You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by dw...@apache.org on 2019/07/31 22:36:31 UTC

[incubator-iceberg] branch master updated: Use UnicodeUtil.truncateString for Truncate transform. (#340)

This is an automated email from the ASF dual-hosted git repository.

dweeks pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iceberg.git


The following commit(s) were added to refs/heads/master by this push:
     new fde0dcc  Use UnicodeUtil.truncateString for Truncate transform. (#340)
fde0dcc is described below

commit fde0dcc58e795281632c219415581f854a58be99
Author: Ryan Blue <rd...@users.noreply.github.com>
AuthorDate: Wed Jul 31 15:36:26 2019 -0700

    Use UnicodeUtil.truncateString for Truncate transform. (#340)
    
    This truncates by unicode codepoint instead of Java chars.
---
 api/src/main/java/org/apache/iceberg/transforms/Truncate.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/api/src/main/java/org/apache/iceberg/transforms/Truncate.java b/api/src/main/java/org/apache/iceberg/transforms/Truncate.java
index d65d646..2eacaa2 100644
--- a/api/src/main/java/org/apache/iceberg/transforms/Truncate.java
+++ b/api/src/main/java/org/apache/iceberg/transforms/Truncate.java
@@ -27,6 +27,7 @@ import org.apache.iceberg.expressions.BoundPredicate;
 import org.apache.iceberg.expressions.Expressions;
 import org.apache.iceberg.expressions.UnboundPredicate;
 import org.apache.iceberg.types.Type;
+import org.apache.iceberg.util.UnicodeUtil;
 
 import static org.apache.iceberg.expressions.Expression.Operation.IS_NULL;
 import static org.apache.iceberg.expressions.Expression.Operation.LT;
@@ -233,7 +234,7 @@ abstract class Truncate<T> implements Transform<T, T> {
 
     @Override
     public CharSequence apply(CharSequence value) {
-      return value.subSequence(0, Math.min(value.length(), length));
+      return UnicodeUtil.truncateString(value, length);
     }
 
     @Override