From 595bd390680bc979ac06f55b38dc90a0be18eae9 Mon Sep 17 00:00:00 2001 From: Jeroen van Straten Date: Mon, 12 Sep 2022 12:26:32 +0200 Subject: [PATCH] chore: minor refactor for proto files --- .../validator/simple_extensions.proto | 81 ++++++------------- proto/substrait/validator/tree.proto | 12 +-- proto/substrait/validator/type_system.proto | 28 +++---- 3 files changed, 39 insertions(+), 82 deletions(-) diff --git a/proto/substrait/validator/simple_extensions.proto b/proto/substrait/validator/simple_extensions.proto index e45d86d3..dd21528b 100644 --- a/proto/substrait/validator/simple_extensions.proto +++ b/proto/substrait/validator/simple_extensions.proto @@ -70,23 +70,20 @@ message ExtensionDefinition { // definitions. Module module = 4; - // Represents a user-defined simple type class. - SimpleTypeClass simple_type_class = 5; - - // Represents a user-defined compound type class. - CompoundTypeClass compound_type_class = 6; + // Represents a user-defined type class. + TypeClass type_class = 5; // Represents a user-defined type variation. - TypeVariation type_variation = 7; + TypeVariation type_variation = 6; // Represents a user-defined scalar function. - ScalarFunction scalar_function = 8; + ScalarFunction scalar_function = 7; // Represents a user-defined aggregate function. - AggregateFunction aggregate_function = 9; + AggregateFunction aggregate_function = 8; // Represents a user-defined window function. - WindowFunction window_function = 10; + WindowFunction window_function = 9; } // Data associated with an extension module definition. @@ -100,10 +97,6 @@ message ExtensionDefinition { // List of immediate dependencies. repeated Dependency dependencies = 3; - - // List of references to all extensions publicly defined by this module. - repeated int64 extension_ids = 4; - message Dependency { // URI of the dependency. string uri = 1; @@ -115,50 +108,27 @@ message ExtensionDefinition { // resolved by the validator. int64 extension_id = 3; } - } - - // Data associated with a simple type class. - message SimpleTypeClass { - // Optional description of the class. Only serves as documentation. - string description = 1; - // Optional structure of the type. If no elements are specified, the type - // is opaque. - repeated Field structure = 2; - - message Field { - // Name of the field. - string name = 1; - - // Data type of the field. - DataType data_type = 2; - } + // List of references to all extensions publicly defined by this module. + repeated int64 extension_ids = 4; } - // Data associated with a simple type class. - message CompoundTypeClass { + // Data associated with a type class. + message TypeClass { // Optional description of the class. Only serves as documentation. string description = 1; - // Set of parameters expected by the type class. + // Set of parameters expected by the type class. If unspecified or empty, + // the type class is a simple type. Otherwise, it is a compound type. // // The structure is shared with function arguments because it is very // similar. Note however that type classes can only accept generics as // value types. Pack parameters = 2; - // Optional structure of the type. If no elements are specified, the type - // is opaque. - repeated Field structure = 3; - message Field { - // Name of the field. - string name = 1; - - // Data type of the field, derived by means of a metapattern evaluated in - // the same context in which the parameter patterns and constraints were - // matched and evaluated. - Metapattern data_type = 2; - } + // Optional pattern for the type representing the structure of the class. + // If not specified, the type class is opaque. + Metapattern structure = 3; } // Data associated with a type variation. @@ -179,32 +149,32 @@ message ExtensionDefinition { // Data associated with a scalar function. message ScalarFunction { // Properties common to all functions. - CommonProperties common_properties = 1; + CommonFunctionProperties common = 1; } // Data associated with an aggregate function. message AggregateFunction { // Properties common to all functions. - CommonProperties common_properties = 1; + CommonFunctionProperties common = 1; // Properties common to both aggregate and window functions. - AggregateProperties aggregate_properties = 2; + AggregateFunctionProperties aggregate = 2; } // Data associated with a window function. message WindowFunction { // Properties common to all functions. - CommonProperties common_properties = 1; + CommonFunctionProperties common = 1; // Properties common to both aggregate and window functions. - AggregateProperties aggregate_properties = 2; + AggregateFunctionProperties aggregate = 2; // Properties specific to window functions. - WindowProperties window_properties = 3; + WindowFunctionProperties window = 3; } // Properties common to all function types. - message CommonProperties { + message CommonFunctionProperties { // Optional description of the variation. Only serves as documentation. string description = 1; @@ -248,7 +218,7 @@ message ExtensionDefinition { } // Properties common to aggregate and window functions. - message AggregateProperties { + message AggregateFunctionProperties { // When specified, the function is decomposable. Decomposability decomposability = 1; message Decomposability { @@ -275,7 +245,7 @@ message ExtensionDefinition { } // Properties applicable only to window functions. - message WindowProperties { + message WindowFunctionProperties { // If set, the window function can be computed in streaming fashion. If not // set, the window function can only start working when the complete input // is available. @@ -299,8 +269,7 @@ message ExtensionDefinition { // - For decomposable aggregate/window functions, evaluate the intermediate // type pattern. // - For functions, evaluate the return type pattern. - // - For user-defined compound type classes, evaluate the structure patterns - // from left to right. + // - For user-defined compound type classes, evaluate the structure pattern. // // If any match or evaluation operation fails, the provided pack is // considered to be incompatible with the function or type class. diff --git a/proto/substrait/validator/tree.proto b/proto/substrait/validator/tree.proto index 98778315..57af9c37 100644 --- a/proto/substrait/validator/tree.proto +++ b/proto/substrait/validator/tree.proto @@ -9,8 +9,8 @@ package substrait.validator; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; -import "substrait/validator/type_system.proto"; import "substrait/validator/simple_extensions.proto"; +import "substrait/validator/type_system.proto"; option csharp_namespace = "Substrait.Validator.Protobuf"; option java_multiple_files = true; @@ -86,8 +86,6 @@ message Node { // Semantic classification of this node. Class class = 13; - - // Semantic classification of a node. enum Class { CLASS_UNSPECIFIED = 0; @@ -121,12 +119,10 @@ message Node { // that don't have a logical Substrait type. DataType data_type = 16; - // Data associated with this node. - repeated Data data = 31; - // Data associated with the node. Note that some variants are illegal based // on the node type (for example, a primitive does not have fields, so it // makes no sense for Field data to appear). + repeated Data data = 31; message Data { oneof kind { // Represents a child node in the tree. @@ -224,8 +220,6 @@ message Path { // Elements of the path. The first element selects a child node of the root // node, the second selects one of its children, etc. repeated Element elements = 2; - - // Path element structure. message Element { oneof kind { Field field = 1; @@ -310,8 +304,6 @@ message Comment { // Comments consist of one or more "elements," defining formatting // information. repeated Element elements = 1; - - // A comment element. message Element { oneof kind { // A span of text. diff --git a/proto/substrait/validator/type_system.proto b/proto/substrait/validator/type_system.proto index 093d3ecc..dd50f447 100644 --- a/proto/substrait/validator/type_system.proto +++ b/proto/substrait/validator/type_system.proto @@ -19,21 +19,6 @@ option java_package = "io.substrait.validator.proto"; message DataType { // Type class. Class class = 1; - - // Nullability. - bool nullable = 8; - - // Type variation. - oneof variation { - google.protobuf.Empty system_preferred_variation = 10; - UserDefinedVariation user_defined_variation = 9; - google.protobuf.Empty unresolved_variation = 15; - } - - // Type parameters for non-simple types. - repeated Parameter parameters = 16; - - // A type class. message Class { oneof kind { Simple simple = 1; @@ -112,6 +97,16 @@ message DataType { } } + // Nullability. + bool nullable = 8; + + // Type variation. + oneof variation { + google.protobuf.Empty system_preferred_variation = 10; + UserDefinedVariation user_defined_variation = 9; + google.protobuf.Empty unresolved_variation = 15; + } + // Information about a type variation. message UserDefinedVariation { // URI of the YAML file that the type variation is (supposed to be) defined @@ -149,7 +144,8 @@ message DataType { } } - // Type parameter. + // Type parameters for non-simple types. + repeated Parameter parameters = 16; message Parameter { // Optional name given to the parameter (currently used only for NSTRUCT). string name = 10;