Skip to content

Conversation

@andylokandy
Copy link
Contributor

  • refactor(planner): minimize ScalarExpr
  • improve

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

Summary

Summary about this PR

Closes #issue

@vercel
Copy link

vercel bot commented Mar 18, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
databend ⬜️ Ignored (Inspect) Visit Preview Apr 12, 2023 3:43pm

@andylokandy andylokandy changed the title refactor(planner): minimize ScalarExpr" refactor(planner): minimize ScalarExpr Mar 18, 2023
@mergify mergify bot added the pr-refactor this PR changes the code base without new features or bugfix label Mar 18, 2023
Copy link
Member

@sundy-li sundy-li left a comment

Choose a reason for hiding this comment

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

Nice simplification!

Copy link
Contributor

@xudong963 xudong963 left a comment

Choose a reason for hiding this comment

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

After the ticket, I think tpcds q4 stackoverflow will be solved, please check again @RinChanNOWWW

@BohuTANG
Copy link
Member

Conflicting files
src/query/sql/src/planner/semantic/type_check.rs

@RinChanNOWWW
Copy link
Contributor

After the ticket, I think tpcds q4 stackoverflow will be solved, please check again @RinChanNOWWW

It seems that it will also stackoverflow, because the recursion counts are the same.

@andylokandy
Copy link
Contributor Author

andylokandy commented Mar 21, 2023

This PR hit on a weird bug that could be solved by #10314

The steps to reproduce:

> CREATE TABLE square (n INT, sq INT)
> INSERT INTO square VALUES (1,1), (2,4), (3,9), (4,16), (5,25), (6,36)

> CREATE TABLE pairs (a INT, b INT)
> INSERT INTO pairs VALUES (1,1), (1,2), (1,3), (1,4), (1,5), (1,6), (2,3), (2,4), (2,5), (2,6), (3,4), (3,5), (3,6), (4,5), (4,6)

> explain  SELECT n FROM pairs LEFT JOIN square ON b = sq where n is not null
+------------------------------------------------------------------------------------------------------------------------+
| explain                                                                                                                |
+------------------------------------------------------------------------------------------------------------------------+
| HashJoin                                                                                                               |
| ├── join type: INNER                                                                                                   |
| ├── build keys: [square.sq (#3)]                                                                                       |
| ├── probe keys: [CAST(pairs.b (#1) AS Int32 NULL)]                                                                     |
| ├── filters: []                                                                                                        |
| ├── estimated rows: 0.71                                                                                               |
| ├── Filter(Build)                                                                                                      |
| │   ├── filters: [true]                                                                                                |
| │   ├── estimated rows: 2.00                                                                                           |
| │   └── TableScan                                                                                                      |
| │       ├── table: default.default.square                                                                              |
| │       ├── read rows: 6                                                                                               |
| │       ├── read bytes: 110                                                                                            |
| │       ├── partitions total: 1                                                                                        |
| │       ├── partitions scanned: 1                                                                                      |
| │       ├── pruning stats: [segments: <range pruning: 1 to 1>, blocks: <range pruning: 1 to 1, bloom pruning: 0 to 0>] |
| │       ├── push downs: [filters: [true], limit: NONE]                                                                 |
| │       └── estimated rows: 6.00                                                                                       |
| └── TableScan(Probe)                                                                                                   |
|     ├── table: default.default.pairs                                                                                   |
|     ├── read rows: 15                                                                                                  |
|     ├── read bytes: 69                                                                                                 |
|     ├── partitions total: 1                                                                                            |
|     ├── partitions scanned: 1                                                                                          |
|     ├── pruning stats: [segments: <range pruning: 1 to 1>, blocks: <range pruning: 1 to 1, bloom pruning: 0 to 0>]     |
|     ├── push downs: [filters: [], limit: NONE]                                                                         |
|     ├── output columns: [b]                                                                                            |
|     └── estimated rows: 15.00                                                                                          |
+------------------------------------------------------------------------------------------------------------------------+

The left outer join was converted to an inner join and resulting in a type error.

@xudong963 Could you take a look to see if we can fix it before #10314?

@andylokandy
Copy link
Contributor Author

awaiting #10710

@andylokandy andylokandy marked this pull request as draft March 22, 2023 13:35
@andylokandy andylokandy marked this pull request as ready for review April 12, 2023 13:11
@andylokandy andylokandy merged commit 28f6887 into databendlabs:main Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-refactor this PR changes the code base without new features or bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants