Парсер DDL Apache Calcite не анализирует ограничение PRIMARY KEYJAVA

Программисты JAVA общаются здесь
Anonymous
Парсер DDL Apache Calcite не анализирует ограничение PRIMARY KEY

Сообщение Anonymous »


I want to parse a few DDL statements for my use case. I am using SqlDDLParserImpl provided by Calcite Server for my use case. version : org.apache.calcite:calcite-server:1.36.0

I am able to parse the create statements who don't have any kind of constraints, however, few of the statements are failing with Primary Key constraints.

So I tried this code for parsing the DDL

SqlParser.Config sqlParserConfig = SqlParser.config() .withParserFactory(SqlDdlParserImpl.FACTORY) .withConformance(SqlConformanceEnum.MYSQL_5) .withLex(Lex.MYSQL); SqlNode sqlNode = SqlParser.create(sql, sqlParserConfig).parseQuery(); This works fine

String sql = "CREATE TABLE employees (\n" + " employee_id INT NOT NULL,\n" + " first_name VARCHAR(50),\n" + " last_name VARCHAR(50),\n" + " email VARCHAR(100),\n" + " department_id INT," + " PRIMARY KEY (employee_id)" + ")"; But this does not

String sql = "CREATE TABLE employees (\n" + " employee_id INT NOT NULL PRIMARY KEY,\n" + " first_name VARCHAR(50),\n" + " last_name VARCHAR(50),\n" + " email VARCHAR(100),\n" + " department_id INT" + ")"; and I get this message from exception

Encountered "PRIMARY" at line 2, column 30. Was expecting one of: "AS" ... "DEFAULT" ... "GENERATED" ... ")" ... "," ... Am I missing something from the parser configuration or only the first one is currently supported by Apache Calcite?


Источник: https://stackoverflow.com/questions/781 ... constraint

Вернуться в «JAVA»