Skip to content

Commit 36fbcde

Browse files
committed
Added new pseudo-extension point, which was why Doltgres was not finding indexes for certain queries
1 parent 0c5806f commit 36fbcde

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

sql/analyzer/analyzer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636

3737
const debugAnalyzerKey = "DEBUG_ANALYZER"
3838
const verboseAnalyzerKey = "VERBOSE_ANALYZER"
39+
const traceAnalyzerKey = "TRACE_ANALYZER"
3940

4041
const maxAnalysisIterations = 8
4142

@@ -215,6 +216,7 @@ func (s simpleLogFormatter) Format(entry *logrus.Entry) ([]byte, error) {
215216
func (ab *Builder) Build() *Analyzer {
216217
_, debug := os.LookupEnv(debugAnalyzerKey)
217218
_, verbose := os.LookupEnv(verboseAnalyzerKey)
219+
_, trace := os.LookupEnv(traceAnalyzerKey)
218220
var batches = []*Batch{
219221
{
220222
Desc: "pre-analyzer",
@@ -266,6 +268,7 @@ func (ab *Builder) Build() *Analyzer {
266268
return &Analyzer{
267269
Debug: debug || ab.debug,
268270
Verbose: verbose,
271+
Trace: trace,
269272
contextStack: make([]string, 0),
270273
Batches: batches,
271274
Catalog: NewCatalog(ab.provider),

sql/memo/join_order_builder.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ import (
2626
"github.com/dolthub/go-mysql-server/sql/plan"
2727
)
2828

29+
// SplitConjunction is a pseudo-extension point of expression.SplitConjunction, used to alter the logic
30+
// for different integrators.
31+
var SplitConjunction func(expr sql.Expression) []sql.Expression = expression.SplitConjunction
32+
2933
// joinOrderBuilder enumerates valid plans for a join tree. We build the join
3034
// tree bottom up, first joining single nodes with join condition "edges", then
3135
// single nodes to hypernodes (1+n), and finally hyper nodes to
@@ -510,7 +514,7 @@ func (j *joinOrderBuilder) buildJoinOp(n *plan.JoinNode) *ExprGroup {
510514
rightEdges: rightE,
511515
}
512516

513-
filters := expression.SplitConjunction(n.JoinCond())
517+
filters := SplitConjunction(n.JoinCond())
514518
j.m.Tracer.Log("Join filters: %v", filters)
515519
union := leftV.union(rightV)
516520
group, ok := j.plans[union]
@@ -538,7 +542,7 @@ func (j *joinOrderBuilder) buildFilter(child sql.Node, e sql.Expression) (vertex
538542
// memoize child
539543
childV, childE, childGrp := j.populateSubgraph(child)
540544

541-
filterGrp := j.m.MemoizeFilter(nil, childGrp, expression.SplitConjunction(e))
545+
filterGrp := j.m.MemoizeFilter(nil, childGrp, SplitConjunction(e))
542546

543547
// filter will absorb child relation for join reordering
544548
j.plans[childV] = filterGrp

0 commit comments

Comments
 (0)