-
Notifications
You must be signed in to change notification settings - Fork 28.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
[SPARK-35332][SQL] Make cache plan disable configs configurable #32482
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7625677
refactor
ulysses-you f0c99db
address comment
ulysses-you 30b0572
refine default value
ulysses-you 708bb0c
fix
ulysses-you a83e9cf
wrap withSQLConf
ulysses-you 515aeba
fix
ulysses-you 763312f
test
ulysses-you 16b8a22
docs
ulysses-you 2e8492b
comment
ulysses-you 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1175,7 +1175,7 @@ class CachedTableSuite extends QueryTest with SQLTestUtils | |
} | ||
|
||
test("cache supports for intervals") { | ||
withTable("interval_cache") { | ||
withTable("interval_cache", "t1") { | ||
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. not related this pr, but affected the new added test with |
||
Seq((1, "1 second"), (2, "2 seconds"), (2, null)) | ||
.toDF("k", "v").write.saveAsTable("interval_cache") | ||
sql("CACHE TABLE t1 AS SELECT k, cast(v as interval) FROM interval_cache") | ||
|
@@ -1554,4 +1554,65 @@ class CachedTableSuite extends QueryTest with SQLTestUtils | |
assert(!spark.catalog.isCached(viewName)) | ||
} | ||
} | ||
|
||
test("SPARK-35332: Make cache plan disable configs configurable - check AQE") { | ||
withSQLConf(SQLConf.SHUFFLE_PARTITIONS.key -> "2", | ||
SQLConf.COALESCE_PARTITIONS_MIN_PARTITION_NUM.key -> "1", | ||
SQLConf.ADAPTIVE_EXECUTION_ENABLED.key -> "true") { | ||
|
||
withTempView("t1", "t2", "t3") { | ||
withSQLConf(SQLConf.CAN_CHANGE_CACHED_PLAN_OUTPUT_PARTITIONING.key -> "false") { | ||
sql("CACHE TABLE t1 as SELECT /*+ REPARTITION */ * FROM values(1) as t(c)") | ||
assert(spark.table("t1").rdd.partitions.length == 2) | ||
} | ||
|
||
withSQLConf(SQLConf.CAN_CHANGE_CACHED_PLAN_OUTPUT_PARTITIONING.key -> "true") { | ||
assert(spark.table("t1").rdd.partitions.length == 2) | ||
sql("CACHE TABLE t2 as SELECT /*+ REPARTITION */ * FROM values(2) as t(c)") | ||
assert(spark.table("t2").rdd.partitions.length == 1) | ||
} | ||
|
||
withSQLConf(SQLConf.CAN_CHANGE_CACHED_PLAN_OUTPUT_PARTITIONING.key -> "false") { | ||
assert(spark.table("t1").rdd.partitions.length == 2) | ||
assert(spark.table("t2").rdd.partitions.length == 1) | ||
sql("CACHE TABLE t3 as SELECT /*+ REPARTITION */ * FROM values(3) as t(c)") | ||
assert(spark.table("t3").rdd.partitions.length == 2) | ||
} | ||
} | ||
} | ||
} | ||
|
||
test("SPARK-35332: Make cache plan disable configs configurable - check bucket scan") { | ||
withTable("t1", "t2", "t3") { | ||
Seq(1, 2, 3).foreach { i => | ||
spark.range(1, 2) | ||
.write | ||
.format("parquet") | ||
.bucketBy(2, "id") | ||
.saveAsTable(s"t$i") | ||
} | ||
|
||
withCache("t1", "t2", "t3") { | ||
withSQLConf(SQLConf.BUCKETING_ENABLED.key -> "true", | ||
SQLConf.FILES_MIN_PARTITION_NUM.key -> "1", | ||
SQLConf.CAN_CHANGE_CACHED_PLAN_OUTPUT_PARTITIONING.key -> "false") { | ||
sql("CACHE TABLE t1") | ||
assert(spark.table("t1").rdd.partitions.length == 2) | ||
|
||
withSQLConf(SQLConf.CAN_CHANGE_CACHED_PLAN_OUTPUT_PARTITIONING.key -> "true") { | ||
assert(spark.table("t1").rdd.partitions.length == 2) | ||
sql("CACHE TABLE t2") | ||
assert(spark.table("t2").rdd.partitions.length == 1) | ||
} | ||
|
||
withSQLConf(SQLConf.CAN_CHANGE_CACHED_PLAN_OUTPUT_PARTITIONING.key -> "false") { | ||
assert(spark.table("t1").rdd.partitions.length == 2) | ||
assert(spark.table("t2").rdd.partitions.length == 1) | ||
sql("CACHE TABLE t3") | ||
assert(spark.table("t3").rdd.partitions.length == 2) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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.
"If CAN_CHANGE_CACHED_PLAN_OUTPUT_PARTITIONING is disabled" -> do we mean enabled?
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.
good catch!
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.
Sorry, forgot to fix the comment, create followup #32543.