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 90FD011549 for ; Thu, 11 Sep 2014 18:49:08 +0000 (UTC) Received: (qmail 16628 invoked by uid 500); 11 Sep 2014 18:49:08 -0000 Delivered-To: apmail-hive-commits-archive@hive.apache.org Received: (qmail 16576 invoked by uid 500); 11 Sep 2014 18:49:08 -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 16564 invoked by uid 99); 11 Sep 2014 18:49:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Sep 2014 18:49:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Sep 2014 18:48:45 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4409D23889D5; Thu, 11 Sep 2014 18:48:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1624360 - in /hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator: RexNodeConverter.java TypeConverter.java Date: Thu, 11 Sep 2014 18:48:43 -0000 To: commits@hive.apache.org From: hashutosh@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140911184843.4409D23889D5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: hashutosh Date: Thu Sep 11 18:48:42 2014 New Revision: 1624360 URL: http://svn.apache.org/r1624360 Log: HIVE-8048 : [CBO] Handle union type (Ashutosh Chauhan via John Pullokkaran) Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/RexNodeConverter.java hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/TypeConverter.java Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/RexNodeConverter.java URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/RexNodeConverter.java?rev=1624360&r1=1624359&r2=1624360&view=diff ============================================================================== --- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/RexNodeConverter.java (original) +++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/RexNodeConverter.java Thu Sep 11 18:48:42 2014 @@ -34,6 +34,7 @@ import org.apache.hadoop.hive.common.typ import org.apache.hadoop.hive.common.type.HiveDecimal; import org.apache.hadoop.hive.common.type.HiveVarchar; import org.apache.hadoop.hive.ql.exec.FunctionRegistry; +import org.apache.hadoop.hive.ql.optimizer.optiq.OptiqSemanticException; import org.apache.hadoop.hive.ql.parse.ParseUtils; import org.apache.hadoop.hive.ql.parse.RowResolver; import org.apache.hadoop.hive.ql.parse.SemanticException; @@ -211,7 +212,8 @@ public class RexNodeConverter { return castExpr; } - private RexNode handleExplicitCast(ExprNodeGenericFuncDesc func, List childRexNodeLst) { + private RexNode handleExplicitCast(ExprNodeGenericFuncDesc func, + List childRexNodeLst) throws OptiqSemanticException { RexNode castExpr = null; if (childRexNodeLst != null && childRexNodeLst.size() == 1) { Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/TypeConverter.java URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/TypeConverter.java?rev=1624360&r1=1624359&r2=1624360&view=diff ============================================================================== --- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/TypeConverter.java (original) +++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/TypeConverter.java Thu Sep 11 18:48:42 2014 @@ -17,12 +17,14 @@ */ package org.apache.hadoop.hive.ql.optimizer.optiq.translator; +import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Map; import org.apache.hadoop.hive.ql.exec.ColumnInfo; import org.apache.hadoop.hive.ql.exec.RowSchema; +import org.apache.hadoop.hive.ql.optimizer.optiq.OptiqSemanticException; import org.apache.hadoop.hive.ql.optimizer.optiq.translator.SqlFunctionConverter.HiveToken; import org.apache.hadoop.hive.ql.parse.HiveParser; import org.apache.hadoop.hive.ql.parse.RowResolver; @@ -68,7 +70,8 @@ public class TypeConverter { }; /*********************** Convert Hive Types To Optiq Types ***********************/ - public static RelDataType getType(RelOptCluster cluster, List cInfoLst) { + public static RelDataType getType(RelOptCluster cluster, + List cInfoLst) throws OptiqSemanticException { RexBuilder rexBuilder = cluster.getRexBuilder(); RelDataTypeFactory dtFactory = rexBuilder.getTypeFactory(); List fieldTypes = new LinkedList(); @@ -81,7 +84,8 @@ public class TypeConverter { return dtFactory.createStructType(fieldTypes, fieldNames); } - public static RelDataType getType(RelOptCluster cluster, RowResolver rr, List neededCols) { + public static RelDataType getType(RelOptCluster cluster, RowResolver rr, + List neededCols) throws OptiqSemanticException { RexBuilder rexBuilder = cluster.getRexBuilder(); RelDataTypeFactory dtFactory = rexBuilder.getTypeFactory(); RowSchema rs = rr.getRowSchema(); @@ -97,7 +101,8 @@ public class TypeConverter { return dtFactory.createStructType(fieldTypes, fieldNames); } - public static RelDataType convert(TypeInfo type, RelDataTypeFactory dtFactory) { + public static RelDataType convert(TypeInfo type, RelDataTypeFactory dtFactory) + throws OptiqSemanticException{ RelDataType convertedType = null; switch (type.getCategory()) { @@ -185,31 +190,32 @@ public class TypeConverter { return convertedType; } - public static RelDataType convert(ListTypeInfo lstType, RelDataTypeFactory dtFactory) { + public static RelDataType convert(ListTypeInfo lstType, + RelDataTypeFactory dtFactory) throws OptiqSemanticException { RelDataType elemType = convert(lstType.getListElementTypeInfo(), dtFactory); return dtFactory.createArrayType(elemType, -1); } - public static RelDataType convert(MapTypeInfo mapType, RelDataTypeFactory dtFactory) { + public static RelDataType convert(MapTypeInfo mapType, RelDataTypeFactory dtFactory) + throws OptiqSemanticException { RelDataType keyType = convert(mapType.getMapKeyTypeInfo(), dtFactory); RelDataType valueType = convert(mapType.getMapValueTypeInfo(), dtFactory); return dtFactory.createMapType(keyType, valueType); } - public static RelDataType convert(StructTypeInfo structType, final RelDataTypeFactory dtFactory) { - List fTypes = Lists.transform(structType.getAllStructFieldTypeInfos(), - new Function() { - @Override - public RelDataType apply(TypeInfo tI) { - return convert(tI, dtFactory); - } - }); + public static RelDataType convert(StructTypeInfo structType, + final RelDataTypeFactory dtFactory) throws OptiqSemanticException { + List fTypes = new ArrayList(structType.getAllStructFieldTypeInfos().size()); + for (TypeInfo ti : structType.getAllStructFieldTypeInfos()) { + fTypes.add(convert(ti,dtFactory)); + } return dtFactory.createStructType(fTypes, structType.getAllStructFieldNames()); } - public static RelDataType convert(UnionTypeInfo unionType, RelDataTypeFactory dtFactory) { - // @todo what do we about unions? - throw new UnsupportedOperationException(); + public static RelDataType convert(UnionTypeInfo unionType, RelDataTypeFactory dtFactory) + throws OptiqSemanticException{ + // Union type is not supported in Optiq. + throw new OptiqSemanticException("Union type is not supported"); } public static TypeInfo convert(RelDataType rType) {