From 69c09b155dd2fc0f20630fbf0c6799022b125f20 Mon Sep 17 00:00:00 2001 From: universalmind303 Date: Thu, 26 Sep 2024 14:44:44 -0500 Subject: [PATCH] add length_bytes --- src/daft-sql/src/modules/utf8.rs | 1 + tests/sql/test_utf8_exprs.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/daft-sql/src/modules/utf8.rs b/src/daft-sql/src/modules/utf8.rs index d31f394ba9..6e7b6b68a5 100644 --- a/src/daft-sql/src/modules/utf8.rs +++ b/src/daft-sql/src/modules/utf8.rs @@ -38,6 +38,7 @@ impl SQLModule for SQLModuleUtf8 { // TODO add replace variants // parent.add("replace", f(Replace(false))); parent.add_fn("length", Length); + parent.add_fn("length_bytes", LengthBytes); parent.add_fn("lower", Lower); parent.add_fn("upper", Upper); parent.add_fn("lstrip", Lstrip); diff --git a/tests/sql/test_utf8_exprs.py b/tests/sql/test_utf8_exprs.py index aff960b52f..12b53a9ebc 100644 --- a/tests/sql/test_utf8_exprs.py +++ b/tests/sql/test_utf8_exprs.py @@ -38,6 +38,7 @@ def test_utf8_exprs(): regexp_replace(a, 'ba.', 'foo') as replace_a, regexp_split(a, '\\s+') as regexp_split_a, length(a) as length_a, + length_bytes(a) as length_bytes_a, lower(a) as lower_a, lstrip(a) as lstrip_a, rstrip(a) as rstrip_a, @@ -77,6 +78,7 @@ def test_utf8_exprs(): col("a").str.split(r"\s+", regex=True).alias("regexp_split_a"), col("a").str.replace("ba.", "foo").alias("replace_a"), col("a").str.length().alias("length_a"), + col("a").str.length_bytes().alias("length_bytes_a"), col("a").str.lower().alias("lower_a"), col("a").str.lstrip().alias("lstrip_a"), col("a").str.rstrip().alias("rstrip_a"),