You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "Shekharrajak (via GitHub)" <gi...@apache.org> on 2026/04/06 10:26:38 UTC
[PR] Iceberg V2 Delete File Support (druid)
Shekharrajak opened a new pull request, #19266:
URL: https://github.com/apache/druid/pull/19266
Ref https://github.com/apache/druid/issues/19190
### Description
In IcebergCatalog.extractSnapshotDataFiles(), line:
```
dataFilePaths.add(task.file().location());
```
discards task.deletes() entirely. Every FileScanTask from tableScan.planFiles() carries a List<DeleteFile> that must
be applied for correct v2 reads. The current code passes only raw file paths to warehouseSource, and Druid's
ParquetReader has zero awareness of Iceberg delete files.
### Changes
IcebergNativeRecordReader.java Streaming InputSourceReader using IcebergGenerics.read() -- applies positional +
equality deletes via Iceberg's own reader stack
#### Release note
Iceberg V2 Delete File Support
<hr>
##### Key changed/added classes in this PR
* `V2DeleteHandling.java`
* `IcebergNativeRecordReader.java`
* `IcebergRecordConverter.java`
* `IcebergInputSource.java`
<hr>
This PR has:
- [ ] been self-reviewed.
- [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
- [ ] added documentation for new or modified features or behaviors.
- [ ] a release note entry in the PR description.
- [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
- [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
- [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
- [ ] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
- [ ] added integration tests.
- [ ] been tested in a test Druid cluster.
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] feat: Iceberg V2 delete file support in druid-iceberg-extensions (druid)
Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #19266:
URL: https://github.com/apache/druid/pull/19266#discussion_r3040003007
##########
embedded-tests/src/test/java/org/apache/druid/testing/embedded/iceberg/IcebergV2DeleteIngestionTest.java:
##########
@@ -0,0 +1,402 @@
+/*
+ * 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.testing.embedded.iceberg;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.druid.data.input.parquet.ParquetExtensionsModule;
+import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.query.http.SqlTaskStatus;
+import org.apache.druid.testing.embedded.EmbeddedBroker;
+import org.apache.druid.testing.embedded.EmbeddedCoordinator;
+import org.apache.druid.testing.embedded.EmbeddedDruidCluster;
+import org.apache.druid.testing.embedded.EmbeddedHistorical;
+import org.apache.druid.testing.embedded.EmbeddedIndexer;
+import org.apache.druid.testing.embedded.EmbeddedOverlord;
+import org.apache.druid.testing.embedded.junit5.EmbeddedClusterTestBase;
+import org.apache.druid.testing.embedded.msq.EmbeddedMSQApis;
+import org.apache.iceberg.DataFile;
+import org.apache.iceberg.DeleteFile;
+import org.apache.iceberg.PartitionSpec;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.Table;
+import org.apache.iceberg.data.GenericRecord;
+import org.apache.iceberg.data.parquet.GenericParquetWriter;
+import org.apache.iceberg.deletes.EqualityDeleteWriter;
+import org.apache.iceberg.deletes.PositionDelete;
+import org.apache.iceberg.deletes.PositionDeleteWriter;
+import org.apache.iceberg.io.DataWriter;
+import org.apache.iceberg.io.OutputFile;
+import org.apache.iceberg.parquet.Parquet;
+import org.apache.iceberg.types.Types;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.UUID;
+
+/**
+ * End-to-end integration test for Iceberg v2 delete file support.
+ * Creates v2-format tables with positional and equality deletes,
+ * ingests via MSQ SQL, and verifies that deleted rows are excluded.
+ */
+public class IcebergV2DeleteIngestionTest extends EmbeddedClusterTestBase
+{
+ private static final String ICEBERG_NAMESPACE = "default";
+
+ private static final Schema TABLE_SCHEMA = new Schema(
+ Types.NestedField.required(1, "event_time", Types.StringType.get()),
+ Types.NestedField.required(2, "order_id", Types.IntegerType.get()),
+ Types.NestedField.required(3, "product", Types.StringType.get()),
+ Types.NestedField.required(4, "amount", Types.LongType.get())
+ );
+
+ private final IcebergRestCatalogResource icebergCatalog = new IcebergRestCatalogResource();
+
+ private final EmbeddedOverlord overlord = new EmbeddedOverlord();
+ private final EmbeddedCoordinator coordinator = new EmbeddedCoordinator();
+ private final EmbeddedIndexer indexer = new EmbeddedIndexer()
+ .setServerMemory(300_000_000L)
+ .addProperty("druid.worker.capacity", "2");
+ private final EmbeddedBroker broker = new EmbeddedBroker();
+
+ private EmbeddedMSQApis msqApis;
+
+ @Override
+ protected EmbeddedDruidCluster createCluster()
+ {
+ return EmbeddedDruidCluster
+ .withEmbeddedDerbyAndZookeeper()
+ .useLatchableEmitter()
+ .addResource(icebergCatalog)
+ .addExtension(ParquetExtensionsModule.class)
+ .addServer(overlord)
+ .addServer(coordinator)
+ .addServer(indexer)
+ .addServer(broker)
+ .addServer(new EmbeddedHistorical());
+ }
+
+ @BeforeAll
+ public void setup()
Review Comment:
## CodeQL / Missing Override annotation
This method overrides [EmbeddedClusterTestBase.setup](1); it is advisable to add an Override annotation.
[Show more details](https://github.com/apache/druid/security/code-scanning/10955)
##########
embedded-tests/src/test/java/org/apache/druid/testing/embedded/iceberg/IcebergV2DeleteIngestionTest.java:
##########
@@ -0,0 +1,402 @@
+/*
+ * 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.testing.embedded.iceberg;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.druid.data.input.parquet.ParquetExtensionsModule;
+import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.query.http.SqlTaskStatus;
+import org.apache.druid.testing.embedded.EmbeddedBroker;
+import org.apache.druid.testing.embedded.EmbeddedCoordinator;
+import org.apache.druid.testing.embedded.EmbeddedDruidCluster;
+import org.apache.druid.testing.embedded.EmbeddedHistorical;
+import org.apache.druid.testing.embedded.EmbeddedIndexer;
+import org.apache.druid.testing.embedded.EmbeddedOverlord;
+import org.apache.druid.testing.embedded.junit5.EmbeddedClusterTestBase;
+import org.apache.druid.testing.embedded.msq.EmbeddedMSQApis;
+import org.apache.iceberg.DataFile;
+import org.apache.iceberg.DeleteFile;
+import org.apache.iceberg.PartitionSpec;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.Table;
+import org.apache.iceberg.data.GenericRecord;
+import org.apache.iceberg.data.parquet.GenericParquetWriter;
+import org.apache.iceberg.deletes.EqualityDeleteWriter;
+import org.apache.iceberg.deletes.PositionDelete;
+import org.apache.iceberg.deletes.PositionDeleteWriter;
+import org.apache.iceberg.io.DataWriter;
+import org.apache.iceberg.io.OutputFile;
+import org.apache.iceberg.parquet.Parquet;
+import org.apache.iceberg.types.Types;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.UUID;
+
+/**
+ * End-to-end integration test for Iceberg v2 delete file support.
+ * Creates v2-format tables with positional and equality deletes,
+ * ingests via MSQ SQL, and verifies that deleted rows are excluded.
+ */
+public class IcebergV2DeleteIngestionTest extends EmbeddedClusterTestBase
+{
+ private static final String ICEBERG_NAMESPACE = "default";
+
+ private static final Schema TABLE_SCHEMA = new Schema(
+ Types.NestedField.required(1, "event_time", Types.StringType.get()),
+ Types.NestedField.required(2, "order_id", Types.IntegerType.get()),
+ Types.NestedField.required(3, "product", Types.StringType.get()),
+ Types.NestedField.required(4, "amount", Types.LongType.get())
+ );
+
+ private final IcebergRestCatalogResource icebergCatalog = new IcebergRestCatalogResource();
+
+ private final EmbeddedOverlord overlord = new EmbeddedOverlord();
+ private final EmbeddedCoordinator coordinator = new EmbeddedCoordinator();
+ private final EmbeddedIndexer indexer = new EmbeddedIndexer()
+ .setServerMemory(300_000_000L)
+ .addProperty("druid.worker.capacity", "2");
+ private final EmbeddedBroker broker = new EmbeddedBroker();
+
+ private EmbeddedMSQApis msqApis;
+
+ @Override
+ protected EmbeddedDruidCluster createCluster()
+ {
+ return EmbeddedDruidCluster
+ .withEmbeddedDerbyAndZookeeper()
+ .useLatchableEmitter()
+ .addResource(icebergCatalog)
+ .addExtension(ParquetExtensionsModule.class)
+ .addServer(overlord)
+ .addServer(coordinator)
+ .addServer(indexer)
+ .addServer(broker)
+ .addServer(new EmbeddedHistorical());
+ }
+
+ @BeforeAll
+ public void setup()
+ {
+ msqApis = new EmbeddedMSQApis(cluster, overlord);
+ icebergCatalog.createNamespace(ICEBERG_NAMESPACE);
+ }
+
+ @AfterAll
+ public void tearDown()
Review Comment:
## CodeQL / Missing Override annotation
This method overrides [EmbeddedClusterTestBase.tearDown](1); it is advisable to add an Override annotation.
[Show more details](https://github.com/apache/druid/security/code-scanning/10954)
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] feat: Iceberg V2 delete file support in druid-iceberg-extensions (druid)
Posted by "Shekharrajak (via GitHub)" <gi...@apache.org>.
Shekharrajak commented on PR #19266:
URL: https://github.com/apache/druid/pull/19266#issuecomment-4469921951
Noted gaps in iceberg v2 spec support https://github.com/apache/druid/issues/19471
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] feat: Iceberg V2 delete file support in druid-iceberg-extensions (druid)
Posted by "Shekharrajak (via GitHub)" <gi...@apache.org>.
Shekharrajak commented on PR #19266:
URL: https://github.com/apache/druid/pull/19266#issuecomment-4500931348
Flaky test reported https://github.com/apache/druid/issues/19491
Please help in triggering the one failed CI check run. We can work on this flaky test separately.
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] feat: Iceberg V2 delete file support in druid-iceberg-extensions (druid)
Posted by "FrankChen021 (via GitHub)" <gi...@apache.org>.
FrankChen021 commented on code in PR #19266:
URL: https://github.com/apache/druid/pull/19266#discussion_r3259155168
##########
extensions-contrib/druid-iceberg-extensions/src/main/java/org/apache/druid/iceberg/input/IcebergNativeRecordReader.java:
##########
@@ -0,0 +1,355 @@
+/*
+ * 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>
+ *
+ * All reads use Iceberg's Parquet reader with {@link GenericParquetReaders} for
+ * schema-aware reading. Files are accessed via Hadoop {@link Configuration}.
+ */
+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;
+
+ 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
+ )
+ {
+ this.dataFilePath = dataFilePath;
+ this.deleteFiles = deleteFiles;
+ this.tableSchemaJson = tableSchemaJson;
+ this.warehouseSource = warehouseSource;
+ this.inputRowSchema = inputRowSchema;
+ this.hadoopConf = new Configuration();
+ this.fileIO = buildFileIO(fileIOImpl, fileIOProperties, hadoopConf);
+ }
+
+ private static FileIO buildFileIO(
+ @Nullable final String fileIOImpl,
+ @Nullable final Map<String, String> fileIOProperties,
+ final Configuration hadoopConf
+ )
+ {
+ final Map<String, String> props = fileIOProperties == null ? Collections.emptyMap() : fileIOProperties;
+ if (fileIOImpl == null || fileIOImpl.isEmpty()) {
+ return new HadoopFileIO(hadoopConf);
+ }
+ return CatalogUtil.loadFileIO(fileIOImpl, props, hadoopConf);
+ }
+
+ @Override
+ public CloseableIterator<InputRow> read(final InputStats inputStats) throws IOException
+ {
+ final Schema tableSchema = SchemaParser.fromJson(tableSchemaJson);
+
+ // Step 1: Collect positional deletes
+ final Set<Long> deletedPositions = collectPositionalDeletes();
+
+ // Step 2: Collect equality deletes
+ final List<EqualityDeleteSet> equalityDeleteSets = collectEqualityDeletes(tableSchema);
+
+ // Step 3: Stream data file with delete application
+ final InputFile dataInputFile = fileIO.newInputFile(dataFilePath);
+ final CloseableIterable<Record> records = Parquet.read(dataInputFile)
Review Comment:
[P2] V2 delete path only reads Parquet files
The new v2 path bypasses the configured inputFormat and always opens the data file with Parquet.read(...), and the delete readers do the same for delete files. The extension still documents Iceberg data files as Parquet, ORC, or Avro via the delegated warehouseSource/inputFormat path, so any ORC/Avro Iceberg table with delete files will now route through this native reader and fail to parse the files instead of using the configured format-specific reader. Please either dispatch by Iceberg FileFormat / reader support or explicitly reject/document v2 delete support as Parquet-only.
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] feat: Iceberg V2 delete file support in druid-iceberg-extensions (druid)
Posted by "Shekharrajak (via GitHub)" <gi...@apache.org>.
Shekharrajak commented on code in PR #19266:
URL: https://github.com/apache/druid/pull/19266#discussion_r3312805995
##########
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:
https://github.com/apache/druid/pull/19266/changes/5ecc28cfb2d8ef114b40eac2de35cb00d1dd03d7
##########
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:
updated
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] feat: Iceberg V2 delete file support in druid-iceberg-extensions (druid)
Posted by "Shekharrajak (via GitHub)" <gi...@apache.org>.
Shekharrajak commented on code in PR #19266:
URL: https://github.com/apache/druid/pull/19266#discussion_r3259726270
##########
extensions-contrib/druid-iceberg-extensions/src/main/java/org/apache/druid/iceberg/input/IcebergNativeRecordReader.java:
##########
@@ -0,0 +1,355 @@
+/*
+ * 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>
+ *
+ * All reads use Iceberg's Parquet reader with {@link GenericParquetReaders} for
+ * schema-aware reading. Files are accessed via Hadoop {@link Configuration}.
+ */
+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;
+
+ 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
+ )
+ {
+ this.dataFilePath = dataFilePath;
+ this.deleteFiles = deleteFiles;
+ this.tableSchemaJson = tableSchemaJson;
+ this.warehouseSource = warehouseSource;
+ this.inputRowSchema = inputRowSchema;
+ this.hadoopConf = new Configuration();
+ this.fileIO = buildFileIO(fileIOImpl, fileIOProperties, hadoopConf);
+ }
+
+ private static FileIO buildFileIO(
+ @Nullable final String fileIOImpl,
+ @Nullable final Map<String, String> fileIOProperties,
+ final Configuration hadoopConf
+ )
+ {
+ final Map<String, String> props = fileIOProperties == null ? Collections.emptyMap() : fileIOProperties;
+ if (fileIOImpl == null || fileIOImpl.isEmpty()) {
+ return new HadoopFileIO(hadoopConf);
+ }
+ return CatalogUtil.loadFileIO(fileIOImpl, props, hadoopConf);
+ }
+
+ @Override
+ public CloseableIterator<InputRow> read(final InputStats inputStats) throws IOException
+ {
+ final Schema tableSchema = SchemaParser.fromJson(tableSchemaJson);
+
+ // Step 1: Collect positional deletes
+ final Set<Long> deletedPositions = collectPositionalDeletes();
+
+ // Step 2: Collect equality deletes
+ final List<EqualityDeleteSet> equalityDeleteSets = collectEqualityDeletes(tableSchema);
+
+ // Step 3: Stream data file with delete application
+ final InputFile dataInputFile = fileIO.newInputFile(dataFilePath);
+ final CloseableIterable<Record> records = Parquet.read(dataInputFile)
Review Comment:
Let me document for parquet only and follow up PR will add it : https://github.com/apache/druid/issues/19472
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] feat: Iceberg V2 delete file support in druid-iceberg-extensions (druid)
Posted by "FrankChen021 (via GitHub)" <gi...@apache.org>.
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] feat: Iceberg V2 delete file support in druid-iceberg-extensions (druid)
Posted by "Shekharrajak (via GitHub)" <gi...@apache.org>.
Shekharrajak commented on code in PR #19266:
URL: https://github.com/apache/druid/pull/19266#discussion_r3254176806
##########
extensions-contrib/druid-iceberg-extensions/src/main/java/org/apache/druid/iceberg/input/IcebergNativeRecordReader.java:
##########
@@ -0,0 +1,335 @@
+/*
+ * 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.Schema;
+import org.apache.iceberg.SchemaParser;
+import org.apache.iceberg.data.Record;
+import org.apache.iceberg.data.parquet.GenericParquetReaders;
+import org.apache.iceberg.hadoop.HadoopInputFile;
+import org.apache.iceberg.io.CloseableIterable;
+import org.apache.iceberg.io.DeleteSchemaUtil;
+import org.apache.iceberg.io.InputFile;
+import org.apache.iceberg.parquet.Parquet;
+import org.apache.iceberg.types.Types;
+
+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>
+ *
+ * All reads use Iceberg's Parquet reader with {@link GenericParquetReaders} for
+ * schema-aware reading. Files are accessed via Hadoop {@link Configuration}.
+ */
+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;
+
+ public IcebergNativeRecordReader(
+ final String dataFilePath,
+ final List<DeleteFileInfo> deleteFiles,
+ final String tableSchemaJson,
+ final InputSourceFactory warehouseSource,
+ final InputRowSchema inputRowSchema
+ )
+ {
+ this.dataFilePath = dataFilePath;
+ this.deleteFiles = deleteFiles;
+ this.tableSchemaJson = tableSchemaJson;
+ this.warehouseSource = warehouseSource;
+ this.inputRowSchema = inputRowSchema;
+ this.hadoopConf = new Configuration();
+ }
+
+ @Override
+ public CloseableIterator<InputRow> read(final InputStats inputStats) throws IOException
+ {
+ final Schema tableSchema = SchemaParser.fromJson(tableSchemaJson);
+
+ // Step 1: Collect positional deletes
+ final Set<Long> deletedPositions = collectPositionalDeletes();
+
+ // Step 2: Collect equality deletes
+ final List<EqualityDeleteSet> equalityDeleteSets = collectEqualityDeletes(tableSchema);
+
+ // Step 3: Stream data file with delete application
+ final InputFile dataInputFile = HadoopInputFile.fromLocation(dataFilePath, hadoopConf);
Review Comment:
Thanks for checking - updated : https://github.com/apache/druid/pull/19266/changes/23ef4dbe6c910b238c0379943b58f7fe2d954d51#diff-1b9776e43fa17c32a610eee043a6fd6cbf32b29ae4026d24ea798ac9a6f638bcR299
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] feat: Iceberg V2 delete file support in druid-iceberg-extensions (druid)
Posted by "FrankChen021 (via GitHub)" <gi...@apache.org>.
FrankChen021 commented on code in PR #19266:
URL: https://github.com/apache/druid/pull/19266#discussion_r3324570062
##########
extensions-contrib/druid-iceberg-extensions/src/main/java/org/apache/druid/iceberg/input/IcebergFileTaskInputSource.java:
##########
@@ -0,0 +1,188 @@
+/*
+ * 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 com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputRowSchema;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSourceFactory;
+import org.apache.druid.data.input.InputSourceReader;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.data.input.impl.SplittableInputSource;
+import org.apache.hadoop.conf.Configuration;
+
+import javax.annotation.Nullable;
+import java.io.File;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Stream;
+
+/**
+ * A {@link SplittableInputSource} representing a single Iceberg v2 data file with its
+ * associated delete files. Created internally by {@link IcebergInputSource} when v2
+ * delete files are detected. Reports itself as non-splittable (one file = one split)
+ * so MSQ routes it to a single worker without further splitting.
+ *
+ * This input source is JSON-serializable, carrying all metadata needed for a worker
+ * to read a data file and apply deletes without catalog access:
+ * <ul>
+ * <li>Data file path</li>
+ * <li>Delete file metadata (paths, types, equality field IDs)</li>
+ * <li>Serialized Iceberg table schema (JSON)</li>
+ * <li>warehouseSource for file I/O</li>
+ * </ul>
+ */
+public class IcebergFileTaskInputSource implements SplittableInputSource<List<String>>
+{
+ public static final String TYPE_KEY = "icebergFileTask";
+
+ private final String dataFilePath;
+ private final List<DeleteFileInfo> deleteFiles;
+ private final String tableSchemaJson;
+ private final InputSourceFactory warehouseSource;
+ private final String fileIOImpl;
+ private final Map<String, String> fileIOProperties;
+ // TODO https://github.com/apache/druid/issues/19472: extend to ORC/AVRO once iceberg-orc/iceberg-avro deps are added
+ private final String fileFormat;
+ private final Configuration hadoopConf;
+
+ @JsonCreator
+ public IcebergFileTaskInputSource(
+ @JsonProperty("dataFilePath") final String dataFilePath,
+ @JsonProperty("deleteFiles") final List<DeleteFileInfo> deleteFiles,
+ @JsonProperty("tableSchemaJson") final String tableSchemaJson,
+ @JsonProperty("warehouseSource") final InputSourceFactory warehouseSource,
+ @JsonProperty("fileIOImpl") @Nullable final String fileIOImpl,
+ @JsonProperty("fileIOProperties") @Nullable final Map<String, String> fileIOProperties,
+ @JsonProperty("fileFormat") @Nullable final String fileFormat,
+ final Configuration hadoopConf
Review Comment:
[P1] Unbound Configuration breaks v2 split deserialization
IcebergFileTaskInputSource is registered as a Jackson subtype and returned from withSplit for v2 tables, so workers need to deserialize it. The @JsonCreator leaves hadoopConf as an unannotated constructor parameter, unlike the catalog classes that use @JacksonInject @HiveConf, so Druid's ObjectMapper has no property or injectable value to bind. This can make v2 delete splits fail before reading. Inject it, annotate it, or create a safe default, and add a Jackson round-trip test for this input source.
##########
extensions-contrib/druid-iceberg-extensions/src/main/java/org/apache/druid/iceberg/input/IcebergNativeRecordReader.java:
##########
@@ -0,0 +1,381 @@
+/*
+ * 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,
+ final Configuration hadoopConf
+ )
+ {
+ this.dataFilePath = dataFilePath;
+ this.deleteFiles = deleteFiles;
+ this.tableSchemaJson = tableSchemaJson;
+ this.warehouseSource = warehouseSource;
+ this.inputRowSchema = inputRowSchema;
+ this.hadoopConf = hadoopConf;
+ this.fileIO = buildFileIO(fileIOImpl, fileIOProperties, hadoopConf);
+ this.fileFormat = fileFormat;
+ }
+
+ private void requireParquet(final String filePath)
+ {
+ if (!"PARQUET".equalsIgnoreCase(fileFormat)) {
+ throw new UnsupportedOperationException(
+ "Iceberg file format [" + fileFormat + "] is not supported for file [" + filePath
+ + "]. Only PARQUET is currently supported. See https://github.com/apache/druid/issues/19472"
+ );
+ }
+ }
+
+ private void requireParquetDeleteFile(final DeleteFileInfo deleteFileInfo)
+ {
+ if (!"PARQUET".equalsIgnoreCase(deleteFileInfo.getFormat())) {
+ throw new UnsupportedOperationException(
+ "Iceberg delete file format [" + deleteFileInfo.getFormat() + "] is not supported for file ["
+ + deleteFileInfo.getPath() + "]. Only PARQUET is currently supported. "
+ + "See https://github.com/apache/druid/issues/19472"
+ );
+ }
+ }
+
+ private static FileIO buildFileIO(
+ @Nullable final String fileIOImpl,
+ @Nullable final Map<String, String> fileIOProperties,
+ final Configuration hadoopConf
+ )
+ {
+ final Map<String, String> props = fileIOProperties == null ? Collections.emptyMap() : fileIOProperties;
+ if (fileIOImpl == null || fileIOImpl.isEmpty()) {
+ return new HadoopFileIO(hadoopConf);
+ }
+ return CatalogUtil.loadFileIO(fileIOImpl, props, hadoopConf);
+ }
+
+ @Override
+ public CloseableIterator<InputRow> read(final InputStats inputStats) throws IOException
+ {
+ final Schema tableSchema = SchemaParser.fromJson(tableSchemaJson);
+
+ // Step 1: Collect positional deletes
+ final Set<Long> deletedPositions = collectPositionalDeletes();
+
+ // Step 2: Collect equality deletes
+ final List<EqualityDeleteSet> equalityDeleteSets = collectEqualityDeletes(tableSchema);
+
+ // Step 3: Stream data file with delete application
+ requireParquet(dataFilePath);
+ final InputFile dataInputFile = fileIO.newInputFile(dataFilePath);
Review Comment:
[P1] V2 path bypasses warehouseSource file access
When delete files are present, the new reader opens data and delete files through Iceberg FileIO instead of the configured warehouseSource/inputFormat. Existing Iceberg specs use warehouseSource for S3/GCS/local access settings, endpoints, and credentials, so a table that only adds delete files can silently switch file-access mechanisms and fail or read from the wrong filesystem. The v2 path should preserve or translate the warehouseSource-backed access configuration for native reads.
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] feat: Iceberg V2 delete file support in druid-iceberg-extensions (druid)
Posted by "FrankChen021 (via GitHub)" <gi...@apache.org>.
FrankChen021 commented on code in PR #19266:
URL: https://github.com/apache/druid/pull/19266#discussion_r3273988148
##########
extensions-contrib/druid-iceberg-extensions/src/main/java/org/apache/druid/iceberg/input/IcebergNativeRecordReader.java:
##########
@@ -0,0 +1,355 @@
+/*
+ * 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>
+ *
+ * All reads use Iceberg's Parquet reader with {@link GenericParquetReaders} for
+ * schema-aware reading. Files are accessed via Hadoop {@link Configuration}.
+ */
+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;
+
+ 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
+ )
+ {
+ this.dataFilePath = dataFilePath;
+ this.deleteFiles = deleteFiles;
+ this.tableSchemaJson = tableSchemaJson;
+ this.warehouseSource = warehouseSource;
+ this.inputRowSchema = inputRowSchema;
+ this.hadoopConf = new Configuration();
+ this.fileIO = buildFileIO(fileIOImpl, fileIOProperties, hadoopConf);
+ }
+
+ private static FileIO buildFileIO(
+ @Nullable final String fileIOImpl,
+ @Nullable final Map<String, String> fileIOProperties,
+ final Configuration hadoopConf
+ )
+ {
+ final Map<String, String> props = fileIOProperties == null ? Collections.emptyMap() : fileIOProperties;
+ if (fileIOImpl == null || fileIOImpl.isEmpty()) {
+ return new HadoopFileIO(hadoopConf);
+ }
+ return CatalogUtil.loadFileIO(fileIOImpl, props, hadoopConf);
+ }
+
+ @Override
+ public CloseableIterator<InputRow> read(final InputStats inputStats) throws IOException
+ {
+ final Schema tableSchema = SchemaParser.fromJson(tableSchemaJson);
+
+ // Step 1: Collect positional deletes
+ final Set<Long> deletedPositions = collectPositionalDeletes();
+
+ // Step 2: Collect equality deletes
+ final List<EqualityDeleteSet> equalityDeleteSets = collectEqualityDeletes(tableSchema);
+
+ // Step 3: Stream data file with delete application
+ final InputFile dataInputFile = fileIO.newInputFile(dataFilePath);
+ final CloseableIterable<Record> records = Parquet.read(dataInputFile)
Review Comment:
Thanks, this now guards the data file format, but I think one edge of the original concern is still open: Iceberg delete files carry their own `deleteFile.format()`, separate from `task.file().format()`. Right now `DeleteFileInfo` only carries path/content/equality fields, and `requireParquet(deleteFileInfo.getPath())` checks the data file format, so a PARQUET data file with an ORC/AVRO delete file would still reach `Parquet.read(deleteInputFile)` instead of being explicitly rejected. Could we preserve the delete-file format and guard each delete file too?
Also, the user docs still say Iceberg data files can be Parquet, ORC, or Avro and the new v2 delete section does not call out the Parquet-only limitation, so it would be worth documenting that limitation there as well.
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] feat: Iceberg V2 delete file support in druid-iceberg-extensions (druid)
Posted by "jtuglu1 (via GitHub)" <gi...@apache.org>.
jtuglu1 commented on PR #19266:
URL: https://github.com/apache/druid/pull/19266#issuecomment-4595322740
https://github.com/apache/druid/pull/19534
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Iceberg V2 delete file support in druid-iceberg-extensions (druid)
Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #19266:
URL: https://github.com/apache/druid/pull/19266#discussion_r3039099643
##########
extensions-contrib/druid-iceberg-extensions/src/test/java/org/apache/druid/iceberg/input/V2DeleteHandlingTest.java:
##########
@@ -0,0 +1,400 @@
+/*
+ * 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 com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import org.apache.druid.data.input.ColumnsFilter;
+import org.apache.druid.data.input.InputRow;
+import org.apache.druid.data.input.InputRowSchema;
+import org.apache.druid.data.input.InputSourceReader;
+import org.apache.druid.data.input.impl.DimensionsSpec;
+import org.apache.druid.data.input.impl.LocalInputSourceFactory;
+import org.apache.druid.data.input.impl.TimestampSpec;
+import org.apache.druid.error.DruidException;
+import org.apache.druid.java.util.common.FileUtils;
+import org.apache.druid.java.util.common.parsers.CloseableIterator;
+import org.apache.iceberg.DataFile;
+import org.apache.iceberg.DeleteFile;
+import org.apache.iceberg.FileFormat;
+import org.apache.iceberg.PartitionSpec;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.Table;
+import org.apache.iceberg.catalog.Namespace;
+import org.apache.iceberg.catalog.TableIdentifier;
+import org.apache.iceberg.data.GenericRecord;
+import org.apache.iceberg.data.parquet.GenericParquetWriter;
+import org.apache.iceberg.deletes.EqualityDeleteWriter;
+import org.apache.iceberg.deletes.PositionDelete;
+import org.apache.iceberg.deletes.PositionDeleteWriter;
+import org.apache.iceberg.io.DataWriter;
+import org.apache.iceberg.io.OutputFile;
+import org.apache.iceberg.parquet.Parquet;
+import org.apache.iceberg.types.Types;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.UUID;
+
+public class V2DeleteHandlingTest
+{
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ private IcebergCatalog testCatalog;
+ private File warehouseDir;
+
+ private static final String NAMESPACE = "default";
+ private static final String TABLE_NAME = "v2TestTable";
+
+ private final Schema tableSchema = new Schema(
+ Types.NestedField.required(1, "order_id", Types.IntegerType.get()),
+ Types.NestedField.required(2, "product", Types.StringType.get()),
+ Types.NestedField.required(3, "amount", Types.DoubleType.get())
+ );
+
+ private final InputRowSchema inputRowSchema = new InputRowSchema(
+ new TimestampSpec("order_id", "auto", null),
+ new DimensionsSpec(DimensionsSpec.getDefaultSchemas(ImmutableList.of("order_id", "product", "amount"))),
+ ColumnsFilter.all(),
+ ImmutableSet.of()
+ );
+
+ @Before
+ public void setup()
+ {
+ warehouseDir = FileUtils.createTempDir();
+ testCatalog = new LocalCatalog(warehouseDir.getPath(), new HashMap<>(), true);
+ }
+
+ @After
+ public void tearDown()
+ {
+ final TableIdentifier tableId = TableIdentifier.of(Namespace.of(NAMESPACE), TABLE_NAME);
+ try {
+ testCatalog.retrieveCatalog().dropTable(tableId);
+ }
+ catch (Exception e) {
+ // ignore if table doesn't exist
+ }
+ }
+
+ @Test
+ public void testSkipModeUsesFilePathExtractionOnly() throws IOException
+ {
+ // Create a v2 table with equality deletes
+ createTableWithEqualityDelete();
+
+ // SKIP mode uses extractSnapshotDataFiles (file paths only), ignoring delete files.
+ // Verify the catalog returns the raw data file paths without considering deletes.
+ final List<String> dataFiles = testCatalog.extractSnapshotDataFiles(
+ NAMESPACE,
+ TABLE_NAME,
+ null,
+ null,
+ ResidualFilterMode.IGNORE
+ );
+
+ // Should return 1 data file (the delete file is ignored since it's not a data file)
+ Assert.assertEquals(1, dataFiles.size());
+ }
+
+ @Test
+ public void testFailModeThrowsWhenDeletesPresent() throws IOException
+ {
+ createTableWithEqualityDelete();
+
+ final IcebergInputSource inputSource = new IcebergInputSource(
+ TABLE_NAME,
+ NAMESPACE,
+ null,
+ testCatalog,
+ new LocalInputSourceFactory(),
+ null,
+ null,
+ V2DeleteHandling.FAIL
+ );
+
+ Assert.assertThrows(
+ DruidException.class,
+ () -> inputSource.reader(inputRowSchema, null, temporaryFolder.newFolder())
+ );
+ }
+
+ @Test
+ public void testFailModeDoesNotThrowWhenNoDeletes() throws IOException
+ {
+ createTableWithoutDeletes();
+
+ // When no delete files exist, FAIL mode should not throw.
+ // Verify via extractFileScanTasks that no deletes are detected.
+ final IcebergCatalog.FileScanResult result = testCatalog.extractFileScanTasks(
+ NAMESPACE,
+ TABLE_NAME,
+ null,
+ null,
+ ResidualFilterMode.IGNORE
+ );
+
+ Assert.assertFalse("Table without deletes should have hasDeleteFiles=false", result.hasDeleteFiles());
+ Assert.assertEquals(1, result.getFileScanTasks().size());
+ }
+
+ @Test
+ public void testApplyModeWithEqualityDelete() throws IOException
+ {
+ createTableWithEqualityDelete();
+
+ final IcebergInputSource inputSource = new IcebergInputSource(
+ TABLE_NAME,
+ NAMESPACE,
+ null,
+ testCatalog,
+ new LocalInputSourceFactory(),
+ null,
+ null,
+ V2DeleteHandling.APPLY
+ );
+
+ final InputSourceReader reader = inputSource.reader(inputRowSchema, null, temporaryFolder.newFolder());
+ final List<InputRow> rows = readAll(reader);
+
+ // Equality delete removed order_id=2, so only 2 rows remain
+ Assert.assertEquals(2, rows.size());
+
+ final List<Object> orderIds = new ArrayList<>();
+ for (final InputRow row : rows) {
+ orderIds.add(row.getDimension("order_id").get(0));
+ }
+ Assert.assertTrue("Should contain order_id 1", orderIds.contains("1"));
+ Assert.assertTrue("Should contain order_id 3", orderIds.contains("3"));
+ Assert.assertFalse("Should NOT contain deleted order_id 2", orderIds.contains("2"));
+ }
+
+ @Test
+ public void testApplyModeWithNoDeletesFallsBackToFilePaths() throws IOException
+ {
+ createTableWithoutDeletes();
+
+ // When APPLY mode is used but no delete files exist, the code falls through
+ // to the warehouseSource path (extracting file paths only). Verify the scan
+ // result correctly detects no deletes.
+ final IcebergCatalog.FileScanResult result = testCatalog.extractFileScanTasks(
+ NAMESPACE,
+ TABLE_NAME,
+ null,
+ null,
+ ResidualFilterMode.IGNORE
+ );
+
+ Assert.assertFalse("Table without deletes should have hasDeleteFiles=false", result.hasDeleteFiles());
+ Assert.assertEquals(1, result.getFileScanTasks().size());
+ Assert.assertNotNull(result.getTable());
+ }
+
+ @Test
+ public void testApplyModeWithPositionalDelete() throws IOException
+ {
+ createTableWithPositionalDelete();
+
+ final IcebergInputSource inputSource = new IcebergInputSource(
+ TABLE_NAME,
+ NAMESPACE,
+ null,
+ testCatalog,
+ new LocalInputSourceFactory(),
+ null,
+ null,
+ V2DeleteHandling.APPLY
+ );
+
+ final InputSourceReader reader = inputSource.reader(inputRowSchema, null, temporaryFolder.newFolder());
+ final List<InputRow> rows = readAll(reader);
+
+ // Positional delete removed row at position 1 (order_id=2), so 2 rows remain
+ Assert.assertEquals(2, rows.size());
+ }
+
+ @Test
+ public void testDefaultV2DeleteHandlingIsSkip()
+ {
+ final IcebergInputSource inputSource = new IcebergInputSource(
+ TABLE_NAME,
+ NAMESPACE,
+ null,
+ testCatalog,
+ new LocalInputSourceFactory(),
+ null,
+ null,
+ null
+ );
+ Assert.assertEquals(V2DeleteHandling.SKIP, inputSource.getV2DeleteHandling());
+ }
+
+ // --- Helper methods ---
+
+ private List<InputRow> readAll(final InputSourceReader reader) throws IOException
+ {
+ final List<InputRow> rows = new ArrayList<>();
+ try (CloseableIterator<InputRow> iterator = reader.read()) {
+ while (iterator.hasNext()) {
+ rows.add(iterator.next());
+ }
+ }
+ return rows;
+ }
+
+ private Table createBaseTable()
+ {
+ final TableIdentifier tableId = TableIdentifier.of(Namespace.of(NAMESPACE), TABLE_NAME);
+ return testCatalog.retrieveCatalog().createTable(
+ tableId,
+ tableSchema,
+ PartitionSpec.unpartitioned(),
+ new HashMap<String, String>() {{
+ put("format-version", "2");
+ }}
+ );
+ }
+
+ private DataFile writeDataFile(final Table table) throws IOException
+ {
+ final GenericRecord template = GenericRecord.create(tableSchema);
Review Comment:
## CodeQL / Unread local variable
Variable 'GenericRecord template' is never read.
[Show more details](https://github.com/apache/druid/security/code-scanning/10953)
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] feat: Iceberg V2 delete file support in druid-iceberg-extensions (druid)
Posted by "Shekharrajak (via GitHub)" <gi...@apache.org>.
Shekharrajak commented on PR #19266:
URL: https://github.com/apache/druid/pull/19266#issuecomment-4469755858
> * extensions-contrib/druid-iceberg-extensions/src/main/java/org/apache/druid/iceberg/input/IcebergInputSource.java:164 - [P1] V2 tables with deletes produce zero splits. When any delete file is present, retrieveIcebergDatafiles() sets delegateInputSource to EmptyInputSource, so createSplits() returns an empty stream and estimateNumSplits() returns 0. MSQ and parallel ingestion slice SplittableInputSource inputs exclusively through createSplits()/withSplit(), so an Iceberg v2 table with deletes will schedule no readable input slices and ingest no rows instead of using the native reader path.
updated : https://github.com/apache/druid/pull/19266/changes/309c97b387f9a7012c218ae35659654e7c13f0e3#diff-1b9776e43fa17c32a610eee043a6fd6cbf32b29ae4026d24ea798ac9a6f638bcR168
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] feat: Iceberg V2 delete file support in druid-iceberg-extensions (druid)
Posted by "FrankChen021 (via GitHub)" <gi...@apache.org>.
FrankChen021 commented on code in PR #19266:
URL: https://github.com/apache/druid/pull/19266#discussion_r3141492295
##########
extensions-contrib/druid-iceberg-extensions/src/main/java/org/apache/druid/iceberg/input/IcebergNativeRecordReader.java:
##########
@@ -0,0 +1,335 @@
+/*
+ * 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.Schema;
+import org.apache.iceberg.SchemaParser;
+import org.apache.iceberg.data.Record;
+import org.apache.iceberg.data.parquet.GenericParquetReaders;
+import org.apache.iceberg.hadoop.HadoopInputFile;
+import org.apache.iceberg.io.CloseableIterable;
+import org.apache.iceberg.io.DeleteSchemaUtil;
+import org.apache.iceberg.io.InputFile;
+import org.apache.iceberg.parquet.Parquet;
+import org.apache.iceberg.types.Types;
+
+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>
+ *
+ * All reads use Iceberg's Parquet reader with {@link GenericParquetReaders} for
+ * schema-aware reading. Files are accessed via Hadoop {@link Configuration}.
+ */
+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;
+
+ public IcebergNativeRecordReader(
+ final String dataFilePath,
+ final List<DeleteFileInfo> deleteFiles,
+ final String tableSchemaJson,
+ final InputSourceFactory warehouseSource,
+ final InputRowSchema inputRowSchema
+ )
+ {
+ this.dataFilePath = dataFilePath;
+ this.deleteFiles = deleteFiles;
+ this.tableSchemaJson = tableSchemaJson;
+ this.warehouseSource = warehouseSource;
+ this.inputRowSchema = inputRowSchema;
+ this.hadoopConf = new Configuration();
+ }
+
+ @Override
+ public CloseableIterator<InputRow> read(final InputStats inputStats) throws IOException
+ {
+ final Schema tableSchema = SchemaParser.fromJson(tableSchemaJson);
+
+ // Step 1: Collect positional deletes
+ final Set<Long> deletedPositions = collectPositionalDeletes();
+
+ // Step 2: Collect equality deletes
+ final List<EqualityDeleteSet> equalityDeleteSets = collectEqualityDeletes(tableSchema);
+
+ // Step 3: Stream data file with delete application
+ final InputFile dataInputFile = HadoopInputFile.fromLocation(dataFilePath, hadoopConf);
Review Comment:
[P1] Native reader bypasses configured warehouse access
The v2 path reads data and delete files with HadoopInputFile.fromLocation(..., new Configuration()) and never uses the configured warehouseSource or catalog FileIO properties. Existing specs that use s3/gcs/azure warehouse sources, dynamic credentials, or non-default Hadoop configuration will work on the v1 path but fail as soon as delete files are present because workers try to open the object-store paths with an empty Hadoop configuration.
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org