Skip to content

[FLINK-39090][SQL] Enhance structured condition display of Explain output#27610

Open
featzhang wants to merge 4 commits intoapache:masterfrom
featzhang:feature/join-condition-structured-display
Open

[FLINK-39090][SQL] Enhance structured condition display of Explain output#27610
featzhang wants to merge 4 commits intoapache:masterfrom
featzhang:feature/join-condition-structured-display

Conversation

@featzhang
Copy link
Copy Markdown
Member

What is the purpose of the change

This PR enhances the explain output of FlinkLogicalJoin to display join conditions in a more readable and structured format. Instead of showing low-level positional references like =($0, $3), it now displays actual field names in a clear format.

Before:

Join(condition=[=($0, $3)])

After:

Join:
  Type: INNER
  Condition: user_id = id

Brief change log

  • Add explainTerms override method in FlinkLogicalJoin class
  • Implement formatJoinCondition method for recursive RexNode condition parsing
  • Implement formatOperand method for field reference resolution
  • Support for EQUALS, AND, OR operators with proper field name resolution
  • Use FlinkRexUtil.getExpressionString as fallback for complex expressions

Verifying this change

This change is a display-only enhancement and can be verified by:

  1. Build the flink-table-planner module:

    ./mvnw clean install -DskipTests -Pfast -pl flink-table/flink-table-planner
  2. Run EXPLAIN queries in Flink SQL Client with joins:

    EXPLAIN SELECT * FROM orders o JOIN users u ON o.user_id = u.id;
  3. Verify the join condition is displayed with field names instead of positional references

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 (Enhancement only)
  • If yes, how is the feature documented? Not applicable

This change only enhances the explain output format and does not modify any RelNode structure, query optimization logic, or runtime behavior. It has zero impact on performance and is 100% backward compatible.

@flinkbot
Copy link
Copy Markdown
Collaborator

flinkbot commented Feb 14, 2026

CI report:

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

@featzhang featzhang changed the title [table-planner] Enhance FlinkLogicalJoin explain output with structured condition display [FLINK-39090][SQL] Enhance structured condition display of Explain output Feb 14, 2026
@featzhang featzhang force-pushed the feature/join-condition-structured-display branch from 358eded to 27780c0 Compare March 4, 2026 00:58
@featzhang featzhang closed this Mar 16, 2026
@featzhang featzhang reopened this Mar 16, 2026
@featzhang featzhang force-pushed the feature/join-condition-structured-display branch 2 times, most recently from 56b1244 to 675130d Compare March 17, 2026 21:38
featzhang added a commit to featzhang/flink that referenced this pull request Mar 18, 2026
…lain output

This commit includes the following improvements:

1. Fix projection field alias display to avoid duplicate output
   - Enhanced projection field alias handling in RelTreeWriterImpl
   - Added utility method for enhanced projection field alias display
   - Integrated projection field alias enhancement into explain output

2. Enhance FlinkLogicalCalc explain output
   - Added structured filter condition display in explain output
   - Improved readability of FlinkLogicalCalc explain plans

3. Enhance FlinkLogicalJoin explain output
   - Added structured condition display in explain output
   - Improved readability of FlinkLogicalJoin explain plans

4. Code quality improvements
   - Removed demo test file
   - Auto-formatted code with spotless

Changes affect:
- 180 files total (111 modified)
-主要集中在flink-table-planner模块
- 1909 insertions, 3005 deletions

This fixes CI test failures related to projection field alias display
and improves the overall explain output quality.

Related: FLINK-39089, PR apache#27610
…ed filter condition display

This commit enhances the EXPLAIN output for FlinkLogicalCalc (Filter) to display filter conditions with actual field names instead of positional references, improving readability and debuggability.

Changes:
- Override explainTerms method in FlinkLogicalCalc class
- Add formatFilterCondition method to parse and format filter conditions
- Support common comparison operators (>, <, >=, <=, =, <>)
- Support logical operators (AND, OR, NOT)
- Fallback to default formatting for complex expressions
- Add unit tests for filter condition formatting

Example:
Before: Filter(condition=[>($2, 100)])
After:  Filter:
          amount > 100

This follows the same approach as FlinkLogicalJoin condition display and does not modify any query optimization logic.
Remove the demo test file. Actual testing should be done through updating XML files in existing test cases.
@featzhang featzhang force-pushed the feature/join-condition-structured-display branch from 675130d to da64458 Compare March 18, 2026 04:48
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.

2 participants