Martijn Visser created FLINK-40540:
--------------------------------------
Summary: Put the rule's reason first in the planner's "Cannot
generate a valid execution plan" message
Key: FLINK-40540
URL: https://issues.apache.org/jira/browse/FLINK-40540
Project: Flink
Issue Type: Improvement
Components: Table SQL / Planner
Reporter: Martijn Visser
Assignee: Martijn Visser
When a planner rule rejects a query with a TableException during the Volcano
phase, FlinkVolcanoProgram rewraps it as "Cannot generate a valid execution
plan for the given query:" followed by the full FlinkLogical plan and only then
the rule's own message, plus a generic "Please check the documentation"
trailer. The rule sentence is the only actionable part; the plan buries it.
Users of the Java API, the SQL gateway and PyFlink see the wrapped form. The
SQL client happens to hide it because it prints the innermost cause.
Proposal: keep the wrapper exception and its cause chain, so that tests and
tools matching on the header, the type or the cause keep working, but put the
rule's message on the header line and move the plan behind a "Plan:" marker so
that tools rewriting the message can find and strip it:
Cannot generate a valid execution plan for the given query: <rule message>
Plan:
<FlinkLogical plan>
A ValidationException thrown while applying a rule gets the same shape as a
ValidationException (with the original as cause) instead of leaking as
Calcite's RuntimeException. The CannotPlanException case keeps its text and
gets the same "Plan:" marker. The "Sql optimization: " prefix on the
Calcite-wrapped path and the "Please check the documentation" trailer on rule
rejections are dropped.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)