Skip to content
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

jsonExtractIndex support array of default values #12748

Merged
merged 2 commits into from
Mar 29, 2024

Conversation

saurabhd336
Copy link
Contributor

#12532 added support for extracting multi value json fields using jsonExtractIndex. The default value was always an empty array []. This PR enhances the functionality by allowing users to specify any arbitrary array default value.

Eg:

{
    "stringField": "xyz",
    "arrField": [{"f1": 1, "f2": 2}, {"f1": 3, "f2": 4}, {"f2": 6}]
}

jsonExtractIndex(jsonField, '$.arrField[*].f1', 'INT_ARRAY') returns [1, 3] for this row
jsonExtractIndex(jsonField, '$.arrField[*].f2', 'INT_ARRAY') returns [2, 4, 6] for this row

jsonExtractIndex(jsonField, '$.arrField[*].f5', 'INT_ARRAY', '[]') returns [] for this row (Default value since $.arrField[*].f5 doesn't exist)
jsonExtractIndex(jsonField, '$.arrField[*].f5', 'INT_ARRAY', '[1, 2, 3]') returns [1, 2, 3]

@codecov-commenter
Copy link

codecov-commenter commented Mar 29, 2024

Codecov Report

Attention: Patch coverage is 61.53846% with 20 lines in your changes are missing coverage. Please review.

Project coverage is 61.56%. Comparing base (59551e4) to head (214251f).
Report is 184 commits behind head on master.

Files Patch % Lines
...rm/function/JsonExtractIndexTransformFunction.java 61.53% 13 Missing and 7 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #12748      +/-   ##
============================================
- Coverage     61.75%   61.56%   -0.19%     
+ Complexity      207      198       -9     
============================================
  Files          2436     2462      +26     
  Lines        133233   134588    +1355     
  Branches      20636    20838     +202     
============================================
+ Hits          82274    82856     +582     
- Misses        44911    45540     +629     
- Partials       6048     6192     +144     
Flag Coverage Δ
custom-integration1 <0.01% <0.00%> (-0.01%) ⬇️
integration <0.01% <0.00%> (-0.01%) ⬇️
integration1 <0.01% <0.00%> (-0.01%) ⬇️
integration2 0.00% <0.00%> (ø)
java-11 61.52% <61.53%> (-0.19%) ⬇️
java-21 61.44% <61.53%> (-0.19%) ⬇️
skip-bytebuffers-false 61.55% <61.53%> (-0.20%) ⬇️
skip-bytebuffers-true 61.40% <61.53%> (+33.67%) ⬆️
temurin 61.56% <61.53%> (-0.19%) ⬇️
unittests 61.55% <61.53%> (-0.19%) ⬇️
unittests1 46.13% <61.53%> (-0.76%) ⬇️
unittests2 27.96% <0.00%> (+0.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Jackie-Jiang Jackie-Jiang merged commit 174377d into apache:master Mar 29, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants