Skip to content
Advertisement

how do we check if an element in the array exists and if it has a value of “true” in Presto

The data in the array looks like XXXX:”False”. I used

element_at(array_name,'Field') and contains(map_keys(array_name),'Field'). They only check if the element is present in the array. But if the ‘Field’ has a value of ‘true’, How do i check that value?

Advertisement

Answer

Assuming that you have a map at hand, and that you want to check the value of of a given key, you can just use element_at():

where element_at(array_name, 'Field') = 'True'
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement