Skip to content

Commit

Permalink
eval: improve offset validation (Netflix#1600)
Browse files Browse the repository at this point in the history
Check each data expression to catch some uses of named
rewrites where the offset is not available on the display
expression.
  • Loading branch information
brharrington authored and manolama committed May 22, 2024
1 parent 3376c40 commit 6996d19
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ private[stream] class ExprInterpreter(config: Config) {
case op: FilterExpr => invalidOperator(op); op
case op: DataExpr if !op.offset.isZero => invalidOperator(op); op
}

// Double check all data expressions do not have an offset. In some cases for named rewrites
// the check above may not detect the offset.
result.expr.dataExprs.filterNot(_.offset.isZero).foreach(invalidOperator)
}

// Perform host rewrites based on the Atlas hostname
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,14 @@ class EvaluatorSuite extends FunSuite {
invalidOperator("offset", "name,jvm.gc.pause,:eq,:sum,1w,:offset")
}

test("validate: unsupported operation `:offset` with math") {
invalidOperator("offset", "name,a,:eq,:sum,:dup,1w,:offset,:div")
}

test("validate: unsupported operation `:offset` with named rewrite and math") {
invalidOperator("offset", "name,a,:eq,:sum,:sdes-slower,:dup,1w,:offset,:div")
}

test("validate: unsupported operation `:integral`") {
invalidOperator("integral", "name,jvm.gc.pause,:eq,:sum,:integral")
}
Expand Down

0 comments on commit 6996d19

Please sign in to comment.