Skip to content

fix: support JSON and STRUCT for bbq.sql_scalar #1754

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

Merged
merged 3 commits into from
May 21, 2025

Conversation

chelsea-lin
Copy link
Contributor

Fixes internal issue 416015997🦕

@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. labels May 20, 2025
@chelsea-lin chelsea-lin force-pushed the main_chelsealin_sqlscalar branch from cdd2edd to 7244c33 Compare May 20, 2025 23:47
@chelsea-lin chelsea-lin marked this pull request as ready for review May 21, 2025 02:26
@chelsea-lin chelsea-lin requested review from a team as code owners May 21, 2025 02:26
@chelsea-lin chelsea-lin requested a review from shobsi May 21, 2025 02:26
literals = [
bigframes.dtypes.bigframes_dtype_to_literal(column.dtype) for column in columns
literals_sql = [
sqlglot_ir._literal(column.values[0], column.dtype).sql(dialect="bigquery")
Copy link
Collaborator

Choose a reason for hiding this comment

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

column.values can be quite expensive. That's going to download everything as a numpy array. Also, it might return NaN if the first row contains null.

Can we keep using bigframes_dtype_to_literal to get representative values for the type?

Copy link
Contributor Author

@chelsea-lin chelsea-lin May 21, 2025

Choose a reason for hiding this comment

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

Good catch! Yes, I've implemented it so that None value generates literal SQL. This simplifies the logic, and it's confirmed by the test_sql_scalar_w_all_scalar_output test. Would you mind double-checking this?

@chelsea-lin chelsea-lin force-pushed the main_chelsealin_sqlscalar branch from 7244c33 to 84fd8fa Compare May 21, 2025 20:14
@chelsea-lin chelsea-lin requested a review from tswast May 21, 2025 20:16
@chelsea-lin chelsea-lin force-pushed the main_chelsealin_sqlscalar branch from 8384f2d to 97b49e0 Compare May 21, 2025 20:27
@chelsea-lin chelsea-lin merged commit 190390b into main May 21, 2025
22 of 24 checks passed
@chelsea-lin chelsea-lin deleted the main_chelsealin_sqlscalar branch May 21, 2025 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants