Hi, team. I need to write a UDF that extracts data from JSON using a specific 
path with three different leaf fields for various queries. While there is 
complex manipulation with values, that detail is not relevant here.

For example:  
{a: 1, b: {aa: 2, bb: 3, cc: 4}}

I want to retrieve the value of aa in one query, bb in another, and so on. 
Instead of creating three UDFs—extractAaFromMyJson, extractBbFromMyJson, and 
extractCcFromMyJson—with hardcoded paths, I plan to create a single function, 
extractFromMyJson, that has a hardcoded first path part and takes the second 
part as an argument, leaveField. I would call it like this:

extractFromMyJson(data, 'aa')  
etc.

Can using a constant as a UDF argument affect performance in any way?

Thank you!
With best regards, Alexey.

———
Alexey Sanko
Principle Data Engineer
Data Experience Enablement Team
He/His



Reply via email to