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

   ### What changes were proposed in this pull request?
   
   Fixes `ExtractGenerator` to wait for `UnresolvedStarWithColumns` to be 
resolved.
   
   ### Why are the changes needed?
   
   `df.withColumn` is now analyzed in the analyzer, it causes 
`ExtractGenerator` rule to misunderstand that the generator is nested.
   
   This only happens with Spark Connect because Spark Classic always can 
resolve `UnresolvedStarWithColumns` before `ExtractGenerator` rule.
   
   ```py
   from pyspark.sql.functions import *
   
   df = spark.createDataFrame([("082017",)], ['dt'])
   df_dt = df.select(date_format(to_date(col("dt"), "MMyyyy"), 
"MM/dd/yyyy").alias("dt"))
   
   monthArray = [lit(x) for x in range(0, 12)]
   df_month_y = df_dt.withColumn("month_y", explode(array(monthArray)))
   
   df_month_y.show()
   ```
   
   ```
   pyspark.errors.exceptions.connect.AnalysisException: 
[UNSUPPORTED_GENERATOR.NESTED_IN_EXPRESSIONS] The generator is not supported: 
nested in expressions "unresolvedstarwithcolumns(explode(array(0, 1, 2, 3, 4, 
5, 6, 7, 8, 9, 10, 11)))". SQLSTATE: 42K0E
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, `df.withColumn` with generators will be back available.
   
   ### How was this patch tested?
   
   Added the related tests.
   
   ### 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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to