From 1ce01d707332a224e5b94b43db71650e4375e15b Mon Sep 17 00:00:00 2001 From: lingo-xp <36907211+lingo-xp@users.noreply.github.com> Date: Fri, 6 Dec 2024 10:17:06 +0800 Subject: [PATCH] Fix parse empty assign item issue. (#6272) * Fix parse empty assign item issue. * Set PPROX_QUANTILES as agg function. * Set PPROX_QUANTILES as agg function. * Fix. --------- Co-authored-by: Shaojin Wen --- .../druid/sql/parser/SQLExprParser.java | 18 +++--- .../test/resources/bvt/parser/bigquery/0.txt | 59 +++++++++++++++++++ 2 files changed, 69 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/com/alibaba/druid/sql/parser/SQLExprParser.java b/core/src/main/java/com/alibaba/druid/sql/parser/SQLExprParser.java index 0259a1f3fe..47886440d4 100644 --- a/core/src/main/java/com/alibaba/druid/sql/parser/SQLExprParser.java +++ b/core/src/main/java/com/alibaba/druid/sql/parser/SQLExprParser.java @@ -5178,15 +5178,17 @@ public SQLUnique parseUnique() { public void parseAssignItem(List outList, SQLObject parent) { accept(Token.LPAREN); - for (; ; ) { - SQLAssignItem item = this.parseAssignItem(true, parent); - item.setParent(parent); - outList.add(item); - if (lexer.token() == Token.COMMA) { - lexer.nextToken(); - continue; + if (lexer.token() != Token.RPAREN) { + for (; ; ) { + SQLAssignItem item = this.parseAssignItem(true, parent); + item.setParent(parent); + outList.add(item); + if (lexer.token() == Token.COMMA) { + lexer.nextToken(); + continue; + } + break; } - break; } accept(Token.RPAREN); } diff --git a/core/src/test/resources/bvt/parser/bigquery/0.txt b/core/src/test/resources/bvt/parser/bigquery/0.txt index 552b08cf82..cafa7d06b7 100644 --- a/core/src/test/resources/bvt/parser/bigquery/0.txt +++ b/core/src/test/resources/bvt/parser/bigquery/0.txt @@ -1,3 +1,62 @@ +create temporary function poly(polygon string) +returns string language js as """ +var res = JSON.parse(polygon); +var l = res.length; +var i; +for (i=0; i