-
Notifications
You must be signed in to change notification settings - Fork 338
fix: decline native V1 scans on object_store-unsupported filesystem schemes #4525
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
andygrove
merged 10 commits into
apache:main
from
schenksj:fix/scheme-gate-object-store
Jun 19, 2026
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7786c5c
fix: decline native V1 scans on object_store-unsupported filesystem s…
schenksj 8c1c260
Merge branch 'main' into fix/scheme-gate-object-store
schenksj b457024
ci: register CometScanSchemeFallbackSuite in PR build workflows
schenksj 8b1c417
test: make CometScanSchemeFallbackSuite compile under Spark 3.5 / Sca…
schenksj 7e8b136
refactor: use imports instead of fully-qualified names in CometScanRule
schenksj a1a29a0
fix: use withFallbackReason in scheme gate (leftover from #4508 rename)
schenksj f5e6609
fix: default hdfs scheme to natively-readable in CometScanRule gate
schenksj 24dc5d3
Merge branch 'main' into fix/scheme-gate-object-store
schenksj 213946b
style: drop no-op s-interpolators in CometScanSchemeFallbackSuite (sc…
schenksj 287a689
Merge branch 'main' into fix/scheme-gate-object-store
schenksj 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
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
95 changes: 95 additions & 0 deletions
95
spark/src/test/scala/org/apache/comet/rules/CometScanSchemeFallbackSuite.scala
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,95 @@ | ||
| /* | ||
| * 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.comet.rules | ||
|
|
||
| import java.io.File | ||
| import java.nio.file.Files | ||
| import java.util.UUID | ||
|
|
||
| import org.apache.commons.io.FileUtils | ||
| import org.apache.spark.SparkConf | ||
| import org.apache.spark.sql.{CometTestBase, SaveMode} | ||
| import org.apache.spark.sql.comet.CometScanExec | ||
| import org.apache.spark.sql.execution.{FileSourceScanExec, SparkPlan} | ||
|
|
||
| import org.apache.comet.CometConf | ||
| import org.apache.comet.hadoop.fs.FakeHDFSFileSystem | ||
|
|
||
| /** | ||
| * Comet's native readers go through object_store, which only understands a fixed set of URL | ||
| * schemes. A custom Hadoop FileSystem scheme that object_store can't parse (here `fake://`) must | ||
| * NOT be claimed by the native scan -- it would fail at execution with "Unable to recognise URL". | ||
| * `CometScanRule` must decline it so Spark's Hadoop-FS-aware reader handles the scan. | ||
| * | ||
| * Unlike `ParquetReadFromFakeHadoopFsSuite`, this suite does NOT route the `fake` scheme through | ||
| * libhdfs (`spark.hadoop.fs.comet.libhdfs.schemes`), so it exercises the decline path. The test | ||
| * applies the rule directly to the physical plan and asserts fallback -- no query execution, so | ||
| * it doesn't depend on the native reader actually attempting (and failing on) the scheme. | ||
| */ | ||
| class CometScanSchemeFallbackSuite extends CometTestBase { | ||
|
|
||
| private var fakeRootDir: File = _ | ||
|
|
||
| override protected def sparkConf: SparkConf = { | ||
| val conf = super.sparkConf | ||
| conf.set("spark.hadoop.fs.fake.impl", "org.apache.comet.hadoop.fs.FakeHDFSFileSystem") | ||
| conf.set("spark.hadoop.fs.defaultFS", FakeHDFSFileSystem.PREFIX) | ||
| // Intentionally NOT setting CometConf.COMET_LIBHDFS_SCHEMES -- `fake` is not natively readable. | ||
| conf | ||
| } | ||
|
|
||
| override def beforeAll(): Unit = { | ||
| fakeRootDir = Files.createTempDirectory(s"comet_scheme_${UUID.randomUUID().toString}").toFile | ||
| super.beforeAll() | ||
| } | ||
|
|
||
| protected override def afterAll(): Unit = { | ||
| if (fakeRootDir != null) FileUtils.deleteDirectory(fakeRootDir) | ||
| super.afterAll() | ||
| } | ||
|
|
||
| test("native scan declines a filesystem scheme object_store can't read (fake://)") { | ||
| val path = s"${FakeHDFSFileSystem.PREFIX}${fakeRootDir.getAbsolutePath}/data" | ||
| spark.range(0, 10).toDF("id").write.format("parquet").mode(SaveMode.Overwrite).save(path) | ||
|
|
||
| // Obtain a clean Spark physical plan (Comet disabled) with the FileSourceScanExec, then apply | ||
| // CometScanRule directly. No execution -- we only check whether the rule claims the scan. | ||
| val sparkPlan: SparkPlan = withSQLConf(CometConf.COMET_ENABLED.key -> "false") { | ||
| spark.read.parquet(path).queryExecution.executedPlan | ||
| } | ||
|
|
||
| withSQLConf( | ||
| CometConf.COMET_ENABLED.key -> "true", | ||
| CometConf.COMET_NATIVE_SCAN_ENABLED.key -> "true", | ||
| CometConf.COMET_EXEC_ENABLED.key -> "true") { | ||
| val transformed = CometScanRule(spark).apply(stripAQEPlan(sparkPlan)) | ||
|
|
||
| val cometScans = transformed.collect { case s: CometScanExec => s } | ||
| val sparkScans = transformed.collect { case s: FileSourceScanExec => s } | ||
| assert( | ||
| cometScans.isEmpty, | ||
| s"`fake://` is not object_store-readable; the native scan must fall back to Spark, " + | ||
| s"but Comet claimed it:\n$transformed") | ||
| assert( | ||
| sparkScans.size == 1, | ||
| s"expected the scan to remain a Spark FileSourceScanExec:\n$transformed") | ||
| } | ||
| } | ||
| } |
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.
please add imports rather than use fully qualified class names
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.
Done. Added imports for
java.net.URI,java.util.Locale,java.util.concurrent.ConcurrentHashMap, andjava.lang.Boolean(aliasedJBoolean) and dropped the fully-qualified references. Also fixed a leftoverwithInfocall in the same code (renamed towithFallbackReasonin #4508) that was breaking compilation after merging main.