Skip to content

Commit c851ebc

Browse files
committed
docs: consistently mark 0 as valid anchor/reference
1 parent 84816cd commit c851ebc

File tree

9 files changed

+39
-11
lines changed

9 files changed

+39
-11
lines changed

proto/substrait/algebra.proto

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ message ConsistentPartitionWindowRel {
388388
// sorts, and bounds, since those must be consistent across the various functions in this rel. Refer
389389
// to the `WindowFunction` message for a description of these fields.
390390
message WindowRelFunction {
391+
// References a function_anchor defined in this plan.
392+
// Required; 0 is considered to be a valid anchor/reference.
391393
uint32 function_reference = 1;
392394

393395
repeated FunctionArgument arguments = 9;
@@ -789,6 +791,7 @@ message ComparisonJoinKey {
789791
// collations, where we might want to do something like a case-insensitive comparison.
790792
//
791793
// This must be a binary function with a boolean return type
794+
// Required; 0 is considered to be a valid anchor/reference.
792795
uint32 custom_function_reference = 2;
793796
}
794797
}
@@ -1046,6 +1049,7 @@ message Expression {
10461049
// optionally points to a type_variation_anchor defined in this plan.
10471050
// Applies to all members of union other than the Typed null (which should
10481051
// directly declare the type variation).
1052+
// Required; 0 is considered to be a valid anchor/reference.
10491053
uint32 type_variation_reference = 51;
10501054

10511055
message VarChar {
@@ -1125,9 +1129,11 @@ message Expression {
11251129
message UserDefined {
11261130
oneof type_anchor_type {
11271131
// points to a type_anchor defined in this plan
1132+
// Required; 0 is considered to be a valid anchor/reference.
11281133
uint32 type_reference = 1;
11291134

11301135
// points to a type_alias_anchor defined in this plan.
1136+
// Required; 0 is considered to be a valid anchor/reference.
11311137
uint32 type_alias_reference = 5;
11321138
}
11331139

@@ -1152,6 +1158,7 @@ message Expression {
11521158

11531159
// Optionally points to a type_variation_anchor defined in this plan for
11541160
// the returned nested type.
1161+
// Required; 0 is considered to be a valid anchor/reference.
11551162
uint32 type_variation_reference = 2;
11561163

11571164
oneof nested_type {
@@ -1189,8 +1196,8 @@ message Expression {
11891196
// A scalar function call.
11901197
message ScalarFunction {
11911198
// Points to a function_anchor defined in this plan, which must refer
1192-
// to a scalar function in the associated YAML file. Required; avoid
1193-
// using anchor/reference zero.
1199+
// to a scalar function in the associated YAML file.
1200+
// Required; 0 is considered to be a valid anchor/reference.
11941201
uint32 function_reference = 1;
11951202

11961203
// The arguments to be bound to the function. This must have exactly the
@@ -1649,6 +1656,7 @@ message DynamicParameter {
16491656
Type type = 1;
16501657

16511658
// The surrogate key used within a plan to reference a specific parameter binding.
1659+
// Required; 0 is considered to be a valid anchor/reference.
16521660
uint32 parameter_reference = 2;
16531661
}
16541662

@@ -1658,6 +1666,8 @@ message SortField {
16581666

16591667
oneof sort_kind {
16601668
SortDirection direction = 2;
1669+
// References a function_anchor defined in this plan.
1670+
// Required; 0 is considered to be a valid anchor/reference.
16611671
uint32 comparison_function_reference = 3;
16621672
}
16631673
enum SortDirection {
@@ -1703,8 +1713,8 @@ enum AggregationPhase {
17031713
// An aggregate function.
17041714
message AggregateFunction {
17051715
// Points to a function_anchor defined in this plan, which must refer
1706-
// to an aggregate function in the associated YAML file. Required; 0 is
1707-
// considered to be a valid anchor/reference.
1716+
// to an aggregate function in the associated YAML file.
1717+
// Required; 0 is considered to be a valid anchor/reference.
17081718
uint32 function_reference = 1;
17091719

17101720
// The arguments to be bound to the function. This must have exactly the

proto/substrait/extensions/extensions.proto

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ option java_package = "io.substrait.proto";
1414
message SimpleExtensionURI {
1515
option deprecated = true;
1616
// A surrogate key used in the context of a single plan used to reference the
17-
// URI associated with an extension.
17+
// URI associated with an extension. 0 is a valid anchor value.
1818
uint32 extension_uri_anchor = 1;
1919

2020
// The URI where this extension YAML can be retrieved. This is the "namespace"
@@ -24,7 +24,7 @@ message SimpleExtensionURI {
2424

2525
message SimpleExtensionURN {
2626
// A surrogate key used in the context of a single plan used to reference the
27-
// URN associated with an extension.
27+
// URN associated with an extension. 0 is a valid anchor value.
2828
uint32 extension_urn_anchor = 1;
2929

3030
// The extension URN that uniquely identifies this extension. This must follow the
@@ -45,15 +45,17 @@ message SimpleExtensionDeclaration {
4545
message ExtensionType {
4646
// references the extension_uri_anchor defined for a specific extension URI.
4747
// this is now deprecated and extension_urn_reference should be used instead.
48+
// Required; 0 is considered to be a valid anchor/reference.
4849
uint32 extension_uri_reference = 1 [deprecated = true];
4950

5051
// references the extension_urn_anchor defined for a specific extension URN.
5152
// If both extension_urn_reference and extension_uri_reference are present,
5253
// extension_urn_reference takes precedence.
54+
// Required; 0 is considered to be a valid anchor/reference.
5355
uint32 extension_urn_reference = 4;
5456

5557
// A surrogate key used in the context of a single plan to reference a
56-
// specific extension type
58+
// specific extension type. 0 is a valid anchor value.
5759
uint32 type_anchor = 2;
5860

5961
// the name of the type in the defined extension YAML.
@@ -63,15 +65,17 @@ message SimpleExtensionDeclaration {
6365
message ExtensionTypeVariation {
6466
// references the extension_uri_anchor defined for a specific extension URI.
6567
// this is now deprecated and extension_urn_reference should be used instead.
68+
// Required; 0 is considered to be a valid anchor/reference.
6669
uint32 extension_uri_reference = 1 [deprecated = true];
6770

6871
// references the extension_urn_anchor defined for a specific extension URN.
6972
// If both extension_urn_reference and extension_uri_reference are present,
7073
// extension_urn_reference takes precedence.
74+
// Required; 0 is considered to be a valid anchor/reference.
7175
uint32 extension_urn_reference = 4;
7276

7377
// A surrogate key used in the context of a single plan to reference a
74-
// specific type variation
78+
// specific type variation. 0 is a valid anchor value.
7579
uint32 type_variation_anchor = 2;
7680

7781
// the name of the type in the defined extension YAML.
@@ -81,15 +85,17 @@ message SimpleExtensionDeclaration {
8185
message ExtensionFunction {
8286
// references the extension_uri_anchor defined for a specific extension URI.
8387
// this is now deprecated and extension_urn_reference should be used instead.
88+
// Required; 0 is considered to be a valid anchor/reference.
8489
uint32 extension_uri_reference = 1 [deprecated = true];
8590

8691
// references the extension_urn_anchor defined for a specific extension URN.
8792
// If both extension_urn_reference and extension_uri_reference are present,
8893
// extension_urn_reference takes precedence.
94+
// Required; 0 is considered to be a valid anchor/reference.
8995
uint32 extension_urn_reference = 4;
9096

9197
// A surrogate key used in the context of a single plan to reference a
92-
// specific function
98+
// specific function. 0 is a valid anchor value.
9399
uint32 function_anchor = 2;
94100

95101
// A function signature

proto/substrait/plan.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ message Version {
102102
// Represents a binding for a dynamic parameter.
103103
message DynamicParameterBinding {
104104
// The parameter anchor that identifies the dynamic parameter reference.
105+
// Required; 0 is considered to be a valid anchor/reference.
105106
uint32 parameter_anchor = 1;
106107

107108
// The literal value assigned to the parameter at runtime.

proto/substrait/type.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ option go_package = "github.com/substrait-io/substrait-protobuf/go/substraitpb";
1010
option java_multiple_files = true;
1111
option java_package = "io.substrait.proto";
1212

13+
// Note: type_variation_reference fields within Type messages reference a
14+
// type_variation_anchor defined in the plan's extension declarations. The value
15+
// 0 represents the system-preferred variation and is a valid reference value.
1316
message Type {
1417
oneof kind {
1518
Boolean bool = 1;
@@ -224,6 +227,8 @@ message Type {
224227
}
225228

226229
message UserDefined {
230+
// References a type_anchor defined in the plan's extension declarations.
231+
// 0 is a valid reference value.
227232
uint32 type_reference = 1;
228233
uint32 type_variation_reference = 2;
229234
Nullability nullability = 3;
@@ -257,6 +262,7 @@ message Type {
257262
message TypeAlias {
258263
// A surrogate key used in the context of a single plan to reference a
259264
// specific type alias.
265+
// Required; 0 is considered to be a valid anchor/reference.
260266
uint32 type_alias_anchor = 1;
261267

262268
// A concrete type to be aliased.

site/docs/extensions/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This extension URN uses the format `extension:<OWNER>:<ID>`, where:
2222

2323
The YAML file is constructed according to the [YAML Schema](https://github.com/substrait-io/substrait/blob/main/text/simple_extensions_schema.yaml). Each definition in the file corresponds to the YAML-based serialization of the relevant data structure. If a user only wants to extend one of these types of objects (e.g. types), a developer does not have to provide definitions for the other extension points.
2424

25-
A Substrait plan can reference one or more YAML files via their extension URN. In the places where these entities are referenced, they will be referenced using an extension URN + name reference. The name scheme per type works as follows:
25+
A Substrait plan can reference one or more YAML files via their extension URN. In the places where these entities are referenced, they will be referenced using an extension URN + name reference. Each extension entity (type, type variation, or function) is assigned an anchor value, which is a non-negative integer starting from 0. The anchor value 0 is valid and can be used to reference extension entities. The name scheme per type works as follows:
2626

2727
| Category | Naming scheme |
2828
| ------------------ | ------------------------------------------------------------ |

site/docs/serialization/binary_serialization.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Extension URNs and declarations are encapsulated in the top level of the plan. E
3636

3737
Once the YAML file extension URN anchor is defined, the anchor will be referenced by zero or more `SimpleExtensionDefinition`s. For each simple extension definition, an anchor is defined for that specific extension entity. This anchor is then referenced to within lower-level primitives (functions, etc.) to reference that specific extension. Message properties are named `*_anchor` where the anchor is defined and `*_reference` when referencing the anchor. For example `function_anchor` and `function_reference`.
3838

39+
Anchor values are non-negative integers starting from 0. A value of 0 is valid and can be used to reference an extension entity.
40+
3941
=== "Simple Extension Declaration"
4042

4143
```proto

site/docs/types/type_aliases.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Type aliases allow a plan to declare a type once and reference it multiple times
1010

1111
A type alias is a mapping from an anchor to a concrete Substrait type. A valid type alias is described below.
1212

13+
* Anchors are non-negative integers starting from 0, meaning 0 is a valid anchor value.
1314
* All type parameters must be specified.
1415
* Cannot directly be another alias.
1516
* Type parameters can reference other aliased types as long as no circular dependencies are introduced.

site/docs/types/type_classes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Compound type classes are type classes that need to be configured by means of a
5050

5151
User-defined type classes are defined as part of [simple extensions](../extensions/index.md#simple-extensions). An extension can declare an arbitrary number of user-defined extension types. Once a type has been declared, it can be used in function declarations.
5252

53+
User-defined types are referenced in a plan using a `type_reference` anchor value that corresponds to a `type_anchor` defined in the plan's extension declarations. The anchor value is a non-negative integer starting from 0, meaning 0 is a valid anchor value.
54+
5355
For example, the following declares a type named `point` (namespaced to the associated YAML file) and two scalar functions that operate on it.
5456

5557
```yaml

site/docs/types/type_variations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Type variations may be used to represent differences in representation between different consumers. For example, an engine might support dictionary encoding for a string, or could be using either a row-wise or columnar representation of a struct. All variations of a type are expected to have the same semantics when operated on by functions or other expressions.
44

5-
All variations except the "system-preferred" variation (a.k.a. `[0]`, see [Type Parsing](type_parsing.md)) must be defined using [simple extensions](../extensions/index.md#simple-extensions). The key properties of these variations are:
5+
Type variation references use non-negative integer anchor values starting from 0. All variations except the "system-preferred" variation (a.k.a. `[0]`, see [Type Parsing](type_parsing.md)) must be defined using [simple extensions](../extensions/index.md#simple-extensions). The key properties of these variations are:
66

77
| Property | Description |
88
| ----------------- | ------------------------------------------------------------ |

0 commit comments

Comments
 (0)