[
https://issues.apache.org/jira/browse/FLINK-28813?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
jackylau updated FLINK-28813:
-----------------------------
Description:
{code:java}
// code placeholder
public static final BuiltInFunctionDefinition CONV =
BuiltInFunctionDefinition.newBuilder()
.name("CONV")
.kind(SCALAR)
.inputTypeStrategy(
or(
sequence(
logical(LogicalTypeFamily.INTEGER_NUMERIC),
logical(LogicalTypeFamily.INTEGER_NUMERIC),
logical(LogicalTypeFamily.INTEGER_NUMERIC)),
sequence(
logical(LogicalTypeFamily.CHARACTER_STRING),
logical(LogicalTypeFamily.INTEGER_NUMERIC),
logical(LogicalTypeFamily.INTEGER_NUMERIC))))
.outputTypeStrategy(nullableIfArgs(explicit(DataTypes.STRING())))
.runtimeClass("org.apache.flink.table.runtime.functions.scalar.ConvFunction")
.build();{code}
{code:java}
// code placeholder
public class ConvFunction extends BuiltInScalarFunction {
public ConvFunction(SpecializedFunction.SpecializedContext context) {
super(BuiltInFunctionDefinitions.CONV, context);
}
public static StringData eval(StringData input, Integer fromBase, Integer
toBase) {
if (input == null || fromBase == null || toBase == null) {
return null;
}
return StringData.fromString(BaseConversionUtils.conv(input.toBytes(),
fromBase, toBase));
}
public static StringData eval(long input, Integer fromBase, Integer toBase)
{
return eval(StringData.fromString(String.valueOf(input)), fromBase,
toBase);
}
}
@Test
public void testRowScalarFunction1() throws Exception {
tEnv().executeSql(
"CREATE TABLE TestTable(s STRING) " + "WITH ('connector' =
'COLLECTION')");
// the names of the function input and r differ
tEnv().executeSql("INSERT INTO TestTable select conv(3, cast(1 AS TINYINT),
4)").await();
} {code}
was:
{code:java}
org.apache.flink.table.api.ValidationException: Could not find an
implementation method 'eval' in class
'org.apache.flink.table.runtime.functions.scalar.ConvFunction' for function
'CONV' that matches the following signature:
org.apache.flink.table.data.StringData
eval(org.apache.flink.table.data.StringData, java.lang.Byte, java.lang.Integer)
at
org.apache.flink.table.functions.UserDefinedFunctionHelper.validateClassForRuntime(UserDefinedFunctionHelper.java:319)
{code}
{code:java}
// code placeholder
public class ConvFunction extends BuiltInScalarFunction {
public ConvFunction(SpecializedFunction.SpecializedContext context) {
super(BuiltInFunctionDefinitions.CONV, context);
}
public static StringData eval(StringData input, Integer fromBase, Integer
toBase) {
if (input == null || fromBase == null || toBase == null) {
return null;
}
return StringData.fromString(BaseConversionUtils.conv(input.toBytes(),
fromBase, toBase));
}
public static StringData eval(long input, Integer fromBase, Integer toBase)
{
return eval(StringData.fromString(String.valueOf(input)), fromBase,
toBase);
}
}
@Test
public void testRowScalarFunction1() throws Exception {
tEnv().executeSql(
"CREATE TABLE TestTable(s STRING) " + "WITH ('connector' =
'COLLECTION')");
// the names of the function input and r differ
tEnv().executeSql("INSERT INTO TestTable select conv(3, cast(1 AS TINYINT),
4)").await();
} {code}
> new stach builtinfunction validateClassForRuntime it not correct
> -----------------------------------------------------------------
>
> Key: FLINK-28813
> URL: https://issues.apache.org/jira/browse/FLINK-28813
> Project: Flink
> Issue Type: Improvement
> Components: Table SQL / Planner
> Affects Versions: 1.16.0
> Reporter: jackylau
> Priority: Major
> Fix For: 1.16.0
>
>
> {code:java}
> // code placeholder
> public static final BuiltInFunctionDefinition CONV =
> BuiltInFunctionDefinition.newBuilder()
> .name("CONV")
> .kind(SCALAR)
> .inputTypeStrategy(
> or(
> sequence(
>
> logical(LogicalTypeFamily.INTEGER_NUMERIC),
>
> logical(LogicalTypeFamily.INTEGER_NUMERIC),
>
> logical(LogicalTypeFamily.INTEGER_NUMERIC)),
> sequence(
>
> logical(LogicalTypeFamily.CHARACTER_STRING),
>
> logical(LogicalTypeFamily.INTEGER_NUMERIC),
>
> logical(LogicalTypeFamily.INTEGER_NUMERIC))))
>
> .outputTypeStrategy(nullableIfArgs(explicit(DataTypes.STRING())))
>
> .runtimeClass("org.apache.flink.table.runtime.functions.scalar.ConvFunction")
> .build();{code}
> {code:java}
> // code placeholder
> public class ConvFunction extends BuiltInScalarFunction {
> public ConvFunction(SpecializedFunction.SpecializedContext context) {
> super(BuiltInFunctionDefinitions.CONV, context);
> }
> public static StringData eval(StringData input, Integer fromBase, Integer
> toBase) {
> if (input == null || fromBase == null || toBase == null) {
> return null;
> }
> return
> StringData.fromString(BaseConversionUtils.conv(input.toBytes(), fromBase,
> toBase));
> }
> public static StringData eval(long input, Integer fromBase, Integer
> toBase) {
> return eval(StringData.fromString(String.valueOf(input)), fromBase,
> toBase);
> }
> }
> @Test
> public void testRowScalarFunction1() throws Exception {
> tEnv().executeSql(
> "CREATE TABLE TestTable(s STRING) " + "WITH ('connector'
> = 'COLLECTION')");
> // the names of the function input and r differ
> tEnv().executeSql("INSERT INTO TestTable select conv(3, cast(1 AS
> TINYINT), 4)").await();
> } {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)