lib/bigquery_migration/action.rb in bigquery_migration-0.1.2 vs lib/bigquery_migration/action.rb in bigquery_migration-0.1.3

- old
+ new

@@ -39,10 +39,11 @@ migrate_table insert preview insert_select copy_table + table_info ]) end def client @client ||= BigqueryMigration.new(@config, @opts) @@ -99,8 +100,26 @@ query: config[:query], destination_table: config[:destination_table], destination_dataset: config[:destination_dataset], write_disposition: config[:write_disposition], ) + end + + def table_info + if config[:prefix] + tables = client.list_tables[:tables].select {|table| table.start_with?(config[:prefix]) } + table_infos = tables.map do |table| + result = client.get_table(table: table) + result.delete(:responses) + result + end + result = { + sum_num_bytes: table_infos.map {|info| info[:num_bytes].to_i }.inject(:+), + sum_num_rows: table_infos.map {|info| info[:num_rows].to_i }.inject(:+), + table_infos: table_infos, + } + else + client.get_table + end end end end