carbondata-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From QiangCai <...@git.apache.org>
Subject [GitHub] incubator-carbondata pull request #403: [CARBONDATA-497][SPARK2]fix datatype...
Date Wed, 07 Dec 2016 03:46:46 GMT
Github user QiangCai commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/403#discussion_r91222679
  
    --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/optimizer/CarbonLateDecodeRule.scala
---
    @@ -456,76 +487,143 @@ class CarbonLateDecodeRule extends Rule[LogicalPlan] with PredicateHelper
{
           case cd: CarbonDictionaryCatalystDecoder =>
             cd
           case sort: Sort =>
    +        val tmpAttrMap = new mutable.HashMap[AttributeReferenceWrapper, Attribute]()
    +        if (sort.child.isInstanceOf[CarbonDictionaryTempDecoder]) {
    +          val tempDecoder = sort.child.asInstanceOf[CarbonDictionaryTempDecoder]
    +          tempDecoder.attrList.asScala.foreach{attr => tmpAttrMap.put(attr, attr.attr)}
    +        }
             val sortExprs = sort.order.map { s =>
               s.transform {
                 case attr: AttributeReference =>
    -              updateDataType(attr, attrMap, allAttrsNotDecode, aliasMap)
    +              val tempAttr = tmpAttrMap.get(AttributeReferenceWrapper(attr))
    +              if(tempAttr.isDefined) {
    +                tempAttr.get
    +              } else {
    +                updateDataType(attr, attrMap, allAttrsNotDecode, aliasMap)
    +              }
               }.asInstanceOf[SortOrder]
             }
             Sort(sortExprs, sort.global, sort.child)
           case agg: Aggregate if !agg.child.isInstanceOf[CarbonDictionaryCatalystDecoder]
=>
    +        val tmpAttrMap = new mutable.HashMap[AttributeReferenceWrapper, Attribute]()
    +        if (agg.child.isInstanceOf[CarbonDictionaryTempDecoder]) {
    +          val tempDecoder = agg.child.asInstanceOf[CarbonDictionaryTempDecoder]
    +          tempDecoder.attrList.asScala.foreach{attr => tmpAttrMap.put(attr, attr.attr)}
    +        }
    +
             val aggExps = agg.aggregateExpressions.map { aggExp =>
               aggExp.transform {
                 case attr: AttributeReference =>
    -              updateDataType(attr, attrMap, allAttrsNotDecode, aliasMap)
    +              val tempAttr = tmpAttrMap.get(AttributeReferenceWrapper(attr))
    +              if(tempAttr.isDefined) {
    +                tempAttr.get
    +              } else {
    +                updateDataType(attr, attrMap, allAttrsNotDecode, aliasMap)
    +              }
               }
             }.asInstanceOf[Seq[NamedExpression]]
     
             val grpExps = agg.groupingExpressions.map { gexp =>
               gexp.transform {
                 case attr: AttributeReference =>
    -              updateDataType(attr, attrMap, allAttrsNotDecode, aliasMap)
    +              val tempAttr = tmpAttrMap.get(AttributeReferenceWrapper(attr))
    +              if(tempAttr.isDefined) {
    +                tempAttr.get
    +              } else {
    +                updateDataType(attr, attrMap, allAttrsNotDecode, aliasMap)
    +              }
               }
             }
             Aggregate(grpExps, aggExps, agg.child)
           case expand: Expand =>
    +        val tmpAttrMap = new mutable.HashMap[AttributeReferenceWrapper, Attribute]()
    +        if (expand.child.isInstanceOf[CarbonDictionaryTempDecoder]) {
    +          val tempDecoder = expand.child.asInstanceOf[CarbonDictionaryTempDecoder]
    +          tempDecoder.attrList.asScala.foreach{attr => tmpAttrMap.put(attr, attr.attr)}
    +        }
             expand.transformExpressions {
               case attr: AttributeReference =>
    -            updateDataType(attr, attrMap, allAttrsNotDecode, aliasMap)
    +            val tempAttr = tmpAttrMap.get(AttributeReferenceWrapper(attr))
    +            if(tempAttr.isDefined) {
    +              tempAttr.get
    +            } else {
    +              updateDataType(attr, attrMap, allAttrsNotDecode, aliasMap)
    +            }
             }
           case filter: Filter =>
    -        val filterExps = filter.condition transform {
    -          case attr: AttributeReference =>
    -            updateDataType(attr, attrMap, allAttrsNotDecode, aliasMap)
    -        }
    -        Filter(filterExps, filter.child)
    +        filter
           case j: Join =>
             marker.pushBinaryMarker(allAttrsNotDecode)
             j
           case u: Union =>
             marker.pushBinaryMarker(allAttrsNotDecode)
             u
           case p: Project if relations.nonEmpty =>
    +        val tmpAttrMap = new mutable.HashMap[AttributeReferenceWrapper, Attribute]()
    +        if (p.child.isInstanceOf[CarbonDictionaryTempDecoder]) {
    +          val tempDecoder = p.child.asInstanceOf[CarbonDictionaryTempDecoder]
    +          tempDecoder.attrList.asScala.foreach{attr => tmpAttrMap.put(attr, attr.attr)}
    +        }
             val prExps = p.projectList.map { prExp =>
    -          prExp.transform {
    -            case attr: AttributeReference =>
    -              updateDataType(attr, attrMap, allAttrsNotDecode, aliasMap)
    -          }
    +              prExp.transform {
    --- End diff --
    
    fixed


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message