Database Reference
In-Depth Information
Importing data into DynamoDB
Sometimes there might be a use case where you need to move your application from some
database to DynamoDB. In that case, you use the following techniques to get your data up
on DynamoDB.
Importing data from AWS S3
Here again, we need to use EMR and Hive to create external tables and import the data
from S3. First, we need to create a table in Hive that is mapped to a bucket on Amazon S3.
Then, we need to create one more table that would be mapped to a table in DynamoDB, in
which we need to dump this data. And then we can simply run insert into query to import
data to DynamoDB from S3. The following code shows how to import data from the
packt-pub-employee bucket to the Employee table in DynamoDB:
CREATE EXTERNAL TABLE packtPubEmployee_s3 (empid String, yoj
String, department String, salary bigint, manager String)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
LOCATION 's3://packt-pub-employee/employee/';
CREATE EXTERNAL TABLE packtPubEmployee (empid String, yoj
String, department String, salary bigint, ,manager String)
STORED BY
'org.apache.hadoop.hive.dynamodb.DynamoDBStorageHandler'
TBLPROPERTIES ("dynamodb.table.name" = "Employee",
"dynamodb.column.mapping" =
"empid:empId,yoj:yoj,department:dept,salary:salary,manager:manager");
INSERT OVERWRITE TABLE packtPubEmployee SELECT * FROM
packtPubEmployee_s3;
You can also import data from S3 without specifying the attribute mapping as shown:
CREATE EXTERNAL TABLE packtPubEmployee_s3 (item map<string,
string>)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
LOCATION 's3://packt-pub-employee/employee/';
Search WWH ::




Custom Search