Skip to content

[branch-4.0](jsonb) add json_object_flatten scalar function (#62825)#63114

Open
csun5285 wants to merge 3 commits into
apache:branch-4.0from
csun5285:pick-62825-to-4.0
Open

[branch-4.0](jsonb) add json_object_flatten scalar function (#62825)#63114
csun5285 wants to merge 3 commits into
apache:branch-4.0from
csun5285:pick-62825-to-4.0

Conversation

@csun5285
Copy link
Copy Markdown
Contributor

pick from master #62825

Introduce `json_object_flatten(JSONB) -> JSONB`. Turn a nested JSONB
object into a single-level JSONB whose keys are the dot-joined paths to
each leaf, mirroring NiFi `FlattenJson` *keep-arrays* semantics:

```
{"a":{"b":2}}        -> {"a.b":2}
{"a":{"b":{"c":3}}}  -> {"a.b.c":3}
{"a":[{"b":1}]}      -> {"a":[{"b":1}]}
```
apache/doris-website#3589

(cherry picked from commit 18fceee)
@hello-stephen
Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@csun5285
Copy link
Copy Markdown
Contributor Author

run buildall

@csun5285 csun5285 changed the title [feature](jsonb) add json_object_flatten scalar function (#62825) [branch-4.0](jsonb) add json_object_flatten scalar function (#62825) May 10, 2026
@hello-stephen
Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 90.32% (28/31) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 53.19% (19378/36435)
Line Coverage 36.30% (180844/498166)
Region Coverage 32.88% (140279/426641)
Branch Coverage 33.79% (60774/179884)

…anch-4.0 variant->jsonb cast

On branch-4.0, the variant->jsonb cast returns NULL for an empty object
and for objects whose leaves are all null ({}, {"a":{}}, {"a":null},
{"a":{"b":null}}), whereas master preserves them as {}. Update rows
k=4..7 of the sql_variant expected output from {} to \N so the suite
matches the actual branch-4.0 behavior. The function itself is correct
and the jsonb-column section is unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@csun5285
Copy link
Copy Markdown
Contributor Author

run buildall

@csun5285 csun5285 closed this May 11, 2026
@csun5285 csun5285 reopened this May 11, 2026
@csun5285
Copy link
Copy Markdown
Contributor Author

run buildall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants