You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "koert kuipers (Jira)" <ji...@apache.org> on 2021/04/14 21:47:00 UTC

[jira] [Created] (SPARK-35079) Transform with udf gives incorrect result

koert kuipers created SPARK-35079:
-------------------------------------

             Summary: Transform with udf gives incorrect result
                 Key: SPARK-35079
                 URL: https://issues.apache.org/jira/browse/SPARK-35079
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 3.1.1
            Reporter: koert kuipers


i think this is a correctness bug in spark 3.1.1

the behavior is correct in spark 3.0.1

in spark 3.0.1:
{code:java}
scala> import spark.implicits._

scala> import org.apache.spark.sql.functions._

scala> val x = Seq(Seq("11", "22", "33")).toDF
x: org.apache.spark.sql.DataFrame = [value: array<string>]

scala> x.select(transform(col("value"), col => udf((_: String).drop(1)).apply(col))).show
+---------------------------------------------------+
|transform(value, lambdafunction(UDF(lambda 'x), x))|
+---------------------------------------------------+
|                                          [1, 2, 3]|
+---------------------------------------------------+
{code}
in spark 3.1.1:
{code:java}
scala> import spark.implicits._

scala> import org.apache.spark.sql.functions._

scala> val x = Seq(Seq("11", "22", "33")).toDF
x: org.apache.spark.sql.DataFrame = [value: array<string>]

scala> x.select(transform(col("value"), col => udf((_: String).drop(1)).apply(col))).show
+---------------------------------------------------+
|transform(value, lambdafunction(UDF(lambda 'x), x))|
+---------------------------------------------------+
|                                          [3, 3, 3]|
+---------------------------------------------------+
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org