Skip to content

Add 2 tests for coverage gaps in PR #121332 - #124384

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr121332
Oct 18, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr121332

Conversation

@clickgapai

@clickgapai clickgapai commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Test-only PR. Review: are the gaps real, is the test right.

Adds test coverage for 2 untested code paths, found during automated review of PR #121332.
That PR: (1) Replaces raw dynamic_cast/typeid_cast of catalog pointers with castStorage<T>(ptr, DeferredTable::Load|Skip) / resolveStorageProxyLoading at ~70 sites, adds tryGetNested overrides, makes Distributed/Buffer/MaterializedPostgreSQL/Merge/Memory eager in lazy_load_tables …

1. ATTACH/REPLACE PARTITION FROM: lazy and non-MergeTree sources untested
src/Storages/MergeTree/MergeTreeData.cpp:9590
Risk: runCommandSegments (InterpreterAlterQuery.cpp:408) -> MergeTreeData::alterPartition -> REPLACE_PARTITION: resolveStorageProxyLoading + castStorage<MergeTreeData>(from_storage, DeferredTable::Load), refusal at MergeTreeData.cpp:9590 when null. Risk: a revert to a raw cast makes every …
Unique vs PR tests: PR tests cover system.parts/system.replicas listings (Skip), SYSTEM SYNC REPLICA and hypothetical indexes (Load). None runs a partition command on a lazily loaded table or with a non-MergeTree FROM source. The cases fit 05233_lazy_load_tables_cast_storage.sql; kept standalone …
Tags: -- Tags: no-replicated-database — no-replicated-database: re-attaches an Atomic database with lazy_load_tables, same as the PR's own 05233/05291

2. joinGet(identifier, ...): lazy Join table and non-Join refusal untested
src/Analyzer/Resolve/resolveFunction.cpp:1539
Risk: QueryAnalyzer::resolveFunction (first argument is an identifier that is not a column) -> IdentifierResolver::tryResolveTableIdentifierFromDatabaseCatalog -> castStorage<StorageJoin>(..., Load), refusal at resolveFunction.cpp:1539; the argument then becomes a constant and getJoin …
Unique vs PR tests: No PR test touches Join/joinGet; the PR's tests cover MergeTree/ReplicatedMergeTree listings, SYSTEM SYNC REPLICA and hypothetical indexes. Could also be appended to 05233_lazy_load_tables_cast_storage.sql (needs ZooKeeper) or 01141_join_get_negative.sql (refusal only).
Tags: -- Tags: no-replicated-database — no-replicated-database: re-attaches an Atomic database with lazy_load_tables, same as the PR's own 05233/05291

cc @evillique (author of #121332), @thevar1able (merged/approved #121332) — could you take a look, and add the can be tested label if this looks good?

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Not applicable — test-only change.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Workflow [PR]
Sync PR [sync-upstream/pr/124384]

Version info

  • Merged into: 26.11.1.139-master (included in 26.11 and later)

@clickgapai

Copy link
Copy Markdown
Contributor Author
Pre-PR validation: 6/6 ✅

a) Deterministic repro? ✅
Test exercises the previously-uncovered branch and passes (correct behaviour).

b) Root cause explained? ✅
src/Storages/MergeTree/MergeTreeData.cpp:9588-9591 (PR head; 9732-9735 in the current checkout): if (!from_storage_merge_tree) throw Exception(ErrorCodes::NOT_IMPLEMENTED, ...). The positive side is reachable only through a re-attached lazy_load_tables database, the refusal only through a non-MergeTree source; no test does either.

c) Fix matches root cause? ✅
N/A for coverage gap — this PR adds a regression test, not a fix. Asserts current correct behaviour at the cited line.

d) Test intent preserved? / New tests added? ✅
New regression test added: 05332_lazy_load_tables_partition_commands.sql.

e) Both directions demonstrated? ✅
Test passes (MATCH) on master proving current correctness; would fail if the cited branch regressed. Single-direction is the correct shape for a coverage gap test.

f) Fix is general, not a narrow patch? ✅
Test asserts the invariant at the cited line — covers the branch, not a specific input shape.

@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 7, 2026
@evillique evillique self-assigned this Oct 7, 2026
@evillique

Copy link
Copy Markdown
Member

@clickgapai Both gaps are real: the tests fail on master before #121332 and pass after it. Two small changes:

  • Remove the final system.tables listing in both tests. It only checks that a refused command loads the table, which is incidental.
  • In 05332, keep one of the two non-MergeTree refusals, since both go through the same code.

@evillique evillique added the can be tested Allows running workflows for external contributors label Oct 7, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [343e3ca]

Summary: ✅


AI Review

Summary

This test-only PR adds two stateless regressions around lazy_load_tables: one exercises partition commands against unloaded MergeTree and non-MergeTree tables, and the other checks joinGet / joinGetOrNull against an unloaded Join table plus the non-Join refusal. I did not find a correctness or coverage issue in the current diff; the tests hit the intended DeferredTable::Load branches, and the reduced assertions match the maintainer feedback already captured in the discussion.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Oct 7, 2026
The final listing only showed that a refused command loads the table.
ATTACH and REPLACE PARTITION FROM parse to the same REPLACE_PARTITION
command, so 05332 keeps only the ATTACH refusal.

Requested by @evillique in ClickHouse#124384 (comment)
@clickgapai

Copy link
Copy Markdown
Contributor Author

Pushed a commit. Here's the actual diff so you can review what was committed:

diff --git a/tests/queries/0_stateless/05332_lazy_load_tables_partition_commands.reference b/tests/queries/0_stateless/05332_lazy_load_tables_partition_commands.reference
index d289641c628d..f3be1d7af8a7 100644
--- a/tests/queries/0_stateless/05332_lazy_load_tables_partition_commands.reference
+++ b/tests/queries/0_stateless/05332_lazy_load_tables_partition_commands.reference
@@ -11,7 +11,3 @@ REPLACE PARTITION FROM a loaded source
 10	45
 a source that is not MergeTree is refused
 10	45
-t_dst	MergeTree
-t_log	Log
-t_moved	MergeTree
-t_src	MergeTree
diff --git a/tests/queries/0_stateless/05332_lazy_load_tables_partition_commands.sql b/tests/queries/0_stateless/05332_lazy_load_tables_partition_commands.sql
index 8fce6f1ae595..8d8c4b081c19 100644
--- a/tests/queries/0_stateless/05332_lazy_load_tables_partition_commands.sql
+++ b/tests/queries/0_stateless/05332_lazy_load_tables_partition_commands.sql
@@ -36,11 +36,8 @@ SELECT count(), sum(n) FROM t_dst;
 
 SELECT 'a source that is not MergeTree is refused';
 ALTER TABLE t_dst ATTACH PARTITION tuple() FROM t_log; -- { serverError NOT_IMPLEMENTED }
-ALTER TABLE t_dst REPLACE PARTITION tuple() FROM t_log; -- { serverError NOT_IMPLEMENTED }
 SELECT count(), sum(n) FROM t_dst;
 
-SELECT name, engine FROM system.tables WHERE database = currentDatabase() ORDER BY name;
-
 DROP TABLE t_src;
 DROP TABLE t_dst;
 DROP TABLE t_moved;
diff --git a/tests/queries/0_stateless/05333_lazy_load_tables_join_get.reference b/tests/queries/0_stateless/05333_lazy_load_tables_join_get.reference
index 14b2904cc527..ff53d1559fba 100644
--- a/tests/queries/0_stateless/05333_lazy_load_tables_join_get.reference
+++ b/tests/queries/0_stateless/05333_lazy_load_tables_join_get.reference
@@ -5,5 +5,3 @@ one
 1	one
 2	two
 3	\N
-t_join	Join
-t_log	Log
diff --git a/tests/queries/0_stateless/05333_lazy_load_tables_join_get.sql b/tests/queries/0_stateless/05333_lazy_load_tables_join_get.sql
index efa2d3d107dc..e286d6a5cb2c 100644
--- a/tests/queries/0_stateless/05333_lazy_load_tables_join_get.sql
+++ b/tests/queries/0_stateless/05333_lazy_load_tables_join_get.sql
@@ -22,8 +22,6 @@ SELECT joinGet(t_join, 'v', toUInt64(1));
 SELECT number, joinGetOrNull(t_join, 'v', number) FROM numbers(4) ORDER BY number;
 SELECT joinGet(t_log, 'v', toUInt64(1)); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
 
-SELECT name, engine FROM system.tables WHERE database = currentDatabase() ORDER BY name;
-
 DROP TABLE t_join;
 DROP TABLE t_log;
 

If this isn't the change you wanted, please describe the edit concretely and I'll retry.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 18, 2026
Merged via the queue into ClickHouse:master with commit 8755c1a Oct 18, 2026
152 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 18, 2026
@clickhouse-gh clickhouse-gh Bot added comp-database-engines Database engine implementations (e.g., Atomic/Replicated) and database-level behavior. and removed comp-testing Test content only (no production code). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-database-engines Database engine implementations (e.g., Atomic/Replicated) and database-level behavior. pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants