I have a dataframe that has a column which is an array of structs, like:
+-----+-----+------------------+---+----+
|index|state|entries |0 |1 |
+-----+-----+------------------+---+----+
|0 |KY |[[A, 45]] |45 |null|
|1 |OR |[[A, 30], [B, 10]]|30 |10 |
+-----+-----+------------------+---+----+
where "Entries" are structs with two fields, "name" and "number". I want to be able to grab one of those inner values at a particular index.
One way I could do this is:
df.withColumn(col("entries").getItem(0), "dumbName").select("dumbName.name")
I want to be able to do this with anonymous columns, though, so it would look more like
col("entries").getItem(0).someMagicFunction("name")