数据框上的 Spark 过滤器,数组包含地图

Spark filter on dataframe with array containing a map

我有一个带有模式的数据框,其中有一个嵌套的地图值数组:

root
 |-- array_of_properties: array (nullable = true)
 |    |-- element: struct (containsNull = true)
 |    |    |-- name: string (nullable = true)
 |    |    |-- props: map (nullable = true)
 |    |    |    |-- key: string
 |    |    |    |-- value: string (valueContainsNull = true)

我需要过滤数组内映射中的结构名称和某些特定键的值。我可以过滤名称:

dataframe.filter(array_contains(col("array_of_properties.name"), "somename"))

如何在嵌套的 props 映射中对两个键的值添加 AND 过滤器(例如,布尔值为 true 或 false 的键名 is_enabled,以及键名source 字符串值为 test) ?

使用exists函数:

dataframe.filter("exists(array_of_properties, x -> x.name = 'somename' and x.props['is_enabled'] is true)")