ajantha-bhat commented on code in PR #11904: URL: https://github.com/apache/iceberg/pull/11904#discussion_r1911927458
########## api/src/test/java/org/apache/iceberg/util/RandomUtil.java: ########## @@ -237,7 +237,7 @@ private static BigInteger randomUnscaled(int precision, Random random) { } public static List<Object> generateList( - Random random, Types.ListType list, Supplier<Object> elementResult) { Review Comment: Addressing the nit from https://github.com/apache/iceberg/pull/11919/#discussion_r1909246082 ########## parquet/src/main/java/org/apache/iceberg/data/parquet/BaseParquetWriter.java: ########## @@ -192,13 +205,17 @@ public Optional<ParquetValueWriters.PrimitiveWriter<?>> visit( @Override public Optional<ParquetValueWriters.PrimitiveWriter<?>> visit( LogicalTypeAnnotation.DateLogicalTypeAnnotation dateType) { - return Optional.of(new DateWriter(desc)); + return dateWriter(desc); } @Override public Optional<ParquetValueWriters.PrimitiveWriter<?>> visit( LogicalTypeAnnotation.TimeLogicalTypeAnnotation timeType) { - return Optional.of(new TimeWriter(desc)); + Preconditions.checkArgument( Review Comment: Added this check as for timestamp there was a check to process only MICROS. ########## parquet/src/main/java/org/apache/iceberg/parquet/ParquetValueWriters.java: ########## @@ -313,6 +327,44 @@ public void write(int repetitionLevel, ByteBuffer buffer) { } } + private static class FixedBufferWriter extends PrimitiveWriter<ByteBuffer> { + private final int length; + + private FixedBufferWriter(ColumnDescriptor desc) { + super(desc); + this.length = desc.getPrimitiveType().getTypeLength(); + } + + @Override + public void write(int repetitionLevel, ByteBuffer buffer) { + Preconditions.checkArgument( + buffer.remaining() == length, + "Cannot write byte buffer of length %s as fixed[%s]", + buffer.remaining(), + length); + column.writeBinary(repetitionLevel, Binary.fromReusedByteBuffer(buffer)); + } + } + + private static class FixedWriter extends PrimitiveWriter<byte[]> { Review Comment: I just moved this class from `BaseParquetWriter`, it was missing validation for length. I added it. ########## data/src/test/java/org/apache/iceberg/data/parquet/TestInternalData.java: ########## @@ -0,0 +1,94 @@ +/* + * 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.iceberg.data.parquet; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.File; +import java.io.IOException; +import java.util.List; +import org.apache.iceberg.Files; +import org.apache.iceberg.InternalTestHelpers; +import org.apache.iceberg.PartitionSpec; +import org.apache.iceberg.RandomInternalData; +import org.apache.iceberg.Schema; +import org.apache.iceberg.StructLike; +import org.apache.iceberg.data.DataTest; +import org.apache.iceberg.io.CloseableIterable; +import org.apache.iceberg.io.DataWriter; +import org.apache.iceberg.io.OutputFile; +import org.apache.iceberg.parquet.Parquet; +import org.apache.iceberg.relocated.com.google.common.collect.Lists; + +public class TestInternalData extends DataTest { Review Comment: Kept this class in data module instead of parquet because, parquet module don't have `DataTest`. It will be lot of code duplication to have it in parquet module. ########## parquet/src/main/java/org/apache/iceberg/data/parquet/BaseParquetWriter.java: ########## @@ -208,11 +225,7 @@ public Optional<ParquetValueWriters.PrimitiveWriter<?>> visit( LogicalTypeAnnotation.TimeUnit.MICROS.equals(timestampType.getUnit()), "Cannot write timestamp in %s, only MICROS is supported", timestampType.getUnit()); - if (timestampType.isAdjustedToUTC()) { - return Optional.of(new TimestamptzWriter(desc)); - } else { - return Optional.of(new TimestampWriter(desc)); - } + return timestampWriter(desc, timestampType.isAdjustedToUTC()); Review Comment: Should I pass a `TimeUnit` to avoid modifying the signature in the future when other units are supported? Also same for timeType ########## spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/data/SparkParquetReaders.java: ########## @@ -373,41 +371,6 @@ public Decimal read(Decimal ignored) { } } - private static class TimestampMillisReader extends UnboxedReader<Long> { Review Comment: Only removed for latest version of spark, thinking when we deprecate the older versions, this code will be removed. Spark-3.3 is deprecated. Spark-3.4 Should I handle it? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org