- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
Value expressions are the general expression language used to produce values for conditions, SELECT
expressions, filters, and clauses like WHERE
, ORDER BY
, and GROUP BY
. The expression syntax of DDSQL is a superset of SQL expression syntax.
DDSQL supports standard binary and unary infix arithmetic notation from SQL and many other languages:
Operator | Description | Example | Result |
---|---|---|---|
+ | addition | 2 + 3 | 5 |
- | subtraction | 2 - 3 | -1 |
* | multiplication | 2 * 3 | 6 |
/ | division (non-truncating) | 5 / 2 | 2.5 |
The standard order of operations applies. To control the order of operations, add parentheses: (5 - 2) * 3
.
DDSQL implements the following comparison operators:
Operator | Description | Example | Result |
---|---|---|---|
> | greater than | 2 > 3 | false |
< | less than | 2 < 3 | true |
>= | greater than or equals | 3 >= 2 | true |
<= | less than or equals | 3 <= 2 | false |
= | equals* | 3 = 3 | true |
!=, <> | not equals | 3 != 3 | false |
For tag references and tag groups, the equality operator (=
) is treated as a “contains” comparison. See the Querying Tags in DDSQL for more details.
Additionally, DDSQL supports the following SQL keywords, which function as standard boolean operators:
NOT
AND
OR
DDSQL also supports the following comparator keywords as they are defined in the SQL standard:
IS NULL
IS NOT NULL
LIKE
NOT LIKE
IN
NOT IN
DDSQL supports the BETWEEN
keyword such that a BETWEEN x AND y
is equivalent to a >= x AND a <= y
. See the Postgres documentation for BETWEEN
for details.
Name | Description |
---|---|
AND | Boolean logic, a & b |
OR | Boolean logic, a || b |
XOR | Boolean logic, a ^ b |
NOT | Boolean logic, !a |
IS NULL | Returns true for each row that is null |
The CASE
expression is a generic conditional expression, similar to if/else statements in other programming languages. CASE
comes in two forms, simple and searched.
Simple CASE statements use the following syntax:
CASE expression
WHEN value THEN result
[ WHEN ... ]
[ ELSE result ]
END
The expression is computed, then compared to each of the value expressions in the WHEN
clauses until one is found that is equal to it. If no match is found, the result of the ELSE
clause, or NULL
if ELSE
is omitted, is returned.
Searched CASE statements use the following syntax:
CASE
WHEN condition THEN result
[ WHEN ... ]
[ ELSE result ]
END
If a condition’s result is true, the value of the CASE
expression is the result that follows the condition, and the remainder of the CASE
expression is not processed. If the condition’s result is not true, any subsequent WHEN
clauses are examined in the same manner. If no WHEN
condition yields true, the value of the CASE
expression is the result of the ELSE
clause. If the ELSE
clause is omitted and no condition is true, the result is NULL
.
CAST
specifies a conversion from one data type to another.
CAST(expression AS type)
Not all types are convertible in this way.
DDSQL also supports Postgres casting syntax:
expression::type
For example, SELECT 1::text;
.