zhengruifeng opened a new pull request, #43683:
URL: https://github.com/apache/spark/pull/43683

   ### What changes were proposed in this pull request?
   Fix column resolution in DataFrame.drop
   
   
   
   
   ### Why are the changes needed?
   
   ```
   from pyspark.sql.functions import col
   
   # create first dataframe
   left_df = spark.createDataFrame([(1, 'a'), (2, 'b'), (3, 'c')], ['join_key', 
'value1'])
   # create second dataframe
   right_df = spark.createDataFrame([(1, 'aa'), (2, 'bb'), (4, 'dd')], 
['join_key', 'value2'])
   joined_df = left_df.join(right_df, on=left_df['join_key'] == 
right_df['join_key'], how='left')
   display(joined_df)
   cleaned_df = joined_df.drop(left_df['join_key'])
   display(cleaned_df) # error here
   
   JVM stacktrace:
   org.apache.spark.sql.AnalysisException: [AMBIGUOUS_REFERENCE] Reference 
`join_key` is ambiguous, could be: [`join_key`, `join_key`]. SQLSTATE: 42704
        at 
org.apache.spark.sql.errors.QueryCompilationErrors$.ambiguousReferenceError(QueryCompilationErrors.scala:1957)
        at 
org.apache.spark.sql.catalyst.expressions.package$AttributeSeq.resolve(package.scala:377)
        at 
org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.resolve(LogicalPlan.scala:156)
        at 
org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.resolveQuoted(LogicalPlan.scala:167)
        at org.apache.spark.sql.Dataset.$anonfun$drop$4(Dataset.scala:3071)
   ```
   
   
   
   ### Does this PR introduce _any_ user-facing change?
   no
   
   
   ### How was this patch tested?
   ci
   
   ### Was this patch authored or co-authored using generative AI tooling?
   no
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to