Skip to content

Commit

Permalink
explain add test cases
Browse files Browse the repository at this point in the history
  go test -update ./...
  • Loading branch information
martianzhang committed May 28, 2019
1 parent 77a48f1 commit ceaf588
Show file tree
Hide file tree
Showing 20 changed files with 691 additions and 295 deletions.
2 changes: 2 additions & 0 deletions advisor/testdata/TestListTestSQLs.golden
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,5 @@ SELECT DATE_FORMAT(t.last_update, '%Y-%m-%d'), COUNT(DISTINCT (t.city)) FROM cit
create table hello.t (id int unsigned);
select * from tb where data >= '';
alter table tb alter column id drop default;
select maxId, minId from (select max(film_id) maxId, min(film_id) minId from film where last_update > '2016-03-27 02:01:01') as d;
select maxId, minId from (select max(film_id) maxId, min(film_id) minId from film) as d;
4 changes: 4 additions & 0 deletions ast/testdata/TestCompress.golden
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,7 @@ select * from tb where data >= '';
select * from tb where data >= '';
alter table tb alter column id drop default;
alter table tb alter column id drop default;
select maxId, minId from (select max(film_id) maxId, min(film_id) minId from film where last_update > '2016-03-27 02:01:01') as d;
select maxId, minId from (select max(film_id) maxId, min(film_id) minId from film where last_update > '2016-03-27 02:01:01') as d;
select maxId, minId from (select max(film_id) maxId, min(film_id) minId from film) as d;
select maxId, minId from (select max(film_id) maxId, min(film_id) minId from film) as d;
23 changes: 23 additions & 0 deletions ast/testdata/TestFormat.golden
Original file line number Diff line number Diff line change
Expand Up @@ -880,3 +880,26 @@ ALTER TABLE
tb alter column id
DROP
DEFAULT;
select maxId, minId from (select max(film_id) maxId, min(film_id) minId from film where last_update > '2016-03-27 02:01:01') as d;

SELECT
maxId, minId
FROM
(
SELECT
MAX( film_id) maxId, MIN( film_id) minId
FROM
film
WHERE
last_update > '2016-03-27 02:01:01'
) as d;
select maxId, minId from (select max(film_id) maxId, min(film_id) minId from film) as d;

SELECT
maxId, minId
FROM
(
SELECT
MAX( film_id) maxId, MIN( film_id) minId
FROM
film) as d;
23 changes: 23 additions & 0 deletions ast/testdata/TestPretty.golden
Original file line number Diff line number Diff line change
Expand Up @@ -1524,4 +1524,27 @@ ALTER TABLE
tb alter column id
DROP
DEFAULT;
select maxId, minId from (select max(film_id) maxId, min(film_id) minId from film where last_update > '2016-03-27 02:01:01') as d;

SELECT
maxId, minId
FROM
(
SELECT
MAX( film_id) maxId, MIN( film_id) minId
FROM
film
WHERE
last_update > '2016-03-27 02:01:01'
) as d;
select maxId, minId from (select max(film_id) maxId, min(film_id) minId from film) as d;

SELECT
maxId, minId
FROM
(
SELECT
MAX( film_id) maxId, MIN( film_id) minId
FROM
film) as d;
select 1
2 changes: 2 additions & 0 deletions ast/testdata/TestQueryType.golden
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@ SELECT
CREATE
SELECT
ALTER
SELECT
SELECT
4 changes: 4 additions & 0 deletions ast/testdata/TestSchemaMetaInfo.golden
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,7 @@ select * from tb where data >= '';
[`sakila`.`tb`]
alter table tb alter column id drop default;
[`sakila`.tb`]
select maxId, minId from (select max(film_id) maxId, min(film_id) minId from film where last_update > '2016-03-27 02:01:01') as d;
[`sakila`.`film`]
select maxId, minId from (select max(film_id) maxId, min(film_id) minId from film) as d;
[`sakila`.`film`]
4 changes: 4 additions & 0 deletions ast/testdata/TestTokenize.golden
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,7 @@ select * from tb where data >= '';
[{5 SELECT 0} {7 * 0} {0 0} {5 FROM 0} {1 tb 0} {5 WHERE 0} {1 data 0} {7 >= 0} {0 0} {2 '' 0} {7 ; 0}]
alter table tb alter column id drop default;
[{5 ALTER TABLE 0} {1 tb 0} {1 alter 0} {1 column 0} {1 id 0} {5 DROP 0} {4 DEFAULT; 0}]
select maxId, minId from (select max(film_id) maxId, min(film_id) minId from film where last_update > '2016-03-27 02:01:01') as d;
[{5 SELECT 0} {1 maxId, 0} {0 0} {1 minId 0} {5 FROM 0} {7 ( 0} {5 SELECT 0} {4 MAX( 0} {1 film_id) 0} {0 0} {1 maxId, 0} {0 0} {4 MIN( 0} {1 film_id) 0} {0 0} {1 minId 0} {5 FROM 0} {1 film 0} {5 WHERE 0} {1 last_update 0} {7 > 0} {0 0} {2 '2016-03-27 02:01:01' 0} {7 ) 0} {0 0} {1 as 0} {1 d; 0}]
select maxId, minId from (select max(film_id) maxId, min(film_id) minId from film) as d;
[{5 SELECT 0} {1 maxId, 0} {0 0} {1 minId 0} {5 FROM 0} {7 ( 0} {5 SELECT 0} {4 MAX( 0} {1 film_id) 0} {0 0} {1 maxId, 0} {0 0} {4 MIN( 0} {1 film_id) 0} {0 0} {1 minId 0} {5 FROM 0} {1 film) 0} {0 0} {1 as 0} {1 d; 0}]
2 changes: 1 addition & 1 deletion ast/testdata/TestTokenizer.golden
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
}
[]ast.Token{
{Type:57348, Val:"select", i:0},
{Type:57592, Val:"sql_calc_found_rows", i:0},
{Type:57593, Val:"sql_calc_found_rows", i:0},
{Type:57396, Val:"col", i:0},
{Type:57353, Val:"from", i:0},
{Type:57396, Val:"tbl", i:0},
Expand Down
4 changes: 4 additions & 0 deletions common/cases.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,5 +205,9 @@ func init() {

// https://github.com/XiaoMi/soar/issues/163
"alter table tb alter column id drop default;",

// explain extra info "Select tables optimized away"
"select maxId, minId from (select max(film_id) maxId, min(film_id) minId from film where last_update > '2016-03-27 02:01:01') as d;",
"select maxId, minId from (select max(film_id) maxId, min(film_id) minId from film) as d;",
}
}
Loading

0 comments on commit ceaf588

Please sign in to comment.