Skip to content

Commit 0c0da1c

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

File tree

9 files changed

+43
-10
lines changed

9 files changed

+43
-10
lines changed

proto/substrait/algebra.proto

Lines changed: 15 additions & 5 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+
// 0 is a valid anchor/reference.
391393
uint32 function_reference = 1;
392394

393395
repeated FunctionArgument arguments = 9;
@@ -788,7 +790,8 @@ message ComparisonJoinKey {
788790
// A custom comparison behavior is used. This can happen, for example, when using
789791
// collations, where we might want to do something like a case-insensitive comparison.
790792
//
791-
// This must be a binary function with a boolean return type
793+
// This must be a binary function with a boolean return type.
794+
// 0 is 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+
// 0 is 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+
// 0 is a valid anchor/reference.
11281133
uint32 type_reference = 1;
11291134

11301135
// points to a type_alias_anchor defined in this plan.
1136+
// 0 is 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+
// 0 is 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 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+
// 0 is 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+
// 0 is 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 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: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ message SimpleExtensionURI {
1515
option deprecated = true;
1616
// A surrogate key used in the context of a single plan used to reference the
1717
// URI associated with an extension.
18+
// 0 is a valid anchor/reference.
1819
uint32 extension_uri_anchor = 1;
1920

2021
// The URI where this extension YAML can be retrieved. This is the "namespace"
@@ -25,6 +26,7 @@ message SimpleExtensionURI {
2526
message SimpleExtensionURN {
2627
// A surrogate key used in the context of a single plan used to reference the
2728
// URN associated with an extension.
29+
// 0 is a valid anchor/reference.
2830
uint32 extension_urn_anchor = 1;
2931

3032
// The extension URN that uniquely identifies this extension. This must follow the
@@ -45,15 +47,18 @@ message SimpleExtensionDeclaration {
4547
message ExtensionType {
4648
// references the extension_uri_anchor defined for a specific extension URI.
4749
// this is now deprecated and extension_urn_reference should be used instead.
50+
// 0 is a valid anchor/reference.
4851
uint32 extension_uri_reference = 1 [deprecated = true];
4952

5053
// references the extension_urn_anchor defined for a specific extension URN.
5154
// If both extension_urn_reference and extension_uri_reference are present,
5255
// extension_urn_reference takes precedence.
56+
// 0 is a valid anchor/reference.
5357
uint32 extension_urn_reference = 4;
5458

5559
// A surrogate key used in the context of a single plan to reference a
56-
// specific extension type
60+
// specific extension type.
61+
// 0 is a valid anchor/reference.
5762
uint32 type_anchor = 2;
5863

5964
// the name of the type in the defined extension YAML.
@@ -63,15 +68,18 @@ message SimpleExtensionDeclaration {
6368
message ExtensionTypeVariation {
6469
// references the extension_uri_anchor defined for a specific extension URI.
6570
// this is now deprecated and extension_urn_reference should be used instead.
71+
// 0 is a valid anchor/reference.
6672
uint32 extension_uri_reference = 1 [deprecated = true];
6773

6874
// references the extension_urn_anchor defined for a specific extension URN.
6975
// If both extension_urn_reference and extension_uri_reference are present,
7076
// extension_urn_reference takes precedence.
77+
// 0 is a valid anchor/reference.
7178
uint32 extension_urn_reference = 4;
7279

7380
// A surrogate key used in the context of a single plan to reference a
74-
// specific type variation
81+
// specific type variation.
82+
// 0 is a valid anchor/reference.
7583
uint32 type_variation_anchor = 2;
7684

7785
// the name of the type in the defined extension YAML.
@@ -81,15 +89,18 @@ message SimpleExtensionDeclaration {
8189
message ExtensionFunction {
8290
// references the extension_uri_anchor defined for a specific extension URI.
8391
// this is now deprecated and extension_urn_reference should be used instead.
92+
// 0 is a valid anchor/reference.
8493
uint32 extension_uri_reference = 1 [deprecated = true];
8594

8695
// references the extension_urn_anchor defined for a specific extension URN.
8796
// If both extension_urn_reference and extension_uri_reference are present,
8897
// extension_urn_reference takes precedence.
98+
// 0 is a valid anchor/reference.
8999
uint32 extension_urn_reference = 4;
90100

91101
// A surrogate key used in the context of a single plan to reference a
92-
// specific function
102+
// specific function.
103+
// 0 is a valid anchor/reference.
93104
uint32 function_anchor = 2;
94105

95106
// 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+
// 0 is 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 anchor/reference.
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+
// 0 is 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)