-
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
Speed up translation of IN / NOT IN to tuple domain #9874
Speed up translation of IN / NOT IN to tuple domain #9874
Conversation
core/trino-main/src/main/java/io/trino/sql/planner/DomainTranslator.java
Outdated
Show resolved
Hide resolved
5f4b548
to
5bff879
Compare
Also, use shorter way to define list with null.
Replace it with a helper. `TupleDomain.withColumnDomains` is named in a way so that it should not be imported statically.
Among others, this adds test coverage for IN, NOT IN with floating point types, which have special treatment in `DomainTranslator`.
5bff879
to
0160bb2
Compare
List<Expression> excludedExpressions = new ArrayList<>(); | ||
|
||
for (Expression expression : valueList.getValues()) { | ||
Object value = new ExpressionInterpreter(expression, metadata, session, expressionTypes) |
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.
This should normally be handled by other optimizers. Why is it necessary to do it here?
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.
It's necessary to obtain the native value from a constant expression.
optimization is others' responsibility, but we need to handle whatever LiteralEncoder constructs, for a type.
(btw we use this pattern in other places, for same reason.)
This makes `TestHiveConnectorTest.testLargeIn[5000]` over 3x faster.
0160bb2
to
25bc059
Compare
// TODO this currently fails; fix https://github.com/trinodb/trino/issues/9885 and restore: assertThat(query("SELECT price, vendor FROM " + JSON_TABLE + " WHERE price NOT IN (4.5, 5.5, 6.5, 7.5, 8.5, 9.5)")).isNotFullyPushedDown(FilterNode.class); | ||
assertThatThrownBy(() -> query("SELECT price, vendor FROM " + JSON_TABLE + " WHERE price NOT IN (4.5, 5.5, 6.5, 7.5, 8.5, 9.5)")) | ||
.hasMessage("java.lang.IllegalStateException") | ||
.hasStackTraceContaining("at com.google.common.base.Preconditions.checkState") | ||
.hasStackTraceContaining("at io.trino.plugin.pinot.query.PinotQueryBuilder.toPredicate"); |
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.
This makes
TestHiveConnectorTest.testLargeIn[5000]
over 3x faster.