-
Notifications
You must be signed in to change notification settings - Fork 3k
Support structured streaming read for Iceberg #2272
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
84d20fe
Support structured streaming read for Iceberg
XuQianJin-Stars 01995a9
Support structured streaming read for Iceberg
3e1cd20
Support structured streaming read for Iceberg
057b260
Support structured streaming read for Iceberg
b0bfca3
Support structured streaming read for Iceberg
db6cdb0
Support structured streaming read for Iceberg
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
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 |
|---|---|---|
|
|
@@ -188,6 +188,26 @@ private StructType lazyType() { | |
| return type; | ||
| } | ||
|
|
||
| protected Long splitSize() { | ||
| return splitSize; | ||
| } | ||
|
|
||
| protected Integer splitLookback() { | ||
| return splitLookback; | ||
| } | ||
|
|
||
| protected Long splitOpenFileCost() { | ||
| return splitOpenFileCost; | ||
| } | ||
|
|
||
| protected boolean caseSensitive() { | ||
| return caseSensitive; | ||
| } | ||
|
|
||
| protected List<Expression> filterExpressions() { | ||
| return filterExpressions; | ||
| } | ||
|
|
||
| @Override | ||
| public StructType readSchema() { | ||
| return lazyType(); | ||
|
|
@@ -315,33 +335,7 @@ public Statistics estimateStatistics() { | |
|
|
||
| @Override | ||
| public boolean enableBatchRead() { | ||
| if (readUsingBatch == null) { | ||
| boolean allParquetFileScanTasks = | ||
| tasks().stream() | ||
| .allMatch(combinedScanTask -> !combinedScanTask.isDataTask() && combinedScanTask.files() | ||
| .stream() | ||
| .allMatch(fileScanTask -> fileScanTask.file().format().equals( | ||
| FileFormat.PARQUET))); | ||
|
|
||
| boolean allOrcFileScanTasks = | ||
| tasks().stream() | ||
| .allMatch(combinedScanTask -> !combinedScanTask.isDataTask() && combinedScanTask.files() | ||
| .stream() | ||
| .allMatch(fileScanTask -> fileScanTask.file().format().equals( | ||
| FileFormat.ORC))); | ||
|
|
||
| boolean atLeastOneColumn = lazySchema().columns().size() > 0; | ||
|
|
||
| boolean onlyPrimitives = lazySchema().columns().stream().allMatch(c -> c.type().isPrimitiveType()); | ||
|
|
||
| boolean hasNoDeleteFiles = tasks().stream().noneMatch(TableScanUtil::hasDeletes); | ||
|
|
||
| boolean batchReadsEnabled = batchReadsEnabled(allParquetFileScanTasks, allOrcFileScanTasks); | ||
|
|
||
| this.readUsingBatch = batchReadsEnabled && hasNoDeleteFiles && (allOrcFileScanTasks || | ||
| (allParquetFileScanTasks && atLeastOneColumn && onlyPrimitives)); | ||
| } | ||
| return readUsingBatch; | ||
| return readUsingBatch == null ? checkEnableBatchRead(tasks()) : readUsingBatch; | ||
| } | ||
|
|
||
| private boolean batchReadsEnabled(boolean isParquetOnly, boolean isOrcOnly) { | ||
|
|
@@ -389,7 +383,7 @@ private static void mergeIcebergHadoopConfs( | |
| .forEach(key -> baseConf.set(key.replaceFirst("hadoop.", ""), options.get(key))); | ||
| } | ||
|
|
||
| private List<CombinedScanTask> tasks() { | ||
| protected List<CombinedScanTask> tasks() { | ||
| if (tasks == null) { | ||
| TableScan scan = table | ||
| .newScan() | ||
|
|
@@ -440,6 +434,35 @@ private List<CombinedScanTask> tasks() { | |
| return tasks; | ||
| } | ||
|
|
||
| // An extracted method which will be overrided by StreamingReader. This is because the tasks generated by Streaming is | ||
| // per batch and cannot be planned like Reader beforehand. | ||
| protected boolean checkEnableBatchRead(List<CombinedScanTask> taskList) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with this, |
||
| boolean allParquetFileScanTasks = | ||
| taskList.stream() | ||
| .allMatch(combinedScanTask -> !combinedScanTask.isDataTask() && combinedScanTask.files() | ||
| .stream() | ||
| .allMatch(fileScanTask -> fileScanTask.file().format().equals( | ||
| FileFormat.PARQUET))); | ||
|
|
||
| boolean allOrcFileScanTasks = | ||
| taskList.stream() | ||
| .allMatch(combinedScanTask -> !combinedScanTask.isDataTask() && combinedScanTask.files() | ||
| .stream() | ||
| .allMatch(fileScanTask -> fileScanTask.file().format().equals( | ||
| FileFormat.ORC))); | ||
|
|
||
| boolean atLeastOneColumn = lazySchema().columns().size() > 0; | ||
|
|
||
| boolean onlyPrimitives = lazySchema().columns().stream().allMatch(c -> c.type().isPrimitiveType()); | ||
|
|
||
| boolean hasNoDeleteFiles = taskList.stream().noneMatch(TableScanUtil::hasDeletes); | ||
|
|
||
| boolean batchReadsEnabled = batchReadsEnabled(allParquetFileScanTasks, allOrcFileScanTasks); | ||
|
|
||
| return batchReadsEnabled && hasNoDeleteFiles && (allOrcFileScanTasks || | ||
| (allParquetFileScanTasks && atLeastOneColumn && onlyPrimitives)); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return String.format( | ||
|
|
||
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
Oops, something went wrong.
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.
So it seems like we're not using the checkpointLocation here, do we not need to store anything to be able to recover on failure? I think this is the case because as we read data it's not like it gets "consumed" but I just want to make sure.