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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Previously correct translation of ArrayJoin is now broken for various dialects #3119

Closed
cpcloud opened this issue Mar 11, 2024 · 3 comments · Fixed by #3120
Closed

Previously correct translation of ArrayJoin is now broken for various dialects #3119

cpcloud opened this issue Mar 11, 2024 · 3 comments · Fixed by #3120
Assignees

Comments

@cpcloud
Copy link
Contributor

cpcloud commented Mar 11, 2024

Fully reproducible code snippet

In [12]: import sqlglot as sg, sqlglot.expressions as sge

In [13]: sg.__version__
Out[13]: '22.3.1'

In [14]: sge.ArrayJoin(this=sg.column("arg"), expression=sg.column("sep")).sql("bigquery")
Out[14]: 'ARRAY_JOIN(arg, sep)'

Interestingly, when I parse the result I get an ArrayJoin instance and calling .sql on the result of parse_one generates the correct code, but constructing the object directly generates incorrect code:

In [20]: sg.parse_one("select array_to_string(arg, sep)", read="bigquery")
Out[20]:
Select(
  expressions=[
    ArrayJoin(
      this=Column(
        this=Identifier(this=arg, quoted=False)),
      expression=Column(
        this=Identifier(this=sep, quoted=False)))])

In [21]: sg.parse_one("select array_to_string(arg, sep)", read="bigquery").sql("bigquery")
Out[21]: 'SELECT array_to_string(arg, sep)'

Official Documentation

E.g., BigQuery has no function called array_join: https://cloud.google.com/bigquery/docs/reference/standard-sql/array_functions

@georgesittas georgesittas self-assigned this Mar 11, 2024
@georgesittas
Copy link
Collaborator

@cpcloud what other dialects besides bigquery are broken?

@cpcloud
Copy link
Contributor Author

cpcloud commented Mar 11, 2024

I think you covered the ones we care about in Ibis!

@georgesittas
Copy link
Collaborator

Thanks for checking and apologies for the trouble, should've tested better. These _sql_names changes are easy to overlook!

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 a pull request may close this issue.

2 participants