Skip to content

feat: add bigframes.bigquery.aead.* scalar functions#17168

Merged
tswast merged 25 commits into
mainfrom
tswast-bbq-gen
May 20, 2026
Merged

feat: add bigframes.bigquery.aead.* scalar functions#17168
tswast merged 25 commits into
mainfrom
tswast-bbq-gen

Conversation

@tswast
Copy link
Copy Markdown
Contributor

@tswast tswast commented May 18, 2026

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 #<issue_number_goes_here> 🦕

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new configuration file, aead.yaml, which defines several GoogleSQL scalar functions for AEAD encryption and decryption, including aead.decrypt_bytes, aead.decrypt_string, aead.encrypt, and their envelope counterparts. I have no feedback to provide.

@tswast
Copy link
Copy Markdown
Contributor Author

tswast commented May 19, 2026

@tswast tswast marked this pull request as ready for review May 19, 2026 17:14
@tswast tswast requested review from a team as code owners May 19, 2026 17:14
@tswast tswast requested review from sycai and removed request for a team May 19, 2026 17:14
Comment thread packages/bigframes/bigframes/core/sentinels.py
Comment thread packages/bigframes/scripts/generate_bigframes_bigquery.py Outdated
Comment thread packages/bigframes/tests/unit/bigquery/_operations/conftest.py Outdated
Comment thread packages/bigframes/scripts/data/sql-functions/aead.yaml


def decrypt_bytes(
keyset: Union[T, bigframes.core.col.Expression, Union[bytes, dict]],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this "bigframes.core.col.Expression" necessary, given that it's already included in "T"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. My intention is to allow a mix of types. Basically, a mix of Series and Expression should give Series. Just Expression should give Expression.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see your point. How about ditching the generic type entirely and spell out all possible types in the type hints? I don't think "T" brings us any significant advantages here. Plus, it makes mypy unhappy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It does bring a big advantage: mypy can determine when all are series, that it should return a series. The alternative is to return a Union type, but then we'd have to cast any time we use one of these functions.

@tswast tswast requested a review from sycai May 19, 2026 22:10
cast(bpd.Series, scalar_types_df["{{ arg.col_name }}"]),
{% endfor %}
).to_frame()
snapshot.assert_match(result.sql.rstrip() + "\n", "out.sql")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: an empty line before the assert_match to demarcate the "act" and "assert" block

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@tswast tswast merged commit a7e4d04 into main May 20, 2026
31 checks passed
@tswast tswast deleted the tswast-bbq-gen branch May 20, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants