diqiu50 opened a new issue, #14073:
URL: https://github.com/apache/gravitino/issues/14073

   ### Version
   
   main branch
   
   ### Describe what's wrong
   
   When updating a column position, the reference column in `AFTER <column>` is 
written without backticks:
   
   - MySQL: both the explicit `AFTER x` branch and the null-position branch 
(after the last column).
   - Doris and StarRocks: the null-position branch (after the last column).
   
   Column names with special characters such as `-` (allowed by MySQL) or 
reserved words such as `key` produce invalid SQL.
   
   ### Error message and/or stacktrace
   
   MySQL:
   ```
   java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; ... 
near 'order-id' at line 2
   ```
   
   Doris/StarRocks:
   ```
   java.sql.SQLSyntaxErrorException: Getting syntax error at line 2, column 60. 
Detail message: Unexpected input 'key', the most similar input is {a legal 
identifier}.
   ```
   
   ### How to reproduce
   
   MySQL:
   1. Create a table with columns `id`, `status`, `order-id`.
   2. Move `status` with `TableChange.updateColumnPosition(new String[] 
{"status"}, ColumnPosition.after("order-id"))`.
   3. The alter fails with the SQL syntax error above.
   
   Doris/StarRocks:
   1. Create a table whose last column is `key`.
   2. Call the table operations' `alterTable` with 
`TableChange.updateColumnPosition(new String[] {"status"}, null)`.
   3. The alter fails with the SQL syntax error above.
   
   ### Additional context
   
   The add-column paths in the same classes already quote the reference column.
   


-- 
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