-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Spark 3.4: Support distributed planning #8123
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /* | ||
| * 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 java.util.List; | ||
| import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList; | ||
|
|
||
| abstract class DataScan<ThisT, T extends ScanTask, G extends ScanTaskGroup<T>> | ||
| extends SnapshotScan<ThisT, T, G> { | ||
|
|
||
| protected DataScan(Table table, Schema schema, TableScanContext context) { | ||
| super(table, schema, context); | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean useSnapshotSchema() { | ||
| return true; | ||
| } | ||
|
|
||
| protected ManifestGroup newManifestGroup( | ||
| List<ManifestFile> dataManifests, List<ManifestFile> deleteManifests) { | ||
| return newManifestGroup(dataManifests, deleteManifests, context().returnColumnStats()); | ||
| } | ||
|
|
||
| protected ManifestGroup newManifestGroup( | ||
| List<ManifestFile> dataManifests, boolean withColumnStats) { | ||
| return newManifestGroup(dataManifests, ImmutableList.of(), withColumnStats); | ||
| } | ||
|
|
||
| protected ManifestGroup newManifestGroup( | ||
| List<ManifestFile> dataManifests, | ||
| List<ManifestFile> deleteManifests, | ||
| boolean withColumnStats) { | ||
|
|
||
| ManifestGroup manifestGroup = | ||
| new ManifestGroup(io(), dataManifests, deleteManifests) | ||
| .caseSensitive(isCaseSensitive()) | ||
| .select(withColumnStats ? SCAN_WITH_STATS_COLUMNS : SCAN_COLUMNS) | ||
| .filterData(filter()) | ||
| .specsById(table().specs()) | ||
| .scanMetrics(scanMetrics()) | ||
| .ignoreDeleted(); | ||
|
|
||
| if (shouldIgnoreResiduals()) { | ||
| manifestGroup = manifestGroup.ignoreResiduals(); | ||
| } | ||
|
|
||
| if (shouldPlanWithExecutor() && (dataManifests.size() > 1 || deleteManifests.size() > 1)) { | ||
| manifestGroup = manifestGroup.planWith(planExecutor()); | ||
| } | ||
|
|
||
| return manifestGroup; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,7 @@ | |
| import org.apache.iceberg.io.CloseableIterator; | ||
| import org.apache.iceberg.io.FileIO; | ||
| import org.apache.iceberg.metrics.ScanMetrics; | ||
| import org.apache.iceberg.metrics.ScanMetricsUtil; | ||
| import org.apache.iceberg.relocated.com.google.common.collect.Iterables; | ||
| import org.apache.iceberg.relocated.com.google.common.collect.Lists; | ||
| import org.apache.iceberg.relocated.com.google.common.collect.Sets; | ||
|
|
@@ -222,6 +223,19 @@ public CloseableIterable<ManifestEntry<DataFile>> entries() { | |
| return CloseableIterable.concat(entries((manifest, entries) -> entries)); | ||
| } | ||
|
|
||
| /** | ||
| * Returns an iterable for groups of data files in the set of manifests. | ||
| * | ||
| * <p>Files are not copied, it is the caller's responsibility to make defensive copies if adding | ||
| * these files to a collection. | ||
| * | ||
| * @return an iterable of file groups | ||
| */ | ||
| public Iterable<CloseableIterable<DataFile>> fileGroups() { | ||
|
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. Why is this called
Contributor
Author
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. I called it |
||
| return entries( | ||
| (manifest, entries) -> CloseableIterable.transform(entries, ManifestEntry::file)); | ||
| } | ||
|
|
||
| private <T> Iterable<CloseableIterable<T>> entries( | ||
| BiFunction<ManifestFile, CloseableIterable<ManifestEntry<DataFile>>, CloseableIterable<T>> | ||
| entryFn) { | ||
|
|
@@ -349,12 +363,7 @@ private static CloseableIterable<FileScanTask> createFileScanTasks( | |
| entry -> { | ||
| DataFile dataFile = entry.file().copy(ctx.shouldKeepStats()); | ||
| DeleteFile[] deleteFiles = ctx.deletes().forEntry(entry); | ||
| for (DeleteFile deleteFile : deleteFiles) { | ||
| ctx.scanMetrics().totalDeleteFileSizeInBytes().increment(deleteFile.fileSizeInBytes()); | ||
| } | ||
| ctx.scanMetrics().totalFileSizeInBytes().increment(dataFile.fileSizeInBytes()); | ||
| ctx.scanMetrics().resultDataFiles().increment(); | ||
| ctx.scanMetrics().resultDeleteFiles().increment((long) deleteFiles.length); | ||
| ScanMetricsUtil.fileTask(ctx.scanMetrics(), dataFile, deleteFiles); | ||
| return new BaseFileScanTask( | ||
| dataFile, deleteFiles, ctx.schemaAsString(), ctx.specAsString(), ctx.residuals()); | ||
| }); | ||
|
|
||
| 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.iceberg; | ||
|
|
||
| import org.apache.iceberg.relocated.com.google.common.base.Preconditions; | ||
|
|
||
| public enum PlanningMode { | ||
| AUTO("auto"), | ||
| LOCAL("local"), | ||
| DISTRIBUTED("distributed"); | ||
|
|
||
| private final String modeName; | ||
|
|
||
| PlanningMode(String modeName) { | ||
| this.modeName = modeName; | ||
| } | ||
|
|
||
| public static PlanningMode fromName(String modeName) { | ||
| Preconditions.checkArgument(modeName != null, "Mode name is null"); | ||
|
|
||
| if (AUTO.modeName().equalsIgnoreCase(modeName)) { | ||
| return AUTO; | ||
|
|
||
| } else if (LOCAL.modeName().equalsIgnoreCase(modeName)) { | ||
| return LOCAL; | ||
|
|
||
| } else if (DISTRIBUTED.modeName().equalsIgnoreCase(modeName)) { | ||
| return DISTRIBUTED; | ||
|
|
||
| } else { | ||
| throw new IllegalArgumentException("Unknown planning mode: " + modeName); | ||
| } | ||
| } | ||
|
|
||
| public String modeName() { | ||
| return modeName; | ||
| } | ||
| } |
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.
big difference from the previous implementation here? I assume i'll see later that you moved the validation out?
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.
The validation is in the parent so that I can reuse it in both scans now.