eldenmoon opened a new pull request, #63792:
URL: https://github.com/apache/doris/pull/63792

   ### What problem does this PR solve?
   
   Issue Number: close #24260
   
   Related PR: #xxx
   
   Problem Summary: Inserting `json_object` into a `variant` column could 
materialize the JSONB value through a string cast path that lost escaping for 
quoted strings. The stored value stayed as a root JSONB/string-like scalar, so 
path extraction such as `ch['ch']` returned `NULL`.
   
   ### What is changed?
   
   Convert scalar JSONB variant roots directly back to JSON text with 
`JsonbToJson::jsonb_to_json_string` before parsing into `ColumnVariant`, 
instead of using the generic JSONB-to-string cast path. This preserves embedded 
quotes in object string values and lets variant subcolumns be materialized 
correctly.
   
   A regression case covers `INSERT INTO variant SELECT json_object(...)` with 
`Willie "The Lion" Smith` and verifies both `variant_type(ch)` and `ch['ch']`.
   
   ### Release note
   
   Fix variant insertion from `json_object` for strings containing quotes.
   
   ### Check List (For Author)
   
   - Test:
       - Build: `./build.sh --be`
       - Regression test: `./run-regression-test.sh --run -d variant_p0 -s 
test_insert_json_object_to_variant ...`
       - Manual test: reproduced DORIS-24260 SQL before the fix and verified 
`variant_type(ch)` plus `ch['ch']` after the fix
       - Static check: 
`CLANG_TIDY_BINARY=/mnt/disk1/claude-max/.vscode-server/extensions/ms-vscode.cpptools-1.32.2-linux-x64/LLVM/bin/clang-tidy
 build-support/run-clang-tidy.sh --build-dir be/build_Release --files 
be/src/exec/common/variant_util.cpp`
       - Note: `build-support/clang-format.sh` was attempted but 
`clang-format`/`clang-format-16` is unavailable in this local environment.
   - Behavior changed: Yes. `json_object` inserted into `variant` now 
materializes as an object so subpath extraction works when string values 
contain quotes.
   - Does this need documentation: No
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to