-
Notifications
You must be signed in to change notification settings - Fork 708
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
Add Option[T] support for primitives + string in case class macros #1133
Comments
If we add Option[T], we need to make the Fields macro return AnyRef for the type and do all the parsing of it ourselves. The issue is that if we say it is a T, if T is a Number, Cascading will treat null like 0, so by the time we see our Tuple, the information is lost (see LongCoerce.java) which is used in cascading when Fields have a Long type attached. |
How would you get to the situation of mixed nulls / non-nulls? |
suppose you defined a schema with case classes, but something else writes it (pig, export from some other system). I think this should just be an error and the fact is the scheme is wrong here. It is possible we would allow a mode where we a loose and log to warning when we see a nonsensical output. |
Also, when I said do all the parsing ourselves, it is as easy as this: if (tup.getObject(idx) == null) None
else tup.getInt(idx) // cascading parses strings here, dubious idea, but true |
I see. Yeah I'd go with throw a runtime exception if the expectation about the schema is not met |
@ianoc this is closed now, right? |
Yep, i believe so. |
In #1131 we could use null to represent None.
This is trickier for Options of case classes. On the Setter side, that is no problem. On the Converter side it is not clear what to do if you get some nulls and some non-nulls. You could:
I can actually see the merit in going with 2. Cascading tuples are already not typesafe, and they can throw exceptions at runtime. So, allowing more expressivity which in the usual operation cannot fail might be a good idea.
The text was updated successfully, but these errors were encountered: