Skip to content

Commit

Permalink
added test cases for distinct count map and array types
Browse files Browse the repository at this point in the history
Signed-off-by: chloe-zh <chloezh1102@gmail.com>
  • Loading branch information
chloe-zh committed Jul 27, 2021
1 parent f5cece5 commit 832e019
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,26 @@ public class AggregationTest extends ExpressionTestBase {

protected static List<ExprValue> tuples_with_duplicates =
Arrays.asList(
ExprValueUtils.tupleValue(ImmutableMap.of("integer_value", 1, "double_value", 4d)),
ExprValueUtils.tupleValue(ImmutableMap.of("integer_value", 1, "double_value", 3d)),
ExprValueUtils.tupleValue(ImmutableMap.of("integer_value", 2, "double_value", 2d)),
ExprValueUtils.tupleValue(ImmutableMap.of("integer_value", 3, "double_value", 1d)));
ExprValueUtils.tupleValue(ImmutableMap.of(
"integer_value", 1,
"double_value", 4d,
"struct_value", ImmutableMap.of("str", 1),
"array_value", ImmutableList.of(1))),
ExprValueUtils.tupleValue(ImmutableMap.of(
"integer_value", 1,
"double_value", 3d,
"struct_value", ImmutableMap.of("str", 1),
"array_value", ImmutableList.of(1))),
ExprValueUtils.tupleValue(ImmutableMap.of(
"integer_value", 2,
"double_value", 2d,
"struct_value", ImmutableMap.of("str", 2),
"array_value", ImmutableList.of(2))),
ExprValueUtils.tupleValue(ImmutableMap.of(
"integer_value", 3,
"double_value", 1d,
"struct_value", ImmutableMap.of("str1", 1),
"array_value", ImmutableList.of(1, 2))));

protected static List<ExprValue> tuples_with_null_and_missing =
Arrays.asList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,20 @@ public void filtered_distinct_count() {
assertEquals(2, result.value());
}

@Test
public void distinct_count_map() {
ExprValue result = aggregation(dsl.distinctCount(DSL.ref("struct_value", STRUCT)),
tuples_with_duplicates);
assertEquals(3, result.value());
}

@Test
public void distinct_count_array() {
ExprValue result = aggregation(dsl.distinctCount(DSL.ref("array_value", ARRAY)),
tuples_with_duplicates);
assertEquals(3, result.value());
}

@Test
public void count_with_missing() {
ExprValue result = aggregation(dsl.count(DSL.ref("integer_value", INTEGER)),
Expand Down

0 comments on commit 832e019

Please sign in to comment.