-
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
Changes from 8 commits
7625677
f0c99db
30b0572
708bb0c
a83e9cf
515aeba
763312f
16b8a22
2e8492b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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") { | ||
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 one nested? 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'm expecting something like
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. Updated it. |
||
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") { | ||
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. ditto |
||
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) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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.