diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java index 24e5a2e3827d..43c1639de89d 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergUtil.java @@ -241,7 +241,7 @@ public static Map getIdentityPartitions(PartitionSpec p ImmutableMap.Builder columns = ImmutableMap.builder(); for (int i = 0; i < partitionSpec.fields().size(); i++) { PartitionField field = partitionSpec.fields().get(i); - if (field.transform().toString().equals("identity")) { + if (field.transform().isIdentity()) { columns.put(field, i); } } diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/PartitionTransforms.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/PartitionTransforms.java index c55023e179f1..5bbf991c8461 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/PartitionTransforms.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/PartitionTransforms.java @@ -78,85 +78,85 @@ public final class PartitionTransforms private PartitionTransforms() {} - public static ColumnTransform getColumnTransform(PartitionField field, Type type) + public static ColumnTransform getColumnTransform(PartitionField field, Type sourceType) { String transform = field.transform().toString(); switch (transform) { case "identity": - return identity(type); + return identity(sourceType); case "year": - if (type.equals(DATE)) { + if (sourceType.equals(DATE)) { return yearsFromDate(); } - if (type.equals(TIMESTAMP_MICROS)) { + if (sourceType.equals(TIMESTAMP_MICROS)) { return yearsFromTimestamp(); } - if (type.equals(TIMESTAMP_TZ_MICROS)) { + if (sourceType.equals(TIMESTAMP_TZ_MICROS)) { return yearsFromTimestampWithTimeZone(); } throw new UnsupportedOperationException("Unsupported type for 'year': " + field); case "month": - if (type.equals(DATE)) { + if (sourceType.equals(DATE)) { return monthsFromDate(); } - if (type.equals(TIMESTAMP_MICROS)) { + if (sourceType.equals(TIMESTAMP_MICROS)) { return monthsFromTimestamp(); } - if (type.equals(TIMESTAMP_TZ_MICROS)) { + if (sourceType.equals(TIMESTAMP_TZ_MICROS)) { return monthsFromTimestampWithTimeZone(); } throw new UnsupportedOperationException("Unsupported type for 'month': " + field); case "day": - if (type.equals(DATE)) { + if (sourceType.equals(DATE)) { return daysFromDate(); } - if (type.equals(TIMESTAMP_MICROS)) { + if (sourceType.equals(TIMESTAMP_MICROS)) { return daysFromTimestamp(); } - if (type.equals(TIMESTAMP_TZ_MICROS)) { + if (sourceType.equals(TIMESTAMP_TZ_MICROS)) { return daysFromTimestampWithTimeZone(); } throw new UnsupportedOperationException("Unsupported type for 'day': " + field); case "hour": - if (type.equals(TIMESTAMP_MICROS)) { + if (sourceType.equals(TIMESTAMP_MICROS)) { return hoursFromTimestamp(); } - if (type.equals(TIMESTAMP_TZ_MICROS)) { + if (sourceType.equals(TIMESTAMP_TZ_MICROS)) { return hoursFromTimestampWithTimeZone(); } throw new UnsupportedOperationException("Unsupported type for 'hour': " + field); case "void": - return voidTransform(type); + return voidTransform(sourceType); } Matcher matcher = BUCKET_PATTERN.matcher(transform); if (matcher.matches()) { int count = parseInt(matcher.group(1)); - return bucket(type, count); + return bucket(sourceType, count); } matcher = TRUNCATE_PATTERN.matcher(transform); if (matcher.matches()) { int width = parseInt(matcher.group(1)); - if (type.equals(INTEGER)) { + if (sourceType.equals(INTEGER)) { return truncateInteger(width); } - if (type.equals(BIGINT)) { + if (sourceType.equals(BIGINT)) { return truncateBigint(width); } - if (isShortDecimal(type)) { - DecimalType decimal = (DecimalType) type; - return truncateShortDecimal(type, width, decimal); + if (isShortDecimal(sourceType)) { + DecimalType decimal = (DecimalType) sourceType; + return truncateShortDecimal(sourceType, width, decimal); } - if (isLongDecimal(type)) { - DecimalType decimal = (DecimalType) type; - return truncateLongDecimal(type, width, decimal); + if (isLongDecimal(sourceType)) { + DecimalType decimal = (DecimalType) sourceType; + return truncateLongDecimal(sourceType, width, decimal); } - if (type instanceof VarcharType) { + if (sourceType instanceof VarcharType) { return truncateVarchar(width); } - if (type.equals(VARBINARY)) { + if (sourceType.equals(VARBINARY)) { return truncateVarbinary(width); } throw new UnsupportedOperationException("Unsupported type for 'truncate': " + field);