Class: PatriotGCP::Command::BQCommand

Inherits:
Patriot::Command::Base
  • Object
show all
Includes:
Ext::BigQuery
Defined in:
lib/patriot_gcp/command/bq.rb

Defined Under Namespace

Classes: BigQueryException, GoogleCloudPlatformException

Instance Method Summary collapse

Methods included from Ext::BigQuery

#bq, #bq_load, included

Instance Method Details

#configureObject

See Also:

  • Patriot::Command::Base#configure


18
19
20
21
22
23
24
# File 'lib/patriot_gcp/command/bq.rb', line 18

def configure
  if @name_suffix == _date_
    raise ArgumentError, 'To set _date_ only is not allowed here to avoid job name duplication.'
  end
  @statement = eval_attr(@statement)
  self
end

#executeObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/patriot_gcp/command/bq.rb', line 26

def execute
  @logger.info "start bq"

  ini = IniFile.load(@inifile)
  if ini.nil?
    raise Exception, "inifile not found"
  end

  bigquery_keyfile  = ini["gcp"]["bigquery_keyfile"]

  stat_info = bq(
    bigquery_keyfile,
    @project_id,
    @statement
  )

  @logger.info "statement execution succeeded: #{stat_info}"
  @logger.info "end bq"
end

#job_idObject



13
14
15
# File 'lib/patriot_gcp/command/bq.rb', line 13

def job_id
  "#{command_name}_#{@project_id}_#{@name_suffix}"
end