-
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? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you elaborate on this part? IIUC I can't understand In my opinion, these checks are preferable. # can't use two partitions config at the same time.
if task['time_partitioning'] && task['range_partitioning']
raise ConfigError.new ...
end
# partition decrator doesn't support range_partition (if needed)
if Helper.has_partition_decorator?(task['table']) && task['range_partitioning']
raise ConfigError.new ...
end There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for the review. I think that the following code would be preferable. if Helper.has_partition_decorator?(task['table'])
task['time_partitioning'] = {'type' => 'DAY'}
end
if task['time_partitioning'] && task['range_partitioning']
raise ConfigError.new ...
end There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, the error message would be confusing. I fix like e9cc945. Could you check this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (This is just a double check.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I use like following. Users who use partition decorator may be confused, because he don't use time_partitioning.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, you mean if the user uses the following configuration, the user may confuse the storage message. correct?
|
||
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.
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.