Skip to content
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

fix: explain ast of multi table insert stmt #15527

Merged

Conversation

dantengsky
Copy link
Member

@dantengsky dantengsky commented May 14, 2024

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

Summary

fix explain ast insert first/all.

before this PR, explain ast of multiple table insert stmt panics, with this PR:

query T
EXPLAIN AST
INSERT FIRST
WHEN order_amount > 1000 THEN INTO cat.db1.t1(order_id, update_note) VALUES (order_id, 'PriorityHandling')
WHEN order_amount > 500 THEN INTO cat2.db2.t2 VALUES (order_id, 'ExpressHandling')
WHEN order_amount > 100 THEN
   INTO cat3.db3.t3 VALUES (order_id, 'StandardHandling')
   INTO cat3.db3.t4 VALUES (order_id, 'StandardHandling')
ELSE INTO processing_updates VALUES (order_id, 'ReviewNeeded')
SELECT order_id, order_amount FROM orders_placed;
----
INSERT FIRST (children 5)
├── WHEN (children 2)
│   ├── Function > (children 2)
│   │   ├── ColumnIdentifier order_amount
│   │   └── Literal UInt64(1000)
│   └── INTO (children 2)
│       ├── TableIdentifier cat.db1.t1
│       └── Columns (children 2)
│           ├── Identifier order_id
│           └── Identifier update_note
├── WHEN (children 2)
│   ├── Function > (children 2)
│   │   ├── ColumnIdentifier order_amount
│   │   └── Literal UInt64(500)
│   └── INTO (children 1)
│       └── TableIdentifier cat2.db2.t2
├── WHEN (children 3)
│   ├── Function > (children 2)
│   │   ├── ColumnIdentifier order_amount
│   │   └── Literal UInt64(100)
│   ├── INTO (children 1)
│   │   └── TableIdentifier cat3.db3.t3
│   └── INTO (children 1)
│       └── TableIdentifier cat3.db3.t4
├── ELSE (children 1)
│   └── INTO (children 1)
│       └── TableIdentifier processing_updates
└── Query (children 1)
    └── QueryBody (children 1)
        └── SelectQuery (children 2)
            ├── SelectList (children 2)
            │   ├── Target (children 1)
            │   │   └── ColumnIdentifier order_id
            │   └── Target (children 1)
            │       └── ColumnIdentifier order_amount
            └── TableList (children 1)
                └── TableIdentifier orders_placed

  • Fixes #[Link the issue here]

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

@dantengsky dantengsky force-pushed the fix-explain-ast-multi-table-insert branch from 6ed1016 to 12385d1 Compare May 14, 2024 15:35
@dantengsky dantengsky changed the title Fix: explain ast multi table insert stmt fix: explain ast multi table insert stmt May 14, 2024
@github-actions github-actions bot added the pr-bugfix this PR patches a bug in codebase label May 14, 2024
@dantengsky dantengsky changed the title fix: explain ast multi table insert stmt fix: explain ast of multi table insert stmt May 14, 2024
@dantengsky dantengsky marked this pull request as ready for review May 14, 2024 16:11
@dantengsky dantengsky requested a review from SkyFan2002 May 14, 2024 16:11
@SkyFan2002
Copy link
Member

LGTM. Thanks!

@SkyFan2002 SkyFan2002 added this pull request to the merge queue May 14, 2024
Merged via the queue into databendlabs:main with commit 1564572 May 14, 2024
83 of 84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-bugfix this PR patches a bug in codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants