This message was deleted.
# general
s
This message was deleted.
v
No, there isn't a way to do it in bulk, you would have to spell out the name of every key but doing that defeats the purpose of the COMPLEX<json> type
c
i suppose we could add customization options to lower or uppercase the keys someday if that’s a common need, or a transform function for it 🤷
or maybe an option store them case insensitive or something
p
Here are examples.
Copy code
> SELECT transform(array(1, 2, 3), x -> x + 1);
 [2,3,4]
> SELECT transform(array(1, 2, 3), (x, i) -> x + i);
 [1,3,5]
Copy code
> SELECT transform_keys(map_from_arrays(array(1, 2, 3), array(1, 2, 3)), (k, v) -> k + 1);
 {2:1,3:2,4:3}
> SELECT transform_keys(map_from_arrays(array(1, 2, 3), array(1, 2, 3)), (k, v) -> k + v);
 {2:1,4:2,6:3}
Copy code
> SELECT transform_values(map_from_arrays(array(1, 2, 3), array(1, 2, 3)), (k, v) -> v + 1);
 {1:2,2:3,3:4}
> SELECT transform_values(map_from_arrays(array(1, 2, 3), array(1, 2, 3)), (k, v) -> k + v);
 {1:2,2:4,3:6}
Those transform functions also accept a map parameter.
Copy code
df.selectExpr("transform_values(col1, (k,v) -> coalesce(v.a, v.b, v.c, v.d)) as col1").show()