You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/06/10 04:34:25 UTC

[GitHub] [flink] sunjincheng121 commented on a change in pull request #8641: [FLINK-12757][python] Improves the word_count example to use the descriptor API

sunjincheng121 commented on a change in pull request #8641: [FLINK-12757][python] Improves the word_count example to use the descriptor API
URL: https://github.com/apache/flink/pull/8641#discussion_r291877199
 
 

 ##########
 File path: flink-python/pyflink/table/examples/batch/word_count.py
 ##########
 @@ -39,41 +34,40 @@ def word_count():
               "License you may not use this file except in compliance " \
               "with the License"
 
-    with open(source_path, 'w') as f:
-        for word in content.split(" "):
-            f.write(",".join([word, "1"]))
-            f.write("\n")
-            f.flush()
-        f.close()
-
     t_config = TableConfig.Builder().as_batch_execution().build()
     t_env = TableEnvironment.create(t_config)
 
-    field_names = ["word", "cout"]
-    field_types = [DataTypes.STRING(), DataTypes.BIGINT()]
-
-    # register Orders table in table environment
-    t_env.register_table_source(
-        "Word",
-        CsvTableSource(source_path, field_names, field_types))
-
     # register Results table in table environment
     tmp_dir = tempfile.gettempdir()
-    tmp_csv = tmp_dir + '/streaming2.csv'
-    if os.path.isfile(tmp_csv):
-        os.remove(tmp_csv)
+    result_dir = tmp_dir + '/result'
+    if os.path.exists(result_dir):
+        try:
+            shutil.rmtree(result_dir)
 
 Review comment:
   we should check the file by follows code:
   ```
               if os.path.isfile(result_dir):
                   os.remove(result_dir)
               else:
                   shutil.rmtree(result_dir)
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services