Skip to content

Add test: JSON_VALUE multi-path over Dynamic input with function_json_value_return_type_allow_nullable=1 — per-leaf makeNullable branch untested - #111866

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr109944
Aug 1, 2026
Merged

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

Conversation

@clickgapai

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 #109944.
PR fixes a LOGICAL_ERROR in JSON_EXISTS/JSON_VALUE/JSON_QUERY when the input is Dynamic and the path argument is a multi-path (Tuple/Array) whose elements are wrapped in LowCardinality or Nullable (e.g. tuple('$.a', toLowCardinality('$.b')), or a scalar Tuple subquery arriving

1. JSON_VALUE multi-path over Dynamic input with function_json_value_return_type_allow_nullable=1 — per-leaf makeNullable branch untested
src/Functions/FunctionSQLJSON.h:655
Risk: FunctionSQLJSON.h:654-655 only runs when the setting is enabled AND the input is Dynamic AND the path is multi-path; the PR's Dynamic tests use the default (setting=0) and the existing setting=1 test (04066) uses non-Dynamic input, so the branch that makes leaves Nullable on the Dynamic path is never executed. Risk: if this branch is broken the declared return type collapses to non-nullable Tuple(String, ...) while execution fills NULLs, reproducing the LOGICAL_ERROR (declared-type …
What's unique vs PR tests: The PR's 04325 Dynamic tests run only at the default function_json_value_return_type_allow_nullable=0 (plain String leaves); the existing 04066 setting=1 test uses non-Dynamic input (hits line 632, not the Dynamic overload at 654-655). This test is the only one that combines Dynamic input + multi-path + setting=1, executing line 655.
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)

@clickgapai

Copy link
Copy Markdown
Contributor Author

Pre-PR Validation Gate (per ClickGap pipeline):

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

b) Root cause explained? ✅
src/Functions/FunctionSQLJSON.h:655 leaf_type = makeNullable(leaf_type); inside getReturnTypeForDynamic, guarded by if (function_json_value_return_type_allow_nullable) — reachable only on the Dynamic multi-path with the setting enabled.

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: 04628_json_value_dynamic_multipath_nullable.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.

@groeneai

Copy link
Copy Markdown
Collaborator

I reviewed this test and it looks good.

Coverage gap is real. 04325_sql_json_functions_with_dynamic_input covers JSON_VALUE multi-path over Dynamic only at the default function_json_value_return_type_allow_nullable=0, and 04066_json_value_tuple_array sets it to 1 but never over a Dynamic argument. No stateless test combines all three, so the getReturnTypeForDynamic per-leaf makeNullable branch is untested. Scoping to JSON_VALUE is right: JSON_EXISTS returns UInt8 and JSON_QUERY ignores that setting, so only JSON_VALUE has this branch.

Reference verified. I ran the .sql against a master binary that contains the merged fix (GIT_HASH 088d09b) and the output matches the committed .reference exactly (all 5 lines, exit 0).

Parallel-safe: only literals and a session-local SET, no files or global state, so no no-parallel tag is needed. Not a duplicate.

One note: this branch is about 1900 commits behind master and predates the fix, so it only passes after a merge with current master. CI tests refs/pull/N/merge so that is fine, but a rebase would make local runs pass too.

On the can be tested label: I do not have push access to this repo, so I cannot add labels. That is a maintainer action.

@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Jul 29, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9dafddb]

Summary: ✅


AI Review

Summary

This PR adds a focused stateless regression test for JSON_VALUE on Dynamic multi-path inputs with function_json_value_return_type_allow_nullable=1. I did not find review blockers: the new test closes a real gap between the existing Dynamic coverage in 04325_sql_json_functions_with_dynamic_input and the setting-enabled non-Dynamic coverage in 04066_json_value_tuple_array, it checks both the declared nullable-leaf return types and the runtime NULL materialization, and the current PR CI report is all green.

Final Verdict

✅ Approve. No correctness, coverage, or PR-metadata issues found in the current diff.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jul 29, 2026
@alexey-milovidov alexey-milovidov self-assigned this Aug 1, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 1, 2026
Merged via the queue into ClickHouse:master with commit f13ca7e Aug 1, 2026
179 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 1, 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.

5 participants