| /** |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| package org.apache.tajo.engine.query; |
| |
| import org.apache.tajo.IntegrationTest; |
| import org.apache.tajo.QueryTestCaseBase; |
| import org.junit.Test; |
| import org.junit.experimental.categories.Category; |
| |
| import java.sql.ResultSet; |
| |
| @Category(IntegrationTest.class) |
| public class TestJoinQuery extends QueryTestCaseBase { |
| @Test |
| public final void testCrossJoin() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testWhereClauseJoin1() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testWhereClauseJoin2() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testWhereClauseJoin3() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testWhereClauseJoin4() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testWhereClauseJoin5() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testWhereClauseJoin6() throws Exception { |
| ResultSet res = executeQuery(); |
| System.out.println(resultSetToString(res)); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testTPCHQ2Join() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testLeftOuterJoin1() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testLeftOuterJoinWithConstantExpr1() throws Exception { |
| // outer join with constant projections |
| // |
| // select c_custkey, orders.o_orderkey, 'val' as val from customer |
| // left outer join orders on c_custkey = o_orderkey; |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testLeftOuterJoinWithConstantExpr2() throws Exception { |
| // outer join with constant projections |
| // |
| // select c_custkey, o.o_orderkey, 'val' as val from customer left outer join |
| // (select * from orders) o on c_custkey = o.o_orderkey |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testLeftOuterJoinWithConstantExpr3() throws Exception { |
| // outer join with constant projections |
| // |
| // select a.c_custkey, 123::INT8 as const_val, b.min_name from customer a |
| // left outer join ( select c_custkey, min(c_name) as min_name from customer group by c_custkey) b |
| // on a.c_custkey = b.c_custkey; |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testRightOuterJoin1() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testFullOuterJoin1() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public void testJoinCoReferredEvals1() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public void testJoinCoReferredEvalsWithSameExprs1() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public void testJoinCoReferredEvalsWithSameExprs2() throws Exception { |
| // including grouping operator |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public void testCrossJoinAndCaseWhen() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public void testOuterJoinAndCaseWhen1() throws Exception { |
| executeDDL("oj_table1_ddl.sql", "table1.tbl"); |
| executeDDL("oj_table2_ddl.sql", "table2.tbl"); |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public void testCrossJoinWithAsterisk1() throws Exception { |
| // select region.*, customer.* from region, customer; |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public void testCrossJoinWithAsterisk2() throws Exception { |
| // select region.*, customer.* from customer, region; |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public void testCrossJoinWithAsterisk3() throws Exception { |
| // select * from customer, region |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public void testCrossJoinWithAsterisk4() throws Exception { |
| // select length(r_regionkey), *, c_custkey*10 from customer, region |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testInnerJoinWithEmptyTable() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testLeftOuterJoinWithEmptyTable1() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testLeftOuterJoinWithEmptyTable2() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testLeftOuterJoinWithEmptyTable3() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testLeftOuterJoinWithEmptyTable4() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testRightOuterJoinWithEmptyTable1() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testFullOuterJoinWithEmptyTable1() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| @Test |
| public final void testCrossJoinWithEmptyTable1() throws Exception { |
| ResultSet res = executeQuery(); |
| assertResultSet(res); |
| cleanupQuery(res); |
| } |
| |
| } |