Repository navigation
[Cherry-pick to branch-1.3] [#13973][#13974] fix(catalog-jdbc): Escape column default literals and table properties (#13975) - #14104
Merged
Conversation
…d table properties (#13975) ### What changes were proposed in this pull request? Column default literals (#13973): - `JdbcColumnDefaultValueConverter`: escape string, date and time default literals through a new overridable `quoteStringLiteral` (backslash escapes plus doubled apostrophes). Numeric defaults must parse as a number, or the request fails with `Invalid numeric column default value`. - PostgreSQL and Hologres: override `quoteStringLiteral` to double apostrophes only, and turn `''` back into `'` when parsing a default read from the database. - Doris CREATE TABLE: render string defaults in the form the Doris version stores correctly. 2.1 and later keep the literal text and parse it again as a double-quoted literal, so the value is double-quoted with backslash escapes. 1.2 decodes the literal at CREATE TABLE, so it keeps the single-quoted form. The version is looked up only when a string default contains `'`, `"` or `\`. Table properties (#13974): - Doris: escape property keys and values in ALTER TABLE `SetProperty`, as CREATE TABLE already does. - StarRocks: escape property keys and values on CREATE TABLE, CREATE DATABASE and ALTER TABLE `SetProperty`. Unescape properties parsed from `SHOW CREATE TABLE`, as Doris does. ### Why are the changes needed? Column defaults and table properties went into the generated DDL unescaped. A value containing a quote produced invalid DDL, and a value carrying quotes and SQL text changed the statement. On StarRocks the property key is affected too: any key with the `dynamic_partition.` or `binlog.` prefix passes the alterable-property check. Fix: #13973 Fix: #13974 ### Does this PR introduce _any_ user-facing change? Yes. String defaults and property values with quotes or backslashes are now stored as given. A non-numeric value for a numeric column default is rejected instead of being written into the DDL. ### How was this patch tested? - Unit tests for the common, PostgreSQL, Hologres and Doris default converters, Doris CREATE TABLE SQL generation, Doris and StarRocks `SetProperty` SQL generation, and StarRocks `generatePropertiesSql` / `extractPropertiesFromSql`. - New Docker cases that create a table, add a column and update a default with values such as `O'Brien`, `a""b`, `\path` and a trailing backslash, then check the loaded default (and, for Doris, the stored row): | Class | Result | |---|---| | `TestMysqlTableOperations` | 18 passed | | `TestPostgreSqlTableOperations` | 12 passed | | `TestOceanBaseTableOperations` | 19 passed | | `TestDorisTableOperations` (1.2) | 13 passed | | `CatalogDoris2xIT` (2.1.0, `-PdorisMultiVersionTest`) | 6 passed | The double-quoted Doris form was also checked on 3.0.6.2 and 4.0.6 (`CatalogDoris3xIT` / `CatalogDoris4xIT` passed) before the 1.2 path was made version-aware. `TestStarRocksTableOperations`, the version-aware rerun on 3.0 and 4.0, and the Docker ITs for the property changes were not run locally. --------- Co-authored-by: yuqi1129 <yuqi4733@protonmail.com> # Conflicts: # catalogs/catalog-jdbc-doris/src/main/java/org/apache/gravitino/catalog/doris/converter/DorisColumnDefaultValueConverter.java # catalogs/catalog-jdbc-doris/src/main/java/org/apache/gravitino/catalog/doris/operation/DorisTableOperations.java # catalogs/catalog-jdbc-doris/src/test/java/org/apache/gravitino/catalog/doris/converter/TestDorisColumnDefaultValueConverter.java # catalogs/catalog-jdbc-doris/src/test/java/org/apache/gravitino/catalog/doris/operation/TestDorisTableOperationsSqlGeneration.java
Author
Code Coverage Report
Files
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick Information:
branch-1.3Resolved the committed conflict markers in the four Doris files and adapted the required default-value serialization helpers and test fixtures to branch-1.3. Existing branch-specific nested-column exception behavior is preserved.
Validation: Spotless and 490 non-Docker unit tests passed across JDBC common, Doris, MySQL, PostgreSQL, StarRocks, Hologres, and OceanBase. No conflict markers remain, and
git diff --checkpasses. Live database integration tests were not run locally because Docker is unavailable; CI validation remains pending.