Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
query()
Browse files Browse the repository at this point in the history
DongLiang-0 committed Jan 17, 2025

Verified

This commit was signed with the committer’s verified signature.
SergeyKopienko Sergey Kopienko
1 parent 87b3a9a commit bebcc47
Showing 6 changed files with 172 additions and 178 deletions.
59 changes: 29 additions & 30 deletions docs/sql-manual/sql-functions/table-valued-functions/query.md
Original file line number Diff line number Diff line change
@@ -24,69 +24,66 @@ specific language governing permissions and limitations
under the License.
-->

## query

### Name

query

### description
## Description

Query table function (table-valued-function, tvf) can be used to transparently transmit query statements directly to a catalog for data query

:::info note
Supported by Doris version 2.1.3, currently only transparent query jdbc catalog is supported.
You need to create the corresponding catalog in Doris first.
:::

#### syntax

## Syntax

```sql
query(
"catalog" = "catalog_name",
"query" = "select * from db_name.table_name where condition"
QUERY(
"catalog" = "<catalog>",
"query" = "<query_sql>"
);
```

**Parameter Description**

## Required Parameters
Each parameter in the query table function tvf is a `"key"="value"` pair.
Related parameters:
- `catalog`: (required) catalog name, which needs to be filled in according to the name of the catalog.
- `query`: (required) The query statement to be executed.

### Example
| Field | Description |
|------------|--------------------------------------------|
| `catalog` | Catalog name, which needs to be filled in according to the name of the catalog. |
| `query` | The query statement to be executed. |

Use the query function to query tables in the jdbc data source

```sql
select * from query("catalog" = "jdbc", "query" = "select * from db_name.table_name where condition");
```
## Examples

Can be used with `desc function`

```sql
desc function query("catalog" = "jdbc", "query" = "select * from db_name.table_name where condition");
desc function query("catalog" = "jdbc", "query" = "select * from test.student");
```
```text
+-------+------+------+-------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------+------+-------+---------+-------+
| id | int | Yes | true | NULL | |
| name | text | Yes | false | NULL | NONE |
+-------+------+------+-------+---------+-------+
```

### Keywords

query, table-valued-function, tvf

### Best Prac

Transparent query for tables in jdbc catalog data source

```sql
select * from query("catalog" = "jdbc", "query" = "select * from test.student");
```
```text
+------+---------+
| id | name |
+------+---------+
| 1 | alice |
| 2 | bob |
| 3 | jack |
+------+---------+
```
```sql
select * from query("catalog" = "jdbc", "query" = "select * from test.score");
```
```text
+------+---------+
| id | score |
+------+---------+
@@ -100,6 +97,8 @@ Transparent join query for tables in jdbc catalog data source

```sql
select * from query("catalog" = "jdbc", "query" = "select a.id, a.name, b.score from test.student a join test.score b on a.id = b.id");
```
```
+------+---------+---------+
| id | name | score |
+------+---------+---------+
Original file line number Diff line number Diff line change
@@ -24,69 +24,66 @@ specific language governing permissions and limitations
under the License.
-->

## query

### Name

query

## 描述

query 表函数(table-valued-function,tvf),可用于将查询语句直接透传到某个 catalog 进行数据查询

:::info note
Doris 2.1.3 版本开始支持,当前仅支持透传查询 jdbc catalog。
需要先在 Doris 中创建对应的 catalog。
:::

## 语法

```sql
query(
"catalog" = "catalog_name",
"query" = "select * from db_name.table_name where condition"
QUERY(
"catalog" = "<catalog>",
"query" = "<query_sql>"
);
```

**参数说明**
## 必填参数
query表函数 tvf中的每一个参数都是一个 `"key"="value"`

query表函数 tvf中的每一个参数都是一个 `"key"="value"` 对。
相关参数:
- `catalog`: (必填) catalog名称,需要按照catalog的名称填写
- `query`: (必填) 需要执行的查询语句
| 字段 | 描述 |
|--------------|----------------------------|
| `catalog` | catalog名称,需要按照catalog的名称填写 |
| `query` | 需要执行的查询语句 |

## 举例

使用 query 函数查询 jdbc 数据源中的表

```sql
select * from query("catalog" = "jdbc", "query" = "select * from db_name.table_name where condition");
```
## 举例

可以配合`desc function`使用

```sql
desc function query("catalog" = "jdbc", "query" = "select * from db_name.table_name where condition");
desc function query("catalog" = "jdbc", "query" = "select * from test.student");
```
```text
+-------+------+------+-------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------+------+-------+---------+-------+
| id | int | Yes | true | NULL | |
| name | text | Yes | false | NULL | NONE |
+-------+------+------+-------+---------+-------+
```

### Keywords

query, table-valued-function, tvf

### Best Prac

透传查询 jdbc catalog 数据源中的表

```sql
select * from query("catalog" = "jdbc", "query" = "select * from test.student");
```
```text
+------+---------+
| id | name |
+------+---------+
| 1 | alice |
| 2 | bob |
| 3 | jack |
+------+---------+
```
```sql
select * from query("catalog" = "jdbc", "query" = "select * from test.score");
```
```text
+------+---------+
| id | score |
+------+---------+
@@ -100,6 +97,8 @@ select * from query("catalog" = "jdbc", "query" = "select * from test.score");

```sql
select * from query("catalog" = "jdbc", "query" = "select a.id, a.name, b.score from test.student a join test.score b on a.id = b.id");
```
```
+------+---------+---------+
| id | name | score |
+------+---------+---------+
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
{
"title": "QUERY",
"language": "zh-CN"
"title": "QUERY",
"language": "zh-CN"
}
---

@@ -24,69 +24,66 @@ specific language governing permissions and limitations
under the License.
-->

## query

### Name

query

## 描述

query 表函数(table-valued-function,tvf),可用于将查询语句直接透传到某个 catalog 进行数据查询

:::info note
Doris 2.1.3 版本开始支持,当前仅支持透传查询 jdbc catalog。
需要先在 Doris 中创建对应的 catalog。
:::

## 语法

```sql
query(
"catalog" = "catalog_name",
"query" = "select * from db_name.table_name where condition"
QUERY(
"catalog" = "<catalog>",
"query" = "<query_sql>"
);
```

**参数说明**
## 必填参数
query表函数 tvf中的每一个参数都是一个 `"key"="value"`

query表函数 tvf中的每一个参数都是一个 `"key"="value"` 对。
相关参数:
- `catalog`: (必填) catalog名称,需要按照catalog的名称填写
- `query`: (必填) 需要执行的查询语句
| 字段 | 描述 |
|--------------|----------------------------|
| `catalog` | catalog名称,需要按照catalog的名称填写 |
| `query` | 需要执行的查询语句 |

## 举例

使用 query 函数查询 jdbc 数据源中的表

```sql
select * from query("catalog" = "jdbc", "query" = "select * from db_name.table_name where condition");
```
## 举例

可以配合`desc function`使用

```sql
desc function query("catalog" = "jdbc", "query" = "select * from db_name.table_name where condition");
desc function query("catalog" = "jdbc", "query" = "select * from test.student");
```
```text
+-------+------+------+-------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------+------+-------+---------+-------+
| id | int | Yes | true | NULL | |
| name | text | Yes | false | NULL | NONE |
+-------+------+------+-------+---------+-------+
```

### Keywords

query, table-valued-function, tvf

### Best Prac

透传查询 jdbc catalog 数据源中的表

```sql
select * from query("catalog" = "jdbc", "query" = "select * from test.student");
```
```text
+------+---------+
| id | name |
+------+---------+
| 1 | alice |
| 2 | bob |
| 3 | jack |
+------+---------+
```
```sql
select * from query("catalog" = "jdbc", "query" = "select * from test.score");
```
```text
+------+---------+
| id | score |
+------+---------+
@@ -100,6 +97,8 @@ select * from query("catalog" = "jdbc", "query" = "select * from test.score");

```sql
select * from query("catalog" = "jdbc", "query" = "select a.id, a.name, b.score from test.student a join test.score b on a.id = b.id");
```
```
+------+---------+---------+
| id | name | score |
+------+---------+---------+
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
{
"title": "QUERY",
"language": "zh-CN"
"title": "QUERY",
"language": "zh-CN"
}
---

@@ -24,69 +24,66 @@ specific language governing permissions and limitations
under the License.
-->

## query

### Name

query

## 描述

query 表函数(table-valued-function,tvf),可用于将查询语句直接透传到某个 catalog 进行数据查询

:::info note
Doris 2.1.3 版本开始支持,当前仅支持透传查询 jdbc catalog。
需要先在 Doris 中创建对应的 catalog。
:::

## 语法

```sql
query(
"catalog" = "catalog_name",
"query" = "select * from db_name.table_name where condition"
QUERY(
"catalog" = "<catalog>",
"query" = "<query_sql>"
);
```

**参数说明**
## 必填参数
query表函数 tvf中的每一个参数都是一个 `"key"="value"`

query表函数 tvf中的每一个参数都是一个 `"key"="value"` 对。
相关参数:
- `catalog`: (必填) catalog名称,需要按照catalog的名称填写
- `query`: (必填) 需要执行的查询语句
| 字段 | 描述 |
|--------------|----------------------------|
| `catalog` | catalog名称,需要按照catalog的名称填写 |
| `query` | 需要执行的查询语句 |

## 举例

使用 query 函数查询 jdbc 数据源中的表

```sql
select * from query("catalog" = "jdbc", "query" = "select * from db_name.table_name where condition");
```
## 举例

可以配合`desc function`使用

```sql
desc function query("catalog" = "jdbc", "query" = "select * from db_name.table_name where condition");
desc function query("catalog" = "jdbc", "query" = "select * from test.student");
```
```text
+-------+------+------+-------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------+------+-------+---------+-------+
| id | int | Yes | true | NULL | |
| name | text | Yes | false | NULL | NONE |
+-------+------+------+-------+---------+-------+
```

### Keywords

query, table-valued-function, tvf

### Best Prac

透传查询 jdbc catalog 数据源中的表

```sql
select * from query("catalog" = "jdbc", "query" = "select * from test.student");
```
```text
+------+---------+
| id | name |
+------+---------+
| 1 | alice |
| 2 | bob |
| 3 | jack |
+------+---------+
```
```sql
select * from query("catalog" = "jdbc", "query" = "select * from test.score");
```
```text
+------+---------+
| id | score |
+------+---------+
@@ -100,6 +97,8 @@ select * from query("catalog" = "jdbc", "query" = "select * from test.score");

```sql
select * from query("catalog" = "jdbc", "query" = "select a.id, a.name, b.score from test.student a join test.score b on a.id = b.id");
```
```
+------+---------+---------+
| id | name | score |
+------+---------+---------+
Original file line number Diff line number Diff line change
@@ -24,69 +24,66 @@ specific language governing permissions and limitations
under the License.
-->

## query

### Name

query

### description
## Description

Query table function (table-valued-function, tvf) can be used to transparently transmit query statements directly to a catalog for data query

:::info note
Supported by Doris version 2.1.3, currently only transparent query jdbc catalog is supported.
You need to create the corresponding catalog in Doris first.
:::

#### syntax

## Syntax

```sql
query(
"catalog" = "catalog_name",
"query" = "select * from db_name.table_name where condition"
QUERY(
"catalog" = "<catalog>",
"query" = "<query_sql>"
);
```

**Parameter Description**

## Required Parameters
Each parameter in the query table function tvf is a `"key"="value"` pair.
Related parameters:
- `catalog`: (required) catalog name, which needs to be filled in according to the name of the catalog.
- `query`: (required) The query statement to be executed.

### Example
| Field | Description |
|------------|--------------------------------------------|
| `catalog` | Catalog name, which needs to be filled in according to the name of the catalog. |
| `query` | The query statement to be executed. |

Use the query function to query tables in the jdbc data source

```sql
select * from query("catalog" = "jdbc", "query" = "select * from db_name.table_name where condition");
```
## Examples

Can be used with `desc function`

```sql
desc function query("catalog" = "jdbc", "query" = "select * from db_name.table_name where condition");
desc function query("catalog" = "jdbc", "query" = "select * from test.student");
```
```text
+-------+------+------+-------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------+------+-------+---------+-------+
| id | int | Yes | true | NULL | |
| name | text | Yes | false | NULL | NONE |
+-------+------+------+-------+---------+-------+
```

### Keywords

query, table-valued-function, tvf

### Best Prac

Transparent query for tables in jdbc catalog data source

```sql
select * from query("catalog" = "jdbc", "query" = "select * from test.student");
```
```text
+------+---------+
| id | name |
+------+---------+
| 1 | alice |
| 2 | bob |
| 3 | jack |
+------+---------+
```
```sql
select * from query("catalog" = "jdbc", "query" = "select * from test.score");
```
```text
+------+---------+
| id | score |
+------+---------+
@@ -100,6 +97,8 @@ Transparent join query for tables in jdbc catalog data source

```sql
select * from query("catalog" = "jdbc", "query" = "select a.id, a.name, b.score from test.student a join test.score b on a.id = b.id");
```
```
+------+---------+---------+
| id | name | score |
+------+---------+---------+
Original file line number Diff line number Diff line change
@@ -24,69 +24,66 @@ specific language governing permissions and limitations
under the License.
-->

## query

### Name

query

### description
## Description

Query table function (table-valued-function, tvf) can be used to transparently transmit query statements directly to a catalog for data query

:::info note
Supported by Doris version 2.1.3, currently only transparent query jdbc catalog is supported.
You need to create the corresponding catalog in Doris first.
:::

#### syntax

## Syntax

```sql
query(
"catalog" = "catalog_name",
"query" = "select * from db_name.table_name where condition"
QUERY(
"catalog" = "<catalog>",
"query" = "<query_sql>"
);
```

**Parameter Description**

## Required Parameters
Each parameter in the query table function tvf is a `"key"="value"` pair.
Related parameters:
- `catalog`: (required) catalog name, which needs to be filled in according to the name of the catalog.
- `query`: (required) The query statement to be executed.

### Example
| Field | Description |
|------------|--------------------------------------------|
| `catalog` | Catalog name, which needs to be filled in according to the name of the catalog. |
| `query` | The query statement to be executed. |

Use the query function to query tables in the jdbc data source

```sql
select * from query("catalog" = "jdbc", "query" = "select * from db_name.table_name where condition");
```
## Examples

Can be used with `desc function`

```sql
desc function query("catalog" = "jdbc", "query" = "select * from db_name.table_name where condition");
desc function query("catalog" = "jdbc", "query" = "select * from test.student");
```
```text
+-------+------+------+-------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------+------+-------+---------+-------+
| id | int | Yes | true | NULL | |
| name | text | Yes | false | NULL | NONE |
+-------+------+------+-------+---------+-------+
```

### Keywords

query, table-valued-function, tvf

### Best Prac

Transparent query for tables in jdbc catalog data source

```sql
select * from query("catalog" = "jdbc", "query" = "select * from test.student");
```
```text
+------+---------+
| id | name |
+------+---------+
| 1 | alice |
| 2 | bob |
| 3 | jack |
+------+---------+
```
```sql
select * from query("catalog" = "jdbc", "query" = "select * from test.score");
```
```text
+------+---------+
| id | score |
+------+---------+
@@ -100,6 +97,8 @@ Transparent join query for tables in jdbc catalog data source

```sql
select * from query("catalog" = "jdbc", "query" = "select a.id, a.name, b.score from test.student a join test.score b on a.id = b.id");
```
```
+------+---------+---------+
| id | name | score |
+------+---------+---------+

0 comments on commit bebcc47

Please sign in to comment.