[ 
https://issues.apache.org/jira/browse/CALCITE-4580?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17321045#comment-17321045
 ] 

Konstantin Orlov commented on CALCITE-4580:
-------------------------------------------

We are implementing a custom CREATE TABLE command. The {{CustomCreateTable}} 
extends {{SqlCreate}} and everything is fine here. But we have a several table 
options which could be specified within the command and for this we need a 
container. All these options are effectively a key-value pairs.

An approach #1 is to put both option's key and value in the {{SqlNodeList}}. 
The cons is we need to perform an additional check that the size is even and 
treat the key as SqlIdentifier rather {{TableOptionEnum}} value. For me it 
looks more like a workaround.

An approach #2 is to contribute to Calcite some sort of {{KeyValueNode}}. The 
cons is we still need to work with the key as with SqlIdentifier.

An approach #3 is to give an ability to create an arbitrary nodes the developer 
want without forcing to stick with a particular package. I think this is better 
fits the system positioned as framework.

IMO the second approach is not so bad too, but quick googling shows that we not 
the only one who creates it's own nodes. Here are guys from 
[twilio|https://github.com/twilio/calcite-kudu/tree/main/adapter/src/main/java/org/apache/calcite/sql],
 for example

> Change the visibility for SqlNode constructor
> ---------------------------------------------
>
>                 Key: CALCITE-4580
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4580
>             Project: Calcite
>          Issue Type: Task
>            Reporter: Konstantin Orlov
>            Priority: Minor
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Currently the constructor is package private. That forces developers 
> extending the parser to put all custom nodes under {{org.apache.calcite.sql}} 
> package (or at least create one abstract node {{MySqlNode}} extending 
> {{SqlNode}} and exposing the constructor). It would nice to have the 
> constructor exposed by {{SqlNode}} itself.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to