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(',')})" : '' <<-DDL.unindent -- #{h[:name]}_s3 CREATE EXTERNAL TABLE #{h[:name]}_s3 ( #{fields.map { |attr| "#{attr[:name]} #{attr[:type].upcase}" }.join(',')} ) #{partitioned_by} ROW FORMAT DELIMITED FIELDS TERMINATED BY '\\t' LINES TERMINATED BY '\\n' LOCATION '#{h[:s3_location]}'; DDL else STDERR.puts "[ERROR] The location of #{h[:name]}_s3 is not found" nil end end ddl_body.compact.join("\n") end |