peter-toth opened a new pull request #31682:
URL: https://github.com/apache/spark/pull/31682


   ### What changes were proposed in this pull request?
   
   This PR fixes equality check of `Row` and `InternalRow`.
   
   ### Why are the changes needed?
   Otherwise rows containing `[1]` and `[1.0]` would be `true` and this can 
cause nasty issues like in https://issues.apache.org/jira/browse/SPARK-34545 
description:
   
   ```
   >>> from pyspark.sql.functions import udf
   >>> from pyspark.sql.types import *
   >>> 
   >>> def udf1(data_type):
           def u1(e):
               return e[0]
           return udf(u1, data_type)
   >>> 
   >>> df = spark.createDataFrame([((1.0, 1.0), (1, 1))], ['c1', 'c2'])
   >>> 
   >>> df = df.withColumn("c3", udf1(DoubleType())("c1"))
   >>> df = df.withColumn("c4", udf1(IntegerType())("c2"))
   >>> 
   >>> df.select("c3").show()
   +---+
   | c3|
   +---+
   |1.0|
   +---+
   
   >>> df.select("c4").show()
   +---+
   | c4|
   +---+
   |  1|
   +---+
   
   >>> df.select("c3", "c4").show()
   +---+----+
   | c3|  c4|
   +---+----+
   |1.0|null|
   +---+----+
   ```
   This is due to `Pickler` in `BatchEvalPythonExec` uses memoization.
   
   ### Does this PR introduce _any_ user-facing change?
   Yes, fixes a correctness issue.
   
   ### How was this patch tested?
   Added new UT + manual tests.
   


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

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