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

Reconstruct NOT IN when pushing down to JDBC source #6343

Merged
merged 6 commits into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@ private String toPredicate(JdbcColumnHandle column, Domain domain, List<TypeAndV
private String toPredicate(JdbcColumnHandle column, ValueSet valueSet, List<TypeAndValue> accumulator)
{
checkArgument(!valueSet.isNone(), "none values should be handled earlier");

if (!valueSet.isDiscreteSet()) {
ValueSet complement = valueSet.complement();
if (complement.isDiscreteSet()) {
return format("NOT (%s)", toPredicate(column, complement, accumulator));
}
}

List<String> disjuncts = new ArrayList<>();
List<Object> singleValues = new ArrayList<>();
for (Range range : valueSet.getRanges().getOrderedRanges()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ public void testBuildSqlWithDomainComplement()
assertThat(lastQuery).isEqualTo("" +
Copy link
Member

Choose a reason for hiding this comment

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

Do we have query in ATDQ to trigger this pushdown?

Copy link
Member Author

Choose a reason for hiding this comment

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

"SELECT \"col_0\" AS \"col_0\", \"col_3\" AS \"col_3\", \"col_9\" AS \"col_9\" " +
"FROM \"test_table\" " +
"WHERE ((\"col_0\" < ? OR (\"col_0\" > ? AND \"col_0\" < ?) OR (\"col_0\" > ? AND \"col_0\" < ?) OR \"col_0\" > ?) OR \"col_0\" IS NULL) " +
"AND (\"col_1\" < ? OR (\"col_1\" > ? AND \"col_1\" < ?) OR (\"col_1\" > ? AND \"col_1\" < ?) OR \"col_1\" > ?) " +
"WHERE (NOT (\"col_0\" IN (?,?,?)) OR \"col_0\" IS NULL) " +
"AND NOT (\"col_1\" IN (?,?,?)) " +
"AND \"col_9\" >= ?");
ImmutableSet.Builder<Long> builder = ImmutableSet.builder();
try (ResultSet resultSet = preparedStatement.executeQuery()) {
Expand Down