Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions core/src/main/resources/error/error-classes.json
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,11 @@
"AES-<mode> with the padding <padding> by the <functionName> function."
]
},
"ANALYZE_TABLE_VIEW_NOT_CACHED" : {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"ANALYZE_TABLE_VIEW_NOT_CACHED" : {
"ANALYZE_UNCACHED_TEMP_VIEW" : {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

"message" : [
"Temporary view <tableName> is not cached for analyzing columns."
Copy link
Member

@MaxGekk MaxGekk Dec 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you improve the error message by following the common structure as in other errors in error-classes.json:

  1. State the issue
  2. Give a suggestion how to solve it.

The error could be:

Suggested change
"Temporary view <tableName> is not cached for analyzing columns."
"The ANALYZE TABLE FOR COLUMNS command can operate on temporary views that have been cached already. Consider to cache the view <viewName>."

]
},
"CATALOG_OPERATION" : {
"message" : [
"Catalog <catalogName> does not support <operation>."
Expand Down Expand Up @@ -2868,11 +2873,6 @@
"Partition spec is invalid. The spec (<specKeys>) must match the partition spec (<partitionColumnNames>) defined in table '<tableName>'."
]
},
"_LEGACY_ERROR_TEMP_1234" : {
"message" : [
"Temporary view <tableIdent> is not cached for analyzing columns."
]
},
"_LEGACY_ERROR_TEMP_1235" : {
"message" : [
"Column <name> in table <tableIdent> is of type <dataType>, and Spark does not support statistics collection on this column type."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2287,8 +2287,8 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase {

def tempViewNotCachedForAnalyzingColumnsError(tableIdent: TableIdentifier): Throwable = {
new AnalysisException(
errorClass = "_LEGACY_ERROR_TEMP_1234",
messageParameters = Map("tableIdent" -> tableIdent.toString))
errorClass = "UNSUPPORTED_FEATURE.ANALYZE_TABLE_VIEW_NOT_CACHED",
messageParameters = Map("tableName" -> toSQLId(tableIdent.toString)))
}

def columnTypeNotSupportStatisticsCollectionError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,10 +581,13 @@ class StatisticsCollectionSuite extends StatisticsCollectionTestBase with Shared
withTempView("tempView") {
// Analyzes in a temporary view
sql("CREATE TEMPORARY VIEW tempView AS SELECT 1 id")
val errMsg = intercept[AnalysisException] {
sql("ANALYZE TABLE tempView COMPUTE STATISTICS FOR COLUMNS id")
}.getMessage
assert(errMsg.contains("Temporary view `tempView` is not cached for analyzing columns"))
checkError(
exception = intercept[AnalysisException] {
sql("ANALYZE TABLE tempView COMPUTE STATISTICS FOR COLUMNS id")
},
errorClass = "UNSUPPORTED_FEATURE.ANALYZE_TABLE_VIEW_NOT_CACHED",
parameters = Map("tableName" -> "`tempView`")
)

// Cache the view then analyze it
sql("CACHE TABLE tempView")
Expand All @@ -604,11 +607,13 @@ class StatisticsCollectionSuite extends StatisticsCollectionTestBase with Shared
ExpectedContext(s"$globalTempDB.gTempView", 14, 13 + s"$globalTempDB.gTempView".length))
// Analyzes in a global temporary view
sql("CREATE GLOBAL TEMP VIEW gTempView AS SELECT 1 id")
val errMsg2 = intercept[AnalysisException] {
sql(s"ANALYZE TABLE $globalTempDB.gTempView COMPUTE STATISTICS FOR COLUMNS id")
}.getMessage
assert(errMsg2.contains(
s"Temporary view `$globalTempDB`.`gTempView` is not cached for analyzing columns"))
checkError(
exception = intercept[AnalysisException] {
sql(s"ANALYZE TABLE $globalTempDB.gTempView COMPUTE STATISTICS FOR COLUMNS id")
},
errorClass = "UNSUPPORTED_FEATURE.ANALYZE_TABLE_VIEW_NOT_CACHED",
parameters = Map("tableName" -> "`global_temp`.`gTempView`")
)

// Cache the view then analyze it
sql(s"CACHE TABLE $globalTempDB.gTempView")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,13 @@ abstract class SQLViewSuite extends QueryTest with SQLTestUtils {
}.getMessage
assert(e4.contains(
s"$viewName is a temp view. 'ANALYZE TABLE' expects a table or permanent view."))
val e5 = intercept[AnalysisException] {
sql(s"ANALYZE TABLE $viewName COMPUTE STATISTICS FOR COLUMNS id")
}.getMessage
assert(e5.contains(s"Temporary view `$viewName` is not cached for analyzing columns."))
checkError(
exception = intercept[AnalysisException] {
sql(s"ANALYZE TABLE $viewName COMPUTE STATISTICS FOR COLUMNS id")
},
errorClass = "UNSUPPORTED_FEATURE.ANALYZE_TABLE_VIEW_NOT_CACHED",
parameters = Map("tableName" -> "`testView`")
)
}
}

Expand Down