Skip to content

Commit

Permalink
Add support for alternative argument type support in the protobuf rep…
Browse files Browse the repository at this point in the history
…resentation (type and option arguments) (#161)

* feat: support type function arguments in protobuf

Type arguments can now be passed to functions. This modifies the
structure for specifying function arguments in general, deprecating
the old structure.

Co-authored-by: Jacques Nadeau <jacquesnadeau@gmail.com>
  • Loading branch information
jvanstraten and jacques-n authored May 20, 2022
1 parent 8e206b9 commit df98816
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions proto/substrait/algebra.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ syntax = "proto3";
package substrait;

import "google/protobuf/any.proto";
import "google/protobuf/empty.proto";
import "substrait/extensions/extensions.proto";
import "substrait/type.proto";

Expand Down Expand Up @@ -320,6 +321,21 @@ message Rel {
}
}

message FunctionArgument {
oneof arg_type {
Enum enum = 1;
Type type = 2;
Expression value = 3;
}

message Enum {
oneof enum_kind {
string specified = 1;
google.protobuf.Empty unspecified = 2;
}
}
}

message Expression {
oneof rex_type {
Literal literal = 1;
Expand All @@ -330,18 +346,26 @@ message Expression {
SwitchExpression switch_expression = 7;
SingularOrList singular_or_list = 8;
MultiOrList multi_or_list = 9;
Enum enum = 10;
Cast cast = 11;
Subquery subquery = 12;

// deprecated: enum literals are only sensible in the context of
// function arguments, for which FunctionArgument should now be
// used
Enum enum = 10 [deprecated = true];
}

message Enum {
option deprecated = true;

oneof enum_kind {
string specified = 1;
Empty unspecified = 2;
}

message Empty {}
message Empty {
option deprecated = true;
}
}

message Literal {
Expand Down Expand Up @@ -448,8 +472,11 @@ message Expression {
message ScalarFunction {
// points to a function_anchor defined in this plan
uint32 function_reference = 1;
repeated Expression args = 2;
repeated FunctionArgument arguments = 4;
Type output_type = 3;

// deprecated; use args instead
repeated Expression args = 2 [deprecated = true];
}

message WindowFunction {
Expand All @@ -461,7 +488,10 @@ message Expression {
Bound lower_bound = 5;
AggregationPhase phase = 6;
Type output_type = 7;
repeated Expression args = 8;
repeated FunctionArgument arguments = 9;

// deprecated; use args instead
repeated Expression args = 8 [deprecated = true];

message Bound {
message Preceding {
Expand Down Expand Up @@ -798,13 +828,15 @@ enum AggregationPhase {
message AggregateFunction {
// points to a function_anchor defined in this plan
uint32 function_reference = 1;
repeated Expression args = 2;
repeated FunctionArgument arguments = 7;
repeated SortField sorts = 3;
AggregationPhase phase = 4;
Type output_type = 5;

AggregationInvocation invocation = 6;

// deprecated; use args instead
repeated Expression args = 2 [deprecated = true];

enum AggregationInvocation {
AGGREGATION_INVOCATION_UNSPECIFIED = 0;

Expand Down

0 comments on commit df98816

Please sign in to comment.