HyukjinKwon commented on a change in pull request #24605: [SPARK-27711][CORE] 
Unset InputFileBlockHolder at the end of tasks
URL: https://github.com/apache/spark/pull/24605#discussion_r284070990
 
 

 ##########
 File path: python/pyspark/sql/tests/test_functions.py
 ##########
 @@ -278,6 +279,22 @@ def test_sort_with_nulls_order(self):
             
df.select(df.name).orderBy(functions.desc_nulls_last('name')).collect(),
             [Row(name=u'Tom'), Row(name=u'Alice'), Row(name=None)])
 
+    def test_input_file_name_reset_for_rdd(self):
+        from pyspark.sql.functions import udf, input_file_name
+        rdd = 
self.sc.textFile('python/test_support/hello/hello.txt').map(lambda x: {'data': 
x})
+        df = self.spark.createDataFrame(rdd, StructType([StructField('data', 
StringType(), True)]))
+        df.select(input_file_name().alias('file')).collect()
+
+        non_file_df = self.spark.range(0, 100, 1, 
100).select(input_file_name().alias('file'))
+
+        results = non_file_df.collect()
+        self.assertTrue(len(results) == 100)
+
+        # [SC-12160]: if everything was properly reset after the last job, 
this should return
+        # empty string rather than the file read in the last job.
+        for result in results:
+            assert(result[0] == '')
 
 Review comment:
   we can stick to `self.assertEqual` for a better message.

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to