lib/embulk/output/bigquery.rb in embulk-output-bigquery-0.6.5 vs lib/embulk/output/bigquery.rb in embulk-output-bigquery-0.6.6

- old
+ new

@@ -34,10 +34,11 @@ task = { 'mode' => config.param('mode', :string, :default => 'append'), 'auth_method' => config.param('auth_method', :string, :default => 'application_default'), 'json_keyfile' => config.param('json_keyfile', LocalFile, :default => nil), 'project' => config.param('project', :string, :default => nil), + 'destination_project' => config.param('destination_project', :string, :default => nil), 'dataset' => config.param('dataset', :string), 'location' => config.param('location', :string, :default => nil), 'table' => config.param('table', :string), 'dataset_old' => config.param('dataset_old', :string, :default => nil), 'table_old' => config.param('table_old', :string, :default => nil), @@ -133,16 +134,17 @@ if task['json_keyfile'] begin json_key = JSON.parse(task['json_keyfile']) task['project'] ||= json_key['project_id'] rescue => e - raise ConfigError.new "json_keyfile is not a JSON file" + raise ConfigError.new "Parsing 'json_keyfile' failed with error: #{e.class} #{e.message}" end end if task['project'].nil? raise ConfigError.new "Required field \"project\" is not set" end + task['destination_project'] ||= task['project'] if (task['payload_column'] or task['payload_column_index']) and task['auto_create_table'] if task['schema_file'].nil? and task['template_table'].nil? raise ConfigError.new "Cannot guess table schema from Embulk schema with `payload_column` or `payload_column_index`. Either of `schema_file` or `template_table` is required for auto_create_table true" end @@ -164,10 +166,10 @@ raise ConfigError.new "schema_file #{task['schema_file']} is not found" end begin JSON.parse(File.read(task['schema_file'])) rescue => e - raise ConfigError.new "schema_file #{task['schema_file']} is not a JSON file" + raise ConfigError.new "Parsing 'schema_file' #{task['schema_file']} failed with error: #{e.class} #{e.message}" end end if task['path_prefix'].nil? task['path_prefix'] = Tempfile.create('embulk_output_bigquery_') {|fp| fp.path }