Skip to content

Consolidate DDSQL references #28821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 12 additions & 31 deletions config/_default/menus/main.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ menu:
pre: cloudcraft
identifier: cloudcraft
parent: essentials_heading
weight: 270000
weight: 130000
- name: Getting Started
url: cloudcraft/getting-started/
identifier: cloudcraft_getting_started
Expand Down Expand Up @@ -1318,6 +1318,12 @@ menu:
identifier: cloudcraft_api_users_info
parent: cloudcraft_api_users
weight: 1
- name: DDSQL Reference
url: ddsql_reference/
pre: ddsql
identifier: ddsql_reference
parent: essentials_heading
weight: 140000
- name: Watchdog
url: watchdog/
identifier: watchdog_top_level
Expand Down Expand Up @@ -1537,36 +1543,16 @@ menu:
parent: ddsql_editor
identifier: ddsql_editor_getting_started
weight: 1
- name: Statements
url: ddsql_editor/reference/statements
parent: ddsql_editor
identifier: ddsql_editor_statements
weight: 2
- name: Expressions and Operators
url: ddsql_editor/reference/expressions_and_operators
parent: ddsql_editor
identifier: ddsql_editor_expressions_and_operators
weight: 3
- name: Data Types
url: ddsql_editor/reference/data_types
parent: ddsql_editor
identifier: ddsql_editor_data_types
weight: 4
- name: Functions
url: ddsql_editor/reference/functions
parent: ddsql_editor
identifier: ddsql_editor_functions
weight: 5
- name: Querying Tags
url: ddsql_editor/reference/tags
url: ddsql_editor/tags
parent: ddsql_editor
identifier: ddsql_editor_tags
weight: 6
weight: 2
- name: Querying Reference Tables
url: ddsql_editor/reference_tables
parent: ddsql_editor
identifier: ddsql_editor_reference_tables
weight: 7
weight: 3
- name: Guides
url: ddsql_editor/guide
parent: ddsql_editor
Expand Down Expand Up @@ -5875,21 +5861,16 @@ menu:
parent: log_management
identifier: logs_workspaces
weight: 6
- name: SQL Reference
url: logs/workspaces/sql_reference/
parent: logs_workspaces
identifier: logs_workspaces_sql_reference
weight: 601
- name: Use Cases
url: logs/workspaces/use_cases/
parent: logs_workspaces
identifier: logs_workspaces_use_cases
weight: 602
weight: 601
- name: Time Selection
url: logs/workspaces/time_selection/
parent: logs_workspaces
identifier: logs_workspaces_time_selection
weight: 603
weight: 602
- name: Error Tracking
url: logs/error_tracking/
parent: log_management
Expand Down
2 changes: 2 additions & 0 deletions config/_default/params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ code_language_ids:
apache: "Apache HTTP Server"
ibm: "IBM HTTP Server"
gcp-service-extensions: "GCP Service Extensions"
ddsql_editor_syntax: "DDSQL Editor Syntax (Preview)"
ddsql_default: "DDSQL"
branch: ""

signupclass: sign-up-trigger
Expand Down
21 changes: 8 additions & 13 deletions content/en/ddsql_editor/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
title: DDSQL Editor
aliases:
- /dashboards/ddsql_editor/
- /ddsql_editor/reference/
further_reading:
- link: "/ddsql_editor/reference"
tag: "Documentation"
text: "References for DDSQL Queries"
- link: "/ddsql_editor/guide/ddsql_use_cases"
tag: "Guide"
text: "Common queries and use cases"
- link: "/ddsql_reference/ddsql_editor_syntax"
tag: "Documentation"
text: "DDSQL Editor Syntax (Preview)"
---


Expand All @@ -33,21 +32,17 @@ Type your question into the search box, and Datadog builds the SQL query for you

DDSQL is a query language for Datadog data. It implements several standard SQL operations, such as `SELECT`, and allows queries against unstructured data, such as [tags][2]. Get exactly the data you want by writing your own `SELECT` statement. Query tags as if they are standard table columns.

<div class="alert alert-warning">
There are two different <strong>variants</strong> of DDSQL. For the <strong>DDSQL Editor</strong>, use the syntax documented in the <a href="/ddsql_reference/ddsql_editor_syntax">DDSQL Editor syntax documentation</a>.
</div>

{{< code-block lang="sql" >}}
SELECT instance_type, count(instance_type)
FROM aws_ec2_instance
WHERE env = 'staging' -- env is a tag, not a column
GROUP BY instance_type
{{< /code-block >}}

{{< whatsnext desc="For more information on DDSQL queries, see the DDSQL References:" >}}
{{< nextlink href="ddsql_editor/reference/functions" >}}Functions{{< /nextlink >}}
{{< nextlink href="ddsql_editor/reference/data_types" >}}Data Types{{< /nextlink >}}
{{< nextlink href="ddsql_editor/reference/expressions_and_operators" >}}Expressions and Operators{{< /nextlink >}}
{{< nextlink href="ddsql_editor/reference/statements" >}}Statements{{< /nextlink >}}
{{< nextlink href="ddsql_editor/reference/tags" >}}Tags{{< /nextlink >}}
{{< /whatsnext >}}

### Explore your infrastructure data

View and filter the list of tables and fields in the schema side panel:
Expand Down Expand Up @@ -77,7 +72,7 @@ To access the DDSQL Editor app, users need the `ddsql_editor_read` permission. T
{{< partial name="whats-next/whats-next.html" >}}

[1]: https://app.datadoghq.com/ddsql/editor
[2]: /dashboards/ddsql_editor/reference/tags
[2]: /ddsql_editor/tags
[3]: /account_management/rbac/
[4]: /bits_ai
[5]: /help/
2 changes: 1 addition & 1 deletion content/en/ddsql_editor/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ If you forget to save a useful query before navigating away from it, you can sti

[1]: https://app.datadoghq.com/ddsql/editor
[2]: /ddsql_editor/#use-sql-syntax-ddsql
[3]: /ddsql_editor/reference/tags
[3]: /ddsql_editor/tags
11 changes: 11 additions & 0 deletions content/en/ddsql_editor/reference_tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@ further_reading:
- link: "/integrations/guide/reference-tables/"
tag: "Documentation"
text: "Add Custom Metadata with Reference Tables"
- link: "/ddsql_reference/ddsql_editor_syntax"
tag: "Documentation"
text: "DDSQL Editor Syntax (Preview)"
---

{{< callout url="https://datadoghq.com/private-beta/ddsql-editor">}}
The DDSQL Editor is in Preview.
{{< /callout >}}

<div class="alert alert-warning">
There are two different <strong>variants</strong> of DDSQL. For the <strong>DDSQL Editor</strong>, use the syntax documented in the <a href="/ddsql_reference/ddsql_editor_syntax">DDSQL Editor syntax documentation</a>.
</div>

# Overview

Reference Tables allow you to combine metadata with information already in Datadog. These tables store predefined sets of information that can be easily referenced within your queries, reducing complexity and enhancing query performance. With DDSQL you can query and join reference tables with other tables to expand your analytical insights.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@
title: Querying Tags in DDSQL
aliases:
- /dashboards/ddsql_editor/reference/tags/
- /ddsql_editor/reference/tags/
further_reading:
- link: "/ddsql_reference/ddsql_editor_syntax"
tag: "Documentation"
text: "DDSQL Editor Syntax (Preview)"
---

{{< callout url="https://datadoghq.com/private-beta/ddsql-editor">}}
DDSQL is in Preview.
The DDSQL Editor is in Preview.
{{< /callout >}}

<div class="alert alert-warning">
There are two different <strong>variants</strong> of DDSQL. For the <strong>DDSQL Editor</strong>, use the syntax documented in the <a href="/ddsql_reference/ddsql_editor_syntax">DDSQL Editor syntax documentation</a>.
</div>

Tags are a widespread mechanism to encode metadata about a particular record across several products at Datadog. Tags are key-value pairs for which a key may contain multiple values.

Tags are modeled in DDSQL with the key as a column name, and values in a `group` type, a sorted set of strings with tag-like "= is contains" semantics.
Expand Down Expand Up @@ -66,3 +75,7 @@ SELECT #service FROM resources.host
The tag's name in the projection is `#service`, which should be used throughout the query, as `service` refers to the schema column.

For tag references that require quoting, the `#` should appear outside of quotes (for example, `#"availability-zone"`). This is necessary to differentiate between explicit tag references and columns that start with a `#` character.

## Further reading

{{< partial name="whats-next/whats-next.html" >}}
28 changes: 28 additions & 0 deletions content/en/ddsql_reference/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: DDSQL Reference
type: multi-code-lang
external_redirect: /ddsql_reference/ddsql_default
further_reading:
- link: "/ddsql_editor"
tag: "Documentation"
text: "Learn more about the DDSQL Editor"
---

## Supported DDSQL Syntax

DDSQL is a query language for Datadog data. It implements several standard SQL operations, such as `SELECT`, and allows queries against unstructured data, such as [tags][1]. Get exactly the data you want by writing your own `SELECT` statement. Query tags as if they are standard table columns.

<div class="alert alert-warning">
There are two different <strong>variants</strong> of DDSQL. For the <strong>DDSQL Editor</strong>, use the syntax documented in the <a href="/ddsql_reference/ddsql_editor_syntax">DDSQL Editor syntax documentation</a>.
</div>

{{< whatsnext desc="Syntax references:" >}}
{{< nextlink href="/ddsql_reference/ddsql_default" >}}DDSQL{{< /nextlink >}}
{{< nextlink href="/ddsql_reference/ddsql_editor_syntax" >}}DDSQL Editor Syntax (Preview){{< /nextlink >}}
{{< /whatsnext >}}

## Further reading

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

[1]: /ddsql_editor/tags
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
---
title: SQL Reference
title: DDSQL
aliases:
- /logs/workspaces/sql_reference
code_lang: ddsql_default
type: multi-code-lang
code_lang_weight: 1
products:
- name: Log Workspaces
url: /logs/workspaces/
icon: logs
further_reading:
- link: "/logs/workspaces/"
tag: "Documentation"
text: "Learn more about Log Workspaces"
---

{{< product-availability >}}

<div class="alert alert-warning">
There are two different <strong>variants</strong> of DDSQL. For the <strong>DDSQL Editor</strong>, use the syntax documented in the <a href="/ddsql_reference/ddsql_editor_syntax">DDSQL Editor syntax documentation</a>.
</div>

## Overview

SQL in [Analysis cells][1] allows you to analyze and manipulate data within Log Workspaces. This documentation covers the SQL support available in Log Workspaces and includes:
SQL in [Analysis cells][1] allows you to analyze and manipulate data. This documentation covers the SQL support available and includes:
- [Syntax compatible with PostgreSQL](#syntax)
- [SQL functions](#functions)
- [Window functions](#window-functions)
Expand Down Expand Up @@ -217,23 +232,23 @@ SELECT
### `TRIM`
{{< code-block lang="sql" >}}
SELECT
TRIM(name) AS trimmed_name
trim(name) AS trimmed_name
FROM
users
{{< /code-block >}}

### `REPLACE`
{{< code-block lang="sql" >}}
SELECT
REPLACE(description, 'old', 'new') AS updated_description
replace(description, 'old', 'new') AS updated_description
FROM
products
{{< /code-block >}}

### `SUBSTRING`
{{< code-block lang="sql" >}}
SELECT
SUBSTRING(title, 1, 10) AS short_title
substring(title, 1, 10) AS short_title
FROM
books
{{< /code-block >}}
Expand Down Expand Up @@ -270,7 +285,7 @@ Supported extraction units:

{{< code-block lang="sql" >}}
SELECT
EXTRACT(year FROM purchase_date) AS purchase_year
extract(year FROM purchase_date) AS purchase_year
FROM
sales
{{< /code-block >}}
Expand All @@ -297,7 +312,7 @@ Supported patterns for date/time formatting:

{{< code-block lang="sql" >}}
SELECT
TO_TIMESTAMP('25/12/2025 04:23 pm', 'DD/MM/YYYY HH:MI am') AS ts
to_timestamp('25/12/2025 04:23 pm', 'DD/MM/YYYY HH:MI am') AS ts
{{< /code-block >}}

### `TO_CHAR`
Expand All @@ -322,7 +337,7 @@ Supported patterns for date/time formatting:

{{< code-block lang="sql" >}}
SELECT
TO_CHAR(order_date, 'MM-DD-YYYY') AS formatted_date
to_char(order_date, 'MM-DD-YYYY') AS formatted_date
FROM
orders
{{< /code-block >}}
Expand All @@ -342,7 +357,7 @@ Supported truncations:

{{< code-block lang="sql" >}}
SELECT
DATE_TRUNC('month', event_time) AS month_start
date_trunc('month', event_time) AS month_start
FROM
events
{{< /code-block >}}
Expand All @@ -354,7 +369,7 @@ SELECT
FROM
emails
WHERE
REGEXP_LIKE(email_address, '@example\.com$')
regexp_like(email_address, '@example\.com$')
{{< /code-block >}}

### `CARDINALITY`
Expand Down Expand Up @@ -406,19 +421,19 @@ FROM

## Window functions

This table provides an overview of the supprted window functions. For comprehensive details and examples, see to the [PostgreSQL documentation][2].

| Function | Return Type | Description |
|-------------------------------|-------------------|------------------------------------------------------------------------|
| `over` | N/A | Defines a window for a set of rows for other window functions to operate on. |
| `partition by` | N/A | Divides the result set into partitions, specifically for applying window functions. |
| `rank()` | integer | Assigns a rank to each row within a partition, with gaps for ties. |
| `row_number()` | integer | Assigns a unique sequential number to each row within a partition. |
| `lead(column n)` | typeof column | Returns the value from the next row in the partition. |
| `lag(column n)` | typeof column | Returns the value from the previous row in the partition. |
| `first_value(column n)` | typeof column | Returns the first value in an ordered set of values. |
| `last_value(column n)` | typeof column | Returns the last value in an ordered set of values. |
| `nth_value(column n, offset)` | typeof column | Returns the value at the specified offset in an ordered set of values. |
This table provides an overview of the supprted window functions. For comprehensive details and examples, see the [PostgreSQL documentation][2].

| Function | Return Type | Description |
|-------------------------|-------------------|------------------------------------------------------------------------|
| `OVER` | N/A | Defines a window for a set of rows for other window functions to operate on. |
| `PARTITION BY` | N/A | Divides the result set into partitions, specifically for applying window functions. |
| `RANK()` | integer | Assigns a rank to each row within a partition, with gaps for ties. |
| `ROW_NUMBER()` | integer | Assigns a unique sequential number to each row within a partition. |
| `LEAD(column n)` | typeof column | Returns the value from the next row in the partition. |
| `LAG(column n)` | typeof column | Returns the value from the previous row in the partition. |
| `FIRST_VALUE(column n)` | typeof column | Returns the first value in an ordered set of values. |
| `LAST_VALUE(column n)` | typeof column | Returns the last value in an ordered set of values. |
| `NTH_VALUE(column n, offset)`| typeof column | Returns the value at the specified offset in an ordered set of values. |


## Further reading
Expand Down
25 changes: 25 additions & 0 deletions content/en/ddsql_reference/ddsql_editor_syntax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: DDSQL Editor Syntax (Preview)
code_lang: ddsql_editor_syntax
type: multi-code-lang
code_lang_weight: 2
further_reading:
- link: "/ddsql_editor/"
tag: "Documentation"
text: "Learn more about the DDSQL Editor"
---

{{< callout url="https://datadoghq.com/private-beta/ddsql-editor">}}
DDSQL Editor is in Preview.
{{< /callout >}}

{{< whatsnext desc="For more information on DDSQL queries, see the DDSQL References:" >}}
{{< nextlink href="ddsql_reference/ddsql_editor_syntax/functions" >}}Functions{{< /nextlink >}}
{{< nextlink href="ddsql_reference/ddsql_editor_syntax/data_types" >}}Data Types{{< /nextlink >}}
{{< nextlink href="ddsql_reference/ddsql_editor_syntax/expressions_and_operators" >}}Expressions and Operators{{< /nextlink >}}
{{< nextlink href="ddsql_reference/ddsql_editor_syntax/statements" >}}Statements{{< /nextlink >}}
{{< /whatsnext >}}

## Further reading

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