dylanhz commented on code in PR #25109:
URL: https://github.com/apache/flink/pull/25109#discussion_r1691012678


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/MathFunctionsITCase.java:
##########
@@ -141,4 +178,181 @@ Stream<TestSetSpec> getTestSetSpecs() {
                                 new BigDecimal("123.45"),
                                 DataTypes.DECIMAL(6, 2).notNull()));
     }
+
+    private Stream<TestSetSpec> convTestCases() {
+        return Stream.of(
+                TestSetSpec.forFunction(BuiltInFunctionDefinitions.CONV)
+                        .onFieldsWithData(
+                                null, null, "100", "", "11abc", "\u000B\f   
4521   \n\r\t")
+                        .andDataTypes(
+                                DataTypes.INT(),
+                                DataTypes.STRING(),
+                                DataTypes.STRING(),
+                                DataTypes.STRING(),
+                                DataTypes.STRING(),
+                                DataTypes.STRING())
+                        // null input
+                        .testResult($("f0").conv(2, 2), "CONV(f0, 2, 2)", 
null, DataTypes.STRING())
+                        .testResult($("f1").conv(2, 2), "CONV(f1, 2, 2)", 
null, DataTypes.STRING())
+                        .testResult(
+                                $("f2").conv($("f0"), 2),
+                                "CONV(f2, f0, 2)",
+                                null,
+                                DataTypes.STRING())
+                        .testResult(
+                                $("f2").conv(2, $("f0")),
+                                "CONV(f2, 2, f0)",
+                                null,
+                                DataTypes.STRING())
+                        // empty string
+                        .testResult($("f3").conv(2, 4), "CONV(f3, 2, 4)", 
null, DataTypes.STRING())
+                        // invalid fromBase
+                        .testResult($("f2").conv(1, 2), "CONV(f2, 1, 2)", 
null, DataTypes.STRING())
+                        .testResult(
+                                $("f2").conv(40, 2), "CONV(f2, 40, 2)", null, 
DataTypes.STRING())
+                        // invalid toBase
+                        .testResult(
+                                $("f2").conv(2, -1), "CONV(f2, 2, -1)", null, 
DataTypes.STRING())
+                        .testResult(
+                                $("f2").conv(2, -40), "CONV(f2, 2, -40)", 
null, DataTypes.STRING())
+                        // invalid num format, ignore suffix
+                        .testResult(
+                                $("f4").conv(10, 16), "CONV(f4, 10, 16)", "B", 
DataTypes.STRING())
+                        // num overflow
+                        .testTableApiRuntimeError(
+                                lit("FFFFFFFFFFFFFFFF").conv(16, 16),
+                                NumberFormatException.class,
+                                "The number FFFFFFFFFFFFFFFF overflows.")
+                        .testSqlRuntimeError(
+                                "CONV('FFFFFFFFFFFFFFFF', 16, 16)",
+                                NumberFormatException.class,
+                                "The number FFFFFFFFFFFFFFFF overflows.")
+                        .testTableApiRuntimeError(
+                                lit("FFFFFFFFFFFFFFFEE").conv(16, 16),
+                                NumberFormatException.class,
+                                "The number FFFFFFFFFFFFFFFEE overflows.")

Review Comment:
   There are three distinct numbers involved in overflow test cases: 
   - `FFFFFFFFFFFFFFFF`, which equates to -1, will not trigger overflow in 
encode(). However, since -1 is inherently treated as an overflow flag, it ends 
up throwing an exception. 
   - `FFFFFFFFFFFFFFFEE` will trigger overflow in encode() line  97.
   - `18446744073709551616` will trigger overflow in encode() line  105.
   
   So these numbers are actually very special boundary cases and I think they 
should be kept.
   



-- 
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]

Reply via email to