osipovartem opened a new issue, #14340: URL: https://github.com/apache/datafusion/issues/14340
### Describe the bug Query ```sql create table test (COLUMN_NAME TEXT NOT NULL, constraint COLUMN_NAME_PK primary key (COLUMN_NAME)) ``` triggers the error ```Column for primary key not found in schema: COLUMN_NAME``` When creating a table, we build a schema and apply [normalization](https://github.com/apache/datafusion/blob/main/datafusion/sql/src/planner.rs#L260) to column names with to_ascii_lowercase call, which is enabled by default. But during constraint check we don't do this for the [constraint column name](https://github.com/apache/datafusion/blob/main/datafusion/sql/src/statement.rs#L1459). ### To Reproduce _No response_ ### Expected behavior The query should work without errors ```sql create table test (COLUMN_NAME TEXT NOT NULL, constraint COLUMN_NAME_PK primary key (COLUMN_NAME)) ``` ### Additional context Suggestion to use just [to_lowercase](https://github.com/apache/datafusion/blob/main/datafusion/sql/src/statement.rs#L1459) (since we don't pass column names with ascii symbols) ```rust .position(|item| *item.to_lowercase() == pk.value.to_lowercase()) ``` -- 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: github-unsubscr...@datafusion.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org