Skip to content

Commit bc3d861

Browse files
committed
fix tests
1 parent 4d75250 commit bc3d861

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ trait CheckAnalysis extends PredicateHelper {
104104
case u: UnresolvedTable =>
105105
u.failAnalysis(s"Table not found for '${u.commandName}': ${u.multipartIdentifier.quoted}")
106106

107+
case u: UnresolvedView =>
108+
u.failAnalysis(s"View not found for '${u.commandName}': ${u.multipartIdentifier.quoted}")
109+
107110
case u: UnresolvedTableOrView =>
108111
val viewStr = if (u.allowTempView) "view" else "permanent view"
109112
u.failAnalysis(

sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
13681368
sql("DROP VIEW dbx.tab1")
13691369
}
13701370
assert(
1371-
e.getMessage.contains("Cannot drop a table with DROP VIEW. Please use DROP TABLE instead"))
1371+
e.getMessage.contains("dbx.tab1 is a table. 'DROP VIEW' expects a view."))
13721372
}
13731373

13741374
protected def testSetProperties(isDatasourceTable: Boolean): Unit = {

sql/core/src/test/scala/org/apache/spark/sql/execution/command/PlanResolutionSuite.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ class PlanResolutionSuite extends AnalysisTest {
7878
V1Table(t)
7979
}
8080

81+
private val view: V1Table = {
82+
val t = mock(classOf[CatalogTable])
83+
when(t.schema).thenReturn(new StructType().add("i", "int").add("s", "string"))
84+
when(t.tableType).thenReturn(CatalogTableType.VIEW)
85+
when(t.provider).thenReturn(Some(v1Format))
86+
V1Table(t)
87+
}
88+
8189
private val testCat: TableCatalog = {
8290
val newCatalog = mock(classOf[TableCatalog])
8391
when(newCatalog.loadTable(any())).thenAnswer((invocation: InvocationOnMock) => {
@@ -101,6 +109,7 @@ class PlanResolutionSuite extends AnalysisTest {
101109
case "v2Table" => table
102110
case "v2Table1" => table
103111
case "v2TableWithAcceptAnySchemaCapability" => tableWithAcceptAnySchemaCapability
112+
case "view" => view
104113
case name => throw new NoSuchTableException(name)
105114
}
106115
})
@@ -677,6 +686,8 @@ class PlanResolutionSuite extends AnalysisTest {
677686
val viewIdent1 = TableIdentifier("view", Option("db"))
678687
val viewName2 = "view"
679688
val viewIdent2 = TableIdentifier("view", Option("default"))
689+
val tempViewName = "v"
690+
val tempViewIdent = TableIdentifier("v")
680691

681692
parseResolveCompare(s"DROP VIEW $viewName1",
682693
DropTableCommand(viewIdent1, ifExists = false, isView = true, purge = false))
@@ -686,6 +697,10 @@ class PlanResolutionSuite extends AnalysisTest {
686697
DropTableCommand(viewIdent2, ifExists = false, isView = true, purge = false))
687698
parseResolveCompare(s"DROP VIEW IF EXISTS $viewName2",
688699
DropTableCommand(viewIdent2, ifExists = true, isView = true, purge = false))
700+
parseResolveCompare(s"DROP VIEW $tempViewName",
701+
DropTableCommand(tempViewIdent, ifExists = false, isView = true, purge = false))
702+
parseResolveCompare(s"DROP VIEW IF EXISTS $tempViewName",
703+
DropTableCommand(tempViewIdent, ifExists = true, isView = true, purge = false))
689704
}
690705

691706
test("drop view in v2 catalog") {

0 commit comments

Comments
 (0)