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

   ### What changes were proposed in this pull request?
   
   This pull request makes the JDBC Doris catalog include 
`TableChange.AddColumn.getDefaultValue()` when generating `ALTER TABLE ... ADD 
COLUMN` SQL. It adds an ADD-only Doris default serializer so CREATE TABLE and 
MODIFY COLUMN continue using their existing write-serialization paths.
   
   The serializer preserves unset, explicit null, numeric, string, and 
`CURRENT_TIMESTAMP` semantics. For string defaults containing backslashes, it 
performs one Doris version lookup per ALTER request and applies the additional 
escape layer required by Doris 3.x while retaining the existing form on Doris 
1.2.x and 4.x. The read path normalizes the escaped string forms returned by 
Doris JDBC metadata.
   
   The patch also adds focused SQL-generation and converter tests plus 
end-to-end ADD COLUMN, metadata round-trip, and omitted-column INSERT coverage 
for the repository's Doris 1.2.x test image (Doris 1.2.7.1), Doris 3.0.6.2, and 
Doris 4.0.6.
   
   ### Why are the changes needed?
   
   The Doris catalog accepts a default value through the public AddColumn API 
but currently omits it from the generated column definition. A nullable column 
can therefore be added while silently losing its requested default, and Doris 
may reject a non-nullable column because the generated ADD COLUMN statement has 
no default.
   
   Doris versions also parse backslashes in ALTER ADD COLUMN defaults 
differently. Keeping this compatibility handling in an ADD-specific write path 
preserves the requested default without changing CREATE TABLE or unrelated 
MODIFY COLUMN write serialization. This patch separately normalizes the escaped 
string-default forms returned by Doris JDBC metadata during `loadTable()`.
   
   Fix: #12764
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. Doris ADD COLUMN operations now preserve supported literal defaults and 
`CURRENT_TIMESTAMP`; explicit `DEFAULT NULL` remains distinct from an unset 
default at SQL generation time. For a literal default containing a backslash, 
the connector executes `SHOW FRONTENDS` once per ALTER request to select the 
Doris-compatible escaping; the operation fails with an explicit error if the 
connection user cannot run that statement. Defaults without a backslash do not 
trigger this version lookup. No public API or property key is added or removed.
   
   ### How was this patch tested?
   
   - `./gradlew :catalogs:catalog-jdbc-doris:spotlessCheck`
   - `./gradlew rat`
   - `./gradlew :catalogs:catalog-jdbc-doris:test -PskipITs`
   - `./gradlew :catalogs:catalog-jdbc-doris:test --tests 
'org.apache.gravitino.catalog.doris.integration.test.CatalogDorisIT.testAddColumnPreservesDefaultValue'
 -PskipDockerTests=false -PdorisMultiVersionTest`
   - `./gradlew :catalogs:catalog-jdbc-doris:test --tests 
'org.apache.gravitino.catalog.doris.integration.test.CatalogDoris3xIT.testAddColumnPreservesDefaultValue'
 -PskipDockerTests=false -PdorisMultiVersionTest`
   - `./gradlew :catalogs:catalog-jdbc-doris:test --tests 
'org.apache.gravitino.catalog.doris.integration.test.CatalogDoris4xIT.testAddColumnPreservesDefaultValue'
 -PskipDockerTests=false -PdorisMultiVersionTest`
   - `./gradlew :catalogs:catalog-jdbc-doris:build -x test`
   
   All listed commands passed.
   


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