Skip to content

Commit

Permalink
chore: minor refactor for proto files
Browse files Browse the repository at this point in the history
  • Loading branch information
jvanstraten committed Sep 12, 2022
1 parent 2ed9757 commit 595bd39
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 82 deletions.
81 changes: 25 additions & 56 deletions proto/substrait/validator/simple_extensions.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand All @@ -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.
Expand All @@ -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;

Expand Down Expand Up @@ -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 {
Expand All @@ -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.
Expand All @@ -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.
Expand Down
12 changes: 2 additions & 10 deletions proto/substrait/validator/tree.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -86,8 +86,6 @@ message Node {

// Semantic classification of this node.
Class class = 13;

// Semantic classification of a node.
enum Class {
CLASS_UNSPECIFIED = 0;

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
28 changes: 12 additions & 16 deletions proto/substrait/validator/type_system.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 595bd39

Please sign in to comment.