Skip to content

Add functional tests to improve coverage - #103456

Merged
alexey-milovidov merged 7 commits into
masterfrom
coverage-improvements-2026-04-23
Apr 26, 2026
Merged

alexey-milovidov merged 7 commits into
masterfrom
coverage-improvements-2026-04-23

Conversation

@fm4v

@fm4v fm4v commented Apr 23, 2026

Copy link
Copy Markdown
Member

Add 28 new stateless functional tests (04113..04140) targeting modules with the largest uncovered-line counts in master coverage data. All tests pass locally.

The targets are SQL-reachable code paths with significant gaps — parsers, aggregate functions, column types, formats, and functions. Integration-heavy modules (Kafka, Hive, Iceberg, Kubernetes, LDAP, Keeper) are excluded because they need running external services.

Coverage highlights by test:

  • 04113 timeSlots vector/constant combinations for DateTime and DateTime64
  • 04114 flameGraph arity, merge, empty trace, error paths
  • 04115 tumble / hop / windowID error and type paths
  • 04116 formatDateTime / formatDateTimeInJodaSyntax / fromUnixTimestamp edges
  • 04117 + 04124 ParserSystemQuery and ASTSystemQuery formatters
  • 04118 KQL make-series parser (ParserKQLMakeSeries.cpp, was 0%)
  • 04119 ParserSnapshotQuery round-trip
  • 04120 parseDateTime mysql and Joda format specifiers + error paths
  • 04121 JSONExtractTree across NumericNode / BoolNode / StringNode / DecimalNode / DateNode / UUIDNode / IPv4Node / EnumNode / LowCardinalityNode / NullableNode / ArrayNode / TupleNode / MapNode / VariantNode / DynamicNode / ObjectNode
  • 04122 SerializationTime64 across TSV / CSV / JSONEachRow / Values / TSKV
  • 04123 KQL string operators (contains / startswith / endswith / has / has_any / has_all / =~ / !~ / in~)
  • 04125 arrayLevenshteinDistance / arrayLevenshteinDistanceWeighted / arraySimilarity type dispatch
  • 04126 ParserAlterQuery variants not covered by existing tests
  • 04127 bitmap functions across integer element types
  • 04128 sequenceNextNode direction × base combos, merge, type dispatch
  • 04129 distinctJSONPaths / distinctJSONPathsAndTypes
  • 04130 Variant column operations (variantType / variantElement, MergeTree round-trip)
  • 04131 PrometheusQueryParsingUtil via the prometheusQuery table function
  • 04132 ColumnSparse aggregate / filter / sort / JOIN / mutation
  • 04133 groupArray / groupArrayLast / groupArraySample / groupArrayMoving* / groupArrayInsertAt
  • 04134 SingleValueDataGenericWithColumn over Tuple / Array / Map / Decimal / IPv4 / IPv6
  • 04135 BSONEachRow input type soup, numeric coercion, nullable, schema inference
  • 04136 window function frame bounds (ROWS / RANGE, PRECEDING / FOLLOWING, rank / ntile / nth_value)
  • 04137 conversion edges: toXxxOrZero / toXxxOrNull / toXxxOrDefault / accurateCast across numeric / Decimal / Date* / UUID / IPv4 / IPv6 / FixedString / big-integer
  • 04138 higher-order array lambdas (arrayMap / arrayFilter / arrayFold / arraySort with captures)
  • 04139 aggregate-function state round-trip via AggregatingMergeTree and -State / -Merge
  • 04140 Parquet type soup, compression codecs, multiple row groups, filter pushdown, column pruning, nullable, schema inference

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

Not for changelog (changelog entry is not required)

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Add 28 new stateless tests (04113..04140) targeting modules with the
largest uncovered-line counts from master coverage data:

- KQL: make-series parser, string operators
- Parsers: ParserSnapshotQuery, ParserSystemQuery extras, ParserAlterQuery variants
- Functions: parseDateTime format specifiers, JSONExtract type tree,
  conversion OrZero/OrNull/accurateCast, bitmap integer type dispatch,
  arrayLevenshtein/Weighted/Similarity, higher-order lambdas, timeSlots,
  time window (tumble/hop), formatDateTime edge cases
- AggregateFunctions: flameGraph arity/merge paths, sequenceNextNode
  direction/base combos, distinctJSONPaths, groupArray family,
  SingleValueData complex types, state/merge lifecycle
- Columns: Variant operations, sparse serialization, aggregate-function column
- Formats: BSONEachRow type soup + coercion, Parquet type soup + codecs +
  row groups + pruning
- Transforms: window function frame bounds
- DataTypes: SerializationTime64 across TSV/CSV/JSON/Values/TSKV
- Storages: Prometheus/PromQL parser via prometheusQuery table function
@clickhouse-gh

clickhouse-gh Bot commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c366da5]

Summary: ✅


AI Review

Summary

This PR adds a large batch of new 0_stateless functional tests (04113..04140) to improve coverage across parser, function, format, and type-conversion paths. I did not find new correctness, safety, performance, or repository-policy issues in the current PR head.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ➖
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
No large/binary files ✅
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Apr 23, 2026
fm4v added 6 commits April 23, 2026 19:46
- 04117, 04124: add no-parallel tag (SYSTEM DROP in the file trips the
  style check), and drop the bare `SYSTEM STOP MERGES` / `SYSTEM FLUSH LOGS`
  lines that the style check rejects wherever they appear.
- 04131: add no-fasttest tag (ANTLR4 is disabled in the fast-test build).
- 04132: add `database = currentDatabase()` to the `system.parts_columns`
  query.
- 04140: add no-fasttest tag (fast-test build lacks some Parquet codecs).

See #103456
The 'system\s*flush\s*logs\s*(;|$|")' grep rule also matched the
literal 'SYSTEM FLUSH LOGS;' inside comments I added in the previous
commit, so the style check flagged those comment lines.
Stateless tests randomize `--session_timezone` (Africa/Juba, Mexico/BajaSur,
etc.). 04118, 04120 and 04137 rendered zero/epoch DateTime values and bucketed
datetimes whose output changed with timezone, which tripped reference diff in
the flaky and parallel jobs. Adding `SET session_timezone = 'UTC'` at the top
makes the output independent of the CI override.

See #103456
- 04127: wrap bitmapSubsetInRange/Limit output in arraySort (roaring bitmap
  iteration order is not guaranteed).
- 04133: sort groupArrayArray result (UNION ALL block order is not stable).
- 04134: replace any()/anyLast() over tuples with ORDER BY + LIMIT 1 since
  any*() are documented as returning an unspecified row.
- 04136: add a rowNumberInAllBlocks() tiebreaker so row_number() over ties
  has a deterministic assignment.
- 04139: feed topKState() a weighted distribution instead of unique values
  so the top-3 is unambiguous.

See #103456
Those aggregators intentionally return an unspecified row and remain
non-deterministic under parallel execution, so they can't be asserted on
in a reference test. Keep min/max/count on the Nullable branch, which are
still exercising SingleValueDataGenericWithColumn paths.

See #103456
- 04131: add no-replicated-database tag. The experimental TimeSeries
  engine does not round-trip through DatabaseReplicated; the cleanup
  DROP TABLE hangs for 12+ minutes and cascades as timeouts into
  subsequent tests on that shard.
- 04136: percent_rank() / cume_dist() require an explicit
  RANGE UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING frame. Using a
  WINDOW clause with ORDER BY picked the default CURRENT ROW frame,
  which those functions reject with BAD_ARGUMENTS. Split the window
  into three named windows so each function gets a frame it supports.

The 04134 timeout in the same shard was collateral from 04131's cleanup
hang; no change needed there.

#103456

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it.

@alexey-milovidov alexey-milovidov self-assigned this Apr 26, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Apr 26, 2026
Merged via the queue into master with commit 38cb80c Apr 26, 2026
164 checks passed
@alexey-milovidov
alexey-milovidov deleted the coverage-improvements-2026-04-23 branch April 26, 2026 11:44
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 26, 2026
yonas pushed a commit to yonasBSD/ClickHouse that referenced this pull request Apr 29, 2026
…2, 04134, 04135, 04140)

Several of the tests added in PR ClickHouse#103456 codified weak or wrong expected output
because they were generated by a low-reasoning agent that accepted whatever the
server returned. This commit fixes the assertions so the tests actually
discriminate between correct and broken behaviour.

- 04121: Replace `JSONExtract('{"x": 3.14}', 'x', 'Variant(String, Int64, Float64)')`
  which returned 3 (silent truncation) with `Variant(String, Float64)` which
  returns 3.14. The truncation case is tracked separately in
  ClickHouse#103617.

- 04128: The original `sequenceNextNode` matrix used `(time, event, event='A',
  event='B')` arguments where `event='A'` is the base condition and `event='B'`
  is chain[0]; both must be true on the same row, which is impossible for
  mutually exclusive predicates. Every two-matcher case returned `\N`,
  exercising no traversal. Rewritten so the direction x base matrix produces
  six distinct non-NULL results plus a non-trivial GROUP BY merge.

- 04131: PromQL evaluator coverage for selector-based queries (rate, by/without,
  group_left/right, prometheusQueryRange) is unverifiable because the
  `TimeSeries` engine does not support direct INSERT (`NOT_IMPLEMENTED`). Added
  a scope note clarifying that those `count() == 0` assertions exercise only
  the parser surface and an evaluator regression on an empty selector would
  need a separate integration test.

- 04132: Replaced `SELECT name, serialization_kind FROM system.parts_columns`
  with `SELECT column, serialization_kind`. `name` is the part name
  (`all_1_1_0`), so the original query returned three identical part-name rows
  and gave no information about which column got which serialization. The
  fixed query returns `id Default / s Sparse / v Sparse`.

- 04134: Removed the misleading `any_value of Tuple via ORDER BY LIMIT 1`
  section: it was claimed to "still exercise the tuple code path
  deterministically" but `ORDER BY val LIMIT 1` invokes the sort path, not
  `any()/anyLast()` over `SingleValueDataGenericWithColumn`. The header now
  states explicitly that `any/anyLast` are excluded because they return
  unspecified rows under parallelism. The empty-input case is renamed and
  asserts only `min/max/argMin/argMax`.

- 04135: The original `Int32 -> Int8` coerce used value 42, which fits in
  `Int8`, so a silent-truncation regression would have passed. Switched to
  value 200 and codified the resulting `-56` wrap explicitly so the test now
  detects regressions in the narrowing path. Tightened the error matcher
  from `Code: [0-9]*` to `Code: [0-9]+`.

- 04140: The original "filter pushdown" and "column pruning" sections only
  asserted result correctness; a regression that disabled pushdown or read
  all columns would still pass. Added profile-event assertions:
  ParquetPrunedRowGroups for row-group pruning (5000 rows / 500 per group =>
  10 groups, expecting `read=1 pruned=9`) and ParquetDecodingTasks for
  column pruning (single-column read should issue fewer decoding tasks
  than reading all columns). Also asserts result equivalence with
  `input_format_parquet_filter_push_down=0`.

Discovered while reviewing ClickHouse#103456. The PR has been merged, so this lands as
follow-up rather than amend.
yonas pushed a commit to yonasBSD/ClickHouse that referenced this pull request Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci 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.

3 participants