Repository navigation
Optimize json.path[N].nested.path to json.path[].nested.path[N] - #99802
Conversation
|
Workflow [PR], commit [5ab38d3] Summary: ❌
|
…-json-array-path-optimization # Conflicts: # src/Analyzer/Passes/FunctionToSubcolumnsPass.cpp
…-json-array-path-optimization
alexey-milovidov
left a comment
There was a problem hiding this comment.
LGTM, except the fact that there is no setting to turn this optimization on/off. Which means if we discover a subtle bug, it will be harder to work around.
|
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. |
|
The MSan stress test failure (MemorySanitizer: use-of-uninitialized-value, STID 4179-5154 or 4148-3044) is a known pre-existing issue unrelated to this PR. Fix: #102158 |
| /// Build the new subcolumn name: "col.:`Array(JSON)`.f1.f2...fK". | ||
| String new_col_name = ctx.column.name + ".:`Array(JSON)`"; | ||
| for (const auto & field : field_names) | ||
| new_col_name += "." + field; |
There was a problem hiding this comment.
The rewritten subcolumn name is assembled with raw field segments (new_col_name += "." + field). For quoted JSON keys that contain dots (e.g. ``json.a.b[1].`c.d```), `field` is `c.d`, so this produces `... .c.d` instead of a single escaped segment. As a result, `tryGetColumn` cannot resolve the intended `Array(JSON)` subcolumn and the optimization is skipped for this key shape.
Could you build the path with proper escaping/identifier concatenation for each segment (instead of raw string concatenation), and add an EXPLAIN assertion for the dotted-key case to lock this behavior?
There was a problem hiding this comment.
Re-checking the current head, this is still live: new_col_name is built via raw concatenation (new_col_name += "." + field), so a quoted key segment like `c.d` is turned into .c.d instead of one escaped segment. The tryGetColumn lookup then misses the intended Array(JSON) subcolumn, so the optimization is skipped for this key shape.
Could you build each appended segment with identifier escaping (so dotted keys remain a single path element) and add an EXPLAIN QUERY TREE assertion for the dotted-key case to lock this behavior?
There was a problem hiding this comment.
so a quoted key segment like
`c.d`is turned into .c.d instead of one escaped segment
What? This is something strange. Why should we escape anything? Segments in JSON path subcolumn should not be escaped
|
The flaky check failure is fixed in #102148, let's update the branch. |
This optimization is guarded by |
…-json-array-path-optimization
…-json-array-path-optimization
…-json-array-path-optimization
LLVM Coverage Report
Changed lines: 91.67% (143/156) · Uncovered code |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Optimize
json.path[N].nested.path(which istupleElement(tupleElement(json.path[N], 'nested'), 'path'),) tojson.path[].nested.path[N]which reads much less dataDocumentation entry for user-facing changes
Version info
26.5.1.602