Skip to content

Commit

Permalink
planner: fix bug that window function do not check ignore null… (#11593)
Browse files Browse the repository at this point in the history
  • Loading branch information
sre-bot authored and zz-jason committed Aug 5, 2019
1 parent 234a610 commit 9cb903e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions planner/core/logical_plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -3218,6 +3218,15 @@ func (b *PlanBuilder) buildWindowFunctions(ctx context.Context, p LogicalPlan, g
// Because of the grouped specification is different from it, we should especially check them before build window frame.
func (b *PlanBuilder) checkOriginWindowSpecs(funcs []*ast.WindowFuncExpr, orderByItems []property.Item) error {
for _, f := range funcs {
if f.IgnoreNull {
return ErrNotSupportedYet.GenWithStackByArgs("IGNORE NULLS")
}
if f.Distinct {
return ErrNotSupportedYet.GenWithStackByArgs("<window function>(DISTINCT ..)")
}
if f.FromLast {
return ErrNotSupportedYet.GenWithStackByArgs("FROM LAST")
}
spec := f.Spec
if spec.Frame == nil {
continue
Expand Down
17 changes: 17 additions & 0 deletions planner/core/logical_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2403,6 +2403,23 @@ func (s *testPlanSuite) TestWindowFunction(c *C) {
sql: "select dense_rank() over w1, a, b from t window w1 as (partition by t.b order by t.a asc range between 1250951168 following AND 1250951168 preceding)",
result: "[planner:3586]Window 'w1': frame start or end is negative, NULL or of non-integral type",
},
// Test issue 10556.
{
sql: "SELECT FIRST_VALUE(a) IGNORE NULLS OVER () FROM t",
result: "[planner:1235]This version of TiDB doesn't yet support 'IGNORE NULLS'",
},
{
sql: "SELECT SUM(DISTINCT a) OVER () FROM t",
result: "[planner:1235]This version of TiDB doesn't yet support '<window function>(DISTINCT ..)'",
},
{
sql: "SELECT NTH_VALUE(a, 1) FROM LAST over (partition by b order by b), a FROM t",
result: "[planner:1235]This version of TiDB doesn't yet support 'FROM LAST'",
},
{
sql: "SELECT NTH_VALUE(a, 1) FROM LAST IGNORE NULLS over (partition by b order by b), a FROM t",
result: "[planner:1235]This version of TiDB doesn't yet support 'IGNORE NULLS'",
},
}

s.Parser.EnableWindowFunc(true)
Expand Down

0 comments on commit 9cb903e

Please sign in to comment.