Github user sameeragarwal commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16785#discussion_r102361204
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/LogicalPlan.scala
 ---
    @@ -314,7 +314,17 @@ abstract class UnaryNode extends LogicalPlan {
        * expressions with the corresponding alias
        */
       protected def getAliasedConstraints(projectList: Seq[NamedExpression]): 
Set[Expression] = {
    -    var allConstraints = child.constraints.asInstanceOf[Set[Expression]]
    +    val relativeReferences = AttributeSet(projectList.collect {
    +      case a: Alias => a
    +    }.flatMap(_.references)) ++ outputSet
    +
    +    // We only care about the constraints which refer to attributes in 
output and aliases.
    +    // For example, for a constraint 'a > b', if 'a' is aliased to 'c', we 
need to get aliased
    +    // constraint 'c > b' only if 'b' is in output.
    +    var allConstraints = child.constraints.filter { constraint =>
    +      constraint.references.subsetOf(relativeReferences)
    --- End diff --
    
    Hi @viirya, I understand that https://github.com/apache/spark/pull/16998 
probably supersedes this, but just out of curiosity, did you see a lot of 
benefit from pruning these attributes here given that we already prune them 
later in `QueryPlan`?


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to