-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Core: Add position deletes metadata table #6365
Merged
aokolnychyi
merged 1 commit into
apache:master
from
szehon-ho:position_delete_table_only
Jan 24, 2023
Merged
Changes from all commits
Commits
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 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 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 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
42 changes: 42 additions & 0 deletions
42
core/src/main/java/org/apache/iceberg/BasePositionDeletesScanTask.java
This file contains 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,42 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.iceberg; | ||
|
||
import org.apache.iceberg.expressions.ResidualEvaluator; | ||
|
||
/** Base implementation of {@link PositionDeletesScanTask} */ | ||
class BasePositionDeletesScanTask extends BaseContentScanTask<PositionDeletesScanTask, DeleteFile> | ||
implements PositionDeletesScanTask, SplittableScanTask<PositionDeletesScanTask> { | ||
|
||
BasePositionDeletesScanTask( | ||
DeleteFile file, String schemaString, String specString, ResidualEvaluator evaluator) { | ||
super(file, schemaString, specString, evaluator); | ||
} | ||
|
||
@Override | ||
protected BasePositionDeletesScanTask self() { | ||
return this; | ||
} | ||
|
||
@Override | ||
protected PositionDeletesScanTask newSplitTask( | ||
PositionDeletesScanTask parentTask, long offset, long length) { | ||
return new SplitPositionDeletesScanTask(parentTask, offset, length); | ||
aokolnychyi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
This file contains 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 |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.concurrent.ExecutorService; | ||
import org.apache.iceberg.expressions.Binder; | ||
|
@@ -59,6 +60,23 @@ abstract class BaseScan<ThisT, T extends ScanTask, G extends ScanTaskGroup<T>> | |
private static final List<String> SCAN_WITH_STATS_COLUMNS = | ||
ImmutableList.<String>builder().addAll(SCAN_COLUMNS).addAll(STATS_COLUMNS).build(); | ||
|
||
protected static final List<String> DELETE_SCAN_COLUMNS = | ||
ImmutableList.of( | ||
"snapshot_id", | ||
"content", | ||
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. This has to differ from data file's SCAN_COLUMNS by including content, which is used in the scan to filter later. |
||
"file_path", | ||
"file_ordinal", | ||
"file_format", | ||
"block_size_in_bytes", | ||
"file_size_in_bytes", | ||
"record_count", | ||
"partition", | ||
"key_metadata", | ||
"split_offsets"); | ||
|
||
protected static final List<String> DELETE_SCAN_WITH_STATS_COLUMNS = | ||
ImmutableList.<String>builder().addAll(DELETE_SCAN_COLUMNS).addAll(STATS_COLUMNS).build(); | ||
|
||
private static final boolean PLAN_SCANS_WITH_WORKER_POOL = | ||
SystemProperties.getBoolean(SystemProperties.SCAN_THREAD_POOL_ENABLED, true); | ||
|
||
|
@@ -84,7 +102,7 @@ protected TableOperations tableOps() { | |
return null; | ||
} | ||
|
||
protected Table table() { | ||
public Table table() { | ||
return table; | ||
} | ||
|
||
|
@@ -96,6 +114,10 @@ protected TableScanContext context() { | |
return context; | ||
} | ||
|
||
protected Map<String, String> options() { | ||
return context().options(); | ||
} | ||
|
||
protected List<String> scanColumns() { | ||
return context.returnColumnStats() ? SCAN_WITH_STATS_COLUMNS : SCAN_COLUMNS; | ||
} | ||
|
This file contains 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 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 |
---|---|---|
|
@@ -30,12 +30,11 @@ public class MetadataColumns { | |
private MetadataColumns() {} | ||
|
||
// IDs Integer.MAX_VALUE - (1-100) are used for metadata columns | ||
public static final int FILE_PATH_COLUMN_ID = Integer.MAX_VALUE - 1; | ||
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. +1 to this solution |
||
public static final String FILE_PATH_COLUMN_DOC = "Path of the file in which a row is stored"; | ||
public static final NestedField FILE_PATH = | ||
NestedField.required( | ||
Integer.MAX_VALUE - 1, | ||
"_file", | ||
Types.StringType.get(), | ||
"Path of the file in which a row is stored"); | ||
FILE_PATH_COLUMN_ID, "_file", Types.StringType.get(), FILE_PATH_COLUMN_DOC); | ||
public static final NestedField ROW_POSITION = | ||
NestedField.required( | ||
Integer.MAX_VALUE - 2, | ||
|
@@ -48,12 +47,11 @@ private MetadataColumns() {} | |
"_deleted", | ||
Types.BooleanType.get(), | ||
"Whether the row has been deleted"); | ||
public static final int SPEC_ID_COLUMN_ID = Integer.MAX_VALUE - 4; | ||
public static final String SPEC_ID_COLUMN_DOC = "Spec ID used to track the file containing a row"; | ||
public static final NestedField SPEC_ID = | ||
NestedField.required( | ||
Integer.MAX_VALUE - 4, | ||
"_spec_id", | ||
Types.IntegerType.get(), | ||
"Spec ID used to track the file containing a row"); | ||
SPEC_ID_COLUMN_ID, "_spec_id", Types.IntegerType.get(), SPEC_ID_COLUMN_DOC); | ||
// the partition column type is not static and depends on all specs in the table | ||
public static final int PARTITION_COLUMN_ID = Integer.MAX_VALUE - 5; | ||
public static final String PARTITION_COLUMN_NAME = "_partition"; | ||
|
This file contains 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 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.
Before this change, predicate pushdown would make the PositionDeletes scan tasks have wrong partition field id, spec id, so they will not work in the DeleteFile read.
Though it only happens in corner cases like dropped partition fields (where the auto-generated field-ids are not correct anymore). Added a test for this in TestMetadataTableScansWithPartitionEvolution