|
| 1 | +/* Copyright (c) 2022-2025 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 formula. The result table contains |
| 9 | + * additional columns with windowed rolling formulas for each specified column in the source table. |
| 10 | + * <p> |
| 11 | + * Note: This test must contain benchmarks and <code>rev_time/fwd_time</code> that are comparable to |
| 12 | + * <code>RollingFormulaTickTest</code> |
| 13 | + */ |
| 14 | +public class RollingFormulaTimeTest { |
| 15 | + final StandardTestRunner runner = new StandardTestRunner(this); |
| 16 | + final Setup setup = new Setup(runner); |
| 17 | + |
| 18 | + void setup(int rowFactor, int staticFactor, int incFactor) { |
| 19 | + runner.setRowFactor(rowFactor); |
| 20 | + runner.setScaleFactors(staticFactor, incFactor); |
| 21 | + runner.tables("timed"); |
| 22 | + var s = """ |
| 23 | + from deephaven.updateby import rolling_formula_time |
| 24 | + """; |
| 25 | + runner.addSetupQuery(s); |
| 26 | + } |
| 27 | + |
| 28 | + @Test |
| 29 | + void rollingFormulaParamTime2Groups3Ops() { |
| 30 | + setup(2, 2, 1); |
| 31 | + runner.addSetupQuery(""" |
| 32 | + contains = rolling_formula_time(formula="avg(x)", formula_param="x", ts_col="timestamp", |
| 33 | + cols=["Contains=num1"], rev_time="PT4M", fwd_time="PT5M") |
| 34 | + """); |
| 35 | + var q = "timed.update_by(ops=[contains], by=['key1','key2'])"; |
| 36 | + runner.test("RollingFormulaTime- 2 Groups 10K Unique Combos", q, "key1", "key2", "num1", "timestamp"); |
| 37 | + } |
| 38 | + |
| 39 | + @Test |
| 40 | + void rollingFormulaGeneralTime0Group3Ops() { |
| 41 | + setup(1, 1, 1); |
| 42 | + runner.addSetupQuery(""" |
| 43 | + contains = rolling_formula_time(formula="Contains=avg(num1)", ts_col="timestamp", rev_time="PT2S", |
| 44 | + fwd_time="PT3S") |
| 45 | + """); |
| 46 | + var q = "timed.update_by(ops=[contains])"; |
| 47 | + runner.test("RollingFormulaGeneralTime- No Groups 1 Col", q, "num1", "timestamp"); |
| 48 | + } |
| 49 | + |
| 50 | + @Test |
| 51 | + void rollingFormulaGeneralTime1Group3Ops() { |
| 52 | + setup(3, 2, 1); |
| 53 | + runner.addSetupQuery(""" |
| 54 | + contains = rolling_formula_time(formula="Contains=avg(num1)", ts_col="timestamp", rev_time="PT2S", |
| 55 | + fwd_time="PT3S") |
| 56 | + """); |
| 57 | + var q = "timed.update_by(ops=[contains], by=['key1'])"; |
| 58 | + runner.test("RollingFormulaGeneralTime- 1 Group 100 Unique Vals", q, "key1", "num1", "timestamp"); |
| 59 | + } |
| 60 | + |
| 61 | + @Test |
| 62 | + void rollingFormulaGeneralTime2Groups3Ops() { |
| 63 | + setup(2, 2, 1); |
| 64 | + runner.addSetupQuery(""" |
| 65 | + contains = rolling_formula_time(formula="Contains=avg(num1)", ts_col="timestamp", rev_time="PT4M", |
| 66 | + fwd_time="PT5M") |
| 67 | + """); |
| 68 | + var q = "timed.update_by(ops=[contains], by=['key1','key2'])"; |
| 69 | + runner.test("RollingFormulaGeneralTime- 2 Groups 10K Unique Combos", q, "key1", "key2", "num1", "timestamp"); |
| 70 | + } |
| 71 | + |
| 72 | +} |
0 commit comments