-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#6497 merged with an error where the `rollup` `count_where` aggregation was aliased to the regular `count_` aggregation. This PR corrects that mistake.
- Loading branch information
Showing
3 changed files
with
169 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
engine/table/src/test/java/io/deephaven/engine/table/impl/TestRollup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
// | ||
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending | ||
// | ||
package io.deephaven.engine.table.impl; | ||
|
||
import io.deephaven.api.agg.Aggregation; | ||
import io.deephaven.engine.table.Table; | ||
import io.deephaven.engine.table.hierarchical.RollupTable; | ||
import io.deephaven.engine.testutil.*; | ||
import io.deephaven.engine.testutil.generator.*; | ||
import io.deephaven.engine.testutil.testcase.RefreshingTableTestCase; | ||
import io.deephaven.test.types.OutOfBandTest; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
|
||
import java.util.*; | ||
|
||
import static io.deephaven.api.agg.Aggregation.*; | ||
import static io.deephaven.engine.testutil.TstUtils.*; | ||
|
||
@Category(OutOfBandTest.class) | ||
public class TestRollup extends RefreshingTableTestCase { | ||
// This is the list of supported aggregations for rollup. These are all using `intCol` as the column to aggregate | ||
// because the re-aggregation logic is effectively the same for all column types. | ||
private final Collection<Aggregation> aggs = List.of( | ||
AggAbsSum("absSum=intCol"), | ||
AggAvg("avg=intCol"), | ||
AggCount("count"), | ||
AggCountWhere("countWhere", "intCol > 50"), | ||
AggCountDistinct("countDistinct=intCol"), | ||
AggDistinct("distinct=intCol"), | ||
AggFirst("first=intCol"), | ||
AggLast("last=intCol"), | ||
AggMax("max=intCol"), | ||
AggMin("min=intCol"), | ||
AggSortedFirst("Sym", "firstSorted=intCol"), | ||
AggSortedLast("Sym", "lastSorted=intCol"), | ||
AggStd("std=intCol"), | ||
AggSum("sum=intCol"), | ||
AggUnique("unique=intCol"), | ||
AggVar("var=intCol"), | ||
AggWAvg("intCol", "wavg=intCol"), | ||
AggWSum("intCol", "wsum=intCol")); | ||
|
||
// Companion list of columns to compare between rollup root and the zero-key equivalent | ||
private final String[] columnsToCompare = new String[] { | ||
"absSum", | ||
"avg", | ||
"count", | ||
"countWhere", | ||
"countDistinct", | ||
"distinct", | ||
"first", | ||
"last", | ||
"max", | ||
"min", | ||
"firstSorted", | ||
"lastSorted", | ||
"std", | ||
"sum", | ||
"unique", | ||
"var", | ||
"wavg", | ||
"wsum" | ||
}; | ||
|
||
@SuppressWarnings("rawtypes") | ||
private final ColumnInfo[] columnInfo = initColumnInfos( | ||
new String[] {"Sym", "intCol"}, | ||
new SetGenerator<>("a", "b", "c", "d"), | ||
new IntGenerator(10, 100)); | ||
|
||
private QueryTable createTable(boolean refreshing, int size, Random random) { | ||
return getTable(refreshing, size, random, columnInfo); | ||
} | ||
|
||
@Override | ||
public void setUp() throws Exception { | ||
super.setUp(); | ||
} | ||
|
||
@Test | ||
public void testRollup() { | ||
final Random random = new Random(0); | ||
// Create the test table | ||
final Table testTable = createTable(false, 100_000, random); | ||
|
||
final RollupTable rollupTable = testTable.rollup(aggs, false, "Sym"); | ||
final Table rootTable = rollupTable.getRoot(); | ||
|
||
final Table actual = rootTable.select(columnsToCompare); | ||
final Table expected = testTable.aggBy(aggs); | ||
|
||
// Compare the zero-key equivalent table to the rollup table root | ||
TstUtils.assertTableEquals(actual, expected); | ||
} | ||
|
||
@Test | ||
public void testRollupIncremental() { | ||
for (int size = 10; size <= 1000; size *= 10) { | ||
testRollupIncrementalInternal("size-" + size, size); | ||
} | ||
} | ||
|
||
private void testRollupIncrementalInternal(final String ctxt, final int size) { | ||
final Random random = new Random(0); | ||
|
||
final QueryTable testTable = createTable(true, size * 10, random); | ||
EvalNuggetInterface[] en = new EvalNuggetInterface[] { | ||
new QueryTableTest.TableComparator( | ||
testTable.rollup(aggs, false, "Sym") | ||
.getRoot().select(columnsToCompare), | ||
testTable.aggBy(aggs)) | ||
}; | ||
|
||
final int steps = 100; | ||
for (int step = 0; step < steps; step++) { | ||
if (RefreshingTableTestCase.printTableUpdates) { | ||
System.out.println("Step = " + step); | ||
} | ||
simulateShiftAwareStep(ctxt + " step == " + step, size, random, testTable, columnInfo, en); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters