Skip to content
Draft
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
12 changes: 11 additions & 1 deletion docs/reference/sql/tql.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The `TQL` keyword executes TQL language in SQL. The TQL is Time-Series Query Lan
### Syntax

```sql
TQL [EVAL | EVALUATE] (start, end, step) expr
TQL [EVAL | EVALUATE] (start, end, step) expr [AS alias]
```

The `start`, `end` and `step` are the query parameters just like [Prometheus Query API](https://prometheus.io/docs/prometheus/latest/querying/api/):
Expand All @@ -23,6 +23,8 @@ The `start`, `end` and `step` are the query parameters just like [Prometheus Que

The `expr` is the TQL expression query string.

The optional `AS alias` clause allows you to provide an alias for the query result. This is useful for giving meaningful names to the output columns.

### Examples

Return the per-second rate for all time series with the `http_requests_total` metric name, as measured over the last 5 minutes:
Expand All @@ -33,6 +35,14 @@ TQL eval (1677057993, 1677058993, '1m') rate(prometheus_http_requests_total{job=

will get a result just like other normal SQL queries.

You can also use value aliasing to give a meaningful name to your query result:

```sql
TQL eval (0, 10, '5s') {__name__="test"} AS test_series;
```

This will return the results with the column named `test_series` instead of the default column name.

## EXPLAIN

`EXPLAIN` displays both the logical plan and execution plan for a given PromQL query. The syntax is as follows:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ description: 介绍了 `TQL` 关键字及其在 GreptimeDB 中的用法,包括
### Syntax

```sql
TQL [EVAL | EVALUATE] (start, end, step) expr
TQL [EVAL | EVALUATE] (start, end, step) expr [AS alias]
```

`start`, `end` 和 `step` 是查询参数,就像 [Prometheus Query API](https://prometheus.io/docs/prometheus/latest/querying/api/) 一样:
Expand All @@ -23,6 +23,8 @@ TQL [EVAL | EVALUATE] (start, end, step) expr

`expr` 是 TQL 表达式查询字符串。

可选的 `AS alias` 子句允许你为查询结果提供别名。这有助于为输出列提供有意义的名称。

### 示例

返回过去 5 分钟内 `http_requests_total` 指标的所有时间序列的每秒值:
Expand All @@ -33,6 +35,14 @@ TQL eval (1677057993, 1677058993, '1m') rate(prometheus_http_requests_total{job=

其查询结果和 SQL 查询结果类似。

你也可以使用值别名为查询结果提供有意义的名称:

```sql
TQL eval (0, 10, '5s') {__name__="test"} AS test_series;
```

这将返回列名为 `test_series` 而不是默认列名的结果。

## EXPLAIN

`EXPLAIN` 展示特定 PromQL 查询的逻辑计划和执行计划,其语法如下:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ description: 介绍了 `TQL` 关键字及其在 GreptimeDB 中的用法,包括
### Syntax

```sql
TQL [EVAL | EVALUATE] (start, end, step) expr
TQL [EVAL | EVALUATE] (start, end, step) expr [AS alias]
```

`start`, `end` 和 `step` 是查询参数,就像 [Prometheus Query API](https://prometheus.io/docs/prometheus/latest/querying/api/) 一样:
Expand All @@ -23,6 +23,8 @@ TQL [EVAL | EVALUATE] (start, end, step) expr

`expr` 是 TQL 表达式查询字符串。

可选的 `AS alias` 子句允许你为查询结果提供别名。这有助于为输出列提供有意义的名称。

### 示例

返回过去 5 分钟内 `http_requests_total` 指标的所有时间序列的每秒值:
Expand All @@ -33,6 +35,14 @@ TQL eval (1677057993, 1677058993, '1m') rate(prometheus_http_requests_total{job=

其查询结果和 SQL 查询结果类似。

你也可以使用值别名为查询结果提供有意义的名称:

```sql
TQL eval (0, 10, '5s') {__name__="test"} AS test_series;
```

这将返回列名为 `test_series` 而不是默认列名的结果。

## EXPLAIN

`EXPLAIN` 展示特定 PromQL 查询的逻辑计划和执行计划,其语法如下:
Expand Down
12 changes: 11 additions & 1 deletion versioned_docs/version-0.17/reference/sql/tql.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The `TQL` keyword executes TQL language in SQL. The TQL is Time-Series Query Lan
### Syntax

```sql
TQL [EVAL | EVALUATE] (start, end, step) expr
TQL [EVAL | EVALUATE] (start, end, step) expr [AS alias]
```

The `start`, `end` and `step` are the query parameters just like [Prometheus Query API](https://prometheus.io/docs/prometheus/latest/querying/api/):
Expand All @@ -23,6 +23,8 @@ The `start`, `end` and `step` are the query parameters just like [Prometheus Que

The `expr` is the TQL expression query string.

The optional `AS alias` clause allows you to provide an alias for the query result. This is useful for giving meaningful names to the output columns.

### Examples

Return the per-second rate for all time series with the `http_requests_total` metric name, as measured over the last 5 minutes:
Expand All @@ -33,6 +35,14 @@ TQL eval (1677057993, 1677058993, '1m') rate(prometheus_http_requests_total{job=

will get a result just like other normal SQL queries.

You can also use value aliasing to give a meaningful name to your query result:

```sql
TQL eval (0, 10, '5s') {__name__="test"} AS test_series;
```

This will return the results with the column named `test_series` instead of the default column name.

## EXPLAIN

`EXPLAIN` displays both the logical plan and execution plan for a given PromQL query. The syntax is as follows:
Expand Down