[#10381][#10378] fix(clickhouse-catalog): Fix ClickHouse alter-table bugs#10383
[#10381][#10378] fix(clickhouse-catalog): Fix ClickHouse alter-table bugs#10383yuqi1129 merged 20 commits intoapache:mainfrom
Conversation
…0381) Add integration tests in CatalogClickHouseIT and CatalogClickHouseClusterIT to cover generateAlterTableSql branches, including supported alter operations and unsupported/edge branches for property, index, and column changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds additional ClickHouse JDBC integration tests to exercise more ALTER TABLE branches (including index deletion, missing column/index handling, and unsupported change types) in both single-node and cluster ClickHouse environments, helping prevent regressions discussed in #10381 and #10378.
Changes:
- Add a new single-node integration test covering alter-table edge/unsupported branches and index deletion.
- Add a new cluster integration test covering alter-table branches including add column, position/type/comment/default/nullability updates, and index deletion.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| catalogs-contrib/catalog-jdbc-clickhouse/src/test/java/org/apache/gravitino/catalog/clickhouse/integration/test/CatalogClickHouseIT.java | Adds a new integration test to cover additional alter-table branches (incl. missing column/index behavior and unsupported operations). |
| catalogs-contrib/catalog-jdbc-clickhouse/src/test/java/org/apache/gravitino/catalog/clickhouse/integration/test/CatalogClickHouseClusterIT.java | Adds a new cluster integration test to exercise alter-table branches on clustered ClickHouse tables. |
Add integration cases for unsupported addIndex branch, both updateColumnAutoIncrement(true/false) unsupported branches, and multi-index drop validation for minmax and bloom filter indexes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Implement AddIndex handling in ClickHouseTableOperations#generateAlterTableSql for DATA_SKIPPING_MINMAX and DATA_SKIPPING_BLOOM_FILTER, with validation for duplicate/invalid index definitions and explicit unsupported behavior for PRIMARY_KEY alter-add. Update unit and integration tests to validate real behavior for add/drop index and autoIncrement branches. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Verified against real ClickHouse integration tests: ADD INDEX and DROP INDEX for data skipping indexes are supported and now implemented in generateAlterTableSql for DATA_SKIPPING_MINMAX and DATA_SKIPPING_BLOOM_FILTER. ADD INDEX PRIMARY_KEY via ALTER is not supported and stays explicit unsupported behavior. updateColumnAutoIncrement true/false is unsupported in tested ClickHouse 24.8 and tests now assert this behavior. Also updated unit and integration coverage to match runtime behavior. |
Code Coverage Report
Files
|
Add explicit assertions for column ordering after updateColumnPosition and for col_1 default value after updateColumnDefaultValue in CatalogClickHouseClusterIT. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Validate create-table columns in ClickHouse and fail fast when any column is marked autoIncrement. Add unit and integration tests to lock behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Handle multiline ORDER BY/PARTITION BY clauses when parsing SHOW CREATE TABLE, so loadTable keeps sort orders configured at create time. Add unit parsing test and cluster integration assertions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
You can also share your feedback on Copilot code review. Take the survey.
|
@diqiu50 |
| JdbcConnectorUtils.executeUpdate(connection, generateDropDatabaseSql(databaseName, cascade)); | ||
| if (!cascade) { | ||
| try (Statement stmt = connection.createStatement(); | ||
| ResultSet rs = stmt.executeQuery(String.format("SHOW TABLES IN `%s`", databaseName))) { |
There was a problem hiding this comment.
You'd better use the system table to check table exists in db
There was a problem hiding this comment.
What's the side effect of using SHOW TABLES IN?
There was a problem hiding this comment.
May be the table is just not in this host, if you don't want handle this case, add some comments
There was a problem hiding this comment.
Querying system table does not handle this case too. you'd better Add some comments
| JdbcConnectorUtils.executeUpdate(connection, generateDropDatabaseSql(databaseName, cascade)); | ||
| if (!cascade) { | ||
| try (Statement stmt = connection.createStatement(); | ||
| ResultSet rs = stmt.executeQuery(String.format("SHOW TABLES IN `%s`", databaseName))) { |
There was a problem hiding this comment.
May be the table is just not in this host, if you don't want handle this case, add some comments
| * ENGINE = MergeTree() | ||
| * ORDER BY `id` | ||
| * COMMENT 'order records\n[Gravitino] ch.cluster=ck_cluster' | ||
| * |
There was a problem hiding this comment.
Mark "\n[Gravitino] ch.cluster=ck_cluster" will always at the end of the comment, what do you mean here?
There was a problem hiding this comment.
if the user add some comments after \n[Gravitino] ch.cluster=ck_cluster, is it a problem?
There was a problem hiding this comment.
Do you mean users will update the comment without using Gravitino and add something at the end of \n[Gravitino] ch.cluster=ck_cluster?
We can't avoid such a problem as long as users can update comments without notifying Gravitino.
There was a problem hiding this comment.
So we usually add an end delimiter to avoid things getting mixed together.
| JdbcConnectorUtils.executeUpdate(connection, generateDropDatabaseSql(databaseName, cascade)); | ||
| if (!cascade) { | ||
| try (Statement stmt = connection.createStatement(); | ||
| ResultSet rs = stmt.executeQuery(String.format("SHOW TABLES IN `%s`", databaseName))) { |
There was a problem hiding this comment.
Querying system table does not handle this case too. you'd better Add some comments
…bugs (#10383) ### What changes were proposed in this pull request? Add comprehensive integration coverage for ClickHouse alter-table behavior in: - `CatalogClickHouseIT` - `CatalogClickHouseClusterIT` The new tests exercise `ClickHouseTableOperations#generateAlterTableSql` branches in real ClickHouse environments, including: - supported alter branches: add/update type/update default/update comment/update position/update nullability/delete index/delete column - edge/no-op branches: delete missing column/index with `ifExists=true` - unsupported branches: set/remove property, update auto increment, nested column add Tests also verify resulting table metadata (column type/comment/nullability/index removal) after alter operations. ### Why are the changes needed? To prevent regressions in ClickHouse ALTER TABLE SQL generation and close branch-level test gaps for issues discussed in #10381 and #10378. Fixed: #10381 Fixed: #10372 Fixed: #10396 Fixed: #10405 ### Does this PR introduce _any_ user-facing change? N/A Closes #10381 Closes #10378 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…alter-table bugs (apache#10383) ### What changes were proposed in this pull request? Add comprehensive integration coverage for ClickHouse alter-table behavior in: - `CatalogClickHouseIT` - `CatalogClickHouseClusterIT` The new tests exercise `ClickHouseTableOperations#generateAlterTableSql` branches in real ClickHouse environments, including: - supported alter branches: add/update type/update default/update comment/update position/update nullability/delete index/delete column - edge/no-op branches: delete missing column/index with `ifExists=true` - unsupported branches: set/remove property, update auto increment, nested column add Tests also verify resulting table metadata (column type/comment/nullability/index removal) after alter operations. ### Why are the changes needed? To prevent regressions in ClickHouse ALTER TABLE SQL generation and close branch-level test gaps for issues discussed in apache#10381 and apache#10378. Fixed: apache#10381 Fixed: apache#10372 Fixed: apache#10396 Fixed: apache#10405 ### Does this PR introduce _any_ user-facing change? N/A Closes apache#10381 Closes apache#10378 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…alter-table bugs (apache#10383) ### What changes were proposed in this pull request? Add comprehensive integration coverage for ClickHouse alter-table behavior in: - `CatalogClickHouseIT` - `CatalogClickHouseClusterIT` The new tests exercise `ClickHouseTableOperations#generateAlterTableSql` branches in real ClickHouse environments, including: - supported alter branches: add/update type/update default/update comment/update position/update nullability/delete index/delete column - edge/no-op branches: delete missing column/index with `ifExists=true` - unsupported branches: set/remove property, update auto increment, nested column add Tests also verify resulting table metadata (column type/comment/nullability/index removal) after alter operations. ### Why are the changes needed? To prevent regressions in ClickHouse ALTER TABLE SQL generation and close branch-level test gaps for issues discussed in apache#10381 and apache#10378. Fixed: apache#10381 Fixed: apache#10372 Fixed: apache#10396 Fixed: apache#10405 ### Does this PR introduce _any_ user-facing change? N/A Closes apache#10381 Closes apache#10378 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
What changes were proposed in this pull request?
Add comprehensive integration coverage for ClickHouse alter-table behavior in:
CatalogClickHouseITCatalogClickHouseClusterITThe new tests exercise
ClickHouseTableOperations#generateAlterTableSqlbranches in real ClickHouse environments, including:ifExists=trueTests also verify resulting table metadata (column type/comment/nullability/index removal) after alter operations.
Why are the changes needed?
To prevent regressions in ClickHouse ALTER TABLE SQL generation and close branch-level test gaps for issues discussed in #10381 and #10378.
Fixed: #10381
Fixed: #10372
Fixed: #10396
Fixed: #10405
Does this PR introduce any user-facing change?
N/A
Closes #10381
Closes #10378