Skip to content
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

[SPARK-25068][SQL] Add exists function. #22052

Closed
wants to merge 2 commits into from

Conversation

ueshin
Copy link
Member

@ueshin ueshin commented Aug 9, 2018

What changes were proposed in this pull request?

This pr adds exists function which tests whether a predicate holds for one or more elements in the array.

> SELECT exists(array(1, 2, 3), x -> x % 2 == 0);
 true

How was this patch tested?

Added tests.

@ueshin
Copy link
Member Author

ueshin commented Aug 9, 2018

cc @hvanhovell @gatorsmile

@SparkQA
Copy link

SparkQA commented Aug 9, 2018

Test build #94483 has finished for PR 22052 at commit 9b47b02.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • case class ArrayExists(

while (i < arr.numElements) {
elementVar.value.set(arr.get(i, elementVar.dataType))
if (f.eval(inputRow).asInstanceOf[Boolean]) {
return true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we use a var exists = false to keep the result, and stop the loop when result is true while (i < arr.numElements & !exists)?

IIUC return in Scala is implemented by throwing an exception, which may have performance issue.

@cloud-fan
Copy link
Contributor

LGTM

Copy link
Contributor

@hvanhovell hvanhovell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SparkQA
Copy link

SparkQA commented Aug 9, 2018

Test build #94510 has finished for PR 22052 at commit 85b356e.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Member

@gatorsmile gatorsmile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Merged to master.

@asfgit asfgit closed this in 9b8521e Aug 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants