Class: BigqueryMigration::TableData
- Inherits:
-
Object
- Object
- BigqueryMigration::TableData
- Defined in:
- lib/bigquery_migration/table_data.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
-
#initialize(columns, rows) ⇒ TableData
constructor
A new instance of TableData.
- #logger ⇒ Object
-
#values ⇒ Object
format list_table_data response rows which is like.
Constructor Details
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
6 7 8 |
# File 'lib/bigquery_migration/table_data.rb', line 6 def columns @columns end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
6 7 8 |
# File 'lib/bigquery_migration/table_data.rb', line 6 def rows @rows end |
Instance Method Details
#logger ⇒ Object
8 9 10 |
# File 'lib/bigquery_migration/table_data.rb', line 8 def logger BigqueryMigration.logger end |
#values ⇒ Object
format list_table_data response rows which is like
[
{ f: [
{ v: "foo" },
{ v: "1" },
{ v: [] },
{ v: "1.1" },
{ v: "true" },
{ v: "1.444435200E9" }
] },
{ f: [
{ v: "foo" },
{ v: "2" },
{ v: [
{ v: "foo" },
{ v: "bar" }
] },
{ v: "2.2" },
{ v: "false" },
{ v: "1.444435200E9" }
] }
]
into
[
# first row
[
[ "foo", "1", nil, "1.1", "true", "1.444435200E9" ]
],
# second row
[
[ "foo", "2", "foo", "2.2", "false", "1.444435200E9" ],
[ nil, nil, "bar", nil, nil, nil ],
],
]
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/bigquery_migration/table_data.rb', line 54 def values values = @rows.map do |row| repeated_count = repeated_count(columns: @columns, rows: row) formatted_row = [] repeated_count.times do |count| formatted_row << format_row(columns: @columns, rows: row, count: count) end formatted_row end # flattern if there is no repeated column for backward compatibility values.map(&:length).max > 1 ? values : values.flatten(1) end |