Github user cloud-fan commented on the pull request:

    https://github.com/apache/spark/pull/12719#issuecomment-216444201
  
    Sorry for the delay, I was on 5.1 vacation and didn't bring my laptop.
    
    One comment about the `FoldablePropagation` rule:
    I think we can make it more general to fit all cases, instead of being 
restricted on some operators.
    Give a plan tree, we can first traverse it to find a `Project` that 
contains foldable expressions. Then transform the plan tree, replace attributes 
with corresponding foldable expressions.
    e.g.
    ```
    val projWithConstant = plan.find {
      case Proejct(projectList, _)  => projectList.exists(_.foldable)
      case _ => false
    }
    
    if (projWithConstant.isEmpty) {
      plan
    } else {
      val attrToContant = projWithConstant.map { p =>
        p.output.zip(p.projectList).filter(_._2.foldable)
      }.get
    
      plan.trasformAllExpressions {
        case attr: Attribute if attrToConstant.contains(attr) => 
attrToConstant(attr)
      }
    }
    
    ```


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to