From 324628c274bf90e92a8d293967e4abb8e4e0a052 Mon Sep 17 00:00:00 2001 From: lingo-xp <36907211+lingo-xp@users.noreply.github.com> Date: Thu, 19 Dec 2024 09:37:00 +0800 Subject: [PATCH] Fix bq any type parse issue. (#6294) * Fix bq any type parse issue. * Fix bq any type parse issue. --- .../bigquery/parser/BigQueryExprParser.java | 4 ++-- .../bvt/sql/bigquery/BigQueryDataTypeTest.java | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 core/src/test/java/com/alibaba/druid/bvt/sql/bigquery/BigQueryDataTypeTest.java diff --git a/core/src/main/java/com/alibaba/druid/sql/dialect/bigquery/parser/BigQueryExprParser.java b/core/src/main/java/com/alibaba/druid/sql/dialect/bigquery/parser/BigQueryExprParser.java index 21f9d6b6ca..c06978bb09 100644 --- a/core/src/main/java/com/alibaba/druid/sql/dialect/bigquery/parser/BigQueryExprParser.java +++ b/core/src/main/java/com/alibaba/druid/sql/dialect/bigquery/parser/BigQueryExprParser.java @@ -333,12 +333,12 @@ public SQLExpr primaryRest(SQLExpr expr) { return super.primaryRest(expr); } - public SQLDataType parseDataType() { + public SQLDataType parseDataType(boolean restrict) { if (lexer.nextIf(Token.ANY)) { acceptIdentifier("TYPE"); return new SQLDataTypeImpl("ANY TYPE"); } - return parseDataType(true); + return super.parseDataType(restrict); } protected SQLExpr dotRest(SQLExpr expr) { diff --git a/core/src/test/java/com/alibaba/druid/bvt/sql/bigquery/BigQueryDataTypeTest.java b/core/src/test/java/com/alibaba/druid/bvt/sql/bigquery/BigQueryDataTypeTest.java new file mode 100644 index 0000000000..0a99fed758 --- /dev/null +++ b/core/src/test/java/com/alibaba/druid/bvt/sql/bigquery/BigQueryDataTypeTest.java @@ -0,0 +1,18 @@ +package com.alibaba.druid.bvt.sql.bigquery; + +import com.alibaba.druid.DbType; +import com.alibaba.druid.sql.ast.SQLDataType; +import com.alibaba.druid.sql.parser.SQLExprParser; +import com.alibaba.druid.sql.parser.SQLParserUtils; +import org.junit.Assert; +import org.junit.Test; + +public class BigQueryDataTypeTest { + @Test + public void testDataType() { + String sql = "ANY TYPE"; + SQLExprParser exprParser = SQLParserUtils.createExprParser(sql, DbType.bigquery); + SQLDataType dataType = exprParser.parseDataType(false); + Assert.assertEquals(sql, dataType.getName()); + } +}