Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add JSON type, bindparam support#1147

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
r1b wants to merge5 commits intogoogleapis:main
base:main
Choose a base branch
Loading
fromr1b:feat/json-support-inc-type

Conversation

@r1b
Copy link

@r1br1b commentedDec 10, 2024
edited
Loading

Extracted from#1146, this is a smaller set of changes that establish a JSON type.

Changes:

  • Export a JSON type
  • Acceptjson_serializer /json_deserializer dialect kwargs
  • Handle JSON bind parameters
  • Tests

Once this is merged, users will be able to:

  • Define tables with JSON columns
  • Reference JSON columns in expressions
  • Submit JSON query parameters (as STRINGs, with output conversion back to JSON)

In future PRs, we can add support for:

  • JSON comparator conversion functions (BOOL / LAX_BOOL, etc.)
  • JSON indexing operations

Fixes#399 🦕

@r1br1b requested review froma team ascode ownersDecember 10, 2024 23:38
@product-auto-labelproduct-auto-labelbot added size: mPull request size is medium. api: bigqueryIssues related to the googleapis/python-bigquery-sqlalchemy API. labelsDec 10, 2024
Comment on lines +5 to +8
defbind_expression(self,bindvalue):
# JSON query parameters have type STRING
# This hook ensures that the rendered expression has type JSON
returnsqlalchemy.func.PARSE_JSON(bindvalue,type_=self)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

note An alternative here would be to just preserve the STRING type and let BigQuery handle the cast, but this seems hard to reason about. It feels right to have the expression type in BigQuery match the expression type here in SQLAlchemy.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looking at [1] and pondering this - it wouldn't be that surprising if a user wanted to submitinvalid JSON as a query parameter at some point. This could be supported by parameterizing this behavior in the type, i.e:JSON(strict=False) or similar. Not worried about it right now, though.

[1]https://cloud.google.com/bigquery/docs/reference/standard-sql/json_functions#non-validation_of_string_inputs

Comment on lines +1100 to +1101
json_serializer=None,
json_deserializer=None,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@alvarowolfxalvarowolfxAwaiting requested review from alvarowolfxalvarowolfx was automatically assigned from googleapis/api-bigquery

At least 1 approving review is required to merge this pull request.

Assignees

@farhan0102farhan0102

Labels

api: bigqueryIssues related to the googleapis/python-bigquery-sqlalchemy API.size: mPull request size is medium.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Add support for JSON datatype

2 participants

@r1b@farhan0102

[8]ページ先頭

©2009-2025 Movatter.jp