-
Notifications
You must be signed in to change notification settings - Fork 753
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: databend-meta transaction support generic bool-expression and e…
…lse-if chain (#17064) Since this commit, application is allowed to specify a complex bool expressions as the transaction predicate. For example, the transaction will execute as if running the following pseudo codes: ``` if (a == 1 || b == 2) && (x == 3 || y == 4) { ops1 } else if (x == 2 || y == 1) { ops2 } else if (y == 3 && z == 4) { ops3 } else { ops4 } ``` ```rust let eq = |key: &str, val: &str| TxnCondition::eq_value(sample(key), b(val)); TxnRequest{ operations: vec![ BoolExpression::new( Some(eq("a", 1).or(eq("b", 2)) .and(eq("x", 3).or(eq("y", 4)))), ops1), BoolExpression::new( Some(eq("x", 2).or(eq("y", 1))), ops2), ], condition: vec![eq("y", 3), eq("z", 4)], if_then: ops3, else_then: ops4, } ``` For backward compatibility, both already existing `condition` and the new `operations` will be evaluated: transaction handler evaluate the `operations` first. If there is a met condition, execute and return. Otherwise, it evaluate `condition` and then execute `if_then` branch or `else_then` branch. TxnReply changes: Add field `execution_path` to indicate the executed branch, which is one of: - `"operation:<index>"`, operation at `index` is executed. - `"then"`: `if_then` is executed. - `"else"`: `else_then` is executed. `TxnReply.success` is set to `false` only when `else` is executed.
- Loading branch information
1 parent
bed61d2
commit 22f9ba2
Showing
21 changed files
with
955 additions
and
292 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.