allisonwang-db commented on a change in pull request #30564:
URL: https://github.com/apache/spark/pull/30564#discussion_r535514353



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/QueryCompilationErrors.scala
##########
@@ -159,6 +164,174 @@ object QueryCompilationErrors {
       s"Couldn't find the reference column for $after at $parentName")
   }
 
-}
+  def windowSpecificationNotDefinedError(windowName: String): Throwable = {
+    new AnalysisException(s"Window specification $windowName is not defined in 
the WINDOW clause.")
+  }
+
+  def selectExprNotInGroupByError(expr: Expression, groupByAliases: 
Seq[Alias]): Throwable = {
+    new AnalysisException(s"$expr doesn't show up in the GROUP BY list 
$groupByAliases")
+  }
+
+  def groupingMustWithGroupingSetsOrCubeOrRollupError(): Throwable = {
+    new AnalysisException("grouping()/grouping_id() can only be used with 
GroupingSets/Cube/Rollup")
+  }
+
+  def pandasUDFAggregateNotSupportedInPivotError(): Throwable = {
+    new AnalysisException("Pandas UDF aggregate expressions are currently not 
supported in pivot.")
+  }
+
+  def aggregateExpressionRequiredForPivotError(sql: String): Throwable = {
+    new AnalysisException(s"Aggregate expression required for pivot, but 
'$sql' " +
+      "did not appear in any aggregate function.")
+  }
+
+  def expectedTableNotTempViewError(quoted: String, cmd: String, t: 
TreeNode[_]): Throwable = {

Review comment:
       expectTableNotTempViewError

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/QueryCompilationErrors.scala
##########
@@ -159,6 +164,174 @@ object QueryCompilationErrors {
       s"Couldn't find the reference column for $after at $parentName")
   }
 
-}
+  def windowSpecificationNotDefinedError(windowName: String): Throwable = {
+    new AnalysisException(s"Window specification $windowName is not defined in 
the WINDOW clause.")
+  }
+
+  def selectExprNotInGroupByError(expr: Expression, groupByAliases: 
Seq[Alias]): Throwable = {
+    new AnalysisException(s"$expr doesn't show up in the GROUP BY list 
$groupByAliases")
+  }
+
+  def groupingMustWithGroupingSetsOrCubeOrRollupError(): Throwable = {
+    new AnalysisException("grouping()/grouping_id() can only be used with 
GroupingSets/Cube/Rollup")
+  }
+
+  def pandasUDFAggregateNotSupportedInPivotError(): Throwable = {
+    new AnalysisException("Pandas UDF aggregate expressions are currently not 
supported in pivot.")
+  }
+
+  def aggregateExpressionRequiredForPivotError(sql: String): Throwable = {
+    new AnalysisException(s"Aggregate expression required for pivot, but 
'$sql' " +
+      "did not appear in any aggregate function.")
+  }
+
+  def expectedTableNotTempViewError(quoted: String, cmd: String, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def expectedTableOrPermanentViewNotTempViewError(

Review comment:
       expectTableOrPermanentViewNotTempViewError

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/QueryCompilationErrors.scala
##########
@@ -159,6 +164,174 @@ object QueryCompilationErrors {
       s"Couldn't find the reference column for $after at $parentName")
   }
 
-}
+  def windowSpecificationNotDefinedError(windowName: String): Throwable = {
+    new AnalysisException(s"Window specification $windowName is not defined in 
the WINDOW clause.")
+  }
+
+  def selectExprNotInGroupByError(expr: Expression, groupByAliases: 
Seq[Alias]): Throwable = {
+    new AnalysisException(s"$expr doesn't show up in the GROUP BY list 
$groupByAliases")
+  }
+
+  def groupingMustWithGroupingSetsOrCubeOrRollupError(): Throwable = {
+    new AnalysisException("grouping()/grouping_id() can only be used with 
GroupingSets/Cube/Rollup")
+  }
+
+  def pandasUDFAggregateNotSupportedInPivotError(): Throwable = {
+    new AnalysisException("Pandas UDF aggregate expressions are currently not 
supported in pivot.")
+  }
+
+  def aggregateExpressionRequiredForPivotError(sql: String): Throwable = {
+    new AnalysisException(s"Aggregate expression required for pivot, but 
'$sql' " +
+      "did not appear in any aggregate function.")
+  }
+
+  def expectedTableNotTempViewError(quoted: String, cmd: String, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def expectedTableOrPermanentViewNotTempViewError(
+      quoted: String, cmd: String, t: TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table or 
permanent view.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def viewDepthExceedsMaxResolutionDepthError(
+      identifier: TableIdentifier, maxNestedViewDepth: Int, t: TreeNode[_]): 
Throwable = {
+    new AnalysisException(s"The depth of view $identifier exceeds the maximum 
" +
+      s"view resolution depth ($maxNestedViewDepth). Analysis is aborted to " +
+      s"avoid errors. Increase the value of 
${SQLConf.MAX_NESTED_VIEW_DEPTH.key} to work " +
+      "around this.", t.origin.line, t.origin.startPosition)
+  }
+
+  def insertingIntoViewNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Inserting into a view is not allowed. View: 
$identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def writingIntoViewNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Writing into a view is not allowed. View: 
$identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def writingIntoV1TableNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {

Review comment:
       writeIntoV1TableNotAllowedError
   
   What is a V1 table here?

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/QueryCompilationErrors.scala
##########
@@ -159,6 +164,174 @@ object QueryCompilationErrors {
       s"Couldn't find the reference column for $after at $parentName")
   }
 
-}
+  def windowSpecificationNotDefinedError(windowName: String): Throwable = {
+    new AnalysisException(s"Window specification $windowName is not defined in 
the WINDOW clause.")
+  }
+
+  def selectExprNotInGroupByError(expr: Expression, groupByAliases: 
Seq[Alias]): Throwable = {
+    new AnalysisException(s"$expr doesn't show up in the GROUP BY list 
$groupByAliases")
+  }
+
+  def groupingMustWithGroupingSetsOrCubeOrRollupError(): Throwable = {
+    new AnalysisException("grouping()/grouping_id() can only be used with 
GroupingSets/Cube/Rollup")
+  }
+
+  def pandasUDFAggregateNotSupportedInPivotError(): Throwable = {
+    new AnalysisException("Pandas UDF aggregate expressions are currently not 
supported in pivot.")
+  }
+
+  def aggregateExpressionRequiredForPivotError(sql: String): Throwable = {
+    new AnalysisException(s"Aggregate expression required for pivot, but 
'$sql' " +
+      "did not appear in any aggregate function.")
+  }
+
+  def expectedTableNotTempViewError(quoted: String, cmd: String, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def expectedTableOrPermanentViewNotTempViewError(
+      quoted: String, cmd: String, t: TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table or 
permanent view.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def viewDepthExceedsMaxResolutionDepthError(
+      identifier: TableIdentifier, maxNestedViewDepth: Int, t: TreeNode[_]): 
Throwable = {
+    new AnalysisException(s"The depth of view $identifier exceeds the maximum 
" +
+      s"view resolution depth ($maxNestedViewDepth). Analysis is aborted to " +
+      s"avoid errors. Increase the value of 
${SQLConf.MAX_NESTED_VIEW_DEPTH.key} to work " +
+      "around this.", t.origin.line, t.origin.startPosition)
+  }
+
+  def insertingIntoViewNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Inserting into a view is not allowed. View: 
$identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def writingIntoViewNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Writing into a view is not allowed. View: 
$identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def writingIntoV1TableNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Cannot write into v1 table: $identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def expectsTableNotViewError(v: ResolvedView, cmd: String, t: TreeNode[_]): 
Throwable = {
+    val viewStr = if (v.isTemp) "temp view" else "view"
+    new AnalysisException(s"${v.identifier.quoted} is a $viewStr. '$cmd' 
expects a table.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def starNotAllowedWhenGroupByOrdinalPositionUsedError(): Throwable = {
+    new AnalysisException(
+      "Star (*) is not allowed in select list when GROUP BY ordinal position 
is used")
+  }
+
+  def starInExplodeOrJsonTupleOrUDTFInvalidError(): Throwable = {
+    new AnalysisException("Invalid usage of '*' in explode/json_tuple/UDTF")
+  }
+
+  def starInExpressionInvalidError(prettyName: String): Throwable = {
+    new AnalysisException(s"Invalid usage of '*' in expression '$prettyName'")
+  }
+
+  def orderByPositionRangeError(index: Int, size: Int, t: TreeNode[_]): 
Throwable = {
+    new AnalysisException(s"ORDER BY position $index is not in select list " +
+      s"(valid range is [1, $size])", t.origin.line, t.origin.startPosition)
+  }
+
+  def groupByPositionRangeError(index: Int, size: Int, t: TreeNode[_]): 
Throwable = {
+    new AnalysisException(s"GROUP BY position $index is not in select list " +
+      s"(valid range is [1, $size])", t.origin.line, t.origin.startPosition)
+  }
+
+  def generatorNotExpectedError(name: FunctionIdentifier, classCanonicalName: 
String): Throwable = {
+    new AnalysisException(s"$name is expected to be a generator. However, " +
+      s"its class is $classCanonicalName, which is not a generator.")
+  }
+
+  def distinctOrFilterOnlyWithAggregateFunctionError(prettyName: String): 
Throwable = {
+    new AnalysisException("DISTINCT or FILTER specified, " +
+      s"but $prettyName is not an aggregate function")
+  }
+
+  def filterInAggregateFunctionInvalidError(): Throwable = {
+    new AnalysisException("FILTER expression is non-deterministic, " +
+      "it cannot be used in aggregate functions")
+  }
+
+  def aliasNumberNotMatchColumnNumberError(
+      columnSize: Int, outputSize: Int, t: TreeNode[_]): Throwable = {
+    new AnalysisException("Number of column aliases does not match number of 
columns. " +
+      s"Number of column aliases: $columnSize; " +
+      s"number of columns: $outputSize.", t.origin.line, 
t.origin.startPosition)
+  }
 
+  def distinctOrFilterOnlyWithAggregateFunctionError(

Review comment:
       This name does not match the error description.

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/QueryCompilationErrors.scala
##########
@@ -159,6 +164,174 @@ object QueryCompilationErrors {
       s"Couldn't find the reference column for $after at $parentName")
   }
 
-}
+  def windowSpecificationNotDefinedError(windowName: String): Throwable = {
+    new AnalysisException(s"Window specification $windowName is not defined in 
the WINDOW clause.")
+  }
+
+  def selectExprNotInGroupByError(expr: Expression, groupByAliases: 
Seq[Alias]): Throwable = {
+    new AnalysisException(s"$expr doesn't show up in the GROUP BY list 
$groupByAliases")
+  }
+
+  def groupingMustWithGroupingSetsOrCubeOrRollupError(): Throwable = {
+    new AnalysisException("grouping()/grouping_id() can only be used with 
GroupingSets/Cube/Rollup")
+  }
+
+  def pandasUDFAggregateNotSupportedInPivotError(): Throwable = {
+    new AnalysisException("Pandas UDF aggregate expressions are currently not 
supported in pivot.")
+  }
+
+  def aggregateExpressionRequiredForPivotError(sql: String): Throwable = {
+    new AnalysisException(s"Aggregate expression required for pivot, but 
'$sql' " +
+      "did not appear in any aggregate function.")
+  }
+
+  def expectedTableNotTempViewError(quoted: String, cmd: String, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def expectedTableOrPermanentViewNotTempViewError(
+      quoted: String, cmd: String, t: TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table or 
permanent view.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def viewDepthExceedsMaxResolutionDepthError(
+      identifier: TableIdentifier, maxNestedViewDepth: Int, t: TreeNode[_]): 
Throwable = {
+    new AnalysisException(s"The depth of view $identifier exceeds the maximum 
" +
+      s"view resolution depth ($maxNestedViewDepth). Analysis is aborted to " +
+      s"avoid errors. Increase the value of 
${SQLConf.MAX_NESTED_VIEW_DEPTH.key} to work " +
+      "around this.", t.origin.line, t.origin.startPosition)
+  }
+
+  def insertingIntoViewNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Inserting into a view is not allowed. View: 
$identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def writingIntoViewNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Writing into a view is not allowed. View: 
$identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def writingIntoV1TableNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Cannot write into v1 table: $identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def expectsTableNotViewError(v: ResolvedView, cmd: String, t: TreeNode[_]): 
Throwable = {
+    val viewStr = if (v.isTemp) "temp view" else "view"
+    new AnalysisException(s"${v.identifier.quoted} is a $viewStr. '$cmd' 
expects a table.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def starNotAllowedWhenGroupByOrdinalPositionUsedError(): Throwable = {
+    new AnalysisException(
+      "Star (*) is not allowed in select list when GROUP BY ordinal position 
is used")
+  }
+
+  def starInExplodeOrJsonTupleOrUDTFInvalidError(): Throwable = {
+    new AnalysisException("Invalid usage of '*' in explode/json_tuple/UDTF")
+  }
+
+  def starInExpressionInvalidError(prettyName: String): Throwable = {
+    new AnalysisException(s"Invalid usage of '*' in expression '$prettyName'")
+  }
+
+  def orderByPositionRangeError(index: Int, size: Int, t: TreeNode[_]): 
Throwable = {
+    new AnalysisException(s"ORDER BY position $index is not in select list " +
+      s"(valid range is [1, $size])", t.origin.line, t.origin.startPosition)
+  }
+
+  def groupByPositionRangeError(index: Int, size: Int, t: TreeNode[_]): 
Throwable = {
+    new AnalysisException(s"GROUP BY position $index is not in select list " +
+      s"(valid range is [1, $size])", t.origin.line, t.origin.startPosition)
+  }
+
+  def generatorNotExpectedError(name: FunctionIdentifier, classCanonicalName: 
String): Throwable = {
+    new AnalysisException(s"$name is expected to be a generator. However, " +
+      s"its class is $classCanonicalName, which is not a generator.")
+  }
+
+  def distinctOrFilterOnlyWithAggregateFunctionError(prettyName: String): 
Throwable = {
+    new AnalysisException("DISTINCT or FILTER specified, " +
+      s"but $prettyName is not an aggregate function")
+  }
+
+  def filterInAggregateFunctionInvalidError(): Throwable = {
+    new AnalysisException("FILTER expression is non-deterministic, " +
+      "it cannot be used in aggregate functions")
+  }
+
+  def aliasNumberNotMatchColumnNumberError(
+      columnSize: Int, outputSize: Int, t: TreeNode[_]): Throwable = {
+    new AnalysisException("Number of column aliases does not match number of 
columns. " +
+      s"Number of column aliases: $columnSize; " +
+      s"number of columns: $outputSize.", t.origin.line, 
t.origin.startPosition)
+  }
 
+  def distinctOrFilterOnlyWithAggregateFunctionError(
+      aliasesSize: Int, aliasesNames: String): Throwable = {
+    new AnalysisException("The number of aliases supplied in the AS clause 
does not " +
+      s"match the number of columns output by the UDTF expected $aliasesSize " 
+
+      s"aliases but got $aliasesNames ")
+  }
+
+  def windowAggregateFunctionWithFilterNotSupportedError(): Throwable = {
+    new AnalysisException("window aggregate function with filter predicate is 
not supported yet.")
+  }
+
+  def windowFunctionInsideAggregateFunctionNotAllowedError(): Throwable = {
+    new AnalysisException("It is not allowed to use a window function inside 
an aggregate " +
+      "function. Please use the inner window function in a sub-query.")
+  }
+
+  def expressionWithoutWindowExpressionError(expr: NamedExpression): Throwable 
= {
+    new AnalysisException(s"$expr does not have any WindowExpression.")
+  }
+
+  def expressionWithMultiWindowExpressionError(
+      expr: NamedExpression, distinctWindowSpec: Seq[WindowSpecDefinition]): 
Throwable = {
+    new AnalysisException(s"$expr has multiple Window Specifications 
($distinctWindowSpec)." +
+      s"Please file a bug report with this error message, stack trace, and the 
query.")
+  }
 
+  def windowFunctionsNotAllowedInsideWhereClauseError(): Throwable = {
+    new AnalysisException("It is not allowed to use window functions inside 
WHERE clause")
+  }
+
+  def windowFunctionsNotAllowedInsideHavingClauseError(): Throwable = {

Review comment:
       Maybe we can combine this error and the one above it into one: 
`windowFunctionNotAllowedError` with the detailed message.

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/QueryCompilationErrors.scala
##########
@@ -159,6 +164,174 @@ object QueryCompilationErrors {
       s"Couldn't find the reference column for $after at $parentName")
   }
 
-}
+  def windowSpecificationNotDefinedError(windowName: String): Throwable = {
+    new AnalysisException(s"Window specification $windowName is not defined in 
the WINDOW clause.")
+  }
+
+  def selectExprNotInGroupByError(expr: Expression, groupByAliases: 
Seq[Alias]): Throwable = {
+    new AnalysisException(s"$expr doesn't show up in the GROUP BY list 
$groupByAliases")
+  }
+
+  def groupingMustWithGroupingSetsOrCubeOrRollupError(): Throwable = {
+    new AnalysisException("grouping()/grouping_id() can only be used with 
GroupingSets/Cube/Rollup")
+  }
+
+  def pandasUDFAggregateNotSupportedInPivotError(): Throwable = {
+    new AnalysisException("Pandas UDF aggregate expressions are currently not 
supported in pivot.")
+  }
+
+  def aggregateExpressionRequiredForPivotError(sql: String): Throwable = {
+    new AnalysisException(s"Aggregate expression required for pivot, but 
'$sql' " +
+      "did not appear in any aggregate function.")
+  }
+
+  def expectedTableNotTempViewError(quoted: String, cmd: String, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def expectedTableOrPermanentViewNotTempViewError(
+      quoted: String, cmd: String, t: TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table or 
permanent view.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def viewDepthExceedsMaxResolutionDepthError(
+      identifier: TableIdentifier, maxNestedViewDepth: Int, t: TreeNode[_]): 
Throwable = {
+    new AnalysisException(s"The depth of view $identifier exceeds the maximum 
" +
+      s"view resolution depth ($maxNestedViewDepth). Analysis is aborted to " +
+      s"avoid errors. Increase the value of 
${SQLConf.MAX_NESTED_VIEW_DEPTH.key} to work " +
+      "around this.", t.origin.line, t.origin.startPosition)
+  }
+
+  def insertingIntoViewNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Inserting into a view is not allowed. View: 
$identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def writingIntoViewNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Writing into a view is not allowed. View: 
$identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def writingIntoV1TableNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Cannot write into v1 table: $identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def expectsTableNotViewError(v: ResolvedView, cmd: String, t: TreeNode[_]): 
Throwable = {
+    val viewStr = if (v.isTemp) "temp view" else "view"
+    new AnalysisException(s"${v.identifier.quoted} is a $viewStr. '$cmd' 
expects a table.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def starNotAllowedWhenGroupByOrdinalPositionUsedError(): Throwable = {
+    new AnalysisException(
+      "Star (*) is not allowed in select list when GROUP BY ordinal position 
is used")
+  }
+
+  def starInExplodeOrJsonTupleOrUDTFInvalidError(): Throwable = {
+    new AnalysisException("Invalid usage of '*' in explode/json_tuple/UDTF")
+  }
+
+  def starInExpressionInvalidError(prettyName: String): Throwable = {
+    new AnalysisException(s"Invalid usage of '*' in expression '$prettyName'")
+  }
+
+  def orderByPositionRangeError(index: Int, size: Int, t: TreeNode[_]): 
Throwable = {
+    new AnalysisException(s"ORDER BY position $index is not in select list " +
+      s"(valid range is [1, $size])", t.origin.line, t.origin.startPosition)
+  }
+
+  def groupByPositionRangeError(index: Int, size: Int, t: TreeNode[_]): 
Throwable = {
+    new AnalysisException(s"GROUP BY position $index is not in select list " +
+      s"(valid range is [1, $size])", t.origin.line, t.origin.startPosition)
+  }
+
+  def generatorNotExpectedError(name: FunctionIdentifier, classCanonicalName: 
String): Throwable = {
+    new AnalysisException(s"$name is expected to be a generator. However, " +
+      s"its class is $classCanonicalName, which is not a generator.")
+  }
+
+  def distinctOrFilterOnlyWithAggregateFunctionError(prettyName: String): 
Throwable = {
+    new AnalysisException("DISTINCT or FILTER specified, " +
+      s"but $prettyName is not an aggregate function")
+  }
+
+  def filterInAggregateFunctionInvalidError(): Throwable = {
+    new AnalysisException("FILTER expression is non-deterministic, " +
+      "it cannot be used in aggregate functions")
+  }
+
+  def aliasNumberNotMatchColumnNumberError(
+      columnSize: Int, outputSize: Int, t: TreeNode[_]): Throwable = {
+    new AnalysisException("Number of column aliases does not match number of 
columns. " +
+      s"Number of column aliases: $columnSize; " +
+      s"number of columns: $outputSize.", t.origin.line, 
t.origin.startPosition)
+  }
 
+  def distinctOrFilterOnlyWithAggregateFunctionError(
+      aliasesSize: Int, aliasesNames: String): Throwable = {
+    new AnalysisException("The number of aliases supplied in the AS clause 
does not " +
+      s"match the number of columns output by the UDTF expected $aliasesSize " 
+
+      s"aliases but got $aliasesNames ")
+  }
+
+  def windowAggregateFunctionWithFilterNotSupportedError(): Throwable = {
+    new AnalysisException("window aggregate function with filter predicate is 
not supported yet.")
+  }
+
+  def windowFunctionInsideAggregateFunctionNotAllowedError(): Throwable = {
+    new AnalysisException("It is not allowed to use a window function inside 
an aggregate " +
+      "function. Please use the inner window function in a sub-query.")
+  }
+
+  def expressionWithoutWindowExpressionError(expr: NamedExpression): Throwable 
= {
+    new AnalysisException(s"$expr does not have any WindowExpression.")
+  }
+
+  def expressionWithMultiWindowExpressionError(
+      expr: NamedExpression, distinctWindowSpec: Seq[WindowSpecDefinition]): 
Throwable = {
+    new AnalysisException(s"$expr has multiple Window Specifications 
($distinctWindowSpec)." +
+      s"Please file a bug report with this error message, stack trace, and the 
query.")
+  }
 
+  def windowFunctionsNotAllowedInsideWhereClauseError(): Throwable = {
+    new AnalysisException("It is not allowed to use window functions inside 
WHERE clause")
+  }
+
+  def windowFunctionsNotAllowedInsideHavingClauseError(): Throwable = {
+    new AnalysisException("It is not allowed to use window functions inside 
HAVING clause")
+  }
+
+  def specifyWindowFrameForFrameLessOffsetWindowFunctionError(prettyName: 
String): Throwable = {

Review comment:
       Maybe `cannotSpecifyWindowFrameError`?

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/QueryCompilationErrors.scala
##########
@@ -159,6 +164,174 @@ object QueryCompilationErrors {
       s"Couldn't find the reference column for $after at $parentName")
   }
 
-}
+  def windowSpecificationNotDefinedError(windowName: String): Throwable = {
+    new AnalysisException(s"Window specification $windowName is not defined in 
the WINDOW clause.")
+  }
+
+  def selectExprNotInGroupByError(expr: Expression, groupByAliases: 
Seq[Alias]): Throwable = {
+    new AnalysisException(s"$expr doesn't show up in the GROUP BY list 
$groupByAliases")
+  }
+
+  def groupingMustWithGroupingSetsOrCubeOrRollupError(): Throwable = {
+    new AnalysisException("grouping()/grouping_id() can only be used with 
GroupingSets/Cube/Rollup")
+  }
+
+  def pandasUDFAggregateNotSupportedInPivotError(): Throwable = {
+    new AnalysisException("Pandas UDF aggregate expressions are currently not 
supported in pivot.")
+  }
+
+  def aggregateExpressionRequiredForPivotError(sql: String): Throwable = {
+    new AnalysisException(s"Aggregate expression required for pivot, but 
'$sql' " +
+      "did not appear in any aggregate function.")
+  }
+
+  def expectedTableNotTempViewError(quoted: String, cmd: String, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def expectedTableOrPermanentViewNotTempViewError(
+      quoted: String, cmd: String, t: TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table or 
permanent view.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def viewDepthExceedsMaxResolutionDepthError(
+      identifier: TableIdentifier, maxNestedViewDepth: Int, t: TreeNode[_]): 
Throwable = {
+    new AnalysisException(s"The depth of view $identifier exceeds the maximum 
" +
+      s"view resolution depth ($maxNestedViewDepth). Analysis is aborted to " +
+      s"avoid errors. Increase the value of 
${SQLConf.MAX_NESTED_VIEW_DEPTH.key} to work " +
+      "around this.", t.origin.line, t.origin.startPosition)
+  }
+
+  def insertingIntoViewNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {

Review comment:
       insertIntoViewNotAllowedError

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/QueryCompilationErrors.scala
##########
@@ -159,6 +164,174 @@ object QueryCompilationErrors {
       s"Couldn't find the reference column for $after at $parentName")
   }
 
-}
+  def windowSpecificationNotDefinedError(windowName: String): Throwable = {
+    new AnalysisException(s"Window specification $windowName is not defined in 
the WINDOW clause.")
+  }
+
+  def selectExprNotInGroupByError(expr: Expression, groupByAliases: 
Seq[Alias]): Throwable = {
+    new AnalysisException(s"$expr doesn't show up in the GROUP BY list 
$groupByAliases")
+  }
+
+  def groupingMustWithGroupingSetsOrCubeOrRollupError(): Throwable = {
+    new AnalysisException("grouping()/grouping_id() can only be used with 
GroupingSets/Cube/Rollup")
+  }
+
+  def pandasUDFAggregateNotSupportedInPivotError(): Throwable = {
+    new AnalysisException("Pandas UDF aggregate expressions are currently not 
supported in pivot.")
+  }
+
+  def aggregateExpressionRequiredForPivotError(sql: String): Throwable = {
+    new AnalysisException(s"Aggregate expression required for pivot, but 
'$sql' " +
+      "did not appear in any aggregate function.")
+  }
+
+  def expectedTableNotTempViewError(quoted: String, cmd: String, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def expectedTableOrPermanentViewNotTempViewError(
+      quoted: String, cmd: String, t: TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table or 
permanent view.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def viewDepthExceedsMaxResolutionDepthError(
+      identifier: TableIdentifier, maxNestedViewDepth: Int, t: TreeNode[_]): 
Throwable = {
+    new AnalysisException(s"The depth of view $identifier exceeds the maximum 
" +
+      s"view resolution depth ($maxNestedViewDepth). Analysis is aborted to " +
+      s"avoid errors. Increase the value of 
${SQLConf.MAX_NESTED_VIEW_DEPTH.key} to work " +
+      "around this.", t.origin.line, t.origin.startPosition)
+  }
+
+  def insertingIntoViewNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Inserting into a view is not allowed. View: 
$identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def writingIntoViewNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {

Review comment:
       writeIntoViewNotAllowedError

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/QueryCompilationErrors.scala
##########
@@ -159,6 +164,174 @@ object QueryCompilationErrors {
       s"Couldn't find the reference column for $after at $parentName")
   }
 
-}
+  def windowSpecificationNotDefinedError(windowName: String): Throwable = {
+    new AnalysisException(s"Window specification $windowName is not defined in 
the WINDOW clause.")
+  }
+
+  def selectExprNotInGroupByError(expr: Expression, groupByAliases: 
Seq[Alias]): Throwable = {
+    new AnalysisException(s"$expr doesn't show up in the GROUP BY list 
$groupByAliases")
+  }
+
+  def groupingMustWithGroupingSetsOrCubeOrRollupError(): Throwable = {
+    new AnalysisException("grouping()/grouping_id() can only be used with 
GroupingSets/Cube/Rollup")
+  }
+
+  def pandasUDFAggregateNotSupportedInPivotError(): Throwable = {
+    new AnalysisException("Pandas UDF aggregate expressions are currently not 
supported in pivot.")
+  }
+
+  def aggregateExpressionRequiredForPivotError(sql: String): Throwable = {
+    new AnalysisException(s"Aggregate expression required for pivot, but 
'$sql' " +
+      "did not appear in any aggregate function.")
+  }
+
+  def expectedTableNotTempViewError(quoted: String, cmd: String, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def expectedTableOrPermanentViewNotTempViewError(
+      quoted: String, cmd: String, t: TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table or 
permanent view.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def viewDepthExceedsMaxResolutionDepthError(
+      identifier: TableIdentifier, maxNestedViewDepth: Int, t: TreeNode[_]): 
Throwable = {
+    new AnalysisException(s"The depth of view $identifier exceeds the maximum 
" +
+      s"view resolution depth ($maxNestedViewDepth). Analysis is aborted to " +
+      s"avoid errors. Increase the value of 
${SQLConf.MAX_NESTED_VIEW_DEPTH.key} to work " +
+      "around this.", t.origin.line, t.origin.startPosition)
+  }
+
+  def insertingIntoViewNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Inserting into a view is not allowed. View: 
$identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def writingIntoViewNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Writing into a view is not allowed. View: 
$identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def writingIntoV1TableNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Cannot write into v1 table: $identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def expectsTableNotViewError(v: ResolvedView, cmd: String, t: TreeNode[_]): 
Throwable = {

Review comment:
       expectTableNotViewError
   
   This one seems to also cover the `expectTableNotTempViewError`. We can 
combine these two errors.

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/QueryCompilationErrors.scala
##########
@@ -159,6 +164,174 @@ object QueryCompilationErrors {
       s"Couldn't find the reference column for $after at $parentName")
   }
 
-}
+  def windowSpecificationNotDefinedError(windowName: String): Throwable = {
+    new AnalysisException(s"Window specification $windowName is not defined in 
the WINDOW clause.")
+  }
+
+  def selectExprNotInGroupByError(expr: Expression, groupByAliases: 
Seq[Alias]): Throwable = {
+    new AnalysisException(s"$expr doesn't show up in the GROUP BY list 
$groupByAliases")
+  }
+
+  def groupingMustWithGroupingSetsOrCubeOrRollupError(): Throwable = {
+    new AnalysisException("grouping()/grouping_id() can only be used with 
GroupingSets/Cube/Rollup")
+  }
+
+  def pandasUDFAggregateNotSupportedInPivotError(): Throwable = {
+    new AnalysisException("Pandas UDF aggregate expressions are currently not 
supported in pivot.")
+  }
+
+  def aggregateExpressionRequiredForPivotError(sql: String): Throwable = {
+    new AnalysisException(s"Aggregate expression required for pivot, but 
'$sql' " +
+      "did not appear in any aggregate function.")
+  }
+
+  def expectedTableNotTempViewError(quoted: String, cmd: String, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def expectedTableOrPermanentViewNotTempViewError(
+      quoted: String, cmd: String, t: TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table or 
permanent view.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def viewDepthExceedsMaxResolutionDepthError(
+      identifier: TableIdentifier, maxNestedViewDepth: Int, t: TreeNode[_]): 
Throwable = {
+    new AnalysisException(s"The depth of view $identifier exceeds the maximum 
" +
+      s"view resolution depth ($maxNestedViewDepth). Analysis is aborted to " +
+      s"avoid errors. Increase the value of 
${SQLConf.MAX_NESTED_VIEW_DEPTH.key} to work " +
+      "around this.", t.origin.line, t.origin.startPosition)
+  }
+
+  def insertingIntoViewNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Inserting into a view is not allowed. View: 
$identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def writingIntoViewNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Writing into a view is not allowed. View: 
$identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def writingIntoV1TableNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Cannot write into v1 table: $identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def expectsTableNotViewError(v: ResolvedView, cmd: String, t: TreeNode[_]): 
Throwable = {
+    val viewStr = if (v.isTemp) "temp view" else "view"
+    new AnalysisException(s"${v.identifier.quoted} is a $viewStr. '$cmd' 
expects a table.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def starNotAllowedWhenGroupByOrdinalPositionUsedError(): Throwable = {
+    new AnalysisException(
+      "Star (*) is not allowed in select list when GROUP BY ordinal position 
is used")
+  }
+
+  def starInExplodeOrJsonTupleOrUDTFInvalidError(): Throwable = {
+    new AnalysisException("Invalid usage of '*' in explode/json_tuple/UDTF")
+  }
+
+  def starInExpressionInvalidError(prettyName: String): Throwable = {

Review comment:
       I think this one can be combined with the previous one 
(starInExplodeOrJsonTupleOrUDTFInvalidError) into an `invalidStarUsageError` 
with detailed messages.

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/QueryCompilationErrors.scala
##########
@@ -159,6 +164,174 @@ object QueryCompilationErrors {
       s"Couldn't find the reference column for $after at $parentName")
   }
 
-}
+  def windowSpecificationNotDefinedError(windowName: String): Throwable = {
+    new AnalysisException(s"Window specification $windowName is not defined in 
the WINDOW clause.")
+  }
+
+  def selectExprNotInGroupByError(expr: Expression, groupByAliases: 
Seq[Alias]): Throwable = {
+    new AnalysisException(s"$expr doesn't show up in the GROUP BY list 
$groupByAliases")
+  }
+
+  def groupingMustWithGroupingSetsOrCubeOrRollupError(): Throwable = {
+    new AnalysisException("grouping()/grouping_id() can only be used with 
GroupingSets/Cube/Rollup")
+  }
+
+  def pandasUDFAggregateNotSupportedInPivotError(): Throwable = {
+    new AnalysisException("Pandas UDF aggregate expressions are currently not 
supported in pivot.")
+  }
+
+  def aggregateExpressionRequiredForPivotError(sql: String): Throwable = {
+    new AnalysisException(s"Aggregate expression required for pivot, but 
'$sql' " +
+      "did not appear in any aggregate function.")
+  }
+
+  def expectedTableNotTempViewError(quoted: String, cmd: String, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def expectedTableOrPermanentViewNotTempViewError(
+      quoted: String, cmd: String, t: TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table or 
permanent view.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def viewDepthExceedsMaxResolutionDepthError(
+      identifier: TableIdentifier, maxNestedViewDepth: Int, t: TreeNode[_]): 
Throwable = {
+    new AnalysisException(s"The depth of view $identifier exceeds the maximum 
" +
+      s"view resolution depth ($maxNestedViewDepth). Analysis is aborted to " +
+      s"avoid errors. Increase the value of 
${SQLConf.MAX_NESTED_VIEW_DEPTH.key} to work " +
+      "around this.", t.origin.line, t.origin.startPosition)
+  }
+
+  def insertingIntoViewNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Inserting into a view is not allowed. View: 
$identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def writingIntoViewNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Writing into a view is not allowed. View: 
$identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def writingIntoV1TableNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Cannot write into v1 table: $identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def expectsTableNotViewError(v: ResolvedView, cmd: String, t: TreeNode[_]): 
Throwable = {
+    val viewStr = if (v.isTemp) "temp view" else "view"
+    new AnalysisException(s"${v.identifier.quoted} is a $viewStr. '$cmd' 
expects a table.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def starNotAllowedWhenGroupByOrdinalPositionUsedError(): Throwable = {
+    new AnalysisException(
+      "Star (*) is not allowed in select list when GROUP BY ordinal position 
is used")
+  }
+
+  def starInExplodeOrJsonTupleOrUDTFInvalidError(): Throwable = {
+    new AnalysisException("Invalid usage of '*' in explode/json_tuple/UDTF")
+  }
+
+  def starInExpressionInvalidError(prettyName: String): Throwable = {
+    new AnalysisException(s"Invalid usage of '*' in expression '$prettyName'")
+  }
+
+  def orderByPositionRangeError(index: Int, size: Int, t: TreeNode[_]): 
Throwable = {
+    new AnalysisException(s"ORDER BY position $index is not in select list " +
+      s"(valid range is [1, $size])", t.origin.line, t.origin.startPosition)
+  }
+
+  def groupByPositionRangeError(index: Int, size: Int, t: TreeNode[_]): 
Throwable = {
+    new AnalysisException(s"GROUP BY position $index is not in select list " +
+      s"(valid range is [1, $size])", t.origin.line, t.origin.startPosition)
+  }
+
+  def generatorNotExpectedError(name: FunctionIdentifier, classCanonicalName: 
String): Throwable = {
+    new AnalysisException(s"$name is expected to be a generator. However, " +
+      s"its class is $classCanonicalName, which is not a generator.")
+  }
+
+  def distinctOrFilterOnlyWithAggregateFunctionError(prettyName: String): 
Throwable = {
+    new AnalysisException("DISTINCT or FILTER specified, " +
+      s"but $prettyName is not an aggregate function")
+  }
+
+  def filterInAggregateFunctionInvalidError(): Throwable = {

Review comment:
       We might want to emphasize the non-deterministic filter here: 
`nonDeterministicFilterInAggregateError`

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/QueryCompilationErrors.scala
##########
@@ -159,6 +164,174 @@ object QueryCompilationErrors {
       s"Couldn't find the reference column for $after at $parentName")
   }
 
-}
+  def windowSpecificationNotDefinedError(windowName: String): Throwable = {
+    new AnalysisException(s"Window specification $windowName is not defined in 
the WINDOW clause.")
+  }
+
+  def selectExprNotInGroupByError(expr: Expression, groupByAliases: 
Seq[Alias]): Throwable = {
+    new AnalysisException(s"$expr doesn't show up in the GROUP BY list 
$groupByAliases")
+  }
+
+  def groupingMustWithGroupingSetsOrCubeOrRollupError(): Throwable = {
+    new AnalysisException("grouping()/grouping_id() can only be used with 
GroupingSets/Cube/Rollup")
+  }
+
+  def pandasUDFAggregateNotSupportedInPivotError(): Throwable = {
+    new AnalysisException("Pandas UDF aggregate expressions are currently not 
supported in pivot.")
+  }
+
+  def aggregateExpressionRequiredForPivotError(sql: String): Throwable = {
+    new AnalysisException(s"Aggregate expression required for pivot, but 
'$sql' " +
+      "did not appear in any aggregate function.")
+  }
+
+  def expectedTableNotTempViewError(quoted: String, cmd: String, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def expectedTableOrPermanentViewNotTempViewError(
+      quoted: String, cmd: String, t: TreeNode[_]): Throwable = {
+    new AnalysisException(s"$quoted is a temp view. '$cmd' expects a table or 
permanent view.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def viewDepthExceedsMaxResolutionDepthError(
+      identifier: TableIdentifier, maxNestedViewDepth: Int, t: TreeNode[_]): 
Throwable = {
+    new AnalysisException(s"The depth of view $identifier exceeds the maximum 
" +
+      s"view resolution depth ($maxNestedViewDepth). Analysis is aborted to " +
+      s"avoid errors. Increase the value of 
${SQLConf.MAX_NESTED_VIEW_DEPTH.key} to work " +
+      "around this.", t.origin.line, t.origin.startPosition)
+  }
+
+  def insertingIntoViewNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Inserting into a view is not allowed. View: 
$identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def writingIntoViewNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Writing into a view is not allowed. View: 
$identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def writingIntoV1TableNotAllowedError(identifier: TableIdentifier, t: 
TreeNode[_]): Throwable = {
+    new AnalysisException(s"Cannot write into v1 table: $identifier.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def expectsTableNotViewError(v: ResolvedView, cmd: String, t: TreeNode[_]): 
Throwable = {
+    val viewStr = if (v.isTemp) "temp view" else "view"
+    new AnalysisException(s"${v.identifier.quoted} is a $viewStr. '$cmd' 
expects a table.",
+      t.origin.line, t.origin.startPosition)
+  }
+
+  def starNotAllowedWhenGroupByOrdinalPositionUsedError(): Throwable = {
+    new AnalysisException(
+      "Star (*) is not allowed in select list when GROUP BY ordinal position 
is used")
+  }
+
+  def starInExplodeOrJsonTupleOrUDTFInvalidError(): Throwable = {
+    new AnalysisException("Invalid usage of '*' in explode/json_tuple/UDTF")
+  }
+
+  def starInExpressionInvalidError(prettyName: String): Throwable = {
+    new AnalysisException(s"Invalid usage of '*' in expression '$prettyName'")
+  }
+
+  def orderByPositionRangeError(index: Int, size: Int, t: TreeNode[_]): 
Throwable = {
+    new AnalysisException(s"ORDER BY position $index is not in select list " +
+      s"(valid range is [1, $size])", t.origin.line, t.origin.startPosition)
+  }
+
+  def groupByPositionRangeError(index: Int, size: Int, t: TreeNode[_]): 
Throwable = {
+    new AnalysisException(s"GROUP BY position $index is not in select list " +
+      s"(valid range is [1, $size])", t.origin.line, t.origin.startPosition)
+  }
+
+  def generatorNotExpectedError(name: FunctionIdentifier, classCanonicalName: 
String): Throwable = {
+    new AnalysisException(s"$name is expected to be a generator. However, " +
+      s"its class is $classCanonicalName, which is not a generator.")
+  }
+
+  def distinctOrFilterOnlyWithAggregateFunctionError(prettyName: String): 
Throwable = {
+    new AnalysisException("DISTINCT or FILTER specified, " +
+      s"but $prettyName is not an aggregate function")
+  }
+
+  def filterInAggregateFunctionInvalidError(): Throwable = {
+    new AnalysisException("FILTER expression is non-deterministic, " +
+      "it cannot be used in aggregate functions")
+  }
+
+  def aliasNumberNotMatchColumnNumberError(
+      columnSize: Int, outputSize: Int, t: TreeNode[_]): Throwable = {
+    new AnalysisException("Number of column aliases does not match number of 
columns. " +
+      s"Number of column aliases: $columnSize; " +
+      s"number of columns: $outputSize.", t.origin.line, 
t.origin.startPosition)
+  }
 
+  def distinctOrFilterOnlyWithAggregateFunctionError(
+      aliasesSize: Int, aliasesNames: String): Throwable = {
+    new AnalysisException("The number of aliases supplied in the AS clause 
does not " +
+      s"match the number of columns output by the UDTF expected $aliasesSize " 
+
+      s"aliases but got $aliasesNames ")
+  }
+
+  def windowAggregateFunctionWithFilterNotSupportedError(): Throwable = {
+    new AnalysisException("window aggregate function with filter predicate is 
not supported yet.")
+  }
+
+  def windowFunctionInsideAggregateFunctionNotAllowedError(): Throwable = {
+    new AnalysisException("It is not allowed to use a window function inside 
an aggregate " +
+      "function. Please use the inner window function in a sub-query.")
+  }
+
+  def expressionWithoutWindowExpressionError(expr: NamedExpression): Throwable 
= {
+    new AnalysisException(s"$expr does not have any WindowExpression.")
+  }
+
+  def expressionWithMultiWindowExpressionError(

Review comment:
       expressionWithMultiWindowExpressionsError

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
##########
@@ -50,6 +50,10 @@ trait CheckAnalysis extends PredicateHelper {
     throw new AnalysisException(msg)
   }
 
+  protected def failAnalysis(t: Throwable): Nothing = {

Review comment:
       Maybe use `error` instead of `t` here?

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/package.scala
##########
@@ -42,6 +42,10 @@ package object analysis {
       throw new AnalysisException(msg, t.origin.line, t.origin.startPosition)
     }
 
+    def failAnalysis(t: Throwable): Nothing = {

Review comment:
       ditto




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to