()
| 5 | |
| 6 | |
| 7 | def hello_pyflink(): |
| 8 | |
| 9 | # environment |
| 10 | t_env = TableEnvironment.create(EnvironmentSettings.in_streaming_mode()) |
| 11 | |
| 12 | # source table (in-mem data generator) |
| 13 | t_env.execute_sql(""" |
| 14 | CREATE TABLE generator_source ( |
| 15 | num BIGINT |
| 16 | ) WITH ( |
| 17 | 'connector' = 'datagen', |
| 18 | 'rows-per-second' = '1' |
| 19 | )""") |
| 20 | |
| 21 | # sink table (printer to stdout) |
| 22 | t_env.execute_sql(""" |
| 23 | CREATE TABLE print_sink ( |
| 24 | num BIGINT, |
| 25 | hello STRING |
| 26 | ) WITH ( |
| 27 | 'connector' = 'print' |
| 28 | )""") |
| 29 | |
| 30 | # read source -> process -> write sink |
| 31 | # using INSERT INTO ... SELECT ... FROM |
| 32 | t_env.execute_sql(""" |
| 33 | INSERT INTO print_sink SELECT ABS(num) % 10 AS num, 'hello 🐍 pyflink 🐿️ ' AS hello FROM generator_source""" |
| 34 | ).wait() |
| 35 | |
| 36 | |
| 37 | if __name__ == '__main__': |
no outgoing calls
no test coverage detected