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

Use JDBC parameters in JDBC complex expression pushdown #16616

Merged
merged 2 commits into from
Mar 22, 2023

Conversation

findepi
Copy link
Member

@findepi findepi commented Mar 17, 2023

No description provided.

@findepi
Copy link
Member Author

findepi commented Mar 20, 2023

ci / check-commit (0fea223476b591d2472b9f89bc3afe5ed8561b99) (pull_request) failure seems unrelated

Error:  Error downloading dependencies for project
Error:  The following artifacts could not be resolved: io.trino:trino-matching:jar:411-SNAPSHOT, io.trino:trino-main:jar:tests:411-SNAPSHOT, io.trino:trino-main:jar:411-SNAPSHOT, io.trino:trino-testing-kafka:jar:411-SNAPSHOT, io.trino:trino-testing:jar:411-SNAPSHOT, io.trino:trino-tpch:jar:411-SNAPSHOT, io.trino:trino-collect:jar:411-SNAPSHOT, io.trino:trino-spi:jar:411-SNAPSHOT, io.trino:trino-plugin-toolkit:jar:411-SNAPSHOT, io.trino:trino-spi:jar:tests:411-SNAPSHOT: Could not find artifact io.trino:trino-matching:jar:411-SNAPSHOT in sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots)
Warning:  The following artifacts could not be resolved: io.trino:trino-matching:jar:411-SNAPSHOT, io.trino:trino-main:jar:tests:411-SNAPSHOT, io.trino:trino-main:jar:411-SNAPSHOT, io.trino:trino-testing-kafka:jar:411-SNAPSHOT, io.trino:trino-testing:jar:411-SNAPSHOT, io.trino:trino-tpch:jar:411-SNAPSHOT, io.trino:trino-collect:jar:411-SNAPSHOT, io.trino:trino-spi:jar:411-SNAPSHOT, io.trino:trino-plugin-toolkit:jar:411-SNAPSHOT, io.trino:trino-spi:jar:tests:411-SNAPSHOT: Could not find artifact io.trino:trino-matching:jar:411-SNAPSHOT in sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots)

ignoring

cc @nineinchnick

@findepi findepi marked this pull request as ready for review March 20, 2023 12:03
@findepi
Copy link
Member Author

findepi commented Mar 20, 2023

CI #13199 and ci / check-commit again

@findepi findepi requested review from ebyhr and losipiuk March 20, 2023 21:22
Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

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

the API seems good, yet to review the changes in all the rewrite rules

Stream.concat(constraintExpressions.stream(), splitPredicate.stream())
.collect(joining(") AND (", "(", ")")));
return Optional.of(new ParameterizedExpression(
Stream.concat(constraintExpressions.stream().map(ParameterizedExpression::expression), splitPredicate.stream())
Copy link
Contributor

Choose a reason for hiding this comment

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

This block is hard to read and follow. Can we make it easier to reason about?

Copy link
Member Author

Choose a reason for hiding this comment

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

this line was as-is here before, right?

@@ -374,7 +375,7 @@ public Optional<AggregationApplicationResult<ConnectorTableHandle>> applyAggrega
newColumns.add(newColumn);
projections.add(new Variable(newColumn.getColumnName(), aggregate.getOutputType()));
resultAssignments.add(new Assignment(newColumn.getColumnName(), newColumn, aggregate.getOutputType()));
expressions.put(columnName, expression.get().getExpression());
expressions.put(columnName, new ParameterizedExpression(expression.get().getExpression(), expression.get().getParameters()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we introduce a factory method that will produce ParametrizedExpression from JdbcExpression?

Copy link
Member Author

Choose a reason for hiding this comment

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

is this the only place where this would be useful?

@@ -92,4 +103,14 @@ public int hashCode()
{
return Objects.hash(jdbcType, type, value);
}

@Override
public String toString()
Copy link
Contributor

Choose a reason for hiding this comment

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

Separate commit?

@wendigo
Copy link
Contributor

wendigo commented Mar 21, 2023

I like this change very much. Thank you @findepi

@findepi findepi force-pushed the findepi/jdbc-param branch from 426182a to dc58b78 Compare March 21, 2023 21:27
Copy link
Member

@hashhar hashhar left a comment

Choose a reason for hiding this comment

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

Thanks a lot for working on this.

LGTM % comment

Copy link
Member

Choose a reason for hiding this comment

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

For other reviewers: this is now un-needed since we use prepared statements and the driver will handle this part now. (It took me quite some time to understand this).

@findepi As part of this we should also add a test which verifies pushdown works for unicode literals instead of query failures.

Copy link
Member Author

Choose a reason for hiding this comment

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

@hashhar i am not introducing new functionality. What testing was RewriteUnicodeVarcharConstant.java covered with?

@findepi
Copy link
Member Author

findepi commented Mar 22, 2023

@kokosing ptal

@kokosing
Copy link
Member

ACK. I skimmed the code and I trust @hashhar review here.

@findepi findepi merged commit e3bbf6c into master Mar 22, 2023
@findepi findepi deleted the findepi/jdbc-param branch March 22, 2023 10:31
@github-actions github-actions bot added this to the 411 milestone Mar 22, 2023
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.

4 participants