Skip to content

[Cherry-pick to branch-1.3] [#13973][#13974] fix(catalog-jdbc): Escape column default literals and table properties (#13975) - #14104

Merged
jerryshao merged 2 commits into
branch-1.3from
cherry-pick-4e900e8f-to-branch-1.3
Oct 22, 2026
Merged

jerryshao merged 2 commits into
branch-1.3from
cherry-pick-4e900e8f-to-branch-1.3

Conversation

@github-actions

@github-actions github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Cherry-pick Information:

  • Original commit: 4e900e8
  • Target branch: branch-1.3
  • Status: Conflicts resolved in c720a3b.

Resolved 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 --check passes. Live database integration tests were not run locally because Docker is unavailable; CI validation remains pending.

…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
@github-actions github-actions Bot added cherry-pick Automatically opened cherry-pick PR cherry-pick-conflict Cherry-pick has conflicts; needs human resolution before merge labels Oct 21, 2026
@github-actions
github-actions Bot requested a review from jerryshao October 21, 2026 21:21
@yuqi1129 yuqi1129 changed the title [DO NOT MERGE] [Cherry-pick to branch-1.3] [#13973][#13974] fix(catalog-jdbc): Escape column default literals and table properties (#13975) [Cherry-pick to branch-1.3] [#13973][#13974] fix(catalog-jdbc): Escape column default literals and table properties (#13975) Oct 21, 2026
@yuqi1129 yuqi1129 removed the cherry-pick-conflict Cherry-pick has conflicts; needs human resolution before merge label Oct 21, 2026
@jerryshao
jerryshao merged commit a42a73f into branch-1.3 Oct 22, 2026
35 checks passed
@jerryshao
jerryshao deleted the cherry-pick-4e900e8f-to-branch-1.3 branch October 22, 2026 03:07
@github-actions

Copy link
Copy Markdown
Author

Code Coverage Report

Overall Project 69.78% +0.45% 🟢
Files changed 87.27% 🟢

Module Coverage
aliyun 19.74% 🔴
api 47.41% 🟢
authorization-common 85.96% 🟢
authorization-ranger 10.17% 🔴
aws 60.78% 🟢
aws-bundle 0.0% 🔴
azure 68.04% 🟢
azure-bundle 0.0% 🔴
catalog-common 19.13% 🔴
catalog-fileset 80.73% 🟢
catalog-glue 71.33% 🟢
catalog-hive 80.55% 🟢
catalog-jdbc-clickhouse 84.7% 🟢
catalog-jdbc-common 54.11% +1.58% 🟢
catalog-jdbc-doris 88.58% +6.26% 🟢
catalog-jdbc-hologres 54.1% +2.95% 🟢
catalog-jdbc-mysql 85.0% 🟢
catalog-jdbc-oceanbase 78.97% 🟢
catalog-jdbc-postgresql 83.82% -2.31% 🟢
catalog-jdbc-starrocks 81.16% +8.04% 🟢
catalog-kafka 75.49% 🟢
catalog-lakehouse-generic 76.11% 🟢
catalog-lakehouse-hudi 79.1% 🟢
catalog-lakehouse-iceberg 85.9% 🟢
catalog-lakehouse-paimon 82.17% 🟢
catalog-model 77.99% 🟢
cli 44.51% 🟢
client-java 78.45% 🟢
client-java-runtime 0.0% 🔴
common 51.51% 🟢
core 83.93% 🟢
filesystem-hadoop3 77.68% 🟢
flink 18.07% 🔴
flink-common 50.97% 🟢
flink-runtime 0.0% 🔴
gcp 32.2% 🔴
hadoop-common 15.43% 🔴
hive-metastore-common 62.61% 🟢
hive-metastore3-libs 58.8% 🟢
iceberg-aliyun-bundle 0.0% 🔴
iceberg-common 60.96% 🟢
iceberg-rest-server 76.51% 🟢
idp-basic 86.99% 🟢
integration-test-common 0.0% 🔴
jobs 60.37% 🟢
lance-common 35.51% 🔴
lance-rest-server 79.88% 🟢
lineage 59.39% 🟢
optimizer 82.85% 🟢
optimizer-api 42.56% 🟢
server 89.66% 🟢
server-common 79.3% 🟢
spark 28.57% 🔴
spark-common 51.29% +1.39% 🟢
trino-connector 62.84% 🟢
Files
Module File Coverage
catalog-jdbc-common JdbcColumnDefaultValueConverter.java 95.45% 🟢
catalog-jdbc-doris DorisUtils.java 95.76% 🟢
DorisTableOperations.java 92.66% 🟢
DorisColumnDefaultValueConverter.java 79.78% 🟢
DorisDatabaseOperations.java 77.78% 🟢
catalog-jdbc-hologres HologresColumnDefaultValueConverter.java 100.0% 🟢
catalog-jdbc-postgresql PostgreSqlColumnDefaultValueConverter.java 45.45% 🔴
catalog-jdbc-starrocks StarRocksUtils.java 87.3% 🟢
StarRocksTableOperations.java 84.52% 🟢
core JobManager.java 90.92% 🟢
BaseCatalog.java 63.08% 🟢
spark-common IcebergRestOAuthConfig.java 98.31% 🟢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick Automatically opened cherry-pick PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants