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

    https://github.com/apache/spark/pull/7478#discussion_r34944311
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/SQLContext.scala ---
    @@ -1018,6 +1022,20 @@ class SQLContext(@transient val sparkContext: 
SparkContext)
       }
     
       /**
    +   * Used to resolve virtual column attributes and insert the expression 
for them. Add case
    +   * statements to this for each additional virtual column
    +   */
    +  private[sql] class VirtualColumnsRule(resolver: Resolver) extends 
Rule[LogicalPlan] {
    +    def apply(plan: LogicalPlan): LogicalPlan = plan transform {
    +      case lPlan: LogicalPlan => lPlan transformExpressionsUp {
    +        case u @ UnresolvedAttribute(nameParts) if nameParts.length == 1 &&
    +          resolver(nameParts(0), VirtualColumn.sparkPartitionId) =>
    +          Alias(SparkPartitionID, VirtualColumn.sparkPartitionId)()
    --- End diff --
    
    I see. Actually, I think you do not need to make any change in 
`LogicalPlan.scala` at all because seems you are changing an 
`UnresolvedAttribute` to another `UnresolvedAttribute`. You only need this rule 
to resolve virtual columns.
    
    btw, SQLContext is not a good place for this rule. I guess you can move it 
to the package of `org.apache.spark.sql.expressions` and rename it to 
`ResolveVirtualColumns`.


---
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