8000 [Explain] Add the YAML format for EXPLAIN statements by qsliu2017 · Pull Request #17572 · duckdb/duckdb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Explain] Add the YAML format for EXPLAIN statements #17572

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

qsliu2017
Copy link
Contributor

YAML is a superset of JSON, and usually has less lines than JSON. With support of editor, I find it is easier to understand an explain result in YAML.

The YAML emitter implementation in this PR is very simple, since the explain result is not such complicate. Hopefully there is no corner case.


example: EXPLAIN (FORMAT YAML) SELECT SUM(i) FROM (SELECT * FROM integers i1, integers i2 UNION ALL SELECT * FROM integers i1, integers i2);
output:

- name: "UNGROUPED_AGGREGATE"
  "Aggregates": "sum_no_overflow(#0)"
  children: 
    - name: "PROJECTION"
      "__projections__": "i"
      "__estimated_cardinality__": "32"
      children: 
        - name: "UNION"
          children: 
            - name: "PROJECTION"
              "__projections__": "i"
              "__estimated_cardinality__": "16"
              children: 
                - name: "CROSS_PRODUCT"
                  children: 
                    - name: "SEQ_SCAN "
                      "Table": "integers"
                      "Type": "Sequential Scan"
                      "Projections": ""
                      "__estimated_cardinality__": "4"
                    - name: "SEQ_SCAN "
                      "Table": "integers"
                      "Type": "Sequential Scan"
                      "Projections": "i"
                      "__estimated_cardinality__": "4"
            - name: "PROJECTION"
              "__projections__": "i"
              "__estimated_cardinality__": "16"
              children: 
                - name: "CROSS_PRODUCT"
                  children: 
                    - name: "SEQ_SCAN "
                      "Table": "integers"
                      "Type": "Sequential Scan"
                      "Projections": ""
                      "__estimated_cardinality__": "4"
                    - name: "SEQ_SCAN "
                      "Table": "integers"
                      "Type": "Sequential Scan"
                      "Projections": "i"
                      "__estimated_cardinality__": "4"

@duckdb-draftbot duckdb-draftbot marked this pull request as draft May 21, 2025 04:23
@qsliu2017 qsliu2017 marked this pull request as ready for review May 21, 2025 04:23
@duckdb-draftbot duckdb-draftbot marked this pull request as draft May 21, 2025 09:43
@qsliu2017 qsliu2017 marked this pull request as ready for review May 21, 2025 10:04
Copy link
Collaborator
@Mytherin Mytherin left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I think this is a good idea. Some comments:

};

std::ostream &operator<<(std::ostream &out, const EscapedString &es) {
out << '"';
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is rather over-eager with adding quotes which reduces readability - can we only add quotes when required (i.e. when there are special characters in the string)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copy this from postgres. As comment there,

the YAML quoting rules are ridiculously complicated... so we chose to just quote everything

https://github.com/postgres/postgres/blob/84914e964b447a63c5208ca2ec11ec3abfda0879/src/backend/commands/explain_format.c?plain=1#L700-L714

@duckdb-draftbot duckdb-draftbot marked this pull request as draft June 12, 2025 22:53
@qsliu2017 qsliu2017 marked this pull request as ready for review June 12, 2025 22:54
@qsliu2017 qsliu2017 requested a review from Mytherin June 14, 2025 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0