Return-Path: X-Original-To: apmail-hive-commits-archive@www.apache.org Delivered-To: apmail-hive-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id ADC1518808 for ; Thu, 6 Aug 2015 00:50:07 +0000 (UTC) Received: (qmail 46630 invoked by uid 500); 6 Aug 2015 00:50:07 -0000 Delivered-To: apmail-hive-commits-archive@hive.apache.org Received: (qmail 46573 invoked by uid 500); 6 Aug 2015 00:50:07 -0000 Mailing-List: contact commits-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hive-dev@hive.apache.org Delivered-To: mailing list commits@hive.apache.org Received: (qmail 46533 invoked by uid 99); 6 Aug 2015 00:50:07 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Aug 2015 00:50:07 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 56A36DFC13; Thu, 6 Aug 2015 00:50:07 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sershe@apache.org To: commits@hive.apache.org Date: Thu, 06 Aug 2015 00:50:07 -0000 Message-Id: <8f9d1818a5f44addab68cb4879fb5a27@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [01/53] [abbrv] hive git commit: HIVE-10799. Refactor the SearchArgumentFactory to remove the AST-specific factory. (omalley reviewed by prasanth_j) Repository: hive Updated Branches: refs/heads/llap ef454511d -> c8ae1fbf1 http://git-wip-us.apache.org/repos/asf/hive/blob/c178a6e9/serde/src/java/org/apache/hadoop/hive/ql/io/sarg/PredicateLeaf.java ---------------------------------------------------------------------- diff --git a/serde/src/java/org/apache/hadoop/hive/ql/io/sarg/PredicateLeaf.java b/serde/src/java/org/apache/hadoop/hive/ql/io/sarg/PredicateLeaf.java index 0a95363..3a92565 100644 --- a/serde/src/java/org/apache/hadoop/hive/ql/io/sarg/PredicateLeaf.java +++ b/serde/src/java/org/apache/hadoop/hive/ql/io/sarg/PredicateLeaf.java @@ -18,6 +18,10 @@ package org.apache.hadoop.hive.ql.io.sarg; +import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable; + +import java.sql.Date; +import java.sql.Timestamp; import java.util.List; /** @@ -43,14 +47,27 @@ public interface PredicateLeaf { * The possible types for sargs. */ public static enum Type { - INTEGER, // all of the integer types except long - LONG, - FLOAT, // float and double - STRING, // string, char, varchar - DATE, - DECIMAL, - TIMESTAMP, - BOOLEAN + INTEGER(Integer.class), // all of the integer types except long + LONG(Long.class), + FLOAT(Double.class), // float and double + STRING(String.class), // string, char, varchar + DATE(Date.class), + DECIMAL(HiveDecimalWritable.class), + TIMESTAMP(Timestamp.class), + BOOLEAN(Boolean.class); + + private final Class cls; + Type(Class cls) { + this.cls = cls; + } + + /** + * For all SARG leaves, the values must be the matching class. + * @return the value class + */ + public Class getValueClass() { + return cls; + } } /** http://git-wip-us.apache.org/repos/asf/hive/blob/c178a6e9/serde/src/java/org/apache/hadoop/hive/ql/io/sarg/SearchArgument.java ---------------------------------------------------------------------- diff --git a/serde/src/java/org/apache/hadoop/hive/ql/io/sarg/SearchArgument.java b/serde/src/java/org/apache/hadoop/hive/ql/io/sarg/SearchArgument.java index 84604cb..bc0d503 100644 --- a/serde/src/java/org/apache/hadoop/hive/ql/io/sarg/SearchArgument.java +++ b/serde/src/java/org/apache/hadoop/hive/ql/io/sarg/SearchArgument.java @@ -215,58 +215,78 @@ public interface SearchArgument { /** * Add a less than leaf to the current item on the stack. * @param column the name of the column + * @param type the type of the expression * @param literal the literal * @return this */ - public Builder lessThan(String column, Object literal); + public Builder lessThan(String column, PredicateLeaf.Type type, + Object literal); /** * Add a less than equals leaf to the current item on the stack. * @param column the name of the column + * @param type the type of the expression * @param literal the literal * @return this */ - public Builder lessThanEquals(String column, Object literal); + public Builder lessThanEquals(String column, PredicateLeaf.Type type, + Object literal); /** * Add an equals leaf to the current item on the stack. * @param column the name of the column + * @param type the type of the expression * @param literal the literal * @return this */ - public Builder equals(String column, Object literal); + public Builder equals(String column, PredicateLeaf.Type type, + Object literal); /** * Add a null safe equals leaf to the current item on the stack. * @param column the name of the column + * @param type the type of the expression * @param literal the literal * @return this */ - public Builder nullSafeEquals(String column, Object literal); + public Builder nullSafeEquals(String column, PredicateLeaf.Type type, + Object literal); /** * Add an in leaf to the current item on the stack. * @param column the name of the column + * @param type the type of the expression * @param literal the literal * @return this */ - public Builder in(String column, Object... literal); + public Builder in(String column, PredicateLeaf.Type type, + Object... literal); /** * Add an is null leaf to the current item on the stack. * @param column the name of the column + * @param type the type of the expression * @return this */ - public Builder isNull(String column); + public Builder isNull(String column, PredicateLeaf.Type type); /** * Add a between leaf to the current item on the stack. * @param column the name of the column + * @param type the type of the expression * @param lower the literal * @param upper the literal * @return this */ - public Builder between(String column, Object lower, Object upper); + public Builder between(String column, PredicateLeaf.Type type, + Object lower, Object upper); + + /** + * Add a truth value to the expression. + * @param truth + * @return this + */ + public Builder literal(TruthValue truth); /** * Build and return the SearchArgument that has been defined. All of the http://git-wip-us.apache.org/repos/asf/hive/blob/c178a6e9/serde/src/java/org/apache/hadoop/hive/serde2/io/HiveDecimalWritable.java ---------------------------------------------------------------------- diff --git a/serde/src/java/org/apache/hadoop/hive/serde2/io/HiveDecimalWritable.java b/serde/src/java/org/apache/hadoop/hive/serde2/io/HiveDecimalWritable.java index a17d2cc..885828a 100644 --- a/serde/src/java/org/apache/hadoop/hive/serde2/io/HiveDecimalWritable.java +++ b/serde/src/java/org/apache/hadoop/hive/serde2/io/HiveDecimalWritable.java @@ -46,6 +46,10 @@ public class HiveDecimalWritable implements WritableComparable