Unique - ObjectVision/GeoDMS GitHub Wiki

Relational functions unique

syntax

  • unique(a)
  • unique_with_null(a)
  • unique_uint8(a)
  • unique_uint8_with_null(a)
  • unique_uint16(a)
  • unique_uint16_with_null(a)
  • unique_uint32(a)
  • unique_uint32_with_null(a)
  • unique_uint64(a)
  • unique_uint64_with_null(a)

definition

unique(a) results in a new domain unit with the unique occurrences of the values of attribute a.

The value type of the unit that results from unique and unique_with_null is the cardinal type of the domain of a. The value type of all other variants of unique is equal to the applied suffix.

description

This function generates a subitem, named Values. This data item contains the values in attribute a, ordered according to the value type specific ordering, which is

  • ascending for numeric values
  • lexicographical for point values, first ordered on row number, a.k.a. the y-coordinate, and values in the same row are ordered according to column number, aka the x-coordinate.
  • lexicographical for string, and numeric sequence values; i.e. only ordered with respect to later elements when earlier elements are equal; for strings, elements, a.k.a. characters are ordered according to the byte values of their utf8 representations. For all value types that can represent null values, null is ordered before any non-null value.

Values are not repeated and null values are skipped unless a _with_null suffix is used.

The Values data item can be used in a lookup (in case attribute a is a relation) or an rjoin function, to relate attributes to the new domain unit, see the example.

applies to

  • attribute a with any value element

example

unit<UInt32> Region := unique(City/RegionCode)
{
   attribute<string> name := rjoin(Values, City/RegionCode, City/RegionName);
}
City/RegionCode City/RegionName
100 Noord Holland
200 Zuid Holland
300 Utrecht
200 Zuid Holland
400 Noord Brabant
null null
400 null

domain City, nr of rows = 7

Region/Values Region/name
100 Noord Holland
200 Zuid Holland
300 Utrecht
400 Noord Brabant

domain Region, nr of rows = 5

see also

⚠️ **GitHub.com Fallback** ⚠️