Skip to content

Commit 8a1a88e

Browse files
[Spark] Fix DeltaDataFrameWriterV2Suite.Replace: fail if table does not exist (delta-io#4847)
#### Which Delta project/connector is this regarding? - [x] Spark - [ ] Standalone - [ ] Flink - [ ] Kernel - [ ] Other (fill in here) ## Description CannotReplaceMissingTableException extends AnalysisException. Spark has rewrites that sometimes change AnalysisException into ExtendedAnalysisException to add more context. For some reason, it started happening here. Rewriting it into ExtendedAnalysisException makes it lose the CannotReplaceMissingTableException, but it retains the correct error class and SQL state. Make the test check the error class and SQL state instead. ## How was this patch tested? Test runs. ## Does this PR introduce _any_ user-facing changes? No. Co-authored-by: Julek Sompolski <Juliusz Sompolski>
1 parent 7a030ea commit 8a1a88e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

spark/src/test/scala/org/apache/spark/sql/delta/DeltaDataFrameWriterV2Suite.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,12 @@ trait OpenSourceDataFrameWriterV2Tests
403403
}
404404

405405
test("Replace: fail if table does not exist") {
406-
val exc = intercept[CannotReplaceMissingTableException] {
406+
val exc = intercept[AnalysisException] {
407407
spark.table("source").writeTo("table_name").using("delta").replace()
408408
}
409409

410-
assert(exc.getMessage.contains("table_name"))
410+
checkError(exc, "TABLE_OR_VIEW_NOT_FOUND", Some("42P01"),
411+
Map("relationName" -> "`default`.`table_name`"))
411412
}
412413

413414
test("CreateOrReplace: table does not exist") {

0 commit comments

Comments
 (0)