@@ -42,19 +42,27 @@ public abstract class PlanUtil {
42
42
private final static ObjectMapper objectMapper = new ObjectMapper ();
43
43
44
44
static ObjectNode buildGroupByCount () {
45
- return newOperation ("group-by" , args -> args
46
- .add (objectMapper .nullNode ())
47
- .addObject ().put ("ns" , "op" ).put ("fn" , "count" ).putArray ("args" ).add ("count" ).add (objectMapper .nullNode ()));
45
+ return newOperation ("group-by" , args -> {
46
+ args .add (objectMapper .nullNode ());
47
+ addCountArg (args );
48
+ });
48
49
}
49
50
50
51
static ObjectNode buildGroupByCount (String columnName ) {
51
52
return newOperation ("group-by" , args -> {
52
53
populateSchemaCol (args .addObject (), columnName );
53
- // Using "null" is the equivalent of "count(*)" - it counts rows, not values.
54
- args .addObject ().put ("ns" , "op" ).put ("fn" , "count" ).putArray ("args" ).add ("count" ).add (objectMapper .nullNode ());
54
+ addCountArg (args );
55
55
});
56
56
}
57
57
58
+ private static void addCountArg (ArrayNode args ) {
59
+ args .addObject ().put ("ns" , "op" ).put ("fn" , "count" ).putArray ("args" )
60
+ // "count" is used as the column name as that's what Spark uses when the operation is not pushed down.
61
+ .add ("count" )
62
+ // Using "null" is the equivalent of "count(*)" - it counts rows, not values.
63
+ .add (objectMapper .nullNode ());
64
+ }
65
+
58
66
static ObjectNode buildLimit (int limit ) {
59
67
return newOperation ("limit" , args -> args .add (limit ));
60
68
}
0 commit comments