-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-6994]Add helper methods to access by field #5754
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
This is a trial change, is useful in java (because java developer can't benefit from getAs[T] method).
|
Why can't Java user use getAs[T]? |
|
@szheng79 this has nothing to do with SPARK-6994 |
|
@rxin I just think it is best for a java developer has more specific way to control the return type. Like current there is these version of methods to access row by index. Because I move my code base from getString(int) like method, so it is a bit lazy for me to change everywhere. So I think if I need to have these helper method, I just add them to the code, so make it consistent with current method style. Simply use getAs method can't give direct result type to compiler, so sometimes it will enforce class cast (in java) to tell what it the result type: For example: I just realize this is same case in scala? Is it the reason why so many getTYPE(int index) method there? But I have no preference on whether we must have this. If here people think we better don't have these, I will delete the pull request :). And to me, if we don't have these, I will say we better only keep getAs(int) and getAs(String), instead of only have getString(int index) like method without similar getString(String fieldName) |
|
@srowen I say it is with SPARK-6994, because the implementation must based on SPARK-6994 change. And because this is a very minor change, I don't want to hijack other people's credit. So I just put it under 6994 |
|
That's my fault. I typed the wrong JIRA. Yes it is related. |
|
P.S. I'd say String s = row.getAs(1);Anyway, one advantage of having dozen of methods for primitive types is to avoid boxing. In scala, so looks 🆗 to me. |
|
@szheng79 please add to this PR the updated Spark-SQL docs for Java from this branch: https://github.com/apache/spark/compare/master...vidma:docs/row-with-named-fields-java?expand=1 |
|
ok to test |
|
Test build #34744 has finished for PR 5754 at commit
|
|
@szheng79 do you mind bringing this up to date? I think we can merge this then. Thanks. |
|
Can one of the admins verify this patch? |
|
ping @szheng79 can you rebase to master? |
|
I'm going to close this pull request. If this is still relevant and you are interested in pushing it forward, please open a new pull request. Thanks! |
This is a trial change, is useful in java (because java developer can't benefit from getAs[T] method).