…rtToJsonPath
convertToJsonPath() unconditionally prepended "$." to the input path.
When users passed standard JSONPath notation like "$.name", this produced
the invalid path "$.$.name" which matched nothing, causing json_extract
to return null instead of the actual value.
Strip any existing "$." prefix before normalization so that both the
plugin's custom notation (e.g. "name", "a{}.b") and standard JSONPath
notation (e.g. "$.name", "$.user.name") are handled correctly.
Signed-off-by: Peng Huo <penghuo@gmail.com>
Description
json_extractalways returned string"null"instead of the actual extracted value when using standard JSONPath notation (e.g.,$.name).Root cause:
JsonUtils.convertToJsonPath()unconditionally prepends$.to all input paths. When users pass standard JSONPath like$.name, it becomes$.$.name— an invalid path that matches nothing, causing Calcite'sJsonFunctionsto return null.Fix: Strip any existing
$.prefix before normalization inconvertToJsonPath(), so paths already in standard JSONPath form are handled correctly. Also handles bare$input. The fix benefits all 5 JSON UDFs that share this code path (json_extract, json_delete, json_set, json_append, json_extend).Related Issues
#5166
Check List
--signoffor-s.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.