-
Notifications
You must be signed in to change notification settings - Fork 3.8k
fix(delta): drain all batches per scan file in DeltaInputSourceIterator #19592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
abhishekrb19
merged 5 commits into
apache:master
from
rinchinov:fix/delta-lake-batch-iteration-18606
Jun 18, 2026
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
54d0b57
fix(delta): drain all batches per scan file in DeltaInputSourceIterator
rinchinov 6b103c6
test(delta): add regression test for GH-18606 batch drain fix
rinchinov 7bb82fd
test(delta): add BatchDrainRegressionTests to DeltaInputSourceTest fo…
rinchinov 910bd75
style: add missing newline at end of LargeRowGroupDeltaTable.java
rinchinov 0c9e615
fix(delta): close drained file iterator before advancing
rinchinov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...talake-extensions/src/test/java/org/apache/druid/delta/input/LargeRowGroupDeltaTable.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /* | ||
| * 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.delta.input; | ||
|
|
||
| import com.google.common.collect.ImmutableList; | ||
| import org.apache.druid.data.input.ColumnsFilter; | ||
| import org.apache.druid.data.input.InputRowSchema; | ||
| import org.apache.druid.data.input.impl.DimensionsSpec; | ||
| import org.apache.druid.data.input.impl.LongDimensionSchema; | ||
| import org.apache.druid.data.input.impl.StringDimensionSchema; | ||
| import org.apache.druid.data.input.impl.TimestampSpec; | ||
|
|
||
| /** | ||
| * Descriptor for a Delta table with 2 Parquet files × 2000 rows = 4000 rows total. | ||
| * | ||
| * Each file has more than 1024 rows, ensuring the Delta kernel reads more than one | ||
| * batch per file. Used as a regression test for GH-18606 where | ||
| * {@link DeltaInputSourceReader} only returned the first 1024 rows per file. | ||
| * | ||
| * Generated by src/test/resources/create_delta_table.py (large-row-group-table). | ||
| */ | ||
| public class LargeRowGroupDeltaTable | ||
| { | ||
| public static final String DELTA_TABLE_PATH = | ||
| "src/test/resources/large-row-group-table"; | ||
|
|
||
| public static final int EXPECTED_ROW_COUNT = 4000; | ||
|
|
||
| public static final InputRowSchema SCHEMA = new InputRowSchema( | ||
| new TimestampSpec("id", "posix", null), | ||
| new DimensionsSpec(ImmutableList.of( | ||
| new LongDimensionSchema("id"), | ||
| new StringDimensionSchema("name") | ||
| )), | ||
| ColumnsFilter.all() | ||
| ); | ||
| } | ||
|
rinchinov marked this conversation as resolved.
Outdated
|
||
Binary file added
BIN
+152 Bytes
...-row-group-table/.part-00000-42349806-104f-42a0-a6fe-5397f37d29d8-c000.snappy.parquet.crc
Binary file not shown.
Binary file added
BIN
+152 Bytes
...-row-group-table/.part-00001-42b5d278-2c32-4094-af60-5eaca2f7ba03-c000.snappy.parquet.crc
Binary file not shown.
Binary file added
BIN
+20 Bytes
...nsions/src/test/resources/large-row-group-table/_delta_log/.00000000000000000000.json.crc
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
...-extensions/src/test/resources/large-row-group-table/_delta_log/00000000000000000000.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| {"commitInfo":{"timestamp":1781690365208,"operation":"WRITE","operationParameters":{"mode":"Overwrite","partitionBy":"[]"},"isolationLevel":"Serializable","isBlindAppend":false,"operationMetrics":{"numFiles":"2","numOutputRows":"4000","numOutputBytes":"36263"},"engineInfo":"Apache-Spark/3.5.0 Delta-Lake/3.2.0","txnId":"f2a1da56-9880-474d-80cb-520430c4d221"}} | ||
| {"metaData":{"id":"c1c6ec87-61f6-4ca9-8b67-2edd4a2e6acb","format":{"provider":"parquet","options":{}},"schemaString":"{\"type\":\"struct\",\"fields\":[{\"name\":\"id\",\"type\":\"long\",\"nullable\":true,\"metadata\":{}},{\"name\":\"name\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}}]}","partitionColumns":[],"configuration":{},"createdTime":1781690363342}} | ||
| {"protocol":{"minReaderVersion":1,"minWriterVersion":2}} | ||
| {"add":{"path":"part-00000-42349806-104f-42a0-a6fe-5397f37d29d8-c000.snappy.parquet","partitionValues":{},"size":18078,"modificationTime":1781690364771,"dataChange":true,"stats":"{\"numRecords\":2002,\"minValues\":{\"id\":1,\"name\":\"name_1\"},\"maxValues\":{\"id\":3995,\"name\":\"name_995\"},\"nullCount\":{\"id\":0,\"name\":0}}"}} | ||
| {"add":{"path":"part-00001-42b5d278-2c32-4094-af60-5eaca2f7ba03-c000.snappy.parquet","partitionValues":{},"size":18185,"modificationTime":1781690364771,"dataChange":true,"stats":"{\"numRecords\":1998,\"minValues\":{\"id\":0,\"name\":\"name_0\"},\"maxValues\":{\"id\":3999,\"name\":\"name_999\"},\"nullCount\":{\"id\":0,\"name\":0}}"}} |
Binary file added
BIN
+17.7 KB
...large-row-group-table/part-00000-42349806-104f-42a0-a6fe-5397f37d29d8-c000.snappy.parquet
Binary file not shown.
Binary file added
BIN
+17.8 KB
...large-row-group-table/part-00001-42b5d278-2c32-4094-af60-5eaca2f7ba03-c000.snappy.parquet
Binary file not shown.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Close exhausted file iterators before advancing
The latest commit only adds a newline, so this remains from the full PR diff: after draining currentFileIterator, hasNext() overwrites it with the next scan-file iterator without closing the exhausted one. These iterators come from Scan.transformPhysicalData(), whose close() closes the underlying Parquet physicalDataIter, so a fully read multi-file table leaks every completed file reader except the last one closed by DeltaInputSourceIterator.close(). Large Delta ingestions can therefore accumulate open Parquet readers/file handles. Close the exhausted currentFileIterator before assigning the next one, or otherwise ensure each per-file iterator is closed once it is drained.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for mentioning it, applied closing iterator