Skip to content

Commit d9ef739

Browse files
authored
feat: DH-19379 Added CountWhere operations (#406)
* Added CountWhere operations * Remove unnessary num2 * fixed some test method names * Add more filters to CumCountWhere, remove 0 group and some Incs from others
1 parent 513e226 commit d9ef739

File tree

6 files changed

+185
-1
lines changed

6 files changed

+185
-1
lines changed

.github/distro/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ services:
55
- "${DEEPHAVEN_PORT:-10000}:10000"
66
volumes:
77
- ./data:/data
8+
- ./minio:/minio
89
environment:
910
- "START_OPTS=-Xmx24G -DAuthHandlers=io.deephaven.auth.AnonymousAuthenticationHandler"
1011

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* Copyright (c) 2025-2026 Deephaven Data Labs and Patent Pending */
2+
package io.deephaven.benchmark.tests.standard.aggby;
3+
4+
import org.junit.jupiter.api.*;
5+
import io.deephaven.benchmark.tests.standard.StandardTestRunner;
6+
7+
/**
8+
* Standard tests for the countWhere table operation. Returns the number of rows for each group.
9+
*/
10+
public class CountWhereTest {
11+
final StandardTestRunner runner = new StandardTestRunner(this);
12+
13+
@BeforeEach
14+
void setup() {
15+
runner.setRowFactor(6);
16+
runner.tables("source");
17+
18+
var setupStr = "from deephaven import agg";
19+
runner.addSetupQuery(setupStr);
20+
}
21+
22+
@Test
23+
void countWhere1Group() {
24+
runner.setScaleFactors(9, 0);
25+
var q = "source.agg_by([agg.count_where(col='count', filters=['num1 > 3'])], by=['key1'])";
26+
runner.test("CountWhere-AggBy- Range 1 Group 100 Unique Vals", 100, q, "key1", "num1");
27+
}
28+
29+
@Test
30+
void countWhere2Group() {
31+
runner.setScaleFactors(3, 2);
32+
var q = "source.agg_by([agg.count_where(col='count', filters=['num1 % 3 = 0'])], by=['key1', 'key2'])";
33+
runner.test("CountWhere-AggBy- Equals 2 Groups 10K Unique Combos", 10100, q, "key1", "key2", "num1");
34+
}
35+
36+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/* Copyright (c) 2025-2026 Deephaven Data Labs and Patent Pending */
2+
package io.deephaven.benchmark.tests.standard.updateby;
3+
4+
import org.junit.jupiter.api.*;
5+
import io.deephaven.benchmark.tests.standard.StandardTestRunner;
6+
7+
/**
8+
* Standard tests for the updateBy table operation. Calculates a cumulative countWhere for specified columns and places
9+
* the result into a new column for each row.
10+
*/
11+
public class CumCountWhereTest {
12+
final StandardTestRunner runner = new StandardTestRunner(this);
13+
14+
void setup(int rowFactor, int staticFactor, int incFactor) {
15+
runner.setRowFactor(rowFactor);
16+
runner.setScaleFactors(staticFactor, incFactor);
17+
runner.tables("timed");
18+
runner.addSetupQuery("""
19+
from deephaven.updateby import cum_count_where
20+
from deephaven.filters import or_
21+
""");
22+
}
23+
24+
@Test
25+
void cumCountWhereRange0Group1Col() {
26+
setup(5, 10, 0);
27+
var q = "timed.update_by(ops=cum_count_where(col='X', filters=['num1 > 3']))";
28+
runner.test("CumCountWhere- Range No Groups 1 Col", q, "num1");
29+
}
30+
31+
@Test
32+
void cumCountWhereEquals0Group1Col() {
33+
setup(5, 8, 0);
34+
var q = "timed.update_by(ops=cum_count_where(col='X', filters=['num1 % 3 = 0']))";
35+
runner.test("CumCountWhere- Equals No Groups 1 Col", q, "num1");
36+
}
37+
38+
@Test
39+
void cumCountWhereAnd0Group1Col() {
40+
setup(5, 10, 0);
41+
var q = "timed.update_by(ops=cum_count_where(col='X', filters=['num1 > 3','num1 % 3 = 0']))";
42+
runner.test("CumCountWhere- And No Groups 1 Col", q, "num1");
43+
}
44+
45+
@Test
46+
void cumCountWhereOr0Group1Col() {
47+
setup(5, 3, 0);
48+
var q = "timed.update_by(ops=cum_count_where(col='X', filters=or_(['num1 > 3','num1 % 3 = 0'])))";
49+
runner.test("CumCountWhere- Or No Groups 1 Col", q, "num1");
50+
}
51+
52+
@Test
53+
void cumCountWhereRange1Group1Col() {
54+
setup(3, 10, 0);
55+
var q = "timed.update_by(ops=cum_count_where(col='X', filters=['num1 > 3']), by=['key1'])";
56+
runner.test("CumCountWhere- Range 1 Group 100 Unique Vals", q, "key1", "num1");
57+
}
58+
59+
@Test
60+
void cumCountWhereEquals2Groups1Col() {
61+
setup(2, 3, 1);
62+
var q = "timed.update_by(ops=cum_count_where(col='X', filters=['num1 % 3 = 0']), by=['key1','key2'])";
63+
runner.test("CumCountWhere- Equals 2 Groups 10K Unique Combos", q, "key1", "key2", "num1");
64+
}
65+
66+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* Copyright (c) 2025-2026 Deephaven Data Labs and Patent Pending */
2+
package io.deephaven.benchmark.tests.standard.updateby;
3+
4+
import org.junit.jupiter.api.*;
5+
import io.deephaven.benchmark.tests.standard.StandardTestRunner;
6+
7+
/**
8+
* Standard tests for the updateBy table operation. Defines a tick-based rolling countWhere. The result table contains
9+
* an additional column with windowed rolling countWhere.
10+
* <p>
11+
* Note: This test must contain benchmarks and <code>rev_ticks/fwd_ticks</code> that are comparable to
12+
* <code>RollingCountWhereTimeTest</code>
13+
*/
14+
public class RollingCountWhereTickTest {
15+
final StandardTestRunner runner = new StandardTestRunner(this);
16+
final Setup setup = new Setup(runner);
17+
final String fifty = """
18+
from deephaven.updateby import rolling_count_where_tick
19+
contains_row = rolling_count_where_tick('X',filters=["num1 > 3"],rev_ticks=20,fwd_ticks=30)
20+
""";
21+
22+
23+
@Test
24+
void rollingCountWhereTick1Group3Ops() {
25+
setup.factors(5, 4, 0);
26+
runner.addSetupQuery(fifty);
27+
var q = "timed.update_by(ops=[contains_row], by=['key1'])";
28+
runner.test("RollingCountWhereTick- 1 Group 100 Unique Vals", q, "key1", "num1");
29+
}
30+
31+
@Test
32+
void rollingCountWhereTick2Groups3Ops() {
33+
setup.factors(2, 3, 1);
34+
runner.addSetupQuery(fifty);
35+
var q = "timed.update_by(ops=[contains_row], by=['key1','key2'])";
36+
runner.test("RollingCountWhereTick- 2 Groups 10K Unique Combos", q, "key1", "key2", "num1");
37+
}
38+
39+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* Copyright (c) 2025-2026 Deephaven Data Labs and Patent Pending */
2+
package io.deephaven.benchmark.tests.standard.updateby;
3+
4+
import org.junit.jupiter.api.*;
5+
import io.deephaven.benchmark.tests.standard.StandardTestRunner;
6+
7+
/**
8+
* Standard tests for the updateBy table operation. Defines a time-based rolling countWhere. The result table contains
9+
* an additional column with windowed rolling countWhere.
10+
* <p>
11+
* Note: This test must contain benchmarks and <code>rev_time/fwd_time</code> that are comparable to
12+
* <code>RollingCountWhereTickTest</code>
13+
*/
14+
public class RollingCountWhereTimeTest {
15+
final StandardTestRunner runner = new StandardTestRunner(this);
16+
final Setup setup = new Setup(runner);
17+
final String fifty1Group = """
18+
from deephaven.updateby import rolling_count_where_time
19+
contains_row = rolling_count_where_time("timestamp",'X',filters=["num1 > 3"],rev_time="PT2S",fwd_time="PT3S")
20+
""";
21+
final String fifty2Groups = """
22+
from deephaven.updateby import rolling_count_where_time
23+
contains_row = rolling_count_where_time("timestamp",'X',filters=["num1 > 3"],rev_time="PT4M",fwd_time="PT5M")
24+
""";
25+
26+
@Test
27+
void rollingCountWhereTime1Group3Ops() {
28+
setup.factors(4, 2, 0);
29+
runner.addSetupQuery(fifty1Group);
30+
var q = "timed.update_by(ops=[contains_row], by=['key1'])";
31+
runner.test("RollingCountWhereTime- 1 Group 100 Unique Vals", q, "key1", "num1", "timestamp");
32+
}
33+
34+
@Test
35+
void rollingCountWhereTime2Groups3Ops() {
36+
setup.factors(2, 2, 1);
37+
runner.addSetupQuery(fifty2Groups);
38+
var q = "timed.update_by(ops=[contains_row], by=['key1','key2'])";
39+
runner.test("RollingCountWhereTime- 2 Groups 10K Unique Combos", q, "key1", "key2", "num1", "timestamp");
40+
}
41+
42+
}

src/main/resources/io/deephaven/benchmark/run/profile/queries/publish.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
with urlopen(root + '/deephaven-benchmark/benchmark_tables.dh.py') as r:
1010
benchmark_storage_uri_arg = root + '/deephaven-benchmark'
1111
benchmark_category_arg = 'nightly' # release | nightly
12-
benchnark_max_sets_arg = 45
12+
benchmark_max_sets_arg = 45
1313
benchmark_actor_filter_arg = 'deephaven'
1414
benchmark_set_filter_arg = '[0-9]{4}([-][0-9]{2}){2}' # yyyy-mm-dd
1515
exec(r.read().decode(), globals(), locals())

0 commit comments

Comments
 (0)