Ma77Ball opened a new pull request, #5045:
URL: https://github.com/apache/texera/pull/5045
### What changes were proposed in this PR?
`JSONUtils.JSONToMap` with `flatten=true` silently dropped primitive
elements that lived inside an array. The docstring's worked example claimed
`{"E":["X","Y"]}` would flatten to
`{"E1":"X","E2":"Y"}`, but the implementation only emitted entries from
inside its `isObject` / `isArray` branches, so a recursive call landing on a
value node returned an empty map
and the data vanished. This PR adds a third top-level branch that emits
`parentName -> node.asText()` whenever `JSONToMap` is called on a value node
with a non-empty `parentName`,
bringing the behavior into line with the docstring. The two
`JSONUtilsSpec` cases that previously pinned the buggy behavior (with comments
inviting exactly this tightening) are flipped
to assert the documented contract, and a new case covers a mixed array of
objects and primitives.
### Any related issues, documentation, or discussions?
N/A
### How was this PR tested?
- Updated `JSONUtilsSpec`: flipped the two pinning cases
(array-of-primitives, top-level array of primitives) to assert the documented
output, added a mixed-array case.
- `sbt "WorkflowCore/testOnly org.apache.texera.amber.util.JSONUtilsSpec"`
passes (15/15).
- `sbt scalafmtAll` is clean.
### Was this PR authored or co-authored using generative AI tooling?
Co-authored with Claude Opus 4.7 in compliance with ASF
--
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]