cloud-fan commented on code in PR #36689:
URL: https://github.com/apache/spark/pull/36689#discussion_r883260438
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala:
##########
@@ -2752,6 +2758,22 @@ class DataSourceV2SQLSuite
sql("WITH x AS (SELECT 1) SELECT * FROM x VERSION AS OF 1")
)
assert(e7.message.contains("Cannot time travel subqueries from WITH
clause"))
+
+ def checkSubqueryError(subquery: String, errMsg: String): Unit = {
+ val e1 = intercept[Exception](
+ sql(s"SELECT * FROM t TIMESTAMP AS OF ($subquery)").collect()
+ )
+ assert(e1.getMessage.contains(errMsg))
+ // Nested subquery should also report error correctly.
+ val e2 = intercept[Exception](
+ sql(s"SELECT * FROM t TIMESTAMP AS OF (SELECT
($subquery))").collect()
+ )
+ assert(e2.getMessage.contains(errMsg))
+ }
+ checkSubqueryError("SELECT 1 FROM non_exist", "Table or view not found:
non_exist")
+ checkSubqueryError("SELECT col", "MISSING_COLUMN")
+ checkSubqueryError("SELECT 1, 2", "Scalar subquery must return only one
column")
+ checkSubqueryError("SELECT * FROM VALUES (1), (2)",
"MULTI_VALUE_SUBQUERY_ERROR")
Review Comment:
`checkSubqueryError("SELECT col", "MISSING_COLUMN")` is the test case for
correlated subquery. `TimeTravelRelation` has no output column so the outer
reference can never be resolved.
--
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]