-
Notifications
You must be signed in to change notification settings - Fork 72
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
feat: support new IntervalCompound and IntervalDay update #288
Conversation
…sion BREAKING CHANGE: IntervalDay now has "subsecond" and "precision" fields instead of "microseconds". Old protobufs should be still read correctly.
@vbarua @jacques-n even with the fixed functions_datetime.yml (see substrait-io/substrait#687), substrait-java fails to read the extensions, caused by the additions to
so coming from
|
Running this locally, the substrait-java/core/src/main/java/io/substrait/type/parser/ParseToPojo.java Lines 222 to 238 in d625648
as you pointed out.
It think this logic is too strict and we should make it looser. @jacques-n what do you think? |
long milliseconds = | ||
expr.precision() > 3 | ||
? (expr.subseconds() / (int) Math.pow(10, expr.precision() - 3)) | ||
: (expr.subseconds() * (int) Math.pow(10, 3 - expr.precision())); |
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.
These two branches produce the same number don't they?
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.
Yes, but with integer operations
@vbarua @Blizzara to continue the discussion....
I'm really keen we get this PR merged so that we can move forward with other features that require the latest protobuf additions. I'm not sure what the 'proper' fix is for this, but perhaps we do an interim fix that passes the tests and defer the proper fix to a later PR? The following solution worked for me: Feel free to cherrypick this commit for this PR, if you wish. Thanks! |
core/src/main/java/io/substrait/type/proto/ProtoTypeConverter.java
Outdated
Show resolved
Hide resolved
typeToMatch.isInstanceOf[Type.IntervalDay] || typeToMatch.isInstanceOf[ParameterizedType.IntervalDay] | ||
|
||
override def visit(`type`: Type.IntervalCompound): Boolean = | ||
typeToMatch.isInstanceOf[Type.IntervalCompound] || typeToMatch.isInstanceOf[ParameterizedType.IntervalCompound] |
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.
meta: I wonder if we can't just re-use the Java visitor here. Not for this PR though.
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.
Yeaah frankly I'm overall not a huge fan of the way this lib works, there feels to be too much hand-rolled replication of the proto classes. I guess the reason is the proto classes are not very ergonomic to work with, but then it leads to these manual boilerplate things where there's a high risk of bugs and missing features..
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.
I agree that the manual boilerplate transformations are easy to screw up, but the improved ergonomics for building and working with plans outweigh that for me. There's a lot of transformations we perform over substrait trees that I think would be significantly harder over the generated protobuf. I actually find myself missing the niceness of the Java POJOs in other language.
I think the changes @andrew-coleman proposed in #288 (comment) seem like a good fix for the test failures. Aside from that, there's one piece of handling that is wrong in the ProtoTypeConverter that I I think we should address as well. |
Signed-off-by: Andrew Coleman <andrew_coleman@uk.ibm.com>
2807c2b
to
c13dddd
Compare
I pulled those in (thanks @andrew-coleman !). However I'm not sure if they do the right thing - I guess they make the "0" treated as a parameter name, like "P" or "S" would be? Not sure, maybe there is something later on that turns the number-string into a proper number. Anyways it does make the tests pass so I'm fine with it to unblock this PR 🤷
Thanks, fixed! |
Agreed |
…strait-io#288) BREAKING CHANGE: IntervalDay now has "subsecond" and "precision" fields instead of "microseconds". Old protobufs should be still read correctly.
Bumps substrait to latest to get substrait-io/substrait#665 and addresses the breaks, adding IntervalCompound type and literal and adapting IntervalDay type and literal to have precision. For IntervalDay, backwards-compatibility is provided for reading existing protobufs using microseconds, but not for generating new protobufs, ie new plans will always use precision and subseconds.
Requires substrait-io/substrait#687 ✅
CSV support from substrait-io/substrait#646 is not implemented yet