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

Add support for custom functions in Table API

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.2.0
    • Table SQL / API
    • None

    Description

      Currently, the Table API has a very limited set of built-in functions. Support for custom functions can solve this problem. Adding of a custom row function could look like:

      TableEnvironment tableEnv = new TableEnvironment();
      
      RowFunction<String> rf = new RowFunction<String>() {
          @Override
          public String call(Object[] args) {
              return ((String) args[0]).trim();
          }
      };
      
      tableEnv.getConfig().registerRowFunction("TRIM", rf,
          BasicTypeInfo.STRING_TYPE_INFO);
      
      DataSource<Tuple1<String>> input = env.fromElements(
          new Tuple1<>(" 1 "));
      
      Table table = tableEnv.fromDataSet(input);
      
      Table result = table.select("TRIM(f0)");
      

      This feature is also necessary as part of FLINK-2099.

      Attachments

        Issue Links

          Activity

            People

              twalthr Timo Walther
              twalthr Timo Walther
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: