[#12764] fix(doris): preserve defaults when adding columns - #12767
Open
jiangxt2 wants to merge 1 commit into
Open
[#12764] fix(doris): preserve defaults when adding columns#12767jiangxt2 wants to merge 1 commit into
jiangxt2 wants to merge 1 commit into
Conversation
Signed-off-by: jiangxt2 <jiangxt2@vip.qq.com>
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.
What changes were proposed in this pull request?
This pull request makes the JDBC Doris catalog include
TableChange.AddColumn.getDefaultValue()when generatingALTER TABLE ... ADD COLUMNSQL. 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_TIMESTAMPsemantics. 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; explicitDEFAULT NULLremains distinct from an unset default at SQL generation time. For a literal default containing a backslash, the connector executesSHOW FRONTENDSonce 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 testAll listed commands passed.