Module: ActiveRecord::LoadOperations::ClassMethods

Defined in:
lib/active_record/connection_adapters/bigquery_adapter.rb

Instance Method Summary collapse

Instance Method Details

#bigquery_export(bucket_location = nil) ⇒ Object



327
328
329
330
331
332
333
334
# File 'lib/active_record/connection_adapters/bigquery_adapter.rb', line 327

def bigquery_export(bucket_location = nil)
  bucket_location = bucket_location.nil? ? "#{table_name}.json" : bucket_location
  cfg = connection_config
  GoogleBigquery::Jobs.export(cfg[:project],
    cfg[:database],
    table_name,
    "#{cfg[:database]}/#{bucket_location}")
end

#bigquery_importObject



347
348
# File 'lib/active_record/connection_adapters/bigquery_adapter.rb', line 347

def bigquery_import()
end

#bigquery_load(bucket_location = []) ⇒ Object



336
337
338
339
340
341
342
343
344
345
# File 'lib/active_record/connection_adapters/bigquery_adapter.rb', line 336

def bigquery_load(bucket_location = [])
  bucket_location = bucket_location.empty? ? ["#{cfg[:database]}/#{table_name}.json"] : bucket_location
  cfg = connection_config
  fields = columns.map{|o| {name: o.name, type: o.sql_type, mode: "nullable" } }
  GoogleBigquery::Jobs.load(cfg[:project],
    cfg[:database],
    table_name,
    bucket_location,
    fields)
end