From c91b759e1139621721ad732457ba1957f2e40495 Mon Sep 17 00:00:00 2001 From: Bradley Besserman Date: Fri, 22 Aug 2025 13:57:05 -0400 Subject: [PATCH 1/3] [DDSQL] DDSQL type and type literal docs --- content/en/ddsql_reference/_index.md | 58 ++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/content/en/ddsql_reference/_index.md b/content/en/ddsql_reference/_index.md index e2e838aa898..80b7409dac4 100644 --- a/content/en/ddsql_reference/_index.md +++ b/content/en/ddsql_reference/_index.md @@ -24,6 +24,8 @@ DDSQL is SQL for Datadog data. It implements several standard SQL operations, su This documentation covers the SQL support available and includes: - [Syntax compatible with PostgreSQL](#syntax) +- [Data types](#data-types) +- [Type literals](#type-literals) - [SQL functions](#functions) - [Window functions](#window-functions) - [JSON functions](#json-functions-and-operators) @@ -88,6 +90,62 @@ FROM employees {{< /code-block >}} | FROM products {{< /code-block >}} | | `INTERVAL value unit` | interval | Represents a time duration specified in a given unit. Supported units:
- `milliseconds` / `millisecond`
- `seconds` / `second`
- `minutes` / `minute`
- `hours` / `hour`
- `days` / `day` | +## Data types + +DDSQL supports the following data types: + +| Data Type | Description | +|-----------|-------------| +| `BIGINT` | 64-bit signed integers | +| `BOOLEAN` | True or false values | +| `DOUBLE` | Double-precision floating-point numbers | +| `INTERVAL` | Time duration values | +| `JSON` | JSON data | +| `TIMESTAMP` | Date and time values | +| `VARCHAR` | Variable-length character strings | + +### Array types + +All data types except `JSON` support array types. Arrays can contain multiple values of the same data type. + +## Type literals + +DDSQL supports explicit type literals using the syntax `[TYPE] [value]`. + +| Type | Syntax | Example | +|------|--------|---------| +| `BIGINT` | `BIGINT value` | `BIGINT 1234567` | +| `BOOLEAN` | `BOOLEAN value` | `BOOLEAN true` | +| `DOUBLE` | `DOUBLE value` | `DOUBLE 3.14159` | +| `INTERVAL` | `INTERVAL 'value unit'` | `INTERVAL '30 minutes'` | +| `JSON` | `JSON 'value'` | `JSON '{"key": "value", "count": 42}'` | +| `TIMESTAMP` | `TIMESTAMP 'value'` | `TIMESTAMP '2023-12-25 10:30:00'` | +| `VARCHAR` | `VARCHAR 'value'` | `VARCHAR 'hello world'` | + +The type prefix can be omitted and the type will be automatically inferred from the value. For example, `'hello world'` will be inferred as `VARCHAR`, `123` as `BIGINT`, and `true` as `BOOLEAN`. + +### Array literals + +Array literals use the syntax `ARRAY[value1, value2, ...]`. The array type is automatically inferred from the values. + +{{< code-block lang="sql" >}} +SELECT ARRAY['apple', 'banana', 'cherry'] AS fruits; -- Inferred as VARCHAR array +SELECT ARRAY[1, 2, 3] AS numbers; -- Inferred as BIGINT array +SELECT ARRAY[true, false, true] AS flags; -- Inferred as BOOLEAN array +SELECT ARRAY[1.1, 2.2, 3.3] AS decimals; -- Inferred as DOUBLE array +{{< /code-block >}} + +### Example + +{{< code-block lang="sql" >}} +-- Using type literals in queries +SELECT + VARCHAR 'Product Name: ' || name AS labeled_name, + price * DOUBLE 1.08 AS price_with_tax, + created_at + INTERVAL '7 days' AS expiry_date +FROM products +WHERE active = BOOLEAN true; +{{< /code-block >}} ## Functions From 39d0d943a5fe60dcdb14f4a72f56568d91e8c292 Mon Sep 17 00:00:00 2001 From: Bradley Besserman Date: Mon, 25 Aug 2025 11:35:50 -0400 Subject: [PATCH 2/3] Update type inference phrasing Co-authored-by: May Lee --- content/en/ddsql_reference/_index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/ddsql_reference/_index.md b/content/en/ddsql_reference/_index.md index 80b7409dac4..85a0b4aa6cd 100644 --- a/content/en/ddsql_reference/_index.md +++ b/content/en/ddsql_reference/_index.md @@ -122,7 +122,7 @@ DDSQL supports explicit type literals using the syntax `[TYPE] [value]`. | `TIMESTAMP` | `TIMESTAMP 'value'` | `TIMESTAMP '2023-12-25 10:30:00'` | | `VARCHAR` | `VARCHAR 'value'` | `VARCHAR 'hello world'` | -The type prefix can be omitted and the type will be automatically inferred from the value. For example, `'hello world'` will be inferred as `VARCHAR`, `123` as `BIGINT`, and `true` as `BOOLEAN`. +The type prefix can be omitted and the type is automatically inferred from the value. For example, `'hello world'` is inferred as `VARCHAR`, `123` as `BIGINT`, and `true` as `BOOLEAN`. ### Array literals From 08a99623c4f92658ab7acf90f2acb7993998b1f3 Mon Sep 17 00:00:00 2001 From: Bradley Besserman Date: Mon, 25 Aug 2025 11:36:04 -0400 Subject: [PATCH 3/3] Update boolean type description Co-authored-by: May Lee --- content/en/ddsql_reference/_index.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/content/en/ddsql_reference/_index.md b/content/en/ddsql_reference/_index.md index 85a0b4aa6cd..a678fac791b 100644 --- a/content/en/ddsql_reference/_index.md +++ b/content/en/ddsql_reference/_index.md @@ -96,13 +96,13 @@ DDSQL supports the following data types: | Data Type | Description | |-----------|-------------| -| `BIGINT` | 64-bit signed integers | -| `BOOLEAN` | True or false values | -| `DOUBLE` | Double-precision floating-point numbers | -| `INTERVAL` | Time duration values | -| `JSON` | JSON data | -| `TIMESTAMP` | Date and time values | -| `VARCHAR` | Variable-length character strings | +| `BIGINT` | 64-bit signed integers. | +| `BOOLEAN` | `true` or `false` values. | +| `DOUBLE` | Double-precision floating-point numbers. | +| `INTERVAL` | Time duration values. | +| `JSON` | JSON data. | +| `TIMESTAMP` | Date and time values. | +| `VARCHAR` | Variable-length character strings. | ### Array types