Skip to content

Commit bd01541

Browse files
author
Alex Jo
committed
Fix error in Iceberg predicate pushdown to Parquet files
The Paruqet reader does not support pushdown on fields of a Row type. The checks in `IcebergPageSourceProvider#getParquetTupleDomain` used to prevent this, but they stopped working when dereference pushdown was implemented. If a row field had the same name as a top level column this would have resulted in a correctness issue.
1 parent cd8eac6 commit bd01541

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergPageSourceProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,7 @@ private static TupleDomain<ColumnDescriptor> getParquetTupleDomain(Map<List<Stri
13541354
effectivePredicate.getDomains().orElseThrow().forEach((columnHandle, domain) -> {
13551355
String baseType = columnHandle.getType().getTypeSignature().getBase();
13561356
// skip looking up predicates for complex types as Parquet only stores stats for primitives
1357-
if (!baseType.equals(StandardTypes.MAP) && !baseType.equals(StandardTypes.ARRAY) && !baseType.equals(StandardTypes.ROW)) {
1357+
if (columnHandle.isBaseColumn() && (!baseType.equals(StandardTypes.MAP) && !baseType.equals(StandardTypes.ARRAY) && !baseType.equals(StandardTypes.ROW))) {
13581358
ColumnDescriptor descriptor = descriptorsByPath.get(ImmutableList.of(columnHandle.getName()));
13591359
if (descriptor != null) {
13601360
predicate.put(descriptor, domain);

testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3827,6 +3827,18 @@ public void testUpdateRowType()
38273827
}
38283828
}
38293829

3830+
@Test
3831+
public void testPredicateOnRowTypeField()
3832+
{
3833+
skipTestUnless(hasBehavior(SUPPORTS_CREATE_TABLE) && hasBehavior(SUPPORTS_INSERT) && hasBehavior(SUPPORTS_ROW_TYPE));
3834+
3835+
try (TestTable table = new TestTable(getQueryRunner()::execute, "test_predicate_on_row_type_field", "(int_t INT, row_t row(varchar_t VARCHAR, int_t INT))")) {
3836+
assertUpdate("INSERT INTO " + table.getName() + " VALUES (2, row('first', 1)), (20, row('second', 10)), (200, row('third', 100))", 3);
3837+
assertQuery("SELECT int_t FROM " + table.getName() + " WHERE row_t.int_t = 1", "VALUES 2");
3838+
assertQuery("SELECT int_t FROM " + table.getName() + " WHERE row_t.int_t > 1", "VALUES 20, 200");
3839+
}
3840+
}
3841+
38303842
@Test
38313843
public void testUpdateAllValues()
38323844
{

0 commit comments

Comments
 (0)