[
https://issues.apache.org/jira/browse/CALCITE-4412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17235963#comment-17235963
]
Danny Chen commented on CALCITE-4412:
-------------------------------------
Yeah, Calcite INT type does not support precision yet. Isn't the integer type's
max precision just 10 ? Just curious ~
> SqlParser MySQL mode fails to parse "INT(11)" type
> --------------------------------------------------
>
> Key: CALCITE-4412
> URL: https://issues.apache.org/jira/browse/CALCITE-4412
> Project: Calcite
> Issue Type: Bug
> Components: server
> Affects Versions: 1.26.0
> Environment: Java 11
> Windows 10
> Reporter: Alex Ramos
> Priority: Major
>
> I am trying to use Calcite to parse some MySQL-style DDL. The parse fails on
> MySQL-style type declarations that include a display size e.g. int(11).
> Here is my test code:
> {code:java}
> public class SqlParserMysqlTest {
> private static final Config CONFIG = SqlParser.Config.DEFAULT
> .withLex(Lex.MYSQL).withConformance(SqlConformanceEnum.MYSQL_5)
> .withParserFactory(SqlDdlParserImpl.FACTORY);
> @Test
> public void testMysqlCreate() throws SqlParseException {
> SqlParser sqlParser = SqlParser.create(
> new SourceStringReader("create table `t1` (x int(11))"),
> CONFIG);
> SqlNode sqlNode = sqlParser.parseQuery();
> Assert.assertEquals(SqlKind.CREATE_TABLE, sqlNode.getKind());
> SqlCreateTable create = (SqlCreateTable) sqlNode;
> Assert.assertEquals("T1", create.name.getSimple());
> final SqlColumnDeclaration sqlColumnDeclaration =
> (SqlColumnDeclaration) create.columnList
> .get(0);
> Assert.assertEquals("X", sqlColumnDeclaration.name.getSimple());
> Assert.assertEquals("INTEGER",
> sqlColumnDeclaration.dataType.getTypeName().getSimple());
> }
> }
> {code}
> And here is the error:
> {noformat}
> org.apache.calcite.sql.parser.SqlParseException: Encountered "(" at line 1,
> column 25.
> Was expecting one of:
> "ARRAY" ...
> "AS" ...
> "DEFAULT" ...
> "GENERATED" ...
> "MULTISET" ...
> "NOT" ...
> "NULL" ...
> ")" ...
> "," ...
>
> at
> org.apache.calcite.sql.parser.ddl.SqlDdlParserImpl.convertException(SqlDdlParserImpl.java:394)
> at
> org.apache.calcite.sql.parser.ddl.SqlDdlParserImpl.normalizeException(SqlDdlParserImpl.java:157)
> at
> org.apache.calcite.sql.parser.SqlParser.handleException(SqlParser.java:140)
> at
> org.apache.calcite.sql.parser.SqlParser.parseQuery(SqlParser.java:155){noformat}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)