-
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 1 commit
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,30 @@ 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 | ||
|
||
unless task['range_partitioning']['range']['start'] | ||
raise ConfigError.new "`range_partitioning` must have `range.start` key" | ||
end | ||
unless task['range_partitioning']['range']['end'] | ||
raise ConfigError.new "`range_partitioning` must have `range.end` key" | ||
end | ||
unless task['range_partitioning']['range']['interval'] | ||
raise ConfigError.new "`range_partitioning` must have `range.interval` key" | ||
end | ||
end | ||
|
||
if task['clustering'] | ||
unless task['clustering']['fields'] | ||
raise ConfigError.new "`clustering` must have `fields` key" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this part use
string
instead ofinteger
? As far as I know, range partition uses a number. And we can check the range is valid (start < end
) if we useinteger
.What do you think of this configuration layout?
(Do we need a
range
block?).(This is just my opinion, I want to ask co-maintainers this comment.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the comment! I followed the api documentation. If you prefer integer, I'll change this!
https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#RangePartitioning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed it with 49d2c36.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, @kitagry. Thank you for waiting.
Could you use this layout? (Sorry, we decided to use the original design (except using
integer
instead ofstring
in range values.)and Could you check the range
start
+interval
<end
?If you have any concern, please let me know.
I referenced the
time_partition
configurations.BigQuery API use
embulk configuration
We discussed this using this design document. (Written in Japanese)
After modification, I'll check the partition feature.