Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-28813

new stach builtinfunction validateClassForRuntime it not correct

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.16.0
    • 2.0.0
    • Table SQL / Planner
    • None

    Description

      // 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 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();
      
      } 

      Attachments

        Activity

          People

            Unassigned Unassigned
            jackylau Jacky Lau
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: