Class: PatriotGCP::Command::LoadToBigQueryCommand
- Inherits:
-
Patriot::Command::Base
- Object
- Patriot::Command::Base
- PatriotGCP::Command::LoadToBigQueryCommand
show all
- Includes:
- Ext::BigQuery
- Defined in:
- lib/patriot_gcp/command/load_to_bigquery.rb
Defined Under Namespace
Classes: BigQueryException, GoogleCloudPlatformException
Instance Method Summary
collapse
#bq, #bq_load, included
Instance Method Details
18
19
20
21
|
# File 'lib/patriot_gcp/command/load_to_bigquery.rb', line 18
def configure
@name_suffix ||= _date_
self
end
|
#execute ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/patriot_gcp/command/load_to_bigquery.rb', line 23
def execute
@logger.info "start load_to_bigquery"
ini = IniFile.load(@inifile)
if ini.nil?
raise Exception, "inifile not found"
end
bigquery_keyfile = ini["gcp"]["bigquery_keyfile"]
unless @input_file.start_with? 'gs://'
unless File.exist?(@input_file)
raise Exception, "The given file doesn't exist."
end
unless File.size?(@input_file)
@logger.warn "The target file is empty"
return
end
end
@logger.info "start loading"
stat_info = bq_load(@input_file,
bigquery_keyfile,
@project_id,
@dataset,
@table,
@schema,
@options,
@polling_interval)
@logger.info "load succeeded: #{stat_info}"
@logger.info "end load_to_bigquery"
end
|
#job_id ⇒ Object
13
14
15
|
# File 'lib/patriot_gcp/command/load_to_bigquery.rb', line 13
def job_id
"#{command_name}_#{@project_id}_#{@dataset}_#{@table}_#{@name_suffix}"
end
|