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: add better explain for merge into #14005

Merged
merged 8 commits into from
Dec 13, 2023

Conversation

JackTan25
Copy link
Contributor

@JackTan25 JackTan25 commented Dec 13, 2023

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

Summary

Summary about this PR

mysql> explain MERGE INTO salaries USING (SELECT * FROM employees) as employees ON salaries.employee_id = 
employees.employee_id WHEN MATCHED AND employees.department = 'HR' THEN UPDATE SET salaries.salary = 
salaries.salary + 1000.00 WHEN MATCHED THEN UPDATE SET salaries.salary = salaries.salary + 500.00 WHEN NOT 
MATCHED THEN INSERT (employee_id, salary) VALUES (employees.employee_id, 55000.00);
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| explain                                                                                                                                                                     |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| MergeInto:                                                                                                                                                                  |
| target_table: default.default.salaries                                                                                                                                      |
| ├── matched update: [condition: eq(employees.department (#2), 'HR'),update set salary = plus(salaries.salary (#4), 1000.00)]                                                |
| ├── matched update: [condition: None,update set salary = plus(salaries.salary (#4), 500.00)]                                                                                |
| ├── unmatched insert: [condition: None,insert into (employee_id,salary) values(CAST(employees.employee_id (#0) AS Int32 NULL),CAST(55000.00 AS Decimal(10, 2) NULL))]       |
| └── HashJoin: RIGHT OUTER                                                                                                                                                   |
|     ├── equi conditions: [eq(salaries.employee_id (#3), employees.employee_id (#0))]                                                                                        |
|     ├── non-equi conditions: []                                                                                                                                             |
|     ├── LogicalGet                                                                                                                                                          |
|     │   ├── table: default.default.salaries                                                                                                                                 |
|     │   ├── filters: []                                                                                                                                                     |
|     │   ├── order by: []                                                                                                                                                    |
|     │   └── limit: NONE                                                                                                                                                     |
|     └── EvalScalar                                                                                                                                                          |
|         ├── scalars: [employees.employee_id (#0), employees.employee_name (#1), employees.department (#2)]                                                                  |
|         └── LogicalGet                                                                                                                                                      |
|             ├── table: default.default.employees                                                                                                                            |
|             ├── filters: []                                                                                                                                                 |
|             ├── order by: []                                                                                                                                                |
|             └── limit: NONE                                                                                                                                                 |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
20 rows in set (0.11 sec)
Read 0 rows, 0.00 B in 0.005 sec., 0 rows/sec., 0.00 B/sec.

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test

This change is Reviewable

@github-actions github-actions bot added the pr-bugfix this PR patches a bug in codebase label Dec 13, 2023
@JackTan25 JackTan25 marked this pull request as ready for review December 13, 2023 10:14
@xudong963
Copy link
Member

You can add a explain merge into test

@leiysky
Copy link
Contributor

leiysky commented Dec 13, 2023

It's better to move the test to this folder, which is for the explain tests running in standalone mode.

@BohuTANG BohuTANG merged commit a1cfc7a into databendlabs:main Dec 13, 2023
68 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.

4 participants