Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.deephaven.javascript.proto.dhinternal.io.deephaven_core.proto.table_pb.aggspec.AggSpecFirst;
import io.deephaven.javascript.proto.dhinternal.io.deephaven_core.proto.table_pb.aggspec.AggSpecLast;
import io.deephaven.javascript.proto.dhinternal.io.deephaven_core.proto.table_pb.aggspec.AggSpecMax;
import io.deephaven.javascript.proto.dhinternal.io.deephaven_core.proto.table_pb.aggspec.AggSpecMedian;
import io.deephaven.javascript.proto.dhinternal.io.deephaven_core.proto.table_pb.aggspec.AggSpecMin;
import io.deephaven.javascript.proto.dhinternal.io.deephaven_core.proto.table_pb.aggspec.AggSpecNonUniqueSentinel;
import io.deephaven.javascript.proto.dhinternal.io.deephaven_core.proto.table_pb.aggspec.AggSpecStd;
Expand Down Expand Up @@ -70,14 +71,15 @@ public class JsTotalsTableConfig {
LAST = "Last",
// ARRAY = "Array",
SKIP = "Skip";
private static final List<String> knownAggTypes = Arrays.asList(
protected static final List<String> knownAggTypes = Arrays.asList(
JsAggregationOperation.COUNT,
JsAggregationOperation.MIN,
JsAggregationOperation.MAX,
JsAggregationOperation.SUM,
JsAggregationOperation.ABS_SUM,
JsAggregationOperation.VAR,
JsAggregationOperation.AVG,
JsAggregationOperation.MEDIAN,
JsAggregationOperation.STD,
JsAggregationOperation.FIRST,
JsAggregationOperation.LAST,
Expand Down Expand Up @@ -357,6 +359,15 @@ public AggregateRequest buildRequest(JsArray<Column> allColumns) {
agg.setColumns(columns);
break;
}
case JsAggregationOperation.MEDIAN: {
AggSpec spec = new AggSpec();
spec.setMedian(new AggSpecMedian());
columns = new AggregationColumns();
columns.setSpec(spec);
columns.setMatchPairsList(aggColumns);
agg.setColumns(columns);
break;
}
case JsAggregationOperation.STD: {
AggSpec spec = new AggSpec();
spec.setStd(new AggSpecStd());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public class JsAggregationOperation {
* "Avg".
*/
AVG = "Avg",
/**
* The median of all values in the specified column. Can only apply to numeric types. String value is
* "Median".
*/
MEDIAN = "Median",
/**
* The sample standard deviation of all values in the specified column. Can only apply to numeric types.
* String value is "Std". Sample standard deviation is computed using Bessel's correction
Expand Down Expand Up @@ -111,6 +116,7 @@ public static boolean canAggregateType(String aggregationType, String columnType
case STD: {
return isNumeric(columnType);
}
case MEDIAN:
case MIN:
case MAX: {
// Can only apply to Comparables - JS can't work this out, so we'll stick to known types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
import io.deephaven.web.client.api.subscription.ViewportData;
import jsinterop.base.Js;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;

public class TotalsTableTestGwt extends AbstractAsyncGwtTestCase {
private final TableSourceBuilder tables = new TableSourceBuilder()
Expand Down Expand Up @@ -371,6 +374,33 @@ public void testGroupedTotals() {
.then(this::finish).catch_(this::report);
}

public void testCreateTotalsTableAggTypes() {
connect(tables)
.then(table("hasTotals"))
.then(table -> {
List<Supplier<Promise<JsTotalsTable>>> tests = new ArrayList<>();
List<String> aggs = JsTotalsTableConfig.knownAggTypes;
for (int i = 0; i < aggs.size(); i++) {
String operation = aggs.get(i);
JsTotalsTableConfig config = new JsTotalsTableConfig();
config.groupBy.push("K");
config.operationMap.set("J",
Js.uncheckedCast(new JsString[] {toJsString(operation)}));
tests.add(() -> table.getTotalsTable(config).then(totals -> {
totals.setViewport(0, 100, null, null, null);

return waitForEvent(totals, JsTable.EVENT_UPDATED, update -> {
ViewportData viewportData = (ViewportData) update.getDetail();
assertEquals(2, viewportData.getRows().length);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably include checks for the content of the cells in these rows, similar to the above test cases.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Colin asked for a test similar to HierarchicalTableTestGwt.testCreateRollupAggTypes, which looks like it iterates over all the agg types and checks that they work and send an update. Checking the data might be complicated because we are doing every agg, so the data will be different per agg.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some value checking.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Data checking in the rollup test doesnt exist either - the intention was just to make sure we could at least read every type, and that no supported agg causes a failure when passing it to the API.

}, 1500);
}));
}

return tests.stream().reduce((p1, p2) -> () -> p1.get().then(result -> p2.get())).get().get();
})
.then(this::finish).catch_(this::report);
}

private static class TotalsResults {
int k;
long i;
Expand Down