-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
chore(engine): Add first stage of physical query planning #16891
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
760d043
chore: Move common types into separate internal package
chaudum d927193
chore(treeprinter): Print predicates as comments
chaudum 60e57c2
chore(planner): Add interface for `Catalog`
chaudum d5c6bd6
chore(planner): Adapt ColumnExpr and LiteralExpr
chaudum d333d8a
chore(planner): Implement first planning phase
chaudum 11b04aa
Merge branch 'main' into chaudum/physical-planner-v2
chaudum 241034a
fixup: Change API so Planner.Build() returns Plan and error
chaudum 656d712
fixup: Move BinaryOp and UnaryOp into internal types package
chaudum af16df0
fixup: Remove duplicate conversion code
chaudum f2afd24
fixup: Code unification and linter fix
chaudum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package types | ||
|
||
import "fmt" | ||
|
||
// ColumnType denotes the column type for a [ColumnRef]. | ||
type ColumnType int | ||
|
||
// Recognized values of [ColumnType]. | ||
const ( | ||
// ColumnTypeInvalid indicates an invalid column type. | ||
ColumnTypeInvalid ColumnType = iota | ||
|
||
ColumnTypeBuiltin // ColumnTypeBuiltin represents a builtin column (such as timestamp). | ||
ColumnTypeLabel // ColumnTypeLabel represents a column from a stream label. | ||
ColumnTypeMetadata // ColumnTypeMetadata represents a column from a log metadata. | ||
) | ||
|
||
// String returns a human-readable representation of the column type. | ||
func (ct ColumnType) String() string { | ||
switch ct { | ||
case ColumnTypeInvalid: | ||
return typeInvalid | ||
case ColumnTypeBuiltin: | ||
return "builtin" | ||
case ColumnTypeLabel: | ||
return "label" | ||
case ColumnTypeMetadata: | ||
return "metadata" | ||
default: | ||
return fmt.Sprintf("ColumnType(%d)", ct) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package types | ||
|
||
import "fmt" | ||
|
||
// LiteralKind denotes the kind of [Literal] value. | ||
type LiteralKind int | ||
|
||
// Recognized values of [LiteralKind]. | ||
const ( | ||
// LiteralKindInvalid indicates an invalid literal value. | ||
LiteralKindInvalid LiteralKind = iota | ||
|
||
LiteralKindNull // NULL literal value. | ||
LiteralKindString // String literal value. | ||
LiteralKindInt64 // 64-bit integer literal value. | ||
LiteralKindUint64 // 64-bit unsigned integer literal value. | ||
LiteralKindByteArray // Byte array literal value. | ||
) | ||
|
||
// String returns the string representation of the LiteralKind. | ||
func (k LiteralKind) String() string { | ||
switch k { | ||
case LiteralKindInvalid: | ||
return typeInvalid | ||
case LiteralKindNull: | ||
return "null" | ||
case LiteralKindString: | ||
return "string" | ||
case LiteralKindInt64: | ||
return "int64" | ||
case LiteralKindUint64: | ||
return "uint64" | ||
case LiteralKindByteArray: | ||
return "[]byte" | ||
default: | ||
return fmt.Sprintf("LiteralKind(%d)", k) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package types | ||
|
||
import "fmt" | ||
|
||
// UnaryOp denotes the kind of [UnaryOp] operation to perform. | ||
type UnaryOp uint32 | ||
|
||
// Recognized values of [UnaryOp]. | ||
const ( | ||
// UnaryOpKindInvalid indicates an invalid unary operation. | ||
UnaryOpInvalid UnaryOp = iota | ||
|
||
UnaryOpNot // Logical NOT operation (!). | ||
UnaryOpAbs // Mathematical absolute operation (abs). | ||
) | ||
|
||
// String returns the string representation of the UnaryOp. | ||
func (t UnaryOp) String() string { | ||
switch t { | ||
case UnaryOpInvalid: | ||
return typeInvalid | ||
case UnaryOpNot: | ||
return "NOT" | ||
case UnaryOpAbs: | ||
return "ABS" | ||
default: | ||
panic(fmt.Sprintf("unknown unary operator %d", t)) | ||
} | ||
} | ||
|
||
// BinaryOp denotes the kind of [BinaryOp] operation to perform. | ||
type BinaryOp uint32 | ||
|
||
// Recognized values of [BinaryOp]. | ||
const ( | ||
// BinaryOpInvalid indicates an invalid binary operation. | ||
BinaryOpInvalid BinaryOp = iota | ||
|
||
BinaryOpEq // Equality comparison (==). | ||
BinaryOpNeq // Inequality comparison (!=). | ||
BinaryOpGt // Greater than comparison (>). | ||
BinaryOpGte // Greater than or equal comparison (>=). | ||
BinaryOpLt // Less than comparison (<). | ||
BinaryOpLte // Less than or equal comparison (<=). | ||
BinaryOpAnd // Logical AND operation (&&). | ||
BinaryOpOr // Logical OR operation (||). | ||
BinaryOpXor // Logical XOR operation (^). | ||
BinaryOpNot // Logical NOT operation (!). | ||
|
||
BinaryOpAdd // Addition operation (+). | ||
BinaryOpSub // Subtraction operation (-). | ||
BinaryOpMul // Multiplication operation (*). | ||
BinaryOpDiv // Division operation (/). | ||
BinaryOpMod // Modulo operation (%). | ||
|
||
BinaryOpMatchStr // String matching operation (|=). | ||
BinaryOpNotMatchStr // String non-matching operation (!=). | ||
BinaryOpMatchRe // Regular expression matching operation (|~). | ||
BinaryOpNotMatchRe // Regular expression non-matching operation (!~). | ||
) | ||
|
||
// String returns a human-readable representation of the binary operation kind. | ||
func (t BinaryOp) String() string { | ||
switch t { | ||
case BinaryOpInvalid: | ||
return typeInvalid | ||
case BinaryOpEq: | ||
return "EQ" | ||
case BinaryOpNeq: | ||
return "NEQ" // convenience for NOT(EQ(expr)) | ||
case BinaryOpGt: | ||
return "GT" | ||
case BinaryOpGte: | ||
return "GTE" | ||
case BinaryOpLt: | ||
return "LT" // convenience for NOT(GTE(expr)) | ||
case BinaryOpLte: | ||
return "LTE" // convenience for NOT(GT(expr)) | ||
case BinaryOpAnd: | ||
return "AND" | ||
case BinaryOpOr: | ||
return "OR" | ||
case BinaryOpXor: | ||
return "XOR" | ||
case BinaryOpNot: | ||
return "NOT" | ||
case BinaryOpAdd: | ||
return "ADD" | ||
case BinaryOpSub: | ||
return "SUB" | ||
case BinaryOpMul: | ||
return "MUL" | ||
case BinaryOpDiv: | ||
return "DIV" | ||
case BinaryOpMod: | ||
return "MOD" | ||
case BinaryOpMatchStr: | ||
return "MATCH_STR" | ||
case BinaryOpNotMatchStr: | ||
return "NOT_MATCH_STR" // convenience for NOT(MATCH_STR(...)) | ||
case BinaryOpMatchRe: | ||
return "MATCH_RE" | ||
case BinaryOpNotMatchRe: | ||
return "NOT_MATCH_RE" // convenience for NOT(MATCH_RE(...)) | ||
default: | ||
panic(fmt.Sprintf("unknown binary operator %d", t)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package types | ||
|
||
const ( | ||
typeInvalid = "invalid" | ||
) | ||
|
||
// ValueType represents the type of a value, which can either be a literal value, or a column value. | ||
type ValueType uint32 | ||
|
||
const ( | ||
ValueTypeInvalid ValueType = iota // zero-value is an invalid type | ||
|
||
ValueTypeNull // NULL value. | ||
ValueTypeBool // Boolean value | ||
ValueTypeInt // Signed 64bit integer value | ||
ValueTypeTimestamp // Unsigned 64bit integer value (nanosecond timestamp) | ||
ValueTypeStr // String value | ||
ValueTypeBytes // Byte-slice value | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit: Go package naming usually discourages naming a package types like this:
I think it's fine for now since it's internal, but we should keep an eye out for opportunities to organize by domain. Some things like
ColumnType
might be better for the schema package, but I'm not sure about the other types yet.