Home / Flink / Query compilation
Flink SQL: Cannot generate a valid execution plan for the given query
org.apache.flink.table.api.TableExceptionCannot generate a valid execution plan for the given query:The planner could not turn the query into an executable plan. The message prints the logical plan followed by the reason; most often the query uses a feature that is not supported in streaming mode, such as a regular join or ORDER BY on a non-time column over an unbounded stream.
Common causes
- ORDER BY on a non-time attribute, or without LIMIT, over an unbounded streaming source.How to confirm: The plan in the message contains a Sort node over a streaming scan.
- A temporal or lookup join is written without the FOR SYSTEM_TIME AS OF clause, or the right side does not support lookups.How to confirm: The plan shows a Join node whose right input is a table that cannot be looked up.
- An operation that needs to update earlier results feeds a sink that only accepts appends.How to confirm: The text after the plan mentions update or retraction changes.
How to fix it
Read the reason printed after the plan; it names the unsupported operation. Rewrite that part, for example add LIMIT to ORDER BY, or order by a time attribute.
For lookup joins, use FOR SYSTEM_TIME AS OF on a processing-time attribute and a connector that supports lookups (JDBC, HBase).
Where the message comes from
FlinkVolcanoProgram.scalainapache/flinkatrelease-2.3.0- Message checked in Flink 2.3.0