Created
July 7, 2017 21:35
-
-
Save jugyo/7b51d286b2728e426dfb88e627501e01 to your computer and use it in GitHub Desktop.
A patch to add a method Gogole::Cloud::Bigquery::Dataset#create_time_partitioned_table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Google | |
module Cloud | |
module Bigquery | |
class Dataset | |
def create_time_partitioned_table table_id, name: nil, description: nil, type: 'DAY', expiration_ms: nil | |
ensure_service! | |
new_tb = Google::Apis::BigqueryV2::Table.new( | |
table_reference: Google::Apis::BigqueryV2::TableReference.new( | |
project_id: project_id, dataset_id: dataset_id, | |
table_id: table_id), | |
time_partitioning: Google::Apis::BigqueryV2::TimePartitioning.new( | |
type: 'DAY', | |
expiration_ms: expiration_ms)) | |
updater = Table::Updater.new(new_tb).tap do |tb| | |
tb.name = name unless name.nil? | |
tb.description = description unless description.nil? | |
end | |
yield updater if block_given? | |
gapi = service.insert_table dataset_id, updater.to_gapi | |
Table.from_gapi gapi, service | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment