module Flydata module TableDef class RedshiftTableDef TYPE_MAP_F2R = { 'binary' => {type: 'varchar', use_params: true}, 'char' => {type: 'char', use_params: true}, 'date' => {type: 'date'}, 'datetime' => {type: 'timestamp'}, 'enum' => {type: 'varchar encode bytedict'}, 'float4' => {type: 'float4'}, 'float4 unsigned' => {type: 'float4'}, 'float8' => {type: 'float8'}, 'float8 unsigned' => {type: 'float8'}, 'int1' => {type: 'int2'}, 'int1 unsigned' => {type: 'int2', unsigned: true}, 'int2' => {type: 'int2'}, 'int2 unsigned' => {type: 'int4', unsigned: true}, 'int3' => {type: 'int4'}, 'int3 unsigned' => {type: 'int4', unsigned: true}, 'int4' => {type: 'int4'}, 'int4 unsigned' => {type: 'int8', unsigned: true}, 'int8' => {type: 'int8'}, 'int8 unsigned' => {type: 'numeric(20,0)', unsigned: true}, 'numeric' => {type: 'numeric', use_params: true, max_size: [38,37]}, 'numeric unsigned' => {type: 'numeric', use_params: true, max_size: [38,37]}, 'text' => {type: 'varchar(max)'}, 'time' => {type: 'timestamp'}, 'varbinary' => {type: 'varchar', use_params: true, max_size: 65535}, 'varchar' => {type: 'varchar', use_params: true, max_size: 65535}, } def self.from_flydata_tabledef(flydata_tabledef, options = {}) options[:flydata_ctl_table] = true unless options.has_key?(:flydata_ctl_table) tabledef = "" tabledef += create_flydata_ctl_table_sql if options[:flydata_ctl_table] tabledef += create_table_sql(flydata_tabledef) tabledef += comment_sql(flydata_tabledef) tabledef += flydata_ctl_sql(flydata_tabledef) end CREATE_FLYDATA_CTL_TABLE_SQL = < max_size_a[i].to_i ? max_size_a[i] : param) end final_params.join(",") end end end end