Refactor all protocol related code to frontend #1010
Labels
C-enhancement
Category Enhancements
help wanted
Extra attention is needed
tracking-issue
A tracking issue for a feature.
Milestone
What type of enhancement is this?
Tech debt reduction
What does the enhancement do?
We've been expecting that all protocol-related logic remains in frontend, including protocol parsing and logical planning. For some reason now datanode also keeps a parser and can also accepts SQL queries. Also frontend delegates SQL parsing to datanode in standalone mode:
greptimedb/src/frontend/src/instance.rs
Line 182 in de0b8aa
This compromise brings a lot of tech debt and maintenance overhead, for example, introducing a new protocol involves both frontend and datanode. Now it's time to get things right.
Steps
tests
mod in Datanode to Frontend. They are largely sql and promql tests.Implementation challenges
SqlQueryHandler
trait, it should only keep aGrpcQueryHandler
implementation.greptimedb/src/datanode/src/instance/sql.rs
Line 234 in de0b8aa
sql_handler
field ofdatanode::instance::Instance
should be moved to frontend instance.SqlHandler
also has some field liketable_engine
andcatalog_manager
, which in standalone mode, datanode should share these components to frontend so that frontend can build aSqlHandler
.greptimedb/src/datanode/src/instance.rs
Line 71 in 75b8afe
PromqlHandler
implementation from datanode to frontend. In standalone mode it's also delegated to datanode.greptimedb/src/frontend/src/instance.rs
Line 528 in de0b8aa
GrpcQueryHandler
to accommodate more plans and data types.After the refactoring, datanode accepts only grpc requests with logical plans encoded as substrait (for inserts, gRPC protocol also has an
Insert
variant). Thus we need to support all the possible logical plans and data types in substrait.LogicalPlan::Extension
.greptimedb/src/common/substrait/src/df_logical.rs
Line 305 in 8ffc078
greptimedb/src/common/substrait/src/types.rs
Line 57 in d1730a9
The text was updated successfully, but these errors were encountered: