Repository navigation
Send time_partitioning_expiration as an integer number of milliseconds #231
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
Open
lbarrosby
wants to merge
2
commits into
fluent-plugins-nursery:master
Choose a base branch
from
lbarrosby:fix-partition-expiration-integer-ms
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -342,6 +342,55 @@ def test_write_with_auto_create_table | |||||||
| end | ||||||||
| end | ||||||||
|
|
||||||||
| def test_write_with_auto_create_table_time_partitioning_expiration_in_seconds | ||||||||
| driver = create_driver(<<-CONFIG) | ||||||||
| table foo | ||||||||
| email foo@bar.example | ||||||||
| private_key_path /path/to/key | ||||||||
| project yourproject_id | ||||||||
| dataset yourdataset_id | ||||||||
|
|
||||||||
| <buffer> | ||||||||
| @type memory | ||||||||
| </buffer> | ||||||||
|
|
||||||||
| auto_create_table true | ||||||||
| schema_path #{SCHEMA_PATH} | ||||||||
|
|
||||||||
| time_partitioning_type day | ||||||||
| time_partitioning_expiration 2592000 | ||||||||
| CONFIG | ||||||||
|
|
||||||||
| job = nil | ||||||||
| response_stub = stub! | ||||||||
| stub_writer do |writer| | ||||||||
| mock(writer).fetch_load_job(is_a(Fluent::BigQuery::Writer::JobReference)) { response_stub } | ||||||||
| mock(writer).commit_load_job(is_a(String), response_stub) | ||||||||
|
|
||||||||
| mock(writer.client).get_table('yourproject_id', 'yourdataset_id', 'foo') do | ||||||||
| raise Google::Apis::ClientError.new("notFound: Not found: Table yourproject_id:yourdataset_id.foo", status_code: 404) | ||||||||
| end | ||||||||
|
|
||||||||
| mock(writer.client).insert_job('yourproject_id', anything, upload_source: duck_type(:write, :sync, :rewind), content_type: "application/octet-stream") do |_, configuration, _| | ||||||||
| job = configuration | ||||||||
| stub!.job_reference.stub! do |s| | ||||||||
| s.job_id { "dummy_job_id" } | ||||||||
| s.location { "us" } | ||||||||
| end | ||||||||
| end | ||||||||
| end | ||||||||
|
|
||||||||
| driver.run do | ||||||||
| driver.feed("tag", Time.now.to_i, {"a" => "b"}) | ||||||||
| end | ||||||||
|
|
||||||||
| time_partitioning = job[:configuration][:load][:time_partitioning] | ||||||||
| assert_equal({type: "DAY", expiration_ms: 2592000000}, time_partitioning) | ||||||||
|
Contributor
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. NIT: This assertion also passes on master.
Suggested change
|
||||||||
| assert_kind_of(Integer, time_partitioning[:expiration_ms]) | ||||||||
| json = Google::Apis::BigqueryV2::Job::Representation.new(job).to_json(user_options: { skip_undefined: true }) | ||||||||
| assert_equal({"type" => "DAY", "expirationMs" => "2592000000"}, JSON.parse(json)["configuration"]["load"]["timePartitioning"]) | ||||||||
| end | ||||||||
|
|
||||||||
| private | ||||||||
|
|
||||||||
| def create_response_stub(response) | ||||||||
|
|
||||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
SHOULD: This test sends a real request to BigQuery.
fetch_load_jobandcommit_load_jobare not mocked, so the polling timer callsclient.get_jobagainstbigquery.googleapis.com. When I ran it with network access, the API returned 401 and the test passed. Without network access, the chunk is rolled back and written again,get_tableis called twice, and the test fails withRR::Errors::TimesCalledErrorbefore any assertion runs.Could you mock them in this test the same way
test_writedoes? With this change the test passes offline, and it still fails on master with"2592000000.0".