Class: Trinamo::DynamodbConverter
- Inherits:
-
BaseConverter
- Object
- BaseConverter
- Trinamo::DynamodbConverter
- Defined in:
- lib/trinamo/converter/dynamodb_converter.rb
Instance Attribute Summary
Attributes inherited from BaseConverter
Instance Method Summary collapse
Methods inherited from BaseConverter
Constructor Details
This class inherits a constructor from Trinamo::BaseConverter
Instance Method Details
#convert ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/trinamo/converter/dynamodb_converter.rb', line 5 def convert ddl_body = @ddl[:tables].map do |h| fields = ([h[:hash_key]] + [h[:range_key]] + [h[:attributes]]).flatten.compact " -- \#{h[:name]}_ddb\n CREATE EXTERNAL TABLE \#{h[:name]}_ddb (\n \#{fields.map { |attr| \"\#{attr[:name]} \#{attr[:type].upcase}\" }.join(',')}\n )\n STORED BY 'org.apache.hadoop.hive.dynamodb.DynamoDBStorageHandler'\n TBLPROPERTIES (\n 'dynamodb.table.name' = '\#{h[:name]}',\n 'dynamodb.column.mapping' = '\#{fields.map { |attr| \"\#{attr[:name]}:\#{attr[:name]}\" }.join(',') }'\n );\n DDL\n end\n\n ddl_body.join(\"\\n\")\nend\n".unindent |