WeiZhong94 commented on a change in pull request #13070: URL: https://github.com/apache/flink/pull/13070#discussion_r466150697
########## File path: docs/dev/table/tableApi.md ########## @@ -1490,8 +1558,12 @@ result = left.join(right).where("a = d && rowtime1 >= rowtime2 - 1.second <p>Joins a table with the results of a table function. Each row of the left (outer) table is joined with all rows produced by the corresponding call of the table function. A row of the left (outer) table is dropped, if its table function call returns an empty result. </p> {% highlight python %} -# register Java User-Defined Table Function -table_env.register_java_function("split", "com.my.udf.MySplitUDTF") +# register User-Defined Table Function +@udtf(input_types=[DataTypes.BIGINT()], + result_types=[DataTypes.BIGINT(), DataTypes.BIGINT(), DataTypes.BIGINT()]) +def split(x): + return [Row(1, 2, 3)] Review comment: yield Row(1, 2, 3) ? ########## File path: docs/dev/table/tableApi.md ########## @@ -464,6 +485,49 @@ orders = table_env.from_path("Orders") {% endhighlight %} </td> </tr> + <tr> + <td> + <strong>FromElements</strong><br> + <span class="label label-primary">Batch</span> <span class="label label-primary">Streaming</span> + </td> + <td> + <p>Similar to the VALUES clause in a SQL query. Produces an inline table out of the provided rows.</p> +{% highlight python %} +table = tEnv.from_elements([(1, 'ABC'), (2, 'ABCDE')]) Review comment: t_env? ########## File path: docs/dev/table/tableApi.md ########## @@ -101,25 +101,49 @@ val result = orders </div> <div data-lang="python" markdown="1"> -The Python Table API is enabled by `from pyflink.table import *`. - The following example shows how a Python Table API program is constructed and how expressions are specified as strings. {% highlight python %} from pyflink.table import * -from pyflink.dataset import * # environment configuration -env = ExecutionEnvironment.get_execution_environment() -t_env = TableEnvironment.create(env, TableConfig()) +t_env = BatchTableEnvironment.create( + environment_settings=EnvironmentSettings.new_instance().in_batch_mode().use_blink_planner().build()) # register Orders table and Result table sink in table environment -# ... +source_data_path = "/path/to/source/directory/" +result_data_path = "/path/to/result/directory/" +source_ddl = """ Review comment: It would be better if we use the format strings: f""" create table Orders( a VARCHAR, b BIGINT, c BIGINT, rowtime TIMESTAMP(3), WATERMARK FOR rowtime AS rowtime - INTERVAL '1' SECOND ) with ( 'connector' = 'filesystem', 'format' = 'csv', 'path' = '{source_data_path}' ) """ ########## File path: docs/dev/table/tableApi.md ########## @@ -1490,8 +1558,12 @@ result = left.join(right).where("a = d && rowtime1 >= rowtime2 - 1.second <p>Joins a table with the results of a table function. Each row of the left (outer) table is joined with all rows produced by the corresponding call of the table function. A row of the left (outer) table is dropped, if its table function call returns an empty result. </p> {% highlight python %} -# register Java User-Defined Table Function -table_env.register_java_function("split", "com.my.udf.MySplitUDTF") +# register User-Defined Table Function +@udtf(input_types=[DataTypes.BIGINT()], Review comment: input_types is unnecessary now. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org