This is an automated email from the ASF dual-hosted git repository.
maxgekk pushed a commit to branch branch-3.5
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-3.5 by this push:
new 8bf5a5bca3f [SPARK-45383][SQL] Fix error message for time travel with
non-existing table
8bf5a5bca3f is described below
commit 8bf5a5bca3f9f7db78182d14e56476d384f442fa
Author: Wenchen Fan <[email protected]>
AuthorDate: Mon Oct 9 22:15:45 2023 +0300
[SPARK-45383][SQL] Fix error message for time travel with non-existing table
### What changes were proposed in this pull request?
Fixes a small bug to report `TABLE_OR_VIEW_NOT_FOUND` error correctly for
time travel. It was missed before because `RelationTimeTravel` is a leaf node
but it may contain `UnresolvedRelation`.
### Why are the changes needed?
bug fix
### Does this PR introduce _any_ user-facing change?
Yes, the error message becomes reasonable
### How was this patch tested?
new tests
### Was this patch authored or co-authored using generative AI tooling?
no
Closes #43298 from cloud-fan/time-travel.
Authored-by: Wenchen Fan <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
(cherry picked from commit ced321c8b5a32c69dfb2841d4bec8a03f21b8038)
Signed-off-by: Max Gekk <[email protected]>
---
.../apache/spark/sql/catalyst/analysis/CheckAnalysis.scala | 4 ++++
.../org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala | 11 +++++++++++
2 files changed, 15 insertions(+)
diff --git
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
index 511f3622e7e..533ea8a2b79 100644
---
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
+++
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
@@ -365,6 +365,9 @@ trait CheckAnalysis extends PredicateHelper with
LookupCatalog with QueryErrorsB
})
operator match {
+ case RelationTimeTravel(u: UnresolvedRelation, _, _) =>
+ u.tableNotFound(u.multipartIdentifier)
+
case etw: EventTimeWatermark =>
etw.eventTime.dataType match {
case s: StructType
@@ -377,6 +380,7 @@ trait CheckAnalysis extends PredicateHelper with
LookupCatalog with QueryErrorsB
"eventName" -> toSQLId(etw.eventTime.name),
"eventType" -> toSQLType(etw.eventTime.dataType)))
}
+
case f: Filter if f.condition.dataType != BooleanType =>
f.failAnalysis(
errorClass = "DATATYPE_MISMATCH.FILTER_NOT_BOOLEAN",
diff --git
a/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala
b/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala
index 06f5600e0d1..7745e9c0a4e 100644
---
a/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala
+++
b/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala
@@ -3014,6 +3014,17 @@ class DataSourceV2SQLSuiteV1Filter
sqlState = None,
parameters = Map("relationId" -> "`x`"))
+ checkError(
+ exception = intercept[AnalysisException] {
+ sql("SELECT * FROM non_exist VERSION AS OF 1")
+ },
+ errorClass = "TABLE_OR_VIEW_NOT_FOUND",
+ parameters = Map("relationName" -> "`non_exist`"),
+ context = ExpectedContext(
+ fragment = "non_exist",
+ start = 14,
+ stop = 22))
+
val subquery1 = "SELECT 1 FROM non_exist"
checkError(
exception = intercept[AnalysisException] {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]