You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by he...@apache.org on 2020/01/21 07:19:04 UTC
[flink] branch release-1.9 updated: [FLINK-15700][python][doc]
Improves the Python API Tutorial doc
This is an automated email from the ASF dual-hosted git repository.
hequn pushed a commit to branch release-1.9
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/release-1.9 by this push:
new d44848c [FLINK-15700][python][doc] Improves the Python API Tutorial doc
d44848c is described below
commit d44848c3a378c154884a5e0867c86a9bb576e891
Author: huangxingbo <hx...@gmail.com>
AuthorDate: Tue Jan 21 11:04:46 2020 +0800
[FLINK-15700][python][doc] Improves the Python API Tutorial doc
This closes #10911.
---
docs/tutorials/python_table_api.md | 18 ++++++++++++++----
docs/tutorials/python_table_api.zh.md | 18 +++++++++++++++---
2 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/docs/tutorials/python_table_api.md b/docs/tutorials/python_table_api.md
index 89d3397..781bdcd 100644
--- a/docs/tutorials/python_table_api.md
+++ b/docs/tutorials/python_table_api.md
@@ -60,7 +60,6 @@ Next we will create a source table and a sink table.
{% highlight python %}
t_env.connect(FileSystem().path('/tmp/input')) \
.with_format(OldCsv()
- .line_delimiter(' ')
.field('word', DataTypes.STRING())) \
.with_schema(Schema()
.field('word', DataTypes.STRING())) \
@@ -115,7 +114,6 @@ t_env = BatchTableEnvironment.create(exec_env, t_config)
t_env.connect(FileSystem().path('/tmp/input')) \
.with_format(OldCsv()
- .line_delimiter(' ')
.field('word', DataTypes.STRING())) \
.with_schema(Schema()
.field('word', DataTypes.STRING())) \
@@ -140,9 +138,13 @@ t_env.execute("tutorial_job")
{% endhighlight %}
## Executing a Flink Python Table API Program
+Firstly, you need to prepare input data in the "/tmp/input" file. You can choose the following command line to prepare the input data:
-You can run this example in your IDE or on the command line (suppose the job script file is
-WordCount.py):
+{% highlight bash %}
+$ echo "flink\npyflink\nflink" > /tmp/input
+{% endhighlight %}
+
+Next, you can run this example on the command line (Note: if the result file "/tmp/output" has already existed, you need to remove the file before running the example):
{% highlight bash %}
$ python WordCount.py
@@ -153,6 +155,14 @@ You can also submit the Python Table API program to a remote cluster, you can re
[Job Submission Examples]({{ site.baseurl }}/ops/cli.html#job-submission-examples)
for more details.
+Finally, you can see the execution result on the command line:
+
+{% highlight bash %}
+$ cat /tmp/output
+flink 2
+pyflink 1
+{% endhighlight %}
+
This should get you started with writing your own Flink Python Table API programs.
To learn more about the Python Table API, you can refer
[Flink Python Table API Docs]({{ site.pythondocs_baseurl }}/api/python) for more details.
diff --git a/docs/tutorials/python_table_api.zh.md b/docs/tutorials/python_table_api.zh.md
index b80dbff..24762ed 100644
--- a/docs/tutorials/python_table_api.zh.md
+++ b/docs/tutorials/python_table_api.zh.md
@@ -55,7 +55,6 @@ t_env = BatchTableEnvironment.create(exec_env, t_config)
{% highlight python %}
t_env.connect(FileSystem().path('/tmp/input')) \
.with_format(OldCsv()
- .line_delimiter(' ')
.field('word', DataTypes.STRING())) \
.with_schema(Schema()
.field('word', DataTypes.STRING())) \
@@ -107,7 +106,6 @@ t_env = BatchTableEnvironment.create(exec_env, t_config)
t_env.connect(FileSystem().path('/tmp/input')) \
.with_format(OldCsv()
- .line_delimiter(' ')
.field('word', DataTypes.STRING())) \
.with_schema(Schema()
.field('word', DataTypes.STRING())) \
@@ -133,7 +131,13 @@ t_env.execute("python_job")
## 执行一个Flink Python Table API程序
-可以在IDE中或者命令行中运行作业(假设作业名为WordCount.py):
+首先,你需要在文件 “/tmp/input” 中准备好输入数据。你可以选择通过如下命令准备输入数据:
+
+{% highlight bash %}
+$ echo "flink\npyflink\nflink" > /tmp/input
+{% endhighlight %}
+
+接下来,可以在命令行中运行作业(假设作业名为WordCount.py)(注意:如果输出结果文件“/tmp/output”已经存在,你需要先删除文件,否则程序将无法正确运行起来):
{% highlight bash %}
$ python WordCount.py
@@ -142,5 +146,13 @@ $ python WordCount.py
上述命令会构建Python Table API程序,并在本地mini cluster中运行。如果想将作业提交到远端集群执行,
可以参考[作业提交示例]({{ site.baseurl }}/zh/ops/cli.html#job-submission-examples)。
+最后,你可以通过如下命令查看你的运行结果:
+
+{% highlight bash %}
+$ cat /tmp/output
+flink 2
+pyflink 1
+{% endhighlight %}
+
上述教程介绍了如何编写并运行一个Flink Python Table API程序,如果想了解Flink Python Table API
的更多信息,可以参考[Flink Python Table API文档]({{ site.pythondocs_baseurl }}/api/python)。