ueshin commented on code in PR #50286:
URL: https://github.com/apache/spark/pull/50286#discussion_r1999339256


##########
python/pyspark/sql/tests/test_dataframe.py:
##########
@@ -1076,6 +1076,32 @@ def test_metadata_column(self):
                     [Row(0), Row(0), Row(0)],
                 )
 
+    def test_with_column_and_generator(self):
+        # SPARK-51451: Generators should be available with withColumn
+        df = self.spark.createDataFrame([("082017",)], ["dt"]).select(
+            to_date(col("dt"), "MMyyyy").alias("dt")
+        )
+        df_dt = df.withColumn("dt", date_format(col("dt"), "MM/dd/yyyy"))
+        monthArray = [lit(x) for x in range(0, 12)]
+        df_month_y = df_dt.withColumn("month_y", explode(array(monthArray)))

Review Comment:
   For this example, its parsed plan is:
   
   ```
   == Parsed Logical Plan ==
   'Project [unresolvedstarwithcolumns(month_y, 'explode('array(0, 1, 2, 3, 4, 
5, 6, 7, 8, 9, 10, 11)), Some(List({})))]
   +- 'Project ['date_format('to_date('dt, MMyyyy), MM/dd/yyyy) AS dt#5]
      +- 'UnresolvedSubqueryColumnAliases [dt]
         +- LocalRelation [dt#4]
   ```
   
   Here `explode` is nested in `unresolvedstarwithcolumns`.
   
   I also updated the description.



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