Skip to content

Commit e76cb87

Browse files
committed
[SPARK-54491] Fix insert into temp view on DSv2 table failure
1 parent 361d0c9 commit e76cb87

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,8 @@ class Analyzer(override val catalogManager: CatalogManager) extends RuleExecutor
11911191
val relation = table match {
11921192
case u: UnresolvedRelation if !u.isStreaming =>
11931193
resolveRelation(u).getOrElse(u)
1194+
case r: V2TableReference =>
1195+
relationResolution.resolveReference(r)
11941196
case other => other
11951197
}
11961198

sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3913,6 +3913,19 @@ class DataSourceV2SQLSuiteV1Filter
39133913
}
39143914
}
39153915

3916+
test("SPARK-54491: insert into temp view on DSv2 table") {
3917+
val t = s"testcat.default.t"
3918+
val v = "v"
3919+
withTable(t) {
3920+
withTempView(v) {
3921+
sql(s"CREATE TABLE $t (id INT) USING foo")
3922+
spark.table(t).createOrReplaceTempView(v)
3923+
sql(s"INSERT INTO v VALUES (1)")
3924+
checkAnswer(sql(s"SELECT * FROM $t"), Seq(Row(1)))
3925+
}
3926+
}
3927+
}
3928+
39163929
private def testNotSupportedV2Command(
39173930
sqlCommand: String,
39183931
sqlParams: String,

0 commit comments

Comments
 (0)