Hi, team. I need to write UDF that extract data fr...
# questions-and-troubleshooting
a
Hi, team. I need to write UDF that extract data from JSON by specific path with 3 different last/leaf fields for different queries (there is complex manipulation with values, but it's not important for this question). For example:
Copy code
{a: 1, b: {aa:2, bb:3, cc:4}}
I need in one query get aa, into another bb, etc. Instead of creation 3 UDFs with
extractAaFromMyJson
,
extractBbFromMyJson
and
extractCcFromMyJson
with hardcoded full path, my first intention to create
extractFromMyJson
function with hardcoded first path part and second part defined as second argument
leaveField
. And call
Copy code
extractFromMyJson(data, 'aa')
etc Can usage of constant as UDF argument affect performance some way?
r
Hi, are the JSONs you're trying to extract coming from inside StarRocks tables or insertion? Is it possible to use the built-in json parser functions provided by StarRocks? https://docs.starrocks.io/docs/3.5/category/json-query-and-processing/
a
@Robert Raharjo thank you so much for answer! I'm SO SORRY for the inconvenience. Wrong Slack server. I wanted to ask Flink community (what we use to load data into Starrocks storage). 🤦