27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/tumugi/plugin/task/bigquery_export.rb', line 27
def run
unless output.is_a?(Tumugi::Plugin::FileSystemTarget)
raise Tumugi::TumugiError.new("BigqueryExportTask#output must be return a instance of Tumugi::Plugin::FileSystemTarget")
end
client = Tumugi::Plugin::Bigquery::Client.new(config)
table = Tumugi::Plugin::Bigquery::Table.new(project_id: client.project_id, dataset_id: dataset_id, table_id: table_id)
job_project_id = client.project_id if job_project_id.nil?
log "Source: #{table}"
log "Destination: #{output}"
if is_gcs?(output)
export_to_gcs(client)
else
if destination_format.upcase == 'AVRO'
raise Tumugi::TumugiError.new("destination_format='AVRO' is only supported when export to Google Cloud Storage")
end
if compression.upcase == 'GZIP'
logger.warn("compression parameter is ignored, it's only supported when export to Google Cloud Storage")
end
export_to_file_system(client)
end
end
|