Skip to content
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

Conversation

findepi
Copy link
Member

@findepi findepi commented Nov 4, 2021

This makes TestHiveConnectorTest.testLargeIn[5000] over 3x faster.

@findepi findepi force-pushed the findepi/speed-up-translation-of-in-not-in-to-tuple-domain-b83255 branch from 5f4b548 to 5bff879 Compare November 4, 2021 21:47
@findepi findepi requested a review from martint November 4, 2021 21:47
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`.
@findepi findepi force-pushed the findepi/speed-up-translation-of-in-not-in-to-tuple-domain-b83255 branch from 5bff879 to 0160bb2 Compare November 5, 2021 13:16
List<Expression> excludedExpressions = new ArrayList<>();

for (Expression expression : valueList.getValues()) {
Object value = new ExpressionInterpreter(expression, metadata, session, expressionTypes)
Copy link
Member

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?

Copy link
Member Author

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.)

@findepi findepi requested a review from martint November 5, 2021 15:37
This makes `TestHiveConnectorTest.testLargeIn[5000]` over 3x faster.
@findepi findepi force-pushed the findepi/speed-up-translation-of-in-not-in-to-tuple-domain-b83255 branch from 0160bb2 to 25bc059 Compare November 5, 2021 16:07
Comment on lines +901 to +905
// 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");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@findepi findepi merged commit 1d771ee into trinodb:master Nov 8, 2021
@findepi findepi mentioned this pull request Nov 8, 2021
12 tasks
@findepi findepi deleted the findepi/speed-up-translation-of-in-not-in-to-tuple-domain-b83255 branch November 8, 2021 12:14
@github-actions github-actions bot added this to the 365 milestone Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants