Skip to content

Conversation

@mgaido91
Copy link
Contributor

@mgaido91 mgaido91 commented Mar 5, 2018

What changes were proposed in this pull request?

The PR adds interpreted execution to UnwrapOption.

How was this patch tested?

added UT

override def eval(input: InternalRow): Any =
throw new UnsupportedOperationException("Only code-generated evaluation is supported")
override def eval(input: InternalRow): Any = {
val inputObject = child.eval(input)
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: you can also use pattern matching here. That saves you some typing:

child.eval(input) match {
  case Some(value) => value
  case _ => null
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for your comment. I haven't used pattern matching because it is a bit slower than using if...else and I'd prefer the fastest way here. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am fine either way. This is going to be slow anyway. Let's leave as it is.

mapEncoder.serializer.head, mapExpected, mapInputRow)
}

test("SPARK-23586: UnwrapOption should support interpreted execution") {
Copy link
Contributor

Choose a reason for hiding this comment

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

I just found out that there are literally no unit tests for this expression :(...

Can you use checkEvaluation? This will make sure both code gen and interpreted mode are tested?

@hvanhovell
Copy link
Contributor

@mgaido91 you picked this up phenomenally fast! It looks pretty good, let two minor comments.

@mgaido91
Copy link
Contributor Author

mgaido91 commented Mar 5, 2018

@hvanhovell thanks for your comments, let's say this is a good opportunity to improve test coverage too for it

@hvanhovell
Copy link
Contributor

LGTM - pending jenkins

@mgaido91 mgaido91 changed the title [SPARK-23586][SQL] Add interpreted execution to UnwrapOption [SPARK-23585][SQL] Add interpreted execution to UnwrapOption Mar 5, 2018
@SparkQA
Copy link

SparkQA commented Mar 5, 2018

Test build #87957 has finished for PR 20736 at commit 804394b.

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

@SparkQA
Copy link

SparkQA commented Mar 5, 2018

Test build #87961 has finished for PR 20736 at commit d899f44.

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

@SparkQA
Copy link

SparkQA commented Mar 5, 2018

Test build #87963 has finished for PR 20736 at commit fc202c6.

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

@hvanhovell
Copy link
Contributor

Merging to master. Thanks!

@asfgit asfgit closed this in ba622f4 Mar 5, 2018
mgaido91 added a commit to mgaido91/spark that referenced this pull request Mar 5, 2018
## What changes were proposed in this pull request?

The PR adds interpreted execution to UnwrapOption.

## How was this patch tested?

added UT

Author: Marco Gaido <[email protected]>

Closes apache#20736 from mgaido91/SPARK-23586.
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.

3 participants