Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(sql): unparse array_has as ANY for Postgres#20654

Open
vimeh wants to merge 1 commit intoapache:mainfrom
vimeh:vinay/any-array-has-postgres
Open

feat(sql): unparse array_has as ANY for Postgres#20654
vimeh wants to merge 1 commit intoapache:mainfrom
vimeh:vinay/any-array-has-postgres

Conversation

@vimeh
Copy link

@vimeh vimeh commented Mar 2, 2026

Which issue does this PR close?

Rationale for this change

PostgreSQL does not have an array_has() function. When the SQL unparser emits array_has(haystack, needle) for the Postgres dialect, it produces invalid SQL. The idiomatic equivalent is needle = ANY(haystack).

What changes are included in this PR?

Adds a scalar_function_to_sql_overrides entry in PostgreSqlDialect that converts array_has(haystack, needle) to needle = ANY(haystack) via ast::Expr::AnyOp.

Are these changes tested?

Yep, with a unit test comparing default vs Postgres dialect output and a roundtrip integration test for = ANY() in a WHERE clause.

Are there any user-facing changes?

No breaking changes. array_has expressions are now unparsed as valid Postgres syntax when using PostgreSqlDialect.

PostgreSQL does not have an array_has() function — it uses the
`= ANY(array)` operator for array containment checks. Without this
dialect override, SQL unparsed for Postgres federation produces
invalid syntax. This converts array_has(haystack, needle) to
needle = ANY(haystack) in the PostgreSqlDialect.
@github-actions github-actions bot added the sql SQL Planner label Mar 2, 2026
@vimeh vimeh changed the title sql: unparse array_has as ANY for Postgres fix(sql): unparse array_has as ANY for Postgres Mar 2, 2026
@vimeh vimeh changed the title fix(sql): unparse array_has as ANY for Postgres feat(sql): unparse array_has as ANY for Postgres Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sql SQL Planner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unparse array_has as = ANY() for PostgreSQL dialect

1 participant