Difference between flink run -py and python run

307 Views Asked by At

I recently working on learning pyflink, but I was a little bit confused. We know that pyflink table API convert stream/batch into table and do some work on it and finally sink to where u want. However, there are several ways to create table env:

For batch example:

t_config = TableConfig()
env = ExecutionEnvironment.get_execution_environment()
t_env = BatchTableEnvironment.create(env, t_config)

and

env_settings = EnvironmentSettings.new_instance().in_batch_mode().use_blink_planner().build()
t_env = BatchTableEnvironment.create(evnironment_settings = env_settings)

but I found one of them only work for flink run -py batch.py, some other styles can be run as python batch.py for local run.

My question is what the difference of executionEnvironment and BatchTableEnvironment/StreamTableEnvironment, and when can use flink run -py and when can run by python interpreter with pyflink installed?

Thx

2

There are 2 best solutions below

0
On

with flink run there is some configuration to set in .sh, you could consider the flink run is some bash scripts plus to the python xx itself.

for more information you could go to $FLINK_HOME/bin/flink or flink-dist/src/flink-bin/flink

0
On

The flink run way is used to submit jobs to run on the cluster. And the way of python xxx.py is to run the job directly in the local memory