-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
OR expression pushdown #11086
OR expression pushdown #11086
Conversation
Currently based on #11045 |
01e25d6
to
fedfff7
Compare
fedfff7
to
f81ceb6
Compare
70390c5
to
745dfc1
Compare
Rebased after #11045 merged. |
core/trino-main/src/main/java/io/trino/sql/planner/ConnectorExpressionTranslator.java
Outdated
Show resolved
Hide resolved
@Override | ||
protected Optional<ConnectorExpression> visitCast(Cast node, Void context) | ||
{ | ||
if (isEffectivelyLiteral(plannerContext, session, node)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add if (!isComplexExpressionPushdown(session)) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this. What's complex about a constant? The explicit literals don't have such a check.
core/trino-main/src/main/java/io/trino/sql/planner/ConnectorExpressionTranslator.java
Show resolved
Hide resolved
core/trino-main/src/main/java/io/trino/sql/planner/ConnectorExpressionTranslator.java
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/expression/RewriteOr.java
Outdated
Show resolved
Hide resolved
...n/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlConnectorTest.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/expression/RewriteComparison.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/expression/RewriteComparison.java
Outdated
Show resolved
Hide resolved
745dfc1
to
5a911f8
Compare
(just rebased) |
5a911f8
to
042c452
Compare
AC. Changes as fixups (inline) + new commit |
...n/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlConnectorTest.java
Show resolved
Hide resolved
reminder to squash fixups before merge |
042c452
to
64988d6
Compare
squashed, rebased, resolved conflicts and added |
This includes OR pushdown framework for JDBC connectors, implemented initially for PostgreSQL. Along with this, there comes support for comparison expressions to support a minimal viable usage example for the OR pushdown.
Use `assertTranslationRoundTrips` where possible... i.e. always.
64988d6
to
5b65402
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM from me.
{ | ||
assertThat(query("SELECT * FROM nation WHERE nationkey != 3 OR regionkey = 4")).isFullyPushedDown(); | ||
assertThat(query("SELECT * FROM nation WHERE nationkey != 3 OR regionkey != 4")).isFullyPushedDown(); | ||
assertThat(query("SELECT * FROM nation WHERE name = 'ALGERIA' OR regionkey = 4")).isFullyPushedDown(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the expression rewrite depend on how predicates are ordered/grouped. I see that if add another case like
assertThat(query("SELECT * FROM nation WHERE (name = 'ALGERIA' AND regionkey != 10) OR (regionkey = 4 AND name != 'FOOBAR')")).isFullyPushedDown();
it fails and we get a ScanFilterNode.
cc: @wendigo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's unrelated to OR. That's because !=
isn't subsumed:
trino:tpch> EXPLAIN SELECT * FROM nation WHERE name != 'FOOBAR' ;
Query Plan
--------------------------------------------------------------------------------------------------------------------------------
....
Fragment 1 [SOURCE]
Output layout: [nationkey, name, regionkey, comment]
Output partitioning: SINGLE []
ScanFilter[table = postgresql:tpch.nation tpch.nation, filterPredicate = ("name" <> CAST('FOOBAR' AS varchar(25)))]
Layout: [nationkey:bigint, name:varchar(25), regionkey:bigint, comment:varchar(152)]
Estimates: {rows: 25 (3.13kB), cpu: 3.13k, memory: 0B, network: 0B}/{rows: ? (?), cpu: 6.25k, memory: 0B, network: 0B}
nationkey := nationkey:bigint:int8
regionkey := regionkey:bigint:int8
name := name:varchar(25):varchar
comment := comment:varchar(152):varchar
This includes OR pushdown framework for JDBC connectors, implemented
initially for PostgreSQL.
Along with this, there comes support for comparison expressions,
effective literals, generic literals (used e.g. for BIGINT), to support
a minimal viable usage example for the OR pushdown.
Relates to #18