Re 1. It seems that the Server parser goes further than the Server 
implementation. You can specify PRIMARY KEY in the DDL, and we can parse it, 
but Server cannot create tables with primary keys. Please log a bug. 
Contributions welcome.

One workaround is for you to parse but not execute. The information you need is 
in the parse tree (SqlCreateTable, SqlKeyConstraint).

Re 2. Can you log a bug? Related to 
https://issues.apache.org/jira/browse/CALCITE-3582 
<https://issues.apache.org/jira/browse/CALCITE-3582> and 
https://issues.apache.org/jira/browse/CALCITE-4642 
<https://issues.apache.org/jira/browse/CALCITE-4642>.

Julian




> On Jul 4, 2021, at 8:14 AM, Arthur Pan <pansich...@berkeley.edu> wrote:
> 
> Greetings to dev@calcite:
> 
> I am currently working on extracting RelNodes from DML queries with schemas
> derived from DDL statements, and I have encountered a few issues:
> 
> 1. My current method to derive schemas from DDL statements is
>    (a) connect to "jdbc:calcite" with parser factory set to
> ServerDdlExecutor.ParserFactory
>    (b) execute the DDL statements
>    (c) extract schema with connection.getRootSchem()
>  Currently simple create statements can be correctly executed. However,
> the execution (at
> org.apache.calcite.server.ServerDdlExecutor.execute(ServerDdlExecutor.java:472))
> will fail when constraints (e.g. PRIMARY KEY) are involved. The CREATE
> statement I used is pasted below:
>    CREATE TABLE EMP (EMP_ID INTEGER NOT NULL,
>                                         EMP_NAME VARCHAR,
>                                         DEPT_ID INTEGER,
>                                         PRIMARY KEY (DEPT_ID))
>  Is there a way to fix this? Or is there a better way to derive schema
> from DDL statements?
> 
> 2. It seems that currently PlannerImpl.rel(SqlNode) decorrelate (at
> PlannerImpl.java:265) the RelRoot converted from SqlNode, regardless what
> the RelBuilderConfig was passed in to the planner. Is there a way to bypass
> such a transformation to RelNode and fetch the raw RelRoot converted from
> SqlNode by SqlToRelConverter in PlannerImpl?
> 
> I would appreciate any insights into anything related. Thanks in advance!
> 
> Sincerely,
> Arthur Pan

Reply via email to