Skip to content

Commit

Permalink
fixup! Fix bug Delta column operations erases its properties on upper…
Browse files Browse the repository at this point in the history
…case names
  • Loading branch information
ebyhr committed Aug 1, 2023
1 parent 0f52ff5 commit 8772297
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
import static io.trino.plugin.hive.util.HiveUtil.escapePathName;
import static java.lang.Math.min;
import static java.lang.String.format;
import static java.util.Locale.ENGLISH;
import static java.util.Objects.requireNonNull;
import static java.util.UUID.randomUUID;
import static java.util.stream.Collectors.toList;
Expand Down Expand Up @@ -159,9 +158,9 @@ public AbstractDeltaLakePageSink(
DeltaLakeColumnHandle column = inputColumns.get(inputIndex);
switch (column.getColumnType()) {
case PARTITION_KEY:
int partitionPosition = canonicalToOriginalPartitionPositions.get(column.getColumnName().toLowerCase(ENGLISH));
int partitionPosition = canonicalToOriginalPartitionPositions.get(column.getColumnName());
partitionColumnInputIndex[partitionPosition] = inputIndex;
originalPartitionColumnNames[partitionPosition] = canonicalToOriginalPartitionColumns.get(column.getColumnName().toLowerCase(ENGLISH));
originalPartitionColumnNames[partitionPosition] = canonicalToOriginalPartitionColumns.get(column.getColumnName());
partitionColumnTypes[partitionPosition] = column.getBaseType();
break;
case REGULAR:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import static io.trino.spi.type.RowType.rowType;
import static io.trino.spi.type.TimestampWithTimeZoneType.TIMESTAMP_TZ_MILLIS;
import static io.trino.spi.type.VarcharType.VARCHAR;
import static java.util.Locale.ENGLISH;
import static java.util.Objects.requireNonNull;

public class DeltaLakeColumnHandle
Expand Down Expand Up @@ -159,7 +160,7 @@ public boolean equals(Object obj)
public String getColumnName()
{
checkState(isBaseColumn(), "Unexpected dereference: %s", this);
return baseColumnName;
return baseColumnName.toLowerCase(ENGLISH);
}

@JsonIgnore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1761,7 +1761,7 @@ private static List<String> getPartitionColumns(List<String> originalPartitionCo
private static List<String> getPartitionColumnsForNameOrIdMapping(List<String> originalPartitionColumns, List<DeltaLakeColumnHandle> dataColumns)
{
Map<String, DeltaLakeColumnHandle> nameToDataColumns = dataColumns.stream()
.collect(toImmutableMap(columnHandle -> columnHandle.getColumnName().toLowerCase(ENGLISH), Function.identity()));
.collect(toImmutableMap(columnHandle -> columnHandle.getColumnName(), Function.identity()));
return originalPartitionColumns.stream()
.map(columnName -> {
DeltaLakeColumnHandle dataColumn = nameToDataColumns.get(columnName.toLowerCase(ENGLISH));
Expand Down Expand Up @@ -1981,7 +1981,7 @@ private Optional<ConnectorTableLayout> getLayoutForOptimize(DeltaLakeTableExecut
return Optional.empty();
}
Map<String, DeltaLakeColumnHandle> columnsByName = optimizeHandle.getTableColumns().stream()
.collect(toImmutableMap(columnHandle -> columnHandle.getColumnName().toLowerCase(ENGLISH), identity()));
.collect(toImmutableMap(columnHandle -> columnHandle.getColumnName(), identity()));
ImmutableList.Builder<DeltaLakeColumnHandle> partitioningColumns = ImmutableList.builder();
for (String columnName : partitionColumnNames) {
partitioningColumns.add(columnsByName.get(columnName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public List<String> getPartitionedBy()
{
return getInputColumns().stream()
.filter(column -> column.getColumnType() == PARTITION_KEY)
.map(DeltaLakeColumnHandle::getColumnName)
.map(DeltaLakeColumnHandle::getBaseColumnName)
.collect(toImmutableList());
}

Expand Down

0 comments on commit 8772297

Please sign in to comment.