@@ -27,19 +27,27 @@ public abstract class PlanUtil {
27
27
private final static ObjectMapper objectMapper = new ObjectMapper ();
28
28
29
29
static ObjectNode buildGroupByCount () {
30
- return newOperation ("group-by" , args -> args
31
- .add (objectMapper .nullNode ())
32
- .addObject ().put ("ns" , "op" ).put ("fn" , "count" ).putArray ("args" ).add ("count" ).add (objectMapper .nullNode ()));
30
+ return newOperation ("group-by" , args -> {
31
+ args .add (objectMapper .nullNode ());
32
+ addCountArg (args );
33
+ });
33
34
}
34
35
35
36
static ObjectNode buildGroupByCount (String columnName ) {
36
37
return newOperation ("group-by" , args -> {
37
38
populateSchemaCol (args .addObject (), columnName );
38
- // Using "null" is the equivalent of "count(*)" - it counts rows, not values.
39
- args .addObject ().put ("ns" , "op" ).put ("fn" , "count" ).putArray ("args" ).add ("count" ).add (objectMapper .nullNode ());
39
+ addCountArg (args );
40
40
});
41
41
}
42
42
43
+ private static void addCountArg (ArrayNode args ) {
44
+ args .addObject ().put ("ns" , "op" ).put ("fn" , "count" ).putArray ("args" )
45
+ // "count" is used as the column name as that's what Spark uses when the operation is not pushed down.
46
+ .add ("count" )
47
+ // Using "null" is the equivalent of "count(*)" - it counts rows, not values.
48
+ .add (objectMapper .nullNode ());
49
+ }
50
+
43
51
static ObjectNode buildLimit (int limit ) {
44
52
return newOperation ("limit" , args -> args .add (limit ));
45
53
}
0 commit comments