Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Merge from apache/spark #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Merge from apache/spark #1
Changes from 1 commit
86db9b2ea2642ef6084a8aeb45df1219d7a0bf1a74fba031333ae24312d20ddbe03d3a0e68330eb386beff48b1b9348e6891d1b306674acdb8bfce5774715d753793b568398432ec269171f6ddded6d2776e8a1d1eebfbe755f2f528778175536f318f6d5739c21ece613b71acfcd746ffe6fd7c745730796e48c67ea11ed4f0b1d224375ccc30ef8fcf66a3dbd492b11a849b8b497044e9e6aeafc364166a7d6bccda75b30fcdc081696302ea17aff2b352514c4a62234d943fd7d141ea0a5eeee3af15cfbe11e3d8837e028ee405955a2d994065df5b77147a702d8c284c4e1c9f95ce734a4be0c090fa6fc300247a0891a87a16a66fe369a2b65ab2970297d045c5df95a909fa703ed5861ab5aadbc96f6831693f92c0d2cddc895f9659e288fc80428368df7fc3e52fc5c1cf0aa656cff7d151c33bdc0b7424930b90aea95683e8af7e8bf65cd3f2dd8b9be9a8047b78041993f2159a7048b18e9414File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
## What changes were proposed in this pull request? In SPARK-20586 the flag `deterministic` was added to Scala UDF, but it is not available for python UDF. This flag is useful for cases when the UDF's code can return different result with the same input. Due to optimization, duplicate invocations may be eliminated or the function may even be invoked more times than it is present in the query. This can lead to unexpected behavior. This PR adds the deterministic flag, via the `asNondeterministic` method, to let the user mark the function as non-deterministic and therefore avoid the optimizations which might lead to strange behaviors. ## How was this patch tested? Manual tests: ``` >>> from pyspark.sql.functions import * >>> from pyspark.sql.types import * >>> df_br = spark.createDataFrame([{'name': 'hello'}]) >>> import random >>> udf_random_col = udf(lambda: int(100*random.random()), IntegerType()).asNondeterministic() >>> df_br = df_br.withColumn('RAND', udf_random_col()) >>> random.seed(1234) >>> udf_add_ten = udf(lambda rand: rand + 10, IntegerType()) >>> df_br.withColumn('RAND_PLUS_TEN', udf_add_ten('RAND')).show() +-----+----+-------------+ | name|RAND|RAND_PLUS_TEN| +-----+----+-------------+ |hello| 3| 13| +-----+----+-------------+ ``` Author: Marco Gaido <[email protected]> Author: Marco Gaido <[email protected]> Closes apache#19929 from mgaido91/SPARK-22629.Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing