Skip to content

UUID values byte-swapped when read inside a nested column #28313

Description

@venajeremy

Create Tables With Identical UUID Data:

CREATE TABLE uuid ( uuidColumn uuid );
CREATE TABLE uuidArray ( uuidArrayColumn ARRAY(uuid) );
INSERT INTO uuid (uuidColumn) values (uuid()), (uuid());
INSERT INTO uuidArray (uuidArrayColumn) SELECT array_agg(uuidColumn) FROM uuid;

SELECT * FROM uuid;
SELECT * FROM uuidArray;

Expected Behavior

uuidColumn:
ea909d04-a6bd-43be-838a-c72775b90270
12320a66-ebf9-4311-80d9-588188ad936a
uuidArrayColumn:
[ "ea909d04-a6bd-43be-838a-c72775b90270", "12320a66-ebf9-4311-80d9-588188ad936a" ]

Current Behavior

uuidColumn:
ea909d04-a6bd-43be-838a-c72775b90270
12320a66-ebf9-4311-80d9-588188ad936a
uuidArrayColumn:
[ "be43bda6-049d-90ea-7002-b97527c78a83", "1143f9eb-660a-3212-6a93-ad888158d980" ]

Possible Solution

The UUID value is manipulated when read from the Parquet BinaryColumnReader.java:

if (type instanceof UuidType) {
    byte[] src = binary.getBytes();
    blockBuilder.writeLong(getLongBigEndian(src, 0));
    blockBuilder.writeLong(getLongBigEndian(src, Long.BYTES));
    blockBuilder.closeEntry();
    return;
}

When read from an array column type in BinaryColumnReader.java is varbinary, not UuidType. This byte reorder should either be handled in the Iceberg table layer and applied to both nested and non-nested reads, or the handling for nested UUID values should be modified to pass the UuidType to the Parquet column reader allowing the above case to be reached.

Environment

  • Presto version used: Master
  • Query Runner: IcebergQueryRunner
  • Deployment: Local

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status
    🆕 Unprioritized

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions