yuqi1129 opened a new pull request, #14764:
URL: https://github.com/apache/gravitino/pull/14764

   ### What changes were proposed in this pull request?
   
   - Add `JdbcConnectorUtils.quoteIdentifier`, which doubles embedded 
delimiters, and use it for identifiers in `JdbcTableOperations` and the MySQL, 
Doris and StarRocks table operations: DROP, RENAME, index columns, `AFTER` 
siblings, and column rename/drop/modify.
   - Quote table and partition names in Doris and StarRocks partition 
statements (`SHOW PARTITIONS`, `ADD`/`DROP PARTITION`) and escape the partition 
name literal in `WHERE PartitionName = "..."`.
   - MySQL, Doris and StarRocks opt into `specificationOnExistingName` for 
`TABLE` and `COLUMN` (`JdbcConnectorUtils.existingQuotedTableName` / 
`existingQuotedColumnName`): an existing name must be non-empty, contain no NUL 
and not be the metadata wildcard `*`; table names also cannot contain a dot, 
because a metadata object name cannot represent it. New names and schema names 
keep their creation rules.
   - `CapabilityHelpers`, on top of the existing-name support for column 
references:
     1. the `AFTER` sibling of a top-level `AddColumn` is validated with 
existing-name rules and case-normalized, like the `AFTER` sibling of 
`UpdateColumnPosition`;
     2. the first component of a nested `AddColumn` is validated as an existing 
parent column instead of a new name;
     3. nested `AFTER` siblings (`AddColumn` and `UpdateColumnPosition`) are no 
longer validated or normalized as top-level names; they follow the connector's 
own field rules.
   
   ### Why are the changes needed?
   
   A table, column or partition that already exists in the database with a 
delimiter in its name produced malformed SQL, and the name could end the 
identifier early.
   
   Fixes #14762
   
   ### Does this PR introduce _any_ user-facing change?
   
   - MySQL, Doris and StarRocks can drop, rename and alter existing native 
tables and columns whose names contain delimiters or other characters outside 
the creation rules.
   - For every catalog, including those that do not opt in: a top-level 
`AddColumn ... AFTER x` now validates `x` (with creation rules unless the 
catalog opts in) and case-normalizes it. Inputs that used to reach the 
connector, such as an `AFTER` column with a space or non-ASCII characters on a 
catalog using the default rules, are now rejected; on case-insensitive catalogs 
`x` is folded.
   - Nested `AFTER` siblings are no longer rejected or case-folded by top-level 
rules.
   - `JdbcTableOperations#quoteIdentifier` now doubles backticks; ClickHouse 
and OceanBase inherit it (OceanBase is MySQL-compatible; ClickHouse backslash 
escaping is unchanged from before).
   - Known limits, not changed here: schema-level SQL is not covered; StarRocks 
reads partition columns by stripping backticks and splitting on commas, so a 
partition column whose name contains a backtick or comma does not round-trip.
   
   ### How was this patch tested?
   
   - DDL-string tests in `*NativeIdentifiers` for MySQL, Doris, StarRocks and 
PostgreSQL with hostile names covering `AFTER` (add and position change), 
rename, drop, modify, type change, index columns, and Doris/StarRocks partition 
statements.
   - Dispatcher-level tests in `TestTableNormalizeDispatcher`, including opt-in 
vs default rules and nested siblings; reverting either `AFTER` change makes 
tests fail.
   - Unit suites: core `TestTableNormalizeDispatcher`/`TestCapability` (29), 
`catalog-jdbc-common` (172), MySQL (100), Doris (167), StarRocks (89), 
PostgreSQL (202).
   - Docker lifecycle tests 
`TestMysqlTableOperations#testNativeQuotedTableAndColumnLifecycle` and the 
PostgreSQL equivalent passed locally; Doris/StarRocks ITs were not run.
   


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