Skip to content
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

enhancement(datadog search): Support && and || in queries #1001

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.d/1001.enhancement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The `match_datadog_query` function now accepts `||` in place of `OR` and `&&` in
place of `AND` in the query string, which is common Datadog syntax.
4 changes: 2 additions & 2 deletions src/datadog/search/grammar.pest
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ COLON = _{ ":" }
STAR = { "*" }
QUESTIONMARK = { "?" }
DQUOTE = _{ "\"" }
AND = { "AND" }
OR = { "OR" }
AND = { "AND" | "&&" }
OR = { "OR" | "||" }
NOT = { "NOT" | "-" }
PLUS = { "+" }
ESC_CHAR = @{ "\\" ~ ANY }
Expand Down
10 changes: 8 additions & 2 deletions src/datadog/search/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,10 @@ mod tests {

#[test]
fn parses_boolean_nodes_with_explicit_operators() {
let cases = ["foo:bar OR baz:qux AND quux:quuz"];
let cases = [
"foo:bar OR baz:qux AND quux:quuz",
"foo:bar || baz:qux && quux:quuz",
];
for query in cases.iter() {
let res = parse(query);
if let QueryNode::Boolean {
Expand All @@ -603,7 +606,10 @@ mod tests {

#[test]
fn parses_boolean_nodes_with_implicit_and_explicit_operators() {
let cases = ["foo:bar OR baz:qux quux:quuz"];
let cases = [
"foo:bar OR baz:qux quux:quuz",
"foo:bar || baz:qux quux:quuz",
];
for query in cases.iter() {
let res = parse(query);
if let QueryNode::Boolean {
Expand Down
Loading