Skip to content

Commit

Permalink
Validate legacy expressions when splitting for predicate pushdown (#4861
Browse files Browse the repository at this point in the history
)

This fixes a panic when performing predicate pushdown for pipelines such
as `export | where "foo" == "bar"`. The issue is that `"foo" == "bar"`
is valid expression, but we perform a translation into a format that the
catalog understands, which doesn't support expressions like that. Thus,
this PR adds a check that validates the expression before returning it.
  • Loading branch information
dominiklohmann authored Dec 12, 2024
2 parents c3aadf2 + 39c6cfa commit 1473c93
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelog/next/bug-fixes/4861--fix-export-where.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Pipelines that begin with `export | where` followed by an expression that does
not depend on the incoming events, such as `export | where 1 == 1`, no longer
cause an internal error.
10 changes: 8 additions & 2 deletions libtenzir/src/tql2/ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,15 @@ auto split_legacy_expression(const ast::expression& x)
if (not left || not right) {
return std::pair{trivially_true_expression(), x};
}
auto result
= expression{predicate{std::move(*left), *rel_op, std::move(*right)}};
if (not normalize_and_validate(result)) {
return std::pair{trivially_true_expression(), x};
}
return std::pair{
expression{predicate{std::move(*left), *rel_op, std::move(*right)}},
ast::expression{ast::constant{true, location::unknown}}};
std::move(result),
ast::expression{ast::constant{true, location::unknown}},
};
}
if (y.op.inner == ast::binary_op::and_) {
auto [lo, ln] = split_legacy_expression(y.left);
Expand Down

0 comments on commit 1473c93

Please sign in to comment.