-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Fix(Variant) Fix null value handling when serializing to JSON string #55876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
ebce83d to
f5ffb25
Compare
|
run buildall |
TPC-H: Total hot run time: 34569 ms |
TPC-DS: Total hot run time: 189453 ms |
ClickBench: Total hot run time: 30.11 s |
f5ffb25 to
5a78c90
Compare
|
run buildall |
TPC-H: Total hot run time: 34713 ms |
TPC-DS: Total hot run time: 189454 ms |
ClickBench: Total hot run time: 29.78 s |
5a78c90 to
83b0cfd
Compare
|
run buildall |
TPC-H: Total hot run time: 34603 ms |
TPC-DS: Total hot run time: 189490 ms |
ClickBench: Total hot run time: 30.04 s |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
Problem:
When Variant data is NULL or its root is empty, serializing it
to JSON would incorrectly produce '\N' or other unexpected
results. The standard JSON format expects a 'null' literal or
an empty object '{}' for such cases.
Solution:
This commit addresses the issue with the following changes:
1. In `HierarchicalDataIterator`, when a Variant's root data
is empty, it is now explicitly marked as NULL in the null map.
2. The JSON serialization logic in
`ColumnVariant::serialize_text_json` is modified to serialize a
NULL sub-column as an empty JSON object '{}' instead of '\N'.
3. The logic in `is_visible_root_value` is updated to rely on
the null flag rather than checking if the data content is
empty, providing a more accurate reflection of the value's
existence.
These changes ensure that the Variant type produces correct and
expected JSON output when serializing null or empty data.
Corresponding regression tests have also been added to cover
scenarios involving NULL and empty JSON objects.
83b0cfd to
f0a6aab
Compare
|
run buildall |
TPC-H: Total hot run time: 34613 ms |
TPC-DS: Total hot run time: 190068 ms |
ClickBench: Total hot run time: 29.54 s |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
serialize_one_cell_to_json should result 'null' instead of '\\N' when cell is empty
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
|
run p0 10 |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
csun5285
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
PR approved by anyone and no changes requested. |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
airborne12
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
PR approved by at least one committer and no changes requested. |
What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
Problem:
When Variant data is NULL or its root is empty, serializing it
to JSON would incorrectly produce '\N' or other unexpected
results. The standard JSON format expects a 'null' literal or
an empty object '{}' for such cases.
Solution:
This commit addresses the issue with the following changes:
1. In
HierarchicalDataIterator, when a Variant's root datais empty, it is now explicitly marked as NULL in the null map.
2. The JSON serialization logic in
ColumnVariant::serialize_text_jsonis modified to serialize aNULL sub-column as an empty JSON object '{}' instead of '\N'.
3. The logic in
is_visible_root_valueis updated to rely onthe null flag rather than checking if the data content is
empty, providing a more accurate reflection of the value's
existence.
These changes ensure that the Variant type produces correct and
expected JSON output when serializing null or empty data.
Corresponding regression tests have also been added to cover
scenarios involving NULL and empty JSON objects.
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)