From 5c1851be150fe549629222e331a83f95322464a3 Mon Sep 17 00:00:00 2001 From: Steve McCanne Date: Sun, 17 Nov 2024 10:17:09 -0800 Subject: [PATCH] add SQL LENGTH() function as alias for len() (#5486) --- runtime/sam/expr/function/function.go | 2 +- runtime/vam/expr/function/function.go | 2 +- runtime/ztests/expr/function/length.yaml | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 runtime/ztests/expr/function/length.yaml diff --git a/runtime/sam/expr/function/function.go b/runtime/sam/expr/function/function.go index cf8bf61f66..57077a2596 100644 --- a/runtime/sam/expr/function/function.go +++ b/runtime/sam/expr/function/function.go @@ -34,7 +34,7 @@ func New(zctx *super.Context, name string, narg int) (expr.Function, field.Path, case "grok": argmin, argmax = 2, 3 f = newGrok(zctx) - case "len": + case "len", "length": f = &LenFn{zctx: zctx} case "abs": f = &Abs{zctx: zctx} diff --git a/runtime/vam/expr/function/function.go b/runtime/vam/expr/function/function.go index b9320abb27..9a4e82eccd 100644 --- a/runtime/vam/expr/function/function.go +++ b/runtime/vam/expr/function/function.go @@ -37,7 +37,7 @@ func New(zctx *super.Context, name string, narg int) (expr.Function, field.Path, f = &Join{zctx: zctx} case "kind": f = &Kind{zctx: zctx} - case "len": + case "len", "length": f = &Len{zctx} case "levenshtein": argmin, argmax = 2, 2 diff --git a/runtime/ztests/expr/function/length.yaml b/runtime/ztests/expr/function/length.yaml new file mode 100644 index 0000000000..959dda56ec --- /dev/null +++ b/runtime/ztests/expr/function/length.yaml @@ -0,0 +1,9 @@ +zed: SELECT LENGTH('W3Schools.com'); + +vector: true + +input: | + null + +output: | + {length:13}