-
Notifications
You must be signed in to change notification settings - Fork 60
feat: Add range partitioning support #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
in: | ||
type: file | ||
path_prefix: example/example.csv | ||
parser: | ||
type: csv | ||
charset: UTF-8 | ||
newline: CRLF | ||
null_string: 'NULL' | ||
skip_header_lines: 1 | ||
comment_line_marker: '#' | ||
columns: | ||
- {name: date, type: string} | ||
- {name: timestamp, type: timestamp, format: "%Y-%m-%d %H:%M:%S.%N", timezone: "+09:00"} | ||
- {name: "null", type: string} | ||
- {name: long, type: long} | ||
- {name: string, type: string} | ||
- {name: double, type: double} | ||
- {name: boolean, type: boolean} | ||
out: | ||
type: bigquery | ||
mode: replace | ||
auth_method: service_account | ||
json_keyfile: example/your-project-000.json | ||
dataset: your_dataset_name | ||
table: your_field_partitioned_table_name | ||
source_format: NEWLINE_DELIMITED_JSON | ||
compression: NONE | ||
auto_create_dataset: true | ||
auto_create_table: true | ||
schema_file: example/schema.json | ||
range_partitioning: | ||
field: 'long' | ||
range: | ||
start: 90 | ||
end: 100 | ||
interval: 1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,7 @@ def self.configure(config, schema, task_count) | |
'ignore_unknown_values' => config.param('ignore_unknown_values', :bool, :default => false), | ||
'allow_quoted_newlines' => config.param('allow_quoted_newlines', :bool, :default => false), | ||
'time_partitioning' => config.param('time_partitioning', :hash, :default => nil), | ||
'range_partitioning' => config.param('range_partitioning', :hash, :default => nil), | ||
'clustering' => config.param('clustering', :hash, :default => nil), # google-api-ruby-client >= v0.21.0 | ||
'schema_update_options' => config.param('schema_update_options', :array, :default => nil), | ||
|
||
|
@@ -231,10 +232,43 @@ def self.configure(config, schema, task_count) | |
unless task['time_partitioning']['type'] | ||
raise ConfigError.new "`time_partitioning` must have `type` key" | ||
end | ||
elsif Helper.has_partition_decorator?(task['table']) | ||
# If user specify range_partitioning, it should be used as is | ||
elsif Helper.has_partition_decorator?(task['table']) && task['range_partitioning'].nil? | ||
|
||
task['time_partitioning'] = {'type' => 'DAY'} | ||
end | ||
|
||
if task['range_partitioning'] | ||
unless task['range_partitioning']['field'] | ||
raise ConfigError.new "`range_partitioning` must have `field` key" | ||
end | ||
unless task['range_partitioning']['range'] | ||
raise ConfigError.new "`range_partitioning` must have `range` key" | ||
end | ||
|
||
range = task['range_partitioning']['range'] | ||
unless range['start'] | ||
raise ConfigError.new "`range_partitioning` must have `range.start` key" | ||
end | ||
unless range['start'].is_a?(Integer) | ||
raise ConfigError.new "`range_partitioning.range.start` must be an integer" | ||
end | ||
unless range['end'] | ||
raise ConfigError.new "`range_partitioning` must have `range.end` key" | ||
end | ||
unless range['end'].is_a?(Integer) | ||
raise ConfigError.new "`range_partitioning.range.end` must be an integer" | ||
end | ||
unless range['interval'] | ||
raise ConfigError.new "`range_partitioning` must have `range.interval` key" | ||
end | ||
unless range['interval'].is_a?(Integer) | ||
raise ConfigError.new "`range_partitioning.range.interval` must be an integer" | ||
end | ||
if range['start'] + range['interval'] > range['end'] | ||
kitagry marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
raise ConfigError.new "`range_partitioning.range.start` + `range_partitioning.range.interval` must be less than `range_partitioning.range.end`" | ||
end | ||
end | ||
|
||
if task['clustering'] | ||
unless task['clustering']['fields'] | ||
raise ConfigError.new "`clustering` must have `fields` key" | ||
|
Uh oh!
There was an error while loading. Please reload this page.