Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion sql/analyzer/indexed_joins.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func recSchemaToGetFields(n sql.Node, sch sql.Schema) []sql.Expression {
}

func replanJoin(ctx *sql.Context, n *plan.JoinNode, a *Analyzer, scope *plan.Scope, qFlags *sql.QueryFlags) (ret sql.Node, err error) {
m := memo.NewMemo(ctx, a.Catalog, scope, len(scope.Schema()), a.Coster, qFlags)
m := memo.NewMemo(ctx, a.Catalog, scope, a.Coster, qFlags)
m.Debug = a.Debug
m.EnableTrace(a.Trace)

Expand Down
2 changes: 1 addition & 1 deletion sql/analyzer/indexed_joins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestHashJoins(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
m := memo.NewMemo(ctx, newTestCatalog(db), nil, 0, memo.NewDefaultCoster(), nil)
m := memo.NewMemo(ctx, newTestCatalog(db), nil, memo.NewDefaultCoster(), nil)
j := memo.NewJoinOrderBuilder(m)
j.ReorderJoin(tt.plan)
addHashJoins(m)
Expand Down
10 changes: 5 additions & 5 deletions sql/memo/exec_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (b *ExecBuilder) buildLookupJoin(j *LookupJoin, children ...sql.Node) (sql.
return nil, err
}
filters := b.buildFilterConjunction(j.Filter...)
return plan.NewJoin(left, right, j.Op, filters).WithScopeLen(j.g.m.scopeLen), nil
return plan.NewJoin(left, right, j.Op, filters), nil
}

func (b *ExecBuilder) buildRangeHeap(sr *RangeHeap, children ...sql.Node) (ret sql.Node, err error) {
Expand Down Expand Up @@ -146,7 +146,7 @@ func (b *ExecBuilder) buildRangeHeapJoin(j *RangeHeapJoin, children ...sql.Node)
return nil, err
}
filters := b.buildFilterConjunction(j.Filter...)
return plan.NewJoin(left, right, j.Op, filters).WithScopeLen(j.g.m.scopeLen), nil
return plan.NewJoin(left, right, j.Op, filters), nil
}

func (b *ExecBuilder) buildConcatJoin(j *ConcatJoin, children ...sql.Node) (sql.Node, error) {
Expand Down Expand Up @@ -181,7 +181,7 @@ func (b *ExecBuilder) buildConcatJoin(j *ConcatJoin, children ...sql.Node) (sql.

filters := b.buildFilterConjunction(j.Filter...)

return plan.NewJoin(children[0], right, j.Op, filters).WithScopeLen(j.g.m.scopeLen), nil
return plan.NewJoin(children[0], right, j.Op, filters), nil
}

func (b *ExecBuilder) buildHashJoin(j *HashJoin, children ...sql.Node) (sql.Node, error) {
Expand All @@ -206,7 +206,7 @@ func (b *ExecBuilder) buildHashJoin(j *HashJoin, children ...sql.Node) (sql.Node

outer := plan.NewHashLookup(children[1], rightEntryKey, leftProbeKey, j.Op)
inner := children[0]
return plan.NewJoin(inner, outer, j.Op, filters).WithScopeLen(j.g.m.scopeLen), nil
return plan.NewJoin(inner, outer, j.Op, filters), nil
}

func (b *ExecBuilder) buildIndexScan(i *IndexScan, children ...sql.Node) (sql.Node, error) {
Expand Down Expand Up @@ -294,7 +294,7 @@ func (b *ExecBuilder) buildMergeJoin(j *MergeJoin, children ...sql.Node) (sql.No
}
}
filters := b.buildFilterConjunction(j.Filter...)
return plan.NewJoin(inner, outer, j.Op, filters).WithScopeLen(j.g.m.scopeLen), nil
return plan.NewJoin(inner, outer, j.Op, filters), nil
}

func (b *ExecBuilder) buildLateralJoin(j *LateralJoin, children ...sql.Node) (sql.Node, error) {
Expand Down
6 changes: 3 additions & 3 deletions sql/memo/join_order_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func TestJoinOrderBuilder(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
j := NewJoinOrderBuilder(NewMemo(newContext(pro), nil, nil, 0, NewDefaultCoster(), nil))
j := NewJoinOrderBuilder(NewMemo(newContext(pro), nil, nil, NewDefaultCoster(), nil))
j.forceFastDFSLookupForTest = tt.forceFastReorder
j.ReorderJoin(tt.in)
require.Equal(t, tt.plans, j.m.String())
Expand Down Expand Up @@ -367,7 +367,7 @@ func TestJoinOrderBuilder_populateSubgraph(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
b := NewJoinOrderBuilder(NewMemo(newContext(pro), nil, nil, 0, NewDefaultCoster(), nil))
b := NewJoinOrderBuilder(NewMemo(newContext(pro), nil, nil, NewDefaultCoster(), nil))
b.populateSubgraph(tt.join)
edgesEq(t, tt.expEdges, b.edges)
})
Expand Down Expand Up @@ -671,7 +671,7 @@ func TestEnsureClosure(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
b := NewJoinOrderBuilder(NewMemo(newContext(pro), nil, nil, 0, NewDefaultCoster(), nil))
b := NewJoinOrderBuilder(NewMemo(newContext(pro), nil, nil, NewDefaultCoster(), nil))
b.populateSubgraph(tt.in)
beforeLen := len(b.edges)
b.ensureClosure(b.m.Root())
Expand Down
4 changes: 1 addition & 3 deletions sql/memo/memo.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,17 @@ type Memo struct {
scope *plan.Scope
TableProps *tableProps
QFlags *sql.QueryFlags
scopeLen int
cnt uint16
Debug bool
Tracer *TraceLogger
}

func NewMemo(ctx *sql.Context, stats sql.StatsProvider, s *plan.Scope, scopeLen int, cost Coster, qFlags *sql.QueryFlags) *Memo {
func NewMemo(ctx *sql.Context, stats sql.StatsProvider, s *plan.Scope, cost Coster, qFlags *sql.QueryFlags) *Memo {
return &Memo{
Ctx: ctx,
c: cost,
statsProv: stats,
scope: s,
scopeLen: scopeLen,
TableProps: newTableProps(),
hints: &joinHints{},
QFlags: qFlags,
Expand Down
4 changes: 2 additions & 2 deletions sql/memo/rel_props_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestPopulateFDs(t *testing.T) {
name: "max1Row",
in: &Max1Row{
relBase: &relBase{},
Child: newExprGroup(NewMemo(nil, nil, nil, 0, nil, nil), 0, &TableScan{
Child: newExprGroup(NewMemo(nil, nil, nil, nil, nil), 0, &TableScan{
sourceBase: &sourceBase{relBase: &relBase{}},
Table: plan.NewResolvedTable(
&dummyTable{
Expand Down Expand Up @@ -117,7 +117,7 @@ func TestPopulateFDs(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tt.in.SetGroup(&ExprGroup{First: tt.in, m: NewMemo(nil, nil, nil, 0, nil, nil)})
tt.in.SetGroup(&ExprGroup{First: tt.in, m: NewMemo(nil, nil, nil, nil, nil)})
props := newRelProps(tt.in)
require.Equal(t, tt.all, props.fds.All())
require.Equal(t, tt.notNull, props.fds.NotNull())
Expand Down
2 changes: 1 addition & 1 deletion sql/memo/select_hints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func TestOrderHintBuilding(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
j := NewJoinOrderBuilder(NewMemo(newContext(pro), nil, nil, 0, NewDefaultCoster(), nil))
j := NewJoinOrderBuilder(NewMemo(newContext(pro), nil, nil, NewDefaultCoster(), nil))
j.ReorderJoin(tt.plan)
j.m.SetJoinOrder(tt.hint)
if tt.invalid {
Expand Down
3 changes: 3 additions & 0 deletions sql/plan/bindvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import (
"github.com/dolthub/go-mysql-server/sql/transform"
)

// TODO: ApplyBindings is only ever called for testing purposes and the other functions in this file are either never
// called or only called by each other. Consider deleting this file.

// ApplyBindings replaces all `BindVar` expressions in the given sql.Node with
// their corresponding sql.Expression entries in the provided |bindings| map.
// If a binding for a |BindVar| expression is not found in the map, no error is
Expand Down