HAVING pushdown and more advanced aggregation pushdown in JDBC connectors#6667
Conversation
5b388ea to
dfd6219
Compare
|
I still need to go over the commits and see whether commit boundaries still make sense. |
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/PreparedQuery.java
Outdated
Show resolved
Hide resolved
b7f9fe2 to
003b894
Compare
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/QueryBuilder.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/QueryParameter.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
can o here raise name conflicts?
There was a problem hiding this comment.
i don't think it can, that's why i used a fixed thing.
There was a problem hiding this comment.
the conditions here are a bit reordered (needed to be), so the diff is not very smart
There was a problem hiding this comment.
It feels like you did not need to introduce Table and Query and already go with JdbcRelationHandle and JdbcQueryRelationHandle from the start.
There was a problem hiding this comment.
Correct, #6667 (comment), i need to clean this up
kokosing
left a comment
There was a problem hiding this comment.
just skimmed few first commits.
plugin/trino-base-jdbc/src/test/java/io/trino/plugin/jdbc/TestJdbcRecordSetProvider.java
Outdated
Show resolved
Hide resolved
| // predicate over aggregation result | ||
| assertThat(query("SELECT regionkey, sum(nationkey) FROM nation GROUP BY regionkey HAVING sum(nationkey) = 77")) | ||
| .matches("VALUES (BIGINT '3', BIGINT '77')") | ||
| .isNotFullyPushedDown(FilterNode.class); |
There was a problem hiding this comment.
I think we should have generic test like that, which could be reused for other connectors. Copy pasting test cases does not look like a good idea. Something like: io.trino.testing.AbstractTestDistributedQueries#testDataMappingSmokeTest ?
There was a problem hiding this comment.
let's not address this here
There was a problem hiding this comment.
because it's part of table handle
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/QueryBuilder.java
Outdated
Show resolved
Hide resolved
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/QueryBuilder.java
Outdated
Show resolved
Hide resolved
8a7485a to
23a089d
Compare
23a089d to
8d952ed
Compare
8d952ed to
e5de3ac
Compare
There was a problem hiding this comment.
Does it make sense to have a test similar to this but where the tupleDomain contains a constraint on s? Or is that impossible?
There was a problem hiding this comment.
Good point. This wouldn't work today (or more precisely -- would depend on whether downstream database is SQL standard compliant or eg MySQL).
I can add some validation.
This is just removal of some safety checks. In the follow-up commit, the expressions are removed from `JdbcColumnHandle` and so the distinction is going to be removed.
dc2710f to
deb2d51
Compare
|
AC, PTAL |
Now `JdbcTableHandle` can represent a table with optional constraints and aggregates (as it used to be), or a query. Due to the fact how is serialization of `ConnectorTableHandle` handled, `JdbcTableHandle` cannot have subclasses, so the semantics are expressed with a polymorphic field, `JdbcRelationHandle`.
This changes how aggregation pushdown is modelled in `JdbcTableHandle`. Instead of `JdbcTableHandle.groupingSets` and `JdbcColumnHandle.expression`, it is converted directly into a query. This allows further pushdowns, e.g. predicate after aggregation.
deb2d51 to
2215497
Compare
plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/JdbcMetadata.java
Show resolved
Hide resolved
| } | ||
| JdbcNamedRelationHandle that = (JdbcNamedRelationHandle) o; | ||
| return Objects.equals(schemaTableName, that.schemaTableName) | ||
| // remoteTableName is not compared here, as required by TestJdbcTableHandle#testEquivalence TODO document why this is important |
There was a problem hiding this comment.
Can you explain it alrady in this PR?
There was a problem hiding this comment.
Sorry, missed this. I think i know, but @electrum would do this better (he authored the test)
There was a problem hiding this comment.
Fine. It was not documented previoulsly :)
for #6620