Skip to content

Commit d3c344a

Browse files
committed
UnresolvedTableOrView -> UnresolvedTable
1 parent 0fe4a61 commit d3c344a

File tree

5 files changed

+11
-20
lines changed

5 files changed

+11
-20
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ class Analyzer(override val catalogManager: CatalogManager)
10841084
lookupTableOrView(identifier).map {
10851085
case v: ResolvedView =>
10861086
val viewStr = if (v.isTemp) "temp view" else "view"
1087-
u.failAnalysis(s"${v.identifier.quoted} is a $viewStr. '$cmd' expects a table.'")
1087+
u.failAnalysis(s"${v.identifier.quoted} is a $viewStr. '$cmd' expects a table.")
10881088
case table => table
10891089
}.getOrElse(u)
10901090

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,10 +1010,6 @@ trait CheckAnalysis extends PredicateHelper {
10101010

10111011
// Make sure that the `SHOW PARTITIONS` command is allowed for the table
10121012
private def checkShowPartitions(showPartitions: ShowPartitions): Unit = showPartitions match {
1013-
case ShowPartitions(v: ResolvedView, _) =>
1014-
failAnalysis(s"SHOW PARTITIONS is not allowed on a view: ${v.identifier}")
1015-
case ShowPartitions(child, _) if !child.isInstanceOf[ResolvedTable] =>
1016-
failAnalysis(s"Cannot resolve the table for SHOW PARTITIONS")
10171013
case ShowPartitions(rt: ResolvedTable, _)
10181014
if !rt.table.isInstanceOf[SupportsPartitionManagement] =>
10191015
failAnalysis(s"SHOW PARTITIONS cannot run for a table which does not support partitioning")

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3648,10 +3648,7 @@ class AstBuilder extends SqlBaseBaseVisitor[AnyRef] with SQLConfHelper with Logg
36483648
UnresolvedPartitionSpec(visitNonOptionalPartitionSpec(specCtx), None)
36493649
}
36503650
ShowPartitions(
3651-
UnresolvedTableOrView(
3652-
multiPart.getOrElse(Seq.empty[String]),
3653-
"SHOW PARTITIONS",
3654-
allowTempView = false),
3651+
UnresolvedTable(multiPart.getOrElse(Seq.empty[String]), "SHOW PARTITIONS"),
36553652
partitionKeys)
36563653
}
36573654

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package org.apache.spark.sql.execution.command
1919

20-
import org.apache.spark.sql.catalyst.analysis.{AnalysisTest, UnresolvedPartitionSpec, UnresolvedTableOrView}
20+
import org.apache.spark.sql.catalyst.analysis.{AnalysisTest, UnresolvedPartitionSpec, UnresolvedTable}
2121
import org.apache.spark.sql.catalyst.parser.CatalystSqlParser.parsePlan
2222
import org.apache.spark.sql.catalyst.parser.ParseException
2323
import org.apache.spark.sql.catalyst.plans.logical.ShowPartitions
@@ -28,19 +28,18 @@ class ShowPartitionsParserSuite extends AnalysisTest with SharedSparkSession {
2828
test("SHOW PARTITIONS") {
2929
val commandName = "SHOW PARTITIONS"
3030
Seq(
31-
"SHOW PARTITIONS t1" -> ShowPartitions(
32-
UnresolvedTableOrView(Seq("t1"), commandName, false), None),
31+
"SHOW PARTITIONS t1" -> ShowPartitions(UnresolvedTable(Seq("t1"), commandName), None),
3332
"SHOW PARTITIONS db1.t1" -> ShowPartitions(
34-
UnresolvedTableOrView(Seq("db1", "t1"), commandName, false), None),
33+
UnresolvedTable(Seq("db1", "t1"), commandName), None),
3534
"SHOW PARTITIONS t1 PARTITION(partcol1='partvalue', partcol2='partvalue')" ->
3635
ShowPartitions(
37-
UnresolvedTableOrView(Seq("t1"), commandName, false),
36+
UnresolvedTable(Seq("t1"), commandName),
3837
Some(UnresolvedPartitionSpec(Map("partcol1" -> "partvalue", "partcol2" -> "partvalue")))),
3938
"SHOW PARTITIONS a.b.c" -> ShowPartitions(
40-
UnresolvedTableOrView(Seq("a", "b", "c"), commandName, false), None),
39+
UnresolvedTable(Seq("a", "b", "c"), commandName), None),
4140
"SHOW PARTITIONS a.b.c PARTITION(ds='2017-06-10')" ->
4241
ShowPartitions(
43-
UnresolvedTableOrView(Seq("a", "b", "c"), commandName, false),
42+
UnresolvedTable(Seq("a", "b", "c"), commandName),
4443
Some(UnresolvedPartitionSpec(Map("ds" -> "2017-06-10"))))
4544
).foreach { case (sql, expected) =>
4645
val parsed = parsePlan(sql)

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.apache.spark.sql.execution.command.v1
1919

2020
import org.apache.spark.sql.{AnalysisException, Row, SaveMode}
21-
import org.apache.spark.sql.catalyst.analysis.NoSuchTableException
2221
import org.apache.spark.sql.connector.catalog.CatalogManager
2322
import org.apache.spark.sql.execution.command
2423
import org.apache.spark.sql.test.SharedSparkSession
@@ -57,7 +56,7 @@ trait ShowPartitionsSuiteBase extends command.ShowPartitionsSuiteBase {
5756
val errMsg = intercept[AnalysisException] {
5857
sql(s"SHOW PARTITIONS $view")
5958
}.getMessage
60-
assert(errMsg.contains("is not allowed on a view"))
59+
assert(errMsg.contains("'SHOW PARTITIONS' expects a table"))
6160
}
6261
}
6362
}
@@ -69,7 +68,7 @@ trait ShowPartitionsSuiteBase extends command.ShowPartitionsSuiteBase {
6968
val errMsg = intercept[AnalysisException] {
7069
sql(s"SHOW PARTITIONS $viewName")
7170
}.getMessage
72-
assert(errMsg.contains("'SHOW PARTITIONS' expects a table or permanent view"))
71+
assert(errMsg.contains("'SHOW PARTITIONS' expects a table"))
7372
}
7473
}
7574
}
@@ -87,7 +86,7 @@ class ShowPartitionsSuite extends ShowPartitionsSuiteBase with SharedSparkSessio
8786
val errMsg = intercept[AnalysisException] {
8887
sql(s"SHOW PARTITIONS $viewName")
8988
}.getMessage
90-
assert(errMsg.contains("'SHOW PARTITIONS' expects a table or permanent view"))
89+
assert(errMsg.contains("'SHOW PARTITIONS' expects a table"))
9190
}
9291
}
9392

0 commit comments

Comments
 (0)