Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyum committed Jul 29, 2019
1 parent f329e6d commit 12ff0b2
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 111 deletions.
60 changes: 30 additions & 30 deletions sql/core/src/test/resources/sql-tests/inputs/pgSQL/join.sql
Expand Up @@ -6,25 +6,25 @@
-- Test JOIN clauses
-- https://github.com/postgres/postgres/blob/REL_12_BETA2/src/test/regress/sql/join.sql
--
create or replace temporary view INT4_TBL as select * from
(values (0), (123456), (-123456), (2147483647), (-2147483647))
as v(f1);
create or replace temporary view INT8_TBL as select * from
(values
CREATE OR REPLACE TEMPORARY VIEW INT4_TBL AS SELECT * FROM
(VALUES (0), (123456), (-123456), (2147483647), (-2147483647))
AS v(f1);
CREATE OR REPLACE TEMPORARY VIEW INT8_TBL AS SELECT * FROM
(VALUES
(123, 456),
(123, 4567890123456789),
(4567890123456789, 123),
(4567890123456789, 4567890123456789),
(4567890123456789, -4567890123456789))
as v(q1, q2);
create or replace temporary view FLOAT8_TBL as select * from
(values (0.0), (1004.30), (-34.84),
AS v(q1, q2);
CREATE OR REPLACE TEMPORARY VIEW FLOAT8_TBL AS SELECT * FROM
(VALUES (0.0), (1004.30), (-34.84),
(cast('1.2345678901234e+200' as double)), (cast('1.2345678901234e-200' as double)))
as v(f1);
create or replace temporary view TEXT_TBL as select * from
(values ('doh!'), ('hi de ho neighbor'))
as v(f1);
create or replace temporary view tenk2 as select * from tenk1;
AS v(f1);
CREATE OR REPLACE TEMPORARY VIEW TEXT_TBL AS SELECT * FROM
(VALUES ('doh!'), ('hi de ho neighbor'))
AS v(f1);
CREATE OR REPLACE TEMPORARY VIEW tenk2 AS SELECT * FROM tenk1;

CREATE TABLE J1_TBL (
i integer,
Expand Down Expand Up @@ -577,15 +577,15 @@ select count(*) from tenk1 a, tenk1 b
-- regression test for 8.2 bug with improper re-ordering of left joins
--

drop table if exists tt3;
create table tt3(f1 int, f2 string) using parquet;
insert into tt3 select x.id, repeat('xyzzy', 100) from range(1,10001) x;
DROP TABLE IF EXISTS tt3;
CREATE TABLE tt3(f1 int, f2 string) USING parquet;
INSERT INTO tt3 SELECT x.id, repeat('xyzzy', 100) FROM range(1,10001) x;
-- create index tt3i on tt3(f1);
-- analyze tt3;

drop table if exists tt4;
create table tt4(f1 int) using parquet;
insert into tt4 values (0),(1),(9999);
DROP TABLE IF EXISTS tt4;
CREATE TABLE tt4(f1 int) USING parquet;
INSERT INTO tt4 VALUES (0),(1),(9999);
-- analyze tt4;

SELECT a.f1
Expand Down Expand Up @@ -1984,19 +1984,19 @@ select f1,g from int4_tbl a cross join (select a.f1 as g) ss;
-- select * from j1
-- inner join (select id from j3 group by id) j3 on j1.id = j3.id;

drop table if exists j1;
drop table if exists j2;
drop table if exists j3;
-- drop table if exists j1;
-- drop table if exists j2;
-- drop table if exists j3;

-- test more complex permutations of unique joins

create table j1 (id1 int, id2 int) using parquet;
create table j2 (id1 int, id2 int) using parquet;
create table j3 (id1 int, id2 int) using parquet;
CREATE TABLE j1 (id1 int, id2 int) USING parquet;
CREATE TABLE j2 (id1 int, id2 int) USING parquet;
-- create table j3 (id1 int, id2 int) using parquet;

insert into j1 values(1,1),(1,2);
insert into j2 values(1,1);
insert into j3 values(1,1);
INSERT INTO j1 values(1,1),(1,2);
INSERT INTO j2 values(1,1);
-- insert into j3 values(1,1);

-- analyze j1;
-- analyze j2;
Expand Down Expand Up @@ -2036,7 +2036,7 @@ insert into j3 values(1,1);
-- create index j2_id1_idx on j2 (id1) where id1 % 1000 = 1;

-- need an additional row in j2, if we want j2_id1_idx to be preferred
insert into j2 values(1,2);
INSERT INTO j2 values(1,2);
-- analyze j2;

-- explain (costs off) select * from j1
Expand All @@ -2053,7 +2053,7 @@ where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1;

drop table j1;
drop table j2;
drop table j3;
-- drop table j3;

-- Skip these tests because it only test explain
-- check that semijoin inner is not seen as unique for a portion of the outerrel
Expand Down
114 changes: 33 additions & 81 deletions sql/core/src/test/resources/sql-tests/results/pgSQL/join.sql.out
@@ -1,55 +1,55 @@
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 191
-- Number of queries: 185


-- !query 0
create or replace temporary view INT4_TBL as select * from
(values (0), (123456), (-123456), (2147483647), (-2147483647))
as v(f1)
CREATE OR REPLACE TEMPORARY VIEW INT4_TBL AS SELECT * FROM
(VALUES (0), (123456), (-123456), (2147483647), (-2147483647))
AS v(f1)
-- !query 0 schema
struct<>
-- !query 0 output



-- !query 1
create or replace temporary view INT8_TBL as select * from
(values
CREATE OR REPLACE TEMPORARY VIEW INT8_TBL AS SELECT * FROM
(VALUES
(123, 456),
(123, 4567890123456789),
(4567890123456789, 123),
(4567890123456789, 4567890123456789),
(4567890123456789, -4567890123456789))
as v(q1, q2)
AS v(q1, q2)
-- !query 1 schema
struct<>
-- !query 1 output



-- !query 2
create or replace temporary view FLOAT8_TBL as select * from
(values (0.0), (1004.30), (-34.84),
CREATE OR REPLACE TEMPORARY VIEW FLOAT8_TBL AS SELECT * FROM
(VALUES (0.0), (1004.30), (-34.84),
(cast('1.2345678901234e+200' as double)), (cast('1.2345678901234e-200' as double)))
as v(f1)
AS v(f1)
-- !query 2 schema
struct<>
-- !query 2 output



-- !query 3
create or replace temporary view TEXT_TBL as select * from
(values ('doh!'), ('hi de ho neighbor'))
as v(f1)
CREATE OR REPLACE TEMPORARY VIEW TEXT_TBL AS SELECT * FROM
(VALUES ('doh!'), ('hi de ho neighbor'))
AS v(f1)
-- !query 3 schema
struct<>
-- !query 3 output



-- !query 4
create or replace temporary view tenk2 as select * from tenk1
CREATE OR REPLACE TEMPORARY VIEW tenk2 AS SELECT * FROM tenk1
-- !query 4 schema
struct<>
-- !query 4 output
Expand Down Expand Up @@ -2536,47 +2536,47 @@ struct<count(1):bigint>


-- !query 107
drop table if exists tt3
DROP TABLE IF EXISTS tt3
-- !query 107 schema
struct<>
-- !query 107 output



-- !query 108
create table tt3(f1 int, f2 string) using parquet
CREATE TABLE tt3(f1 int, f2 string) USING parquet
-- !query 108 schema
struct<>
-- !query 108 output



-- !query 109
insert into tt3 select x.id, repeat('xyzzy', 100) from range(1,10001) x
INSERT INTO tt3 SELECT x.id, repeat('xyzzy', 100) FROM range(1,10001) x
-- !query 109 schema
struct<>
-- !query 109 output



-- !query 110
drop table if exists tt4
DROP TABLE IF EXISTS tt4
-- !query 110 schema
struct<>
-- !query 110 output



-- !query 111
create table tt4(f1 int) using parquet
CREATE TABLE tt4(f1 int) USING parquet
-- !query 111 schema
struct<>
-- !query 111 output



-- !query 112
insert into tt4 values (0),(1),(9999)
INSERT INTO tt4 VALUES (0),(1),(9999)
-- !query 112 schema
struct<>
-- !query 112 output
Expand Down Expand Up @@ -3374,115 +3374,67 @@ cannot resolve '`a.f1`' given input columns: []; line 1 pos 47


-- !query 177
drop table if exists j1
CREATE TABLE j1 (id1 int, id2 int) USING parquet
-- !query 177 schema
struct<>
-- !query 177 output



-- !query 178
drop table if exists j2
CREATE TABLE j2 (id1 int, id2 int) USING parquet
-- !query 178 schema
struct<>
-- !query 178 output



-- !query 179
drop table if exists j3
INSERT INTO j1 values(1,1),(1,2)
-- !query 179 schema
struct<>
-- !query 179 output



-- !query 180
create table j1 (id1 int, id2 int) using parquet
INSERT INTO j2 values(1,1)
-- !query 180 schema
struct<>
-- !query 180 output



-- !query 181
create table j2 (id1 int, id2 int) using parquet
INSERT INTO j2 values(1,2)
-- !query 181 schema
struct<>
-- !query 181 output



-- !query 182
create table j3 (id1 int, id2 int) using parquet
-- !query 182 schema
struct<>
-- !query 182 output



-- !query 183
insert into j1 values(1,1),(1,2)
-- !query 183 schema
struct<>
-- !query 183 output



-- !query 184
insert into j2 values(1,1)
-- !query 184 schema
struct<>
-- !query 184 output



-- !query 185
insert into j3 values(1,1)
-- !query 185 schema
struct<>
-- !query 185 output



-- !query 186
insert into j2 values(1,2)
-- !query 186 schema
struct<>
-- !query 186 output



-- !query 187
select * from j1
inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1
-- !query 187 schema
-- !query 182 schema
struct<id1:int,id2:int,id1:int,id2:int>
-- !query 187 output
-- !query 182 output
1 1 1 1
1 2 1 2


-- !query 188
-- !query 183
drop table j1
-- !query 188 schema
-- !query 183 schema
struct<>
-- !query 188 output
-- !query 183 output



-- !query 189
-- !query 184
drop table j2
-- !query 189 schema
struct<>
-- !query 189 output



-- !query 190
drop table j3
-- !query 190 schema
-- !query 184 schema
struct<>
-- !query 190 output
-- !query 184 output

0 comments on commit 12ff0b2

Please sign in to comment.