-
Notifications
You must be signed in to change notification settings - Fork 608
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
refactor(bigquery): port to sqlglot #7968
Conversation
e848153
to
ee8547d
Compare
BigQuery tests are passing:
|
457f9f5
to
6603c80
Compare
ecf083f
to
91087ec
Compare
e7205ce
to
5b4721f
Compare
ad5f6d0
to
18ef5e3
Compare
BigQuery tests are passing:
|
871d4f4
to
a607fea
Compare
BigQuery tests passing after rebase:
|
ibis/backends/bigquery/tests/unit/udf/snapshots/test_builtin/test_bqutil_fn_from_hex/out.sql
Outdated
Show resolved
Hide resolved
6ae24df
to
9a2ed28
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard to review every line, but overall looking great.
P.S. I tried to run this against googleapis/python-bigquery-dataframes#277 more-or-less unchanged, but still having issues related to #7632. I think I'll probably need #7781 before BigQuery DataFrames can migrate.
ibis/backends/bigquery/tests/system/snapshots/test_client/test_cross_project_query/out.sql
Show resolved
Hide resolved
BigQuery passing:
|
f767c67
to
c887e8b
Compare
bf5d359
to
8a44d75
Compare
BigQuery passing:
|
…or types for datatype conversion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Description of changes
This PR ports the BigQuery dialect to sqlglot.
A number of changes were required to make this work:
I removed the
ibis.bigquery.udf
module in favor of the neweribis.expr.operations.udf
-based UDFsAs part of the previous point I removed explicit support for
udf.sql
andudf.js
.udf.sql
was only used in thetypeof
implementation, andudf.js
was only used to implementation Python UDFs.BigQuery has only partial support for
NULL FIRST/LAST
inRANGE
windows:sum(x) over (order by y desc nulls last)
sum(x) over (order by y asc nulls last)
sum(x) over (order by y asc nulls first)
sum(x) over (order by y desc nulls first)
To workaround this while allowing null ordering in
ORDER BY
(which seems towork fine) I added a sqlglot
transform
to remove null ordering in the abovecases that do not work.
I adjusted the generic UDF implementation to allow for redefinitions of the same UDF, which BigQuery allowed. This implementation is the same strategy used by the previous BQ implementation which is to attach a number to the name of every identically-named UDF. For example, if you define
my_udf
twice, the compiled name will bemy_udf_0
wherever the first definition is invoked andmy_udf_1
wherever the second definition is invoked.