-
Notifications
You must be signed in to change notification settings - Fork 3
test: DH-19379 Added CountWhere operations #406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
921070f
dd4c5d8
fcb8cb2
4d8dcf0
cfd851a
49c8959
7104a1d
2961e99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /* Copyright (c) 2025-2025 Deephaven Data Labs and Patent Pending */ | ||
| package io.deephaven.benchmark.tests.standard.aggby; | ||
|
|
||
| import org.junit.jupiter.api.*; | ||
| import io.deephaven.benchmark.tests.standard.StandardTestRunner; | ||
|
|
||
| /** | ||
| * Standard tests for the countWhere table operation. Returns the number of rows for each group. | ||
| */ | ||
| public class CountWhereTest { | ||
| final StandardTestRunner runner = new StandardTestRunner(this); | ||
|
|
||
| @BeforeEach | ||
| void setup() { | ||
| runner.setRowFactor(6); | ||
| runner.tables("source"); | ||
|
|
||
| var setupStr = """ | ||
| from deephaven import agg | ||
|
|
||
| aggs=[agg.count_where(col="count", filters=["num1 > 3"])] | ||
| """; | ||
| runner.addSetupQuery(setupStr); | ||
| } | ||
|
|
||
| @Test | ||
| void countWhere1Group() { | ||
| runner.setScaleFactors(8, 7); | ||
| var q = "source.agg_by(aggs, by=['key1'])"; | ||
| runner.test("CountWhere-AggBy- 1 Group 100 Unique Vals", 100, q, "key1", "num1"); | ||
| } | ||
|
|
||
| @Test | ||
| void countWhere2Group() { | ||
| runner.setScaleFactors(3, 2); | ||
| var q = "source.agg_by(aggs, by=['key1', 'key2'])"; | ||
| runner.test("CountWhere-AggBy- 2 Groups 10K Unique Combos", 10100, q, "key1", "key2", "num1"); | ||
| } | ||
|
|
||
| @Test | ||
| void countWhere3Group() { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think 3groups testing is needed for CountWhere |
||
| runner.setScaleFactors(2, 1); | ||
| var q = "source.agg_by(aggs, by=['key1', 'key2', 'key3'])"; | ||
| runner.test("CountWhere-AggBy- 3 Groups 100K Unique Combos", 90900, q, "key1", "key2", "key3", "num1"); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* Copyright (c) 2025-2025 Deephaven Data Labs and Patent Pending */ | ||
| package io.deephaven.benchmark.tests.standard.updateby; | ||
|
|
||
| import org.junit.jupiter.api.*; | ||
| import io.deephaven.benchmark.tests.standard.StandardTestRunner; | ||
|
|
||
| /** | ||
| * Standard tests for the updateBy table operation. Calculates a cumulative countWhere for specified columns and places | ||
| * the result into a new column for each row. | ||
| */ | ||
| public class CumCountWhereTest { | ||
| final StandardTestRunner runner = new StandardTestRunner(this); | ||
|
|
||
| void setup(int rowFactor, int staticFactor, int incFactor) { | ||
| runner.setRowFactor(rowFactor); | ||
| runner.setScaleFactors(staticFactor, incFactor); | ||
| runner.tables("timed"); | ||
| runner.addSetupQuery("from deephaven.updateby import cum_count_where"); | ||
| } | ||
|
|
||
| @Test | ||
| void cumCountWhere0Group1Col() { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to test each filter type separately: Taking
Where each test uses the appropriate aggregation. |
||
| setup(5, 10, 10); | ||
| var q = "timed.update_by(ops=cum_count_where(col='X', filters=['num1 > 3']))"; | ||
| runner.test("CumCountWhere- No Groups 1 Col", q, "num1"); | ||
| } | ||
|
|
||
| @Test | ||
| void cumCountWhere1Group1Col() { | ||
| setup(3, 10, 2); | ||
| var q = "timed.update_by(ops=cum_count_where(col='X', filters=['num1 > 3']), by=['key1'])"; | ||
| runner.test("CumCountWhere- 1 Group 100 Unique Vals", q, "key1", "num1"); | ||
| } | ||
|
|
||
| @Test | ||
| void cumCountWhere2Groups1Col() { | ||
| setup(2, 3, 1); | ||
| var q = "timed.update_by(ops=cum_count_where(col='X', filters=['num1 > 3']), by=['key1','key2'])"; | ||
| runner.test("CumCountWhere- 2 Groups 10K Unique Combos", q, "key1", "key2", "num1"); | ||
| } | ||
|
|
||
| @Test | ||
| void cumCountWhere3Groups1Col() { | ||
| setup(1, 3, 1); | ||
| var q = "timed.update_by(ops=cum_count_where(col='X', filters=['num1 > 3']), by=['key1','key2','key3'])"; | ||
| runner.test("CumCountWhere- 3 Groups 100K Unique Combos", q, "key1", "key2", "key3", "num1"); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /* Copyright (c) 2025-2025 Deephaven Data Labs and Patent Pending */ | ||
| package io.deephaven.benchmark.tests.standard.updateby; | ||
|
|
||
| import org.junit.jupiter.api.*; | ||
| import io.deephaven.benchmark.tests.standard.StandardTestRunner; | ||
|
|
||
| /** | ||
| * Standard tests for the updateBy table operation. Defines a tick-based rolling countWhere. The result table contains | ||
| * an additional column with windowed rolling countWhere. | ||
| * <p> | ||
| * Note: This test must contain benchmarks and <code>rev_ticks/fwd_ticks</code> that are comparable to | ||
| * <code>RollingCountWhereTimeTest</code> | ||
| */ | ||
| public class RollingCountWhereTickTest { | ||
| final StandardTestRunner runner = new StandardTestRunner(this); | ||
| final Setup setup = new Setup(runner); | ||
| final String thousands = """ | ||
| from deephaven.updateby import rolling_count_where_tick | ||
| contains_row = rolling_count_where_tick('X',filters=["num1 > 3"],rev_ticks=2000,fwd_ticks=3000) | ||
| """; | ||
| final String fifty = """ | ||
| from deephaven.updateby import rolling_count_where_tick | ||
| contains_row = rolling_count_where_tick('X',filters=["num1 > 3"],rev_ticks=20,fwd_ticks=30) | ||
| """; | ||
|
|
||
| @Test | ||
| void rollingCountWhereTick0Group3Ops() { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to test each filter type separately: Taking
Where each test uses the appropriate aggregation. |
||
| setup.factors(5, 8, 8); | ||
| runner.addSetupQuery(thousands); | ||
| var q = "timed.update_by(ops=[contains_row])"; | ||
| runner.test("RollingCountWhereTick- No Groups 1 Col", q, "num1"); | ||
| } | ||
|
|
||
| @Test | ||
| void rollingCountWhereTick1Group3Ops() { | ||
| setup.factors(5, 4, 1); | ||
| runner.addSetupQuery(fifty); | ||
| var q = "timed.update_by(ops=[contains_row], by=['key1'])"; | ||
| runner.test("RollingCountWhereTick- 1 Group 100 Unique Vals", q, "key1", "num1"); | ||
| } | ||
|
|
||
| @Test | ||
| void rollingCountWhereTick2Groups3Ops() { | ||
| setup.factors(2, 3, 1); | ||
| runner.addSetupQuery(fifty); | ||
| var q = "timed.update_by(ops=[contains_row], by=['key1','key2'])"; | ||
| runner.test("RollingCountWhereTick- 2 Groups 10K Unique Combos", q, "key1", "key2", "num1"); | ||
| } | ||
|
|
||
| @Test | ||
| void rollingCountWhereTick3Groups3Ops() { | ||
| setup.factors(1, 3, 1); | ||
| runner.addSetupQuery(fifty); | ||
| var q = "timed.update_by(ops=[contains_row], by=['key1','key2','key3'])"; | ||
| runner.test("RollingCountWhereTick- 3 Groups 100K Unique Combos", q, "key1", "key2", "key3", "num1"); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /* Copyright (c) 2025-2025 Deephaven Data Labs and Patent Pending */ | ||
| package io.deephaven.benchmark.tests.standard.updateby; | ||
|
|
||
| import org.junit.jupiter.api.*; | ||
| import io.deephaven.benchmark.tests.standard.StandardTestRunner; | ||
|
|
||
| /** | ||
| * Standard tests for the updateBy table operation. Defines a time-based rolling countWhere. The result table contains | ||
| * an additional column with windowed rolling countWhere. | ||
| * <p> | ||
| * Note: This test must contain benchmarks and <code>rev_time/fwd_time</code> that are comparable to | ||
| * <code>RollingCountWhereTickTest</code> | ||
| */ | ||
| public class RollingCountWhereTimeTest { | ||
| final StandardTestRunner runner = new StandardTestRunner(this); | ||
| final Setup setup = new Setup(runner); | ||
| final String thousands = """ | ||
| from deephaven.updateby import rolling_count_where_time | ||
| contains_row = rolling_count_where_time("timestamp",'X',filters=["num1 > 3"],rev_time="PT2S",fwd_time="PT3S") | ||
| """; | ||
| final String fifty1Group = """ | ||
| from deephaven.updateby import rolling_count_where_time | ||
| contains_row = rolling_count_where_time("timestamp",'X',filters=["num1 > 3"],rev_time="PT2S",fwd_time="PT3S") | ||
| """; | ||
| final String fifty2Groups = """ | ||
| from deephaven.updateby import rolling_count_where_time | ||
| contains_row = rolling_count_where_time("timestamp",'X',filters=["num1 > 3"],rev_time="PT4M",fwd_time="PT5M") | ||
| """; | ||
| final String fifty3Groups = """ | ||
| from deephaven.updateby import rolling_count_where_time | ||
| contains_row = rolling_count_where_time("timestamp",'X',filters=["num1 > 3"],rev_time="PT40M",fwd_time="PT50M") | ||
| """; | ||
|
|
||
| @Test | ||
| void rollingCountWhereTime0Group3Ops() { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to test each filter type separately: Taking
Where each test uses the appropriate aggregation. |
||
| setup.factors(5, 4, 3); | ||
| runner.addSetupQuery(thousands); | ||
| var q = "timed.update_by(ops=[contains_row])"; | ||
| runner.test("RollingCountWhereTime- No Groups 1 Col", q, "num1", "timestamp"); | ||
| } | ||
|
|
||
| @Test | ||
| void rollingCountWhereTime1Group3Ops() { | ||
| setup.factors(4, 2, 1); | ||
| runner.addSetupQuery(fifty1Group); | ||
| var q = "timed.update_by(ops=[contains_row], by=['key1'])"; | ||
| runner.test("RollingCountWhereTime- 1 Group 100 Unique Vals", q, "key1", "num1", "timestamp"); | ||
| } | ||
|
|
||
| @Test | ||
| void rollingCountWhereTime2Groups3Ops() { | ||
| setup.factors(2, 2, 1); | ||
| runner.addSetupQuery(fifty2Groups); | ||
| var q = "timed.update_by(ops=[contains_row], by=['key1','key2'])"; | ||
| runner.test("RollingCountWhereTime- 2 Groups 10K Unique Combos", q, "key1", "key2", "num1", "timestamp"); | ||
| } | ||
|
|
||
| @Test | ||
| void rollingCountWhereTime3Groups3Ops() { | ||
| setup.factors(1, 3, 1); | ||
| runner.addSetupQuery(fifty3Groups); | ||
| var q = "timed.update_by(ops=[contains_row], by=['key1','key2','key3'])"; | ||
| runner.test("RollingCountWhereTime- 3 Groups 100K Unique Combos", q, "key1", "key2", "key3", "num1", "timestamp"); | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to add a few more aggs for testing. Specifically, a conditional (something like
num1 % 3 == 0), then AND / OR filters.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to test each filter type separately:
Taking
countWhere1Groupas an example, we should have four tests:Where each test uses the appropriate aggregation.