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

Postgres Array Operators are unsupported expressions #2903

Closed
richard-merrick opened this issue Feb 1, 2024 · 0 comments
Closed

Postgres Array Operators are unsupported expressions #2903

richard-merrick opened this issue Feb 1, 2024 · 0 comments

Comments

@richard-merrick
Copy link

Parsing postgres dialect SQL which contains array operators returns ValueError (Unsupported expression type)

Tested in sqlglot ==20.11.0
Affects at least ArrayOverlaps and ArrayContains

(https://www.postgresql.org/docs/current/functions-array.html)

from sqlglot import parse_one 

sql = "SELECT ARRAY[1,2,3] && ARRAY[2,3,4] FROM table_xyz;"

x = parse_one(sql, read='postgres')

print(x)
Traceback (most recent call last):
  File "./temp.py", line 8, in <module>
    print(x)
  File "./env/lib/python3.10/site-packages/sqlglot/expressions.py", line 501, in __str__
    return self.sql()
  File "./env/lib/python3.10/site-packages/sqlglot/expressions.py", line 526, in sql
    return Dialect.get_or_raise(dialect).generate(self, **opts)
  File "./env/lib/python3.10/site-packages/sqlglot/dialects/dialect.py", line 452, in generate
    return self.generator(**opts).generate(expression, copy=copy)
  File "./env/lib/python3.10/site-packages/sqlglot/generator.py", line 492, in generate
    sql = self.sql(expression).strip()
  File "./env/lib/python3.10/site-packages/sqlglot/generator.py", line 650, in sql
    sql = getattr(self, exp_handler_name)(expression)
  File "./env/lib/python3.10/site-packages/sqlglot/generator.py", line 2062, in select_sql
    expressions = self.expressions(expression)
  File "./env/lib/python3.10/site-packages/sqlglot/generator.py", line 2978, in expressions
    sql = self.sql(e, comment=False)
  File "./env/lib/python3.10/site-packages/sqlglot/generator.py", line 656, in sql
    raise ValueError(f"Unsupported expression type {expression.__class__.__name__}")
ValueError: Unsupported expression type ArrayOverlaps
@tobymao tobymao closed this as completed in ab97246 Feb 1, 2024
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

No branches or pull requests

1 participant