require 'flydata/table_meta' require 'flydata-core/oracle/oracle_client' require 'flydata-core/table_def/oracle_table_def' module Flydata module SourceOracle # Fetch and keep table meta information # # : # table_name: # Table name # table_schema: or nil # Schema name # primary_keys: # Set primary key names. ex: ['group_id', 'category_id'] # pk_positions: # Set the ordinal position of primary keys. ex: [1, 3] # max_row_size: # byte, calculated based on column size # max_num_rows_per_query>: # max number of rows per query # raw_columns: # raw information schema data # columns: table_def.columns # table_def: # columns: # table: # column: # type: # not_null: # primary_key: # default: # column_size: (new) # Set in `OracleTableDef.parse_one_column_def` # class TableMeta < Flydata::TableMeta GET_TABLE_META_SQL = <][:raw_columns] while (col = columns.fetch_hash) column_name = col['COLUMN_NAME'].to_sym table_name = col['TABLE_NAME'].to_sym t_meta = ret[table_name] t_meta[:raw_columns] = Hash.new {|h,k| h[k] = []} unless t_meta[:raw_columns] t_meta[:raw_columns][column_name] << col end ret.each do |table_name, t_meta| begin table_def = FlydataCore::TableDef::OracleTableDef.create( t_meta[:raw_columns].values, @options) rescue FlydataCore::TableDefError => e t_meta.merge!( table_name: table_name, table_def_err: e, ) # Skip when getting an error when parsing the columns next end primary_keys = [] pk_positions = [] table_def.columns.each.with_index(1) do |col, index| col_name = col[:column] if col["CONSTRAINT_TYPE"] == 'P' primary_keys << col_name pk_positions << index.to_s end end t_meta.merge!( table_name: table_name.to_s, table_schema: @schema, primary_keys: primary_keys, pk_positions: pk_positions, max_num_rows_per_query: DEFAULT_MAX_FETCH_RECORD_SIZE, columns: table_def.columns, table_def: table_def, ) end ret end def calc_column_size(column) #TODO: Implement the check logic based on column type 124 end end end end