diff --git a/site/docs/types/named_structs.md b/site/docs/types/named_structs.md index c3f143808..b9db3c99b 100644 --- a/site/docs/types/named_structs.md +++ b/site/docs/types/named_structs.md @@ -4,13 +4,10 @@ A Named Struct is a special type construct that combines: * A Struct type * A list of names for the fields in the Struct, in depth-first search order -The depth-first search order for names arises from the the ability to nest Structs within other types. All struct fields must be named, even nested fields. +The depth-first search order for names arises from the the ability to nest Structs within other types. All Struct fields must be named, even nested fields. Named Structs are most commonly used to model the schema of Read relations. -> Note: In this page Structs are annotated with names for readabilty. -> In practice Structs do not contain name information. - ## Determining Names When producing/consuming names for a NamedStruct, some types require special handling: @@ -19,7 +16,9 @@ A struct has names for each of its inner fields. For example, the following Struct ``` -struct +struct + ↑ ↑ + a b ``` has 2 names, one for each of its inner fields. @@ -29,7 +28,10 @@ Struct types nested in compound types must also be be named. #### Structs within Maps If a Map contains Structs, either as keys or values or both, the Struct fields must be named. Keys are named before values. For example the following Map ``` -map, c: struct> +map, struct> + ↑ ↑ ↑ ↑ ↑ + a b c d e + ``` has 5 named fields * 2 names [a, b] for the struct fields used as a key @@ -38,7 +40,9 @@ has 5 named fields #### Structs within List If a List contains Structs, the Struct fields must be named. For example the following List ``` -list> +list> + ↑ ↑ + a b ``` has 2 named fields [a, b] for the struct fields. @@ -47,7 +51,9 @@ Structs can also be embedded within Structs. A Struct like ``` -struct, d: struct> +struct, struct> + ↑ ↑ ↑ ↑ ↑ ↑ ↑ + a b c d e f g ``` has 7 names * 1 name [a] for the 1st nested struct field @@ -61,7 +67,9 @@ has 7 names ``` NamedStruct { names: [a, b, c, d] - struct: struct, c: map, d: i64> + struct: struct, map, i64> + ↑ ↑ ↑ ↑ + a b c d } ``` @@ -69,7 +77,9 @@ NamedStruct { ``` NamedStruct { names: [a, b, c, d, e, f, g, h] - struct: struct>, e: map>, h:i64> + struct: struct>, map>, i64> + ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ + a b c d e f g h } ``` @@ -77,7 +87,9 @@ NamedStruct { ``` NamedStruct { names: [a, b, c, d, e, f, g, h, i] - struct: struct, g: i64, h: struct>>> + struct: struct, i64, struct>>> + ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ + a b c d e f g h i j } ```