title: Create DynamoDB tables using Hive
body: <p>I have in my cloud, inside a S3 bucket, a CSV file with some data.</p>
  
  <p>I would like to export that data into a DynamoDB table with columns "key" and "value".</p>
  
  <p>Here's the current hive script I wrote:</p>
  
  <pre><code>CREATE EXTERNAL TABLE FromCSV(key string, value string)
  ROW FORMAT DELIMITED FIELDS TERMINATED BY ', '
  LOCATION 's3://mybucket/output/';                    
  
  CREATE EXTERNAL TABLE hiveTransfer(col1 string, col2 string)
  STORED BY 'org.apache.hadoop.hive.dynamodb.DynamoDBStorageHandler' 
  TBLPROPERTIES ("dynamodb.table.name" = "InvertedIndex", 
  "dynamodb.column.mapping" = "col1:key,col2:value");  
  
  INSERT OVERWRITE TABLE hiveTransfer SELECT * FROM FromCSV;
  </code></pre>
  
  <p>Now, basically the script works. though I would like to make some modifications to this script as follows:</p>
  
  <p>1) The script works only if the table "InvertedIndex" already exists in DynamoDB, I would like the script to create the new table by itself and then put the data as it already does.</p>
  
  <p>2) In the CSV the key is always a string but I have 2 kinds of values, string or integer. I would like the script to distinguish between the two and make two different tables.</p>
  
  <p>Any help with those two modifications will be appriciated.
  Thank you</p>