Class: Tumugi::Plugin::BigqueryTableTarget

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/tumugi/plugin/target/bigquery_table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_id: nil, dataset_id:, table_id:, client: nil) ⇒ BigqueryTableTarget

Returns a new instance of BigqueryTableTarget.



16
17
18
19
20
21
22
23
# File 'lib/tumugi/plugin/target/bigquery_table.rb', line 16

def initialize(project_id: nil, dataset_id:, table_id:, client: nil)
  cfg = Tumugi.config.section('bigquery')
  @project_id = project_id || cfg.project_id
  @dataset_id = dataset_id
  @table_id = table_id
  @client = client || Tumugi::Plugin::Bigquery::Client.new(cfg.to_h.merge(project_id: @project_id))
  @table = Tumugi::Plugin::Bigquery::Table.new(project_id: @client.project_id, dataset_id: @dataset_id, table_id: @table_id)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



14
15
16
# File 'lib/tumugi/plugin/target/bigquery_table.rb', line 14

def client
  @client
end

#dataset_idObject (readonly)

Returns the value of attribute dataset_id.



14
15
16
# File 'lib/tumugi/plugin/target/bigquery_table.rb', line 14

def dataset_id
  @dataset_id
end

#project_idObject (readonly)

Returns the value of attribute project_id.



14
15
16
# File 'lib/tumugi/plugin/target/bigquery_table.rb', line 14

def project_id
  @project_id
end

#table_idObject (readonly)

Returns the value of attribute table_id.



14
15
16
# File 'lib/tumugi/plugin/target/bigquery_table.rb', line 14

def table_id
  @table_id
end

Instance Method Details

#exist?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/tumugi/plugin/target/bigquery_table.rb', line 25

def exist?
  @client.table_exist?(@dataset_id, @table_id, project_id: @project_id)
end