Skip to content

Commit

Permalink
Fix Iceberg dereference pushdown when column has a comment
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueStalker authored and findepi committed Feb 25, 2022
1 parent 8bfe9fa commit 9d30624
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,9 @@ public Optional<ProjectionApplicationResult<ConnectorTableHandle>> applyProjecti

private static IcebergColumnHandle createProjectedColumnHandle(IcebergColumnHandle column, List<Integer> indices, io.trino.spi.type.Type projectedColumnType)
{
if (indices.isEmpty()) {
return column;
}
ImmutableList.Builder<Integer> fullPath = ImmutableList.builder();
fullPath.addAll(column.getPath());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3192,6 +3192,23 @@ public void testProjectionPushdownOnPartitionedTables()
assertUpdate("DROP TABLE table_with_partition_at_end");
}

@Test
public void testProjectionPushdownOnPartitionedTableWithComments()
{
assertUpdate("CREATE TABLE test_projection_pushdown_comments (id BIGINT COMMENT 'id', qid BIGINT COMMENT 'QID', root ROW(f1 BIGINT, f2 BIGINT) COMMENT 'root') WITH (partitioning = ARRAY['id'])");
assertUpdate("INSERT INTO test_projection_pushdown_comments VALUES (1, 1, ROW(1, 2)), (1, 2, ROW(2, 3)), (1, 3, ROW(3, 4))", 3);
assertQuery("SELECT id, root.f2 FROM test_projection_pushdown_comments", "VALUES (1, 2), (1, 3), (1, 4)");
// Query with predicates on both nested and top-level columns (with partition column)
assertQuery("SELECT id, root.f2 FROM test_projection_pushdown_comments WHERE id = 1 AND qid = 1 AND root.f1 = 1", "VALUES (1, 2)");
// Query with predicates on both nested and top-level columns (no partition column)
assertQuery("SELECT id, root.f2 FROM test_projection_pushdown_comments WHERE qid = 2 AND root.f1 = 2", "VALUES (1, 3)");
// Query with predicates on top-level columns only
assertQuery("SELECT id, root.f2 FROM test_projection_pushdown_comments WHERE id = 1 AND qid = 1", "VALUES (1, 2)");
// Query with predicates on nested columns only
assertQuery("SELECT id, root.f2 FROM test_projection_pushdown_comments WHERE root.f1 = 2", "VALUES (1, 3)");
assertUpdate("DROP TABLE IF EXISTS test_projection_pushdown_comments");
}

@Test
public void testOptimize()
throws Exception
Expand Down

0 comments on commit 9d30624

Please sign in to comment.