pralabhkumar commented on a change in pull request #35191:
URL: https://github.com/apache/spark/pull/35191#discussion_r784503236



##########
File path: python/pyspark/pandas/series.py
##########
@@ -5228,22 +5228,62 @@ def asof(self, where: Union[Any, List]) -> 
Union[Scalar, "Series"]:
             where = [where]
         index_scol = self._internal.index_spark_columns[0]
         index_type = self._internal.spark_type_for(index_scol)
+        from pyspark.sql.functions import struct, lit, explode, col, row_number
+
+        column_prefix_constant = "col_"
         cond = [
-            F.max(F.when(index_scol <= SF.lit(index).cast(index_type), 
self.spark.column))
+            F.when(
+                index_scol <= SF.lit(index).cast(index_type),
+                struct(
+                    lit(column_prefix_constant + 
str(index)).alias("identifier"),
+                    self.spark.column.alias("Koalas"),
+                ),
+            ).alias(column_prefix_constant + str(index))
             for index in where
         ]
+        cond.append(index_scol)
         sdf = self._internal.spark_frame.select(cond)
+        columns = [cols for cols in sdf.columns if cols.startswith("col")]
+        sdf = sdf.withColumn("combined_cols", F.array(columns)).drop(*columns)
+        sdf = (
+            sdf.select(index_scol, explode("combined_cols").alias("values"))
+            .withColumn("identifier", col("values.identifier"))
+            .withColumn("value", col("values.Koalas"))
+            .drop("values")
+            .na.drop(subset="value")

Review comment:
       Thx for the comment , i'll do the same




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