module BigQuery::Tables
Public Instance Methods
create_table(table, schema)
click to toggle source
# File lib/bigquery-client/tables.rb, line 36 def create_table(table, schema) access_api( api_method: bigquery.tables.insert, body_object: { tableReference: { tableId: table }, schema: { fields: schema } } ) end
delete_table(table)
click to toggle source
# File lib/bigquery-client/tables.rb, line 78 def delete_table(table) access_api( api_method: bigquery.tables.delete, parameters: { tableId: table } ) end
fetch_schema(table)
click to toggle source
# File lib/bigquery-client/tables.rb, line 23 def fetch_schema(table) fetch_table(table)['schema']['fields'] end
fetch_table(table)
click to toggle source
# File lib/bigquery-client/tables.rb, line 27 def fetch_table(table) access_api( api_method: bigquery.tables.get, parameters: { tableId: table } ) end
list_tables(options = {})
click to toggle source
# File lib/bigquery-client/tables.rb, line 16 def list_tables(options = {}) access_api( api_method: bigquery.tables.list, parameters: options ) end
patch_table(table, schema)
click to toggle source
# File lib/bigquery-client/tables.rb, line 50 def patch_table(table, schema) access_api( api_method: bigquery.tables.patch, parameters: { tableId: table }, body_object: { schema: { fields: schema } } ) end
tables(options = {})
click to toggle source
# File lib/bigquery-client/tables.rb, line 5 def tables(options = {}) results = [] page_token = nil loop do response = list_tables({ pageToken: page_token }.merge(options)) results += (response['tables'] || []).map {|table| table['tableReference']['tableId'] } return results unless (page_token = response['nextPageToken']) end end
update_table(table, schema)
click to toggle source
# File lib/bigquery-client/tables.rb, line 64 def update_table(table, schema) access_api( api_method: bigquery.tables.update, parameters: { tableId: table }, body_object: { schema: { fields: schema } } ) end