GitHub user aa8y opened a pull request:
https://github.com/apache/spark/pull/12708
[SPARK-11962] WIP: Added `attempt` and `getOption`.
## What changes were proposed in this pull request?
This PR adds two major methods to Row, `attempt` and `getOption`. The
former returns a `Try` while the latter returns an `Option`. The end use case
for both `attempt` and `getOption` is to get values out of a row object without
throwing an exception. However, in one of my previous PRs, #10247 (which didn't
have an `attempt` method), it was pointed out by @marmbrus that the `getOption`
method caught exceptions and converted them to `None`s. His point of view was
that exceptions should not be automatically handled internally as that hid
important information. But since the whole reason of `getOption` was to *not*
throw exceptions, I introduced the `attempt` method which returns `Success` and
`Failure` objects, which do not lose information and `getOption`, which does
and returns a `Some` or `None` but loses the information.
## How was this patch tested?
I've written extensive unit tests to test the features. The tests testing
for `ClassCastException` do not pass though looking at the code, I cannot tell
why. Would appreciate some feedback if anyone has insights. Also I think
`attempt` might not be the best method name. So I am open to suggestions. Also,
I am closing PR #12587 and creating this because it was pointing to `master`
and not inconvenient to work with.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/aa8y/spark optional
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/12708.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #12708
----
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]