Skip to content

Commit 228e912

Browse files
mhintzbrett0000FF
andauthored
[ddsql] Add examples of multi-valued tags handling to DDSQL tags documentation (#31292)
* Add examples of multi-valued tags handling to DDSQL tags documentation I'd like to add an example of what happens in DDSQL when a resource has multiple values for the same tag key. This is a potential stumbling-block for customers and I'd like to be sure that it's well-documented in case customers run into this. * Update codeowners for DDSQL Reference * Apply PR feedback for future -> present tense Co-authored-by: Brett Blue <[email protected]> --------- Co-authored-by: Brett Blue <[email protected]>
1 parent 4bcbb80 commit 228e912

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ content/en/code_analysis/ @Datadog/static-analysis @Data
165165
content/en/quality_gates/ @Datadog/ci-app-backend @Datadog/documentation
166166

167167
# DDSQL Editor References
168-
content/en/ddsql_reference/*.md @Datadog/xpq @Datadog/documentation @Datadog/advanced-query-guild
168+
content/en/ddsql_reference/*.md @Datadog/documentation @Datadog/advanced-query-guild
169169

170170
# Data Streams Monitoring
171171
content/en/data_streams/*.md @Datadog/data-streams-monitoring @Datadog/documentation

content/en/ddsql_reference/_index.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ ORDER BY value DESC;{{< /code-block >}}
677677

678678
## Tags
679679

680-
DDSQL exposes tags as an `hstore` type, which you can query using the PostgreSQL arrow operator. For example:
680+
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:
681681

682682
```sql
683683
SELECT instance_type, count(instance_type)
@@ -686,7 +686,15 @@ WHERE tags->'region' = 'us-east-1' -- region is a tag, not a column
686686
GROUP BY instance_type
687687
```
688688

689-
Tags are key-value pairs where each key can have zero, one, or multiple values. When accessed, the tag value returns a string containing all corresponding values.
689+
Tags are key-value pairs where each key can have zero, one, or multiple tag values corresponding to it. When accessed, the tag value returns a single string, containing _all_ corresponding values. When the data has multiple tag values for the same tag key, they are represented as a sorted, comma-separated string. For example:
690+
691+
```sql
692+
SELECT tags->'team', instance_type, architecture, COUNT(*) as instance_count
693+
FROM aws.ec2_instance
694+
WHERE tags->'team' = 'compute_provisioning,database_ops'
695+
GROUP BY tags->'team', instance_type, architecture
696+
ORDER BY instance_count DESC
697+
```
690698

691699
You can also compare tag values as strings or entire tag sets:
692700

0 commit comments

Comments
 (0)