Skip to content

Commit

Permalink
Fix merge(qdigest) function
Browse files Browse the repository at this point in the history
Fixes mismatched annotations added in
ff24f6a, i.e. in v 383.
  • Loading branch information
findepi authored and martint committed Oct 13, 2022
1 parent 4d92a8e commit 80f8ed7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ private MergeQuantileDigestFunction() {}
@InputFunction
@TypeParameter("V")
public static void input(
@TypeParameter("V") Type type,
@TypeParameter("qdigest(V)") Type type,
@AggregationState QuantileDigestState state,
@BlockPosition @SqlType("V") Block value,
@BlockPosition @SqlType("qdigest(V)") Block value,
@BlockIndex int index)
{
merge(state, new QuantileDigest(type.getSlice(value, index)));
Expand Down Expand Up @@ -80,7 +80,7 @@ private static void merge(QuantileDigestState state, QuantileDigest input)

@OutputFunction("qdigest(V)")
public static void output(
@TypeParameter("V") Type type,
@TypeParameter("qdigest(V)") Type type,
@AggregationState QuantileDigestState state,
BlockBuilder out)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2096,6 +2096,29 @@ public void testP4ApproxSetGroupByWithNulls()
assertEqualsIgnoreOrder(actual.getMaterializedRows(), expected.getMaterializedRows());
}

@Test
public void testMergeQuantileDigest()
{
assertThat(query("""
WITH
a(field_a, field_b) AS (
VALUES (DOUBLE '10.3', 'group1'), (DOUBLE '11.3', 'group2')),
b AS (
SELECT CAST(qdigest_agg(field_a) AS varbinary) AS qdigest_binary
FROM a GROUP BY field_b)
SELECT CAST(merge(CAST(qdigest_binary AS qdigest(double))) AS varbinary)
FROM b"""))
.matches("""
VALUES X'
00 7b 14 ae 47 e1 7a 84 3f 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 9a 99 99 99 99 99 24
40 9a 99 99 99 99 99 26 40 03 00 00 00 00 00 00
00 00 00 00 f0 3f 9a 99 99 99 99 99 24 c0 00 00
00 00 00 00 00 f0 3f 9a 99 99 99 99 99 26 c0 c7
00 00 00 00 00 00 00 00 9a 99 99 99 99 99 24 c0'
""");
}

@Test
public void testValues()
{
Expand Down

0 comments on commit 80f8ed7

Please sign in to comment.