The question is cross posted on Stack Overflow
https://stackoverflow.com/questions/67195207/flink-not-able-to-sink-a-stream-into-csv
.

I am trying to sink a stream into filesystem in csv format using PyFlink,
however it does not work.

```python
# stream_to_csv.py
from pyflink.table import EnvironmentSettings, StreamTableEnvironment

env_settings =
EnvironmentSettings.new_instance().in_streaming_mode().use_blink_planner().build()
table_env = StreamTableEnvironment.create(environment_settings=env_settings)

table_env.execute_sql("""
    CREATE TABLE datagen (
        id INT,
        data STRING
    ) WITH (
        'connector' = 'datagen',
        'rows-per-second' = '1'
    )
""")

table_env.execute_sql("""
    CREATE TABLE print (
        id INT,
        data STRING
    ) WITH (
        'connector' = 'filesystem',
        'format' = 'csv',
        'path' = '/tmp/output'
    )
""")

table_env.execute_sql("""
INSERT INTO print
SELECT id, data
FROM datagen
""").wait()
```

To run the script:

```
$ python stream_to_csv.py
```

I expect records go to /tmp/output folder, however that doesn't happen.

```
$ ~ ls /tmp/output
(nothing shown here)
```

Anything I miss?

Best,
Yik San

Reply via email to