Skip to content

Commit

Permalink
planner: fix the error output and improve the test coverage radondb#525
Browse files Browse the repository at this point in the history
[summary]
fix the error output and improve the test coverage
[test case]
src/planner/builder/builder_test.go
[patch codecov]
src/planner/builder/project.go 98.1%
  • Loading branch information
andyli029 authored and BohuTANG committed Nov 14, 2019
1 parent c24aa48 commit 7a568c3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/executor/engine/merge_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func keysEqual(row1, row2 []sqltypes.Value, joins []builder.JoinKey) bool {
return true
}

// concatLeftAndRight used to concat thle left and right results, handle otherLeftJoin|rightNull|OtherFilter.
// concatLeftAndRight used to concat the left and right results, handle otherJoinOn|rightNull|OtherFilter.
func concatLeftAndRight(lrows, rrows [][]sqltypes.Value, node *builder.JoinNode, res *sqltypes.Result, maxrow int) error {
var err error
var mu sync.Mutex
Expand Down
4 changes: 4 additions & 0 deletions src/planner/builder/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,8 @@ func TestSelectUnsupported(t *testing.T) {
"select a+1 from A group by a+1",
"select count(distinct *) from A",
"select t1.a from G",
"select S.id from A join B on B.id=A.id",
"select eeeee from A join B on B.id=A.id",
}
results := []string{
"unsupported: subqueries.in.select",
Expand Down Expand Up @@ -561,6 +563,8 @@ func TestSelectUnsupported(t *testing.T) {
"unsupported: group.by.[a + 1].type.should.be.colname",
"unsupported: syntax.error.at.'count(distinct *)'",
"unsupported: unknown.column.'t1.a'.in.exprs",
"unsupported: unknown.column.'S.id'.in.field.list",
"unsupported: unknown.column.'eeeee'.in.select.exprs",
}

log := xlog.NewStdLog(xlog.Level(xlog.PANIC))
Expand Down
4 changes: 2 additions & 2 deletions src/planner/builder/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ func parseHaving(exprs sqlparser.Expr, tbInfos map[string]*tableInfo, fields []s
return tuples, nil
}

// getTbInExpr used to get the referred tables from the expr.
func getTbInExpr(expr sqlparser.Expr) []string {
// getTbsInExpr used to get the referred tables from the expr.
func getTbsInExpr(expr sqlparser.Expr) []string {
var referTables []string
sqlparser.Walk(func(node sqlparser.SQLNode) (kontinue bool, err error) {
switch node := node.(type) {
Expand Down
4 changes: 2 additions & 2 deletions src/planner/builder/join_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,12 @@ func (j *JoinNode) judgeStrategy(filters []exprInfo) {
}

if exp, ok := filter.expr.(*sqlparser.ComparisonExpr); ok {
left := findParent(getTbInExpr(exp.Left), j)
left := findParent(getTbsInExpr(exp.Left), j)
if _, ok := left.(*JoinNode); ok {
j.setNestLoop()
return
}
right := findParent(getTbInExpr(exp.Right), j)
right := findParent(getTbsInExpr(exp.Right), j)
if _, ok := right.(*JoinNode); ok {
j.setNestLoop()
}
Expand Down
2 changes: 1 addition & 1 deletion src/planner/builder/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func parseSelectExpr(expr *sqlparser.AliasedExpr, tbInfos map[string]*tableInfo)
}
} else {
if _, ok := tbInfos[tableName]; !ok {
return false, errors.Errorf("unsupported: unknown.column.'%s'.in.field.list", field)
return false, errors.Errorf("unsupported: unknown.column.'%s.%s'.in.field.list", tableName, field)
}
}

Expand Down

0 comments on commit 7a568c3

Please sign in to comment.