FrankChen021 commented on code in PR #19266:
URL: https://github.com/apache/druid/pull/19266#discussion_r3312283360
##########
extensions-contrib/druid-iceberg-extensions/pom.xml:
##########
@@ -760,17 +760,85 @@
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.iceberg</groupId>
+ <artifactId>iceberg-data</artifactId>
+ <version>${iceberg.core.version}</version>
+ <scope>runtime</scope>
Review Comment:
[P1] iceberg-data is not on the main compile classpath
The new production classes import `org.apache.iceberg.data.Record` and
`GenericParquetReaders`, but `iceberg-data` is declared with runtime scope.
Maven does not put runtime-scoped dependencies on the main compile classpath,
so this module cannot compile once `IcebergNativeRecordReader` and
`IcebergRecordConverter` are compiled. Use the default compile scope for
`iceberg-data`.
##########
extensions-contrib/druid-iceberg-extensions/src/main/java/org/apache/druid/iceberg/input/IcebergNativeRecordReader.java:
##########
@@ -0,0 +1,380 @@
+/*
+ * 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.druid.iceberg.input;
+
+import org.apache.druid.data.input.InputRow;
+import org.apache.druid.data.input.InputRowListPlusRawValues;
+import org.apache.druid.data.input.InputRowSchema;
+import org.apache.druid.data.input.InputSourceFactory;
+import org.apache.druid.data.input.InputSourceReader;
+import org.apache.druid.data.input.InputStats;
+import org.apache.druid.data.input.impl.MapInputRowParser;
+import org.apache.druid.java.util.common.logger.Logger;
+import org.apache.druid.java.util.common.parsers.CloseableIterator;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.iceberg.CatalogUtil;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.SchemaParser;
+import org.apache.iceberg.data.Record;
+import org.apache.iceberg.data.parquet.GenericParquetReaders;
+import org.apache.iceberg.hadoop.HadoopFileIO;
+import org.apache.iceberg.io.CloseableIterable;
+import org.apache.iceberg.io.DeleteSchemaUtil;
+import org.apache.iceberg.io.FileIO;
+import org.apache.iceberg.io.InputFile;
+import org.apache.iceberg.parquet.Parquet;
+import org.apache.iceberg.types.Types;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+/**
+ * An {@link InputSourceReader} that reads an Iceberg data file and applies
+ * associated positional and equality delete files before converting records
+ * to Druid {@link InputRow} objects.
+ *
+ * Delete application follows the Iceberg v2 spec:
+ * <ol>
+ * <li>Positional deletes: read (file_path, pos) pairs, filter by current
data file,
+ * build a Set of deleted positions</li>
+ * <li>Equality deletes: read key tuples from equality delete files, build
Sets
+ * of deleted key values per equality field set</li>
+ * <li>Stream data file: for each record, skip if position-deleted or
equality-deleted</li>
+ * </ol>
+ *
+ * Only Parquet file format is supported. ORC and Avro require additional
dependencies;
+ * see TODO https://github.com/apache/druid/issues/19472.
+ */
+public class IcebergNativeRecordReader implements InputSourceReader
+{
+ private static final Logger log = new
Logger(IcebergNativeRecordReader.class);
+
+ private final String dataFilePath;
+ private final List<DeleteFileInfo> deleteFiles;
+ private final String tableSchemaJson;
+ private final InputSourceFactory warehouseSource;
+ private final InputRowSchema inputRowSchema;
+ private final Configuration hadoopConf;
+ private final FileIO fileIO;
+ private final String fileFormat;
+
+ public IcebergNativeRecordReader(
+ final String dataFilePath,
+ final List<DeleteFileInfo> deleteFiles,
+ final String tableSchemaJson,
+ final InputSourceFactory warehouseSource,
+ final InputRowSchema inputRowSchema,
+ @Nullable final String fileIOImpl,
+ @Nullable final Map<String, String> fileIOProperties,
+ final String fileFormat
+ )
+ {
+ this.dataFilePath = dataFilePath;
+ this.deleteFiles = deleteFiles;
+ this.tableSchemaJson = tableSchemaJson;
+ this.warehouseSource = warehouseSource;
+ this.inputRowSchema = inputRowSchema;
+ this.hadoopConf = new Configuration();
Review Comment:
[P2] V2 reader drops configured warehouse/Hadoop access
The v2 path constructs a fresh Hadoop `Configuration` and then opens data
and delete files through a recreated Iceberg `FileIO`, while the configured
`warehouseSource` is only stored and never used. Existing HDFS/S3 warehouse
ingestion relies on `warehouseSource` and injected Hadoop configuration, so v2
tables with deletes can plan successfully on the controller but fail on workers
when those files require the Druid warehouse source or cluster Hadoop
credentials.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]