Skip to content

Commit 9d2114f

Browse files
gstvggabotechs
authored andcommitted
Add protobuf support for lambdas (apache#22362)
## Which issue does this PR close? Part of apache#21172 ## Rationale for this change Protobuf support wasn't implemented in main lambda PR to not make it even bigger ## What changes are included in this PR? Protobuf encoding and decoding (~1000 LOC in generated files, ~210 impl, ~400 tests) ## Are these changes tested? Unit tests, similar to the existing ones for scalar functions ## Are there any user-facing changes? Proto `ExprType` has new variants
1 parent 4a6f1ba commit 9d2114f

12 files changed

Lines changed: 1630 additions & 194 deletions

File tree

‎datafusion/proto/proto/datafusion.proto‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,10 @@ message LogicalExprNode {
431431

432432
// Subquery expressions
433433
ScalarSubqueryExprNode scalar_subquery_expr = 36;
434+
435+
HigherOrderUDFExprNode higher_order_udf_expr = 37;
436+
Lambda lambda = 38;
437+
LambdaVariable lambda_variable = 39;
434438
}
435439
}
436440

@@ -568,6 +572,22 @@ message ScalarUDFExprNode {
568572
optional bytes fun_definition = 3;
569573
}
570574

575+
message HigherOrderUDFExprNode {
576+
string fun_name = 1;
577+
repeated LogicalExprNode args = 2;
578+
optional bytes fun_definition = 3;
579+
}
580+
581+
message Lambda {
582+
repeated string params = 1;
583+
LogicalExprNode body = 2;
584+
}
585+
586+
message LambdaVariable {
587+
string name = 1;
588+
datafusion_common.Field field = 2;
589+
}
590+
571591
message WindowExprNode {
572592
oneof window_function {
573593
// BuiltInWindowFunction built_in_function = 2;
@@ -937,6 +957,10 @@ message PhysicalExprNode {
937957
PhysicalScalarSubqueryExprNode scalar_subquery = 22;
938958

939959
PhysicalDynamicFilterNode dynamic_filter = 23;
960+
961+
PhysicalHigherOrderUdfNode higher_order_udf = 24;
962+
PhysicalLambdaExprNode lambda = 25;
963+
PhysicalLambdaVariableExprNode lambda_variable = 26;
940964
}
941965
}
942966

@@ -957,6 +981,22 @@ message PhysicalScalarUdfNode {
957981
string return_field_name = 6;
958982
}
959983

984+
message PhysicalHigherOrderUdfNode {
985+
string name = 1;
986+
repeated PhysicalExprNode args = 2;
987+
optional bytes fun_definition = 3;
988+
}
989+
990+
message PhysicalLambdaExprNode {
991+
repeated string params = 1;
992+
PhysicalExprNode body = 2;
993+
}
994+
995+
message PhysicalLambdaVariableExprNode {
996+
uint32 index = 1;
997+
datafusion_common.Field field = 2;
998+
}
999+
9601000
message PhysicalAggregateExprNode {
9611001
oneof AggregateFunction {
9621002
string user_defined_aggr_function = 4;

0 commit comments

Comments
 (0)