Return-Path: X-Original-To: apmail-tajo-commits-archive@minotaur.apache.org Delivered-To: apmail-tajo-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 726BC1085D for ; Fri, 18 Apr 2014 09:19:50 +0000 (UTC) Received: (qmail 76896 invoked by uid 500); 18 Apr 2014 09:19:34 -0000 Delivered-To: apmail-tajo-commits-archive@tajo.apache.org Received: (qmail 76580 invoked by uid 500); 18 Apr 2014 09:19:29 -0000 Mailing-List: contact commits-help@tajo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tajo.apache.org Delivered-To: mailing list commits@tajo.apache.org Received: (qmail 76422 invoked by uid 99); 18 Apr 2014 09:19:24 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Apr 2014 09:19:24 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id A18BD9811D2; Fri, 18 Apr 2014 09:19:23 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: hyunsik@apache.org To: commits@tajo.apache.org Date: Fri, 18 Apr 2014 09:19:23 -0000 Message-Id: <9171a3b9a1e24dccae6e386c4cc8efec@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [01/51] [partial] TAJO-752: Escalate sub modules in tajo-core into the top-level modules. (hyunsik) Repository: tajo Updated Branches: refs/heads/master 795077d89 -> 6594ac1c0 http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java new file mode 100644 index 0000000..8692070 --- /dev/null +++ b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java @@ -0,0 +1,325 @@ +/** + * 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.apache.tajo.TajoConstants; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.sql.ResultSet; + +@Category(IntegrationTest.class) +public class TestJoinQuery extends QueryTestCaseBase { + + public TestJoinQuery() { + super(TajoConstants.DEFAULT_DATABASE_NAME); + } + + @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 testJoinWithMultipleJoinQual1() throws Exception { + ResultSet res = executeQuery(); + assertResultSet(res); + cleanupQuery(res); + } + + @Test + public final void testJoinWithMultipleJoinQual2() throws Exception { + ResultSet res = executeQuery(); + assertResultSet(res); + cleanupQuery(res); + } + + @Test + public final void testJoinWithMultipleJoinQual3() throws Exception { + ResultSet res = executeQuery(); + assertResultSet(res); + cleanupQuery(res); + } + + @Test + public final void testJoinWithMultipleJoinQual4() 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"); + executeDDL("oj_table2_ddl.sql", "table2"); + 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 { + /* + select + c_custkey, + empty_orders.o_orderkey, + empty_orders.o_orderstatus, + empty_orders.o_orderdate + from + customer left outer join empty_orders on c_custkey = o_orderkey + order by + c_custkey, o_orderkey; + */ + + 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); + } + + @Test + public final void testJoinOnMultipleDatabases() throws Exception { + executeString("CREATE DATABASE JOINS"); + assertDatabaseExists("joins"); + executeString("CREATE TABLE JOINS.part_ as SELECT * FROM part"); + assertTableExists("joins.part_"); + executeString("CREATE TABLE JOINS.supplier_ as SELECT * FROM supplier"); + assertTableExists("joins.supplier_"); + ResultSet res = executeQuery(); + assertResultSet(res); + cleanupQuery(res); + } +}