Conversation
|
ACTION NEEDED Substrait follows the Conventional Commits The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification. |
bd62615 to
d0cc543
Compare
d0cc543 to
6c079f0
Compare
Signed-off-by: MBWhite <whitemat@uk.ibm.com>
8618365 to
434df46
Compare
Signed-off-by: MBWhite <whitemat@uk.ibm.com>
434df46 to
83fa865
Compare
56aaa2a to
5bdace0
Compare
Signed-off-by: MBWhite <whitemat@uk.ibm.com>
5bdace0 to
ef5e526
Compare
benbellick
left a comment
There was a problem hiding this comment.
Just a few comments. Thanks!
|
@benbellick updated as suggested :-) |
efabd93 to
fe68836
Compare
Signed-off-by: MBWhite <whitemat@uk.ibm.com>
fe68836 to
1ca14b2
Compare
|
@benbellick since you started this review, do you have time for another look? |
benbellick
left a comment
There was a problem hiding this comment.
Left a few more comments. Thanks!
| * @param expression the boolean expression to negate | ||
| * @return a scalar function invocation representing the logical NOT of the input expression | ||
| */ | ||
| public Expression not(Expression expression) { |
There was a problem hiding this comment.
Slightly relevant issue I just found FYI substrait-io/substrait#1041
There was a problem hiding this comment.
Also and and or above return Expression.ScalarFunctionInvocation, but this one returns the more general Expression. Can we return Expression.ScalarFunctionInvocation to be consistent?
There was a problem hiding this comment.
Also the nullability should be assumed to be MIRROR rather than DECLARED_OUTPUT to be consistent with and and or above. So I think we should check nullability here and only mark the output as nullable if the input is.
| public Expression scalarFn( | ||
| String urn, | ||
| String key, | ||
| Type returnType, |
There was a problem hiding this comment.
Thinking out loud here, but does this builder validate that the returnType is actually possible for this function?
| } | ||
|
|
||
| /** | ||
| * Creates a scalar function invocation with function options. |
There was a problem hiding this comment.
This says
with function options
but only the above method accepts options AFAICT via optionsList, and this one does not. Maybe we just get rid of this whole one to keep things simple?
| * @return a new {@link Plan} | ||
| */ | ||
| public Plan.Root root(final Rel input, final List<String> names) { | ||
| return Plan.Root.builder().input(input).names(names).build(); |
There was a problem hiding this comment.
Also curious if this one validates that the length of names matches the schema of input.
| final Expression.I32Literal input = builder.i32(1); | ||
| final Expression cast = builder.cast(input, R.I64); | ||
| assertNotNull(cast); | ||
| assertTrue(cast instanceof Expression.Cast); |
There was a problem hiding this comment.
Might be better to actually check that the type of this expression is now R.I64.
| DefaultExtensionCatalog.FUNCTIONS_COMPARISON, | ||
| "is_null:any", | ||
| TypeCreator.REQUIRED.BOOLEAN, | ||
| args, |
There was a problem hiding this comment.
nit: could just simplify this to the below and drop the above construction of an ArrayList
| args, | |
| List.of(expression), |
| * @param input the root relational expression of the query plan | ||
| * @param names the ordered list of output column names corresponding to the input relation's | ||
| * output schema | ||
| * @return a new {@link Plan} |
There was a problem hiding this comment.
| * @return a new {@link Plan} | |
| * @return a new {@link Plan.root} |
|
|
||
| final AggregateFunctionInvocation afi1 = | ||
| builder.aggregateFn( | ||
| "extension:io.substrait:functions_aggregate_generic", |
There was a problem hiding this comment.
nit:
| "extension:io.substrait:functions_aggregate_generic", | |
| DefaultExtensionCatalog.FUNCTIONS_AGGREGATE_GENERIC, |
| Fetch limit = builder.limit(10, scan); | ||
| assertEquals(10, limit.getCount().getAsLong()); | ||
| assertEquals(0, limit.getOffset()); | ||
| limit = builder.limit(10, Remap.of(Arrays.asList(new Integer[] {0, 1})), scan); |
There was a problem hiding this comment.
nit:
| limit = builder.limit(10, Remap.of(Arrays.asList(new Integer[] {0, 1})), scan); | |
| limit = builder.limit(10, Remap.of(List.of(0, 1)), scan); |
| * @param value value to create | ||
| * @return i64 instance | ||
| */ | ||
| public Expression.I64Literal i64(long value) { |
There was a problem hiding this comment.
nit: all of the other existing methods use v for the parameter name. Should we do the same for all of the new ones to be consistent?
Follow on to pr #767 to fill some missing gaps in the substrait builder. We've recently used the Substrait Builder and found that there some variants and missing gaps in the APIs. We'd subclassed it to add these, so I'm now wanting to push these to the main codebase.
There wasn't a unit test already so I've added a basic one here - which I appreciate will is quite large.