Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-23158

Source transformation is not added to the StreamExecutionEnvironment explicitly

    XMLWordPrintableJSON

    Details

      Description

      Currently for the implementation of `StreamExecutionEnvironment#fromSource()` and `StreamExecutionEnvironment#addSource()`, the SourceTransformation is not added to the transformation list explicitly, this make the job with a single source could not run directly. For example,

      StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
      		env.addSource(new SourceFunction<String>() {
      			@Override
      			public void run(SourceContext<String> sourceContext) throws Exception {
      
      			}
      
      			@Override
      			public void cancel() {
      
      			}
      		});
      		env.execute();
      

      would throws the exception:

      Exception in thread "main" java.lang.IllegalStateException: No operators defined in streaming topology. Cannot execute.
      	at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.getStreamGraphGenerator(StreamExecutionEnvironment.java:2019)
      	at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.getStreamGraph(StreamExecutionEnvironment.java:2010)
      	at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.getStreamGraph(StreamExecutionEnvironment.java:1995)
      	at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:1834)
      	at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:1817)
      	at test.SingleSourceTest.main(SingleSourceTest.java:41)
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                gaoyunhaii Yun Gao
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: