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

Fix incorrect partition pushdown when no partitionSpec exists in Iceberg #21253

Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -406,9 +406,15 @@ public static boolean canEnforceColumnConstraintInSpecs(
IcebergColumnHandle columnHandle,
Domain domain)
{
return table.specs().values().stream()
raunaqmorarka marked this conversation as resolved.
Show resolved Hide resolved
List<PartitionSpec> partitionSpecs = table.specs().values().stream()
.filter(partitionSpec -> partitionSpecIds.contains(partitionSpec.specId()))
.allMatch(spec -> canEnforceConstraintWithinPartitioningSpec(typeOperators, spec, columnHandle, domain));
.collect(toImmutableList());

if (partitionSpecs.isEmpty()) {
return false;
}

return partitionSpecs.stream().allMatch(spec -> canEnforceConstraintWithinPartitioningSpec(typeOperators, spec, columnHandle, domain));
raunaqmorarka marked this conversation as resolved.
Show resolved Hide resolved
}

private static boolean canEnforceConstraintWithinPartitioningSpec(TypeOperators typeOperators, PartitionSpec spec, IcebergColumnHandle column, Domain domain)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3802,6 +3802,21 @@ public void testPredicatePushdown()
dropTable(tableName.getObjectName());
}

@Test
public void testPredicateOnDataColumnIsNotPushedDown()
{
try (TestTable testTable = new TestTable(
getQueryRunner()::execute,
"test_predicate_on_data_column_is_not_pushed_down",
"(a integer)")) {
assertThat(query("SELECT * FROM " + testTable.getName() + " WHERE a = 10"))
.isNotFullyPushedDown(FilterNode.class);
assertUpdate("INSERT INTO " + testTable.getName() + " VALUES 10", 1);
assertThat(query("SELECT * FROM " + testTable.getName() + " WHERE a = 10"))
.isNotFullyPushedDown(FilterNode.class);
}
}

@Test
public void testPredicatesWithStructuralTypes()
{
Expand Down