aboutsummaryrefslogtreecommitdiff
path: root/sql/catalyst/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'sql/catalyst/src/main')
-rw-r--r--sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala24
1 files changed, 12 insertions, 12 deletions
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
index 25202b521a..14a2a323c8 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
@@ -547,8 +547,7 @@ class Analyzer(
case a: Aggregate if containsStar(a.aggregateExpressions) =>
if (conf.groupByOrdinal && a.groupingExpressions.exists(IntegerIndex.unapply(_).nonEmpty)) {
failAnalysis(
- "Group by position: star is not allowed to use in the select list " +
- "when using ordinals in group by")
+ "Star (*) is not allowed in select list when GROUP BY ordinal position is used")
} else {
a.copy(aggregateExpressions = buildExpandedProjectList(a.aggregateExpressions, a.child))
}
@@ -723,9 +722,9 @@ class Analyzer(
if (index > 0 && index <= child.output.size) {
SortOrder(child.output(index - 1), direction)
} else {
- throw new UnresolvedException(s,
- s"Order/sort By position: $index does not exist " +
- s"The Select List is indexed from 1 to ${child.output.size}")
+ s.failAnalysis(
+ s"ORDER BY position $index is not in select list " +
+ s"(valid range is [1, ${child.output.size}])")
}
case o => o
}
@@ -737,17 +736,18 @@ class Analyzer(
if conf.groupByOrdinal && aggs.forall(_.resolved) &&
groups.exists(IntegerIndex.unapply(_).nonEmpty) =>
val newGroups = groups.map {
- case IntegerIndex(index) if index > 0 && index <= aggs.size =>
+ case ordinal @ IntegerIndex(index) if index > 0 && index <= aggs.size =>
aggs(index - 1) match {
case e if ResolveAggregateFunctions.containsAggregate(e) =>
- throw new UnresolvedException(a,
- s"Group by position: the '$index'th column in the select contains an " +
- s"aggregate function: ${e.sql}. Aggregate functions are not allowed in GROUP BY")
+ ordinal.failAnalysis(
+ s"GROUP BY position $index is an aggregate function, and " +
+ "aggregate functions are not allowed in GROUP BY")
case o => o
}
- case IntegerIndex(index) =>
- throw new UnresolvedException(a,
- s"Group by position: '$index' exceeds the size of the select list '${aggs.size}'.")
+ case ordinal @ IntegerIndex(index) =>
+ ordinal.failAnalysis(
+ s"GROUP BY position $index is not in select list " +
+ s"(valid range is [1, ${aggs.size}])")
case o => o
}
Aggregate(newGroups, aggs, child)