提交 f6c2de67 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Require expected values in TestScript

上级 ad96fd7c
......@@ -494,10 +494,7 @@ public class TestScript extends TestBase {
if (reconnectOften && sql.toUpperCase().startsWith("EXPLAIN")) {
return;
}
errors.append(fileName).append('\n');
errors.append("line: ").append(in.getLineNumber()).append('\n');
errors.append("exp: ").append(compare).append('\n');
errors.append("got: ").append(s).append('\n');
addWriteResultError(compare, s);
if (ex != null) {
TestBase.logError("script", ex);
}
......@@ -508,11 +505,20 @@ public class TestScript extends TestBase {
}
}
} else {
addWriteResultError("<nothing>", s);
TestBase.logErrorMessage(errors.toString());
putBack = compare;
}
write(s);
}
private void addWriteResultError(String expected, String got) {
errors.append(fileName).append('\n');
errors.append("line: ").append(in.getLineNumber()).append('\n');
errors.append("exp: ").append(expected).append('\n');
errors.append("got: ").append(got).append('\n');
}
private void write(String s) {
outputLineNo++;
out.println(s);
......
......@@ -24,6 +24,7 @@ select * from card;
> 0 clubs
> 3 hearts
> 4 null
> rows: 3
select * from card order by suit;
> RANK SUIT
......@@ -31,6 +32,7 @@ select * from card order by suit;
> 4 null
> 3 hearts
> 0 clubs
> rows (ordered): 3
insert into card (rank, suit) values (8, 'diamonds'), (10, 'clubs'), (7, 'hearts');
> update count: 3
......@@ -42,17 +44,13 @@ select suit, count(rank) from card group by suit order by suit, count(rank);
> hearts 2
> clubs 2
> diamonds 1
> rows (ordered): 4
select rank from card where suit = 'diamonds';
> RANK
> ----
> 8
>> 8
select column_type from information_schema.columns where COLUMN_NAME = 'SUIT';
> COLUMN_TYPE
> ------------------------------------------
> ENUM('hearts','clubs','spades','diamonds')
> rows: 1
>> ENUM('hearts','clubs','spades','diamonds')
--- ENUM integer-based operations
......@@ -61,6 +59,7 @@ select rank from card where suit = 1;
> ----
> 0
> 10
> rows: 2
insert into card (rank, suit) values(5, 2);
> update count: 1
......@@ -69,6 +68,7 @@ select * from card where rank = 5;
> RANK SUIT
> ---- ------
> 5 spades
> rows: 1
--- ENUM edge cases
......@@ -100,6 +100,7 @@ select * from card;
> ---- ------
> 0 clubs
> 3 hearts
> rows: 2
drop table card;
> ok
......@@ -125,6 +126,7 @@ select rank from card where suit = 'clubs';
> ----
> 0
> 1
> rows: 2
drop table card;
> ok
......@@ -143,18 +145,21 @@ insert into card (rank, suit) values (0, 'clubs'), (3, 'hearts'), (1, 'clubs');
> update count: 3
create index idx_card_suite on card(`suit`);
> ok
select rank from card where suit = 'clubs';
> RANK
> ----
> 0
> 1
> rows: 2
select rank from card where suit in ('clubs');
> RANK
> ----
> 0
> 1
> rows: 2
drop table card;
> ok
......
......@@ -10,9 +10,7 @@ INSERT INTO tab_with_timezone(x) VALUES ('2017-01-01');
> update count: 1
SELECT "Query".* FROM (select * from tab_with_timezone where x > '2016-01-01') AS "Query";
> X
> ----------------------
> 2017-01-01 00:00:00+00
>> 2017-01-01 00:00:00+00
DELETE FROM tab_with_timezone;
> update count: 1
......
......@@ -19,6 +19,7 @@ SELECT * FROM PARENT;
> -- -----
> 1 Coco1
> 2 Coco2
> rows: 2
EXPLAIN PLAN
MERGE INTO PARENT AS P
......@@ -28,9 +29,7 @@ EXPLAIN PLAN
UPDATE SET P.NAME = S.NAME WHERE 2 = 2 WHEN NOT
MATCHED THEN
INSERT (ID, NAME) VALUES (S.ID, S.NAME);
> PLAN
> ---------------------------------------------------------------------------------------------------------------------------------
> MERGE INTO PUBLIC.PARENT(ID, NAME) KEY(ID) SELECT X AS ID, ('Coco' || X) AS NAME FROM SYSTEM_RANGE(1, 2) /* PUBLIC.RANGE_INDEX */
>> MERGE INTO PUBLIC.PARENT(ID, NAME) KEY(ID) SELECT X AS ID, ('Coco' || X) AS NAME FROM SYSTEM_RANGE(1, 2) /* PUBLIC.RANGE_INDEX */
DROP TABLE PARENT;
> ok
......
......@@ -20,6 +20,7 @@ select array_agg(v order by v asc),
> rows (ordered): 1
create index test_idx on test(v);
> ok
select ARRAY_AGG(v order by v asc),
ARRAY_AGG(v order by v desc) filter (where v >= '4')
......
......@@ -18,6 +18,7 @@ select avg(v), avg(v) filter (where v >= 40) from test where v <= 100;
> rows: 1
create index test_idx on test(v);
> ok
select avg(v), avg(v) filter (where v >= 40) from test where v <= 100;
> AVG(V) AVG(V) FILTER (WHERE (V >= 40))
......
......@@ -21,6 +21,7 @@ select bit_and(v), bit_and(v) filter (where v <= 0xffffffff0fff) from test where
> rows: 1
create index test_idx on test(v);
> ok
select bit_and(v), bit_and(v) filter (where v <= 0xffffffff0fff) from test where v >= 0xff0fffffffff;
> BIT_AND(V) BIT_AND(V) FILTER (WHERE (V <= 281474976649215))
......
......@@ -20,6 +20,7 @@ select bit_or(v), bit_or(v) filter (where v >= 8) from test where v <= 512;
> rows: 1
create index test_idx on test(v);
> ok
select bit_or(v), bit_or(v) filter (where v >= 8) from test where v <= 512;
> BIT_OR(V) BIT_OR(V) FILTER (WHERE (V >= 8))
......
......@@ -18,6 +18,7 @@ select count(v), count(v) filter (where v >= 4) from test where v <= 10;
> rows: 1
create index test_idx on test(v);
> ok
select count(v), count(v) filter (where v >= 4) from test where v <= 10;
> COUNT(V) COUNT(V) FILTER (WHERE (V >= 4))
......
......@@ -20,6 +20,7 @@ select group_concat(v order by v asc separator '-'),
> rows (ordered): 1
create index test_idx on test(v);
> ok
select group_concat(v order by v asc separator '-'),
group_concat(v order by v desc separator '-') filter (where v >= '4')
......
......@@ -18,6 +18,7 @@ select max(v), max(v) filter (where v <= 8) from test where v <= 10;
> rows: 1
create index test_idx on test(v);
> ok
select max(v), max(v) filter (where v <= 8) from test where v <= 10;
> MAX(V) MAX(V) FILTER (WHERE (V <= 8))
......
......@@ -598,6 +598,7 @@ select median(v), median(v) filter (where v >= 40) from test where v <= 100;
> rows: 1
create index test_idx on test(v);
> ok
select median(v), median(v) filter (where v >= 40) from test where v <= 100;
> MEDIAN(V) MEDIAN(V) FILTER (WHERE (V >= 40))
......@@ -623,6 +624,7 @@ insert into test values
('First', 10), ('First', 10), ('First', 20), ('First', 30), ('First', 30),
('Second', 5), ('Second', 4), ('Second', 20), ('Second', 22), ('Second', 300),
('Third', 3), ('Third', 100), ('Third', 150), ('Third', 170), ('Third', 400);
> update count: 15
select dept, median(amount) from test group by dept order by dept;
> DEPT MEDIAN(AMOUNT)
......
......@@ -18,6 +18,7 @@ select min(v), min(v) filter (where v >= 4) from test where v >= 2;
> rows: 1
create index test_idx on test(v);
> ok
select min(v), min(v) filter (where v >= 4) from test where v >= 2;
> MIN(V) MIN(V) FILTER (WHERE (V >= 4))
......
......@@ -18,6 +18,7 @@ select sum(v), sum(v) filter (where v >= 4) from test where v <= 10;
> rows: 1
create index test_idx on test(v);
> ok
select sum(v), sum(v) filter (where v >= 4) from test where v <= 10;
> SUM(V) SUM(V) FILTER (WHERE (V >= 4))
......
......@@ -7,10 +7,10 @@ create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select char(null) en, char(65) ea from test;
> EN EA
> ---- --
> null A
> rows: 1
......@@ -6,6 +6,7 @@ create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select concat(null, null) en, concat(null, 'a') ea, concat('b', null) eb, concat('ab', 'c') abc from test;
> EN EA EB ABC
......
......@@ -7,6 +7,7 @@ create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select difference(null, null) en, difference('a', null) en1, difference(null, 'a') en2 from test;
> EN EN1 EN2
......@@ -19,5 +20,3 @@ select difference('abc', 'abc') e0, difference('Thomas', 'Tom') e1 from test;
> -- --
> 4 3
> rows: 1
......@@ -13,6 +13,7 @@ select regexp_replace('Sylvain', 'S..', 'TOTO', 'mni');
>> TOTOvain
set mode oracle;
> ok
select regexp_replace('first last', '(\w+) (\w+)', '\2 \1');
>> last first
......@@ -27,6 +28,7 @@ select regexp_replace('first last', '(\w+) (\w+)', '$2 $1');
>> $2 $1
set mode regular;
> ok
select regexp_replace('first last', '(\w+) (\w+)', '\2 \1');
>> 2 1
......
......@@ -7,6 +7,7 @@ create memory table test(id int primary key, name varchar(255));
> ok
insert into test values(1, 'Hello');
> update count: 1
select soundex(null) en, soundex('tom') et from test;
> EN ET
......@@ -23,4 +24,3 @@ soundex('VanDeusen') V532, soundex('Ashcraft') A261 from test;
> ---- ---- ---- ---- ---- ---- ---- ----
> W252 L000 G362 P236 J250 T522 V532 A261
> rows: 1
......@@ -11,7 +11,7 @@ select row_number() over () as rnum, str from test where str = 'A';
> RNUM STR
> ---- ---
> 1 A
> rows: 1
drop table test;
> ok
......@@ -24,6 +24,7 @@ SELECT 1 AS VERY_VERY_VERY_LONG_ID_VERY_VERY_VERY_LONG_ID, SUM(X)+1 AS _12345678
> VERY_VERY_VERY_LONG_ID_VERY_VE _123456789012345 SUMX1 SUMX147 x noName6 noName7
> ------------------------------ ---------------- ----- ------- - ------- -------
> 1 4 4 51 x !!! !!!!
> rows: 1
SET COLUMN_NAME_RULES=EMULATE='Oracle';
> ok
......@@ -33,6 +34,7 @@ SELECT 1 AS VERY_VERY_VERY_LONG_ID, SUM(X)+1 AS _123456789012345, SUM(X)+1 , SUM
> VERY_VERY_VERY_LONG_ID _123456789012345 SUMX1 SUMX147 x _UNNAMED_6 _UNNAMED_7
> ---------------------- ---------------- ----- ------- - ---------- ----------
> 1 4 4 51 x !!! !!!!
> rows: 1
SET COLUMN_NAME_RULES=EMULATE='Oracle';
> ok
......@@ -42,6 +44,7 @@ SELECT 1 AS VERY_VERY_VERY_LONG_ID, SUM(X)+1 AS _123456789012345, SUM(X)+1 , SUM
> VERY_VERY_VERY_LONG_ID _123456789012345 SUMX1 SUMX147 x _UNNAMED_6 _UNNAMED_7 _23456789012345678901234567890XXX
> ---------------------- ---------------- ----- ------- - ---------- ---------- ---------------------------------
> 1 4 4 51 x !!! !!!! Very Long
> rows: 1
SET COLUMN_NAME_RULES=EMULATE='PostgreSQL';
> ok
......@@ -51,6 +54,7 @@ SELECT 1 AS VERY_VERY_VERY_LONG_ID, SUM(X)+1 AS _123456789012345, SUM(X)+1 , SUM
> VERY_VERY_VERY_LONG_ID _123456789012345 SUMX1 SUMX147 x _UNNAMED_6 _UNNAMED_7 QuotedColumnId
> ---------------------- ---------------- ----- ------- - ---------- ---------- --------------
> 1 4 4 51 x !!! !!!! 999
> rows: 1
SET COLUMN_NAME_RULES=DEFAULT;
> ok
......
......@@ -764,21 +764,36 @@ DROP TABLE C;
> ok
CREATE TABLE T1(X1 INT);
> ok
CREATE TABLE T2(X2 INT);
> ok
CREATE TABLE T3(X3 INT);
> ok
CREATE TABLE T4(X4 INT);
> ok
CREATE TABLE T5(X5 INT);
> ok
INSERT INTO T1 VALUES (1);
> update count: 1
INSERT INTO T1 VALUES (NULL);
> update count: 1
INSERT INTO T2 VALUES (1);
> update count: 1
INSERT INTO T2 VALUES (NULL);
> update count: 1
INSERT INTO T3 VALUES (1);
> update count: 1
INSERT INTO T3 VALUES (NULL);
> update count: 1
INSERT INTO T4 VALUES (1);
> update count: 1
INSERT INTO T4 VALUES (NULL);
> update count: 1
INSERT INTO T5 VALUES (1);
> update count: 1
INSERT INTO T5 VALUES (NULL);
> update count: 1
SELECT T1.X1, T2.X2, T3.X3, T4.X4, T5.X5 FROM (
T1 INNER JOIN (
......
......@@ -8452,6 +8452,7 @@ select * from test where year in (select distinct year from test order by year d
> ---- ---------
> 2016 order
> 2016 execution
> rows (ordered): 2
drop table test;
> ok
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论