From f39b4554d20698bce41b88c34e275735d12b8b89 Mon Sep 17 00:00:00 2001 From: Terry Kim Date: Mon, 21 Dec 2020 14:37:53 -0800 Subject: [PATCH 1/2] initial commit --- .../sql/catalyst/analysis/CheckAnalysis.scala | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala index 472de096b2f2..93530fe92cee 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala @@ -99,10 +99,10 @@ trait CheckAnalysis extends PredicateHelper with LookupCatalog { throw QueryExecutionErrors.logicalPlanHaveOutputOfCharOrVarcharError(leaf) case u: UnresolvedNamespace => - u.failAnalysis(s"Namespace not found: ${u.multipartIdentifier.quoted}") + throw new NoSuchNamespaceException(s"Namespace not found: ${u.multipartIdentifier.quoted}") case u: UnresolvedTable => - u.failAnalysis(s"Table not found: ${u.multipartIdentifier.quoted}") + throw new NoSuchTableException(s"Table not found: ${u.multipartIdentifier.quoted}") case u @ UnresolvedView(NonSessionCatalogAndIdentifier(catalog, ident), cmd, _, _) => u.failAnalysis( @@ -111,43 +111,44 @@ trait CheckAnalysis extends PredicateHelper with LookupCatalog { s"$cmd expects a view.") case u: UnresolvedView => - u.failAnalysis(s"View not found: ${u.multipartIdentifier.quoted}") + throw new NoSuchTableException(s"View not found: ${u.multipartIdentifier.quoted}") case u: UnresolvedTableOrView => val viewStr = if (u.allowTempView) "view" else "permanent view" - u.failAnalysis( + throw new NoSuchTableException( s"Table or $viewStr not found: ${u.multipartIdentifier.quoted}") case u: UnresolvedRelation => - u.failAnalysis(s"Table or view not found: ${u.multipartIdentifier.quoted}") + throw new NoSuchTableException(s"Table or view not found: ${u.multipartIdentifier.quoted}") case InsertIntoStatement(u: UnresolvedRelation, _, _, _, _, _) => - failAnalysis(s"Table not found: ${u.multipartIdentifier.quoted}") + throw new NoSuchTableException(s"Table not found: ${u.multipartIdentifier.quoted}") case CacheTable(u: UnresolvedRelation, _, _, _) => - failAnalysis(s"Table or view not found: ${u.multipartIdentifier.quoted}") + throw new NoSuchTableException(s"Table or view not found: ${u.multipartIdentifier.quoted}") case UncacheTable(u: UnresolvedRelation, _, _) => - failAnalysis(s"Table or view not found: ${u.multipartIdentifier.quoted}") + throw new NoSuchTableException(s"Table or view not found: ${u.multipartIdentifier.quoted}") // TODO (SPARK-27484): handle streaming write commands when we have them. case write: V2WriteCommand if write.table.isInstanceOf[UnresolvedRelation] => val tblName = write.table.asInstanceOf[UnresolvedRelation].multipartIdentifier - write.table.failAnalysis(s"Table or view not found: ${tblName.quoted}") + throw new NoSuchTableException(s"Table or view not found: ${tblName.quoted}") case u: UnresolvedV2Relation if isView(u.originalNameParts) => - u.failAnalysis( + throw new NoSuchTableException( s"Invalid command: '${u.originalNameParts.quoted}' is a view not a table.") case u: UnresolvedV2Relation => - u.failAnalysis(s"Table not found: ${u.originalNameParts.quoted}") + throw new NoSuchTableException( + s"Table not found: ${u.originalNameParts.quoted}") case AlterTable(_, _, u: UnresolvedV2Relation, _) if isView(u.originalNameParts) => u.failAnalysis( s"Invalid command: '${u.originalNameParts.quoted}' is a view not a table.") case AlterTable(_, _, u: UnresolvedV2Relation, _) => - failAnalysis(s"Table not found: ${u.originalNameParts.quoted}") + throw new NoSuchTableException(s"Table not found: ${u.originalNameParts.quoted}") case operator: LogicalPlan => // Check argument data types of higher-order functions downwards first. From 6893510ed0405fef2fd6dab03709151d9da391e0 Mon Sep 17 00:00:00 2001 From: Terry Kim Date: Mon, 21 Dec 2020 14:38:31 -0800 Subject: [PATCH 2/2] change line --- .../org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala index 93530fe92cee..0ce48f0cd7f1 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala @@ -140,8 +140,7 @@ trait CheckAnalysis extends PredicateHelper with LookupCatalog { s"Invalid command: '${u.originalNameParts.quoted}' is a view not a table.") case u: UnresolvedV2Relation => - throw new NoSuchTableException( - s"Table not found: ${u.originalNameParts.quoted}") + throw new NoSuchTableException(s"Table not found: ${u.originalNameParts.quoted}") case AlterTable(_, _, u: UnresolvedV2Relation, _) if isView(u.originalNameParts) => u.failAnalysis(