-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-23918][SQL] Add array_min function #21025
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
Conversation
python/pyspark/sql/functions.py
Outdated
| >>> df = spark.createDataFrame([([2, 1, 3],), ([None, 10, -1],)], ['data']) | ||
| >>> df.select(array_min(df.data).alias('min')).collect() | ||
| [Row(min=1), Row(min=-1)] | ||
| """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quick nit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I can't see what is the problem here. May you please clarify? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
""" seems having one more leading space ..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right, good catch! I was looking for reference at the sort_array function below which has the same issue. I will fix it there too, thanks.
| Examples: | ||
| > SELECT _FUNC_(array(1, 20, null, 3)); | ||
| 1 | ||
| """, since = "2.4.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation ..
|
Test build #89113 has finished for PR 21025 at commit
|
|
cc @ueshin |
|
Test build #89121 has finished for PR 21025 at commit
|
|
Test build #89125 has finished for PR 21025 at commit
|
|
retest this please |
|
Test build #89140 has finished for PR 21025 at commit
|
| override def nullable: Boolean = | ||
| child.nullable || child.dataType.asInstanceOf[ArrayType].containsNull | ||
|
|
||
| override def foldable: Boolean = child.foldable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already specified in UnaryExpression
|
Test build #89247 has finished for PR 21025 at commit
|
|
Test build #89251 has finished for PR 21025 at commit
|
|
retest this please |
|
Test build #89260 has finished for PR 21025 at commit
|
|
Test build #89270 has finished for PR 21025 at commit
|
|
LGTM. |
| * Returns the minimum value in the array. | ||
| */ | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(array) - Returns the minimum value in the array.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will ignore NULL, right? Please document it.
|
Test build #89328 has finished for PR 21025 at commit
|
|
@mgaido91 Could you address the conflicts? Thanks! |
|
Test build #89386 has finished for PR 21025 at commit
|
|
Test build #89385 has finished for PR 21025 at commit
|
|
The build for the latest commit is 89386 and successfully finished. |
What changes were proposed in this pull request?
The PR adds the SQL function
array_min. It takes an array as argument and returns the minimum value in it.How was this patch tested?
added UTs