cloud-fan commented on code in PR #53333:
URL: https://github.com/apache/spark/pull/53333#discussion_r2627497038
##########
sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala:
##########
@@ -5088,6 +5088,46 @@ class SQLQuerySuite extends QueryTest with
SharedSparkSession with AdaptiveSpark
checkAnswer(sql(query), Row(1, 2))
}
}
+
+ test("SPARK-46741: Cache Table with CTE should work") {
+ withTempView("t2") {
+ withTempView("t1") {
+ sql(
+ """
+ |CREATE TEMPORARY VIEW t1
+ |AS
+ |SELECT * FROM VALUES (0, 0), (1, 1), (2, 2) AS t(c1, c2);
+ |""".stripMargin)
+ sql(
+ """
+ |CREATE TEMPORARY VIEW t2 AS
+ |WITH v as (
+ | SELECT c1 + c1 c3 FROM t1
+ |)
+ |SELECT SUM(c3) s FROM v;
+ |""".stripMargin)
+ sql(
+ """
+ |CACHE TABLE cache_nested_cte_table
+ |WITH
+ |v AS (
+ | SELECT c1 * c2 c3 from t1
+ |)
+ |SELECT SUM(c3) FROM v
+ |EXCEPT
+ |SELECT s FROM t2;
+ |""".stripMargin)
+
+ val df = sql("SELECT * FROM cache_nested_cte_table;")
Review Comment:
```suggestion
val df = sql("SELECT * FROM cache_nested_cte_table")
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]