clintropolis opened a new pull request, #12920:
URL: https://github.com/apache/druid/pull/12920

   ### Description
   This PR adjusts the behavior of `PARSE_JSON` to be strict and a bit more 
intuitive, adds a new `TRY_PARSE_JSON` which will produce `NULL` values instead 
of errors for bad or non-string inputs, and removes `TO_JSON` which no longer 
had a use since its behavior has been made intrinsic to all JSON expressions.
   
   Previously `PARSE_JSON` was far far too forgiving, allowing stuff like 
`PARSE_JSON('hello world')` to pass through into a string root literal even 
though it isn't valid JSON. Meanwhile, something like `PARSE_JSON('{')` would 
be an error. Basically, the behavior was `TO_JSON` if the input was not 
actually JSON, which is far too magical and not particularly useful (apologies 
this made it in like this, it was a relic of an earlier iteration).
   
   Now, `PARSE_JSON` is strict and will fail with an error if provided 
non-string input (with the exception of null, which will output a null) or if 
the string contains invalid JSON. `TRY_PARSE_JSON` has also been added, which 
will return `NULL` for anything that is not a string containing valid JSON in 
the cases where `PARSE_JSON` would have resulted in an error.
   
   I made some adjustments to `StructuredDataProcessor` to look for and 
'unwrap' any `StructuredData` objects it happens to encounter, which would 
allow for the JSON expressions which produce `COMPLEX<json>` outputs to return 
them as `StructuredData`, but have not actually made this change to the 
expressions at this time. This change should be harmless, but isn't currently 
necessary so I can revert it if any reviewers wish.
   
   <hr>
   
   This PR has:
   - [ ] been self-reviewed.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked 
related entities via Javadoc links.
   - [ ] added comments explaining the "why" and the intent of the code 
wherever would not be obvious for an unfamiliar reader.
   - [ ] added unit tests or modified existing tests to cover new code paths, 
ensuring the threshold for [code 
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
 is met.
   - [x] been tested in a test Druid cluster.
   


-- 
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