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

add SQL LENGTH() function as alias for len() #5486

Merged
merged 2 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 1 deletion runtime/sam/expr/function/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion runtime/vam/expr/function/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions runtime/ztests/expr/length.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
zed: SELECT LENGTH('W3Schools.com');
Copy link
Collaborator

@mattnibs mattnibs Nov 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put this in runtime/ztests/expr/function where the test for len is


vector: true

input: |
null

output: |
{length:13}