Union Functions
| Name | Description |
|---|---|
union.tag | Dot notation serves as an alias for union_extract. |
union_extract(union, 'tag') | Extract the value with the named tags from the union. NULL if the tag is not currently selected. |
union_value(tag := any) | Create a single member UNION containing the argument value. The tag of the value will be the bound variable name. |
union_tag(union) | Retrieve the currently selected tag of the union as an Enum. |
union.tag
Dot notation serves as an alias for union_extract.
Query
SELECT (union_value(k := 'hello')).k AS k;Result
k------- hellounion_extract(union, 'tag')
Extract the value with the named tags from the union. NULL if the tag is not currently selected.
Query
SELECT union_extract(union_value(k := 'hello'), 'k') AS k;Result
k------- hellounion_value(tag := any)
| Description | Create a single member UNION containing the argument value. The tag of the value will be the bound variable name. |
|---|---|
| Example | union_value(k := 'hello') |
| Result | 'hello'::UNION(k VARCHAR) |
union_tag(union)
Retrieve the currently selected tag of the union as an Enum.
Query
SELECT union_tag(union_value(k := 'foo')) AS union_tag;Result
union_tag----------- k