Skip to content

Conversation

forsaken628
Copy link
Collaborator

@forsaken628 forsaken628 commented Mar 26, 2025

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

explain(verbose) optimized select date from (select *, 'year' as date from t1 left join t2 on t1.a = t2.b) where date = '';

EvalScalar
├── scalars: [t1.a (#0) AS (#0), t2.b (#1) AS (#1), 'year' AS (#2)]
├── output columns: [default.t1.a (#0), default.t2.b (#1), derived.date (#2)]
├── outer columns: []
├── used columns: [default.t1.a (#0), default.t2.b (#1), derived.date (#2)]
├── cardinality: 0.000
├── precise cardinality: N/A
├── statistics
└── Join(Left)
    ├── build keys: [t2.b (#1)]
    ├── probe keys: [t1.a (#0)]
    ├── other filters: []
    ├── output columns: [default.t1.a (#0), default.t2.b (#1)]
    ├── outer columns: []
    ├── used columns: [default.t1.a (#0), default.t2.b (#1)]
    ├── cardinality: 0.000
    ├── precise cardinality: N/A
    ├── statistics
    ├── Filter
    │   ├── filters: [eq('year', '')]
    │   ├── output columns: [default.t1.a (#0)]
    │   ├── outer columns: []
    │   ├── used columns: [default.t1.a (#0)]
    │   ├── cardinality: 0.000
    │   ├── precise cardinality: N/A
    │   ├── statistics
    │   └── Scan
    │       ├── table: default.t1 (#0)
    │       ├── filters: [eq('year', '')]
    │       ├── order by: []
    │       ├── limit: NONE
    │       ├── output columns: [default.t1.a (#0)]
    │       ├── outer columns: []
    │       ├── used columns: [default.t1.a (#0)]
    │       ├── cardinality: 0.000
    │       ├── precise cardinality: 0
    │       └── statistics
    └── Filter
        ├── filters: [eq('year', '')]
        ├── output columns: [default.t2.b (#1)]
        ├── outer columns: []
        ├── used columns: [default.t2.b (#1)]
        ├── cardinality: 0.000
        ├── precise cardinality: N/A
        ├── statistics
        └── Scan
            ├── table: default.t2 (#1)
            ├── filters: [eq('year', '')]
            ├── order by: []
            ├── limit: NONE
            ├── output columns: [default.t2.b (#1)]
            ├── outer columns: []
            ├── used columns: [default.t2.b (#1)]
            ├── cardinality: 0.000
            ├── precise cardinality: 0
            └── statistics

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions bot added the pr-chore this PR only has small changes that no need to record, like coding styles. label Mar 26, 2025
@forsaken628 forsaken628 marked this pull request as ready for review March 26, 2025 17:19
@BohuTANG BohuTANG requested a review from Copilot March 27, 2025 00:29
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the formatting infrastructure for explain plans by replacing the simple verbose boolean flag with a more robust FormatOptions configuration to include additional output details such as column indices.

  • Update function signatures (explain, format_indent, etc.) to use FormatOptions instead of a boolean verbose flag.
  • Introduce and integrate MetadataIdHumanizer and update formatting logic across planner, interpreter, and test modules.
  • Update tests to reflect the new API for formatting output.

Reviewed Changes

Copilot reviewed 12 out of 20 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/query/sql/src/planner/plans/replace.rs Updated explain signature to use FormatOptions instead of verbose bool.
src/query/sql/src/planner/plans/insert.rs Updated explain and format_insert_source signatures to use FormatOptions.
src/query/sql/src/planner/mod.rs Re-exported format module with updated functionality.
src/query/sql/src/planner/format/* Refactored formatting helpers; removed unused code and integrated MetadataIdHumanizer.
src/query/service/tests/it/sql/planner/optimizer/* Updated tests to pass Default::default() FormatOptions instead of false.
src/query/service/src/interpreters/interpreter_explain.rs Updated explain method calls to create and pass FormatOptions.
src/query/service/src/interpreters/access/management_mode_access.rs Updated access error messages to use the new format_indent API.
Files not reviewed (8)
  • tests/sqllogictests/suites/mode/cluster/explain_v2.test: Language not supported
  • tests/sqllogictests/suites/mode/standalone/explain/explain.test: Language not supported
  • tests/sqllogictests/suites/mode/standalone/explain/explain_sequence.test: Language not supported
  • tests/sqllogictests/suites/mode/standalone/explain/explain_verbose.test: Language not supported
  • tests/sqllogictests/suites/mode/standalone/explain/insert.test: Language not supported
  • tests/sqllogictests/suites/mode/standalone/explain/subquery.test: Language not supported
  • tests/sqllogictests/suites/mode/standalone/explain/table_sample.test: Language not supported
  • tests/sqllogictests/suites/mode/standalone/explain_native/explain.test: Language not supported

@forsaken628 forsaken628 requested a review from sundy-li March 27, 2025 06:32
@forsaken628 forsaken628 merged commit 6c7d602 into databendlabs:main Mar 27, 2025
170 of 175 checks passed
@forsaken628 forsaken628 deleted the explain branch March 27, 2025 07:38
@forsaken628 forsaken628 mentioned this pull request Mar 27, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-chore this PR only has small changes that no need to record, like coding styles.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants