Skip to content

Commit

Permalink
Minor fixes all around
Browse files Browse the repository at this point in the history
  • Loading branch information
cube2222 committed Apr 11, 2019
1 parent 42d9c90 commit 54acc06
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
29 changes: 18 additions & 11 deletions cmd/octosql/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ package main
import (
"context"
"fmt"
"github.com/cube2222/octosql/storage/csv"
"log"
"os"
"strings"

"github.com/bradleyjkemp/memmap"
"github.com/cube2222/octosql/execution"
"github.com/cube2222/octosql/logical"
"github.com/cube2222/octosql/parser"
"github.com/cube2222/octosql/physical"
"github.com/cube2222/octosql/physical/optimizer"
"github.com/cube2222/octosql/storage/csv"
"github.com/cube2222/octosql/storage/json"
"github.com/cube2222/octosql/storage/postgres"
"github.com/cube2222/octosql/storage/redis"
"github.com/xwb1989/sqlparser"
)

Expand All @@ -27,7 +29,7 @@ func main() {
log.Fatal(err)
}

typed, ok := stmt.(*sqlparser.Select)
typed, ok := stmt.(sqlparser.SelectStatement)
if !ok {
log.Fatal("invalid statement type")
}
Expand All @@ -46,28 +48,33 @@ func main() {
log.Fatal(err)
}

err = dataSourceRespository.Register("myusers",
err = dataSourceRespository.Register("users_ids",
postgres.NewDataSourceBuilderFactory("localhost", "root",
"toor", "mydb", "myusers", nil, 5432))

"toor", "mydb", "users_ids", nil, 5432))
if err != nil {
log.Fatal(err)
}

phys, variables, err := parsed.Physical(ctx, logical.NewPhysicalPlanCreator(dataSourceRespository))
err = dataSourceRespository.Register("users",
redis.NewDataSourceBuilderFactory("localhost", "", 6379, 0, "key"))
if err != nil {
log.Fatal(err)
}

switch phys.(type) {
case *physical.Filter:
fmt.Println("It's a filter")
default:
fmt.Println("It's not a filter")
phys, variables, err := parsed.Physical(ctx, logical.NewPhysicalPlanCreator(dataSourceRespository))
if err != nil {
log.Fatal(err)
}

phys = optimizer.Optimize(ctx, optimizer.DefaultScenarios, phys)

f, err := os.Create("diag_got")
if err != nil {
log.Fatal(err)
}
memmap.Map(f, phys)
f.Close()

exec, err := phys.Materialize(ctx)
if err != nil {
log.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion execution/union_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (node *UnifiedStream) Next() (*Record, error) {
return firstRecord, nil
}
for {
secondRecord, err := node.first.Next()
secondRecord, err := node.second.Next()
if err != nil {
if err == ErrEndOfStream {
return nil, ErrEndOfStream
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/cube2222/octosql

require (
github.com/bradleyjkemp/cupaloy v2.3.0+incompatible // indirect
github.com/bradleyjkemp/memmap v0.2.2 // indirect
github.com/bradleyjkemp/memmap v0.2.2
github.com/bradleyjkemp/memviz v0.2.2
github.com/cweill/gotests v1.5.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down
2 changes: 1 addition & 1 deletion physical/optimizer/scenarios.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func subset(set []octosql.VariableName, subset []octosql.VariableName) bool {

func containsVariableName(vns []octosql.VariableName, vn octosql.VariableName) bool {
for i := range vns {
if vn == vns[i] {
if vn.Name() == vns[i].Name() {
return true
}
}
Expand Down

0 comments on commit 54acc06

Please sign in to comment.