ryukobayashi commented on code in PR #5624:
URL: https://github.com/apache/hive/pull/5624#discussion_r2181983736


##########
ql/src/java/org/apache/hadoop/hive/ql/udf/UDFSubstr.java:
##########
@@ -96,13 +98,12 @@ private Text evaluateInternal(Text t, int pos, int len) {
       return r;
     }
 
-    String s = t.toString();
-    int[] index = makeIndex(pos, len, s.length());
-    if (index == null) {
+    StringSubstrColStartLen.populateSubstrOffsets(t.getBytes(), 0, 
t.getLength(), adjustStartPos(pos), len, index);
+    if (index[0] == -1) {
       return r;
     }
 
-    r.set(s.substring(index[0], index[1]));
+    r.set(new String(t.getBytes(), index[0], index[1], 
StandardCharsets.UTF_8));

Review Comment:
   OK, I fixed.



##########
ql/src/java/org/apache/hadoop/hive/ql/udf/UDFSubstr.java:
##########
@@ -133,16 +134,44 @@ private int[] makeIndex(int pos, int len, int inputLen) {
 
   private final IntWritable maxValue = new IntWritable(Integer.MAX_VALUE);
 
-  // Even though we are using longs, substr can only deal with ints, so we use
+  //Even though we are using longs, substr can only deal with ints, so we use
   // the maximum int value as the maxValue
   private final LongWritable maxLongValue = new 
LongWritable(Integer.MAX_VALUE);
 
+  private Text evaluateInternal(Text t, int pos) {
+    r.clear();
+
+    int offset = StringSubstrColStart.getSubstrStartOffset(t.getBytes(), 0, 
t.getLength(), adjustStartPos(pos));
+    if (offset == -1) {
+      return r;
+    }
+
+    r.set(new String(t.getBytes(), offset, t.getLength() - offset, 
StandardCharsets.UTF_8));

Review Comment:
   fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to