Module: BigQuery::Tables
- Included in:
- Client
- Defined in:
- lib/bigquery-client/tables.rb
Instance Method Summary collapse
- #create_table(table, schema) ⇒ Object
- #delete_table(table) ⇒ Object
- #fetch_schema(table) ⇒ Object
- #fetch_table(table) ⇒ Object
- #list_tables(options = {}) ⇒ Object
- #patch_table(table, schema) ⇒ Object
- #tables(options = {}) ⇒ Object
- #update_table(table, schema) ⇒ Object
Instance Method Details
#create_table(table, schema) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# 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) ⇒ Object
78 79 80 81 82 83 84 85 |
# 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) ⇒ Object
23 24 25 |
# File 'lib/bigquery-client/tables.rb', line 23 def fetch_schema(table) fetch_table(table)['schema']['fields'] end |
#fetch_table(table) ⇒ Object
27 28 29 30 31 32 33 34 |
# 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 = {}) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/bigquery-client/tables.rb', line 16 def list_tables( = {}) access_api( api_method: bigquery.tables.list, parameters: ) end |
#patch_table(table, schema) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# 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 = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/bigquery-client/tables.rb', line 5 def tables( = {}) results = [] page_token = nil loop do response = list_tables({ pageToken: page_token }.merge()) results += (response['tables'] || []).map {|table| table['tableReference']['tableId'] } return results unless (page_token = response['nextPageToken']) end end |
#update_table(table, schema) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# 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 |