mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 12:31:07 +01:00
lib/logstorage: substitute |
operator with or
operator at math
pipe
This is needed for avoiding confusion between the `|` operator at `math` pipe and `|` pipe delimiter. For example, the following query was parsed unexpectedly: * | math foo / bar | fields x as * | math foo / (bar | fields) as x Substituting `|` with `or` inside `math` pipe fixes this ambiguity.
This commit is contained in:
parent
95acca6b52
commit
00e7d5add3
@ -1799,7 +1799,7 @@ The following mathematical operations are supported by `math` pipe:
|
||||
- `arg1 % arg2` - returns the remainder of the division of `arg1` by `arg2`
|
||||
- `arg1 ^ arg2` - returns the power of `arg1` by `arg2`
|
||||
- `arg1 & arg2` - returns bitwise `and` for `arg1` and `arg2`. It is expected that `arg1` and `arg2` are in the range `[0 .. 2^53-1]`
|
||||
- `arg1 | arg2` - returns bitwise `or` for `arg1` and `arg2`. It is expected that `arg1` and `arg2` are in the range `[0 .. 2^53-1]`
|
||||
- `arg1 or arg2` - returns bitwise `or` for `arg1` and `arg2`. It is expected that `arg1` and `arg2` are in the range `[0 .. 2^53-1]`
|
||||
- `arg1 xor arg2` - returns bitwise `xor` for `arg1` and `arg2`. It is expected that `arg1` and `arg2` are in the range `[0 .. 2^53-1]`
|
||||
- `arg1 default arg2` - returns `arg2` if `arg1` is non-[numeric](#numeric-values) or equals to `NaN`
|
||||
- `abs(arg)` - returns an absolute value for the given `arg`
|
||||
|
@ -173,7 +173,7 @@ var mathBinaryOps = map[string]mathBinaryOp{
|
||||
priority: 5,
|
||||
f: mathFuncXor,
|
||||
},
|
||||
"|": {
|
||||
"or": {
|
||||
priority: 6,
|
||||
f: mathFuncOr,
|
||||
},
|
||||
|
@ -56,7 +56,7 @@ func TestPipeMath(t *testing.T) {
|
||||
'123.45.67.89' + 1000 as ip,
|
||||
time - time % time_step as time_rounded,
|
||||
duration - duration % duration_step as duration_rounded,
|
||||
(ip & ip_mask | 0x1234) xor 5678 as subnet
|
||||
(ip & ip_mask or 0x1234) xor 5678 as subnet
|
||||
`, [][]Field{
|
||||
{
|
||||
{"time_step", "30m"},
|
||||
|
Loading…
Reference in New Issue
Block a user