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

github-merge-queue[bot] pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/seatunnel.git


The following commit(s) were added to refs/heads/dev by this push:
     new 287288374e [Fix][Transform-V2] Support small integer MOD divisors 
(#12215)
287288374e is described below

commit 287288374e3282816a641146bfaf061c6ee77c09
Author: Jast <[email protected]>
AuthorDate: Thu Sep 10 16:02:47 2026 +0000

    [Fix][Transform-V2] Support small integer MOD divisors (#12215)
    
    Co-authored-by: zhangshenghang <[email protected]>
---
 .../sql/zeta/functions/NumericFunction.java         |  6 ++++++
 .../transform/sql/SQLNumericFunctionsTest.java      | 21 +++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git 
a/seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/sql/zeta/functions/NumericFunction.java
 
b/seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/sql/zeta/functions/NumericFunction.java
index 8cb7de272d..19cb1f91d4 100644
--- 
a/seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/sql/zeta/functions/NumericFunction.java
+++ 
b/seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/sql/zeta/functions/NumericFunction.java
@@ -221,6 +221,12 @@ public class NumericFunction {
                     CommonErrorCodeDeprecated.UNSUPPORTED_OPERATION, "Mod by 
zero");
         }
         BigDecimal[] res = leftBD.divideAndRemainder(rightBD);
+        if (rightValue instanceof Byte) {
+            return res[1].byteValue();
+        }
+        if (rightValue instanceof Short) {
+            return res[1].shortValue();
+        }
         if (rightValue instanceof Integer) {
             return res[1].intValue();
         }
diff --git 
a/seatunnel-transforms-v2/src/test/java/org/apache/seatunnel/transform/sql/SQLNumericFunctionsTest.java
 
b/seatunnel-transforms-v2/src/test/java/org/apache/seatunnel/transform/sql/SQLNumericFunctionsTest.java
index 8e34814a61..f73f83ea8c 100644
--- 
a/seatunnel-transforms-v2/src/test/java/org/apache/seatunnel/transform/sql/SQLNumericFunctionsTest.java
+++ 
b/seatunnel-transforms-v2/src/test/java/org/apache/seatunnel/transform/sql/SQLNumericFunctionsTest.java
@@ -84,6 +84,27 @@ public class SQLNumericFunctionsTest {
         Assertions.assertEquals(1.23d, (Double) outRow.getField(1), 1e-9);
     }
 
+    @Test
+    public void testModWithTinyIntAndSmallIntDivisors() {
+        SeaTunnelRowType rowType =
+                new SeaTunnelRowType(
+                        new String[] {"a", "tiny", "small"},
+                        new SeaTunnelDataType[] {
+                            BasicType.INT_TYPE, BasicType.BYTE_TYPE, 
BasicType.SHORT_TYPE
+                        });
+
+        SeaTunnelRow outRow =
+                runSql(
+                        "select MOD(a, tiny) as tiny_remainder, MOD(a, small) 
as small_remainder from dual",
+                        rowType,
+                        100,
+                        (byte) 7,
+                        (short) 30);
+
+        Assertions.assertEquals((byte) 2, outRow.getField(0));
+        Assertions.assertEquals((short) 10, outRow.getField(1));
+    }
+
     @Test
     public void testModByZero() {
         SeaTunnelRowType rowType =

Reply via email to