-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-40245][SQL] Fix FileScan equality check when partition or data…
… filter columns are not read ### What changes were proposed in this pull request? Unfortunately the fix in apache/spark#31848 was not correct in all cases. When the partition or data filter contains a column that is not in `readSchema()` the filter nornalization in `FileScan.equals()` doesn't work. ### Why are the changes needed? To fix `FileScan.equals()` to fix reuse issues. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Added new UT. Closes #37693 from peter-toth/SPARK-40245-fix-filescan-equals. Authored-by: Peter Toth <ptoth@cloudera.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
- Loading branch information
Showing
52 changed files
with
2,142 additions
and
339 deletions.
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
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
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
113 changes: 113 additions & 0 deletions
113
.../hadoop-3/test/java/org/apache/spark/internal/io/cloud/abortable/AbortableFileSystem.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,113 @@ | ||
/* | ||
* 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.spark.internal.io.cloud.abortable; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.net.URI; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
import org.apache.hadoop.fs.*; | ||
import org.apache.hadoop.fs.permission.FsPermission; | ||
import org.apache.hadoop.util.Progressable; | ||
|
||
public class AbortableFileSystem extends RawLocalFileSystem { | ||
|
||
public static String ABORTABLE_FS_SCHEME = "abortable"; | ||
|
||
@Override | ||
public URI getUri() { | ||
return URI.create(ABORTABLE_FS_SCHEME + ":///"); | ||
} | ||
|
||
public FSDataOutputStream create(Path f, FsPermission permission, boolean overwrite, | ||
int bufferSize, short replication, long blockSize, Progressable progress) throws IOException { | ||
FSDataOutputStream out = this.create(f, overwrite, bufferSize, replication, blockSize, | ||
progress, permission); | ||
return out; | ||
} | ||
|
||
private FSDataOutputStream create(Path f, boolean overwrite, int bufferSize, short replication, | ||
long blockSize, Progressable progress, FsPermission permission) throws IOException { | ||
if (this.exists(f) && !overwrite) { | ||
throw new FileAlreadyExistsException("File already exists: " + f); | ||
} else { | ||
Path parent = f.getParent(); | ||
if (parent != null && !this.mkdirs(parent)) { | ||
throw new IOException("Mkdirs failed to create " + parent.toString()); | ||
} else { | ||
return new FSDataOutputStream(this.createOutputStreamWithMode(f, false, permission), null); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
protected OutputStream createOutputStreamWithMode(Path f, boolean append, | ||
FsPermission permission) throws IOException { | ||
return new AbortableOutputStream(f, append, permission); | ||
} | ||
|
||
class AbortableOutputStream extends ByteArrayOutputStream | ||
implements Abortable, StreamCapabilities { | ||
|
||
private final AtomicBoolean closed = new AtomicBoolean(false); | ||
|
||
private Path f; | ||
|
||
private boolean append; | ||
|
||
private FsPermission permission; | ||
|
||
AbortableOutputStream(Path f, boolean append, FsPermission permission) { | ||
this.f = f; | ||
this.append = append; | ||
this.permission = permission; | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
if (closed.getAndSet(true)) { | ||
return; | ||
} | ||
|
||
OutputStream output = | ||
AbortableFileSystem.super.createOutputStreamWithMode(f, append, permission); | ||
writeTo(output); | ||
output.close(); | ||
} | ||
|
||
@Override | ||
public AbortableResult abort() { | ||
final boolean isAlreadyClosed = closed.getAndSet(true); | ||
return new AbortableResult() { | ||
public boolean alreadyClosed() { | ||
return isAlreadyClosed; | ||
} | ||
|
||
public IOException anyCleanupException() { | ||
return null; | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
public boolean hasCapability(String capability) { | ||
return capability == CommonPathCapabilities.ABORTABLE_STREAM; | ||
} | ||
} | ||
} |
Oops, something went wrong.