Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support parameterized NUMERIC, BIGNUMERIC, STRING, and BYTES types #673

Merged
merged 16 commits into from May 21, 2021

Conversation

@jimfulton
Copy link
Contributor

@jimfulton jimfulton commented May 20, 2021

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #668 馃

Some notes:

  • I verified that the server:
    • enforces STRING maxLen and NUMERIC precision.
    • Enforces scale by truncating values.
  • select * loses type-parameter information. :( but client.list_rows doesn't.
  • I was thinking of trying to make sure that the Decimal objects created in Python matched the NUMERIC parameters, however
    • Because SELECT loses type information, it's mostly unavailable. IDK how often people use list_rows.
    • Because BQ sends data to the client as strings, this mostly just works, however:
      • The strings sent to the client lack trailing zeros. So, for example, given a scale of 2 and a value 123,
        BQ sends 123 rather than 123.00, so the Python Decimal doesn't have the right number of trailing digits.
        This is easy to fix, but incurs some performance overhead. IDK if we want to do this. If we do, we can do it
        in a follow-on PR.
@jimfulton jimfulton changed the title feat: Support parameterized NUMERIC, STRING, and BYTES types. feat: Support parameterized NUMERIC, STRING, and BYTES types May 20, 2021
@google-cla google-cla bot added the cla: yes label May 20, 2021
@jimfulton jimfulton marked this pull request as ready for review May 20, 2021
@jimfulton jimfulton requested review from as code owners May 20, 2021
@jimfulton jimfulton requested review from prash-mi and removed request for May 20, 2021
@jimfulton jimfulton changed the title feat: Support parameterized NUMERIC, STRING, and BYTES types feat: Support parameterized NUMERIC, BIGNUMERIC, STRING, and BYTES types May 20, 2021
Copy link
Contributor

@plamut plamut left a comment

Looks good, just a few minor remarks that were supposed (?) to be caught by the linters.

The only more significant one is about the (non) cleanup in system tests.

Loading

google/cloud/bigquery/schema.py Outdated Show resolved Hide resolved
Loading
google/cloud/bigquery/schema.py Outdated Show resolved Hide resolved
Loading
google/cloud/bigquery/schema.py Outdated Show resolved Hide resolved
Loading
tests/system/test_client.py Outdated Show resolved Hide resolved
Loading
plamut
plamut approved these changes May 21, 2021
Copy link
Contributor

@plamut plamut left a comment

LGTM!

Loading

@plamut plamut merged commit 45421e7 into master May 21, 2021
12 checks passed
Loading
@plamut plamut deleted the riversnake-669-parameterized-schemafield branch May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants