-
Notifications
You must be signed in to change notification settings - Fork 306
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
feat: add support for dataset.default_rounding_mode #1688
feat: add support for dataset.default_rounding_mode #1688
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
590d65e
to
cf723d9
Compare
google/cloud/bigquery/dataset.py
Outdated
""" | ||
optional[str]: it could have one of the following possible value. | ||
ROUNDING_MODE_UNSPECIFIED: Unspecified will default to using ROUND_HALF_AWAY_FROM_ZERO. | ||
ROUND_HALF_AWAY_FROM_ZERO: ROUND_HALF_AWAY_FROM_ZERO rounds half values away from zero when applying precision | ||
and scale upon writing of NUMERIC and BIGNUMERIC values. | ||
For Scale: 0 1.1, 1.2, 1.3, 1.4 => 1 1.5, 1.6, 1.7, 1.8, 1.9 => 2 | ||
ROUND_HALF_EVEN: ROUND_HALF_EVEN rounds half values to the nearest even value when applying precision and scale | ||
upon writing of NUMERIC and BIGNUMERIC values. | ||
For Scale: 0 1.1, 1.2, 1.3, 1.4 => 1 1.5 => 2 1.6, 1.7, 1.8, 1.9 => 2 2.5 => 2 | ||
""" |
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 adding the docstring. I think its format is not passing the docs test, see testing logs for more detailed information. Here is an example for docstring format.
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.
done. i fixed it and run nox -s docs
without any error.
""" | ||
return self._properties.get("defaultRoundingMode") | ||
|
||
@default_rounding_mode.setter |
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.
The test coverage is not passing because the setter function is not covered. Could you please also add unit test for this? Thank you!
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.
@Linchin should I modify this test_create_dataset_w_attrs ?
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 think it would be better to add several smaller tests (in parallel to test_create_dataset_with_default_rounding_mode()
as you added), each for a case in our if
conditions. These include:
value
isNone
value
is not a stringvalue
not inpossible_values
value
is inpossible_values
tests/system/test_client.py
Outdated
if kwargs.get("location"): | ||
dataset.location = kwargs.get("location") | ||
if kwargs.get("max_time_travel_hours"): | ||
dataset.max_time_travel_hours = kwargs.get("max_time_travel_hours") |
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 see you have also opened #1683 that covers max_time_travel_hours
. Let's make these changes over there, and confine this PR to only default_rounding_mode
stuff.
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.
@Linchin done. cherry pick the commit to that pull request.
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.
Could you also delete these lines in this PR? Thank you!
@Gaurang033 Thank you for your contribution! The PR looks good except for a few comments that need to be addressed. Please let us know if you need any help with them :) |
dd54292
to
03becfe
Compare
google/cloud/bigquery/dataset.py
Outdated
|
||
Raises: | ||
ValueError: for invalid value types. | ||
|
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.
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.
@Linchin sorry. what change should i make ?
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.
Just remove this line
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.
@Linchin done. made the changes. could you please review again and let me know if I need to make any other changes.
3c57278
to
5d43d87
Compare
5d43d87
to
b063e8a
Compare
There's a mypy test error that's blocking this PR. Created #1705 to fix this. |
Co-authored-by: Lingqing Gan <[email protected]>
Fixes #1687