Skip to content

Commit

Permalink
Optimize MapNormalize
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikalur committed Mar 14, 2024
1 parent 0572190 commit 1b1f005
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ private MapNormalizeFunction() {}
@SqlType("map<varchar, double>")
public static String arraySumDouble()
{
return "RETURN transform_values(input, (k, v) -> (v / reduce(map_values(input), double '0.0', (s, x) -> (s + coalesce(x, double '0.0')), (s) -> s)))";
return "RETURN " +
"transform(array[ROW(input, reduce(map_values(input), double '0.0', (s, x) -> (s + coalesce(x, double '0.0')), (s) -> s))], " +
"x->transform_values(x[1], (k, v) -> (v / x[2])))[1]";
}
}

0 comments on commit 1b1f005

Please sign in to comment.