Refactor JSON: Currently the JSON evaluates STRING/JSON_ARRAY/JSON_OBJECT. It brings many confusions. In Splunk, the data could be stored as JSON object, JSON function evaluates JSON object. But in Spark, there is no JSON object, but it contains STRING, StructType and ArrayType. So the JSON function can only evaluate STRING types.
Add ARRAY_LENGHT: for the same reason above, we separate JSON_ARRAY_LENGHT to JSON_ARRAY_LENGHT and ARRAY_LENGHT. JSON_ARRAY_LENGHT only accepts STRING type, ARRAY_LENGHT only accepts ArrayType.
Add TO_JSON_STRING: After the refactor of (1), we still need a method to convert JSON_ARRAY/JSON_OBJECT to valid JSON STRING. TO_JSON_STRING accepts both StructType and ArrayType as input and returns JSON formatted string.
Is your feature request related to a problem? A followup of https://github.com/opensearch-project/opensearch-spark/issues/667
Refactor
JSON
: Currently theJSON
evaluates STRING/JSON_ARRAY/JSON_OBJECT. It brings many confusions. In Splunk, the data could be stored as JSON object,JSON
function evaluates JSON object. But in Spark, there is no JSON object, but it contains STRING, StructType and ArrayType. So theJSON
function can only evaluate STRING types.ARRAY_LENGHT
: for the same reason above, we separateJSON_ARRAY_LENGHT
toJSON_ARRAY_LENGHT
andARRAY_LENGHT
.JSON_ARRAY_LENGHT
only accepts STRING type,ARRAY_LENGHT
only accepts ArrayType.Add
TO_JSON_STRING
: After the refactor of (1), we still need a method to convert JSON_ARRAY/JSON_OBJECT to valid JSON STRING.TO_JSON_STRING
accepts both StructType and ArrayType as input and returns JSON formatted string.