Skip to content

fix(udf): handle Integer.MIN_VALUE in Substr function#759

Open
SYaoJun wants to merge 1 commit intoapache:masterfrom
SYaoJun:0303_min
Open

fix(udf): handle Integer.MIN_VALUE in Substr function#759
SYaoJun wants to merge 1 commit intoapache:masterfrom
SYaoJun:0303_min

Conversation

@SYaoJun
Copy link
Contributor

@SYaoJun SYaoJun commented Mar 3, 2026

What changes were proposed in this pull request?

fix: #758

How was this PR tested?

  • Tests have Added for the changes
  • Production environment verified

Substr sb = new Substr();

// Test Integer.MIN_VALUE for String version
Assert.assertEquals(sb.eval("hello", Integer.MIN_VALUE, 1), "hello");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this usage not common in SQL?

return null;
}
if (pos == Integer.MIN_VALUE) {
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the String and BinaryString versions inconsistent?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Math.abs(Integer.MIN_VALUE) will overflow and return a negative value

2 participants