sfc-gh-aloeser commented on code in PR #16972:
URL: https://github.com/apache/iceberg/pull/16972#discussion_r4706089458


##########
format/spec.md:
##########
@@ -399,9 +400,89 @@ For example, a struct column `point` with fields `x` 
(default 0) and `y` (defaul
 
 Default values are attributes of fields in schemas and serialized with fields 
in the JSON format. See [Appendix C](#appendix-c-json-serialization).
 
+#### Collations
+
+A `string` field may have a collation that defines how its values are compared 
and ordered, for example case-insensitive, accent-insensitive, or locale-aware. 
A collation does not change how values are stored: a value written as `'appLE'` 
is read as `'appLE'`.
+
+Any `string` field may have a collation, including nested fields, except map 
keys. A struct field uses the `collation` attribute, a list uses 
`element-collation`, and a map uses `value-collation` (see [Appendix 
C](#appendix-c-json-serialization)). A string field without a collation uses 
UTF-8 byte order.
+
+A collation changes comparison only. The rest of the format stays byte-based, 
because collation order differs between implementations and versions:
+
+* A collated field must not be a source field of a partition field or a sort 
field, and must not be an identifier field. A collation must not be added to a 
field that is used in one of these ways.
+* Map keys must not have a collation.
+* Bounds of the collated field itself use UTF-8 byte order.
+
+SQL comparison, equality, ordering, grouping, and distinctness are the 
engine's responsibility.
+
+##### Collation Names
+
+A collation name has the form `<provider>.<name>`, for example `icu.en_US-ci`. 
The provider is the library that defines the collation. This spec defines one 
provider, `icu`: the [Unicode Collation 
Algorithm](https://unicode.org/reports/tr10/) with 
[CLDR](https://cldr.unicode.org/) locale data. Adding a provider requires a 
spec change. A reader must not use a collation from a provider it does not 
recognize.
+
+```
+specifier  = icu-spec | utf8-spec
+icu-spec   = "icu" "." locale [ "-" case-mod ] [ "-" accent-mod ] [ "-" 
trim-mod ]
+utf8-spec  = "utf8" [ "-" trim-mod ]
+locale     = language [ "_" region ]       ; e.g. en, de, en_US, de_DE
+case-mod   = "ci"                           ; case-insensitive (default is 
case-sensitive)
+accent-mod = "ai"                           ; accent-insensitive (default is 
accent-sensitive)
+trim-mod   = "ltrim" | "rtrim" | "trim"     ; trim leading / trailing / both 
spaces (U+0020)
+```
+
+Modifier order and case are fixed, and defaults have no modifier, so each 
collation has exactly one name. Case- and accent-insensitive collations require 
a locale: `ł` and `l` are equal under `icu.en-ai` but not under `icu.pl-ai`.
+
+Without a trim modifier, leading and trailing spaces are significant. A trim 
modifier removes leading, trailing, or both leading and trailing spaces 
(U+0020) before values are compared, for example `icu.en_US-ci-rtrim`.
+
+`utf8` without a modifier is UTF-8 byte order, the same as no collation.
+
+For `icu`, the locale is the ICU locale ID, and the modifiers map to ICU 
collator settings as follows. All other settings use the locale's defaults. 
Trim modifiers are applied to values before comparison and do not change 
collator settings.
+
+| Modifiers | ICU strength | ICU case level |
+|-----------|--------------|----------------|
+| none      | tertiary     | off            |
+| `ci`      | secondary    | off            |
+| `ai`      | primary      | on             |
+| `ci-ai`   | primary      | off            |
+
+##### Collation Versions
+
+Collation order can change between versions of a provider's data ([UTS 
#10](https://unicode.org/reports/tr10/#Non-Goals)). The schema stores the 
collation name without a version, and collation bounds record the version they 
were produced under. For `icu`, the version is the [ICU collator 
version](https://unicode-org.github.io/icu/userguide/collation/architecture.html#versioning),
 which changes when the collation order can change. Versions are compared as 
opaque strings.
+
+##### Collation Bounds
+
+Byte-order bounds cannot prune a collated field: under a case-insensitive 
collation `'a' < 'B'`, but in byte order `'a' > 'B'`. Collation bounds are kept 
in [stats-only fields](#stats-only-fields), outside the schema. A collated 
field has:
+
+* One `collation-value` stats-only field per collation version. Its 
type-specific fields are `source-id`, the id of the collated field; 
`collation`, the collation name; and `version`, the collation version. Its 
bounds are original string values, compared under that collation and version. 
Its `data-type` must be `string`.
+* Two `expr-value` stats-only fields with `data-type` `int`, for 
`min_code_point(ref)` and `max_code_point(ref)` (see [Iceberg 
functions](expressions-spec.md#appendix-a-iceberg-functions)). The lower bound 
of the first and the upper bound of the second give the file's code-point 
range. They do not depend on the collation or its version.
+
+For example, for a field `city` with id `5` and collation `icu.de_DE` (`expr` 
in short form):
+
+```
+{ "field-id": 101, "type": "collation-value", "source-id": 5, "collation": 
"icu.de_DE", "version": "153.120.0.0", "data-type": "string" }
+{ "field-id": 102, "type": "expr-value", "expr": min_code_point(ref(5)), 
"data-type": "int" }
+{ "field-id": 103, "type": "expr-value", "expr": max_code_point(ref(5)), 
"data-type": "int" }
+```
+
+`collation-value` bounds must be valid but need not be tight: under the 
collation and version, `lower_bound` sorts at or before every value in the 
file, and `upper_bound` at or after.
+
+Bounds a writer stores for a collated field itself must use UTF-8 byte order. 
Writers should store them, so readers without collation support can still 
prune. A writer that supports the collation should also write `collation-value` 
bounds for its version and code-point bounds, and adds these stats-only fields 
when they do not exist. It must not add a second `collation-value` field with 
the same `source-id`, `collation`, and `version`, and must not write 
`collation-value` bounds for a version it does not support.
+
+A reader must not use byte-order bounds to prune comparison, equality, or 
prefix predicates on a collated field. It may prune with `collation-value` 
bounds when their collation is the field's collation and their version is the 
reader's version. It may also use bounds from another version of the same 
collation when both versions order the file's code-point range the same way. 
Otherwise it scans the file.

Review Comment:
   > A reader must not use byte-order bounds
   
   A collation-aware reader?



##########
format/spec.md:
##########
@@ -399,9 +400,89 @@ For example, a struct column `point` with fields `x` 
(default 0) and `y` (defaul
 
 Default values are attributes of fields in schemas and serialized with fields 
in the JSON format. See [Appendix C](#appendix-c-json-serialization).
 
+#### Collations
+
+A `string` field may have a collation that defines how its values are compared 
and ordered, for example case-insensitive, accent-insensitive, or locale-aware. 
A collation does not change how values are stored: a value written as `'appLE'` 
is read as `'appLE'`.
+
+Any `string` field may have a collation, including nested fields, except map 
keys. A struct field uses the `collation` attribute, a list uses 
`element-collation`, and a map uses `value-collation` (see [Appendix 
C](#appendix-c-json-serialization)). A string field without a collation uses 
UTF-8 byte order.
+
+A collation changes comparison only. The rest of the format stays byte-based, 
because collation order differs between implementations and versions:

Review Comment:
   I'm not sure if I understand this sentence. Could you explain how it is 
different from this?
   > A collation does not change how values are stored: a value written as 
`'appLE'` is read as `'appLE'`.
   
   



##########
format/spec.md:
##########
@@ -399,9 +400,89 @@ For example, a struct column `point` with fields `x` 
(default 0) and `y` (defaul
 
 Default values are attributes of fields in schemas and serialized with fields 
in the JSON format. See [Appendix C](#appendix-c-json-serialization).
 
+#### Collations
+
+A `string` field may have a collation that defines how its values are compared 
and ordered, for example case-insensitive, accent-insensitive, or locale-aware. 
A collation does not change how values are stored: a value written as `'appLE'` 
is read as `'appLE'`.
+
+Any `string` field may have a collation, including nested fields, except map 
keys. A struct field uses the `collation` attribute, a list uses 
`element-collation`, and a map uses `value-collation` (see [Appendix 
C](#appendix-c-json-serialization)). A string field without a collation uses 
UTF-8 byte order.
+
+A collation changes comparison only. The rest of the format stays byte-based, 
because collation order differs between implementations and versions:
+
+* A collated field must not be a source field of a partition field or a sort 
field, and must not be an identifier field. A collation must not be added to a 
field that is used in one of these ways.

Review Comment:
   > A collation must not be added to a field that is used in one of these ways.
   
   in the most recent schema?



##########
format/spec.md:
##########
@@ -399,9 +400,89 @@ For example, a struct column `point` with fields `x` 
(default 0) and `y` (defaul
 
 Default values are attributes of fields in schemas and serialized with fields 
in the JSON format. See [Appendix C](#appendix-c-json-serialization).
 
+#### Collations
+
+A `string` field may have a collation that defines how its values are compared 
and ordered, for example case-insensitive, accent-insensitive, or locale-aware. 
A collation does not change how values are stored: a value written as `'appLE'` 
is read as `'appLE'`.
+
+Any `string` field may have a collation, including nested fields, except map 
keys. A struct field uses the `collation` attribute, a list uses 
`element-collation`, and a map uses `value-collation` (see [Appendix 
C](#appendix-c-json-serialization)). A string field without a collation uses 
UTF-8 byte order.
+
+A collation changes comparison only. The rest of the format stays byte-based, 
because collation order differs between implementations and versions:
+
+* A collated field must not be a source field of a partition field or a sort 
field, and must not be an identifier field. A collation must not be added to a 
field that is used in one of these ways.
+* Map keys must not have a collation.
+* Bounds of the collated field itself use UTF-8 byte order.
+
+SQL comparison, equality, ordering, grouping, and distinctness are the 
engine's responsibility.
+
+##### Collation Names
+
+A collation name has the form `<provider>.<name>`, for example `icu.en_US-ci`. 
The provider is the library that defines the collation. This spec defines one 
provider, `icu`: the [Unicode Collation 
Algorithm](https://unicode.org/reports/tr10/) with 
[CLDR](https://cldr.unicode.org/) locale data. Adding a provider requires a 
spec change. A reader must not use a collation from a provider it does not 
recognize.
+
+```
+specifier  = icu-spec | utf8-spec
+icu-spec   = "icu" "." locale [ "-" case-mod ] [ "-" accent-mod ] [ "-" 
trim-mod ]
+utf8-spec  = "utf8" [ "-" trim-mod ]
+locale     = language [ "_" region ]       ; e.g. en, de, en_US, de_DE
+case-mod   = "ci"                           ; case-insensitive (default is 
case-sensitive)
+accent-mod = "ai"                           ; accent-insensitive (default is 
accent-sensitive)
+trim-mod   = "ltrim" | "rtrim" | "trim"     ; trim leading / trailing / both 
spaces (U+0020)
+```
+
+Modifier order and case are fixed, and defaults have no modifier, so each 
collation has exactly one name. Case- and accent-insensitive collations require 
a locale: `ł` and `l` are equal under `icu.en-ai` but not under `icu.pl-ai`.
+
+Without a trim modifier, leading and trailing spaces are significant. A trim 
modifier removes leading, trailing, or both leading and trailing spaces 
(U+0020) before values are compared, for example `icu.en_US-ci-rtrim`.
+
+`utf8` without a modifier is UTF-8 byte order, the same as no collation.
+
+For `icu`, the locale is the ICU locale ID, and the modifiers map to ICU 
collator settings as follows. All other settings use the locale's defaults. 
Trim modifiers are applied to values before comparison and do not change 
collator settings.
+
+| Modifiers | ICU strength | ICU case level |
+|-----------|--------------|----------------|
+| none      | tertiary     | off            |
+| `ci`      | secondary    | off            |
+| `ai`      | primary      | on             |
+| `ci-ai`   | primary      | off            |
+
+##### Collation Versions
+
+Collation order can change between versions of a provider's data ([UTS 
#10](https://unicode.org/reports/tr10/#Non-Goals)). The schema stores the 
collation name without a version, and collation bounds record the version they 
were produced under. For `icu`, the version is the [ICU collator 
version](https://unicode-org.github.io/icu/userguide/collation/architecture.html#versioning),
 which changes when the collation order can change. Versions are compared as 
opaque strings.
+
+##### Collation Bounds
+
+Byte-order bounds cannot prune a collated field: under a case-insensitive 
collation `'a' < 'B'`, but in byte order `'a' > 'B'`. Collation bounds are kept 
in [stats-only fields](#stats-only-fields), outside the schema. A collated 
field has:
+
+* One `collation-value` stats-only field per collation version. Its 
type-specific fields are `source-id`, the id of the collated field; 
`collation`, the collation name; and `version`, the collation version. Its 
bounds are original string values, compared under that collation and version. 
Its `data-type` must be `string`.
+* Two `expr-value` stats-only fields with `data-type` `int`, for 
`min_code_point(ref)` and `max_code_point(ref)` (see [Iceberg 
functions](expressions-spec.md#appendix-a-iceberg-functions)). The lower bound 
of the first and the upper bound of the second give the file's code-point 
range. They do not depend on the collation or its version.
+
+For example, for a field `city` with id `5` and collation `icu.de_DE` (`expr` 
in short form):
+
+```
+{ "field-id": 101, "type": "collation-value", "source-id": 5, "collation": 
"icu.de_DE", "version": "153.120.0.0", "data-type": "string" }
+{ "field-id": 102, "type": "expr-value", "expr": min_code_point(ref(5)), 
"data-type": "int" }
+{ "field-id": 103, "type": "expr-value", "expr": max_code_point(ref(5)), 
"data-type": "int" }
+```
+
+`collation-value` bounds must be valid but need not be tight: under the 
collation and version, `lower_bound` sorts at or before every value in the 
file, and `upper_bound` at or after.
+
+Bounds a writer stores for a collated field itself must use UTF-8 byte order. 
Writers should store them, so readers without collation support can still 
prune. A writer that supports the collation should also write `collation-value` 
bounds for its version and code-point bounds, and adds these stats-only fields 
when they do not exist. It must not add a second `collation-value` field with 
the same `source-id`, `collation`, and `version`, and must not write 
`collation-value` bounds for a version it does not support.
+
+A reader must not use byte-order bounds to prune comparison, equality, or 
prefix predicates on a collated field. It may prune with `collation-value` 
bounds when their collation is the field's collation and their version is the 
reader's version. It may also use bounds from another version of the same 
collation when both versions order the file's code-point range the same way. 
Otherwise it scans the file.
+
+Collation bounds prune comparison and equality predicates. They do not prune 
prefix predicates such as `STARTS_WITH` or `LIKE 'x%'`, because collation order 
does not preserve prefixes.

Review Comment:
   👍 



##########
format/spec.md:
##########
@@ -399,9 +400,89 @@ For example, a struct column `point` with fields `x` 
(default 0) and `y` (defaul
 
 Default values are attributes of fields in schemas and serialized with fields 
in the JSON format. See [Appendix C](#appendix-c-json-serialization).
 
+#### Collations
+
+A `string` field may have a collation that defines how its values are compared 
and ordered, for example case-insensitive, accent-insensitive, or locale-aware. 
A collation does not change how values are stored: a value written as `'appLE'` 
is read as `'appLE'`.
+
+Any `string` field may have a collation, including nested fields, except map 
keys. A struct field uses the `collation` attribute, a list uses 
`element-collation`, and a map uses `value-collation` (see [Appendix 
C](#appendix-c-json-serialization)). A string field without a collation uses 
UTF-8 byte order.
+
+A collation changes comparison only. The rest of the format stays byte-based, 
because collation order differs between implementations and versions:
+
+* A collated field must not be a source field of a partition field or a sort 
field, and must not be an identifier field. A collation must not be added to a 
field that is used in one of these ways.
+* Map keys must not have a collation.
+* Bounds of the collated field itself use UTF-8 byte order.
+
+SQL comparison, equality, ordering, grouping, and distinctness are the 
engine's responsibility.
+
+##### Collation Names
+
+A collation name has the form `<provider>.<name>`, for example `icu.en_US-ci`. 
The provider is the library that defines the collation. This spec defines one 
provider, `icu`: the [Unicode Collation 
Algorithm](https://unicode.org/reports/tr10/) with 
[CLDR](https://cldr.unicode.org/) locale data. Adding a provider requires a 
spec change. A reader must not use a collation from a provider it does not 
recognize.
+
+```
+specifier  = icu-spec | utf8-spec
+icu-spec   = "icu" "." locale [ "-" case-mod ] [ "-" accent-mod ] [ "-" 
trim-mod ]
+utf8-spec  = "utf8" [ "-" trim-mod ]
+locale     = language [ "_" region ]       ; e.g. en, de, en_US, de_DE
+case-mod   = "ci"                           ; case-insensitive (default is 
case-sensitive)
+accent-mod = "ai"                           ; accent-insensitive (default is 
accent-sensitive)
+trim-mod   = "ltrim" | "rtrim" | "trim"     ; trim leading / trailing / both 
spaces (U+0020)
+```
+
+Modifier order and case are fixed, and defaults have no modifier, so each 
collation has exactly one name. Case- and accent-insensitive collations require 
a locale: `ł` and `l` are equal under `icu.en-ai` but not under `icu.pl-ai`.
+
+Without a trim modifier, leading and trailing spaces are significant. A trim 
modifier removes leading, trailing, or both leading and trailing spaces 
(U+0020) before values are compared, for example `icu.en_US-ci-rtrim`.
+
+`utf8` without a modifier is UTF-8 byte order, the same as no collation.

Review Comment:
   A (human) reader might wonder why we're proposing a `utf8` collation here 
when it behaves exactly identical to the default. I realize this is more of an 
engine responsibility/implementation decision, but should we add a reference to 
collation precedence in multi-string operations?
   
   In any operation involving two or more strings, engines need to define which 
collation is the "dominant" one and should be used in the evaluation. Having 
the collation set to `utf8` explicitly might lead to a higher precedence than 
having just the default (no collation)



##########
format/spec.md:
##########
@@ -399,9 +400,89 @@ For example, a struct column `point` with fields `x` 
(default 0) and `y` (defaul
 
 Default values are attributes of fields in schemas and serialized with fields 
in the JSON format. See [Appendix C](#appendix-c-json-serialization).
 
+#### Collations
+
+A `string` field may have a collation that defines how its values are compared 
and ordered, for example case-insensitive, accent-insensitive, or locale-aware. 
A collation does not change how values are stored: a value written as `'appLE'` 
is read as `'appLE'`.
+
+Any `string` field may have a collation, including nested fields, except map 
keys. A struct field uses the `collation` attribute, a list uses 
`element-collation`, and a map uses `value-collation` (see [Appendix 
C](#appendix-c-json-serialization)). A string field without a collation uses 
UTF-8 byte order.
+
+A collation changes comparison only. The rest of the format stays byte-based, 
because collation order differs between implementations and versions:
+
+* A collated field must not be a source field of a partition field or a sort 
field, and must not be an identifier field. A collation must not be added to a 
field that is used in one of these ways.
+* Map keys must not have a collation.
+* Bounds of the collated field itself use UTF-8 byte order.
+
+SQL comparison, equality, ordering, grouping, and distinctness are the 
engine's responsibility.
+
+##### Collation Names
+
+A collation name has the form `<provider>.<name>`, for example `icu.en_US-ci`. 
The provider is the library that defines the collation. This spec defines one 
provider, `icu`: the [Unicode Collation 
Algorithm](https://unicode.org/reports/tr10/) with 
[CLDR](https://cldr.unicode.org/) locale data. Adding a provider requires a 
spec change. A reader must not use a collation from a provider it does not 
recognize.
+
+```
+specifier  = icu-spec | utf8-spec
+icu-spec   = "icu" "." locale [ "-" case-mod ] [ "-" accent-mod ] [ "-" 
trim-mod ]
+utf8-spec  = "utf8" [ "-" trim-mod ]
+locale     = language [ "_" region ]       ; e.g. en, de, en_US, de_DE
+case-mod   = "ci"                           ; case-insensitive (default is 
case-sensitive)
+accent-mod = "ai"                           ; accent-insensitive (default is 
accent-sensitive)
+trim-mod   = "ltrim" | "rtrim" | "trim"     ; trim leading / trailing / both 
spaces (U+0020)
+```
+
+Modifier order and case are fixed, and defaults have no modifier, so each 
collation has exactly one name. Case- and accent-insensitive collations require 
a locale: `ł` and `l` are equal under `icu.en-ai` but not under `icu.pl-ai`.
+
+Without a trim modifier, leading and trailing spaces are significant. A trim 
modifier removes leading, trailing, or both leading and trailing spaces 
(U+0020) before values are compared, for example `icu.en_US-ci-rtrim`.
+
+`utf8` without a modifier is UTF-8 byte order, the same as no collation.
+
+For `icu`, the locale is the ICU locale ID, and the modifiers map to ICU 
collator settings as follows. All other settings use the locale's defaults. 
Trim modifiers are applied to values before comparison and do not change 
collator settings.
+
+| Modifiers | ICU strength | ICU case level |
+|-----------|--------------|----------------|
+| none      | tertiary     | off            |
+| `ci`      | secondary    | off            |
+| `ai`      | primary      | on             |
+| `ci-ai`   | primary      | off            |
+
+##### Collation Versions
+
+Collation order can change between versions of a provider's data ([UTS 
#10](https://unicode.org/reports/tr10/#Non-Goals)). The schema stores the 
collation name without a version, and collation bounds record the version they 
were produced under. For `icu`, the version is the [ICU collator 
version](https://unicode-org.github.io/icu/userguide/collation/architecture.html#versioning),
 which changes when the collation order can change. Versions are compared as 
opaque strings.
+
+##### Collation Bounds
+
+Byte-order bounds cannot prune a collated field: under a case-insensitive 
collation `'a' < 'B'`, but in byte order `'a' > 'B'`. Collation bounds are kept 
in [stats-only fields](#stats-only-fields), outside the schema. A collated 
field has:
+
+* One `collation-value` stats-only field per collation version. Its 
type-specific fields are `source-id`, the id of the collated field; 
`collation`, the collation name; and `version`, the collation version. Its 
bounds are original string values, compared under that collation and version. 
Its `data-type` must be `string`.

Review Comment:
   nit: for utf8 provided-collations, we don't have a version, as UTF-8 
encoding and code point assignments don't change. Can we add that version must 
be omitted for the utf8 provider?



##########
format/spec.md:
##########
@@ -399,9 +400,89 @@ For example, a struct column `point` with fields `x` 
(default 0) and `y` (defaul
 
 Default values are attributes of fields in schemas and serialized with fields 
in the JSON format. See [Appendix C](#appendix-c-json-serialization).
 
+#### Collations
+
+A `string` field may have a collation that defines how its values are compared 
and ordered, for example case-insensitive, accent-insensitive, or locale-aware. 
A collation does not change how values are stored: a value written as `'appLE'` 
is read as `'appLE'`.
+
+Any `string` field may have a collation, including nested fields, except map 
keys. A struct field uses the `collation` attribute, a list uses 
`element-collation`, and a map uses `value-collation` (see [Appendix 
C](#appendix-c-json-serialization)). A string field without a collation uses 
UTF-8 byte order.
+
+A collation changes comparison only. The rest of the format stays byte-based, 
because collation order differs between implementations and versions:
+
+* A collated field must not be a source field of a partition field or a sort 
field, and must not be an identifier field. A collation must not be added to a 
field that is used in one of these ways.

Review Comment:
   > must not be an identifier field
   
   what about unique and primary key constraints? I worry the same problems of 
"two different versions of ICU disagree on equality" might make those 
constraints challenging on collated columns



##########
format/expressions-spec.md:
##########
@@ -228,6 +228,17 @@ Note that `year`, `month`, and `hour` transforms produce 
ordinal values and not
 [bucket-ref]: spec.md#bucket-transform-details
 [truncate-ref]: spec.md#truncate-transform-details
 
+### String functions
+
+Both functions produce `null` for a `null` or empty input value.
+
+Code points are Unicode scalar values, not UTF-16 code units. For example, 
U+10000 is larger than U+FFFF.
+

Review Comment:
   should we move this below the table? It starts with "Both functions" without 
having referenced those functions before



##########
format/spec.md:
##########
@@ -399,9 +400,89 @@ For example, a struct column `point` with fields `x` 
(default 0) and `y` (defaul
 
 Default values are attributes of fields in schemas and serialized with fields 
in the JSON format. See [Appendix C](#appendix-c-json-serialization).
 
+#### Collations
+
+A `string` field may have a collation that defines how its values are compared 
and ordered, for example case-insensitive, accent-insensitive, or locale-aware. 
A collation does not change how values are stored: a value written as `'appLE'` 
is read as `'appLE'`.
+
+Any `string` field may have a collation, including nested fields, except map 
keys. A struct field uses the `collation` attribute, a list uses 
`element-collation`, and a map uses `value-collation` (see [Appendix 
C](#appendix-c-json-serialization)). A string field without a collation uses 
UTF-8 byte order.
+
+A collation changes comparison only. The rest of the format stays byte-based, 
because collation order differs between implementations and versions:
+
+* A collated field must not be a source field of a partition field or a sort 
field, and must not be an identifier field. A collation must not be added to a 
field that is used in one of these ways.
+* Map keys must not have a collation.
+* Bounds of the collated field itself use UTF-8 byte order.
+
+SQL comparison, equality, ordering, grouping, and distinctness are the 
engine's responsibility.
+
+##### Collation Names
+
+A collation name has the form `<provider>.<name>`, for example `icu.en_US-ci`. 
The provider is the library that defines the collation. This spec defines one 
provider, `icu`: the [Unicode Collation 
Algorithm](https://unicode.org/reports/tr10/) with 
[CLDR](https://cldr.unicode.org/) locale data. Adding a provider requires a 
spec change. A reader must not use a collation from a provider it does not 
recognize.
+
+```
+specifier  = icu-spec | utf8-spec
+icu-spec   = "icu" "." locale [ "-" case-mod ] [ "-" accent-mod ] [ "-" 
trim-mod ]
+utf8-spec  = "utf8" [ "-" trim-mod ]
+locale     = language [ "_" region ]       ; e.g. en, de, en_US, de_DE
+case-mod   = "ci"                           ; case-insensitive (default is 
case-sensitive)
+accent-mod = "ai"                           ; accent-insensitive (default is 
accent-sensitive)
+trim-mod   = "ltrim" | "rtrim" | "trim"     ; trim leading / trailing / both 
spaces (U+0020)
+```
+
+Modifier order and case are fixed, and defaults have no modifier, so each 
collation has exactly one name. Case- and accent-insensitive collations require 
a locale: `ł` and `l` are equal under `icu.en-ai` but not under `icu.pl-ai`.

Review Comment:
   I think to make names truly unique, we'd need to define the casing of the 
locales. 
   E.g., the current `language` and `region` tokens are not defined, so EN_us 
would be as valid as en_US.
   I would suggest to make this explicit, similar to how it was done in the 
original proposal: 
https://docs.google.com/document/d/1m8b7u97uteHYjXk-4DNglJSpQO8OcZOCzW2tApCNTW4/edit?tab=t.50g4t7yl7w7t#heading=h.otc95k2cc6qw



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to