-
Notifications
You must be signed in to change notification settings - Fork 0
Pre release #47
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
base: main
Are you sure you want to change the base?
Pre release #47
Changes from 19 commits
0abb344
c25fdec
d8317f3
edeb870
62c36c8
a549495
1d9d8eb
e05fa7e
4910e16
5905cfa
fffdd78
5c7585f
a2f17cc
28d0cae
fbf7564
a734938
70dc63e
9b91355
dfdca8a
bf0bf49
9877a82
8899c6f
e2f8442
2e92fb9
3290029
1d5a987
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,19 +6,21 @@ A high-performance, in-memory query execution engine. | |
|  | ||
|  | ||
|
|
||
|
|
||
| ## Overview | ||
|
|
||
| OptiSQL is a custom in-memory query execution engine. The backend (physical execution) is built using golang and rust.The front end (query parsing & optimization) is built using C++. | ||
|
|
||
| **Technologies:** | ||
|
|
||
| - Go/Rust (physical optimizer, operators) | ||
| - Substrait (logical/physical plan representation) | ||
| - C++ (query parser & optimizer) | ||
| - ect (make,git,s3) | ||
|
|
||
| ## Getting Started | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Go 1.24+ | ||
| - Rust 1.70+ | ||
| - C++23 | ||
|
|
@@ -83,6 +85,7 @@ OptiSQL/ | |
| Initial development is done in **Go** (`opti-sql-go`), which serves as the primary implementation. The **Rust** version (`opti-sql-rs`) is developed shortly after as a learning exercise and eventual performance-optimized alternative, closely mirroring the Go implementation. | ||
|
|
||
| **Key Directories:** | ||
|
|
||
| - `/operators` - SQL operator implementations (filter, join, aggregation, project) | ||
| - `/physical-optimizer` - Query plan parsing and optimization | ||
| - `/substrait` - Substrait plan integration | ||
|
|
@@ -102,6 +105,7 @@ We use a structured branching model to maintain stability and enable smooth coll | |
| This approach prevents unstable code from reaching `main`, simplifies rollbacks, and ensures all changes undergo proper testing and review before deployment. Feature branches isolate work, allowing focused reviews and parallel development without conflicts. The `pre-release` branch acts as a staging area where features are bundled together before being released as a new version. | ||
|
|
||
| **Workflow:** | ||
|
|
||
| 1. Create a feature branch from `pre-release` | ||
| 2. Implement your changes with tests | ||
| 3. Open a PR to merge into `pre-release` | ||
|
|
@@ -112,6 +116,7 @@ This approach prevents unstable code from reaching `main`, simplifies rollbacks, | |
| ### Code Quality | ||
|
|
||
| All code quality checks are automated and enforced by CI: | ||
|
|
||
| - **Linting** - `golangci-lint` (Go), `clippy` (Rust) | ||
| - **Formatting** - `go fmt` (Go), `cargo fmt` (Rust) | ||
| - **Testing** - Unit tests required for all new code | ||
|
|
@@ -133,15 +138,53 @@ Before pushing, verify your changes pass all checks: | |
| make pre-push | ||
| ``` | ||
|
|
||
| ## How to build | ||
|
|
||
| ```bash | ||
| docker buildx build \ | ||
| --platform linux/amd64 \ | ||
| -t rich239/execution-engine:0.9.2 \ ## bump major/minor | ||
| -t rich239/execution-engine:latest \ | ||
| --push \ | ||
| . | ||
|
|
||
| ``` | ||
|
|
||
| ## How to run | ||
|
|
||
| ```bash | ||
| docker pull rich239/execution-engine | ||
| docker run -p 7024:7024 rich239/execution-engine | ||
| ``` | ||
|
|
||
| ## Example GRPC body | ||
|
|
||
| ```bash | ||
| { | ||
| "id": "97b61a8f-ffe1-4e4a-b6d7-73619698dc7a", | ||
| "sql_statement": "select * from table1 where id > 10", | ||
| "logical_plan": "ewogICAgIkVtaXQiOiAKICAgIHsKICAgICAgICAiT3BlcmF0b3IiOiAiRmlsdGVyIiwKICAgICAgICAiRmlsdGVyIjogCiAgICAgICAgewogICAgICAgICAgICAiaW5wdXQiOiAKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgIk9wZXJhdG9yIjogIlNvdXJjZSIsCiAgICAgICAgICAgICAgICAiU291cmNlIjogCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgImZpbGUtbmFtZSI6ICJ1c2VyX3Rlc3RfZGF0YS5jc3YiLAogICAgICAgICAgICAgICAgICAgICJsb2NhbCI6IGZhbHNlCiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0sCiAgICAgICAgICAgICJleHByZXNzaW9uIjogCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICJleHByX3R5cGUiOiAiQmluYXJ5RXhwciIsCiAgICAgICAgICAgICAgICAib3AiOiAiR3JlYXRlclRoYW4iLAogICAgICAgICAgICAgICAgImxlZnQiOiAKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAiZXhwcl90eXBlIjogIkNvbHVtblJlc29sdmUiLAogICAgICAgICAgICAgICAgICAgICJuYW1lIjogImFnZV95ZWFycyIKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAicmlnaHQiOiAKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAiZXhwcl90eXBlIjogIkxpdGVyYWxSZXNvbHZlIiwKICAgICAgICAgICAgICAgICAgICAidmFsdWUiOiAxMCwKICAgICAgICAgICAgICAgICAgICAibGl0X3R5cGUiOiAiaW50IgogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQp9" | ||
| } | ||
| ``` | ||
|
|
||
| This runs formatting, linting, and all tests. | ||
|
|
||
| ## Contributing | ||
|
|
||
| Want to contribute? Check out [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines on: | ||
|
|
||
| - Writing and running tests | ||
| - PR format and commit message conventions | ||
| - Development workflow and tooling | ||
| - Build and run instructions | ||
|
|
||
| ## License | ||
| This project is licensed under the terms specified in [LICENSE.txt](LICENSE.txt). | ||
|
|
||
| This project is licensed under the terms specified in [LICENSE.txt](LICENSE.txt). | ||
|
|
||
| docker buildx build \ | ||
| --platform linux/amd64 \ | ||
| -t rich239/execution-engine:0.9.5 \ ## bump major/minor | ||
| -t rich239/execution-engine:latest \ | ||
| --push \ | ||
| . | ||
|
Comment on lines
+185
to
+190
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,35 +24,35 @@ var ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type binaryOperator int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type BinaryOperator int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // arithmetic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Addition binaryOperator = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Subtraction binaryOperator = 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Multiplication binaryOperator = 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Division binaryOperator = 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Addition BinaryOperator = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Subtraction BinaryOperator = 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Multiplication BinaryOperator = 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Division BinaryOperator = 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // comparison | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Equal binaryOperator = 6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NotEqual binaryOperator = 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LessThan binaryOperator = 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LessThanOrEqual binaryOperator = 9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GreaterThan binaryOperator = 10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GreaterThanOrEqual binaryOperator = 11 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Equal BinaryOperator = 6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NotEqual BinaryOperator = 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LessThan BinaryOperator = 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LessThanOrEqual BinaryOperator = 9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GreaterThan BinaryOperator = 10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GreaterThanOrEqual BinaryOperator = 11 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // logical | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| And binaryOperator = 12 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Or binaryOperator = 13 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| And BinaryOperator = 12 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Or BinaryOperator = 13 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // RegEx expressions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Like binaryOperator = 14 // where column_name like "patte%n_with_wi%dcard_" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Like BinaryOperator = 14 // where column_name like "patte%n_with_wi%dcard_" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type supportedFunctions int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type SupportedFunctions int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Upper supportedFunctions = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Lower supportedFunctions = 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Abs supportedFunctions = 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Round supportedFunctions = 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Upper SupportedFunctions = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Lower SupportedFunctions = 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Abs SupportedFunctions = 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Round SupportedFunctions = 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type aggFunctions = int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -213,8 +213,7 @@ func (c *ColumnResolve) String() string { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Evaluates to a column of length = batch-size, filled with this literal. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // sql: select 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type LiteralResolve struct { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Type arrow.DataType | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // dont forget to cast the value. so string("hello") not just "hello" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Type arrow.DataType | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Value any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -425,11 +424,11 @@ func (l *LiteralResolve) String() string { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type BinaryExpr struct { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Left Expression | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Op binaryOperator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Op BinaryOperator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Right Expression | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func NewBinaryExpr(left Expression, op binaryOperator, right Expression) *BinaryExpr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func NewBinaryExpr(left Expression, op BinaryOperator, right Expression) *BinaryExpr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return &BinaryExpr{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Left: left, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Op: op, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -578,11 +577,11 @@ func unpackDatum(d compute.Datum) (arrow.Array, error) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type ScalarFunction struct { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Function supportedFunctions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Function SupportedFunctions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Arguments Expression // resolve to something you can process IE, literal/coloumn Resolve | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func NewScalarFunction(function supportedFunctions, Argument Expression) *ScalarFunction { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func NewScalarFunction(function SupportedFunctions, Argument Expression) *ScalarFunction { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return &ScalarFunction{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Function: function, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Arguments: Argument, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -736,7 +735,7 @@ func lowerImpl(arr arrow.Array) (arrow.Array, error) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return b.NewArray(), nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func inferScalarFunctionType(fn supportedFunctions, argType arrow.DataType) arrow.DataType { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func inferScalarFunctionType(fn SupportedFunctions, argType arrow.DataType) arrow.DataType { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| switch fn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case Upper, Lower: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -753,7 +752,7 @@ func inferScalarFunctionType(fn supportedFunctions, argType arrow.DataType) arro | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func inferBinaryType(left arrow.DataType, op binaryOperator, right arrow.DataType) arrow.DataType { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func inferBinaryType(left arrow.DataType, op BinaryOperator, right arrow.DataType) arrow.DataType { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| switch op { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case Addition, Subtraction, Multiplication, Division: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -816,3 +815,57 @@ func validRegEx(columnValue, regExExpr string) bool { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ok | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func FnToScalarFunction(s string) SupportedFunctions { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| switch s { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "Upper": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "Lower": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "Abs": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "Round": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+839
to
+850
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func FnToScalarFunction(s string) SupportedFunctions { | |
| switch s { | |
| case "Upper": | |
| return 1 | |
| case "Lower": | |
| return 2 | |
| case "Abs": | |
| return 3 | |
| case "Round": | |
| return 4 | |
| } | |
| return 1 | |
| func FnToScalarFunction(s string) (SupportedFunctions, error) { | |
| switch s { | |
| case "Upper": | |
| return 1, nil | |
| case "Lower": | |
| return 2, nil | |
| case "Abs": | |
| return 3, nil | |
| case "Round": | |
| return 4, nil | |
| default: | |
| return 0, fmt.Errorf("unsupported scalar function: %s", s) | |
| } |
Copilot
AI
Feb 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FnToScalarFunction returns Upper (1) for unknown function names. That can silently turn invalid input into a different operation. Prefer returning a sentinel (e.g., SupportedFunctions(-1)) and/or a (SupportedFunctions, bool) result so callers can handle unknown names explicitly.
| return 1 | |
| return SupportedFunctions(-1) |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,15 @@ | ||||||||||||||||||||||
| FROM golang:1.24 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| WORKDIR /app | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| COPY go.mod go.sum ./ | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| RUN go mod download | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| COPY . . | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| RUN go build -o execution-engine . | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| EXPOSE 7024 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
Comment on lines
+12
to
+14
|
||||||||||||||||||||||
| EXPOSE 7024 | |
| # Create an unprivileged user and give it ownership of the app directory | |
| RUN useradd -m -u 10001 appuser && chown -R appuser /app | |
| EXPOSE 7024 | |
| # Run the execution engine as the unprivileged user | |
| USER appuser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docker build example includes an inline comment after a line-continuation backslash, which will break if copy/pasted (the comment becomes part of the command). Consider moving the comment to its own line or removing the trailing backslash before the comment.