diff --git a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeMetadata.java b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeMetadata.java index 5110fd4c25a3..dee4205f7396 100644 --- a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeMetadata.java +++ b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeMetadata.java @@ -569,9 +569,7 @@ public Map getColumnHandles(ConnectorSession session, Conn { DeltaLakeTableHandle table = checkValidTableHandle(tableHandle); return table.getProjectedColumns() - .map(projectedColumns -> (List) projectedColumns.stream() - .map(DeltaLakeColumnHandle.class::cast) // TODO DeltaLakeTableHandle.projectedColumns should be a collection of DeltaLakeColumnHandle - .collect(toImmutableList())) + .map(projectColumns -> (Collection) projectColumns) .orElseGet(() -> getColumns(table.getMetadataEntry())).stream() // This method does not calculate column name for the projected columns .peek(handle -> checkArgument(handle.isBaseColumn(), "Unsupported projected column: %s", handle)) @@ -2285,7 +2283,9 @@ public Optional> applyProjecti // all references are simple variables if (!isProjectionPushdownEnabled(session) || columnProjections.values().stream().allMatch(ProjectedColumnRepresentation::isVariable)) { - Set projectedColumns = ImmutableSet.copyOf(assignments.values()); + Set projectedColumns = assignments.values().stream() + .map(DeltaLakeColumnHandle.class::cast) + .collect(toImmutableSet()); // Check if column was projected already in previous call if (deltaLakeTableHandle.getProjectedColumns().isPresent() && deltaLakeTableHandle.getProjectedColumns().get().equals(projectedColumns)) { @@ -2308,7 +2308,7 @@ public Optional> applyProjecti Map newAssignments = new HashMap<>(); ImmutableMap.Builder newVariablesBuilder = ImmutableMap.builder(); - ImmutableSet.Builder projectedColumnsBuilder = ImmutableSet.builder(); + ImmutableSet.Builder projectedColumnsBuilder = ImmutableSet.builder(); for (Map.Entry entry : columnProjections.entrySet()) { ConnectorExpression expression = entry.getKey(); diff --git a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeSplitManager.java b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeSplitManager.java index dbe1524282e4..77cbcd0260ce 100644 --- a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeSplitManager.java +++ b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeSplitManager.java @@ -242,7 +242,7 @@ private static boolean mayAnyDataColumnProjected(DeltaLakeTableHandle tableHandl return true; } return tableHandle.getProjectedColumns().get().stream() - .map(columnHandle -> ((DeltaLakeColumnHandle) columnHandle).getColumnType()) + .map(DeltaLakeColumnHandle::getColumnType) .anyMatch(DeltaLakeColumnType.REGULAR::equals); } diff --git a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeTableHandle.java b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeTableHandle.java index 94c26bb5a4e1..fefe408d12c7 100644 --- a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeTableHandle.java +++ b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeTableHandle.java @@ -18,7 +18,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import io.airlift.units.DataSize; import io.trino.plugin.deltalake.transactionlog.MetadataEntry; -import io.trino.spi.connector.ColumnHandle; import io.trino.spi.connector.SchemaTableName; import io.trino.spi.predicate.TupleDomain; @@ -51,7 +50,7 @@ public enum WriteType private final Optional writeType; private final long readVersion; - private final Optional> projectedColumns; + private final Optional> projectedColumns; // UPDATE only: The list of columns being updated private final Optional> updatedColumns; // UPDATE only: The list of columns which need to be copied when applying updates to the new Parquet file @@ -74,7 +73,7 @@ public DeltaLakeTableHandle( @JsonProperty("enforcedPartitionConstraint") TupleDomain enforcedPartitionConstraint, @JsonProperty("nonPartitionConstraint") TupleDomain nonPartitionConstraint, @JsonProperty("writeType") Optional writeType, - @JsonProperty("projectedColumns") Optional> projectedColumns, + @JsonProperty("projectedColumns") Optional> projectedColumns, @JsonProperty("updatedColumns") Optional> updatedColumns, @JsonProperty("updateRowIdColumns") Optional> updateRowIdColumns, @JsonProperty("analyzeHandle") Optional analyzeHandle, @@ -107,7 +106,7 @@ public DeltaLakeTableHandle( TupleDomain enforcedPartitionConstraint, TupleDomain nonPartitionConstraint, Optional writeType, - Optional> projectedColumns, + Optional> projectedColumns, Optional> updatedColumns, Optional> updateRowIdColumns, Optional analyzeHandle, @@ -134,7 +133,7 @@ public DeltaLakeTableHandle( this.readVersion = readVersion; } - public DeltaLakeTableHandle withProjectedColumns(Set projectedColumns) + public DeltaLakeTableHandle withProjectedColumns(Set projectedColumns) { return new DeltaLakeTableHandle( schemaName, @@ -245,7 +244,7 @@ public Optional getWriteType() // Projected columns are not needed on workers @JsonIgnore - public Optional> getProjectedColumns() + public Optional> getProjectedColumns() { return projectedColumns; } diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeMetadata.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeMetadata.java index 613bca33ba49..319526429550 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeMetadata.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/TestDeltaLakeMetadata.java @@ -438,11 +438,11 @@ public Object[][] testApplyProjectionProvider() @Test(dataProvider = "testApplyProjectionProvider") public void testApplyProjection( - Set inputProjectedColumns, + Set inputProjectedColumns, Map inputAssignments, List inputProjections, List expectedProjections, - Set expectedProjectedColumns, + Set expectedProjectedColumns, Map expectedAssignments) { DeltaLakeMetadata deltaLakeMetadata = deltaLakeMetadataFactory.create(SESSION.getIdentity()); @@ -455,8 +455,7 @@ public void testApplyProjection( inputAssignments) .get(); - assertThat(((DeltaLakeTableHandle) projection.getHandle()) - .getProjectedColumns()) + assertThat(((DeltaLakeTableHandle) projection.getHandle()).getProjectedColumns()) .isEqualTo(Optional.of(expectedProjectedColumns)); assertThat(projection.getProjections()) @@ -519,7 +518,7 @@ public void testGetInputInfoForUnPartitionedTable() assertThat(deltaLakeMetadata.getInfo(tableHandle)).isEqualTo(Optional.of(new DeltaLakeInputInfo(false))); } - private static DeltaLakeTableHandle createDeltaLakeTableHandle(Set projectedColumns, Set constrainedColumns) + private static DeltaLakeTableHandle createDeltaLakeTableHandle(Set projectedColumns, Set constrainedColumns) { return new DeltaLakeTableHandle( "test_schema_name",