Class: Trinamo::S3Converter
- Inherits:
-
BaseConverter
- Object
- BaseConverter
- Trinamo::S3Converter
- Defined in:
- lib/trinamo/converter/s3_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 23 24 25 |
# File 'lib/trinamo/converter/s3_converter.rb', line 5 def convert ddl_body = @ddl[:tables].map do |h| if h[:s3_location] fields = ([h[:hash_key]] + [h[:range_key]] + [h[:attributes]]).flatten.compact partitioned_by = h[:s3_partition] ? "PARTITIONED BY (#{h[:s3_partition].map { |attr| "#{attr[:name]} #{attr[:type].upcase}" }.join(',')})" : '' " -- \#{h[:name]}_s3\n CREATE EXTERNAL TABLE \#{h[:name]}_s3 (\n \#{fields.map { |attr| \"\#{attr[:name]} \#{attr[:type].upcase}\" }.join(',')}\n ) \#{partitioned_by}\n ROW FORMAT DELIMITED FIELDS TERMINATED BY '\\\\t' LINES TERMINATED BY '\\\\n'\n LOCATION '\#{h[:s3_location]}';\n DDL\n else\n STDERR.puts \"[ERROR] The location of \#{h[:name]}_s3 is not found\"\n nil\n end\n end\n\n ddl_body.compact.join(\"\\n\")\nend\n".unindent |