parkma99 commented on issue #7152:
URL: 
https://github.com/apache/arrow-datafusion/issues/7152#issuecomment-1658753941

   Hello, [sqlparser-rs](https://github.com/sqlparser-rs/sqlparser-rs) supports 
second version syntax, but `datafusion` failed to support. I am so confusing so 
I take a lot  time to find the reason. Below is I found:
   
   In sqlparser-rs, the first version `primary key(sn)` is parsed in 
https://github.com/sqlparser-rs/sqlparser-rs/blob/10a6ec56371e32f5fa145074e797f8ec74f6d812/src/parser.rs#L3457,
 `primary key(sn)` parsed as `constraints` as a part of `CreateTable 
Statement`. 
   
   Then in `datafusion`, `constraints` will passed in 
https://github.com/apache/arrow-datafusion/blob/e02ed51b880d09f2156bd192d283aef75cab04b7/datafusion/sql/src/statement.rs#L125,
 then in 
https://github.com/apache/arrow-datafusion/blob/e02ed51b880d09f2156bd192d283aef75cab04b7/datafusion/sql/src/statement.rs#L166
 or 
https://github.com/apache/arrow-datafusion/blob/e02ed51b880d09f2156bd192d283aef75cab04b7/datafusion/sql/src/statement.rs#L189
 `constraints` passed in `LogicalPlan`.
   
   The second version `sn INT primary key` is parsed in 
https://github.com/sqlparser-rs/sqlparser-rs/blob/10a6ec56371e32f5fa145074e797f8ec74f6d812/src/parser.rs#L3657C29-L3657C29
 as a part of `ColumnDef` as a part of `columns` in `CreateTable Statement`. 
   
   Then in `datafusion`, `columns` passed in 
https://github.com/apache/arrow-datafusion/blob/e02ed51b880d09f2156bd192d283aef75cab04b7/datafusion/sql/src/planner.rs#L206-L223
 . In there, the `ColumnDef` option only used `NotNull`, others option is 
discareded. The `primary key` does not pass into `LogicalPlan`.
   
   Find the reason is soooo happy.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to