Skip to content

Commit bc8e638

Browse files
committed
fix.
1 parent df766a4 commit bc8e638

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ primaryExpression
569569
| qualifiedName '.' ASTERISK #star
570570
| '(' namedExpression (',' namedExpression)+ ')' #rowConstructor
571571
| '(' query ')' #subqueryExpression
572-
| qualifiedName '(' (setQuantifier? namedExpression (',' namedExpression)*)? ')'
572+
| qualifiedName '(' (setQuantifier? argument+=expression (',' argument+=expression)*)? ')'
573573
(OVER windowSpec)? #functionCall
574574
| value=primaryExpression '[' index=valueExpression ']' #subscript
575575
| identifier #columnReference

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ class AstBuilder(conf: SQLConf) extends SqlBaseBaseVisitor[AnyRef] with Logging
10901090
// Create the function call.
10911091
val name = ctx.qualifiedName.getText
10921092
val isDistinct = Option(ctx.setQuantifier()).exists(_.DISTINCT != null)
1093-
val arguments = ctx.namedExpression().asScala.map(expression) match {
1093+
val arguments = ctx.argument.asScala.map(expression) match {
10941094
case Seq(UnresolvedStar(None))
10951095
if name.toLowerCase(Locale.ROOT) == "count" && !isDistinct =>
10961096
// Transform COUNT(*) into COUNT(1).

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ class PlanParserSuite extends PlanTest {
223223
assertEqual(s"$sql grouping sets((a, b), (a), ())",
224224
GroupingSets(Seq(Seq('a, 'b), Seq('a), Seq()), Seq('a, 'b), table("d"),
225225
Seq('a, 'b, 'sum.function('c).as("c"))))
226+
227+
val m = intercept[ParseException] {
228+
parsePlan("SELECT a, b, count(distinct a, distinct b) as c FROM d GROUP BY a, b")
229+
}.getMessage
230+
assert(m.contains("extraneous input 'b'"))
231+
226232
}
227233

228234
test("limit") {

0 commit comments

Comments
 (0)