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 BA35E1135D for ; Mon, 21 Apr 2014 11:13:03 +0000 (UTC) Received: (qmail 14883 invoked by uid 500); 21 Apr 2014 11:12:59 -0000 Delivered-To: apmail-tajo-commits-archive@tajo.apache.org Received: (qmail 14760 invoked by uid 500); 21 Apr 2014 11:12:56 -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 14722 invoked by uid 99); 21 Apr 2014 11:12:55 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Apr 2014 11:12:55 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 8A13198E54D; Mon, 21 Apr 2014 11:12:55 +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: Mon, 21 Apr 2014 11:12:57 -0000 Message-Id: In-Reply-To: <88552deaf0e94a3c84ad03da11d18d58@git.apache.org> References: <88552deaf0e94a3c84ad03da11d18d58@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/9] git commit: TAJO-777: Partition column in function parameter occurs NPE. (Hyoungjun Kim via hyunsik) TAJO-777: Partition column in function parameter occurs NPE. (Hyoungjun Kim via hyunsik) Project: http://git-wip-us.apache.org/repos/asf/tajo/repo Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/e56a7a41 Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/e56a7a41 Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/e56a7a41 Branch: refs/heads/window_function Commit: e56a7a41fb6b27e093c5c49a2d86a8cabc203156 Parents: 6a005ce Author: Hyunsik Choi Authored: Mon Apr 21 11:36:23 2014 +0900 Committer: Hyunsik Choi Committed: Mon Apr 21 11:36:23 2014 +0900 ---------------------------------------------------------------------- CHANGES.txt | 3 + .../org/apache/tajo/catalog/DDLBuilder.java | 1 - .../java/org/apache/tajo/client/TajoDump.java | 18 +++--- .../tajo/engine/eval/BasicEvalNodeVisitor.java | 4 +- .../tajo/engine/eval/BetweenPredicateEval.java | 12 ++++ .../apache/tajo/engine/eval/CaseWhenEval.java | 14 +++- .../org/apache/tajo/engine/eval/CastEval.java | 4 ++ .../apache/tajo/engine/eval/EvalTreeUtil.java | 68 ++++++++++++++++++-- .../apache/tajo/engine/eval/FunctionEval.java | 2 +- .../org/apache/tajo/engine/eval/NotEval.java | 4 ++ .../org/apache/tajo/engine/eval/SignedEval.java | 4 ++ .../org/apache/tajo/client/TestTajoDump.java | 46 +++++++++++++ .../tajo/engine/query/TestTablePartitions.java | 35 ++++++++++ .../org/apache/tajo/client/TestTajoDump.java | 44 ------------- .../queries/TestTablePartitions/case10.sql | 1 + .../queries/TestTablePartitions/case8.sql | 1 + .../queries/TestTablePartitions/case9.sql | 1 + .../results/TestTablePartitions/case10.result | 7 ++ .../results/TestTablePartitions/case7.result | 5 ++ .../results/TestTablePartitions/case8.result | 7 ++ .../results/TestTablePartitions/case9.result | 7 ++ .../results/TestTajoDump/testDump1.result | 9 ++- .../testBuildDDLForBaseTable.result | 1 - .../testBuildDDLQuotedTableName2.result | 1 - 24 files changed, 228 insertions(+), 71 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 94b6a84..d6ed95a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -334,6 +334,9 @@ Release 0.8.0 - unreleased BUG FIXES + TAJO-777: Partition column in function parameter occurs NPE. + (Hyoungjun Kim via hyunsik) + TAJO-763: Out of range problem in utc_usec_to(). (Ilhyun Suh via hyunsik) TAJO-741: GreedyHeuristicJoinOrderAlgorithm removes some join pairs. (jaehwa) http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/DDLBuilder.java ---------------------------------------------------------------------- diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/DDLBuilder.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/DDLBuilder.java index 1b76f16..77dccd2 100644 --- a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/DDLBuilder.java +++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/DDLBuilder.java @@ -54,7 +54,6 @@ public class DDLBuilder { sb.append("--\n") .append("-- Name: ").append(CatalogUtil.denormalizeIdentifier(desc.getName())).append("; Type: TABLE;") .append(" Storage: ").append(desc.getMeta().getStoreType().name()); - sb.append("\n-- Path: ").append(desc.getPath()); sb.append("\n--\n"); sb.append("CREATE TABLE ").append(CatalogUtil.denormalizeIdentifier(desc.getName())); buildSchema(sb, desc.getSchema()); http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-client/src/main/java/org/apache/tajo/client/TajoDump.java ---------------------------------------------------------------------- diff --git a/tajo-client/src/main/java/org/apache/tajo/client/TajoDump.java b/tajo-client/src/main/java/org/apache/tajo/client/TajoDump.java index 52711c9..60b1a7e 100644 --- a/tajo-client/src/main/java/org/apache/tajo/client/TajoDump.java +++ b/tajo-client/src/main/java/org/apache/tajo/client/TajoDump.java @@ -110,15 +110,15 @@ public class TajoDump { } PrintWriter writer = new PrintWriter(System.out); - dump(client, userInfo, baseDatabaseName, isDumpingAllDatabases, true, writer); + dump(client, userInfo, baseDatabaseName, isDumpingAllDatabases, true, true, writer); System.exit(0); } public static void dump(TajoClient client, UserGroupInformation userInfo, String baseDatabaseName, - boolean isDumpingAllDatabases, boolean includeDate, PrintWriter out) + boolean isDumpingAllDatabases, boolean includeUserName, boolean includeDate, PrintWriter out) throws SQLException, ServiceException { - printHeader(out, userInfo, includeDate); + printHeader(out, userInfo, includeUserName, includeDate); if (isDumpingAllDatabases) { // sort database names in an ascending lexicographic order of the names. @@ -134,13 +134,15 @@ public class TajoDump { out.flush(); } - private static void printHeader(PrintWriter writer, UserGroupInformation userInfo, boolean includeDate) { + private static void printHeader(PrintWriter writer, UserGroupInformation userInfo, boolean includeUSerName, + boolean includeDate) { writer.write("--\n"); writer.write("-- Tajo database dump\n"); - writer.write("--\n"); - writer.write("-- Dump user: " + userInfo.getUserName() + "\n"); + if (includeUSerName) { + writer.write("--\nDump user: " + userInfo.getUserName() + "\n"); + } if (includeDate) { - writer.write("-- Dump date: " + toDateString() + "\n"); + writer.write("\n-- Dump date: " + toDateString() + "\n"); } writer.write("--\n"); writer.write("\n"); @@ -154,7 +156,7 @@ public class TajoDump { writer.write("--\n"); writer.write("\n"); writer.write(String.format("CREATE DATABASE IF NOT EXISTS %s;", CatalogUtil.denormalizeIdentifier(databaseName))); - writer.write("\n"); + writer.write("\n\n"); // returned list is immutable. List tableNames = TUtil.newList(client.getTableList(databaseName)); http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/main/java/org/apache/tajo/engine/eval/BasicEvalNodeVisitor.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/eval/BasicEvalNodeVisitor.java b/tajo-core/src/main/java/org/apache/tajo/engine/eval/BasicEvalNodeVisitor.java index 2208119..015e9db 100644 --- a/tajo-core/src/main/java/org/apache/tajo/engine/eval/BasicEvalNodeVisitor.java +++ b/tajo-core/src/main/java/org/apache/tajo/engine/eval/BasicEvalNodeVisitor.java @@ -280,8 +280,8 @@ public class BasicEvalNodeVisitor implements EvalNodeVisitor2 stack) { RESULT result; stack.push(evalNode); - result = visitChild(context, evalNode.getConditionExpr(), stack); - visitChild(context, evalNode.getResultExpr(), stack); + result = visitChild(context, evalNode.getCondition(), stack); + visitChild(context, evalNode.getResult(), stack); stack.pop(); return result; } http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/main/java/org/apache/tajo/engine/eval/BetweenPredicateEval.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/eval/BetweenPredicateEval.java b/tajo-core/src/main/java/org/apache/tajo/engine/eval/BetweenPredicateEval.java index 0f30ac9..80e6494 100644 --- a/tajo-core/src/main/java/org/apache/tajo/engine/eval/BetweenPredicateEval.java +++ b/tajo-core/src/main/java/org/apache/tajo/engine/eval/BetweenPredicateEval.java @@ -46,14 +46,26 @@ public class BetweenPredicateEval extends EvalNode { this.end = end; } + public void setPredicand(EvalNode predicand) { + this.predicand = predicand; + } + public EvalNode getPredicand() { return predicand; } + public void setBegin(EvalNode begin) { + this.begin = begin; + } + public EvalNode getBegin() { return begin; } + public void setEnd(EvalNode end) { + this.end = end; + } + public EvalNode getEnd() { return end; } http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/main/java/org/apache/tajo/engine/eval/CaseWhenEval.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/eval/CaseWhenEval.java b/tajo-core/src/main/java/org/apache/tajo/engine/eval/CaseWhenEval.java index d08bfd3..0883e5c 100644 --- a/tajo-core/src/main/java/org/apache/tajo/engine/eval/CaseWhenEval.java +++ b/tajo-core/src/main/java/org/apache/tajo/engine/eval/CaseWhenEval.java @@ -63,7 +63,7 @@ public class CaseWhenEval extends EvalNode implements GsonObject { @Override public DataType getValueType() { - return whens.get(0).getResultExpr().getValueType(); + return whens.get(0).getResult().getValueType(); } @Override @@ -163,11 +163,19 @@ public class CaseWhenEval extends EvalNode implements GsonObject { return result.eval(schema, tuple); } - public EvalNode getConditionExpr() { + public void setCondition(EvalNode condition) { + this.condition = condition; + } + + public EvalNode getCondition() { return this.condition; } - public EvalNode getResultExpr() { + public void setResult(EvalNode result) { + this.result = result; + } + + public EvalNode getResult() { return this.result; } http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/main/java/org/apache/tajo/engine/eval/CastEval.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/eval/CastEval.java b/tajo-core/src/main/java/org/apache/tajo/engine/eval/CastEval.java index a024b01..24a0409 100644 --- a/tajo-core/src/main/java/org/apache/tajo/engine/eval/CastEval.java +++ b/tajo-core/src/main/java/org/apache/tajo/engine/eval/CastEval.java @@ -36,6 +36,10 @@ public class CastEval extends EvalNode { this.target = target; } + public void setOperand(EvalNode operand) { + this.operand = operand; + } + public EvalNode getOperand() { return operand; } http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/main/java/org/apache/tajo/engine/eval/EvalTreeUtil.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/eval/EvalTreeUtil.java b/tajo-core/src/main/java/org/apache/tajo/engine/eval/EvalTreeUtil.java index 7dcc26a..38c7e1f 100644 --- a/tajo-core/src/main/java/org/apache/tajo/engine/eval/EvalTreeUtil.java +++ b/tajo-core/src/main/java/org/apache/tajo/engine/eval/EvalTreeUtil.java @@ -57,11 +57,69 @@ public class EvalTreeUtil { if (evalNode.equals(target)) { EvalNode parent = stack.peek(); - if (parent.getLeftExpr().equals(evalNode)) { - parent.setLeftExpr(tobeReplaced); - } - if (parent.getRightExpr().equals(evalNode)) { - parent.setRightExpr(tobeReplaced); + if (parent instanceof BetweenPredicateEval) { + BetweenPredicateEval between = (BetweenPredicateEval) parent; + if (between.getPredicand().equals(evalNode)) { + between.setPredicand(tobeReplaced); + } + if (between.getBegin().equals(evalNode)) { + between.setBegin(tobeReplaced); + } + if (between.getEnd().equals(evalNode)) { + between.setEnd(tobeReplaced); + } + + } else if (parent instanceof CaseWhenEval) { + CaseWhenEval caseWhen = (CaseWhenEval) parent; + + // Here, we need to only consider only 'Else' + // because IfElseEval is handled in the below condition. + if (caseWhen.hasElse() && caseWhen.getElse().equals(evalNode)) { + caseWhen.setElseResult(tobeReplaced); + } + } else if (parent instanceof CaseWhenEval.IfThenEval) { + CaseWhenEval.IfThenEval ifThen = (CaseWhenEval.IfThenEval) parent; + if (ifThen.getCondition().equals(evalNode)) { + ifThen.setCondition(tobeReplaced); + } + if (ifThen.getResult().equals(evalNode)) { + ifThen.setResult(tobeReplaced); + } + } else if (parent instanceof CastEval) { + CastEval cast = (CastEval) parent; + if (cast.getOperand().equals(evalNode)) { + cast.setOperand(tobeReplaced); + } + + } else if (parent instanceof FunctionEval) { + FunctionEval functionEval = (FunctionEval) parent; + EvalNode [] arguments = functionEval.getArgs(); + for (int i = 0; i < arguments.length; i++) { + if (arguments[i].equals(evalNode)) { + arguments[i] = tobeReplaced; + } + } + functionEval.setArgs(arguments); + + } else if (parent instanceof NotEval) { + NotEval not = (NotEval) parent; + if (not.getChild().equals(evalNode)) { + not.setChild(tobeReplaced); + } + + } else if (parent instanceof SignedEval) { + SignedEval sign = (SignedEval) parent; + if (sign.getChild().equals(evalNode)) { + sign.setChild(tobeReplaced); + } + + } else { + if (parent.getLeftExpr() != null && parent.getLeftExpr().equals(evalNode)) { + parent.setLeftExpr(tobeReplaced); + } + if (parent.getRightExpr() != null && parent.getRightExpr().equals(evalNode)) { + parent.setRightExpr(tobeReplaced); + } } } http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/main/java/org/apache/tajo/engine/eval/FunctionEval.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/eval/FunctionEval.java b/tajo-core/src/main/java/org/apache/tajo/engine/eval/FunctionEval.java index de982e5..6781c34 100644 --- a/tajo-core/src/main/java/org/apache/tajo/engine/eval/FunctionEval.java +++ b/tajo-core/src/main/java/org/apache/tajo/engine/eval/FunctionEval.java @@ -64,7 +64,7 @@ public abstract class FunctionEval extends EvalNode implements Cloneable { public boolean isDistinct() { return funcDesc.getFuncType() == DISTINCT_AGGREGATION || funcDesc.getFuncType() == DISTINCT_UDA; } - + public EvalNode [] getArgs() { return this.argEvals; } http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/main/java/org/apache/tajo/engine/eval/NotEval.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/eval/NotEval.java b/tajo-core/src/main/java/org/apache/tajo/engine/eval/NotEval.java index 1a16af4..20de725 100644 --- a/tajo-core/src/main/java/org/apache/tajo/engine/eval/NotEval.java +++ b/tajo-core/src/main/java/org/apache/tajo/engine/eval/NotEval.java @@ -36,6 +36,10 @@ public class NotEval extends EvalNode implements Cloneable { this.childEval = childEval; } + public void setChild(EvalNode child) { + this.childEval = child; + } + public EvalNode getChild() { return childEval; } http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/main/java/org/apache/tajo/engine/eval/SignedEval.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/eval/SignedEval.java b/tajo-core/src/main/java/org/apache/tajo/engine/eval/SignedEval.java index 3c2eeb4..33ea70f 100644 --- a/tajo-core/src/main/java/org/apache/tajo/engine/eval/SignedEval.java +++ b/tajo-core/src/main/java/org/apache/tajo/engine/eval/SignedEval.java @@ -39,6 +39,10 @@ public class SignedEval extends EvalNode implements Cloneable { return negative; } + public void setChild(EvalNode child) { + this.childEval = child; + } + public EvalNode getChild() { return childEval; } http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/test/java/org/apache/tajo/client/TestTajoDump.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/java/org/apache/tajo/client/TestTajoDump.java b/tajo-core/src/test/java/org/apache/tajo/client/TestTajoDump.java new file mode 100644 index 0000000..e0d745e --- /dev/null +++ b/tajo-core/src/test/java/org/apache/tajo/client/TestTajoDump.java @@ -0,0 +1,46 @@ +/** + * 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.client; + +import org.apache.hadoop.security.UserGroupInformation; +import org.apache.tajo.QueryTestCaseBase; +import org.junit.Test; + +import java.io.ByteArrayOutputStream; +import java.io.PrintWriter; + +public class TestTajoDump extends QueryTestCaseBase { + + @Test + public void testDump1() throws Exception { + if (!testingCluster.isHCatalogStoreRunning()) { + executeString("CREATE TABLE \"" + getCurrentDatabase() + + "\".\"TableName1\" (\"Age\" int, \"FirstName\" TEXT, lastname TEXT)"); + + UserGroupInformation userInfo = UserGroupInformation.getCurrentUser(); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + PrintWriter printWriter = new PrintWriter(bos); + TajoDump.dump(client, userInfo, getCurrentDatabase(), false, false, false, printWriter); + printWriter.flush(); + printWriter.close(); + assertStrings(new String(bos.toByteArray())); + bos.close(); + } + } +} http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/test/java/org/apache/tajo/engine/query/TestTablePartitions.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestTablePartitions.java b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestTablePartitions.java index d11cad9..9cc2410 100644 --- a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestTablePartitions.java +++ b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestTablePartitions.java @@ -152,6 +152,41 @@ public class TestTablePartitions extends QueryTestCaseBase { res = executeFile("case3.sql"); assertResultSet(res, "case3.result"); res.close(); + + // select pow(key, 2) from testQueryCasesOnColumnPartitionedTable + res = executeFile("case4.sql"); + assertResultSet(res, "case4.result"); + res.close(); + + // select round(pow(key + 1, 2)) from testQueryCasesOnColumnPartitionedTable + res = executeFile("case5.sql"); + assertResultSet(res, "case5.result"); + res.close(); + + // select col1, key from testQueryCasesOnColumnPartitionedTable order by pow(key, 2) desc + res = executeFile("case6.sql"); + assertResultSet(res, "case6.result"); + res.close(); + + // select col1, key from testQueryCasesOnColumnPartitionedTable WHERE key BETWEEN 35 AND 48; + res = executeFile("case7.sql"); + assertResultSet(res, "case7.result"); + res.close(); + + // select col1, CASE key WHEN 36 THEN key WHEN 49 THEN key ELSE key END from testQueryCasesOnColumnPartitionedTable; + res = executeFile("case8.sql"); + assertResultSet(res, "case8.result"); + res.close(); + + // select col1, CAST(key AS INT) from testQueryCasesOnColumnPartitionedTable; + res = executeFile("case9.sql"); + assertResultSet(res, "case9.result"); + res.close(); + + // select col1, (!(key > 35)) from testQueryCasesOnColumnPartitionedTable; + res = executeFile("case10.sql"); + assertResultSet(res, "case10.result"); + res.close(); } @Test http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/test/resources/org/apache/tajo/client/TestTajoDump.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/resources/org/apache/tajo/client/TestTajoDump.java b/tajo-core/src/test/resources/org/apache/tajo/client/TestTajoDump.java deleted file mode 100644 index 7e72f9b..0000000 --- a/tajo-core/src/test/resources/org/apache/tajo/client/TestTajoDump.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * 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.client; - -import org.apache.hadoop.security.UserGroupInformation; -import org.apache.tajo.QueryTestCaseBase; -import org.junit.Test; - -import java.io.ByteArrayOutputStream; -import java.io.PrintWriter; - -public class TestTajoDump extends QueryTestCaseBase { - - @Test - public void testDump1() throws Exception { - executeString("CREATE TABLE \"" +getCurrentDatabase() + - "\".\"TableName1\" (\"Age\" int, \"FirstName\" TEXT, lastname TEXT)"); - - UserGroupInformation userInfo = UserGroupInformation.getCurrentUser(); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - PrintWriter printWriter = new PrintWriter(bos); - TajoDump.dump(client, userInfo, getCurrentDatabase(), false, false, printWriter); - printWriter.flush(); - printWriter.close(); - assertStrings(new String(bos.toByteArray())); - bos.close(); - } -} http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/test/resources/queries/TestTablePartitions/case10.sql ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/resources/queries/TestTablePartitions/case10.sql b/tajo-core/src/test/resources/queries/TestTablePartitions/case10.sql new file mode 100644 index 0000000..715d8e8 --- /dev/null +++ b/tajo-core/src/test/resources/queries/TestTablePartitions/case10.sql @@ -0,0 +1 @@ +select col1, key, -key as res from testQueryCasesOnColumnPartitionedTable; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/test/resources/queries/TestTablePartitions/case8.sql ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/resources/queries/TestTablePartitions/case8.sql b/tajo-core/src/test/resources/queries/TestTablePartitions/case8.sql new file mode 100644 index 0000000..fe57eb8 --- /dev/null +++ b/tajo-core/src/test/resources/queries/TestTablePartitions/case8.sql @@ -0,0 +1 @@ +select col1, CASE key WHEN 36 THEN key WHEN 49 THEN key ELSE key END from testQueryCasesOnColumnPartitionedTable; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/test/resources/queries/TestTablePartitions/case9.sql ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/resources/queries/TestTablePartitions/case9.sql b/tajo-core/src/test/resources/queries/TestTablePartitions/case9.sql new file mode 100644 index 0000000..595e533 --- /dev/null +++ b/tajo-core/src/test/resources/queries/TestTablePartitions/case9.sql @@ -0,0 +1 @@ +select col1, CAST(key AS INT) from testQueryCasesOnColumnPartitionedTable; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/test/resources/results/TestTablePartitions/case10.result ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/resources/results/TestTablePartitions/case10.result b/tajo-core/src/test/resources/results/TestTablePartitions/case10.result new file mode 100644 index 0000000..a6be56d --- /dev/null +++ b/tajo-core/src/test/resources/results/TestTablePartitions/case10.result @@ -0,0 +1,7 @@ +col1,key,res +------------------------------- +1,17.0,-17.0 +1,36.0,-36.0 +2,38.0,-38.0 +3,45.0,-45.0 +3,49.0,-49.0 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/test/resources/results/TestTablePartitions/case7.result ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/resources/results/TestTablePartitions/case7.result b/tajo-core/src/test/resources/results/TestTablePartitions/case7.result new file mode 100644 index 0000000..8426f48 --- /dev/null +++ b/tajo-core/src/test/resources/results/TestTablePartitions/case7.result @@ -0,0 +1,5 @@ +col1,key +------------------------------- +1,36.0 +2,38.0 +3,45.0 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/test/resources/results/TestTablePartitions/case8.result ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/resources/results/TestTablePartitions/case8.result b/tajo-core/src/test/resources/results/TestTablePartitions/case8.result new file mode 100644 index 0000000..cb51cd6 --- /dev/null +++ b/tajo-core/src/test/resources/results/TestTablePartitions/case8.result @@ -0,0 +1,7 @@ +col1,?casewhen +------------------------------- +1,17.0 +1,36.0 +2,38.0 +3,45.0 +3,49.0 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/test/resources/results/TestTablePartitions/case9.result ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/resources/results/TestTablePartitions/case9.result b/tajo-core/src/test/resources/results/TestTablePartitions/case9.result new file mode 100644 index 0000000..ebfaad2 --- /dev/null +++ b/tajo-core/src/test/resources/results/TestTablePartitions/case9.result @@ -0,0 +1,7 @@ +col1,?cast +------------------------------- +1,17 +1,36 +2,38 +3,45 +3,49 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/test/resources/results/TestTajoDump/testDump1.result ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/resources/results/TestTajoDump/testDump1.result b/tajo-core/src/test/resources/results/TestTajoDump/testDump1.result index bdf31fa..fa68435 100644 --- a/tajo-core/src/test/resources/results/TestTajoDump/testDump1.result +++ b/tajo-core/src/test/resources/results/TestTajoDump/testDump1.result @@ -1,9 +1,6 @@ -- -- Tajo database dump -- --- Dump user: hyunsik --- Dump date: 04/17/2014 13:33:45 --- -- @@ -11,7 +8,9 @@ -- CREATE DATABASE IF NOT EXISTS "TestTajoDump"; + -- --- Name: TestTajoDump.TableName1; Type: TABLE; Storage: CSV +-- Name: "TestTajoDump"."TableName1"; Type: TABLE; Storage: CSV -- -CREATE TABLE "TestTajoDump"."TableName1" ("Age" INT4, "FirstName" TEXT, lastname TEXT) USING CSV WITH ('csvfile.delimiter'='|'); \ No newline at end of file +CREATE TABLE "TestTajoDump"."TableName1" ("Age" INT4, "FirstName" TEXT, lastname TEXT) USING CSV WITH ('csvfile.delimiter'='|'); + http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/test/resources/results/testDDLBuilder/testBuildDDLForBaseTable.result ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/resources/results/testDDLBuilder/testBuildDDLForBaseTable.result b/tajo-core/src/test/resources/results/testDDLBuilder/testBuildDDLForBaseTable.result index bd59e2d..a6e2d05 100644 --- a/tajo-core/src/test/resources/results/testDDLBuilder/testBuildDDLForBaseTable.result +++ b/tajo-core/src/test/resources/results/testDDLBuilder/testBuildDDLForBaseTable.result @@ -1,5 +1,4 @@ -- -- Name: db1.table2; Type: TABLE; Storage: CSV --- Path: /table1 -- CREATE TABLE db1.table2 (name BLOB, addr TEXT) USING CSV WITH ('compression.codec'='org.apache.hadoop.io.compress.GzipCodec', 'csvfile.delimiter'='|'); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tajo/blob/e56a7a41/tajo-core/src/test/resources/results/testDDLBuilder/testBuildDDLQuotedTableName2.result ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/resources/results/testDDLBuilder/testBuildDDLQuotedTableName2.result b/tajo-core/src/test/resources/results/testDDLBuilder/testBuildDDLQuotedTableName2.result index da391cb..eeb9b59 100644 --- a/tajo-core/src/test/resources/results/testDDLBuilder/testBuildDDLQuotedTableName2.result +++ b/tajo-core/src/test/resources/results/testDDLBuilder/testBuildDDLQuotedTableName2.result @@ -1,5 +1,4 @@ -- -- Name: db1."TABLE1"; Type: TABLE; Storage: CSV --- Path: /table1 -- CREATE TABLE db1."TABLE1" (name BLOB, addr TEXT, "FirstName" TEXT, "LastName" TEXT, "with" TEXT) USING CSV WITH ('compression.codec'='org.apache.hadoop.io.compress.GzipCodec', 'csvfile.delimiter'='|') PARTITION BY COLUMN("BirthYear" INT4); \ No newline at end of file