Skip to content

Infer placeholder type from ANY/ALL subquery, unit tests#22545

Open
HairstonE wants to merge 1 commit into
apache:mainfrom
HairstonE:fix/22475-placeholder-set-comparison
Open

Infer placeholder type from ANY/ALL subquery, unit tests#22545
HairstonE wants to merge 1 commit into
apache:mainfrom
HairstonE:fix/22475-placeholder-set-comparison

Conversation

@HairstonE
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #22475.

Rationale for this change

$1 = ANY (SELECT ...) and $1 <> ALL (SELECT ...) left the placeholder untyped because infer_placeholder_types had no arm for SetComparison.

What changes are included in this PR?

Adds the SetComparison arm to infer_placeholder_types, reading the type from the subquery's projected column. Covers all quantifiers (ANY, ALL) and comparison operators.

How are these changes tested?

Unit tests for ANY and ALL placeholder inference, plus end-to-end sqllogictests with PREPARE/EXECUTE.

Are there any user-facing changes?

No.

@github-actions github-actions Bot added the logical-expr Logical plan and expressions label May 26, 2026
@Omega359
Copy link
Copy Markdown
Contributor

I do not see any slt tests as part of this pr? I had codex write some and they seem to fail on the branch with "Schema error: Schema contains duplicate unqualified field name mark" in optimize_projections.

# Allow prepare $1 = ANY (subquery)
statement ok
PREPARE my_plan AS SELECT id FROM person WHERE $1 = ANY (SELECT age FROM person);

query I rowsort
EXECUTE my_plan(20);
----
1

query I rowsort
EXECUTE my_plan(99);
----

statement ok
DEALLOCATE my_plan

# Allow prepare $1 <> ALL (subquery)
statement ok
PREPARE my_plan AS SELECT id FROM person WHERE $1 <> ALL (SELECT age FROM person);

query I rowsort
EXECUTE my_plan(99);
----
1

query I rowsort
EXECUTE my_plan(20);
----

statement ok
DEALLOCATE my_plan

@HairstonE
Copy link
Copy Markdown
Contributor Author

@Omega359 Thanks for the review. I ran into the same Schema Error on main when looking into this. The slt tests would fail because of #22477 , so I stuck with unit tests to verify the implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

logical-expr Logical plan and expressions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Placeholder datatype not inferred for Expr::Comparison (ANY/ALL)

2 participants