drill-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DRILL-3232) Modify existing vectors to allow type promotion
Date Fri, 30 Oct 2015 05:00:30 GMT

    [ https://issues.apache.org/jira/browse/DRILL-3232?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14981894#comment-14981894
] 

ASF GitHub Bot commented on DRILL-3232:
---------------------------------------

Github user jacques-n commented on a diff in the pull request:

    https://github.com/apache/drill/pull/207#discussion_r43471955
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/ExpressionTreeMaterializer.java
---
    @@ -323,23 +454,50 @@ public LogicalExpression visitIfExpression(IfExpression ifExpr,
FunctionLookupCo
     
           MinorType thenType = conditions.expression.getMajorType().getMinorType();
           MinorType elseType = newElseExpr.getMajorType().getMinorType();
    -
    -      // Check if we need a cast
    -      if (thenType != elseType && !(thenType == MinorType.NULL || elseType ==
MinorType.NULL)) {
    -
    -        MinorType leastRestrictive = TypeCastRules.getLeastRestrictiveType((Arrays.asList(thenType,
elseType)));
    -        if (leastRestrictive != thenType) {
    -          // Implicitly cast the then expression
    +      boolean hasUnion = thenType == MinorType.UNION || elseType == MinorType.UNION;
    +      if (unionTypeEnabled) {
    +        if (thenType != elseType && !(thenType == MinorType.NULL || elseType
== MinorType.NULL)) {
    +
    +          MinorType leastRestrictive = MinorType.UNION;
    +          MajorType.Builder builder = MajorType.newBuilder().setMinorType(MinorType.UNION).setMode(DataMode.OPTIONAL);
    +          if (thenType == MinorType.UNION) {
    +            for (MinorType subType : conditions.expression.getMajorType().getSubTypeList())
{
    +              builder.addSubType(subType);
    +            }
    +          } else {
    +            builder.addSubType(thenType);
    +          }
    +          if (elseType == MinorType.UNION) {
    +            for (MinorType subType : newElseExpr.getMajorType().getSubTypeList()) {
    +              builder.addSubType(subType);
    +            }
    +          } else {
    +            builder.addSubType(elseType);
    +          }
    +          MajorType unionType = builder.build();
               conditions = new IfExpression.IfCondition(newCondition,
    -          addCastExpression(conditions.expression, newElseExpr.getMajorType(), functionLookupContext,
errorCollector));
    -        } else if (leastRestrictive != elseType) {
    -          // Implicitly cast the else expression
    -          newElseExpr = addCastExpression(newElseExpr, conditions.expression.getMajorType(),
functionLookupContext, errorCollector);
    -        } else {
    -          /* Cannot cast one of the two expressions to make the output type of if and
else expression
    -           * to be the same. Raise error.
    -           */
    -          throw new DrillRuntimeException("Case expression should have similar output
type on all its branches");
    +                  addCastExpression(conditions.expression, unionType, functionLookupContext,
errorCollector));
    +          newElseExpr = addCastExpression(newElseExpr, unionType, functionLookupContext,
errorCollector);
    +        }
    +
    +      } else {
    +        // Check if we need a cast
    +        if (thenType != elseType && !(thenType == MinorType.NULL || elseType
== MinorType.NULL)) {
    +
    +          MinorType leastRestrictive = TypeCastRules.getLeastRestrictiveType((Arrays.asList(thenType,
elseType)));
    +          if (leastRestrictive != thenType) {
    +            // Implicitly cast the then expression
    +            conditions = new IfExpression.IfCondition(newCondition,
    +            addCastExpression(conditions.expression, newElseExpr.getMajorType(), functionLookupContext,
errorCollector));
    +          } else if (leastRestrictive != elseType) {
    +            // Implicitly cast the else expression
    +            newElseExpr = addCastExpression(newElseExpr, conditions.expression.getMajorType(),
functionLookupContext, errorCollector);
    +          } else {
    +            /* Cannot cast one of the two expressions to make the output type of if and
else expression
    +             * to be the same. Raise error.
    +             */
    +            throw new DrillRuntimeException("Case expression should have similar output
type on all its branches");
    --- End diff --
    
    With union type enabled, we should never get here, right? It seems like you're adding
the Union implicit casts to the implicit casting map. Are we going to get union casts even
if union type is disabled because of the implicit casting map?


> Modify existing vectors to allow type promotion
> -----------------------------------------------
>
>                 Key: DRILL-3232
>                 URL: https://issues.apache.org/jira/browse/DRILL-3232
>             Project: Apache Drill
>          Issue Type: Sub-task
>          Components: Execution - Codegen, Execution - Data Types, Execution - Relational
Operators, Functions - Drill
>            Reporter: Steven Phillips
>            Assignee: Hanifi Gunes
>             Fix For: 1.3.0
>
>
> Support the ability for existing vectors to be promoted similar to supported implicit
casting rules.
> For example:
> INT > DOUBLE > STRING > EMBEDDED



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message