sunjincheng121 commented on a change in pull request #8675: 
[FLINK-12716][python] Add an interactive shell for Python Table API
URL: https://github.com/apache/flink/pull/8675#discussion_r293642907
 
 

 ##########
 File path: docs/ops/python_shell.zh.md
 ##########
 @@ -0,0 +1,179 @@
+---
+title: "Python REPL"
+nav-parent_id: ops
+nav-pos: 7
+---
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+Flink附带了一个集成的交互式Python Shell。
+它既能够运行在本地启动的local模式,也能够运行在集群启动的cluster模式下。
+
+为了使用Flink的Python Shell,你只需要在Flink的binary目录下执行:
+
+{% highlight bash %}
+bin/pyflink-shell.sh local
+{% endhighlight %}
+
+关于如何在一个Cluster集群上运行Python shell,可以参考下面的启动那一节的内容
+
+## 使用
+
+当前Python shell支持Table API的功能。
+在启动之后,Table Environment的相关内容将会被自动加载。
+可以通过变量"bt_env"来使用BatchTableEnvironment,通过变量"st_env"来使用StreamTableEnvironment。
+
+### Table API
+
+下面的内容是关于如何通过Python Table API来实现一个简单的作业:
+<div class="codetabs" markdown="1">
+<div data-lang="stream" markdown="1">
+{% highlight python %}
+>>> import tempfile
+>>> import os
+>>> sink_path = tempfile.gettempdir() + '/streaming.csv'
+>>> if os.path.isfile(sink_path):
+>>>     os.remove(sink_path)
+>>> t = st_env.from_elements([(1, 'hi', 'hello'), (2, 'hi', 'hello')], ['a', 
'b', 'c'])
+>>> st_env.connect(FileSystem().path(sink_path))\
+>>>     .with_format(OldCsv()
+>>>         .field_delimiter(',')
+>>>         .field("a", DataTypes.BIGINT())
+>>>         .field("b", DataTypes.STRING())
+>>>         .field("c", DataTypes.STRING()))\
+>>>     .with_schema(Schema()
+>>>         .field("a", DataTypes.BIGINT())
+>>>         .field("b", DataTypes.STRING())
+>>>         .field("c", DataTypes.STRING()))\
+>>>     .register_table_sink("stream_sink")
+>>> t.select("a + 1, b, c")\
+>>>     .insert_into("stream_sink")
+>>> st_env.execute()
+{% endhighlight %}
+</div>
+<div data-lang="batch" markdown="1">
+{% highlight python %}
+>>> import tempfile
+>>> import os
+>>> sink_path = tempfile.gettempdir() + '/batch.csv'
+>>> if os.path.isfile(sink_path):
+>>>     os.remove(sink_path)
+>>> t = bt_env.from_elements([(1, 'hi', 'hello'), (2, 'hi', 'hello')], ['a', 
'b', 'c'])
+>>> bt_env.connect(FileSystem().path(sink_path))\
+>>>     .with_format(OldCsv()
+>>>         .field_delimiter(',')
+>>>         .field("a", DataTypes.BIGINT())
+>>>         .field("b", DataTypes.STRING())
+>>>         .field("c", DataTypes.STRING()))\
+>>>     .with_schema(Schema()
+>>>         .field("a", DataTypes.BIGINT())
+>>>         .field("b", DataTypes.STRING())
+>>>         .field("c", DataTypes.STRING()))\
+>>>     .register_table_sink("batch_sink")
+>>> t.select("a + 1, b, c")\
+>>>     .insert_into("batch_sink")
+>>> bt_env.execute()
+{% endhighlight %}
+</div>
+</div>
+
+## 启动
+
+为了概览Python Shell提供的可选参数,可以使用:
+
+{% highlight bash %}
+bin/pyflink-shell.sh --help
+{% endhighlight %}
+
+### Local
+
+可以指定Python Shell运行在local模式下,只需要执行:
+
+{% highlight bash %}
+bin/pyflink-shell.sh local
+{% endhighlight %}
+
+
+### Remote
+
+可以指定Python Shell运行在一个指定的JobManager上,通过关键字`remote`和对应的JobManager
 
 Review comment:
   We can delete `可以指定`.

----------------------------------------------------------------
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


With regards,
Apache Git Services

Reply via email to