From 313aeebf78af945c586a18183c05322b417183c8 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 6 May 2024 01:45:36 +0200 Subject: [PATCH] wip --- docs/VictoriaLogs/LogsQL.md | 6 ++++++ lib/logstorage/parser_test.go | 12 ++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/VictoriaLogs/LogsQL.md b/docs/VictoriaLogs/LogsQL.md index 28af77ed0..d2b8fc9c5 100644 --- a/docs/VictoriaLogs/LogsQL.md +++ b/docs/VictoriaLogs/LogsQL.md @@ -1071,6 +1071,8 @@ _time:5m | copy _time as timestmap, _msg as message The `as` keyword is optional. +`cp` keyword can be used instead of `copy` for convenience. For example, `_time:5m | cp foo bar` is equivalent to `_time:5m | copy foo as bar`. + See also: - [`rename` pipe](#rename-pipe) @@ -1160,6 +1162,10 @@ Multiple fields can be renamed with a single `| rename ...` pipe. For example, t _time:5m | rename host as instance, app as job ``` +The `as` keyword is optional. + +`mv` keyword can be used instead of `rename` keyword for convenience. For example, `_time:5m | mv foo bar` is equivalent to `_time:5m | rename foo as bar`. + See also: - [`copy` pipe](#copy-pipe) diff --git a/lib/logstorage/parser_test.go b/lib/logstorage/parser_test.go index 2beffec27..917b77b19 100644 --- a/lib/logstorage/parser_test.go +++ b/lib/logstorage/parser_test.go @@ -830,12 +830,14 @@ func TestParseQuerySuccess(t *testing.T) { // multiple fields pipes f(`foo | fields bar | fields baz, abc`, `foo | fields bar | fields baz, abc`) - // copy pipe + // copy and cp pipe f(`* | copy foo as bar`, `* | copy foo as bar`) + f(`* | cp foo bar`, `* | copy foo as bar`) f(`* | COPY foo as bar, x y | Copy a as b`, `* | copy foo as bar, x as y | copy a as b`) - // rename pipe + // rename and mv pipe f(`* | rename foo as bar`, `* | rename foo as bar`) + f(`* | mv foo bar`, `* | rename foo as bar`) f(`* | RENAME foo AS bar, x y | Rename a as b`, `* | rename foo as bar, x as y | rename a as b`) // delete, del and rm pipe @@ -1141,14 +1143,16 @@ func TestParseQueryFailure(t *testing.T) { f(`foo | fields bar,`) f(`foo | fields bar,,`) - // invalid copy pipe + // invalid copy and cp pipe f(`foo | copy`) + f(`foo | cp`) f(`foo | copy foo`) f(`foo | copy foo,`) f(`foo | copy foo,,`) - // invalid rename pipe + // invalid rename and mv pipe f(`foo | rename`) + f(`foo | mv`) f(`foo | rename foo`) f(`foo | rename foo,`) f(`foo | rename foo,,`)