Skip to content

Add function JSONAllValues and support text index on top of it - #100730

Merged
CurtizJ merged 26 commits into
ClickHouse:masterfrom
CurtizJ:json-all-values-3
Apr 8, 2026
Merged

CurtizJ merged 26 commits into
ClickHouse:masterfrom
CurtizJ:json-all-values-3

Conversation

@CurtizJ

@CurtizJ CurtizJ commented Mar 25, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • New Feature

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

Added function JSONAllValues that returns all values from a JSON column as Array(String), with values serialized in text representation and ordered by their path names. Added support of text index for JSONAllValues expression on JSON columns. When a text index is created on JSONAllValues(json_column), it is automatically used to filter queries on JSON subcolumns (e.g., json_column.key1 = 'value').

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.4.1.675

@clickhouse-gh

clickhouse-gh Bot commented Mar 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [364360e]

Summary: ✅


AI Review

Summary

This PR adds the JSONAllValues function and wires text-index optimization for predicates on JSON subcolumns by matching JSONAllValues(json) index expressions. After reviewing the current PR head and excluding already-reported clickhouse-gh[bot] topics, I found no additional correctness, safety, concurrency, or performance issues that warrant new inline comments.

Missing context
  • ⚠️ I did not analyze detailed CI job logs/benchmarks beyond the PR metadata and inline review context.
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 ✅
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Mar 25, 2026
Comment thread src/DataTypes/DataTypesCache.cpp Resolved
Comment thread src/Functions/JSONAllValues.cpp Resolved
CurtizJ and others added 2 commits March 25, 2026 16:37
…e_index`

`ReadBuffer::peek` returns `true` on success, `false` on EOF.
The early-return guard had the condition inverted, causing
`type_index` to be used uninitialized on the fall-through path.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100730&sha=53e71e3ead5677fe969c09855ad4869c5ee7ae8b&name_0=PR

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Comment on lines +202 to +216
char type_index;
if (!buf.peek(type_index))
throw Exception(ErrorCodes::INCORRECT_DATA, "Cannot parse shared data value of JSON: no type index found");

const auto & cache = getSimpleDataTypeCache();
auto binary_type_index = static_cast<BinaryTypeIndex>(type_index);

if (cache.hasElement(binary_type_index))
{
++buf.position();

const auto & element = cache.getElement(binary_type_index);
const auto & temp_column = get_column_from_cache(element.name, *element.type);
serialize(*element.type, *element.serialization, *temp_column);
}

@CurtizJ CurtizJ Mar 25, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This optimization avoids copying a shared_ptr for the data type and serialization for each row. Copying of shared_ptr is quite heavy because of operations with atomics in the constructor and destructor. I think that simple types cover the majority of values in JSONs and it should work well.

We can also apply this technique to row operations in SerializationDynamic and SerializationObject.

Comment thread src/DataTypes/DataTypesCache.cpp Resolved
@CurtizJ CurtizJ changed the title Add function JSONAllValues Add function JSONAllValues and support text index on top of it Mar 25, 2026
@Avogar Avogar self-assigned this Mar 27, 2026
CurtizJ and others added 4 commits March 27, 2026 16:08
Test covers point lookups (string/numeric), equality, LIKE, `hasToken`,
`hasAllTokens`, `hasAnyTokens`, combined conditions, schema-agnostic
`JSONAllValues` search, and array queries (`has`, array equality).
Each query verifies index filtering via EXPLAIN and correctness via
re-running with skip indexes disabled.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@CurtizJ
CurtizJ force-pushed the json-all-values-3 branch from 3286041 to 4869c9e Compare March 28, 2026 02:36
@CurtizJ
CurtizJ marked this pull request as ready for review March 29, 2026 23:24
@CurtizJ
CurtizJ requested a review from Avogar March 30, 2026 21:30
Comment thread src/Functions/JSONAllValues.cpp Resolved
@alexey-milovidov

Copy link
Copy Markdown
Member

The Stress test (arm_msan) failure is fixed by #101239, which should be merged first. After it is merged, please update the branch to include the fix.

@Avogar Avogar 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.

Looks great!

@clickhouse-gh

clickhouse-gh Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.00% 83.90% -0.10%
Functions 90.90% 90.90% +0.00%
Branches 76.50% 76.40% -0.10%

Changed lines: 93.48% (387/414) | lost baseline coverage: 18 line(s) · Uncovered code

Full report · Diff report

@CurtizJ
CurtizJ added this pull request to the merge queue Apr 8, 2026
Merged via the queue into ClickHouse:master with commit 32310ea Apr 8, 2026
163 checks passed
@CurtizJ
CurtizJ deleted the json-all-values-3 branch April 8, 2026 18:48
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 8, 2026
alexey-milovidov added a commit that referenced this pull request Jun 23, 2026
Reword entries that described a LOGICAL_ERROR as a server crash to say
exception (logical errors do not crash the release build); keep crash
wording only for real release-build crashes (SIGSEGV, uncaught
std::out_of_range) and debug/sanitizer-scoped aborts. Convert the
remaining bare PR/issue URLs (#49579, chdig release, Caused by #100730,
upstream arrow-rs-object-store#585) to markdown links.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature Pull request with new product feature 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