-
Notifications
You must be signed in to change notification settings - Fork 138
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
Dotted syntax (via lambda) for TypedColumns #449
Conversation
This is really cool :). I am not an expert in macros so please bare with me as I try to do my best to peer review your PR. |
Would it be easy to add few more tests.? I know shapeless has some nice primitives to test negative compilations cases. Let me find that command if you can’t spot it easily. |
Codecov Report
@@ Coverage Diff @@
## master #449 +/- ##
=======================================
Coverage 96.28% 96.28%
=======================================
Files 61 62 +1
Lines 1051 1051
Branches 5 5
=======================================
Hits 1012 1012
Misses 39 39
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Sure. Imho there are two things here which need verification:
Negative case: when the user provides a lambda which does not return a field, a compilation error should be raised |
Added some extra typeChecks to verify that invalid/unsupported lambda's are allowd. Currently the compiler does not throw an Exception on the invalid expression "ds.col(_.a.toInt)" (and not immediately clear how I can fix that) |
See also https://github.com/typelevel/frameless/pull/110/files, in case there's anything useful in there @timvw |
I want to spend more time on this PR this weekend. Apologies for for the delay @timvw! From a very quick glance, it looks really cool. I want to play a bit with it locally and see how it behaves in IntelliJ to see if there is anything I can do/say to help. |
@ayoub-benali Yes. This syntax will simply translate a lambda (_.x.y.z) to a spark "column" expression ("x.y.z") |
The only thing I am still considering is to introduce a case class ParameterPath[T](path: String) type which is returned by the macro (instead of a TypedColumn). This way the creation of a TypedColumn (or anything) can be moved out of the macro.. |
@timvw in your example |
Irrespective of the actual value (None,Some) there is no support for Option types (only primitives). Added a test to verify what happens when you encounter an Option/List/Array/Seq in your lambda path.. Conclusion: It is not possible to further navigate. If you try to do so, the compiler will complain (A good thing imho). -- |
@timvw Just wanted to let you know that I have been warming up with Frameless in the past weeks. Your PR is next on my list. Sorry for this delay. |
Hi @timvw, can you try to update your fork with the current master? I can try to help you rebase and test few things using the latest changes. Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx, looks interesting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now
Allow the user to created
TypedColumn
s via lambda syntax, eg:ds.col(_.a)
ords.col(_.x.y)
.