From c90436a6589ec46c66cd88dbcf6e4a5156744691 Mon Sep 17 00:00:00 2001 From: Mryange <2319153948@qq.com> Date: Wed, 18 Sep 2024 22:42:57 +0800 Subject: [PATCH] upd --- .../expressions/functions/executable/StringArithmetic.java | 2 +- .../fold_constant/fold_constant_string_arithmatic.groovy | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/StringArithmetic.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/StringArithmetic.java index bc9cc29e7d06a0..d032ea07304d0e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/StringArithmetic.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/StringArithmetic.java @@ -113,7 +113,7 @@ public static Expression substringVarcharIntInt(StringLikeLiteral first, */ @ExecFunction(name = "length") public static Expression lengthVarchar(StringLikeLiteral first) { - return new IntegerLiteral(first.getValue().length()); + return new IntegerLiteral(first.getValue().getBytes(StandardCharsets.UTF_8).length); } /** diff --git a/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_string_arithmatic.groovy b/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_string_arithmatic.groovy index 2bcdfc2fd24068..9d83e0686a81d9 100644 --- a/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_string_arithmatic.groovy +++ b/regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_string_arithmatic.groovy @@ -50,6 +50,7 @@ suite("fold_constant_string_arithmatic") { testFoldConst("SELECT Concat_Ws('-', '2024', '09', '02')") testFoldConst("SELECT Char(65)") testFoldConst("SELECT Character_Length('Hello World')") + testFoldConst("SELECT Length('你')") testFoldConst("SELECT Initcap('hello world')") testFoldConst("SELECT Md5('Hello World')") testFoldConst("SELECT Md5Sum('Hello World')")