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

[Tracking] Refactor SQL layer #1217

Closed
5 tasks
leiysky opened this issue Jul 28, 2021 · 9 comments
Closed
5 tasks

[Tracking] Refactor SQL layer #1217

leiysky opened this issue Jul 28, 2021 · 9 comments

Comments

@leiysky
Copy link
Collaborator

leiysky commented Jul 28, 2021

To build a robust SQL processing system, it's necessary to divide the components clearly. It is helpful to understand the code.

RFC: https://databend.rs/doc/contributing/rfcs/new-sql-planner-framework

Tracking issue for RFC: #1853

Tasks:

  • Parser: the component to parse SQL string into AST(Abstract Syntax Tree) [Tracking] Refactor SQL Parser #1218
  • Binder: the component takes AST as input and produce a logical plan [Tracking] Refactor PlanBuilder #1219
  • Optimizer: the component can do some optimization to a logical plan, and eventually produce a nice physical plan
  • Catalog: the component maintains all items in the database(e.g. table, column, index, function), which can help Binder to build a correct logical plan Catalog API #867
  • Executor: the component to execute physical plan and produce query result
@zhang2014
Copy link
Member

Maybe we will follow it:
image

@leiysky
Copy link
Collaborator Author

leiysky commented Jul 29, 2021

Maybe we will follow it:

Yes, it's exactly what I mean.

Most of the RDBMS basicly follows the architecture. The benefits are:

  • Friendly to database developers, they can get up with the project quickly.
  • We can utilize the generic approaches in DB area to improve our system.

And the most important reason is, I'm familiar with this 🤣 .

@zhang2014
Copy link
Member

zhang2014 commented Jul 29, 2021

Does the picture come from the lecture of CMU 15-445?

It from https://15721.courses.cs.cmu.edu/spring2020/

@leiysky
Copy link
Collaborator Author

leiysky commented Jul 29, 2021

Does the picture come from the lecture of CMU 15-445?

It from https://15721.courses.cs.cmu.edu/spring2020/

I've followed Andy's coureses for years. 15721 is a nice course which presents the latest academic results and industrial development every year.

@leiysky leiysky changed the title Tracking: Refactor SQL layer [Tracking] Refactor SQL layer Sep 16, 2021
@leiysky leiysky added this to In progress in SQL engine refactor Oct 6, 2021
@leiysky leiysky moved this from In progress to To do in SQL engine refactor Oct 6, 2021
@leiysky leiysky closed this as completed May 13, 2022
SQL engine refactor automation moved this from To do to Done May 13, 2022
@FANNG1
Copy link
Collaborator

FANNG1 commented May 16, 2022

@BohuTANG
Copy link
Member

https://github.com/datafuselabs/databend/blob/main/website/databend/docs/dev/rfcs/query/0005-new-sql-planner-framework.md is 404 , @PsiACE could you update the latest rfc doc?

Sure, please forward to https://databend.rs/doc/contributing/rfcs/new-sql-planner-framework

@dusx1981
Copy link
Contributor

dusx1981 commented Jan 8, 2023

Regarding determining the rules used by Operator, GPORCA's solution is to use bitmaps to manage Rules, and define a RuleFactory to manage all Rules in a unified manner. And classify Rule into Exploration and Implementation. Operator holds a bitmap of the rules that can be applied. When applying a rule, take the bitmap in Expression and all the bitmaps in RuleFactory and to determine the final applied rule, then traverse and apply the rule. After the Exploration stage is completed, all equivalent expressions are generated, and a new tree is generated with Pattern. Is this more efficient? I Translated GPORCA from C++ to Go,And IT works fine。

type RuleFactory struct {
	// range of all rules
	IdToRule map[RuleId]Rule

	// bitset of exploration rules
	ExplorationSet RuleSet

	// bitset of implementation rules
	ImplementationSet RuleSet
}
// Logical Operator
type Logical interface {
	Operator

	// rules can be applied to this operator
	CandidateRules() RuleSet
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

7 participants