eldenmoon opened a new pull request, #68194: URL: https://github.com/apache/doris/pull/68194
### What problem does this PR solve? Issue Number: None Related PR: None Problem Summary: A comment on a VARIANT predefined field is printed without SQL-literal escaping, so the output of SHOW CREATE TABLE cannot be replayed when the comment contains a quote: ```sql CREATE TABLE t (id INT, v VARIANT<'price':INT COMMENT "O'Reilly">) ...; SHOW CREATE TABLE t; -- v variant<'price':int COMMENT 'O'Reilly', ...> -- replaying it fails: no viable alternative at input 'variant<'price':int COMMENT 'O'Reilly' ``` Root cause: both `catalog.VariantField.toSql` (used by SHOW CREATE TABLE through `Column.toSql`) and `nereids.types.VariantField.toSql` wrap the raw comment in single quotes. The parser side was also inconsistent with the rest of the grammar: `visitVariantSubColType` only strips the outer quotes and unescapes backslashes, so a doubled quote such as `'O''Reilly'` is stored as `O''Reilly`. Fix, following how STRUCT field comments are already handled: - print the comment with `SqlUtils.quoteStringLiteral` / `SqlLiteralUtils.quoteStringLiteral`; - parse it with `SqlLiteralUtils.parseStringLiteral`, like `visitComplexColType` does. After the fix the comment above is printed as `COMMENT "O'Reilly"`, and quotes, doubled quotes and backslashes survive a SHOW CREATE TABLE → CREATE TABLE round trip. ### Release note Fix SHOW CREATE TABLE output that could not be replayed when a VARIANT predefined field comment contains quotes or backslashes. ### Check List (For Author) - Test: Regression test (variant_p0/predefine/test_variant_predefine_comment_escape) / Unit Test (TypeTest#testVariantFieldCommentToSqlRoundTrip) - Behavior changed: Yes. SHOW CREATE TABLE prints predefined field comments as double-quoted, escaped literals; a doubled quote inside a comment is now stored as a single quote, like column and STRUCT field comments. - Does this need documentation: No 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
