Skip to content

[Cherry-pick to branch-1.3] [#12736] fix(doris): validate ADD INDEX fields (#12737) - #12762

Merged
yuqi1129 merged 1 commit into
apache:branch-1.3from
jiangxt2:fix/doris-add-index-field-validation-branch-1.3
Sep 3, 2026
Merged

[Cherry-pick to branch-1.3] [#12736] fix(doris): validate ADD INDEX fields (#12737)#12762
yuqi1129 merged 1 commit into
apache:branch-1.3from
jiangxt2:fix/doris-add-index-field-validation-branch-1.3

Conversation

@jiangxt2

@jiangxt2 jiangxt2 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Cherry-pick Information:

What changes were proposed in this pull request?

This pull request manually backports #12737 to branch-1.3. It preserves the shared Doris CREATE/ALTER index field-shape validation and its focused unit and Doris 4.x integration coverage.

Why are the changes needed?

The automated cherry-pick PR #12753 contains unresolved conflict markers in CatalogDoris4xIT and cannot be updated from the contributor's fork. This PR resolves that conflict while preserving the original fix.

Fix: #12736

Does this PR introduce any user-facing change?

Yes. Doris CREATE TABLE and ALTER TABLE ADD INDEX requests containing multiple fields, nested field paths, empty field shapes, or blank field names now fail with an explicit IllegalArgumentException instead of being truncated or producing invalid SQL. Valid single-field index operations are unchanged, and 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 --tests 'org.apache.gravitino.catalog.doris.operation.TestDorisTableOperationsSqlGeneration' -PskipITs
  • ./gradlew :catalogs:catalog-jdbc-doris:test --tests 'org.apache.gravitino.catalog.doris.integration.test.CatalogDoris4xIT.testAddAndDropInvertedIndex' -PskipDockerTests=false -PdorisMultiVersionTest (1 test, 0 skipped, 0 failures, 0 errors)
  • ./gradlew :catalogs:catalog-jdbc-doris:build -x test

### What changes were proposed in this pull request?

This pull request adds a Doris-specific field-shape validator shared by
CREATE TABLE index generation and ALTER TABLE ADD INDEX. The validator
requires exactly one non-blank top-level field and returns that
validated field for SQL generation.

It also adds focused tests for valid index SQL, malformed field shapes,
consistent CREATE and ALTER validation, the no-JDBC-statement failure
path, and the real Doris 4.x ADD/DROP INDEX lifecycle.

### Why are the changes needed?

The Doris ALTER ADD INDEX path currently reads only
`getFieldNames()[0][0]`. When a request contains multiple fields or a
nested field path, Gravitino silently discards the remaining components
and can create a valid single-column Doris index that does not match the
request.

Rejecting unsupported field shapes before DDL generation prevents this
semantic truncation and makes CREATE and ALTER enforce the same Doris
connector contract. Valid single-field index SQL and existing key-model
behavior remain unchanged.

Fix: apache#12736

### Does this PR introduce _any_ user-facing change?

Yes. Doris CREATE TABLE and ALTER TABLE ADD INDEX requests containing
multiple fields, nested field paths, empty field shapes, or blank field
names now fail with an explicit `IllegalArgumentException` instead of
being truncated or producing invalid SQL. Valid single-field index
operations are unchanged, and 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.CatalogDoris4xIT.testAddAndDropInvertedIndex'
-PskipDockerTests=false -PdorisMultiVersionTest`
- `./gradlew :catalogs:catalog-jdbc-doris:build -x test`

Signed-off-by: jiangxt2 <jiangxt2@vip.qq.com>
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Code Coverage Report

Overall Project 68.05% +0.46% 🟢
Files changed 78.28% 🟢

Module Coverage
aliyun 1.72% 🔴
api 47.7% 🟢
authorization-common 85.96% 🟢
aws 42.04% 🟢
azure 2.47% 🔴
catalog-common 10.4% 🔴
catalog-fileset 80.23% 🟢
catalog-glue 68.95% 🟢
catalog-hive 79.42% 🟢
catalog-jdbc-clickhouse 81.78% +4.42% 🟢
catalog-jdbc-common 45.48% 🟢
catalog-jdbc-doris 82.61% +2.38% 🟢
catalog-jdbc-hologres 54.03% 🟢
catalog-jdbc-mysql 79.33% 🟢
catalog-jdbc-oceanbase 78.6% 🟢
catalog-jdbc-postgresql 83.39% 🟢
catalog-jdbc-starrocks 79.16% 🟢
catalog-kafka 77.01% 🟢
catalog-lakehouse-generic 59.18% 🟢
catalog-lakehouse-hudi 79.1% 🟢
catalog-lakehouse-iceberg 85.86% 🟢
catalog-lakehouse-paimon 82.14% 🟢
catalog-model 77.72% 🟢
cli 44.51% 🟢
client-java 78.16% 🟢
common 50.75% +0.06% 🟢
core 83.0% 🟢
filesystem-hadoop3 77.3% 🟢
flink 0.0% 🔴
flink-common 47.12% -9.45% 🟢
flink-runtime 0.0% 🔴
gcp 14.12% 🔴
hadoop-common 10.88% 🔴
hive-metastore-common 53.77% 🟢
iceberg-aliyun-bundle 0.0% 🔴
iceberg-common 58.15% 🟢
iceberg-rest-server 73.95% 🟢
idp-basic 86.02% 🟢
integration-test-common 0.0% 🔴
jobs 66.17% 🟢
lance-common 24.42% 🔴
lance-rest-server 60.13% 🟢
lineage 53.02% 🟢
optimizer 82.87% 🟢
optimizer-api 21.95% 🔴
server 86.46% +6.96% 🟢
server-common 76.09% -1.22% 🟢
spark 28.57% 🔴
spark-common 41.66% 🟢
trino-connector 47.35% +2.12% 🟢
Files
Module File Coverage
catalog-jdbc-clickhouse ClickHouseClusterUtils.java 100.0% 🟢
ClickHouseTableOperations.java 84.3% 🟢
catalog-jdbc-doris DorisTableOperations.java 84.91% 🟢
common AuthMeResponse.java 81.82% 🟢
flink-common BaseCatalog.java 39.71% 🔴
GravitinoHiveCatalog.java 0.0% 🔴
server CatalogOperations.java 100.0% 🟢
FunctionOperations.java 100.0% 🟢
ModelOperations.java 100.0% 🟢
OwnerOperations.java 100.0% 🟢
SchemaOperations.java 100.0% 🟢
TagOperations.java 100.0% 🟢
ViewOperations.java 100.0% 🟢
PolicyOperations.java 97.35% 🟢
TableOperations.java 97.22% 🟢
TopicOperations.java 97.18% 🟢
JobOperations.java 93.67% 🟢
ConfigServlet.java 88.89% 🟢
FilesetOperations.java 85.58% 🟢
MetalakeOperations.java 79.01% 🟢
AuthnOperations.java 60.0% 🟢
server-common MetadataAuthzHelper.java 55.26% 🔴
trino-connector GravitinoConfig.java 85.71% 🟢
GravitinoConnectorFactory.java 67.74% 🟢

@yuqi1129
yuqi1129 merged commit 803191d into apache:branch-1.3 Sep 3, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants