Skip to content

[FLINK-40540][table-planner] Put the rule's reason first in the planning error - #29072

Merged
MartijnVisser merged 1 commit into
apache:masterfrom
MartijnVisser:FLINK-40540-reason-first-planning-error
Sep 4, 2026
Merged

[FLINK-40540][table-planner] Put the rule's reason first in the planning error#29072
MartijnVisser merged 1 commit into
apache:masterfrom
MartijnVisser:FLINK-40540-reason-first-planning-error

Conversation

@MartijnVisser

@MartijnVisser MartijnVisser commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of the change

When a rule rejects a query during the Volcano phase, FlinkVolcanoProgram wraps the exception as "Cannot generate a valid execution plan for the given query:" followed by the full logical plan and only then the rule's own message, so the actionable sentence is buried. A ValidationException thrown from a rule's onMatch() is not caught at all and reaches users as Calcite's "Error while applying rule ..." RuntimeException.

This change keeps the wrapper and its cause chain, so nothing matching on the header, the type or the cause is affected, but puts the rule's reason on the header line and lists the plan after a Plan: marker so that tools rewriting the message can find it:

Cannot generate a valid execution plan for the given query: Window SessionGroupWindow('w$, ts, 1800000) is not supported right now.

Plan:
FlinkLogicalWindowAggregate(window=[SessionGroupWindow('w$, ts, 1800000)], select=[COUNT(*) AS cnt])
+- ...

Brief change log

  • FlinkVolcanoProgram builds one message layout for CannotPlanException and for a TableException or ValidationException thrown by a rule, looking through Calcite's RuntimeException wrapper; other exceptions propagate unchanged
  • Drops the "Sql optimization: " prefix and the "Please check the documentation" trailer from rule rejections

Verifying this change

This change is already covered by existing tests: all assertions on the header text, exception type and cause chain pass unchanged (./mvnw verify for flink-table-planner). Added assertions for the new layout in GroupWindowTest#testNonPartitionedSessionWindow and OverAggregateTest#testExclusionGroupIsNotSupported, and unit tests for FlinkVolcanoProgram#unwrapRuleException.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Claude Code (Claude Fable 5.1)

…ing error

A rule that rejects a query already explains why, but the message buried
that sentence behind the full logical plan. Put the reason on the header
line and mark the plan with "Plan:" so that tools rewriting the message
can find it. The wrapper type and cause chain stay as they are. A
ValidationException thrown while applying a rule now gets the same
treatment instead of leaking as Calcite's RuntimeException.

Generated-by: Claude Code (Claude Fable 5.1)
@MartijnVisser
MartijnVisser force-pushed the FLINK-40540-reason-first-planning-error branch from ee2b45c to cc04471 Compare September 2, 2026 15:23
@flinkbot

flinkbot commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@MartijnVisser

Copy link
Copy Markdown
Contributor Author

@flinkbot run azure

@MartijnVisser
MartijnVisser merged commit dd2bc4b into apache:master Sep 4, 2026
@MartijnVisser
MartijnVisser deleted the FLINK-40540-reason-first-planning-error branch September 4, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants