kasakrisz commented on code in PR #3433:
URL: https://github.com/apache/hive/pull/3433#discussion_r934330702


##########
ql/src/java/org/apache/hadoop/hive/ql/udf/UDFSubstr.java:
##########
@@ -64,19 +64,39 @@ public UDFSubstr() {
     r = new Text();
   }
 
-  public Text evaluate(Text t, IntWritable pos, IntWritable len) {
+  public Text evaluate(Text t, LongWritable pos, LongWritable len) {
+    if ((t == null) || (pos == null) || (len == null)) {
+      return null;
+    }
+
+    long longPos = pos.get();
+    long longLen = len.get();
+    // If an unsupported value is seen, we don't want to return a string
+    // that doesn't match what the user expects, so we return NULL (still
+    // unexpected, of course, but probably better than a bad string).
+    if (longPos > Integer.MAX_VALUE || longLen > Integer.MAX_VALUE) {

Review Comment:
   Should negative overflow also be handled?
   ```
   long l = Integer.MIN_VALUE - 10L;
   int i = (int)l;
   ```
   I think `i` is going to be a positive integer.
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to