You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Xintong Song (Jira)" <ji...@apache.org> on 2023/03/23 08:52:15 UTC
[jira] [Updated] (FLINK-28813) new stach builtinfunction validateClassForRuntime it not correct
[ https://issues.apache.org/jira/browse/FLINK-28813?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Xintong Song updated FLINK-28813:
---------------------------------
Fix Version/s: 1.18.0
(was: 1.17.0)
> new stach builtinfunction validateClassForRuntime it not correct
> -----------------------------------------------------------------
>
> Key: FLINK-28813
> URL: https://issues.apache.org/jira/browse/FLINK-28813
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / Planner
> Affects Versions: 1.16.0
> Reporter: jackylau
> Priority: Major
> Fix For: 1.18.0
>
> Attachments: image-2022-08-04-20-23-57-269.png
>
>
> {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)