risingwavelabs / risingwave

Best-in-class stream processing, analytics, and management. Perform continuous analytics, or build event-driven applications, real-time ETL pipelines, and feature stores in minutes. Unified streaming and batch. PostgreSQL compatible.
https://go.risingwave.com/slack
Apache License 2.0
7.07k stars 582 forks source link

feat(frontend): support xml, yaml format in explain output #19400

Closed lyang24 closed 1 week ago

lyang24 commented 1 week ago

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Please do not leave this empty!

Please explain IN DETAIL what the changes are in this PR and why they are needed:

Checklist

Documentation

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

Release note Public Preview: Do note that the structure and format of EXPLAIN FORMAT YAML, XML is considered unstable, and may change overtime.

After this PR, two new explain option are supported FORMAT (XML | YAML) For FORMAT XML, it will output xml for logical and physical plans. For FORMAT YAML, it will output xml for logical and physical plans. examples: YAML

CREATE TABLE t (v1 int);
    explain (physical, format yaml) create materialized view m1 as SELECT approx_percentile(0.5) WITHIN GROUP (order by v1) from t;

YAML result

    name: StreamMaterialize
    fields:
      columns:
      - approx_percentile
      pk_columns: []
      pk_conflict: NoCheck
      stream_key: []
    children:
    - name: StreamGlobalApproxPercentile
      fields:
        quantile: 0.5:Float64
        relative_error: 0.01:Float64
      children:
      - name: StreamExchange
        fields:
          dist: Single
        children:
        - name: StreamLocalApproxPercentile
          fields:
            percentile_col: $expr1
            quantile: 0.5:Float64
            relative_error: 0.01:Float64
          children:
          - name: StreamProject
            fields:
              exprs:
              - t.v1::Float64 as $expr1
              - t._row_id
            children:
            - name: StreamTableScan
              fields:
                columns:
                - v1
                - _row_id
                table: t
              children: []

XML

  CREATE TABLE t (v1 int);
    explain (physical, format xml) create materialized view m1 as SELECT approx_percentile(0.5) WITHIN GROUP (order by v1) from t;

XML RESULT

 <XmlNode><name>StreamMaterialize</name><fields><columns>approx_percentile</columns><pk_conflict>NoCheck</pk_conflict></fields><children><name>StreamGlobalApproxPercentile</name><fields><quantile>0.5:Float64</quantile><relative_error>0.01:Float64</relative_error></fields><children><name>StreamExchange</name><fields><dist>Single</dist></fields><children><name>StreamLocalApproxPercentile</name><fields><percentile_col>$expr1</percentile_col><quantile>0.5:Float64</quantile><relative_error>0.01:Float64</relative_error></fields><children><name>StreamProject</name><fields><exprs>t.v1::Float64 as $expr1</exprs><exprs>t._row_id</exprs></fields><children><name>StreamTableScan</name><fields><columns>v1</columns><columns>_row_id</columns><table>t</table></fields></children></children></children></children></children></XmlNode>

kwannoel commented 1 week ago

Thanks for your contribution!

There are more related issues for EXPLAIN: https://github.com/risingwavelabs/risingwave/issues/19361. If you're interested, feel free to contribute for these as well.

kwannoel commented 1 week ago

Could you also add a Release Note, since this is a new feature. You can copy the Release Note from https://github.com/risingwavelabs/risingwave/pull/19041, and adapt it for yaml and xml formats.

lyang24 commented 1 week ago

Could you also add a Release Note, since this is a new feature. You can copy the Release Note from #19041, and adapt it for yaml and xml formats.

Yes i mirrored the release note with the example pr, do we also need the release note in commit msg?

kwannoel commented 1 week ago

Could you also add a Release Note, since this is a new feature. You can copy the Release Note from #19041, and adapt it for yaml and xml formats.

Yes i mirrored the release note with the example pr, do we also need the release note in commit msg?

No just PR description is fine.