Skip to content

Commit 058f6f1

Browse files
deigotezafikratmaycmlee
authored
AQG-443: document DDSQL's akeys and avals functions (#32714)
* AQG-443: document DDSQL's `akeys` and `avals` functions These newly added functions operate on the `hstore` type. Since the only place in the docs where `hstore` is mentioned is the section about `Tags`, this PR adds a new subsection there that documents `hstore` functions, loosely following [Postgres' docs](https://www.postgresql.org/docs/8.4/hstore.html) for description. * AQG-443: use singular for tag when used in a genitive sentence Co-authored-by: Zakaria Fikrat <113985839+zafikrat@users.noreply.github.com> * AQG-443: use correct casing, verb time and order of function params Co-authored-by: May Lee <may.lee@datadoghq.com> --------- Co-authored-by: Zakaria Fikrat <113985839+zafikrat@users.noreply.github.com> Co-authored-by: May Lee <may.lee@datadoghq.com>
1 parent 8682a2b commit 058f6f1

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

content/en/ddsql_reference/_index.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -808,9 +808,6 @@ ORDER BY value DESC;{{< /code-block >}}
808808
</table>
809809

810810

811-
812-
813-
814811
## Tags
815812

816813
DDSQL exposes tags as an `hstore` type, which is inspired by PostgreSQL. You can access the values for specific tag keys using the PostgreSQL arrow operator. For example:
@@ -840,6 +837,21 @@ FROM k8s.daemonsets da INNER JOIN k8s.deployments de
840837
ON da.tags = de.tags -- for a specific tag: da.tags->'app' = de.tags->'app'
841838
```
842839

840+
Additionally, you can extract tag keys and values into individual arrays of text:
841+
842+
```sql
843+
SELECT akeys(tags), avals(tags)
844+
FROM aws.ec2_instance
845+
```
846+
847+
### HSTORE functions and operators
848+
849+
| Name | Return type | Description |
850+
|-----------------------------------------------|---------------|---------------------------------------------------------------------------------------------------
851+
| tags -> 'text' | Text | Gets the value for a given key. Returns `null` if key is not present. |
852+
| akeys(hstore tags) | Array of text | Gets the keys of an HSTORE as an array |
853+
| avals(hstore tags) | Array of text | Gets the values of an HSTORE as an array |
854+
843855
## Further reading
844856

845857
{{< partial name="whats-next/whats-next.html" >}}

0 commit comments

Comments
 (0)