Skip to content

Commit

Permalink
Fix bq any type parse issue. (#6294)
Browse files Browse the repository at this point in the history
* Fix bq any type parse issue.

* Fix bq any type parse issue.
  • Loading branch information
lingo-xp authored Dec 19, 2024
1 parent 49f8166 commit 324628c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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());
}
}

0 comments on commit 324628c

Please sign in to comment.