Repository navigation
Add stateless tests for uncovered code paths (llvm coverage smoke test) - #117922
Conversation
12 tests targeting lines with zero hits in the master llvm coverage report, each verified against the instrumented coverage build so that every targeted line is actually executed by the new test: - 05056: MergeTreeMarksLoader streaming marks compression (19/19 lines) - 05059-05061: legacy AST-path optimizers, enable_analyzer=0 (34/34, 30/30, +2 files) - 05062-05064: Analyzer SortNode/Matchers/TableExpressionModifiers - 05065: convertJoinToIn guard conditions (6/6) - 05066-05067: SerializationTime/Interval JSON+CSV formats (24/24, 28/28) - 05068-05069: Dynamic-type distinct + groupArrayInsertAt guards (41/41, 15/15) Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [dd6aca0] Summary: ✅ AI ReviewSummaryThis PR folds a batch of llvm-coverage smoke tests into existing stateless files and slightly widens the extra-baseline search in the differential-coverage job. The direct Findings
Final VerdictLLVM Coverage ReportMeasured on commit dd6aca0.
Changed lines: Uncovered code analysis did not run: No coverable C/C++ source files changed (contrib/ is excluded from coverage). Newly covered: +818 lines in 75 files (-162 lines lost coverage) · Details |
Co-Authored-By: Claude Fable 5 <[email protected]>
|
|
||
| -- b is substituted with a (a is in the primary key → cheaper) | ||
| -- Verify substitution happened: result is correct and the query executes without errors | ||
| SELECT a, b FROM t_subst_legacy WHERE b = 42; |
There was a problem hiding this comment.
This block never makes SubstituteColumnOptimizer observable. Because every inserted row already satisfies a = b, the SELECT, WHERE, PREWHERE, and HAVING queries here all return the same reference whether b gets rewritten to a or the optimizer never runs at all, so the targeted branches can silently lose coverage. Please add an assertion on the rewritten form (EXPLAIN/plan output), or use deliberately inconsistent ASSUME data the way 01622_constraints_simple_optimization.sql does.
| SELECT countIf(explain LIKE '%CreatingSets%') = 0 AS guard_non_hash_algo | ||
| FROM (EXPLAIN description = 0 | ||
| SELECT t1.a FROM (SELECT 1::UInt64 AS a) t1 INNER JOIN (SELECT 1::UInt64 AS a) t2 ON t1.a = t2.a | ||
| SETTINGS join_algorithm = 'partial_merge', serialize_query_plan = 0); | ||
|
|
||
| -- Guard lines 159-160: LEFT SEMI JOIN has strictness=semi (neither Any nor All) -> blocked. | ||
| SELECT countIf(explain LIKE '%CreatingSets%') = 0 AS guard_semi_strictness | ||
| FROM (EXPLAIN description = 0 | ||
| SELECT t1.a FROM (SELECT 1::UInt64 AS a) t1 LEFT SEMI JOIN (SELECT 1::UInt64 AS a) t2 ON t1.a = t2.a | ||
| SETTINGS serialize_query_plan = 0); | ||
|
|
||
| -- Guard lines 163-164: LEFT JOIN has kind=left (not inner) -> blocked. | ||
| SELECT countIf(explain LIKE '%CreatingSets%') = 0 AS guard_left_kind | ||
| FROM (EXPLAIN description = 0 | ||
| SELECT t1.a FROM (SELECT 1::UInt64 AS a) t1 LEFT JOIN (SELECT 1::UInt64 AS a) t2 ON t1.a = t2.a | ||
| SETTINGS serialize_query_plan = 0); | ||
|
|
||
| -- Guard lines 175-176: IS NOT DISTINCT FROM produces NullSafeEquals (op != Equals) -> blocked. | ||
| SELECT countIf(explain LIKE '%CreatingSets%') = 0 AS guard_null_safe_eq | ||
| FROM (EXPLAIN description = 0 | ||
| SELECT t1.a FROM (SELECT 1::UInt64 AS a) t1 INNER JOIN (SELECT 1::UInt64 AS a) t2 ON t1.a IS NOT DISTINCT FROM t2.a | ||
| SETTINGS serialize_query_plan = 0); | ||
|
|
||
| -- Guard lines 190-191: SELECT includes a column from the right-side table -> blocked. | ||
| SELECT countIf(explain LIKE '%CreatingSets%') = 0 AS guard_right_output | ||
| FROM (EXPLAIN description = 0 | ||
| SELECT t1.a, t2.b FROM (SELECT 1::UInt64 AS a) t1 INNER JOIN (SELECT 1::UInt64 AS a, 2::UInt64 AS b) t2 ON t1.a = t2.a |
There was a problem hiding this comment.
countIf(explain LIKE '%CreatingSets%') = 0 only proves that the rewrite did not materialize a CreatingSets step. It does not prove that the guarded Join path stayed in the plan, so a future planner change that removes or rewrites the join earlier would keep all five queries green while these tryConvertJoinToIn early-return branches stop being exercised. 03918_convert_join_to_in_arrayjoin_dangling.sql pins both sides of that contract by checking Join stays and CreatingSets disappears; please add the same positive Join% assertion here for each guard case.
The old-analyzer stateless shards force enable_analyzer=0, which broke 5 tests that relied on the default: - 05062/05063/05064/05065: target analyzer-path code (EXPLAIN QUERY TREE, convertJoinToIn) — pin SET enable_analyzer = 1 explicitly. - 05069: groupArrayInsertAt()(args) with an empty parameter list throws BAD_ARGUMENTS on the old path before the argument type check is reached — drop the empty parens; error codes now identical (43, 128) in both modes. Co-Authored-By: Claude Fable 5 <[email protected]>
|
|
||
| -- Baseline without streaming (must match) | ||
| SYSTEM DROP MARK CACHE; | ||
| SELECT count(), sum(a) FROM wide_adaptive; |
There was a problem hiding this comment.
The three "baseline without streaming" queries here inherit the randomized use_streaming_marks_compression session default. In stateless runs that setting is fuzzed, so these baselines can silently execute the same streaming path as the preceding query and stop checking equivalence against the non-streaming implementation. Please pin the baseline side with SETTINGS use_streaming_marks_compression = 0 (or SET use_streaming_marks_compression = 0 around each baseline block).
Each targets zero-hit lines from the master llvm coverage report and is verified against the instrumented build (all targeted lines executed): - 05076: BSONTypes.cpp error messages for invalid BSON types (25/25) - 05077: system.projection_parts with missing-column parts - 05078: system.unicode notation columns - 05079: aggregate-function parameters as CAST-typed literals (18/18) - 05082: FieldVisitorDump rare Field types (8/8) - 05083: FieldVisitorConvertToNumber error branches, inf/nan guard (14/14) - 05084: gzip FEXTRA/FCOMMENT/FHCRC header extensions in LibdeflateInflatingReadBuffer, shell test crafting binary gzip (22/22) Co-Authored-By: Claude Fable 5 <[email protected]>
On a tests-only PR forced with the ci-coverage label (or a CI-scripts-only PR touching the coverage pipeline), the LLVM Coverage job merged the profiles and generated the full report, but skipped the whole comparison against master: differential report, uncovered code analysis, PR comment, and CI DB row all bailed with no_cpp_changes. The per-changed-line analysis is indeed impossible there, but the global comparison is not: the binary is identical to master, so any difference in hit counts is exactly what the new tests add. In the no_cpp_changes outcome the job now: - compares total line/function/branch coverage against the master baseline (base_llvm_coverage.info is already downloaded there); - runs a new 'Newly Covered Lines' analysis (ci/jobs/scripts/newly_covered_lines.py) reporting lines with 0 hits on master and >0 hits now, and lines that lost coverage, with the detailed per-file report attached as a log artifact; - posts the PR comment and the CI DB row with these numbers, with a 'Newly covered' line instead of the 'Changed lines' one. No degradation gate in this mode: with an unchanged binary a drop can only be baseline noise, never a regression of the PR. Validated on the real tracefiles of https://s3.amazonaws.com/clickhouse-test-reports/PRs/117922/687dc08d3f9fbc0a8fe6f97fef3ee953598b60a9/pr/llvm_coverage/job.log (PR ClickHouse#117922): 1303 newly covered lines in 252 files, topped by the exact files its 12 new tests target; 1.9 s and 190 MB RSS on two 438 MB tracefiles. Co-Authored-By: Claude Fable 5 <[email protected]>
…build Co-Authored-By: Claude Fable 5 <[email protected]>
| unhex('13000000' || '05' || '76616C00' || '04000000' || '08' || '00010203' || '00')); -- { serverError UNKNOWN_TYPE } | ||
|
|
||
| -- getBSONTypeName(DOUBLE): Float64 written as BSON Double, read into IPv6 column | ||
| SELECT * FROM format('BSONEachRow', 'val IPv6', |
There was a problem hiding this comment.
The two UNKNOWN_TYPE cases above are fine because getBSONType / getBSONBinarySubtype are themselves the throw sites. Starting here, though, every check only asserts ILLEGAL_COLUMN, while the lines this block claims to cover (getBSONTypeName / getBSONBinarySubtypeName) affect only the exception text. A future refactor that throws the same code earlier, or keeps ILLEGAL_COLUMN but stops formatting the BSON type/subtype name, will leave this file green while those helpers lose coverage again.
Please capture at least one representative message substring for each family (for example BSON Double, BSON Document, BSON Binary subtype UUID) in a .sh test, or otherwise surface the exception text so the test actually distinguishes these helper calls from a generic ILLEGAL_COLUMN.
| -- 7. Map with multiple entries: exercises the comma-separator branch in Map dump. | ||
| -- FieldVisitorDump.cpp:95-96: the second and later entries prepend ", ". | ||
| -- The output is "Map_(Tuple_(...), Tuple_(...))" with a comma between entries. | ||
| SELECT countIf(explain LIKE '%Map_%,%') > 0 AS found |
There was a problem hiding this comment.
LIKE '%Map_%,%' does not actually pin the if (it != x.begin()) wb << ", "; branch in FieldVisitorDump::operator(Map). Even if the separator between map entries disappeared, this still matches because a single map entry already contains commas inside Tuple_(key, value), and the surrounding EXPLAIN line contains additional commas after the dump. So the test can stay green while lines 95-96 stop running.
Please assert a more specific dumped shape, for example a substring like Map_(Tuple_(Int64_1, 'a'), Tuple_(Int64_2, 'b')), or any other pattern that can only appear when the inter-entry , is emitted.
Against a single master baseline, the tests-only coverage report counts lines that fire only occasionally on master (background/async code) as transitions. On PR 117922 that meant 955 'lost coverage' lines and an inflated newly-covered count, all noise. The diff script now downloads up to 3 extra older master baselines, but only in the no_cpp_changes outcome (a tests-only PR forced with the ci-coverage label, or a coverage-pipeline PR), so C++ PRs pay nothing. newly_covered_lines.py requires every comparable baseline to agree: a line is newly covered only if it has 0 hits in all of them, and lost only if it has >0 hits in all of them. Extra baselines come from older master commits whose source can differ from the PR's merge base, shifting line numbers. Instead of resurrecting the git-diff remapping, a baseline votes on a file only when its instrumented DA line set for that file is identical to the current run's: the line set comes from the static coverage mapping, so equal sets mean the file did not change in between; unequal sets make that baseline abstain for that file. The dead slot-2..6 extraction loop is removed: it belonged to the LBC cross-validation deleted in 080b086 and had no consumer since. Validation on the real tracefiles of https://s3.amazonaws.com/clickhouse-test-reports/PRs/117922/687dc08d3f9fbc0a8fe6f97fef3ee953598b60a9/pr/llvm_coverage/job.log (PR ClickHouse#117922), with 3 extra real master baselines: newly covered 1303 -> 680 lines, lost coverage 955 -> 156 lines, while every genuinely targeted file keeps its exact count (SubstituteColumnOptimizer.cpp 158, OptimizeIfChains.cpp 34, ...). 4.8 s and 460 MB RSS for four 438 MB tracefiles. Co-Authored-By: Claude Fable 5 <[email protected]>
| -- Decimal32 (line 74): float literal cast to Decimal32; hits the else-branch in | ||
| -- convertFieldTo<Decimal32> (non-String, non-Decimal source converted via text). | ||
| DROP TABLE IF EXISTS t_pfl_05079; | ||
| CREATE TABLE t_pfl_05079 (s AggregateFunction(quantile(0.5::Decimal32(1)), Float64)) ENGINE = Memory; | ||
| SELECT type FROM system.columns WHERE database = currentDatabase() AND table = 't_pfl_05079'; | ||
| DROP TABLE t_pfl_05079; | ||
|
|
||
| -- Decimal128 (line 78) | ||
| CREATE TABLE t_pfl_05079 (s AggregateFunction(quantile(0.5::Decimal128(1)), Float64)) ENGINE = Memory; | ||
| SELECT type FROM system.columns WHERE database = currentDatabase() AND table = 't_pfl_05079'; | ||
| DROP TABLE t_pfl_05079; | ||
|
|
||
| -- Decimal256 (line 80) | ||
| CREATE TABLE t_pfl_05079 (s AggregateFunction(quantile(0.5::Decimal256(1)), Float64)) ENGINE = Memory; | ||
| SELECT type FROM system.columns WHERE database = currentDatabase() AND table = 't_pfl_05079'; | ||
| DROP TABLE t_pfl_05079; | ||
|
|
||
| -- Bool (line 83): UInt64 literal cast to Bool; hits the else-branch in convertFieldTo<bool> | ||
| -- (not already Bool, not String -> convert via FieldVisitorToString). | ||
| CREATE TABLE t_pfl_05079 (s AggregateFunction(quantile(0::Bool), Float64)) ENGINE = Memory; | ||
| SELECT type FROM system.columns WHERE database = currentDatabase() AND table = 't_pfl_05079'; | ||
| DROP TABLE t_pfl_05079; | ||
|
|
||
| -- Float64 (line 85): Float64 literal cast to Float64; hits the same-type branch in | ||
| -- convertFieldTo<Float64> (src is already Float64, returned unchanged). | ||
| CREATE TABLE t_pfl_05079 (s AggregateFunction(quantile(0.5::Float64), Float64)) ENGINE = Memory; | ||
| SELECT type FROM system.columns WHERE database = currentDatabase() AND table = 't_pfl_05079'; | ||
| DROP TABLE t_pfl_05079; | ||
|
|
||
| -- String (line 87): quantile does not accept a String parameter. | ||
| CREATE TABLE t_pfl_05079 (s AggregateFunction(quantile('0.5'::String), Float64)) | ||
| ENGINE = Memory; -- { serverError CANNOT_CONVERT_TYPE } | ||
|
|
||
| -- Int64 (line 90): UInt64 literal cast to Int64; hits the else-branch in convertFieldTo<Int64>. | ||
| CREATE TABLE t_pfl_05079 (s AggregateFunction(quantile(1::Int64), Float64)) ENGINE = Memory; | ||
| SELECT type FROM system.columns WHERE database = currentDatabase() AND table = 't_pfl_05079'; | ||
| DROP TABLE t_pfl_05079; | ||
|
|
||
| -- UInt64 (line 92): UInt64 literal cast to UInt64; hits the same-type branch. | ||
| CREATE TABLE t_pfl_05079 (s AggregateFunction(quantile(1::UInt64), Float64)) ENGINE = Memory; | ||
| SELECT type FROM system.columns WHERE database = currentDatabase() AND table = 't_pfl_05079'; | ||
| DROP TABLE t_pfl_05079; | ||
|
|
||
| -- Int128 (line 94) | ||
| CREATE TABLE t_pfl_05079 (s AggregateFunction(quantile(1::Int128), Float64)) ENGINE = Memory; | ||
| SELECT type FROM system.columns WHERE database = currentDatabase() AND table = 't_pfl_05079'; | ||
| DROP TABLE t_pfl_05079; | ||
|
|
||
| -- UInt128 (line 96) | ||
| CREATE TABLE t_pfl_05079 (s AggregateFunction(quantile(1::UInt128), Float64)) ENGINE = Memory; | ||
| SELECT type FROM system.columns WHERE database = currentDatabase() AND table = 't_pfl_05079'; | ||
| DROP TABLE t_pfl_05079; | ||
|
|
||
| -- Int256 (line 98) | ||
| CREATE TABLE t_pfl_05079 (s AggregateFunction(quantile(1::Int256), Float64)) ENGINE = Memory; | ||
| SELECT type FROM system.columns WHERE database = currentDatabase() AND table = 't_pfl_05079'; | ||
| DROP TABLE t_pfl_05079; | ||
|
|
||
| -- UInt256 (line 100) | ||
| CREATE TABLE t_pfl_05079 (s AggregateFunction(quantile(1::UInt256), Float64)) ENGINE = Memory; | ||
| SELECT type FROM system.columns WHERE database = currentDatabase() AND table = 't_pfl_05079'; |
There was a problem hiding this comment.
system.columns.type does not actually distinguish several of the branches this file claims to cover. 0.5::Decimal32(1), 0.5::Decimal128(1), and 0.5::Decimal256(1) all round-trip as AggregateFunction(quantile('0.5'), Float64); 1::Int64 and 1::UInt64 both become AggregateFunction(quantile(1), Float64); and all four big-int cases become AggregateFunction(quantile('1'), Float64).
A future refactor that routes one width or signedness through the wrong parseFieldFromCastedLiteral arm would leave this file green while the targeted dispatch branch loses coverage. Please use boundary values that only fit the intended width/signedness (for example values outside Int64/UInt64 for the 128-bit cases, and values that separate Decimal32 from wider decimal widths), or add some other assertion that makes the chosen cast width observable.
A duplication audit found 15 of the new tests target features that already have a dedicated test file, and one (05068) duplicated 03227_distinct_dynamic_types_json_paths. Rework per review guidance: - Append each test's queries to the existing feature test. Existing queries and their expected output are untouched: every old .reference is a byte-identical prefix of the new one (verified for all 32 files). - Delete the 15 standalone overlap tests and the duplicate 05068. - Keep 05067 standalone: its host is a .j2 template, excluded from append-only rework. - Keep 05079, 05082, 05084: no existing test covers those features. - Re-measured every merge under the llvm-coverage-instrumented build; targeted-line hits match the original standalone tests. Co-Authored-By: Claude Fable 5 <[email protected]>
The style check requires a no-parallel tag for SYSTEM DROP. The drops are unnecessary: each streaming SELECT is the first read of a freshly created table, so its marks are loaded cold either way. Co-Authored-By: Claude Fable 5 <[email protected]>
| ENGINE = MergeTree ORDER BY a; | ||
| INSERT INTO t_stream_wide_adaptive SELECT number, toString(number) FROM numbers(10000); | ||
| SELECT count(), sum(a) FROM t_stream_wide_adaptive SETTINGS use_streaming_marks_compression = 1; | ||
| SELECT count(), sum(a) FROM t_stream_wide_adaptive; |
There was a problem hiding this comment.
The control query here is no longer independent from the use_streaming_marks_compression = 1 read above. MergeTreeMarksLoader::loadMarksSync goes through MarkCache::getOrSet, so after the first SELECT the decoded marks are already cached; this "baseline" reuses the same cached marks instead of calling the non-streaming loader at all. That means a streaming-only decode bug, or a regression in the plain loader hidden behind a warm cache, would still leave both queries green.
Please restore SYSTEM DROP MARK CACHE before each baseline read (and likewise in the other two sections) so the non-streaming side actually reloads marks from disk.
- 04133: the merge reintroduced groupArrayInsertAt()(...) with an empty parameter list, which the old analyzer rejects with BAD_ARGUMENTS before the argument type check. Drop the empty parens (same fix as the original standalone test). Verified: codes 43/128 in both modes. - 04112: formatRow(... AS val) loses the alias on the old analyzer, so the BSON field is skipped as unknown and the ILLEGAL_COLUMN assertions never fire. Pin SET enable_analyzer = 1 at the start of the appended block. Verified: code 44 with the pin, silent success without it (reproduces the CI failure). 05054_nullable_key_todate_monotonicity also fails on this shard, but it fails on 13 other PRs in the same shard this week — pre-existing upstream issue, unrelated to this PR. Co-Authored-By: Claude Fable 5 <[email protected]>
alexey-milovidov
left a comment
There was a problem hiding this comment.
Ok.
But we prepare adding new tests instead of modifying old ones. Reason - better analytics on test history.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Test-only PR: close measured coverage gaps found via the public llvm coverage reports.
Every addition targets lines with zero hits in the master coverage report and was verified under the llvm-coverage-instrumented CI build: the run of only the new queries executes every targeted line (per-line hit counts in the table).
16 existing tests extended, append-only. Existing queries and their expected output are untouched — each old
.referenceis a byte-identical prefix of the new one:enable_analyzer=0enable_analyzer=0notationcolumn: 4/5/6-hex paths-Mergecombinator round-tripuse_streaming_marks_compressionstreaming path4 new test files (no existing test covers these features):
::Typecasts inside AggregateFunction type specsProjected effect (example): MergeTreeMarksLoader.cpp goes from 76.6% (187/244) to ~84.4% line coverage.
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/117922]
Version info
26.9.1.1371(included in26.9and later)