Skip to content

Add test: Time and DateTime string parse failure paths in JSONExtractTree lack test coverage - #105050

Merged
alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr102690
May 19, 2026
Merged

alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr102690

Conversation

@clickgapai

@clickgapai clickgapai commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment.

This is a test-only PR — no source code changes. Please review: test quality, whether the claimed coverage gaps are real, and whether test output makes sense.

Adds test coverage for 1 untested code path(s), found during automated review of PR #102690.
That PR PR #102690 fixes inserting into Time data type during JSON parsing by adding Int64 support to TimeNode and DateTimeNode. The changes (1) modify the condition from isUInt64() to isInt64() || isUInt64() to accept both integer types, (2) add error handling for negative Int64 values in DateTime, and

1. Time and DateTime string parse failure paths in JSONExtractTree lack test coverage
src/Formats/JSONExtractTree.cpp:784, src/Formats/JSONExtractTree.cpp:713
Risk: The call chain is: JSONExtract → TimeNode::insertResultToColumn → element.isString() TRUE → tryParse fails → error set → return false at line 784. Risk: if return false is accidentally removed, the
What's unique vs PR tests: PR test 04094 covers valid Time string parsing ('12:30:45' → 12:30:45). This test covers invalid Time string parsing ('not-a-time' → 00:00:00 default) - the failure path at line 784 that PR tests don'
Tags: -- Tags: no-fasttest — no-fasttest: Time type requires enable_time_time64_type which is not available in fast test build
Try it on ClickHouse Fiddle

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)

Version info

  • Merged into: 26.5.1.834

@clickgapai

Copy link
Copy Markdown
Contributor Author

Pre-PR Validation Gate (per ClickGap pipeline):

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

b) Root cause explained? ✅
src/Formats/JSONExtractTree.cpp:784 (return false in Time string parse failure) and line 713 (DateTime) — error paths that were never tested in the existing test suite.

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: 04240_json_extract_time_string_parse_failure.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.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label May 19, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1c1b550]

Summary: ✅


AI Review

Summary

This PR adds a new stateless test pair (04240_json_extract_invalid_time_string.sql and .reference) to cover JSONExtract string parse failure paths for Time and DateTime. The test is deterministic in the DateTime branch by using DateTime('UTC'), aligns with current function behavior (failed extraction inserts default values), and the prior thread about filename/style-check breakage is already addressed in the current code.

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 May 19, 2026
@alexey-milovidov alexey-milovidov self-assigned this May 19, 2026
Style check rejects test names containing 'fail'. Renamed:
- 04240_json_extract_time_string_parse_failure.sql → 04240_json_extract_invalid_time_string.sql
- 04240_json_extract_time_string_parse_failure.reference → 04240_json_extract_invalid_time_string.reference

Requested by @alexey-milovidov in ClickHouse#105050 (comment)
@clickgapai
clickgapai force-pushed the qa-bot/coverage-pr102690 branch from 6509a59 to 4ecde0a Compare May 19, 2026 01:40
Lines 17-19 used plain `DateTime` which outputs `1970-01-01 00:00:00`
only in UTC sessions; non-UTC servers would format with offset.
Changed to `DateTime('UTC')` so the reference is deterministic.

Requested by @clickhouse-gh[bot] in ClickHouse#105050 (comment)
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue May 19, 2026
Merged via the queue into ClickHouse:master with commit e6324ff May 19, 2026
165 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 19, 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 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.

3 participants