Repository navigation
Add function JSONAllValues and support text index on top of it - #100730
Conversation
|
Workflow [PR], commit [364360e] Summary: ✅ AI ReviewSummaryThis PR adds the Missing context
ClickHouse Rules
Final Verdict
|
…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]>
| 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); | ||
| } |
There was a problem hiding this comment.
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.
JSONAllValuesJSONAllValues and support text index on top of it
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]>
3286041 to
4869c9e
Compare
|
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. |
LLVM Coverage Report
Changed lines: 93.48% (387/414) | lost baseline coverage: 18 line(s) · Uncovered code |
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]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added function
JSONAllValuesthat returns all values from aJSONcolumn asArray(String), with values serialized in text representation and ordered by their path names. Added support of text index forJSONAllValuesexpression onJSONcolumns. When a text index is created onJSONAllValues(json_column), it is automatically used to filter queries onJSONsubcolumns (e.g.,json_column.key1 = 'value').Documentation entry for user-facing changes
Version info
26.4.1.675