query
Name
query
description
query 表函数(table-valued-function,tvf),可用于将查询语句直接透传到某个 catalog 进行数据查询
:::info note Doris 2.1.3 版本开始支持,当前仅支持透传查询 jdbc catalog。 需要先在 Doris 中创建对应的 catalog。 :::
syntax
query(
"catalog" = "catalog_name",
"query" = "select * from db_name.table_name where condition"
);
参数说明
query表函数 tvf中的每一个参数都是一个 "key"="value"
对。
相关参数:
catalog
: (必填) catalog名称,需要按照catalog的名称填写。query
: (必填) 需要执行的查询语句。
Example
使用 query 函数查询 jdbc 数据源中的表
select * from query("catalog" = "jdbc", "query" = "select * from db_name.table_name where condition");
可以配合desc function
使用
desc function query("catalog" = "jdbc", "query" = "select * from db_name.table_name where condition");
Keywords
query, table-valued-function, tvf
Best Prac
透传查询 jdbc catalog 数据源中的表
select * from query("catalog" = "jdbc", "query" = "select * from test.student");
+------+---------+
| id | name |
+------+---------+
| 1 | alice |
| 2 | bob |
| 3 | jack |
+------+---------+
select * from query("catalog" = "jdbc", "query" = "select * from test.score");
+------+---------+
| id | score |
+------+---------+
| 1 | 100 |
| 2 | 90 |
| 3 | 80 |
+------+---------+
透传关联查询 jdbc catalog 数据源中的表
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 |
+------+---------+---------+
| 1 | alice | 100 |
| 2 | bob | 90 |
| 3 | jack | 80 |
+------+---------+---------+