-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
244 additions
and
54 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package datasource | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
func TestStreamingAPI(t *testing.T) { | ||
data := []int{0, 1, 2, 3, 4, 5, 6, 8} | ||
ctx := context.TODO() | ||
|
||
newData := Tap(ctx, data). | ||
Filter(ctx, func(x int) bool { return x%2 == 0 }). | ||
Transform(ctx, func(x int) int { return x * 2 }). | ||
Collect(ctx) | ||
|
||
fmt.Println(newData) | ||
} |
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,48 @@ | ||
package logical_plan | ||
|
||
import "github.com/kwilteam/kwil-db/internal/engine/cost/datatypes" | ||
|
||
type DataFrameAPI interface { | ||
// Project applies a projection | ||
Project(expr ...LogicalExpr) DataFrameAPI | ||
|
||
// Filter applies a filter | ||
Filter(expr LogicalExpr) DataFrameAPI | ||
|
||
// Aggregate applies an aggregation | ||
Aggregate(groupBy []LogicalExpr, aggregateExpr []LogicalExpr) DataFrameAPI | ||
|
||
// Schema returns the schema of the data that will be produced by this DataFrameAPI. | ||
Schema() *datatypes.Schema | ||
|
||
// LogicalPlan returns the logical plan | ||
LogicalPlan() LogicalPlan | ||
} | ||
|
||
type DataFrame struct { | ||
plan LogicalPlan | ||
} | ||
|
||
func (df *DataFrame) Project(exprs ...LogicalExpr) DataFrameAPI { | ||
return &DataFrame{Projection(df.plan, exprs...)} | ||
} | ||
|
||
func (df *DataFrame) Filter(expr LogicalExpr) DataFrameAPI { | ||
return &DataFrame{Filter(df.plan, expr)} | ||
} | ||
|
||
func (df *DataFrame) Aggregate(groupBy []LogicalExpr, aggregateExpr []LogicalExpr) DataFrameAPI { | ||
return &DataFrame{Aggregate(df.plan, groupBy, aggregateExpr)} | ||
} | ||
|
||
func (df *DataFrame) Schema() *datatypes.Schema { | ||
return df.plan.Schema() | ||
} | ||
|
||
func (df *DataFrame) LogicalPlan() LogicalPlan { | ||
return df.plan | ||
} | ||
|
||
func NewDataFrame(plan LogicalPlan) *DataFrame { | ||
return &DataFrame{plan: plan} | ||
} |
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
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