fix: NUMERIC vs BIGNUMERIC column type selection based on precision and scale#1165
Open
claytonjroberts wants to merge 5 commits intogoogleapis:mainfrom
Open
fix: NUMERIC vs BIGNUMERIC column type selection based on precision and scale#1165claytonjroberts wants to merge 5 commits intogoogleapis:mainfrom
claytonjroberts wants to merge 5 commits intogoogleapis:mainfrom
Conversation
Contributor
|
As we discussed in #1164, I think we need to verify the precision and scale in two situations:
I think your code change only covers the second. Could you add logic to distinguish between the two and add back the verification for the first? Also, please add unit tests and system test for these specific cases. Thank you! |
ba7e1e9 to
03d2e7d
Compare
Author
|
My code should cover both your cases. If What case am I missing? from dataclasses import dataclass
@dataclass
class FakeType:
precision: int | None
scale: int | None
def numeric_or_bignumeric(type_) -> str:
return (
"NUMERIC"
if (0 <= (type_.precision or 0) - (type_.scale or 0) <= 29)
else "BIGNUMERIC"
)
if __name__ == "__main__":
assert numeric_or_bignumeric(FakeType(29, 0)) == "NUMERIC"
assert numeric_or_bignumeric(FakeType(29, 1)) == "NUMERIC"
assert numeric_or_bignumeric(FakeType(None, None)) == "NUMERIC"
assert numeric_or_bignumeric(FakeType(30, 0)) == "BIGNUMERIC"
assert numeric_or_bignumeric(FakeType(30, 1)) == "NUMERIC"
assert numeric_or_bignumeric(FakeType(30, None)) == "BIGNUMERIC"
assert numeric_or_bignumeric(FakeType(None, 5)) == "BIGNUMERIC"
print("All tests passed!") |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1164 🦕