From 5c3d0b01cc6c034952b5ce807a1fec3561ec50e5 Mon Sep 17 00:00:00 2001 From: xzhangxian1008 Date: Mon, 8 May 2023 11:46:36 +0800 Subject: [PATCH] add ft --- tests/fullstack-test/mpp/window.test | 54 +++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/tests/fullstack-test/mpp/window.test b/tests/fullstack-test/mpp/window.test index f3e04a15c36..e83cb271a21 100644 --- a/tests/fullstack-test/mpp/window.test +++ b/tests/fullstack-test/mpp/window.test @@ -1,4 +1,4 @@ -# Copyright 2022 PingCAP, Ltd. +# Copyright 2023 PingCAP, Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -55,3 +55,55 @@ mysql> use test; set @@tidb_isolation_read_engines='tiflash'; select count(*) fr +----------+ mysql> drop table if exists test.t1; mysql> drop table if exists test.t2; + +# Test first_value +mysql> drop table if exists test.first; +mysql> create table test.first(p int not null, o int not null, v varchar(30) null); +mysql> insert into first values (0, 0, "1"), (1, 1, "2"), (1, 2, "3"), (1, 3, "4"), (1, 4, "5"), (2, 5, "6"), (2, 6, "7"), (2, 7, "8"), (2, 8, "9"), (2, 9, "10"), (3, 10, "11"), (3, 11, "12"), (3, 12, "13"); +mysql> alter table test.first set tiflash replica 1; + +mysql> drop table if exists test.first1; +mysql> create table test.first1(p int not null, o int not null, v varchar(30) null); +mysql> insert into first1 values (0, 0, null), (1, 1, null), (1, 2, "3"), (1, 3, "4"), (1, 4, "5"), (2, 5, null), (2, 6, "7"), (2, 7, "8"), (2, 8, "9"), (2, 9, "10"), (3, 10, null), (3, 11, "12"), (3, 12, "13"); +mysql> alter table test.first1 set tiflash replica 1; + +func> wait_table test first +func> wait_table test first1 + +mysql> use test; set enforce_tidb_mpp=1; select *, first_value(v) over (partition by p order by o asc) as a from first; ++---+----+------+------+ +| p | o | v | a | ++---+----+------+------+ +| 0 | 0 | 1 | 1 | +| 1 | 1 | 2 | 2 | +| 1 | 2 | 3 | 2 | +| 1 | 3 | 4 | 2 | +| 1 | 4 | 5 | 2 | +| 3 | 10 | 11 | 11 | +| 3 | 11 | 12 | 11 | +| 3 | 12 | 13 | 11 | +| 2 | 5 | 6 | 6 | +| 2 | 6 | 7 | 6 | +| 2 | 7 | 8 | 6 | +| 2 | 8 | 9 | 6 | +| 2 | 9 | 10 | 6 | ++---+----+------+------+ + +mysql> use test; set enforce_tidb_mpp=1; select *, first_value(v) over (partition by p order by o asc) as a from first; ++---+----+------+------+ +| p | o | v | a | ++---+----+------+------+ +| 0 | 0 | NULL | NULL | +| 1 | 1 | NULL | NULL | +| 1 | 2 | 3 | NULL | +| 1 | 3 | 4 | NULL | +| 1 | 4 | 5 | NULL | +| 3 | 10 | NULL | NULL | +| 3 | 11 | 12 | NULL | +| 3 | 12 | 13 | NULL | +| 2 | 5 | NULL | NULL | +| 2 | 6 | 7 | NULL | +| 2 | 7 | 8 | NULL | +| 2 | 8 | 9 | NULL | +| 2 | 9 | 10 | NULL | ++---+----+------+------+