Skip to content

Commit 7eeccaf

Browse files
committed
Added comment to clarify the "count" label
1 parent 4bd1d50 commit 7eeccaf

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/main/java/com/marklogic/spark/reader/PlanUtil.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,27 @@ public abstract class PlanUtil {
2727
private final static ObjectMapper objectMapper = new ObjectMapper();
2828

2929
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+
});
3334
}
3435

3536
static ObjectNode buildGroupByCount(String columnName) {
3637
return newOperation("group-by", args -> {
3738
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);
4040
});
4141
}
4242

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+
4351
static ObjectNode buildLimit(int limit) {
4452
return newOperation("limit", args -> args.add(limit));
4553
}

0 commit comments

Comments
 (0)