Fixing Flink’s java.lang.RuntimeException: No new data sinks have been defined since the last execution.

Flink No new data sinks have been defined since the last execution

There’s a typical error for Apache Flink rookies:

Exception in thread "main" java.lang.RuntimeException: No new data sinks have been defined since the last execution. The last execution refers to the latest call to 'execute()', 'count()', 'collect()', or 'print()'.
	at org.apache.flink.api.java.ExecutionEnvironment.createProgramPlan(ExecutionEnvironment.java:910)
	at org.apache.flink.api.java.ExecutionEnvironment.createProgramPlan(ExecutionEnvironment.java:893)
	at org.apache.flink.api.java.LocalEnvironment.execute(LocalEnvironment.java:50)
	at org.apache.flink.api.java.ExecutionEnvironment.execute(ExecutionEnvironment.java:789)
...

It is caused by the one line in the Apache Flink quickstart tutorial (Word Count example):

env.execute();

The documentation lists the code with the env.execute() statement after calling print() method on a resulting dataset when there are no sinks to proceed.

The print() method triggers the execution by itself so you don’t need to call it manually. In this case just remove the env.execute() line.

If this was not your case, try to explicitly create data sinks.

Here’s the working example of Apache Flink Java Word Count.

Leave a Reply

2 Comments on "Fixing Flink’s java.lang.RuntimeException: No new data sinks have been defined since the last execution."


Guest
Dan
2 years 17 days ago

Good Post!