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



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

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



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

def bigquery_import()
end

#bigquery_load(bucket_location = []) ⇒ Object



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

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