This is an automated email from the ASF dual-hosted git repository.
gengliang 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 71d5b110660f [SPARK-45189][3.5][SQL] Creating UnresolvedRelation from
TableIdentifier should include the catalog field
71d5b110660f is described below
commit 71d5b110660f028bf3b097e6b5805fe68126b4cd
Author: Gengliang Wang <[email protected]>
AuthorDate: Tue Sep 19 22:56:44 2023 -0700
[SPARK-45189][3.5][SQL] Creating UnresolvedRelation from TableIdentifier
should include the catalog field
### What changes were proposed in this pull request?
Creating UnresolvedRelation from TableIdentifier should include the catalog
field
### Why are the changes needed?
Fix a issue in a utility method for UnresolvedRelation
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
New unit test
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #42998 from gengliangwang/backportTableId.
Authored-by: Gengliang Wang <[email protected]>
Signed-off-by: Gengliang Wang <[email protected]>
---
.../org/apache/spark/sql/catalyst/analysis/unresolved.scala | 5 ++---
.../apache/spark/sql/catalyst/parser/PlanParserSuite.scala | 12 ++++++++++++
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala
index 1c72ec0d6998..b1dcb465b477 100644
---
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala
+++
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala
@@ -104,12 +104,11 @@ object UnresolvedRelation {
tableIdentifier: TableIdentifier,
extraOptions: CaseInsensitiveStringMap,
isStreaming: Boolean): UnresolvedRelation = {
- UnresolvedRelation(
- tableIdentifier.database.toSeq :+ tableIdentifier.table, extraOptions,
isStreaming)
+ UnresolvedRelation(tableIdentifier.nameParts, extraOptions, isStreaming)
}
def apply(tableIdentifier: TableIdentifier): UnresolvedRelation =
- UnresolvedRelation(tableIdentifier.database.toSeq :+ tableIdentifier.table)
+ UnresolvedRelation(tableIdentifier.nameParts)
}
/**
diff --git
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala
index 4a5d0a0ae29f..13474fe29de9 100644
---
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala
+++
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala
@@ -26,6 +26,7 @@ import org.apache.spark.sql.catalyst.plans._
import org.apache.spark.sql.catalyst.plans.logical._
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.types.{Decimal, DecimalType, IntegerType,
LongType, StringType}
+import org.apache.spark.sql.util.CaseInsensitiveStringMap
/**
* Parser test cases for rules defined in [[CatalystSqlParser]] /
[[AstBuilder]].
@@ -1758,4 +1759,15 @@ class PlanParserSuite extends AnalysisTest {
parsePlan("SELECT * FROM a LIMIT ?"),
table("a").select(star()).limit(PosParameter(22)))
}
+
+ test("SPARK-45189: Creating UnresolvedRelation from TableIdentifier should
include the" +
+ " catalog field") {
+ val tableId = TableIdentifier("t", Some("db"), Some("cat"))
+ val unresolvedRelation = UnresolvedRelation(tableId)
+ assert(unresolvedRelation.multipartIdentifier == Seq("cat", "db", "t"))
+ val unresolvedRelation2 = UnresolvedRelation(tableId,
CaseInsensitiveStringMap.empty, true)
+ assert(unresolvedRelation2.multipartIdentifier == Seq("cat", "db", "t"))
+ assert(unresolvedRelation2.options == CaseInsensitiveStringMap.empty)
+ assert(unresolvedRelation2.isStreaming)
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]