Improve IS NULL pushdown for ClickHouse complex expression#23459
Conversation
7e00f41 to
4195edb
Compare
4195edb to
c0d94e2
Compare
c0d94e2 to
6be9498
Compare
|
@Praveen2112 @hashhar @ebyhr please review. |
...in/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/IsNullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
...in/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/IsNullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
...in/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/IsNullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
...in/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/IsNullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
...in/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/IsNullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
5982fe3 to
a8c8d0c
Compare
There was a problem hiding this comment.
What we are verifying here actually? It is verifying for only first test case that inputLiteral should not be null.
It seems that before adding the round trip test case, we should be knowing that 1st test case should not have NULL as input literal.
There was a problem hiding this comment.
After going through the code, I got the intention of why we needed SPECIAL_COLUMNS. May be NON_NULL_COLUMNS makes more sense here. WDYT?
There was a problem hiding this comment.
I had TestClickHouseConnectorTest#testTextualPredicatePushdown in mind, where SPECIAL_COLUMNS are
unsupported_1 Point,
unsupported_2 Point,
some_column String,
There was a problem hiding this comment.
What if we could handle this special columns as part of this framework ?
There was a problem hiding this comment.
I think it's possible however I'm not sure how to make it look better that it is right now, because the type of the special columns may differ for different cases:
.addTestCase("String", "'z'", VARCHAR, "CAST('z' AS varchar)") // special, non null column
.addTestCase("String", "'z'", VARBINARY, "CAST('z' AS varbinary)") // special, non null column
...in/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/IsNullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
...in/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/IsNullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
...in/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/IsNullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
...in/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/IsNullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
...in/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/IsNullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
...in/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/IsNullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
...in/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/IsNullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
...in/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/IsNullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
...n/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorTest.java
Outdated
Show resolved
Hide resolved
9d6bf97 to
48e2843
Compare
...in/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/IsNullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
48e2843 to
6c17091
Compare
...in/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/IsNullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
...in/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/IsNullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Can we inject queryAssertions instead of query runner ?
There was a problem hiding this comment.
It conforms to the api of SqlDataTypeTest if we later want to unify these assertions.
There was a problem hiding this comment.
Also not sure if it gives benefits.
...in/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/IsNullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
...in/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/IsNullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
What if we could handle this special columns as part of this framework ?
...in/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/IsNullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
6c17091 to
15d804f
Compare
|
@Praveen2112 please approve and merge. |
...n/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseConnectorTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Instead of asserting them twice like once with all columns AND ? Can we assert them each column at a time ? Like
for (int column = SPECIAL_COLUMNS; column < testCases.size(); column++) {
String queryWithSingleColumnPredicate = "SELECT " + firstColumnName + " FROM " + temporaryRelation.getName() + " WHERE " + getPredicate(column, isNull) + withConnectorExpression;
assertPushdown(expectPushdown,
assertResult(isNull ? Optional.of(firstCase.expectedLiteral()) : Optional.empty(),
assertThat(queryAssertions.query(session, queryWithSingleColumnPredicate))));
}
This would allow us to identify the specific columns which would cause failure in the future
There was a problem hiding this comment.
Not sure if I follow your suggestion. We already asserting each column at a time, in case of failure.
There was a problem hiding this comment.
Instead of handling twice can we try asserting only once for each column so that it would be easier to debug in case of failures
There was a problem hiding this comment.
The first check for all columns is N times faster than the second for single columns. So it's an improvement for sunny-day scenario.
In case of failure there is overhead of 1 additional check, performing N additional checks for single columns.
This was copied from SqlDataTypeTest.
Please let me know if you want to simplify code.
There was a problem hiding this comment.
Makes sense !! Let's have it like this.
There was a problem hiding this comment.
If we could inline IS NULL and IS NOT NULL and the assertion could be inlined right ? Ideally for the test data - we for IS NULL we get a value and for IS NOT NULL we get an empty value - Do we need this dedicated method for each assertion.
There was a problem hiding this comment.
Not sure if I follow. I'm ok with any solution, just to merge this PR.
15d804f to
2360265
Compare
|
@Praveen2112 do you think we are good to merge this PR? |
plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/NullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/NullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/NullPushdownDataTypeTest.java
Outdated
Show resolved
Hide resolved
2360265 to
2ed946e
Compare
|
@Praveen2112 ptal |
Praveen2112
left a comment
There was a problem hiding this comment.
Thanks for working on this
|
@ssheikin Can we update the PR description. |
b8c37ac to
0a81434
Compare
0a81434 to
cd7ddc4
Compare

Description
Additional context and related issues
Release notes
( ) This is not user-visible or is docs only, and no release notes are required.
() Release notes are required. Please propose a release note for me.
(x ) Release notes are required, with the following suggested text: