GitHub user aa8y opened a pull request: https://github.com/apache/spark/pull/12587
[SPARK-11962] (Not merge ready) Added functions `attempt` and `getOption`. ## What changes were proposed in this pull request? Add methods to get `Try` and `Option` types from a `Row`. The code is *not merge ready*. But I was not sure how I could get feedback without a PR. I've added two major methods to Row, `attempt` and `getOption`. The former returns a `Try` while the latter returns an `Option`. * `attempt` was added after a comment was made in PR #10247, where it was suggested I not return None when certain exceptions are thrown. But in my opinion, throwing exceptions from a function which returns an `Option` is not a good use case. * I am not in love with the name `attempt`. Would welcome suggestions. I wanted to use `try` but it's a keyword. * In `RowTest`, the tests testing for `ClassCastException` fail. I am not sure what I am doing wrong in the code here. Would appreciate feedback. ## How was this patch tested? Tests have been added to `RowTest` to test the newly added methods. You can merge this pull request into a Git repository by running: $ git pull https://github.com/aa8y/spark master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/spark/pull/12587.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 #12587 ---- commit 4348492a2d8627869ca7a88fbca0d0e7ee835921 Author: Arun Allamsetty <a...@instructure.com> Date: 2016-04-21T19:14:33Z [SPARK-11962] Add optional get methods to Row. commit 2731613cd6b58051b80d8d035e57282b2ce0257c Author: Arun Allamsetty <a...@instructure.com> Date: 2016-04-21T23:34:00Z [SPARK-11962] (Not merge ready, see commit message) Added functions `attempt` and `getOption`. The code is not merge ready. But I was not sure how I could get feedback without a PR. I've added two major methods to Row, `attempt` and `getOption`. The former returns a Try while the latter returns an Option. - `attempt` was added after a comment was made in PR #10247, where it was suggested I not return None when certain exceptions are thrown. But in my opinion, throwing exceptions from a function which returns an Option is not a good use case. - I am not in love with the name `attempt`. Would welcome suggestions. I wanted to use `try` but it's a keyword. - In `RowTest`, the tests testing for `ClassCastException` fail. I am not sure what I am doing wrong in the code here. Would appreciate feedback. ---- --- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org