This is an automated email from the ASF dual-hosted git repository. hxb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/flink.git
commit bf40e2dc57ebef2e50b0686a480992d77acd8cfa Author: huangxingbo <[email protected]> AuthorDate: Wed Nov 9 19:13:40 2022 +0800 [FLINK-29966][python][doc] Adds PyFlink examples doc This closes #21280. --- .../docs/examples/datastream/basic_operations.rst | 23 +++++++++ .../docs/examples/datastream/connectors.rst | 49 +++++++++++++++++++ flink-python/docs/examples/datastream/index.rst | 32 +++++++++++++ .../docs/examples/datastream/process_json_data.rst | 23 +++++++++ flink-python/docs/examples/datastream/state.rst | 23 +++++++++ flink-python/docs/examples/datastream/timer.rst | 23 +++++++++ flink-python/docs/examples/datastream/window.rst | 55 ++++++++++++++++++++++ .../docs/examples/datastream/word_count.rst | 23 +++++++++ flink-python/docs/examples/index.rst | 27 +++++++++++ .../docs/examples/table/basic_operations.rst | 23 +++++++++ flink-python/docs/examples/table/index.rst | 32 +++++++++++++ .../table/mixing_use_of_datastream_and_table.rst | 23 +++++++++ flink-python/docs/examples/table/multi_sink.rst | 23 +++++++++ flink-python/docs/examples/table/pandas.rst | 32 +++++++++++++ .../docs/examples/table/process_json_data.rst | 32 +++++++++++++ flink-python/docs/examples/table/window.rst | 36 ++++++++++++++ flink-python/docs/examples/table/word_count.rst | 23 +++++++++ 17 files changed, 502 insertions(+) diff --git a/flink-python/docs/examples/datastream/basic_operations.rst b/flink-python/docs/examples/datastream/basic_operations.rst new file mode 100644 index 00000000000..1776940d37c --- /dev/null +++ b/flink-python/docs/examples/datastream/basic_operations.rst @@ -0,0 +1,23 @@ +.. ################################################################################ + 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. + ################################################################################ + +================ +Basic Operations +================ + +.. literalinclude:: ../../../pyflink/examples/datastream/basic_operations.py diff --git a/flink-python/docs/examples/datastream/connectors.rst b/flink-python/docs/examples/datastream/connectors.rst new file mode 100644 index 00000000000..d46f0dd4565 --- /dev/null +++ b/flink-python/docs/examples/datastream/connectors.rst @@ -0,0 +1,49 @@ +.. ################################################################################ + 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. + ################################################################################ + +========== +Connectors +========== + +Kafka +===== + +Kafka With CSV Format +---------------------- + +.. literalinclude:: ../../../pyflink/examples/datastream/connectors/kafka_csv_format.py + +Kafka With Json Format +---------------------- + +.. literalinclude:: ../../../pyflink/examples/datastream/connectors/kafka_json_format.py + +Kafka With Avro Format +---------------------- + +.. literalinclude:: ../../../pyflink/examples/datastream/connectors/kafka_avro_format.py + +Pulsar +====== + +.. literalinclude:: ../../../pyflink/examples/datastream/connectors/pulsar.py + +Elasticsearch +============= + +.. literalinclude:: ../../../pyflink/examples/datastream/connectors/elasticsearch.py diff --git a/flink-python/docs/examples/datastream/index.rst b/flink-python/docs/examples/datastream/index.rst new file mode 100644 index 00000000000..c1809114567 --- /dev/null +++ b/flink-python/docs/examples/datastream/index.rst @@ -0,0 +1,32 @@ +.. ################################################################################ + 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. + ################################################################################ + +=================== +DataStream Examples +=================== + +.. toctree:: + :maxdepth: 2 + + word_count + process_json_data + basic_operations + timer + state + window + connectors diff --git a/flink-python/docs/examples/datastream/process_json_data.rst b/flink-python/docs/examples/datastream/process_json_data.rst new file mode 100644 index 00000000000..46891e32249 --- /dev/null +++ b/flink-python/docs/examples/datastream/process_json_data.rst @@ -0,0 +1,23 @@ +.. ################################################################################ + 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. + ################################################################################ + +================= +Json Data Process +================= + +.. literalinclude:: ../../../pyflink/examples/datastream/process_json_data.py diff --git a/flink-python/docs/examples/datastream/state.rst b/flink-python/docs/examples/datastream/state.rst new file mode 100644 index 00000000000..8287de621ee --- /dev/null +++ b/flink-python/docs/examples/datastream/state.rst @@ -0,0 +1,23 @@ +.. ################################################################################ + 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. + ################################################################################ + +===== +State +===== + +.. literalinclude:: ../../../pyflink/examples/datastream/state_access.py diff --git a/flink-python/docs/examples/datastream/timer.rst b/flink-python/docs/examples/datastream/timer.rst new file mode 100644 index 00000000000..cec35e91238 --- /dev/null +++ b/flink-python/docs/examples/datastream/timer.rst @@ -0,0 +1,23 @@ +.. ################################################################################ + 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. + ################################################################################ + +===== +Timer +===== + +.. literalinclude:: ../../../pyflink/examples/datastream/event_time_timer.py diff --git a/flink-python/docs/examples/datastream/window.rst b/flink-python/docs/examples/datastream/window.rst new file mode 100644 index 00000000000..fe963d4b45c --- /dev/null +++ b/flink-python/docs/examples/datastream/window.rst @@ -0,0 +1,55 @@ +.. ################################################################################ + 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. + ################################################################################ + +====== +Window +====== + +Tumble Window +============= + +Tumbling Time Window +-------------------- + +.. literalinclude:: ../../../pyflink/examples/datastream/windowing/tumbling_time_window.py + +Tumbling Count Window +--------------------- + +.. literalinclude:: ../../../pyflink/examples/datastream/windowing/tumbling_count_window.py + +Sliding Window +============== + +Sliding Time Window +------------------- + +.. literalinclude:: ../../../pyflink/examples/datastream/windowing/sliding_time_window.py + +Session Window +============== + +Session With Gap Window +----------------------- + +.. literalinclude:: ../../../pyflink/examples/datastream/windowing/session_with_gap_window.py + +Session With Dynamic Gap Window +------------------------------- + +.. literalinclude:: ../../../pyflink/examples/datastream/windowing/session_with_dynamic_gap_window.py diff --git a/flink-python/docs/examples/datastream/word_count.rst b/flink-python/docs/examples/datastream/word_count.rst new file mode 100644 index 00000000000..8d2bf533509 --- /dev/null +++ b/flink-python/docs/examples/datastream/word_count.rst @@ -0,0 +1,23 @@ +.. ################################################################################ + 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. + ################################################################################ + +========== +Word Count +========== + +.. literalinclude:: ../../../pyflink/examples/datastream/word_count.py diff --git a/flink-python/docs/examples/index.rst b/flink-python/docs/examples/index.rst new file mode 100644 index 00000000000..a240470778a --- /dev/null +++ b/flink-python/docs/examples/index.rst @@ -0,0 +1,27 @@ +.. ################################################################################ + 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. + ################################################################################ + +======== +Examples +======== + +.. toctree:: + :maxdepth: 2 + + table/index + datastream/index \ No newline at end of file diff --git a/flink-python/docs/examples/table/basic_operations.rst b/flink-python/docs/examples/table/basic_operations.rst new file mode 100644 index 00000000000..dfae9f5cf15 --- /dev/null +++ b/flink-python/docs/examples/table/basic_operations.rst @@ -0,0 +1,23 @@ +.. ################################################################################ + 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. + ################################################################################ + +================ +Basic Operations +================ + +.. literalinclude:: ../../../pyflink/examples/table/basic_operations.py diff --git a/flink-python/docs/examples/table/index.rst b/flink-python/docs/examples/table/index.rst new file mode 100644 index 00000000000..192682b3877 --- /dev/null +++ b/flink-python/docs/examples/table/index.rst @@ -0,0 +1,32 @@ +.. ################################################################################ + 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. + ################################################################################ + +============== +Table Examples +============== + +.. toctree:: + :maxdepth: 2 + + word_count + process_json_data + basic_operations + mixing_use_of_datastream_and_table + pandas + window + multi_sink diff --git a/flink-python/docs/examples/table/mixing_use_of_datastream_and_table.rst b/flink-python/docs/examples/table/mixing_use_of_datastream_and_table.rst new file mode 100644 index 00000000000..c31797a8d98 --- /dev/null +++ b/flink-python/docs/examples/table/mixing_use_of_datastream_and_table.rst @@ -0,0 +1,23 @@ +.. ################################################################################ + 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. + ################################################################################ + +================================== +Mixing Use Of Datastream And Table +================================== + +.. literalinclude:: ../../../pyflink/examples/table/mixing_use_of_datastream_and_table.py diff --git a/flink-python/docs/examples/table/multi_sink.rst b/flink-python/docs/examples/table/multi_sink.rst new file mode 100644 index 00000000000..c1df44eaa97 --- /dev/null +++ b/flink-python/docs/examples/table/multi_sink.rst @@ -0,0 +1,23 @@ +.. ################################################################################ + 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. + ################################################################################ + +========== +Multi Sink +========== + +.. literalinclude:: ../../../pyflink/examples/table/multi_sink.py diff --git a/flink-python/docs/examples/table/pandas.rst b/flink-python/docs/examples/table/pandas.rst new file mode 100644 index 00000000000..e171d7dd124 --- /dev/null +++ b/flink-python/docs/examples/table/pandas.rst @@ -0,0 +1,32 @@ +.. ################################################################################ + 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. + ################################################################################ + +====== +Pandas +====== + +Pandas UDAF +----------- + +.. literalinclude:: ../../../pyflink/examples/table/pandas/pandas_udaf.py + + +Conversion From DataFrame +------------------------- + +.. literalinclude:: ../../../pyflink/examples/table/pandas/conversion_from_dataframe.py diff --git a/flink-python/docs/examples/table/process_json_data.rst b/flink-python/docs/examples/table/process_json_data.rst new file mode 100644 index 00000000000..ef2cda81466 --- /dev/null +++ b/flink-python/docs/examples/table/process_json_data.rst @@ -0,0 +1,32 @@ +.. ################################################################################ + 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. + ################################################################################ + +================= +Json Data Process +================= + +Process Json Data +-------------------------- + +.. literalinclude:: ../../../pyflink/examples/table/process_json_data.py + + +Process Json Data With UDF +-------------------------- + +.. literalinclude:: ../../../pyflink/examples/table/process_json_data_with_udf.py diff --git a/flink-python/docs/examples/table/window.rst b/flink-python/docs/examples/table/window.rst new file mode 100644 index 00000000000..8ce06ba5ccf --- /dev/null +++ b/flink-python/docs/examples/table/window.rst @@ -0,0 +1,36 @@ +.. ################################################################################ + 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. + ################################################################################ + +====== +Window +====== + +Tumble Window +------------- + +.. literalinclude:: ../../../pyflink/examples/table/windowing/tumble_window.py + +Sliding Window +-------------- + +.. literalinclude:: ../../../pyflink/examples/table/windowing/sliding_window.py + +Session Window +-------------- + +.. literalinclude:: ../../../pyflink/examples/table/windowing/session_window.py diff --git a/flink-python/docs/examples/table/word_count.rst b/flink-python/docs/examples/table/word_count.rst new file mode 100644 index 00000000000..af2f509e297 --- /dev/null +++ b/flink-python/docs/examples/table/word_count.rst @@ -0,0 +1,23 @@ +.. ################################################################################ + 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. + ################################################################################ + +========== +Word Count +========== + +.. literalinclude:: ../../../pyflink/examples/table/word_count.py
