Skip to content

feat(optimizer): Optimize constant false filters to empty ValuesTable#1016

Open
marxhxxx wants to merge 2 commits intofacebookincubator:mainfrom
marxhxxx:export-D95446850
Open

feat(optimizer): Optimize constant false filters to empty ValuesTable#1016
marxhxxx wants to merge 2 commits intofacebookincubator:mainfrom
marxhxxx:export-D95446850

Conversation

@marxhxxx
Copy link

@marxhxxx marxhxxx commented Mar 6, 2026

Summary:
Extends addFilter in ToGraph to detect constant false conjuncts in
filter predicates. When the optional output parameter is provided and a
false conjunct is found, replaces the plan with an empty ValuesTable
matching the output schema, avoiding unnecessary table scans for queries
like SELECT * FROM t WHERE false or WHERE 1 > 2.

Differential Revision: D95446850

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 6, 2026
@meta-codesync
Copy link

meta-codesync bot commented Mar 6, 2026

@marxhxxx has exported this pull request. If you are a Meta employee, you can view the originating Diff in D95446850.

marxhxxx pushed a commit to marxhxxx/axiom that referenced this pull request Mar 6, 2026
…facebookincubator#1016)

Summary:

Extends `addFilter` in `ToGraph` to detect constant false conjuncts in
filter predicates. When the optional `output` parameter is provided and a
false conjunct is found, replaces the plan with an empty ValuesTable
matching the output schema, avoiding unnecessary table scans for queries
like `SELECT * FROM t WHERE false` or `WHERE 1 > 2`.

Differential Revision: D95446850
marxhxxx pushed a commit to marxhxxx/axiom that referenced this pull request Mar 6, 2026
…facebookincubator#1016)

Summary:

Extends `addFilter` in `ToGraph` to detect constant false conjuncts in
filter predicates. When the optional `output` parameter is provided and a
false conjunct is found, replaces the plan with an empty ValuesTable
matching the output schema, avoiding unnecessary table scans for queries
like `SELECT * FROM t WHERE false` or `WHERE 1 > 2`.

Differential Revision: D95446850
marxhxxx pushed a commit to marxhxxx/axiom that referenced this pull request Mar 6, 2026
…facebookincubator#1016)

Summary:

Extends `addFilter` in `ToGraph` to detect constant false conjuncts in
filter predicates. When the optional `output` parameter is provided and a
false conjunct is found, replaces the plan with an empty ValuesTable
matching the output schema, avoiding unnecessary table scans for queries
like `SELECT * FROM t WHERE false` or `WHERE 1 > 2`.

Differential Revision: D95446850
marxhxxx pushed a commit to marxhxxx/axiom that referenced this pull request Mar 6, 2026
…facebookincubator#1016)

Summary:

Extends `addFilter` in `ToGraph` to detect constant false conjuncts in
filter predicates. When the optional `output` parameter is provided and a
false conjunct is found, replaces the plan with an empty ValuesTable
matching the output schema, avoiding unnecessary table scans for queries
like `SELECT * FROM t WHERE false` or `WHERE 1 > 2`.

Differential Revision: D95446850
marxhxxx pushed a commit to marxhxxx/axiom that referenced this pull request Mar 6, 2026
…facebookincubator#1016)

Summary:

Extends `addFilter` in `ToGraph` to detect constant false conjuncts in
filter predicates. When the optional `output` parameter is provided and a
false conjunct is found, replaces the plan with an empty ValuesTable
matching the output schema, avoiding unnecessary table scans for queries
like `SELECT * FROM t WHERE false` or `WHERE 1 > 2`.

Differential Revision: D95446850
@marxhxxx marxhxxx force-pushed the export-D95446850 branch 2 times, most recently from aae6bc5 to 89f0369 Compare March 6, 2026 18:36
marxhxxx pushed a commit to marxhxxx/axiom that referenced this pull request Mar 6, 2026
…facebookincubator#1016)

Summary:
Pull Request resolved: facebookincubator#1016

Extends `addFilter` in `ToGraph` to detect constant false conjuncts in
filter predicates. When the optional `output` parameter is provided and a
false conjunct is found, replaces the plan with an empty ValuesTable
matching the output schema, avoiding unnecessary table scans for queries
like `SELECT * FROM t WHERE false` or `WHERE 1 > 2`.

Differential Revision: D95446850
marxhxxx pushed a commit to marxhxxx/axiom that referenced this pull request Mar 6, 2026
…facebookincubator#1016)

Summary:

Extends `addFilter` in `ToGraph` to detect constant false conjuncts in
filter predicates. When the optional `output` parameter is provided and a
false conjunct is found, replaces the plan with an empty ValuesTable
matching the output schema, avoiding unnecessary table scans for queries
like `SELECT * FROM t WHERE false` or `WHERE 1 > 2`.

Differential Revision: D95446850
Shanyue Wan added 2 commits March 10, 2026 11:51
…ator#967)

Summary:

When a JOIN has a constant false conjunct in the ON clause (e.g., `1 > 2`), we can optimize the join based on join type:

Already supported:
- **LEFT JOIN**: Remove the right side and project NULLs for right columns. (already handled)
- **RIGHT JOIN**: Remove the left side and project NULLs for left columns. (already handled)

In this change:
- **FULL JOIN**: Transform into UNION ALL of (left with NULLs for right) and (right with NULLs for left). (NEW)

TODO: INNER JOIN: No rows can ever match, so replace with an empty ValuesTable.

Differential Revision: D94445313
…facebookincubator#1016)

Summary:

Extends `addFilter` in `ToGraph` to detect constant false conjuncts in
filter predicates. When the optional `emptyValuesType` parameter is provided and a
false conjunct is found, replaces the plan with an empty ValuesTable
matching the output schema, avoiding unnecessary table scans for queries
like `SELECT * FROM t WHERE false` or `WHERE 1 > 2`.

Differential Revision: D95446850
marxhxxx pushed a commit to marxhxxx/axiom that referenced this pull request Mar 10, 2026
…facebookincubator#1016)

Summary:

Extends `addFilter` in `ToGraph` to detect constant false conjuncts in
filter predicates. When the optional `emptyValuesType` parameter is provided and a
false conjunct is found, replaces the plan with an empty ValuesTable
matching the output schema, avoiding unnecessary table scans for queries
like `SELECT * FROM t WHERE false` or `WHERE 1 > 2`.

Differential Revision: D95446850
marxhxxx pushed a commit to marxhxxx/axiom that referenced this pull request Mar 10, 2026
…facebookincubator#1016)

Summary:

Extends `addFilter` in `ToGraph` to detect constant false conjuncts in
filter predicates. When the optional `emptyValuesType` parameter is provided and a
false conjunct is found, replaces the plan with an empty ValuesTable
matching the output schema, avoiding unnecessary table scans for queries
like `SELECT * FROM t WHERE false` or `WHERE 1 > 2`.

Differential Revision: D95446850
marxhxxx added a commit to marxhxxx/axiom that referenced this pull request Mar 10, 2026
…facebookincubator#1016)

Summary:
Pull Request resolved: facebookincubator#1016

Extends `addFilter` in `ToGraph` to detect constant false conjuncts in
filter predicates. When the optional `emptyValuesType` parameter is provided and a
false conjunct is found, replaces the plan with an empty ValuesTable
matching the output schema, avoiding unnecessary table scans for queries
like `SELECT * FROM t WHERE false` or `WHERE 1 > 2`.

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

Labels

CLA Signed This label is managed by the Meta Open Source bot. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant