Skip to content

[iceberg] Time column's type is incorrectly set to string in IcebergTableLayoutHandle #26214

@PingLiuPing

Description

@PingLiuPing

When create iceberg table with TIME column, and I noticed that in IcebergTableLayoutHandle, this column's type is string rather than expected Time or bigint. This causes trouble when we need the actual physical type, for example in Prestissimo this type will be converted to varchar, and this makes it impossible to do further operations such as write and read.

This is caused by this method

https://github.com/prestodb/presto/blob/37f83a52e68cd0edd21c0ec62277bded7051be6d/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergUtil.java#L386-L394C2

and eventually it calls

private static String convertToTypeString(Type type) {
switch (type.typeId()) {
case BOOLEAN:
return "boolean";
case INTEGER:
return "int";
case LONG:
return "bigint";
case FLOAT:
return "float";
case DOUBLE:
return "double";
case DATE:
return "date";
case TIME:
case STRING:
case UUID:
return "string";
case TIMESTAMP:
Types.TimestampType timestampType = (Types.TimestampType)type;
if (HiveVersion.min(HiveVersion.HIVE_3) && timestampType.shouldAdjustToUTC()) {
return "timestamp with local time zone";
}

            return "timestamp";
        case FIXED:
        case BINARY:
            return "binary";
        case DECIMAL:
            Types.DecimalType decimalType = (Types.DecimalType)type;
            return String.format("decimal(%s,%s)", decimalType.precision(), decimalType.scale());
        case STRUCT:
            Types.StructType structType = type.asStructType();
            String nameToType = (String)structType.fields().stream().map((f) -> String.format("%s:%s", f.name(), convert(f.type()))).collect(Collectors.joining(","));
            return String.format("struct<%s>", nameToType);
        case LIST:
            Types.ListType listType = type.asListType();
            return String.format("array<%s>", convert(listType.elementType()));
        case MAP:
            Types.MapType mapType = type.asMapType();
            return String.format("map<%s,%s>", convert(mapType.keyType()), convert(mapType.valueType()));
        default:
            throw new UnsupportedOperationException(type + " is not supported");
    }
}

Your Environment

  • Presto version used:
  • Storage (HDFS/S3/GCS..):
  • Data source and connector used:
  • Deployment (Cloud or On-prem):
  • Pastebin link to the complete debug logs:

Expected Behavior

Current Behavior

Possible Solution

Steps to Reproduce

Screenshots (if appropriate)

Context

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

🆕 Unprioritized

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions