Skip to content
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

Rewrite Show statements to Select #68

Merged
merged 11 commits into from
Mar 8, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove unused Show, Describe plans
  • Loading branch information
Aaron Raddon committed Mar 7, 2016
commit 31806da30e2605169817471aabb81998362da196
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@


## v 0.13 March 2016

* Better internal Schema Query planning, system (SHOW, DESCRIBE) with schemadb https://github.com/araddon/qlbridge/pull/68
* introspect csv files for types
* convert `SHOW`, `DESCRIBE` insto `SELECT` statements
* better internal data-source registry


## v 0.12 February 2016

* Enable Distributed runtime by `Executor` interface https://github.com/araddon/qlbridge/pull/66
Expand Down
2 changes: 0 additions & 2 deletions exec/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ func (m *JobExecutor) WalkPlan(p plan.Task) (Task, error) {
return m.Executor.WalkUpdate(p)
case *plan.Delete:
return m.Executor.WalkDelete(p)
case *plan.Show, *plan.Describe:
return nil, fmt.Errorf("Show/Describe should have been re-written to Select already?")
case *plan.Command:
return m.Executor.WalkCommand(p)
}
Expand Down
26 changes: 9 additions & 17 deletions plan/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ var (
_ Task = (*Upsert)(nil)
_ Task = (*Update)(nil)
_ Task = (*Delete)(nil)
_ Task = (*Show)(nil)
_ Task = (*Describe)(nil)
_ Task = (*Command)(nil)
_ Task = (*Projection)(nil)
_ Task = (*Source)(nil)
Expand Down Expand Up @@ -86,8 +84,6 @@ type (
WalkUpsert(p *Upsert) error
WalkUpdate(p *Update) error
WalkDelete(p *Delete) error
WalkShow(p *Show) error
WalkDescribe(p *Describe) error
WalkCommand(p *Command) error
WalkInto(p *Into) error

Expand Down Expand Up @@ -142,14 +138,6 @@ type (
Stmt *rel.SqlDelete
Source schema.Deletion
}
Show struct {
*PlanBase
Stmt *rel.SqlShow
}
Describe struct {
*PlanBase
Stmt *rel.SqlDescribe
}
Command struct {
*PlanBase
Stmt *rel.SqlCommand
Expand All @@ -159,6 +147,7 @@ type (
Projection struct {
*PlanBase
Final bool // Is this final projection or not?
P *Select
Stmt *rel.SqlSelect
Proj *rel.Projection
}
Expand Down Expand Up @@ -348,8 +337,6 @@ func (m *Insert) Walk(p Planner) error { return p.WalkInsert(m) }
func (m *Upsert) Walk(p Planner) error { return p.WalkUpsert(m) }
func (m *Update) Walk(p Planner) error { return p.WalkUpdate(m) }
func (m *Delete) Walk(p Planner) error { return p.WalkDelete(m) }
func (m *Show) Walk(p Planner) error { return p.WalkShow(m) }
func (m *Describe) Walk(p Planner) error { return p.WalkDescribe(m) }
func (m *Command) Walk(p Planner) error { return p.WalkCommand(m) }
func (m *Source) Walk(p Planner) error { return p.WalkSourceSelect(m) }

Expand Down Expand Up @@ -525,6 +512,11 @@ func (m *Source) LoadConn() error {
if m.Conn != nil {
return nil
}
if m.DataSource == nil {
// Not all sources require a source, ie literal queries
u.Debugf("return bc no datasource")
return nil
}
//u.WarnT(4)
source, err := m.DataSource.Open(m.Stmt.SourceName())
if err != nil {
Expand Down Expand Up @@ -613,9 +605,9 @@ func (m *Source) load() error {
}
ss, err := m.ctx.Schema.Source(fromName)
if err != nil {
u.Errorf("no schema found for %T %q ? err=%v", m.ctx.Schema, fromName, err)
//return nil
return err
u.Debugf("no schema found for %T %q ? err=%v", m.ctx.Schema, fromName, err)
return nil
//return err
}
if ss == nil {
u.Warnf("%p Schema no %s found", m.ctx.Schema, fromName)
Expand Down
7 changes: 4 additions & 3 deletions plan/plan_proto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ func selectPlan(t *testing.T, ctx *plan.Context) *plan.Select {
ctx.Stmt = stmt

planner := plan.NewPlanner(ctx)
pln, err := plan.WalkStmt(ctx, stmt, planner)
assert.T(t, err == nil)
pln, _ := plan.WalkStmt(ctx, stmt, planner)
//assert.T(t, err == nil) // since the FROM doesn't exist it errors
assert.T(t, pln != nil, "must have plan")

sp, ok := pln.(*plan.Select)
assert.T(t, ok, "must be *plan.Select")
Expand Down Expand Up @@ -101,7 +102,7 @@ var (
}
// list of tests
sqlTests = []sqlTest{
st(`select toint(str5) as sv FROM mycontext`, map[string]interface{}{"sv": 5}),
st(`select toint(str5) as sv`, map[string]interface{}{"sv": 5}),
}
)

Expand Down
10 changes: 10 additions & 0 deletions plan/planner.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package plan

import (
u "github.com/araddon/gou"
)

var (
// Ensure our default planner meets interface Planner
_ Planner = (*PlannerDefault)(nil)
_ = u.EMPTY
)

// PlannerDefault is implementation of Planner that creates a dag of plan.Tasks
Expand All @@ -25,3 +30,8 @@ func NewPlanner(ctx *Context) *PlannerDefault {
p.Planner = p
return p
}

func (m *PlannerDefault) WalkCommand(p *Command) error {
u.Debugf("VisitCommand %+v", p.Stmt)
return ErrNotImplemented
}
Loading