From 1b1d936cb8b49a067989272904a056af5d57980c Mon Sep 17 00:00:00 2001 From: wshwsh12 <793703860@qq.com> Date: Mon, 6 Dec 2021 11:06:45 +0800 Subject: [PATCH 1/2] fix --- executor/pipelined_window.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/executor/pipelined_window.go b/executor/pipelined_window.go index 8e120376402be..7e8f6a0ed5c5e 100644 --- a/executor/pipelined_window.go +++ b/executor/pipelined_window.go @@ -179,7 +179,7 @@ func (e *PipelinedWindowExec) getRowsInPartition(ctx context.Context) (err error var drained, samePartition bool drained, err = e.fetchChild(ctx) if err != nil { - err = errors.Trace(err) + return errors.Trace(err) } // we return immediately to use a combination of true newPartition but 0 in e.rowToConsume to indicate the data source is drained, if drained { From ce01dee7707a5b7014ea885e913224ce71a8b284 Mon Sep 17 00:00:00 2001 From: wshwsh12 <793703860@qq.com> Date: Mon, 6 Dec 2021 11:53:49 +0800 Subject: [PATCH 2/2] add test --- expression/integration_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/expression/integration_test.go b/expression/integration_test.go index 7f01c659c126d..61a72a9ce49f1 100644 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -10669,3 +10669,15 @@ func (s *testIntegrationSuite) TestIssue30101(c *C) { tk.MustExec("insert into t1 values(9223372036854775808, 9223372036854775809);") tk.MustQuery("select greatest(c1, c2) from t1;").Sort().Check(testkit.Rows("9223372036854775809")) } + +func (s *testIntegrationSuite) TestIssue30326(c *C) { + tk := testkit.NewTestKit(c, s.store) + tk.MustExec("use test") + tk.MustExec("drop table if exists t;") + tk.MustExec("create table t(a int);") + tk.MustExec("insert into t values(1),(1),(2),(2);") + tk.MustExec("set tidb_window_concurrency = 1;") + err := tk.QueryToErr("select (FIRST_VALUE(1) over (partition by v.a)) as c3 from (select a from t where t.a = (select a from t t2 where t.a = t2.a)) as v;") + c.Assert(err, NotNil) + c.Assert(err.Error(), Equals, "[executor:1242]Subquery returns more than 1 row") +}