cloud-fan commented on a change in pull request #31550:
URL: https://github.com/apache/spark/pull/31550#discussion_r578147807
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
##########
@@ -3943,6 +3943,43 @@ class SQLQuerySuite extends QueryTest with
SharedSparkSession with AdaptiveSpark
}
}
}
+
+ test("SPARK-34421: Resolve temporary functions and views in views with
CTEs") {
+ val tempViewName = "temp_view"
+
+ withTempView(tempViewName) {
+ spark.udf.register("temp_func", identity[Int](_))
+
+ sql(
+ s"""
+ |CREATE TEMPORARY VIEW $tempViewName AS
+ |WITH cte AS (
+ | SELECT temp_func(0)
+ |)
+ |SELECT * FROM cte
+ |""".stripMargin)
+ checkAnswer(sql(s"SELECT * FROM $tempViewName"), Row(0))
+ }
+
+ withTempView(tempViewName) {
+ sql(s"CREATE TEMPORARY VIEW $tempViewName AS SELECT 0")
+
+ val viewName = "view_on_temp_view"
+
+ val e = intercept[AnalysisException] {
+ sql(
+ s"""
+ |CREATE VIEW $viewName AS
Review comment:
So the bug happens in permanent view. Is it really a regression?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]