This is an automated email from the ASF dual-hosted git repository.

hubgeter pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 23d5e2d61a5 [fix](iceberg) Preserve UUID and nanosecond timestamps in 
metadata scans (#70506)
23d5e2d61a5 is described below

commit 23d5e2d61a51129b07faca119bf88dcad62d76b1
Author: daidai <[email protected]>
AuthorDate: Tue Dec 1 17:29:06 2026 +0800

    [fix](iceberg) Preserve UUID and nanosecond timestamps in metadata scans 
(#70506)
    
    ### Background
    
    Iceberg metadata tables expose typed partition values and readable file
    metrics. The metadata scanner passes these SDK values and their Iceberg
    types to a Java adapter that feeds Doris JNI vectors.
    
    ### What problem does this PR solve?
    
    Issue Number: None
    Related PR: #68786 (logical UUID mapping), #68934 (nanosecond timestamp
    support), #68985 (typed metadata timestamp adapter), #70509 (nanosecond
    timestamp fix included here)
    PR Type: Bugfix
    
    Problem Summary:
    
    Queries can fail when Iceberg metadata contains a non-null UUID or
    return the wrong value when it contains an unzoned nanosecond timestamp.
    The adapter now returns SDK UUID values directly and decodes timestamps
    using their declared precision and time-zone semantics. Most of the
    change adds regression coverage for partition fields and readable
    metrics.
---
 .../doris/iceberg/IcebergSysTableColumnValue.java  |  19 +-
 .../iceberg/IcebergMetadataTimestampNsTest.java    | 194 +++++++++++++++++++++
 .../doris/iceberg/IcebergSysTableUuidTest.java     | 181 +++++++++++++++++++
 3 files changed, 391 insertions(+), 3 deletions(-)

diff --git 
a/fe/be-java-extensions/iceberg-metadata-scanner/src/main/java/org/apache/doris/iceberg/IcebergSysTableColumnValue.java
 
b/fe/be-java-extensions/iceberg-metadata-scanner/src/main/java/org/apache/doris/iceberg/IcebergSysTableColumnValue.java
index a010c5dc213..5dffe326efb 100644
--- 
a/fe/be-java-extensions/iceberg-metadata-scanner/src/main/java/org/apache/doris/iceberg/IcebergSysTableColumnValue.java
+++ 
b/fe/be-java-extensions/iceberg-metadata-scanner/src/main/java/org/apache/doris/iceberg/IcebergSysTableColumnValue.java
@@ -34,6 +34,7 @@ import java.time.ZoneId;
 import java.time.ZoneOffset;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
 
 public class IcebergSysTableColumnValue implements ColumnValue {
     private static final String DEFAULT_TIME_ZONE = "Asia/Shanghai";
@@ -111,6 +112,11 @@ public class IcebergSysTableColumnValue implements 
ColumnValue {
         return (BigDecimal) fieldData;
     }
 
+    @Override
+    public UUID getUuid() {
+        return (UUID) fieldData;
+    }
+
     @Override
     public String getString() {
         return (String) fieldData;
@@ -145,9 +151,11 @@ public class IcebergSysTableColumnValue implements 
ColumnValue {
     @Override
     public LocalDateTime getDateTime() {
         // NTZ is a wall-clock value; only timestamptz mapped to DATETIME uses 
the session zone.
-        ZoneId zone = icebergType instanceof Types.TimestampType
-                && !((Types.TimestampType) icebergType).shouldAdjustToUTC()
-                ? ZoneOffset.UTC : ZoneId.of(timezone);
+        boolean withoutZone = (icebergType instanceof Types.TimestampType
+                && !((Types.TimestampType) icebergType).shouldAdjustToUTC())
+                || (icebergType instanceof Types.TimestampNanoType
+                && !((Types.TimestampNanoType) 
icebergType).shouldAdjustToUTC());
+        ZoneId zone = withoutZone ? ZoneOffset.UTC : ZoneId.of(timezone);
         return LocalDateTime.ofInstant(timestampInstant(), zone);
     }
 
@@ -157,6 +165,11 @@ public class IcebergSysTableColumnValue implements 
ColumnValue {
     }
 
     private Instant timestampInstant() {
+        if (icebergType instanceof Types.TimestampNanoType) {
+            long nanos = (long) fieldData;
+            return Instant.ofEpochSecond(Math.floorDiv(nanos, 1_000_000_000L),
+                    Math.floorMod(nanos, 1_000_000_000L));
+        }
         long micros = (long) fieldData;
         return Instant.ofEpochSecond(Math.floorDiv(micros, 1_000_000L),
                 Math.floorMod(micros, 1_000_000L) * 1_000L);
diff --git 
a/fe/be-java-extensions/iceberg-metadata-scanner/src/test/java/org/apache/doris/iceberg/IcebergMetadataTimestampNsTest.java
 
b/fe/be-java-extensions/iceberg-metadata-scanner/src/test/java/org/apache/doris/iceberg/IcebergMetadataTimestampNsTest.java
new file mode 100644
index 00000000000..3f98a8b49bc
--- /dev/null
+++ 
b/fe/be-java-extensions/iceberg-metadata-scanner/src/test/java/org/apache/doris/iceberg/IcebergMetadataTimestampNsTest.java
@@ -0,0 +1,194 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.iceberg;
+
+import org.apache.doris.jni.spi.utils.OffHeap;
+import org.apache.doris.jni.spi.vec.ColumnType;
+import org.apache.doris.jni.spi.vec.ColumnValue;
+import org.apache.doris.jni.spi.vec.VectorColumn;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.iceberg.DataFiles;
+import org.apache.iceberg.FileScanTask;
+import org.apache.iceberg.MetadataTableType;
+import org.apache.iceberg.MetadataTableUtils;
+import org.apache.iceberg.Metrics;
+import org.apache.iceberg.PartitionData;
+import org.apache.iceberg.PartitionSpec;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.Table;
+import org.apache.iceberg.hadoop.HadoopTables;
+import org.apache.iceberg.io.CloseableIterable;
+import org.apache.iceberg.types.Conversions;
+import org.apache.iceberg.types.Types;
+import org.apache.iceberg.util.DateTimeUtil;
+import org.apache.iceberg.util.SerializationUtil;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.file.Path;
+import java.time.LocalDateTime;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+public class IcebergMetadataTimestampNsTest {
+    @BeforeAll
+    public static void useUnsafeAllocation() {
+        // The memory tracker natives are registered by BE; these tests run in 
Java.
+        OffHeap.setTesting();
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = {"UTC", "Asia/Shanghai"})
+    public void preservesNanosecondBoundsAndNulls(String zone) {
+        long[] nanos = {Long.MIN_VALUE, -1_000_000_001L, -1_000_000_000L, 
-999_999_999L, -1L,
+                0L, 1L, 999_999_999L, 1_000_000_000L, 1_234_567_890L,
+                DateTimeUtil.nanosFromTimestamp(LocalDateTime.of(2024, 2, 29, 
12, 34, 56, 123456789)),
+                Long.MAX_VALUE};
+        Types.TimestampNanoType type = Types.TimestampNanoType.withoutZone();
+        VectorColumn column = VectorColumn.createWritableColumn(
+                ColumnType.parseType("bound", "timestamp_ns"), nanos.length + 
1);
+        try {
+            for (int i = 0; i < nanos.length; i++) {
+                Object bound = Conversions.fromByteBuffer(type, 
Conversions.toByteBuffer(type, nanos[i]));
+                column.appendValue(new IcebergSysTableColumnValue(bound, zone, 
type));
+                
Assertions.assertEquals(DateTimeUtil.timestampFromNanos(nanos[i]), 
column.getTimestampNs(i));
+                Assertions.assertEquals(nanos[i], OffHeap.getLong(null, 
column.dataAddress() + i * Long.BYTES));
+            }
+            column.appendValue(new IcebergSysTableColumnValue(null, zone, 
type));
+            Assertions.assertTrue(column.isNullAt(nanos.length));
+        } finally {
+            column.close();
+        }
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = {"UTC", "Asia/Shanghai"})
+    public void propagatesNanosecondTypesThroughContainers(String zone) {
+        Types.TimestampNanoType type = Types.TimestampNanoType.withoutZone();
+        Types.StructType struct = Types.StructType.of(
+                Types.NestedField.optional(1, "ns", type),
+                Types.NestedField.optional(2, "micros", 
Types.TimestampType.withoutZone()));
+        PartitionData record = new PartitionData(struct);
+        record.set(0, -1L);
+        record.set(1, -1L);
+        ColumnValue[] values = {
+                new IcebergSysTableColumnValue(Arrays.asList(-1L, null), zone,
+                        Types.ListType.ofOptional(3, type)),
+                new IcebergSysTableColumnValue(Map.of("ts", -1L), zone,
+                        Types.MapType.ofOptional(4, 5, Types.StringType.get(), 
type)),
+                new IcebergSysTableColumnValue(record, zone, struct)
+        };
+        String[] types = {"array<timestamp_ns>", "map<string,timestamp_ns>",
+                "struct<ns:timestamp_ns,micros:datetimev2(6)>"};
+        LocalDateTime expected = LocalDateTime.of(1969, 12, 31, 23, 59, 59, 
999999999);
+        Object[] expectedValues = {Arrays.asList(expected, null), Map.of("ts", 
expected),
+                Map.of("ns", expected, "micros", 
expected.withNano(999999000))};
+        for (int i = 0; i < types.length; i++) {
+            VectorColumn column = 
VectorColumn.createWritableColumn(ColumnType.parseType("nested", types[i]), 1);
+            try {
+                column.appendValue(values[i]);
+                Assertions.assertEquals(expectedValues[i], 
column.getObjectColumn(0, 1)[0]);
+            } finally {
+                column.close();
+            }
+        }
+    }
+
+    @Test
+    public void preservesUntypedMicrosecondConstructors() {
+        long micros = 1_234_567L;
+        LocalDateTime utc = LocalDateTime.of(1970, 1, 1, 0, 0, 1, 234567000);
+        Assertions.assertEquals(utc.plusHours(8), new 
IcebergSysTableColumnValue(micros).getDateTime());
+        Assertions.assertEquals(utc, new IcebergSysTableColumnValue(micros, 
"UTC").getDateTime());
+        Assertions.assertEquals(utc.plusHours(8),
+                new IcebergSysTableColumnValue(micros, 
"Asia/Shanghai").getDateTime());
+        Assertions.assertEquals(utc, new IcebergSysTableColumnValue(micros, 
"Asia/Shanghai").getTimeStampTz());
+    }
+
+    @ParameterizedTest
+    @CsvSource({"FILES,UTC", "FILES,Asia/Shanghai", "PARTITIONS,UTC", 
"PARTITIONS,Asia/Shanghai"})
+    public void scansSerializedNanosecondMetadata(MetadataTableType 
metadataType, String zone,
+            @TempDir Path warehouse) throws IOException {
+        Types.TimestampNanoType type = Types.TimestampNanoType.withoutZone();
+        Schema schema = new Schema(Types.NestedField.optional(1, "ts_ns", 
type));
+        PartitionSpec spec = 
PartitionSpec.builderFor(schema).identity("ts_ns").build();
+        Table table = new HadoopTables(new Configuration()).create(schema, 
spec,
+                Map.of("format-version", "3"), 
warehouse.resolve("t").toString());
+        LocalDateTime expected = LocalDateTime.of(2024, 2, 29, 12, 34, 56, 
123456789);
+        long nanos = DateTimeUtil.nanosFromTimestamp(expected);
+        PartitionData partition = new PartitionData(spec.partitionType());
+        partition.set(0, nanos);
+        Map<Integer, ByteBuffer> bounds = Map.of(1, 
Conversions.toByteBuffer(type, nanos));
+        Metrics metrics = new Metrics(1L, Map.of(1, 8L), Map.of(1, 1L), 
Map.of(1, 0L),
+                Map.of(), bounds, bounds);
+        table.newAppend().appendFile(DataFiles.builder(spec)
+                .withPath(warehouse.resolve("t/data/f.parquet").toString())
+                
.withFileSizeInBytes(10).withPartition(partition).withMetrics(metrics).build()).commit();
+
+        Table metadata = MetadataTableUtils.createMetadataTableInstance(table, 
metadataType);
+        // Request readable_metrics before partition to exercise the projected 
row order as well.
+        boolean files = metadataType == MetadataTableType.FILES;
+        Schema projection = files
+                ? new Schema(metadata.schema().findField("readable_metrics"), 
metadata.schema().findField("partition"))
+                : new Schema(metadata.schema().findField("partition"));
+        int rows = 0;
+        try (CloseableIterable<FileScanTask> tasks = 
metadata.newScan().project(projection).planFiles()) {
+            for (FileScanTask task : tasks) {
+                Map<String, String> params = new HashMap<>();
+                params.put("serialized_split", 
SerializationUtil.serializeToBase64(task));
+                params.put("time_zone", zone);
+                params.put("required_fields", files ? 
"readable_metrics,partition" : "partition");
+                String partitionType = "struct<ts_ns:timestamp_ns>";
+                String metricsType = 
"struct<ts_ns:struct<column_size:bigint,value_count:bigint,"
+                        + "null_value_count:bigint,nan_value_count:bigint,"
+                        + 
"lower_bound:timestamp_ns,upper_bound:timestamp_ns>>";
+                params.put("required_types", files ? metricsType + "#" + 
partitionType : partitionType);
+                IcebergSysTableJniScanner scanner = new 
IcebergSysTableJniScanner(16, params);
+                scanner.open();
+                try {
+                    Assertions.assertNotEquals(0, scanner.getNextBatchMeta());
+                    Assertions.assertEquals(1, 
scanner.getTable().getNumRows());
+                    int partitionIndex = files ? 1 : 0;
+                    Assertions.assertEquals(expected,
+                            
scanner.getTable().getColumn(partitionIndex).getStruct(0).get("ts_ns"));
+                    if (files) {
+                        Map<?, ?> readable = (Map<?, ?>) 
scanner.getTable().getColumn(0).getStruct(0).get("ts_ns");
+                        Assertions.assertEquals(expected, 
readable.get("lower_bound"));
+                        Assertions.assertEquals(expected, 
readable.get("upper_bound"));
+                    }
+                    rows += scanner.getTable().getNumRows();
+                    scanner.releaseTable();
+                    Assertions.assertEquals(0, scanner.getNextBatchMeta());
+                } finally {
+                    scanner.releaseTable();
+                    scanner.close();
+                }
+            }
+        }
+        Assertions.assertEquals(1, rows);
+    }
+}
diff --git 
a/fe/be-java-extensions/iceberg-metadata-scanner/src/test/java/org/apache/doris/iceberg/IcebergSysTableUuidTest.java
 
b/fe/be-java-extensions/iceberg-metadata-scanner/src/test/java/org/apache/doris/iceberg/IcebergSysTableUuidTest.java
new file mode 100644
index 00000000000..3a0645371f2
--- /dev/null
+++ 
b/fe/be-java-extensions/iceberg-metadata-scanner/src/test/java/org/apache/doris/iceberg/IcebergSysTableUuidTest.java
@@ -0,0 +1,181 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.iceberg;
+
+import org.apache.doris.jni.spi.utils.OffHeap;
+import org.apache.doris.jni.spi.vec.ColumnType;
+import org.apache.doris.jni.spi.vec.ColumnValue;
+import org.apache.doris.jni.spi.vec.VectorColumn;
+
+import org.apache.iceberg.DataFile;
+import org.apache.iceberg.DataFiles;
+import org.apache.iceberg.FileFormat;
+import org.apache.iceberg.Metrics;
+import org.apache.iceberg.MetricsUtil;
+import org.apache.iceberg.PartitionData;
+import org.apache.iceberg.PartitionSpec;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.StructLike;
+import org.apache.iceberg.types.Conversions;
+import org.apache.iceberg.types.Type;
+import org.apache.iceberg.types.Types;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+public class IcebergSysTableUuidTest {
+    private static final UUID UUID_VALUE = 
UUID.fromString("00112233-4455-6677-8899-aabbccddeeff");
+    private static final UUID HIGH_UUID = 
UUID.fromString("fedcba98-7654-3210-fedc-ba9876543210");
+
+    @BeforeAll
+    public static void enableOffHeapTesting() {
+        OffHeap.setTesting();
+    }
+
+    @Test
+    public void preservesUuidReadableMetricsBounds() {
+        Schema schema = new Schema(Types.NestedField.optional(1, "id", 
Types.UUIDType.get()));
+        Map<Integer, ByteBuffer> lower = Collections.singletonMap(1,
+                Conversions.toByteBuffer(Types.UUIDType.get(), UUID_VALUE));
+        Map<Integer, ByteBuffer> upper = Collections.singletonMap(1,
+                Conversions.toByteBuffer(Types.UUIDType.get(), HIGH_UUID));
+        DataFile file = DataFiles.builder(PartitionSpec.unpartitioned())
+                
.withPath("uuid-metrics.parquet").withFormat(FileFormat.PARQUET).withFileSizeInBytes(1L)
+                .withMetrics(new Metrics(2L, null, Collections.singletonMap(1, 
2L),
+                        Collections.singletonMap(1, 0L), null, lower, upper))
+                .build();
+        Types.StructType metricsType = 
MetricsUtil.readableMetricsSchema(schema,
+                new Schema(DataFile.getType(Types.StructType.of()).fields()))
+                .findType("readable_metrics").asStructType();
+        StructLike metrics = MetricsUtil.readableMetricsStruct(schema, file, 
metricsType);
+        Map<?, ?> restored = (Map<?, ?>) roundTrip(metrics, metricsType,
+                
"struct<id:struct<column_size:bigint,value_count:bigint,null_value_count:bigint,"
+                        + 
"nan_value_count:bigint,lower_bound:uuid,upper_bound:uuid>>");
+        Map<?, ?> bounds = (Map<?, ?>) restored.get("id");
+        Assertions.assertEquals(UUID_VALUE, bounds.get("lower_bound"));
+        Assertions.assertEquals(HIGH_UUID, bounds.get("upper_bound"));
+        Assertions.assertEquals(2L, bounds.get("value_count"));
+    }
+
+    @Test
+    public void preservesUuidIdentityPartitionsAndNulls() {
+        Schema schema = new Schema(Types.NestedField.optional(1, "id", 
Types.UUIDType.get()));
+        PartitionSpec spec = 
PartitionSpec.builderFor(schema).identity("id").build();
+        PartitionData partition = new PartitionData(spec.partitionType());
+        for (UUID value : Arrays.asList(UUID_VALUE, HIGH_UUID, null)) {
+            partition.set(0, value);
+            Assertions.assertEquals(Collections.singletonMap("id", value),
+                    roundTrip(partition, spec.partitionType(), 
"struct<id:uuid>"));
+        }
+        Assertions.assertNull(roundTrip(null, spec.partitionType(), 
"struct<id:uuid>"));
+    }
+
+    @Test
+    public void preservesUuidBitsAndNullsThroughAllConstructors() {
+        UUID[] values = {UUID_VALUE, new UUID(0L, 0L), new UUID(-1L, -1L),
+                new UUID(Long.MIN_VALUE, Long.MAX_VALUE), HIGH_UUID, null};
+        VectorColumn column = 
VectorColumn.createWritableColumn(ColumnType.parseType("id", "uuid"), 1);
+        try {
+            for (UUID value : values) {
+                column.appendValue(new IcebergSysTableColumnValue(value));
+                column.appendValue(new IcebergSysTableColumnValue(value, 
"UTC"));
+                column.appendValue(new IcebergSysTableColumnValue(value, 
"UTC", Types.UUIDType.get()));
+            }
+            for (int i = 0; i < values.length; i++) {
+                Assertions.assertArrayEquals(new UUID[] {values[i], values[i], 
values[i]},
+                        column.getUuidColumn(i * 3, (i + 1) * 3));
+            }
+        } finally {
+            column.close();
+        }
+    }
+
+    @Test
+    public void preservesUuidListsAndMapKeysAndValues() {
+        List<UUID> elements = Arrays.asList(UUID_VALUE, null, HIGH_UUID);
+        Types.ListType listType = Types.ListType.ofOptional(1, 
Types.UUIDType.get());
+        Assertions.assertEquals(elements, roundTrip(elements, listType, 
"array<uuid>"));
+        Assertions.assertNull(roundTrip(null, listType, "array<uuid>"));
+
+        Map<UUID, UUID> entries = new LinkedHashMap<>();
+        entries.put(UUID_VALUE, HIGH_UUID);
+        entries.put(new UUID(0L, 0L), null);
+        Types.MapType mapType = Types.MapType.ofOptional(1, 2, 
Types.UUIDType.get(), Types.UUIDType.get());
+        Assertions.assertEquals(entries, roundTrip(entries, mapType, 
"map<uuid,uuid>"));
+        Assertions.assertNull(roundTrip(null, mapType, "map<uuid,uuid>"));
+    }
+
+    @Test
+    public void preservesUuidInMixedAndReorderedStructFields() {
+        Types.StructType structType = Types.StructType.of(
+                Types.NestedField.optional(1, "count", 
Types.IntegerType.get()),
+                Types.NestedField.optional(2, "label", Types.StringType.get()),
+                Types.NestedField.optional(3, "id", Types.UUIDType.get()));
+        PartitionData record = new PartitionData(structType);
+        record.set(0, 7);
+        record.set(1, "uuid-partition");
+        record.set(2, UUID_VALUE);
+        Map<String, Object> expected = new LinkedHashMap<>();
+        expected.put("count", 7);
+        expected.put("label", "uuid-partition");
+        expected.put("id", UUID_VALUE);
+        Assertions.assertEquals(expected, roundTrip(record, structType, 
"struct<count:int,label:string,id:uuid>"));
+
+        List<ColumnValue> projected = new ArrayList<>();
+        new IcebergSysTableColumnValue(record, "UTC", structType)
+                .unpackStruct(Arrays.asList(2, 0, 1), projected);
+        Assertions.assertEquals(UUID_VALUE, projected.get(0).getUuid());
+        Assertions.assertEquals(7, projected.get(1).getInt());
+        Assertions.assertEquals("uuid-partition", 
projected.get(2).getString());
+    }
+
+    @Test
+    public void preservesBinaryMetadataOutput() {
+        byte[] bytes = {0, -1, 0};
+        VectorColumn column = 
VectorColumn.createWritableColumn(ColumnType.parseType("value", "varbinary"), 
1);
+        try {
+            column.appendValue(new 
IcebergSysTableColumnValue(ByteBuffer.wrap(bytes), "UTC", 
Types.BinaryType.get()));
+            // Java output uses [length, address] records; BE input uses 
StringView records.
+            long record = column.dataAddress();
+            Assertions.assertEquals(bytes.length, OffHeap.getLong(null, 
record));
+            long address = OffHeap.getLong(null, record + Long.BYTES);
+            Assertions.assertArrayEquals(bytes, OffHeap.getByte(null, address, 
bytes.length));
+        } finally {
+            column.close();
+        }
+    }
+
+    private static Object roundTrip(Object value, Type icebergType, String 
dorisType) {
+        VectorColumn column = 
VectorColumn.createWritableColumn(ColumnType.parseType("value", dorisType), 1);
+        try {
+            column.appendValue(new IcebergSysTableColumnValue(value, "UTC", 
icebergType));
+            return column.getObjectColumn(0, 1)[0];
+        } finally {
+            column.close();
+        }
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to