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
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bigquery-client/tables.rb', line 29 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
71 72 73 74 75 76 77 78 |
# File 'lib/bigquery-client/tables.rb', line 71 def delete_table(table) access_api( api_method: bigquery.tables.delete, parameters: { tableId: table } ) end |
#fetch_schema(table) ⇒ Object
16 17 18 |
# File 'lib/bigquery-client/tables.rb', line 16 def fetch_schema(table) fetch_table(table)['schema']['fields'] end |
#fetch_table(table) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/bigquery-client/tables.rb', line 20 def fetch_table(table) access_api( api_method: bigquery.tables.get, parameters: { tableId: table } ) end |
#list_tables(options = {}) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/bigquery-client/tables.rb', line 9 def list_tables( = {}) access_api( api_method: bigquery.tables.list, parameters: ) end |
#patch_table(table, schema) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/bigquery-client/tables.rb', line 43 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 |
# File 'lib/bigquery-client/tables.rb', line 5 def tables( = {}) (list_tables()['tables'] || []).map {|t| t['tableReference']['tableId'] } end |
#update_table(table, schema) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/bigquery-client/tables.rb', line 57 def update_table(table, schema) access_api( api_method: bigquery.tables.update, parameters: { tableId: table }, body_object: { schema: { fields: schema } } ) end |