Github user fhueske commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3791#discussion_r114061983
  
    --- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/table.scala
 ---
    @@ -309,6 +308,42 @@ class Table(
       }
     
       /**
    +    * Joins this [[Table]] to a user-defined 
[[org.apache.calcite.schema.TableFunction]]. Similar
    +    * to an SQL left outer join with ON TRUE, but it works with a table 
function. It returns all
    +    * the rows from the outer table (table on the left of the operator), 
and rows that do not match
    +    * the condition from the table function (which is defined in the 
expression on the right
    +    * side of the operator). Rows with no matching condition are filled 
with null values.
    +    *
    +    * Scala Example:
    +    * {{{
    +    *   class MySplitUDTF extends TableFunction[String] {
    +    *     def eval(str: String): Unit = {
    +    *       str.split("#").foreach(collect)
    +    *     }
    +    *   }
    +    *
    +    *   val split = new MySplitUDTF()
    +    *   table.leftOuterJoin(split('c) as ('s)).select('a,'b,'c,'s)
    +    * }}}
    +    *
    +    * Java Example:
    +    * {{{
    +    *   class MySplitUDTF extends TableFunction<String> {
    +    *     public void eval(String str) {
    +    *       str.split("#").forEach(this::collect);
    +    *     }
    +    *   }
    +    *
    +    *   TableFunction<String> split = new MySplitUDTF();
    +    *   tableEnv.registerFunction("split", split);
    +    *   
table.leftOuterJoin(tableEnv.tableApply("split(c)").as("s"))).select("a, b, c, 
s");
    --- End diff --
    
    I think the Java Syntax could be improved. Could we do something like:
    ```
    table.leftOuterJoin(new Table(tableEnv, "split(c) as s")).select("a, b, c, 
s");
    ```
    
    by adding an constructor to `Table` like `Table(tEnv: TableEnvironment, 
tableFunc: String)`?
    IMO, this would make it more clear that the TableFunction creates a table 
which is joined.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to