module Bigqueryid::Base
Inject class methods in BigQuery Model
Public Class Methods
bigquery()
click to toggle source
# File lib/bigqueryid/base.rb, line 27 def self.bigquery @bigquery_connection ||= Google::Cloud::Bigquery.new end
dataset(name)
click to toggle source
# File lib/bigqueryid/base.rb, line 18 def self.dataset(name) self.dataset_name = name end
delete_table()
click to toggle source
# File lib/bigqueryid/base.rb, line 42 def self.delete_table gcloud_table.delete if table_exist? end
flush()
click to toggle source
# File lib/bigqueryid/base.rb, line 46 def self.flush delete_table create_table end
gcloud_table()
click to toggle source
# File lib/bigqueryid/base.rb, line 31 def self.gcloud_table table = table_name table += "$#{Time.now.utc.strftime("%Y%m%d")}" if table_partitioned bigquery.dataset(dataset_name).table(table) end
load_data_from_csv(gs_url)
click to toggle source
# File lib/bigqueryid/base.rb, line 51 def self.load_data_from_csv(gs_url) job = gcloud_table.load gs_url end
run(query_string)
click to toggle source
# File lib/bigqueryid/base.rb, line 55 def self.run(query_string) bigquery.query query_string end
table(name, partitioned: false)
click to toggle source
# File lib/bigqueryid/base.rb, line 22 def self.table(name, partitioned: false) self.table_name = name self.table_partitioned = partitioned end
table_exist?()
click to toggle source
# File lib/bigqueryid/base.rb, line 38 def self.table_exist? gcloud_table ? true : false end