Method: BigQuery::Client::Tables#patch_table

Defined in:
lib/big_query/client/tables.rb

#patch_table(tableId, schema = {}) ⇒ Object

Patching a exsiting table

examples:

@bq.patch_table(‘existing_table’, id: { type: ‘INTEGER’, mode: ‘required’ }, price: { type: ‘FLOAT’ }) It should be provide entire schema including the difference between the existing schema Otherwise ‘BigQuery::Errors::BigQueryError: Provided Schema does not match Table’ occur

Parameters:

  • tableId (String)

    table id to insert into

  • schema (Hash) (defaults to: {})

    name => opts hash for the schema



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/big_query/client/tables.rb', line 108

def patch_table(tableId, schema={})
  api(
    api_method: @bq.tables.patch,
    parameters: { 'tableId' => tableId,
                  'datasetId' => @dataset },
    body_object: { 'tableReference' => {
                      'tableId' => tableId,
                      'projectId' => @project_id,
                      'datasetId' => @dataset
                    },
                    'schema' => {
                      'fields' => validate_schema(schema)
                    }
                  }
  )
end