Module: BigQuery::Tabledata

Included in:
Client
Defined in:
lib/bigquery-client/tabledata.rb

Instance Method Summary collapse

Instance Method Details

#insert(table, args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/bigquery-client/tabledata.rb', line 5

def insert(table, args)
  rows = args.is_a?(Array) ? args : [args]
  result = access_api(
    api_method: bigquery.tabledata.insert_all,
    parameters: {
      tableId: table
    },
    body_object: {
      rows: rows.map { |row| { json: row } }
    }
  )
  handle_error(result) if result.error?
end