superdiaodiao commented on code in PR #25109:
URL: https://github.com/apache/flink/pull/25109#discussion_r1690918688
##########
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:
@snuyanzin These two test cases(`FFFFFFFFFFFFFFFF `vs `FFFFFFFFFFFFFFFEE`)
are almost the same, may I ask should we only keep one of them? Like the
comment from another PR:
https://github.com/apache/flink/pull/24773#discussion_r1603091969
cc @lsyldliu
--
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]