Slackbot
04/05/2023, 9:52 AMVadim
04/05/2023, 4:00 PMClint Wylie
04/05/2023, 7:15 PMClint Wylie
04/05/2023, 7:16 PMPark Hoon
04/06/2023, 1:27 AMtransform functions in druid’s the transform spec such as
• https://spark.apache.org/docs/latest/api/sql/index.html#transform
• https://spark.apache.org/docs/latest/api/sql/index.html#transform_keys
• https://spark.apache.org/docs/latest/api/sql/index.html#transform_valuesPark Hoon
04/06/2023, 1:27 AM> 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]
> 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}
> 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}Park Hoon
04/06/2023, 1:37 AMdf.selectExpr("transform_values(col1, (k,v) -> coalesce(v.a, v.b, v.c, v.d)) as col1").show()