hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From x..@apache.org
Subject [36/50] [abbrv] hive git commit: HIVE-11251: CBO (Calcite Return Path): Extending ExprNodeConverter to consider additional types (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)
Date Thu, 16 Jul 2015 07:52:54 GMT
HIVE-11251: CBO (Calcite Return Path): Extending ExprNodeConverter to consider additional types
(Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/8662d9da
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/8662d9da
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/8662d9da

Branch: refs/heads/parquet
Commit: 8662d9dae3da1cdbec3ac8c2c4f7d9f12ae5f1f0
Parents: af4aeab
Author: Jesus Camacho Rodriguez <jcamacho@apache.org>
Authored: Wed Jul 15 07:06:14 2015 +0100
Committer: Jesus Camacho Rodriguez <jcamacho@apache.org>
Committed: Wed Jul 15 18:31:59 2015 +0100

----------------------------------------------------------------------
 .../calcite/translator/ExprNodeConverter.java      | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/8662d9da/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ExprNodeConverter.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ExprNodeConverter.java
b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ExprNodeConverter.java
index bcce74a..4f0db03 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ExprNodeConverter.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/ExprNodeConverter.java
@@ -17,6 +17,7 @@
  */
 package org.apache.hadoop.hive.ql.optimizer.calcite.translator;
 
+import java.math.BigDecimal;
 import java.sql.Date;
 import java.sql.Timestamp;
 import java.util.ArrayList;
@@ -43,6 +44,8 @@ import org.apache.calcite.sql.type.SqlTypeUtil;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hive.common.type.HiveChar;
+import org.apache.hadoop.hive.common.type.HiveIntervalDayTime;
+import org.apache.hadoop.hive.common.type.HiveIntervalYearMonth;
 import org.apache.hadoop.hive.common.type.HiveVarchar;
 import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
 import org.apache.hadoop.hive.ql.optimizer.calcite.translator.ASTConverter.RexVisitor;
@@ -199,6 +202,7 @@ public class ExprNodeConverter extends RexVisitorImpl<ExprNodeDesc>
{
       return new ExprNodeConstantDesc(TypeInfoFactory.longTypeInfo, Long.valueOf(((Number)
literal
           .getValue3()).longValue()));
     case FLOAT:
+    case REAL:
       return new ExprNodeConstantDesc(TypeInfoFactory.floatTypeInfo,
           Float.valueOf(((Number) literal.getValue3()).floatValue()));
     case DOUBLE:
@@ -207,6 +211,7 @@ public class ExprNodeConverter extends RexVisitorImpl<ExprNodeDesc>
{
     case DATE:
       return new ExprNodeConstantDesc(TypeInfoFactory.dateTypeInfo,
         new Date(((Calendar)literal.getValue()).getTimeInMillis()));
+    case TIME:
     case TIMESTAMP: {
       Object value = literal.getValue3();
       if (value instanceof Long) {
@@ -225,6 +230,18 @@ public class ExprNodeConverter extends RexVisitorImpl<ExprNodeDesc>
{
     case CHAR:
       return new ExprNodeConstantDesc(TypeInfoFactory.getCharTypeInfo(lType.getPrecision()),
           new HiveChar((String) literal.getValue3(), lType.getPrecision()));
+    case INTERVAL_YEAR_MONTH: {
+      BigDecimal monthsBd = (BigDecimal) literal.getValue();
+      return new ExprNodeConstantDesc(TypeInfoFactory.intervalYearMonthTypeInfo,
+              new HiveIntervalYearMonth(monthsBd.intValue()));
+    }
+    case INTERVAL_DAY_TIME: {
+      BigDecimal millisBd = (BigDecimal) literal.getValue();
+      // Calcite literal is in millis, we need to convert to seconds
+      BigDecimal secsBd = millisBd.divide(BigDecimal.valueOf(1000));
+      return new ExprNodeConstantDesc(TypeInfoFactory.intervalDayTimeTypeInfo,
+              new HiveIntervalDayTime(secsBd));
+    }
     case OTHER:
     default:
       return new ExprNodeConstantDesc(TypeInfoFactory.voidTypeInfo, literal.getValue3());


Mime
View raw message