Skip to content

Commit

Permalink
Updated java client side testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
lbooker42 committed Jan 15, 2025
1 parent eb7b3cf commit 18b9959
Showing 1 changed file with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ public UpdateByColumn.UpdateBySpec visit(CumProdSpec spec) {
.build();
}

@Override
public UpdateByColumn.UpdateBySpec visit(CumCountWhereSpec spec) {
return UpdateByColumn.UpdateBySpec.newBuilder()
.setCountWhere(UpdateByCumulativeCountWhere.newBuilder()
.setColumnName("count")
.addFilters("x > 5"))
.build();
}

@Override
public UpdateByColumn.UpdateBySpec visit(DeltaSpec spec) {
if (spec.deltaControl().isPresent()) {
Expand Down Expand Up @@ -321,8 +330,28 @@ public UpdateByColumn.UpdateBySpec visit(RollingFormulaSpec spec) {
.build())
.build();
}

@Override
public UpdateByColumn.UpdateBySpec visit(RollingCountWhereSpec spec) {
return UpdateByColumn.UpdateBySpec
.newBuilder().setRollingCountWhere(
UpdateByColumn.UpdateBySpec.UpdateByRollingCountWhere.newBuilder()
.setReverseWindowScale(UpdateByWindowScale.newBuilder()
.setTime(UpdateByWindowScale.UpdateByWindowTime.newBuilder()
.setColumn("Timestamp").setNanos(1).build())
.build())
.setForwardWindowScale(UpdateByWindowScale.newBuilder()
.setTime(UpdateByWindowScale.UpdateByWindowTime.newBuilder()
.setColumn("Timestamp").setNanos(1).build())
.build())
.setColumnName("count")
.addFilters("x > 5")
.build())
.build();
}
}


@Test
void ema() {
check(EmaSpec.ofTime("Timestamp", Duration.ofNanos(1)));
Expand Down Expand Up @@ -428,6 +457,11 @@ void cumulativeProd() {
check(CumProdSpec.of());
}

@Test
void cumulativeCountWhere() {
check(CumCountWhereSpec.of("count", "x > 5"));
}

@Test
void fillBy() {
check(FillBySpec.of());
Expand Down Expand Up @@ -658,6 +692,29 @@ void rollingFormula() {
.build());
}

@Test
void rollingCountWhere() {
check(RollingFormulaSpec.ofTime("Timestamp", Duration.ofNanos(1), Duration.ofNanos(2), "sum(x)", "x"),
UpdateByColumn.UpdateBySpec.newBuilder().setRollingFormula(
UpdateByColumn.UpdateBySpec.UpdateByRollingFormula.newBuilder()
.setReverseWindowScale(time("Timestamp", 1))
.setForwardWindowScale(time("Timestamp", 2))
.setFormula("sum(x)")
.setParamToken("x")
.build())
.build());

check(RollingFormulaSpec.ofTicks(42L, 43L, "sum(x)", "x"),
UpdateByColumn.UpdateBySpec.newBuilder().setRollingFormula(
UpdateByColumn.UpdateBySpec.UpdateByRollingFormula.newBuilder()
.setReverseWindowScale(ticks(42L))
.setForwardWindowScale(ticks(43L))
.setFormula("sum(x)")
.setParamToken("x")
.build())
.build());
}

private static void check(UpdateBySpec spec) {
check(spec, spec.walk(ExpectedSpecVisitor.INSTANCE));
}
Expand Down

0 comments on commit 18b9959

Please sign in to comment.