[
https://issues.apache.org/jira/browse/FLINK-6334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15991548#comment-15991548
]
ASF GitHub Bot commented on FLINK-6334:
---------------------------------------
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.
> Refactoring UDTF interface
> --------------------------
>
> Key: FLINK-6334
> URL: https://issues.apache.org/jira/browse/FLINK-6334
> Project: Flink
> Issue Type: Improvement
> Components: Table API & SQL
> Reporter: Ruidong Li
> Assignee: Ruidong Li
>
> The current UDTF leverages the table.join(expression) interface, which is not
> a proper interface in terms of semantics. We would like to refactor this to
> let UDTF use table.join(table) interface. Very briefly, UDTF's apply method
> will return a Table Type, so Join(UDTF('a, 'b, ...) as 'c) shall be viewed as
> join(Table)
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)