From 78b38d9626d5fc96a711608a165fd469cae3efb2 Mon Sep 17 00:00:00 2001 From: wudongliang <46414265+DongLiang-0@users.noreply.github.com> Date: Tue, 21 Jan 2025 15:40:44 +0800 Subject: [PATCH] improve query(), number(),tasks(),jobs(),partitions() function article format (#1844) ## Versions - [x] dev - [x] 3.0 - [x] 2.1 - [ ] 2.0 ## Languages - [x] Chinese - [x] English ## Docs Checklist - [ ] Checked by AI - [ ] Test Cases Built --- .../sql-functions/table-functions/numbers.md | 25 -- .../table-valued-functions/jobs.md | 164 +++++-------- .../table-valued-functions/numbers.md | 53 +++-- .../table-valued-functions/partitions.md | 153 ++++++------ .../table-valued-functions/query.md | 59 +++-- .../table-valued-functions/tasks.md | 214 +++++++---------- .../table-valued-functions/jobs.md | 170 ++++++-------- .../numbers.md | 44 ++-- .../table-valued-functions/partitions.md | 151 ++++++------ .../table-valued-functions/query.md | 55 +++-- .../table-valued-functions/tasks.md | 199 ++++++---------- .../table-valued-functions/jobs.md | 162 +++++-------- .../numbers.md | 44 ++-- .../table-valued-functions/partitions.md | 155 ++++++------- .../table-valued-functions/query.md | 59 +++-- .../table-valued-functions/tasks.md | 203 +++++++--------- .../table-valued-functions/jobs.md | 162 +++++-------- .../numbers.md | 44 ++-- .../table-valued-functions/partitions.md | 155 ++++++------- .../table-valued-functions/query.md | 59 +++-- .../table-valued-functions/tasks.md | 203 +++++++--------- sidebars.json | 1 - .../sql-functions/table-functions/numbers.md | 25 -- .../table-valued-functions/jobs.md | 168 +++++--------- .../table-valued-functions/numbers.md | 57 +++-- .../table-valued-functions/partitions.md | 157 ++++++------- .../table-valued-functions/query.md | 59 +++-- .../table-valued-functions/tasks.md | 218 +++++++----------- .../sql-functions/table-functions/numbers.md | 25 -- .../table-valued-functions/jobs.md | 168 +++++--------- .../table-valued-functions/numbers.md | 57 +++-- .../table-valued-functions/partitions.md | 157 ++++++------- .../table-valued-functions/query.md | 59 +++-- .../table-valued-functions/tasks.md | 218 +++++++----------- versioned_sidebars/version-2.1-sidebars.json | 1 - versioned_sidebars/version-3.0-sidebars.json | 1 - 36 files changed, 1652 insertions(+), 2252 deletions(-) delete mode 100644 docs/sql-manual/sql-functions/table-functions/numbers.md rename i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/{table-functions => table-valued-functions}/numbers.md (67%) rename i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/{table-functions => table-valued-functions}/numbers.md (67%) rename i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/{table-functions => table-valued-functions}/numbers.md (67%) delete mode 100644 versioned_docs/version-2.1/sql-manual/sql-functions/table-functions/numbers.md delete mode 100644 versioned_docs/version-3.0/sql-manual/sql-functions/table-functions/numbers.md diff --git a/docs/sql-manual/sql-functions/table-functions/numbers.md b/docs/sql-manual/sql-functions/table-functions/numbers.md deleted file mode 100644 index 4c15bf202d8b4..0000000000000 --- a/docs/sql-manual/sql-functions/table-functions/numbers.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -{ - "title": "NUMBERS", - "language": "en" -} ---- - - diff --git a/docs/sql-manual/sql-functions/table-valued-functions/jobs.md b/docs/sql-manual/sql-functions/table-valued-functions/jobs.md index 3bc7276e08e3e..72dcae6b96a86 100644 --- a/docs/sql-manual/sql-functions/table-valued-functions/jobs.md +++ b/docs/sql-manual/sql-functions/table-valued-functions/jobs.md @@ -24,127 +24,87 @@ specific language governing permissions and limitations under the License. --> -## `jobs` - -### Name - -jobs - -### description +## Description Table function, generating a temporary task table, which can view job information in a certain task type. -This function is used in the from clause. +## Syntax -This function is supported since 2.1.0. +```sql +JOBS( + "type"="" +) +``` -#### syntax +## Required Parameters +| Field | Description | +|---------------|-----------------------------------------------------------------------------------------------| +| **``** | The type of the job:
`insert`: Insert into type job.
`mv`: Materialized view job. | -`jobs("type"="")` -**parameter description** -| parameter | description | type | required | -|:----------|:------------|:-------|:---------| -| type | job type | string | yes | +## Return Value -the **type** supported types -- insert: insert into type job -- mv: materialized view job +- **`jobs("type"="insert")`** Job return value of type insert -##### insert job -jobs("type"="insert")Table structure: -``` -mysql> desc function jobs("type"="insert"); -+-------------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-------------------+------+------+-------+---------+-------+ -| Id | TEXT | No | false | NULL | NONE | -| Name | TEXT | No | false | NULL | NONE | -| Definer | TEXT | No | false | NULL | NONE | -| ExecuteType | TEXT | No | false | NULL | NONE | -| RecurringStrategy | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| ExecuteSql | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -| SucceedTaskCount | TEXT | No | false | NULL | NONE | -| FailedTaskCount | TEXT | No | false | NULL | NONE | -| CanceledTaskCount | TEXT | No | false | NULL | NONE | -| Comment | TEXT | No | false | NULL | NONE | -+-------------------+------+------+-------+---------+-------+ -12 rows in set (0.01 sec) -``` -* Id: job ID. -* Name: job name. -* Definer: job definer. -* ExecuteType: Execution type -* RecurringStrategy: recurring strategy -* Status: Job status -* ExecuteSql: Execution SQL -* CreateTime: Job creation time -* SucceedTaskCount: Number of successful tasks -* FailedTaskCount: Number of failed tasks -* CanceledTaskCount: Number of canceled tasks -* Comment: job comment - -##### matterialized view job - -jobs("type"="mv")Table structure: -```sql -mysql> desc function jobs("type"="mv"); -+-------------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-------------------+------+------+-------+---------+-------+ -| Id | TEXT | No | false | NULL | NONE | -| Name | TEXT | No | false | NULL | NONE | -| MvId | TEXT | No | false | NULL | NONE | -| MvName | TEXT | No | false | NULL | NONE | -| MvDatabaseId | TEXT | No | false | NULL | NONE | -| MvDatabaseName | TEXT | No | false | NULL | NONE | -| ExecuteType | TEXT | No | false | NULL | NONE | -| RecurringStrategy | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -+-------------------+------+------+-------+---------+-------+ -10 rows in set (0.00 sec) -``` + | Field | Description | + |--------------------|----------------------------| + | Id | Job ID | + | Name | Job name | + | Definer | Job definer | + | ExecuteType | Execution type | + | RecurringStrategy | Recurring strategy | + | Status | Job status | + | ExecuteSql | Execution SQL | + | CreateTime | Job creation time | + | SucceedTaskCount | Number of successful tasks | + | FailedTaskCount | Number of failed tasks | + | CanceledTaskCount | Number of canceled tasks | + | Comment | Job comment | -* Id: job ID. -* Name: job name. -* MvId: Materialized View ID -* MvName: Materialized View Name -* MvDatabaseId: DB ID of the materialized view -* MvDatabaseName: Name of the database to which the materialized view belongs -* ExecuteType: Execution type -* RecurringStrategy: Loop strategy -* Status: Job status -* CreateTime: Task creation time -### example +- **`jobs("type"="mv")`** MV type job return value -1. View jobs in all materialized views + | Field | Description | + |----------------------|-------------------------------------------------------------| + | Id | job ID | + | Name | job name | + | MvId | Materialized View ID | + | MvName | Materialized View Name | + | MvDatabaseId | DB ID of the materialized view | + | MvDatabaseName | Name of the database to which the materialized view belongs | + | ExecuteType | Execution type | + | RecurringStrategy | Loop strategy | + | Status | Job status | + | CreateTime | Task creation time | -```sql -mysql> select * from jobs("type"="mv"); -``` -2. View job with name `inner_mtmv_75043` - -```sql -mysql> select * from jobs("type"="mv") where Name="inner_mtmv_75043"; -``` +## Examples -3. View all insert jobs +View jobs in all materialized views ```sql -mysql> select * from jobs("type"="insert"); +select * from jobs("type"="mv"); +``` +```text ++-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+-------------+-------------------+---------+---------------------+ +| Id | Name | MvId | MvName | MvDatabaseId | MvDatabaseName | ExecuteType | RecurringStrategy | Status | CreateTime | ++-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+-------------+-------------------+---------+---------------------+ +| 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-08 18:19:10 | +| 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-08 18:19:10 | +| 21794 | inner_mtmv_21788 | 21788 | test_tablet_type_mtmv_mv | 16016 | zd | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-08 12:26:06 | +| 19508 | inner_mtmv_19494 | 19494 | mv1 | 16016 | zd | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-07 22:13:31 | ++-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+-------------+-------------------+---------+---------------------+ ``` -4. View job with name `one_insert_job` +View all insert jobs ```sql -mysql> select * from jobs("type"="insert") where Name='one_insert_job'; +select * from jobs("type"="insert"); ``` - -### keywords - - jobs, job, insert, mv, materialized view, schedule +```text ++----------------+----------------+---------+-------------+--------------------------------------------+---------+--------------------------------------------------------------+---------------------+------------------+-----------------+-------------------+---------+ +| Id | Name | Definer | ExecuteType | RecurringStrategy | Status | ExecuteSql | CreateTime | SucceedTaskCount | FailedTaskCount | CanceledTaskCount | Comment | ++----------------+----------------+---------+-------------+--------------------------------------------+---------+--------------------------------------------------------------+---------------------+------------------+-----------------+-------------------+---------+ +| 78533940810334 | insert_tab_job | root | RECURRING | EVERY 10 MINUTE STARTS 2025-01-17 14:42:53 | RUNNING | INSERT INTO test.insert_tab SELECT * FROM test.example_table | 2025-01-17 14:32:53 | 0 | 0 | 0 | | ++----------------+----------------+---------+-------------+--------------------------------------------+---------+--------------------------------------------------------------+---------------------+------------------+-----------------+-------------------+---------+ +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/table-valued-functions/numbers.md b/docs/sql-manual/sql-functions/table-valued-functions/numbers.md index 723d62154aa89..73c95bbb3aac8 100644 --- a/docs/sql-manual/sql-functions/table-valued-functions/numbers.md +++ b/docs/sql-manual/sql-functions/table-valued-functions/numbers.md @@ -24,27 +24,44 @@ specific language governing permissions and limitations under the License. --> -## `numbers` -### description +## Description Table function that generates a temporary table containing only one column with the column name `number` and all element values are `const_value` if `const_value` is specified, otherwise they are [0,`number`) incremented. -#### syntax +## Syntax ```sql -numbers( - "number" = "n" - <, "const_value" = "x"> +NUMBERS( + "number" = "" + [, "" = "" ] ); ``` -parameter: -- `number`: Line number. -- `const_value`: the constant value. +## Required Parameters -### example +| Field | Description | +|---------------|---------------------------| +| **number** | The number of rows | + +## Optional Parameters + +| Field | Description | +|-------------------|------------------------------------------| +| **const_value** | Specifies the constant value generated | + + + +## Return Value +| Field | Type | Description | +|----------------|---------|---------------------------------| +| **number** | BIGINT | The value returned for each row | + + +## Examples +```sql +select * from numbers("number" = "5"); ``` -mysql> select * from numbers("number" = "5"); +```text +--------+ | number | +--------+ @@ -54,9 +71,12 @@ mysql> select * from numbers("number" = "5"); | 3 | | 4 | +--------+ -5 rows in set (0.11 sec) +``` -mysql> select * from numbers("number" = "5", "const_value" = "-123"); +```sql +select * from numbers("number" = "5", "const_value" = "-123"); +``` +```text +--------+ | number | +--------+ @@ -66,9 +86,4 @@ mysql> select * from numbers("number" = "5", "const_value" = "-123"); | -123 | | -123 | +--------+ -5 rows in set (0.12 sec) -``` - -### keywords - - numbers, const_value \ No newline at end of file +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/table-valued-functions/partitions.md b/docs/sql-manual/sql-functions/table-valued-functions/partitions.md index b5ffa054b6c0d..2434950604479 100644 --- a/docs/sql-manual/sql-functions/table-valued-functions/partitions.md +++ b/docs/sql-manual/sql-functions/table-valued-functions/partitions.md @@ -24,105 +24,94 @@ specific language governing permissions and limitations under the License. --> -## `partitions` - -### Name - -partitions - -### Description +## Description The table function generates a temporary partition TABLE, which allows you to view the PARTITION list of a certain TABLE. -This function is used in the from clause. - -#### Syntax +## Syntax -`partitions("catalog"="","database"="","table"="")` - -partitions() Table structure: ```sql -mysql> desc function partitions("catalog"="internal","database"="zd","table"="user"); -+--------------------------+---------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+--------------------------+---------+------+-------+---------+-------+ -| PartitionId | BIGINT | No | false | NULL | NONE | -| PartitionName | TEXT | No | false | NULL | NONE | -| VisibleVersion | BIGINT | No | false | NULL | NONE | -| VisibleVersionTime | TEXT | No | false | NULL | NONE | -| State | TEXT | No | false | NULL | NONE | -| PartitionKey | TEXT | No | false | NULL | NONE | -| Range | TEXT | No | false | NULL | NONE | -| DistributionKey | TEXT | No | false | NULL | NONE | -| Buckets | INT | No | false | NULL | NONE | -| ReplicationNum | INT | No | false | NULL | NONE | -| StorageMedium | TEXT | No | false | NULL | NONE | -| CooldownTime | TEXT | No | false | NULL | NONE | -| RemoteStoragePolicy | TEXT | No | false | NULL | NONE | -| LastConsistencyCheckTime | TEXT | No | false | NULL | NONE | -| DataSize | TEXT | No | false | NULL | NONE | -| IsInMemory | BOOLEAN | No | false | NULL | NONE | -| ReplicaAllocation | TEXT | No | false | NULL | NONE | -| IsMutable | BOOLEAN | No | false | NULL | NONE | -| SyncWithBaseTables | BOOLEAN | No | false | NULL | NONE | -| UnsyncTables | TEXT | No | false | NULL | NONE | -+--------------------------+---------+------+-------+---------+-------+ -20 rows in set (0.02 sec) +PARTITIONS( + "catalog"="", + "database"="", + "table"="" +) ``` -* PartitionId:partition id -* PartitionName:partition name -* VisibleVersion:visible version -* VisibleVersionTime:visible version time -* State:state -* PartitionKey:partition key -* Range:range -* DistributionKey:distribution key -* Buckets:bucket num -* ReplicationNum:replication num -* StorageMedium:storage medium -* CooldownTime:cooldown time -* RemoteStoragePolicy:remote storage policy -* LastConsistencyCheckTime:last consistency check time -* DataSize:data size -* IsInMemory:is in memory -* ReplicaAllocation:replica allocation -* IsMutable:is mutable -* SyncWithBaseTables:Is it synchronized with the base table data (for partitioning asynchronous materialized views) -* UnsyncTables:Which base table data is not synchronized with (for partitions of asynchronous materialized views) +## Required Parameters +| Field | Description | +|------------------|--------------------------------------------------| +| **``** | Specify the cluster catalog name to be queried. | +| **``** | Specify the cluster database name to be queried. | +| **`
`** | Specify the cluster table name to be queried. | + + +## Return Value +| Field | Description | +|---------------------------|-----------------------------------------------------------------------------| +| PartitionId | Partition ID | +| PartitionName | Name of the partition | +| VisibleVersion | Partition version | +| VisibleVersionTime | Time when the partition version was committed | +| State | State of the partition | +| PartitionKey | Partition key | +| Range | Range of the partition | +| DistributionKey | Distribution key for partitioning | +| Buckets | Number of buckets in the partition | +| ReplicationNum | Number of replicas in the partition | +| StorageMedium | Storage medium used for the partition | +| CooldownTime | Cooldown time for the partition | +| RemoteStoragePolicy | Remote storage policy for the partition | +| LastConsistencyCheckTime | Time of the last consistency check for the partition | +| DataSize | Size of the data in the partition | +| IsInMemory | Whether the partition is stored in memory | +| ReplicaAllocation | Replication strategy for the partition | +| IsMutable | Whether the partition is mutable | +| SyncWithBaseTables | Whether the partition is synchronized with the base table (for async materialized views) | +| UnsyncTables | Which base table is unsynchronized (for async materialized view partitions) | + + + +## Examples +View the partition list of example_table under test in the internal catalog ```sql -mysql> desc function partitions("catalog"="hive","database"="zdtest","table"="com2"); -+-----------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-----------+------+------+-------+---------+-------+ -| Partition | TEXT | No | false | NULL | NONE | -+-----------+------+------+-------+---------+-------+ -1 row in set (0.11 sec) +select * from partitions("catalog"="internal","database"="test","table"="example_table"); ``` - -* Partition:partition name - -### Example - -1. View the partition list of table1 under db1 in the internal catalog - -```sql -mysql> select * from partitions("catalog"="internal","database"="db1","table"="table1"); +```text ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| 43209 | p1 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [0000-01-01]; ..types: [DATEV2]; keys: [2023-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | +| 43210 | p2 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2023-01-01]; ..types: [DATEV2]; keys: [2024-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | +| 43211 | p3 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2024-01-01]; ..types: [DATEV2]; keys: [2025-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | +| 43212 | p4 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2025-01-01]; ..types: [DATEV2]; keys: [2026-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ ``` -2. View the partition information with partition name partition1 under table1 +View the partition information with partition name p1 under example_table ```sql -mysql> select * from partitions("catalog"="internal","database"="db1","table"="table1") where PartitionName = "partition1"; +select * from partitions("catalog"="internal","database"="test","table"="example_table") where PartitionName = "p1"; +``` +```text ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| 43209 | p1 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [0000-01-01]; ..types: [DATEV2]; keys: [2023-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ ``` -3. View the partition ID with the partition name 'partition1' under Table 1 +View the partition ID with the partition name p1 under example_table ```sql -mysql> select PartitionId from partitions("catalog"="internal","database"="db1","table"="table1") where PartitionName = "partition1"; +select PartitionId from partitions("catalog"="internal","database"="test","table"="example_table") where PartitionName = "p1"; +``` +```text ++-------------+ +| PartitionId | ++-------------+ +| 43209 | ++-------------+ ``` -### Keywords - - partitions diff --git a/docs/sql-manual/sql-functions/table-valued-functions/query.md b/docs/sql-manual/sql-functions/table-valued-functions/query.md index f3f0adfd5f2a3..f26d9c0d3de36 100644 --- a/docs/sql-manual/sql-functions/table-valued-functions/query.md +++ b/docs/sql-manual/sql-functions/table-valued-functions/query.md @@ -24,61 +24,54 @@ 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" = "", + "query" = "" ); ``` -**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 | +------+---------+ @@ -86,7 +79,11 @@ select * from query("catalog" = "jdbc", "query" = "select * from test.student"); | 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 | +------+---------+---------+ diff --git a/docs/sql-manual/sql-functions/table-valued-functions/tasks.md b/docs/sql-manual/sql-functions/table-valued-functions/tasks.md index ebd279effe65d..8d1d99bcc48b7 100644 --- a/docs/sql-manual/sql-functions/table-valued-functions/tasks.md +++ b/docs/sql-manual/sql-functions/table-valued-functions/tasks.md @@ -24,151 +24,99 @@ specific language governing permissions and limitations under the License. --> -## `tasks` -### Name - -:::tip -tasks -- since 2.1 -::: - -### description +## Description Table function, generates a temporary table of tasks, which allows you to view the information of tasks generated by jobs in the current Doris cluster. -This function is used in the FROM clause. - -This functions is supported since 2.1.0. - -#### syntax - -`tasks("type"="insert");` -**parameter description** - -| parameter | description | type | required | -|:----------|:------------|:-------|:---------| -| type | job type | string | yes | - -the **type** supported types -- insert: insert into type job -- mv: materilized view type job - -##### Insert tasks - -The table schema of `tasks("type"="insert");` tvf: - -``` -mysql> desc function tasks("type"="insert");; -+---------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+---------------+------+------+-------+---------+-------+ -| TaskId | TEXT | No | false | NULL | NONE | -| JobId | TEXT | No | false | NULL | NONE | -| JobName | TEXT | No | false | NULL | NONE | -| Label | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| ErrorMsg | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -| FinishTime | TEXT | No | false | NULL | NONE | -| TrackingUrl | TEXT | No | false | NULL | NONE | -| LoadStatistic | TEXT | No | false | NULL | NONE | -| User | TEXT | No | false | NULL | NONE | -+---------------+------+------+-------+---------+-------+ -11 row in set (0.01 sec) -``` -- TaskId: task id -- JobId: job id -- JobName: job name -- Label: label -- Status: task status -- ErrorMsg: task failure information -- CreateTime: task creation time -- FinishTime: task completion time -- TrackingUrl: tracking URL -- LoadStatistic: load statistics -- User: user -##### MV Tasks +## Syntax ```sql -mysql> desc function tasks("type"="mv"); -+-----------------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-----------------------+------+------+-------+---------+-------+ -| TaskId | TEXT | No | false | NULL | NONE | -| JobId | TEXT | No | false | NULL | NONE | -| JobName | TEXT | No | false | NULL | NONE | -| MvId | TEXT | No | false | NULL | NONE | -| MvName | TEXT | No | false | NULL | NONE | -| MvDatabaseId | TEXT | No | false | NULL | NONE | -| MvDatabaseName | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| ErrorMsg | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -| StartTime | TEXT | No | false | NULL | NONE | -| FinishTime | TEXT | No | false | NULL | NONE | -| DurationMs | TEXT | No | false | NULL | NONE | -| TaskContext | TEXT | No | false | NULL | NONE | -| RefreshMode | TEXT | No | false | NULL | NONE | -| NeedRefreshPartitions | TEXT | No | false | NULL | NONE | -| CompletedPartitions | TEXT | No | false | NULL | NONE | -| Progress | TEXT | No | false | NULL | NONE | -+-----------------------+------+------+-------+---------+-------+ -18 rows in set (0.00 sec) -``` - -* TaskId: task id -* JobId: job id -* JobName: job Name -* MvId: Materialized View ID -* MvName: Materialized View Name -* MvDatabaseId: DB ID of the materialized view -* MvDatabaseName: Name of the database to which the materialized view belongs -* Status: task status -* ErrorMsg: Task failure information -* CreateTime: Task creation time -* StartTime: Task start running time -* FinishTime: Task End Run Time -* DurationMs: Task runtime -* TaskContext: Task running parameters -* RefreshMode: refresh mode -* NeedRefreshPartitions: The partition information that needs to be refreshed for this task -* CompletedPartitions: The partition information that has been refreshed for this task -* Progress: Task running progress -### example -#### Insert Tasls -``` -mysql> select * from tasks("type"="insert") limit 1 \G -*************************** 1. row *************************** - TaskId: 667704038678903 - JobId: 10069 - Label: 10069_667704038678903 - Status: FINISHED - EtlInfo: \N - TaskInfo: cluster:N/A; timeout(s):14400; max_filter_ratio:0.0; priority:NORMAL - ErrorMsg: \N - CreateTimeMs: 2023-12-08 16:46:57 - FinishTimeMs: 2023-12-08 16:46:57 - TrackingUrl: -LoadStatistic: {"Unfinished backends":{},"ScannedRows":0,"TaskNumber":0,"LoadBytes":0,"All backends":{},"FileNumber":0,"FileSize":0} - User: root -1 row in set (0.05 sec) - +TASKS( + "type"="" +) ``` -#### MV Tasks -1. View tasks for all materialized views +## Required Parameters +| Field | Description | +|---------------|---------------------------------------------------------------------------------------------------| +| **``** | Type of the task:
`insert`: insert into type task.
`mv`: materialized view type task. | + + +## Return Value + +- **`tasks("type"="insert")`** tasks return value of type insert + + | Field Name | Description | + |--------------|------------------------------------| + | **TaskId** | Task id | + | **JobId** | Job id | + | **JobName** | Job name | + | **Label** | Label | + | **Status** | Task status | + | **ErrorMsg** | Task failure information | + | **CreateTime**| Task creation time | + | **FinishTime**| Task completion time | + | **TrackingUrl**| Tracking URL | + | **LoadStatistic**| Load statistics | + | **User** | User | + +- **`tasks("type"="mv")`** Tasks return value of type MV + + | Field Name | Description | + |-----------------------|-----------------------------------------------------------------------------| + | **TaskId** | Task id | + | **JobId** | Job id | + | **JobName** | Job Name | + | **MvId** | Materialized View ID | + | **MvName** | Materialized View Name | + | **MvDatabaseId** | DB ID of the materialized view | + | **MvDatabaseName** | Name of the database to which the materialized view belongs | + | **Status** | Task status | + | **ErrorMsg** | Task failure information | + | **CreateTime** | Task creation time | + | **StartTime** | Task start running time | + | **FinishTime** | Task End Run Time | + | **DurationMs** | Task runtime | + | **TaskContext** | Task running parameters | + | **RefreshMode** | Refresh mode | + | **NeedRefreshPartitions** | The partition information that needs to be refreshed for this task | + | **CompletedPartitions** | The partition information that has been refreshed for this task | + | **Progress** | Task running progress | + + +## Examples + +View tasks for all materialized views ```sql -mysql> select * from tasks("type"="mv"); +select * from tasks("type"="mv"); +``` +```text ++-----------------+-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+---------+----------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------------------------------+-----------------------------------------------+---------------+-----------------------------------+ +| TaskId | JobId | JobName | MvId | MvName | MvDatabaseId | MvDatabaseName | Status | ErrorMsg | CreateTime | StartTime | FinishTime | DurationMs | TaskContext | RefreshMode | NeedRefreshPartitions | CompletedPartitions | Progress | LastQueryId | ++-----------------+-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+---------+----------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------------------------------+-----------------------------------------------+---------------+-----------------------------------+ +| 509478985247053 | 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 233 | {"triggerMode":"SYSTEM","isComplete":false} | COMPLETE | ["p_20231001_20231101"] | ["p_20231001_20231101"] | 100.00% (1/1) | 71897c47d0d94fd2-9ca52a0e6eb3bff5 | +| 509486915704885 | 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:17 | 2025-01-08 18:19:17 | 2025-01-08 18:19:17 | 227 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | 9bf5ff69d4cc4c78-b50505436c8410c4 | +| 509487197275880 | 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 191 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | 5b3b4525b6774b5b-89b070042cdcbcd5 | +| 509478131194211 | 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 156 | {"triggerMode":"SYSTEM","isComplete":false} | COMPLETE | ["p_20231001_20231101"] | ["p_20231001_20231101"] | 100.00% (1/1) | 6d0a0782819b446e-b9da5d5de513ce00 | +| 509486057129101 | 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:17 | 2025-01-08 18:19:17 | 2025-01-08 18:19:18 | 213 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | f1303483e3db43e7-aa424acc32dc39ca | +| 509486143784554 | 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 151 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | 8d29b11ac41f4fe0-9d7c86372707310b | +| 488317385772600 | 21794 | inner_mtmv_21788 | 21788 | test_tablet_type_mtmv_mv | 16016 | zd | SUCCESS | | 2025-01-08 12:26:29 | 2025-01-08 12:26:29 | 2025-01-08 12:26:29 | 1 | {"triggerMode":"MANUAL","partitions":[],"isComplete":true} | NOT_REFRESH | [] | \N | \N | | +| 437156301250803 | 19508 | inner_mtmv_19494 | 19494 | mv1 | 16016 | zd | SUCCESS | | 2025-01-07 22:13:48 | 2025-01-07 22:13:48 | 2025-01-07 22:17:45 | 236985 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | COMPLETE | ["p_20210101_MAXVALUE","p_20200101_20210101"] | ["p_20210101_MAXVALUE","p_20200101_20210101"] | 100.00% (2/2) | 7965b4ddce8a4480-8884e9701679c1c4 | +| 439689059641969 | 19508 | inner_mtmv_19494 | 19494 | mv1 | 16016 | zd | SUCCESS | | 2025-01-07 22:55:59 | 2025-01-07 22:55:59 | 2025-01-07 22:55:59 | 35 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | NOT_REFRESH | [] | \N | \N | | ++-----------------+-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+---------+----------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------------------------------+-----------------------------------------------+---------------+-----------------------------------+ ``` -2. View all tasks with jobName `inner_mtmv_75043` +View tasks for all insert tasks ```sql -mysql> select * from tasks("type"="mv") where JobName="inner_mtmv_75043"; +select * from tasks("type"="insert"); +``` +```text ++----------------+----------------+----------------+-------------------------------+---------+----------+---------------------+---------------------+---------------------+-------------+---------------+------+ +| TaskId | JobId | JobName | Label | Status | ErrorMsg | CreateTime | StartTime | FinishTime | TrackingUrl | LoadStatistic | User | ++----------------+----------------+----------------+-------------------------------+---------+----------+---------------------+---------------------+---------------------+-------------+---------------+------+ +| 79133848479750 | 78533940810334 | insert_tab_job | 78533940810334_79133848479750 | SUCCESS | | 2025-01-17 14:42:54 | 2025-01-17 14:42:54 | 2025-01-17 14:42:54 | | | root | ++----------------+----------------+----------------+-------------------------------+---------+----------+---------------------+---------------------+---------------------+-------------+---------------+------+ ``` - -### keywords - - tasks, job, insert, mv, materilized view diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/jobs.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/jobs.md index 69f010fdccf37..5d9f738822ee2 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/jobs.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/jobs.md @@ -24,123 +24,87 @@ specific language governing permissions and limitations under the License. --> -## `jobs` - -### Name - -jobs - ## 描述 表函数,生成任务临时表,可以查看某个任务类型中的job信息。 -该函数用于 from 子句中。 - -该函数自 2.1.0 版本支持。 - ## 语法 -`jobs("type"="")` - -**参数说明** - -| 参数名 | 说明 | 类型 | 是否必填 | -|:-----|:-----|:-------|:-----| -| type | 作业类型 | string | 是 | - -type 支持的类型: - -- insert:insert into 类型的任务。 -- mv:物化视图类型的任务。 -##### Insert 任务 -jobs("type"="insert")表结构: ```sql -mysql> desc function jobs("type"="insert"); -+-------------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-------------------+------+------+-------+---------+-------+ -| Id | TEXT | No | false | NULL | NONE | -| Name | TEXT | No | false | NULL | NONE | -| Definer | TEXT | No | false | NULL | NONE | -| ExecuteType | TEXT | No | false | NULL | NONE | -| RecurringStrategy | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| ExecuteSql | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -| SucceedTaskCount | TEXT | No | false | NULL | NONE | -| FailedTaskCount | TEXT | No | false | NULL | NONE | -| CanceledTaskCount | TEXT | No | false | NULL | NONE | -| Comment | TEXT | No | false | NULL | NONE | -+-------------------+------+------+-------+---------+-------+ -12 rows in set (0.01 sec) +JOBS( + "type"="" +) ``` -* Id:job id. -* Name:job名称. -* Definer:job定义者. -* ExecuteType:执行类型 -* RecurringStrategy:循环策略 -* Status:job状态 -* ExecuteSql:执行SQL -* CreateTime:job 创建时间 -* SucceedTaskCount:成功任务数量 -* FailedTaskCount:失败任务数量 -* CanceledTaskCount:取消任务数量 -* Comment:job 注释 -##### 物化视图任务 -jobs("type"="mv")表结构: -```sql -mysql> desc function jobs("type"="mv"); -+-------------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-------------------+------+------+-------+---------+-------+ -| Id | TEXT | No | false | NULL | NONE | -| Name | TEXT | No | false | NULL | NONE | -| MvId | TEXT | No | false | NULL | NONE | -| MvName | TEXT | No | false | NULL | NONE | -| MvDatabaseId | TEXT | No | false | NULL | NONE | -| MvDatabaseName | TEXT | No | false | NULL | NONE | -| ExecuteType | TEXT | No | false | NULL | NONE | -| RecurringStrategy | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -+-------------------+------+------+-------+---------+-------+ -10 rows in set (0.00 sec) -``` - -* Id:job id. -* Name:job名称. -* MvId:物化视图id -* MvName:物化视图名称 -* MvDatabaseId:物化视图所属db id -* MvDatabaseName:物化视图所属db名称 -* ExecuteType:执行类型 -* RecurringStrategy:循环策略 -* Status:job状态 -* CreateTime:task创建时间 - -## 举例 -1. 查看所有物化视图的job +## 必填参数 (Required Parameters) +| 字段名 | 描述 | +|--------------|---------------------------------------------------------------| +| **``** | 任务的类型:
`insert`:insert into 类型的任务。
`mv`:物化视图类型的任务。 | + + +## 返回值 + +- **`jobs("type"="insert")`** insert 类型的 job 返回值 + + | 字段名 | 描述 | + |--------------------|--------------------------------| + | Id | job id | + | Name | job名称 | + | Definer | job定义者 | + | ExecuteType | 执行类型 | + | RecurringStrategy | 循环策略 | + | Status | job状态 | + | ExecuteSql | 执行SQL | + | CreateTime | job 创建时间 | + | SucceedTaskCount | 成功任务数量 | + | FailedTaskCount | 失败任务数量 | + | CanceledTaskCount | 取消任务数量 | + | Comment | job 注释 | + + +- **`jobs("type"="mv")`** MV 类型的 job 返回值 + + | 字段名 | 描述 | + |---------------------|--------------------------------------| + | Id | job id | + | Name | job名称 | + | MvId | 物化视图id | + | MvName | 物化视图名称 | + | MvDatabaseId | 物化视图所属db id | + | MvDatabaseName | 物化视图所属db名称 | + | ExecuteType | 执行类型 | + | RecurringStrategy | 循环策略 | + | Status | job状态 | + | CreateTime | task创建时间 | + + +## 示例 + +查看所有物化视图的job ```sql -mysql> select * from jobs("type"="mv"); +select * from jobs("type"="mv"); ``` - -2. 查看 name 为`inner_mtmv_75043`的 job - -```sql -mysql> select * from jobs("type"="mv") where Name="inner_mtmv_75043"; +```text ++-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+-------------+-------------------+---------+---------------------+ +| Id | Name | MvId | MvName | MvDatabaseId | MvDatabaseName | ExecuteType | RecurringStrategy | Status | CreateTime | ++-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+-------------+-------------------+---------+---------------------+ +| 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-08 18:19:10 | +| 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-08 18:19:10 | +| 21794 | inner_mtmv_21788 | 21788 | test_tablet_type_mtmv_mv | 16016 | zd | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-08 12:26:06 | +| 19508 | inner_mtmv_19494 | 19494 | mv1 | 16016 | zd | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-07 22:13:31 | ++-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+-------------+-------------------+---------+---------------------+ ``` -3. 查看所有 insert 任务 -```sql -mysql> select * from jobs("type"="insert"); -``` -4. 查看 name 为`one_insert_job`的 job +查看所有 insert 任务的 job ```sql -mysql> select * from jobs("type"="insert") where Name='one_insert_job'; +select * from jobs("type"="insert"); ``` -### keywords - - jobs, job, insert, mv, materialized view, schedule +```text ++----------------+----------------+---------+-------------+--------------------------------------------+---------+--------------------------------------------------------------+---------------------+------------------+-----------------+-------------------+---------+ +| Id | Name | Definer | ExecuteType | RecurringStrategy | Status | ExecuteSql | CreateTime | SucceedTaskCount | FailedTaskCount | CanceledTaskCount | Comment | ++----------------+----------------+---------+-------------+--------------------------------------------+---------+--------------------------------------------------------------+---------------------+------------------+-----------------+-------------------+---------+ +| 78533940810334 | insert_tab_job | root | RECURRING | EVERY 10 MINUTE STARTS 2025-01-17 14:42:53 | RUNNING | INSERT INTO test.insert_tab SELECT * FROM test.example_table | 2025-01-17 14:32:53 | 0 | 0 | 0 | | ++----------------+----------------+---------+-------------+--------------------------------------------+---------+--------------------------------------------------------------+---------------------+------------------+-----------------+-------------------+---------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-functions/numbers.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/numbers.md similarity index 67% rename from i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-functions/numbers.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/numbers.md index 6db9da9cf8491..47245d5fac489 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-functions/numbers.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/numbers.md @@ -24,27 +24,40 @@ specific language governing permissions and limitations under the License. --> -## `numbers` - ## 描述 表函数,生成一张只含有一列的临时表,列名为`number`,如果指定了`const_value`,则所有元素值均为`const_value`,否则为[0,`number`)递增。 ## 语法 ```sql -numbers( - "number" = "n" - <, "const_value" = "x"> +NUMBERS( + "number" = "" + [, "" = "" ] ); ``` -参数: -- `number`: 行数。 -- `const_value` : 常量值。 +## 必填参数 + +| 字段 | 描述 | +|--------------|----------| +| **number** | 行数 | + +## 选填参数 + +| 字段 | 描述 | +|----------------|------| +| **const_value** | 常量值 | + +## 返回值 +| 字段名 | 类型 | 描述 | +|----------------|---------|----------| +| **number** | BIGINT | 指定每行返回的值 | ## 举例 +```sql +select * from numbers("number" = "5"); ``` -mysql> select * from numbers("number" = "5"); +```text +--------+ | number | +--------+ @@ -54,9 +67,12 @@ mysql> select * from numbers("number" = "5"); | 3 | | 4 | +--------+ -5 rows in set (0.11 sec) +``` -mysql> select * from numbers("number" = "5", "const_value" = "-123"); +```sql +select * from numbers("number" = "5", "const_value" = "-123"); +``` +```text +--------+ | number | +--------+ @@ -66,11 +82,5 @@ mysql> select * from numbers("number" = "5", "const_value" = "-123"); | -123 | | -123 | +--------+ -5 rows in set (0.12 sec) ``` -### keywords - - numbers, const_value - - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/partitions.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/partitions.md index eb8f6a088e56b..dbb0b1641f869 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/partitions.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/partitions.md @@ -24,105 +24,94 @@ specific language governing permissions and limitations under the License. --> -## `partitions` - -### Name - -partitions - ## 描述 表函数,生成分区临时表,可以查看某个 TABLE 的分区列表。 -该函数用于 From 子句中。 - ## 语法 -`partitions("catalog"="","database"="","table"="")` - -partitions()表结构: ```sql -mysql> desc function partitions("catalog"="internal","database"="zd","table"="user"); -+--------------------------+---------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+--------------------------+---------+------+-------+---------+-------+ -| PartitionId | BIGINT | No | false | NULL | NONE | -| PartitionName | TEXT | No | false | NULL | NONE | -| VisibleVersion | BIGINT | No | false | NULL | NONE | -| VisibleVersionTime | TEXT | No | false | NULL | NONE | -| State | TEXT | No | false | NULL | NONE | -| PartitionKey | TEXT | No | false | NULL | NONE | -| Range | TEXT | No | false | NULL | NONE | -| DistributionKey | TEXT | No | false | NULL | NONE | -| Buckets | INT | No | false | NULL | NONE | -| ReplicationNum | INT | No | false | NULL | NONE | -| StorageMedium | TEXT | No | false | NULL | NONE | -| CooldownTime | TEXT | No | false | NULL | NONE | -| RemoteStoragePolicy | TEXT | No | false | NULL | NONE | -| LastConsistencyCheckTime | TEXT | No | false | NULL | NONE | -| DataSize | TEXT | No | false | NULL | NONE | -| IsInMemory | BOOLEAN | No | false | NULL | NONE | -| ReplicaAllocation | TEXT | No | false | NULL | NONE | -| IsMutable | BOOLEAN | No | false | NULL | NONE | -| SyncWithBaseTables | BOOLEAN | No | false | NULL | NONE | -| UnsyncTables | TEXT | No | false | NULL | NONE | -+--------------------------+---------+------+-------+---------+-------+ -20 rows in set (0.02 sec) +PARTITIONS( + "catalog"="", + "database"="", + "table"="
" +) ``` -* PartitionId:分区id -* PartitionName:分区名字 -* VisibleVersion:分区版本 -* VisibleVersionTime:分区版本提交时间 -* State:分区状态 -* PartitionKey:分区key -* Range:分区范围 -* DistributionKey:分布key -* Buckets:分桶数量 -* ReplicationNum:副本数 -* StorageMedium:存储介质 -* CooldownTime:cooldown时间 -* RemoteStoragePolicy:远程存储策略 -* LastConsistencyCheckTime:上次一致性检查时间 -* DataSize:数据大小 -* IsInMemory:是否存在内存 -* ReplicaAllocation:分布策略 -* IsMutable:是否可变 -* SyncWithBaseTables:是否和基表数据同步(针对异步物化视图的分区) -* UnsyncTables:和哪个基表数据不同步(针对异步物化视图的分区) +## 必填参数 (Required Parameters) +| 字段 | 描述 | +|------------------|------------------------------------------| +| **``** | 指定需要查询的集群 catalog 名。 | +| **``** | 指定需要查询的集群数据库名。 | +| **`
`** | 指定需要查询的集群表名。 | + + +## 返回值 + +| 字段名 | 描述 | +|--------------------------|-------------------------| +| PartitionId | 分区ID | +| PartitionName | 分区名称 | +| VisibleVersion | 分区版本 | +| VisibleVersionTime | 分区版本提交时间 | +| State | 分区状态 | +| PartitionKey | 分区键 | +| Range | 分区范围 | +| DistributionKey | 分布键 | +| Buckets | 分桶数量 | +| ReplicationNum | 副本数 | +| StorageMedium | 存储介质 | +| CooldownTime | 冷却时间 | +| RemoteStoragePolicy | 远程存储策略 | +| LastConsistencyCheckTime | 上次一致性检查时间 | +| DataSize | 数据大小 | +| IsInMemory | 是否存在内存 | +| ReplicaAllocation | 分布策略 | +| IsMutable | 是否可变 | +| SyncWithBaseTables | 是否和基表数据同步(针对异步物化视图的分区) | +| UnsyncTables | 和哪个基表数据不同步(针对异步物化视图的分区) | + + +## 示例 + +查看 internal CATALOG 下 test 的 example_table 的分区列表 ```sql -mysql> desc function partitions("catalog"="hive","database"="zdtest","table"="com2"); -+-----------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-----------+------+------+-------+---------+-------+ -| Partition | TEXT | No | false | NULL | NONE | -+-----------+------+------+-------+---------+-------+ -1 row in set (0.11 sec) +select * from partitions("catalog"="internal","database"="test","table"="example_table"); ``` - -* Partition:分区名字 - -## 举例 - -1. 查看 internal CATALOG 下 db1 的 table1 的分区列表 - -```sql -mysql> select * from partitions("catalog"="internal","database"="db1","table"="table1"); +```text ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| 43209 | p1 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [0000-01-01]; ..types: [DATEV2]; keys: [2023-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | +| 43210 | p2 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2023-01-01]; ..types: [DATEV2]; keys: [2024-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | +| 43211 | p3 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2024-01-01]; ..types: [DATEV2]; keys: [2025-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | +| 43212 | p4 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2025-01-01]; ..types: [DATEV2]; keys: [2026-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ ``` -2. 查看 table1 下的分区名称为 partition1 的分区信息 +查看 example_table 下的分区名称为 partition1 的分区信息 ```sql -mysql> select * from partitions("catalog"="internal","database"="db1","table"="table1") where PartitionName = "partition1"; +select * from partitions("catalog"="internal","database"="test","table"="example_table") where PartitionName = "p1"; +``` +```text ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| 43209 | p1 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [0000-01-01]; ..types: [DATEV2]; keys: [2023-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ ``` -3. 查看 table1 下的分区名称为 partition1 的分区 id +查看 user_tab 下的分区名称为 partition1 的分区 id ```sql -mysql> select PartitionId from partitions("catalog"="internal","database"="db1","table"="table1") where PartitionName = "partition1"; +select PartitionId from partitions("catalog"="internal","database"="test","table"="example_table") where PartitionName = "p1"; ``` - -### Keywords - - partitions +```text ++-------------+ +| PartitionId | ++-------------+ +| 43209 | ++-------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/query.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/query.md index 17f183cdc9a50..2307fcdb0ac94 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/query.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/query.md @@ -24,61 +24,54 @@ 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" = "", + "query" = "" ); ``` -**参数说明** +## 必填参数 +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 | +------+---------+ @@ -86,7 +79,11 @@ select * from query("catalog" = "jdbc", "query" = "select * from test.student"); | 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 | +------+---------+---------+ diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/tasks.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/tasks.md index 1d20eccd10dee..15d81365bd165 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/tasks.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/tasks.md @@ -24,145 +24,98 @@ specific language governing permissions and limitations under the License. --> -## `tasks` +## 描述 -### Name +表函数,生成 tasks 临时表,可以查看当前 doris 集群中的 job 产生的 tasks 信息。 -tasks +## 语法 +```sql +TASKS( + "type"="" +) +``` -## 描述 +## 必填参数 (Required Parameters) +| 字段名 | 描述 | +|--------------|---------------------------------------------------------------| +| **``** | 任务的类型:
`insert`:insert into 类型的任务。
`mv`:物化视图类型的任务。 | -表函数,生成 tasks 临时表,可以查看当前 doris 集群中的 job 产生的 tasks 信息。 -该函数用于 from 子句中。 +## 返回值 -该函数自 2.1.0 版本支持。 +- **`tasks("type"="insert")`** insert 类型的 tasks 返回值 -## 语法 + | 字段名 | 描述 | + |--------------|---------------------------| + | **TaskId** | task id | + | **JobId** | job id | + | **JobName** | job 名称 | + | **Label** | label | + | **Status** | task 状态 | + | **ErrorMsg** | task 失败信息 | + | **CreateTime**| task 创建时间 | + | **FinishTime**| task 结束时间 | + | **TrackingUrl**| task tracking url | + | **LoadStatistic**| task 统计信息 | + | **User** | 执行用户 | -`tasks("type"="insert");` -**参数说明** -| 参数名 | 说明 | 类型 | 是否必填 | -|:-----|:-------|:-------|:-----| -| type | 作业类型 | string | 是 | -type 支持的类型: +- **`tasks("type"="mv")`** MV 类型的 tasks 返回值 -- insert:insert into 类型的任务。 -- mv: mv 类型的任务 + | 字段名 | 描述 | + |-----------------------|--------------------------------| + | **TaskId** | task id | + | **JobId** | job id | + | **JobName** | job 名称 | + | **MvId** | 物化视图 id | + | **MvName** | 物化视图名称 | + | **MvDatabaseId** | 物化视图所属 db id | + | **MvDatabaseName** | 物化视图所属 db 名称 | + | **Status** | task 状态 | + | **ErrorMsg** | task 失败信息 | + | **CreateTime** | task 创建时间 | + | **StartTime** | task 开始运行时间 | + | **FinishTime** | task 结束运行时间 | + | **DurationMs** | task 运行时间 | + | **TaskContext** | task 运行参数 | + | **RefreshMode** | 刷新模式 | + | **NeedRefreshPartitions** | 本次 task 需要刷新的分区信息 | + | **CompletedPartitions** | 本次 task 刷新完成的分区信息 | + | **Progress** | task 运行进度 | -##### Insert tasks -`tasks("type"="insert");`表结构: -``` -mysql> desc function tasks("type"="insert");; -+---------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+---------------+------+------+-------+---------+-------+ -| TaskId | TEXT | No | false | NULL | NONE | -| JobId | TEXT | No | false | NULL | NONE | -| JobName | TEXT | No | false | NULL | NONE | -| Label | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| ErrorMsg | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -| FinishTime | TEXT | No | false | NULL | NONE | -| TrackingUrl | TEXT | No | false | NULL | NONE | -| LoadStatistic | TEXT | No | false | NULL | NONE | -| User | TEXT | No | false | NULL | NONE | -+---------------+------+------+-------+---------+-------+ -11 row in set (0.01 sec) -``` -- TaskId:task id -- JobId:job id -- JobName:job 名称 -- Label:label -- Status:task 状态 -- ErrorMsg:task 失败信息 -- CreateTime:task 创建时间 -- FinishTime:task 结束时间 -- TrackingUrl:task tracking url -- LoadStatistic:task 统计信息 -- User:执行用户 -##### MV tasks -```sql -mysql> desc function tasks("type"="mv"); -+-----------------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-----------------------+------+------+-------+---------+-------+ -| TaskId | TEXT | No | false | NULL | NONE | -| JobId | TEXT | No | false | NULL | NONE | -| JobName | TEXT | No | false | NULL | NONE | -| MvId | TEXT | No | false | NULL | NONE | -| MvName | TEXT | No | false | NULL | NONE | -| MvDatabaseId | TEXT | No | false | NULL | NONE | -| MvDatabaseName | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| ErrorMsg | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -| StartTime | TEXT | No | false | NULL | NONE | -| FinishTime | TEXT | No | false | NULL | NONE | -| DurationMs | TEXT | No | false | NULL | NONE | -| TaskContext | TEXT | No | false | NULL | NONE | -| RefreshMode | TEXT | No | false | NULL | NONE | -| NeedRefreshPartitions | TEXT | No | false | NULL | NONE | -| CompletedPartitions | TEXT | No | false | NULL | NONE | -| Progress | TEXT | No | false | NULL | NONE | -+-----------------------+------+------+-------+---------+-------+ -18 rows in set (0.00 sec) -``` -* TaskId:task id -* JobId:job id -* JobName:job 名称 -* MvId:物化视图 id -* MvName:物化视图名称 -* MvDatabaseId:物化视图所属 db id -* MvDatabaseName:物化视图所属 db 名称 -* Status:task 状态 -* ErrorMsg:task 失败信息 -* CreateTime:task 创建时间 -* StartTime:task 开始运行时间 -* FinishTime:task 结束运行时间 -* DurationMs:task 运行时间 -* TaskContext:task 运行参数 -* RefreshMode:刷新模式 -* NeedRefreshPartitions:本次 task 需要刷新的分区信息 -* CompletedPartitions:本次 task 刷新完成的分区信息 -* Progress:task 运行进度 - -## 举例 -#### Insert Tasks -``` -mysql> select * from tasks("type"="insert") limit 1 \G -*************************** 1. row *************************** - TaskId: 667704038678903 - JobId: 10069 - Label: 10069_667704038678903 - Status: FINISHED - EtlInfo: \N - TaskInfo: cluster:N/A; timeout(s):14400; max_filter_ratio:0.0; priority:NORMAL - ErrorMsg: \N - CreateTimeMs: 2023-12-08 16:46:57 - FinishTimeMs: 2023-12-08 16:46:57 - TrackingUrl: -LoadStatistic: {"Unfinished backends":{},"ScannedRows":0,"TaskNumber":0,"LoadBytes":0,"All backends":{},"FileNumber":0,"FileSize":0} - User: root -1 row in set (0.05 sec) -``` -#### MV Tasks -1. 查看所有物化视图的 task +## 示例 + +查看所有物化视图的 tasks ```sql -mysql> select * from tasks("type"="mv"); +select * from tasks("type"="mv"); +``` +```text ++-----------------+-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+---------+----------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------------------------------+-----------------------------------------------+---------------+-----------------------------------+ +| TaskId | JobId | JobName | MvId | MvName | MvDatabaseId | MvDatabaseName | Status | ErrorMsg | CreateTime | StartTime | FinishTime | DurationMs | TaskContext | RefreshMode | NeedRefreshPartitions | CompletedPartitions | Progress | LastQueryId | ++-----------------+-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+---------+----------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------------------------------+-----------------------------------------------+---------------+-----------------------------------+ +| 509478985247053 | 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 233 | {"triggerMode":"SYSTEM","isComplete":false} | COMPLETE | ["p_20231001_20231101"] | ["p_20231001_20231101"] | 100.00% (1/1) | 71897c47d0d94fd2-9ca52a0e6eb3bff5 | +| 509486915704885 | 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:17 | 2025-01-08 18:19:17 | 2025-01-08 18:19:17 | 227 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | 9bf5ff69d4cc4c78-b50505436c8410c4 | +| 509487197275880 | 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 191 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | 5b3b4525b6774b5b-89b070042cdcbcd5 | +| 509478131194211 | 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 156 | {"triggerMode":"SYSTEM","isComplete":false} | COMPLETE | ["p_20231001_20231101"] | ["p_20231001_20231101"] | 100.00% (1/1) | 6d0a0782819b446e-b9da5d5de513ce00 | +| 509486057129101 | 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:17 | 2025-01-08 18:19:17 | 2025-01-08 18:19:18 | 213 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | f1303483e3db43e7-aa424acc32dc39ca | +| 509486143784554 | 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 151 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | 8d29b11ac41f4fe0-9d7c86372707310b | +| 488317385772600 | 21794 | inner_mtmv_21788 | 21788 | test_tablet_type_mtmv_mv | 16016 | zd | SUCCESS | | 2025-01-08 12:26:29 | 2025-01-08 12:26:29 | 2025-01-08 12:26:29 | 1 | {"triggerMode":"MANUAL","partitions":[],"isComplete":true} | NOT_REFRESH | [] | \N | \N | | +| 437156301250803 | 19508 | inner_mtmv_19494 | 19494 | mv1 | 16016 | zd | SUCCESS | | 2025-01-07 22:13:48 | 2025-01-07 22:13:48 | 2025-01-07 22:17:45 | 236985 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | COMPLETE | ["p_20210101_MAXVALUE","p_20200101_20210101"] | ["p_20210101_MAXVALUE","p_20200101_20210101"] | 100.00% (2/2) | 7965b4ddce8a4480-8884e9701679c1c4 | +| 439689059641969 | 19508 | inner_mtmv_19494 | 19494 | mv1 | 16016 | zd | SUCCESS | | 2025-01-07 22:55:59 | 2025-01-07 22:55:59 | 2025-01-07 22:55:59 | 35 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | NOT_REFRESH | [] | \N | \N | | ++-----------------+-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+---------+----------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------------------------------+-----------------------------------------------+---------------+-----------------------------------+ ``` -2. 查看 jobName 为`inner_mtmv_75043`的所有 task - +查看所有 insert 任务的 tasks ```sql -mysql> select * from tasks("type"="mv") where JobName="inner_mtmv_75043"; +select * from tasks("type"="insert"); ``` - -### keywords - - tasks, job, insert, mv, materilized view +```text ++----------------+----------------+----------------+-------------------------------+---------+----------+---------------------+---------------------+---------------------+-------------+---------------+------+ +| TaskId | JobId | JobName | Label | Status | ErrorMsg | CreateTime | StartTime | FinishTime | TrackingUrl | LoadStatistic | User | ++----------------+----------------+----------------+-------------------------------+---------+----------+---------------------+---------------------+---------------------+-------------+---------------+------+ +| 79133848479750 | 78533940810334 | insert_tab_job | 78533940810334_79133848479750 | SUCCESS | | 2025-01-17 14:42:54 | 2025-01-17 14:42:54 | 2025-01-17 14:42:54 | | | root | ++----------------+----------------+----------------+-------------------------------+---------+----------+---------------------+---------------------+---------------------+-------------+---------------+------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-valued-functions/jobs.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-valued-functions/jobs.md index 69f010fdccf37..298c8918da369 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-valued-functions/jobs.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-valued-functions/jobs.md @@ -1,7 +1,7 @@ --- { - "title": "JOBS", - "language": "zh-CN" + "title": "JOBS", + "language": "zh-CN" } --- @@ -24,123 +24,87 @@ specific language governing permissions and limitations under the License. --> -## `jobs` - -### Name - -jobs - ## 描述 表函数,生成任务临时表,可以查看某个任务类型中的job信息。 -该函数用于 from 子句中。 +## 语法 -该函数自 2.1.0 版本支持。 +```sql +JOBS( + "type"="" +) +``` -## 语法 +## 必填参数 (Required Parameters) +| 字段名 | 描述 | +|--------------|---------------------------------------------------------------| +| **``** | 任务的类型:
`insert`:insert into 类型的任务。
`mv`:物化视图类型的任务。 | -`jobs("type"="")` -**参数说明** +## 返回值 -| 参数名 | 说明 | 类型 | 是否必填 | -|:-----|:-----|:-------|:-----| -| type | 作业类型 | string | 是 | +- **`jobs("type"="insert")`** insert 类型的 job 返回值 -type 支持的类型: + | 字段名 | 描述 | + |--------------------|--------------------------------| + | Id | job id | + | Name | job名称 | + | Definer | job定义者 | + | ExecuteType | 执行类型 | + | RecurringStrategy | 循环策略 | + | Status | job状态 | + | ExecuteSql | 执行SQL | + | CreateTime | job 创建时间 | + | SucceedTaskCount | 成功任务数量 | + | FailedTaskCount | 失败任务数量 | + | CanceledTaskCount | 取消任务数量 | + | Comment | job 注释 | -- insert:insert into 类型的任务。 -- mv:物化视图类型的任务。 -##### Insert 任务 -jobs("type"="insert")表结构: -```sql -mysql> desc function jobs("type"="insert"); -+-------------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-------------------+------+------+-------+---------+-------+ -| Id | TEXT | No | false | NULL | NONE | -| Name | TEXT | No | false | NULL | NONE | -| Definer | TEXT | No | false | NULL | NONE | -| ExecuteType | TEXT | No | false | NULL | NONE | -| RecurringStrategy | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| ExecuteSql | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -| SucceedTaskCount | TEXT | No | false | NULL | NONE | -| FailedTaskCount | TEXT | No | false | NULL | NONE | -| CanceledTaskCount | TEXT | No | false | NULL | NONE | -| Comment | TEXT | No | false | NULL | NONE | -+-------------------+------+------+-------+---------+-------+ -12 rows in set (0.01 sec) -``` -* Id:job id. -* Name:job名称. -* Definer:job定义者. -* ExecuteType:执行类型 -* RecurringStrategy:循环策略 -* Status:job状态 -* ExecuteSql:执行SQL -* CreateTime:job 创建时间 -* SucceedTaskCount:成功任务数量 -* FailedTaskCount:失败任务数量 -* CanceledTaskCount:取消任务数量 -* Comment:job 注释 -##### 物化视图任务 -jobs("type"="mv")表结构: -```sql -mysql> desc function jobs("type"="mv"); -+-------------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-------------------+------+------+-------+---------+-------+ -| Id | TEXT | No | false | NULL | NONE | -| Name | TEXT | No | false | NULL | NONE | -| MvId | TEXT | No | false | NULL | NONE | -| MvName | TEXT | No | false | NULL | NONE | -| MvDatabaseId | TEXT | No | false | NULL | NONE | -| MvDatabaseName | TEXT | No | false | NULL | NONE | -| ExecuteType | TEXT | No | false | NULL | NONE | -| RecurringStrategy | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -+-------------------+------+------+-------+---------+-------+ -10 rows in set (0.00 sec) -``` -* Id:job id. -* Name:job名称. -* MvId:物化视图id -* MvName:物化视图名称 -* MvDatabaseId:物化视图所属db id -* MvDatabaseName:物化视图所属db名称 -* ExecuteType:执行类型 -* RecurringStrategy:循环策略 -* Status:job状态 -* CreateTime:task创建时间 +- **`jobs("type"="mv")`** MV 类型的 job 返回值 -## 举例 + | 字段名 | 描述 | + |---------------------|--------------------------------------| + | Id | job id | + | Name | job名称 | + | MvId | 物化视图id | + | MvName | 物化视图名称 | + | MvDatabaseId | 物化视图所属db id | + | MvDatabaseName | 物化视图所属db名称 | + | ExecuteType | 执行类型 | + | RecurringStrategy | 循环策略 | + | Status | job状态 | + | CreateTime | task创建时间 | -1. 查看所有物化视图的job -```sql -mysql> select * from jobs("type"="mv"); -``` +## 示例 -2. 查看 name 为`inner_mtmv_75043`的 job +查看所有物化视图的job ```sql -mysql> select * from jobs("type"="mv") where Name="inner_mtmv_75043"; +select * from jobs("type"="mv"); ``` -3. 查看所有 insert 任务 - -```sql -mysql> select * from jobs("type"="insert"); +```text ++-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+-------------+-------------------+---------+---------------------+ +| Id | Name | MvId | MvName | MvDatabaseId | MvDatabaseName | ExecuteType | RecurringStrategy | Status | CreateTime | ++-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+-------------+-------------------+---------+---------------------+ +| 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-08 18:19:10 | +| 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-08 18:19:10 | +| 21794 | inner_mtmv_21788 | 21788 | test_tablet_type_mtmv_mv | 16016 | zd | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-08 12:26:06 | +| 19508 | inner_mtmv_19494 | 19494 | mv1 | 16016 | zd | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-07 22:13:31 | ++-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+-------------+-------------------+---------+---------------------+ ``` -4. 查看 name 为`one_insert_job`的 job + +查看所有 insert 任务的 job ```sql -mysql> select * from jobs("type"="insert") where Name='one_insert_job'; +select * from jobs("type"="insert"); ``` -### keywords - - jobs, job, insert, mv, materialized view, schedule +```text ++----------------+----------------+---------+-------------+--------------------------------------------+---------+--------------------------------------------------------------+---------------------+------------------+-----------------+-------------------+---------+ +| Id | Name | Definer | ExecuteType | RecurringStrategy | Status | ExecuteSql | CreateTime | SucceedTaskCount | FailedTaskCount | CanceledTaskCount | Comment | ++----------------+----------------+---------+-------------+--------------------------------------------+---------+--------------------------------------------------------------+---------------------+------------------+-----------------+-------------------+---------+ +| 78533940810334 | insert_tab_job | root | RECURRING | EVERY 10 MINUTE STARTS 2025-01-17 14:42:53 | RUNNING | INSERT INTO test.insert_tab SELECT * FROM test.example_table | 2025-01-17 14:32:53 | 0 | 0 | 0 | | ++----------------+----------------+---------+-------------+--------------------------------------------+---------+--------------------------------------------------------------+---------------------+------------------+-----------------+-------------------+---------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-functions/numbers.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-valued-functions/numbers.md similarity index 67% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-functions/numbers.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-valued-functions/numbers.md index 6db9da9cf8491..47245d5fac489 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-functions/numbers.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-valued-functions/numbers.md @@ -24,27 +24,40 @@ specific language governing permissions and limitations under the License. --> -## `numbers` - ## 描述 表函数,生成一张只含有一列的临时表,列名为`number`,如果指定了`const_value`,则所有元素值均为`const_value`,否则为[0,`number`)递增。 ## 语法 ```sql -numbers( - "number" = "n" - <, "const_value" = "x"> +NUMBERS( + "number" = "" + [, "" = "" ] ); ``` -参数: -- `number`: 行数。 -- `const_value` : 常量值。 +## 必填参数 + +| 字段 | 描述 | +|--------------|----------| +| **number** | 行数 | + +## 选填参数 + +| 字段 | 描述 | +|----------------|------| +| **const_value** | 常量值 | + +## 返回值 +| 字段名 | 类型 | 描述 | +|----------------|---------|----------| +| **number** | BIGINT | 指定每行返回的值 | ## 举例 +```sql +select * from numbers("number" = "5"); ``` -mysql> select * from numbers("number" = "5"); +```text +--------+ | number | +--------+ @@ -54,9 +67,12 @@ mysql> select * from numbers("number" = "5"); | 3 | | 4 | +--------+ -5 rows in set (0.11 sec) +``` -mysql> select * from numbers("number" = "5", "const_value" = "-123"); +```sql +select * from numbers("number" = "5", "const_value" = "-123"); +``` +```text +--------+ | number | +--------+ @@ -66,11 +82,5 @@ mysql> select * from numbers("number" = "5", "const_value" = "-123"); | -123 | | -123 | +--------+ -5 rows in set (0.12 sec) ``` -### keywords - - numbers, const_value - - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-valued-functions/partitions.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-valued-functions/partitions.md index eb8f6a088e56b..94f94a964c77b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-valued-functions/partitions.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-valued-functions/partitions.md @@ -1,7 +1,7 @@ --- { - "title": "PARTITIONS", - "language": "zh-CN" + "title": "PARTITIONS", + "language": "zh-CN" } --- @@ -24,105 +24,94 @@ specific language governing permissions and limitations under the License. --> -## `partitions` - -### Name - -partitions - ## 描述 表函数,生成分区临时表,可以查看某个 TABLE 的分区列表。 -该函数用于 From 子句中。 - ## 语法 -`partitions("catalog"="","database"="","table"="")` - -partitions()表结构: ```sql -mysql> desc function partitions("catalog"="internal","database"="zd","table"="user"); -+--------------------------+---------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+--------------------------+---------+------+-------+---------+-------+ -| PartitionId | BIGINT | No | false | NULL | NONE | -| PartitionName | TEXT | No | false | NULL | NONE | -| VisibleVersion | BIGINT | No | false | NULL | NONE | -| VisibleVersionTime | TEXT | No | false | NULL | NONE | -| State | TEXT | No | false | NULL | NONE | -| PartitionKey | TEXT | No | false | NULL | NONE | -| Range | TEXT | No | false | NULL | NONE | -| DistributionKey | TEXT | No | false | NULL | NONE | -| Buckets | INT | No | false | NULL | NONE | -| ReplicationNum | INT | No | false | NULL | NONE | -| StorageMedium | TEXT | No | false | NULL | NONE | -| CooldownTime | TEXT | No | false | NULL | NONE | -| RemoteStoragePolicy | TEXT | No | false | NULL | NONE | -| LastConsistencyCheckTime | TEXT | No | false | NULL | NONE | -| DataSize | TEXT | No | false | NULL | NONE | -| IsInMemory | BOOLEAN | No | false | NULL | NONE | -| ReplicaAllocation | TEXT | No | false | NULL | NONE | -| IsMutable | BOOLEAN | No | false | NULL | NONE | -| SyncWithBaseTables | BOOLEAN | No | false | NULL | NONE | -| UnsyncTables | TEXT | No | false | NULL | NONE | -+--------------------------+---------+------+-------+---------+-------+ -20 rows in set (0.02 sec) +PARTITIONS( + "catalog"="", + "database"="", + "table"="
" +) ``` -* PartitionId:分区id -* PartitionName:分区名字 -* VisibleVersion:分区版本 -* VisibleVersionTime:分区版本提交时间 -* State:分区状态 -* PartitionKey:分区key -* Range:分区范围 -* DistributionKey:分布key -* Buckets:分桶数量 -* ReplicationNum:副本数 -* StorageMedium:存储介质 -* CooldownTime:cooldown时间 -* RemoteStoragePolicy:远程存储策略 -* LastConsistencyCheckTime:上次一致性检查时间 -* DataSize:数据大小 -* IsInMemory:是否存在内存 -* ReplicaAllocation:分布策略 -* IsMutable:是否可变 -* SyncWithBaseTables:是否和基表数据同步(针对异步物化视图的分区) -* UnsyncTables:和哪个基表数据不同步(针对异步物化视图的分区) +## 必填参数 (Required Parameters) +| 字段 | 描述 | +|------------------|------------------------------------------| +| **``** | 指定需要查询的集群 catalog 名。 | +| **``** | 指定需要查询的集群数据库名。 | +| **`
`** | 指定需要查询的集群表名。 | + + +## 返回值 + +| 字段名 | 描述 | +|--------------------------|-------------------------| +| PartitionId | 分区ID | +| PartitionName | 分区名称 | +| VisibleVersion | 分区版本 | +| VisibleVersionTime | 分区版本提交时间 | +| State | 分区状态 | +| PartitionKey | 分区键 | +| Range | 分区范围 | +| DistributionKey | 分布键 | +| Buckets | 分桶数量 | +| ReplicationNum | 副本数 | +| StorageMedium | 存储介质 | +| CooldownTime | 冷却时间 | +| RemoteStoragePolicy | 远程存储策略 | +| LastConsistencyCheckTime | 上次一致性检查时间 | +| DataSize | 数据大小 | +| IsInMemory | 是否存在内存 | +| ReplicaAllocation | 分布策略 | +| IsMutable | 是否可变 | +| SyncWithBaseTables | 是否和基表数据同步(针对异步物化视图的分区) | +| UnsyncTables | 和哪个基表数据不同步(针对异步物化视图的分区) | + + +## 示例 + +查看 internal CATALOG 下 test 的 example_table 的分区列表 ```sql -mysql> desc function partitions("catalog"="hive","database"="zdtest","table"="com2"); -+-----------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-----------+------+------+-------+---------+-------+ -| Partition | TEXT | No | false | NULL | NONE | -+-----------+------+------+-------+---------+-------+ -1 row in set (0.11 sec) +select * from partitions("catalog"="internal","database"="test","table"="example_table"); ``` - -* Partition:分区名字 - -## 举例 - -1. 查看 internal CATALOG 下 db1 的 table1 的分区列表 - -```sql -mysql> select * from partitions("catalog"="internal","database"="db1","table"="table1"); +```text ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| 43209 | p1 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [0000-01-01]; ..types: [DATEV2]; keys: [2023-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | +| 43210 | p2 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2023-01-01]; ..types: [DATEV2]; keys: [2024-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | +| 43211 | p3 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2024-01-01]; ..types: [DATEV2]; keys: [2025-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | +| 43212 | p4 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2025-01-01]; ..types: [DATEV2]; keys: [2026-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ ``` -2. 查看 table1 下的分区名称为 partition1 的分区信息 +查看 example_table 下的分区名称为 partition1 的分区信息 ```sql -mysql> select * from partitions("catalog"="internal","database"="db1","table"="table1") where PartitionName = "partition1"; +select * from partitions("catalog"="internal","database"="test","table"="example_table") where PartitionName = "p1"; +``` +```text ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| 43209 | p1 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [0000-01-01]; ..types: [DATEV2]; keys: [2023-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ ``` -3. 查看 table1 下的分区名称为 partition1 的分区 id +查看 user_tab 下的分区名称为 partition1 的分区 id ```sql -mysql> select PartitionId from partitions("catalog"="internal","database"="db1","table"="table1") where PartitionName = "partition1"; +select PartitionId from partitions("catalog"="internal","database"="test","table"="example_table") where PartitionName = "p1"; ``` - -### Keywords - - partitions +```text ++-------------+ +| PartitionId | ++-------------+ +| 43209 | ++-------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-valued-functions/query.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-valued-functions/query.md index 17f183cdc9a50..f6314b344672e 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-valued-functions/query.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-valued-functions/query.md @@ -1,7 +1,7 @@ --- { -"title": "QUERY", -"language": "zh-CN" + "title": "QUERY", + "language": "zh-CN" } --- @@ -24,61 +24,54 @@ 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" = "", + "query" = "" ); ``` -**参数说明** +## 必填参数 +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 | +------+---------+ @@ -86,7 +79,11 @@ select * from query("catalog" = "jdbc", "query" = "select * from test.student"); | 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 | +------+---------+---------+ diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-valued-functions/tasks.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-valued-functions/tasks.md index 1d20eccd10dee..992b76440c33e 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-valued-functions/tasks.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-valued-functions/tasks.md @@ -1,7 +1,7 @@ --- { - "title": "TASKS", - "language": "zh-CN" + "title": "TASKS", + "language": "zh-CN" } --- @@ -24,145 +24,98 @@ specific language governing permissions and limitations under the License. --> -## `tasks` +## 描述 -### Name +表函数,生成 tasks 临时表,可以查看当前 doris 集群中的 job 产生的 tasks 信息。 -tasks +## 语法 +```sql +TASKS( + "type"="" +) +``` -## 描述 +## 必填参数 (Required Parameters) +| 字段名 | 描述 | +|--------------|---------------------------------------------------------------| +| **``** | 任务的类型:
`insert`:insert into 类型的任务。
`mv`:物化视图类型的任务。 | -表函数,生成 tasks 临时表,可以查看当前 doris 集群中的 job 产生的 tasks 信息。 -该函数用于 from 子句中。 +## 返回值 -该函数自 2.1.0 版本支持。 +- **`tasks("type"="insert")`** insert 类型的 tasks 返回值 -## 语法 + | 字段名 | 描述 | + |--------------|---------------------------| + | **TaskId** | task id | + | **JobId** | job id | + | **JobName** | job 名称 | + | **Label** | label | + | **Status** | task 状态 | + | **ErrorMsg** | task 失败信息 | + | **CreateTime**| task 创建时间 | + | **FinishTime**| task 结束时间 | + | **TrackingUrl**| task tracking url | + | **LoadStatistic**| task 统计信息 | + | **User** | 执行用户 | -`tasks("type"="insert");` -**参数说明** -| 参数名 | 说明 | 类型 | 是否必填 | -|:-----|:-------|:-------|:-----| -| type | 作业类型 | string | 是 | -type 支持的类型: +- **`tasks("type"="mv")`** MV 类型的 tasks 返回值 -- insert:insert into 类型的任务。 -- mv: mv 类型的任务 + | 字段名 | 描述 | + |-----------------------|--------------------------------| + | **TaskId** | task id | + | **JobId** | job id | + | **JobName** | job 名称 | + | **MvId** | 物化视图 id | + | **MvName** | 物化视图名称 | + | **MvDatabaseId** | 物化视图所属 db id | + | **MvDatabaseName** | 物化视图所属 db 名称 | + | **Status** | task 状态 | + | **ErrorMsg** | task 失败信息 | + | **CreateTime** | task 创建时间 | + | **StartTime** | task 开始运行时间 | + | **FinishTime** | task 结束运行时间 | + | **DurationMs** | task 运行时间 | + | **TaskContext** | task 运行参数 | + | **RefreshMode** | 刷新模式 | + | **NeedRefreshPartitions** | 本次 task 需要刷新的分区信息 | + | **CompletedPartitions** | 本次 task 刷新完成的分区信息 | + | **Progress** | task 运行进度 | -##### Insert tasks -`tasks("type"="insert");`表结构: -``` -mysql> desc function tasks("type"="insert");; -+---------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+---------------+------+------+-------+---------+-------+ -| TaskId | TEXT | No | false | NULL | NONE | -| JobId | TEXT | No | false | NULL | NONE | -| JobName | TEXT | No | false | NULL | NONE | -| Label | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| ErrorMsg | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -| FinishTime | TEXT | No | false | NULL | NONE | -| TrackingUrl | TEXT | No | false | NULL | NONE | -| LoadStatistic | TEXT | No | false | NULL | NONE | -| User | TEXT | No | false | NULL | NONE | -+---------------+------+------+-------+---------+-------+ -11 row in set (0.01 sec) -``` -- TaskId:task id -- JobId:job id -- JobName:job 名称 -- Label:label -- Status:task 状态 -- ErrorMsg:task 失败信息 -- CreateTime:task 创建时间 -- FinishTime:task 结束时间 -- TrackingUrl:task tracking url -- LoadStatistic:task 统计信息 -- User:执行用户 -##### MV tasks -```sql -mysql> desc function tasks("type"="mv"); -+-----------------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-----------------------+------+------+-------+---------+-------+ -| TaskId | TEXT | No | false | NULL | NONE | -| JobId | TEXT | No | false | NULL | NONE | -| JobName | TEXT | No | false | NULL | NONE | -| MvId | TEXT | No | false | NULL | NONE | -| MvName | TEXT | No | false | NULL | NONE | -| MvDatabaseId | TEXT | No | false | NULL | NONE | -| MvDatabaseName | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| ErrorMsg | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -| StartTime | TEXT | No | false | NULL | NONE | -| FinishTime | TEXT | No | false | NULL | NONE | -| DurationMs | TEXT | No | false | NULL | NONE | -| TaskContext | TEXT | No | false | NULL | NONE | -| RefreshMode | TEXT | No | false | NULL | NONE | -| NeedRefreshPartitions | TEXT | No | false | NULL | NONE | -| CompletedPartitions | TEXT | No | false | NULL | NONE | -| Progress | TEXT | No | false | NULL | NONE | -+-----------------------+------+------+-------+---------+-------+ -18 rows in set (0.00 sec) -``` -* TaskId:task id -* JobId:job id -* JobName:job 名称 -* MvId:物化视图 id -* MvName:物化视图名称 -* MvDatabaseId:物化视图所属 db id -* MvDatabaseName:物化视图所属 db 名称 -* Status:task 状态 -* ErrorMsg:task 失败信息 -* CreateTime:task 创建时间 -* StartTime:task 开始运行时间 -* FinishTime:task 结束运行时间 -* DurationMs:task 运行时间 -* TaskContext:task 运行参数 -* RefreshMode:刷新模式 -* NeedRefreshPartitions:本次 task 需要刷新的分区信息 -* CompletedPartitions:本次 task 刷新完成的分区信息 -* Progress:task 运行进度 - -## 举例 -#### Insert Tasks -``` -mysql> select * from tasks("type"="insert") limit 1 \G -*************************** 1. row *************************** - TaskId: 667704038678903 - JobId: 10069 - Label: 10069_667704038678903 - Status: FINISHED - EtlInfo: \N - TaskInfo: cluster:N/A; timeout(s):14400; max_filter_ratio:0.0; priority:NORMAL - ErrorMsg: \N - CreateTimeMs: 2023-12-08 16:46:57 - FinishTimeMs: 2023-12-08 16:46:57 - TrackingUrl: -LoadStatistic: {"Unfinished backends":{},"ScannedRows":0,"TaskNumber":0,"LoadBytes":0,"All backends":{},"FileNumber":0,"FileSize":0} - User: root -1 row in set (0.05 sec) -``` -#### MV Tasks -1. 查看所有物化视图的 task +## 示例 + +查看所有物化视图的 tasks ```sql -mysql> select * from tasks("type"="mv"); +select * from tasks("type"="mv"); +``` +```text ++-----------------+-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+---------+----------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------------------------------+-----------------------------------------------+---------------+-----------------------------------+ +| TaskId | JobId | JobName | MvId | MvName | MvDatabaseId | MvDatabaseName | Status | ErrorMsg | CreateTime | StartTime | FinishTime | DurationMs | TaskContext | RefreshMode | NeedRefreshPartitions | CompletedPartitions | Progress | LastQueryId | ++-----------------+-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+---------+----------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------------------------------+-----------------------------------------------+---------------+-----------------------------------+ +| 509478985247053 | 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 233 | {"triggerMode":"SYSTEM","isComplete":false} | COMPLETE | ["p_20231001_20231101"] | ["p_20231001_20231101"] | 100.00% (1/1) | 71897c47d0d94fd2-9ca52a0e6eb3bff5 | +| 509486915704885 | 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:17 | 2025-01-08 18:19:17 | 2025-01-08 18:19:17 | 227 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | 9bf5ff69d4cc4c78-b50505436c8410c4 | +| 509487197275880 | 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 191 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | 5b3b4525b6774b5b-89b070042cdcbcd5 | +| 509478131194211 | 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 156 | {"triggerMode":"SYSTEM","isComplete":false} | COMPLETE | ["p_20231001_20231101"] | ["p_20231001_20231101"] | 100.00% (1/1) | 6d0a0782819b446e-b9da5d5de513ce00 | +| 509486057129101 | 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:17 | 2025-01-08 18:19:17 | 2025-01-08 18:19:18 | 213 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | f1303483e3db43e7-aa424acc32dc39ca | +| 509486143784554 | 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 151 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | 8d29b11ac41f4fe0-9d7c86372707310b | +| 488317385772600 | 21794 | inner_mtmv_21788 | 21788 | test_tablet_type_mtmv_mv | 16016 | zd | SUCCESS | | 2025-01-08 12:26:29 | 2025-01-08 12:26:29 | 2025-01-08 12:26:29 | 1 | {"triggerMode":"MANUAL","partitions":[],"isComplete":true} | NOT_REFRESH | [] | \N | \N | | +| 437156301250803 | 19508 | inner_mtmv_19494 | 19494 | mv1 | 16016 | zd | SUCCESS | | 2025-01-07 22:13:48 | 2025-01-07 22:13:48 | 2025-01-07 22:17:45 | 236985 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | COMPLETE | ["p_20210101_MAXVALUE","p_20200101_20210101"] | ["p_20210101_MAXVALUE","p_20200101_20210101"] | 100.00% (2/2) | 7965b4ddce8a4480-8884e9701679c1c4 | +| 439689059641969 | 19508 | inner_mtmv_19494 | 19494 | mv1 | 16016 | zd | SUCCESS | | 2025-01-07 22:55:59 | 2025-01-07 22:55:59 | 2025-01-07 22:55:59 | 35 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | NOT_REFRESH | [] | \N | \N | | ++-----------------+-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+---------+----------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------------------------------+-----------------------------------------------+---------------+-----------------------------------+ ``` -2. 查看 jobName 为`inner_mtmv_75043`的所有 task - +查看所有 insert 任务的 tasks ```sql -mysql> select * from tasks("type"="mv") where JobName="inner_mtmv_75043"; +select * from tasks("type"="insert"); ``` - -### keywords - - tasks, job, insert, mv, materilized view +```text ++----------------+----------------+----------------+-------------------------------+---------+----------+---------------------+---------------------+---------------------+-------------+---------------+------+ +| TaskId | JobId | JobName | Label | Status | ErrorMsg | CreateTime | StartTime | FinishTime | TrackingUrl | LoadStatistic | User | ++----------------+----------------+----------------+-------------------------------+---------+----------+---------------------+---------------------+---------------------+-------------+---------------+------+ +| 79133848479750 | 78533940810334 | insert_tab_job | 78533940810334_79133848479750 | SUCCESS | | 2025-01-17 14:42:54 | 2025-01-17 14:42:54 | 2025-01-17 14:42:54 | | | root | ++----------------+----------------+----------------+-------------------------------+---------+----------+---------------------+---------------------+---------------------+-------------+---------------+------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-valued-functions/jobs.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-valued-functions/jobs.md index 69f010fdccf37..298c8918da369 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-valued-functions/jobs.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-valued-functions/jobs.md @@ -1,7 +1,7 @@ --- { - "title": "JOBS", - "language": "zh-CN" + "title": "JOBS", + "language": "zh-CN" } --- @@ -24,123 +24,87 @@ specific language governing permissions and limitations under the License. --> -## `jobs` - -### Name - -jobs - ## 描述 表函数,生成任务临时表,可以查看某个任务类型中的job信息。 -该函数用于 from 子句中。 +## 语法 -该函数自 2.1.0 版本支持。 +```sql +JOBS( + "type"="" +) +``` -## 语法 +## 必填参数 (Required Parameters) +| 字段名 | 描述 | +|--------------|---------------------------------------------------------------| +| **``** | 任务的类型:
`insert`:insert into 类型的任务。
`mv`:物化视图类型的任务。 | -`jobs("type"="")` -**参数说明** +## 返回值 -| 参数名 | 说明 | 类型 | 是否必填 | -|:-----|:-----|:-------|:-----| -| type | 作业类型 | string | 是 | +- **`jobs("type"="insert")`** insert 类型的 job 返回值 -type 支持的类型: + | 字段名 | 描述 | + |--------------------|--------------------------------| + | Id | job id | + | Name | job名称 | + | Definer | job定义者 | + | ExecuteType | 执行类型 | + | RecurringStrategy | 循环策略 | + | Status | job状态 | + | ExecuteSql | 执行SQL | + | CreateTime | job 创建时间 | + | SucceedTaskCount | 成功任务数量 | + | FailedTaskCount | 失败任务数量 | + | CanceledTaskCount | 取消任务数量 | + | Comment | job 注释 | -- insert:insert into 类型的任务。 -- mv:物化视图类型的任务。 -##### Insert 任务 -jobs("type"="insert")表结构: -```sql -mysql> desc function jobs("type"="insert"); -+-------------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-------------------+------+------+-------+---------+-------+ -| Id | TEXT | No | false | NULL | NONE | -| Name | TEXT | No | false | NULL | NONE | -| Definer | TEXT | No | false | NULL | NONE | -| ExecuteType | TEXT | No | false | NULL | NONE | -| RecurringStrategy | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| ExecuteSql | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -| SucceedTaskCount | TEXT | No | false | NULL | NONE | -| FailedTaskCount | TEXT | No | false | NULL | NONE | -| CanceledTaskCount | TEXT | No | false | NULL | NONE | -| Comment | TEXT | No | false | NULL | NONE | -+-------------------+------+------+-------+---------+-------+ -12 rows in set (0.01 sec) -``` -* Id:job id. -* Name:job名称. -* Definer:job定义者. -* ExecuteType:执行类型 -* RecurringStrategy:循环策略 -* Status:job状态 -* ExecuteSql:执行SQL -* CreateTime:job 创建时间 -* SucceedTaskCount:成功任务数量 -* FailedTaskCount:失败任务数量 -* CanceledTaskCount:取消任务数量 -* Comment:job 注释 -##### 物化视图任务 -jobs("type"="mv")表结构: -```sql -mysql> desc function jobs("type"="mv"); -+-------------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-------------------+------+------+-------+---------+-------+ -| Id | TEXT | No | false | NULL | NONE | -| Name | TEXT | No | false | NULL | NONE | -| MvId | TEXT | No | false | NULL | NONE | -| MvName | TEXT | No | false | NULL | NONE | -| MvDatabaseId | TEXT | No | false | NULL | NONE | -| MvDatabaseName | TEXT | No | false | NULL | NONE | -| ExecuteType | TEXT | No | false | NULL | NONE | -| RecurringStrategy | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -+-------------------+------+------+-------+---------+-------+ -10 rows in set (0.00 sec) -``` -* Id:job id. -* Name:job名称. -* MvId:物化视图id -* MvName:物化视图名称 -* MvDatabaseId:物化视图所属db id -* MvDatabaseName:物化视图所属db名称 -* ExecuteType:执行类型 -* RecurringStrategy:循环策略 -* Status:job状态 -* CreateTime:task创建时间 +- **`jobs("type"="mv")`** MV 类型的 job 返回值 -## 举例 + | 字段名 | 描述 | + |---------------------|--------------------------------------| + | Id | job id | + | Name | job名称 | + | MvId | 物化视图id | + | MvName | 物化视图名称 | + | MvDatabaseId | 物化视图所属db id | + | MvDatabaseName | 物化视图所属db名称 | + | ExecuteType | 执行类型 | + | RecurringStrategy | 循环策略 | + | Status | job状态 | + | CreateTime | task创建时间 | -1. 查看所有物化视图的job -```sql -mysql> select * from jobs("type"="mv"); -``` +## 示例 -2. 查看 name 为`inner_mtmv_75043`的 job +查看所有物化视图的job ```sql -mysql> select * from jobs("type"="mv") where Name="inner_mtmv_75043"; +select * from jobs("type"="mv"); ``` -3. 查看所有 insert 任务 - -```sql -mysql> select * from jobs("type"="insert"); +```text ++-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+-------------+-------------------+---------+---------------------+ +| Id | Name | MvId | MvName | MvDatabaseId | MvDatabaseName | ExecuteType | RecurringStrategy | Status | CreateTime | ++-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+-------------+-------------------+---------+---------------------+ +| 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-08 18:19:10 | +| 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-08 18:19:10 | +| 21794 | inner_mtmv_21788 | 21788 | test_tablet_type_mtmv_mv | 16016 | zd | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-08 12:26:06 | +| 19508 | inner_mtmv_19494 | 19494 | mv1 | 16016 | zd | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-07 22:13:31 | ++-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+-------------+-------------------+---------+---------------------+ ``` -4. 查看 name 为`one_insert_job`的 job + +查看所有 insert 任务的 job ```sql -mysql> select * from jobs("type"="insert") where Name='one_insert_job'; +select * from jobs("type"="insert"); ``` -### keywords - - jobs, job, insert, mv, materialized view, schedule +```text ++----------------+----------------+---------+-------------+--------------------------------------------+---------+--------------------------------------------------------------+---------------------+------------------+-----------------+-------------------+---------+ +| Id | Name | Definer | ExecuteType | RecurringStrategy | Status | ExecuteSql | CreateTime | SucceedTaskCount | FailedTaskCount | CanceledTaskCount | Comment | ++----------------+----------------+---------+-------------+--------------------------------------------+---------+--------------------------------------------------------------+---------------------+------------------+-----------------+-------------------+---------+ +| 78533940810334 | insert_tab_job | root | RECURRING | EVERY 10 MINUTE STARTS 2025-01-17 14:42:53 | RUNNING | INSERT INTO test.insert_tab SELECT * FROM test.example_table | 2025-01-17 14:32:53 | 0 | 0 | 0 | | ++----------------+----------------+---------+-------------+--------------------------------------------+---------+--------------------------------------------------------------+---------------------+------------------+-----------------+-------------------+---------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-functions/numbers.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-valued-functions/numbers.md similarity index 67% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-functions/numbers.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-valued-functions/numbers.md index 6db9da9cf8491..47245d5fac489 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-functions/numbers.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-valued-functions/numbers.md @@ -24,27 +24,40 @@ specific language governing permissions and limitations under the License. --> -## `numbers` - ## 描述 表函数,生成一张只含有一列的临时表,列名为`number`,如果指定了`const_value`,则所有元素值均为`const_value`,否则为[0,`number`)递增。 ## 语法 ```sql -numbers( - "number" = "n" - <, "const_value" = "x"> +NUMBERS( + "number" = "" + [, "" = "" ] ); ``` -参数: -- `number`: 行数。 -- `const_value` : 常量值。 +## 必填参数 + +| 字段 | 描述 | +|--------------|----------| +| **number** | 行数 | + +## 选填参数 + +| 字段 | 描述 | +|----------------|------| +| **const_value** | 常量值 | + +## 返回值 +| 字段名 | 类型 | 描述 | +|----------------|---------|----------| +| **number** | BIGINT | 指定每行返回的值 | ## 举例 +```sql +select * from numbers("number" = "5"); ``` -mysql> select * from numbers("number" = "5"); +```text +--------+ | number | +--------+ @@ -54,9 +67,12 @@ mysql> select * from numbers("number" = "5"); | 3 | | 4 | +--------+ -5 rows in set (0.11 sec) +``` -mysql> select * from numbers("number" = "5", "const_value" = "-123"); +```sql +select * from numbers("number" = "5", "const_value" = "-123"); +``` +```text +--------+ | number | +--------+ @@ -66,11 +82,5 @@ mysql> select * from numbers("number" = "5", "const_value" = "-123"); | -123 | | -123 | +--------+ -5 rows in set (0.12 sec) ``` -### keywords - - numbers, const_value - - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-valued-functions/partitions.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-valued-functions/partitions.md index eb8f6a088e56b..94f94a964c77b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-valued-functions/partitions.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-valued-functions/partitions.md @@ -1,7 +1,7 @@ --- { - "title": "PARTITIONS", - "language": "zh-CN" + "title": "PARTITIONS", + "language": "zh-CN" } --- @@ -24,105 +24,94 @@ specific language governing permissions and limitations under the License. --> -## `partitions` - -### Name - -partitions - ## 描述 表函数,生成分区临时表,可以查看某个 TABLE 的分区列表。 -该函数用于 From 子句中。 - ## 语法 -`partitions("catalog"="","database"="","table"="")` - -partitions()表结构: ```sql -mysql> desc function partitions("catalog"="internal","database"="zd","table"="user"); -+--------------------------+---------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+--------------------------+---------+------+-------+---------+-------+ -| PartitionId | BIGINT | No | false | NULL | NONE | -| PartitionName | TEXT | No | false | NULL | NONE | -| VisibleVersion | BIGINT | No | false | NULL | NONE | -| VisibleVersionTime | TEXT | No | false | NULL | NONE | -| State | TEXT | No | false | NULL | NONE | -| PartitionKey | TEXT | No | false | NULL | NONE | -| Range | TEXT | No | false | NULL | NONE | -| DistributionKey | TEXT | No | false | NULL | NONE | -| Buckets | INT | No | false | NULL | NONE | -| ReplicationNum | INT | No | false | NULL | NONE | -| StorageMedium | TEXT | No | false | NULL | NONE | -| CooldownTime | TEXT | No | false | NULL | NONE | -| RemoteStoragePolicy | TEXT | No | false | NULL | NONE | -| LastConsistencyCheckTime | TEXT | No | false | NULL | NONE | -| DataSize | TEXT | No | false | NULL | NONE | -| IsInMemory | BOOLEAN | No | false | NULL | NONE | -| ReplicaAllocation | TEXT | No | false | NULL | NONE | -| IsMutable | BOOLEAN | No | false | NULL | NONE | -| SyncWithBaseTables | BOOLEAN | No | false | NULL | NONE | -| UnsyncTables | TEXT | No | false | NULL | NONE | -+--------------------------+---------+------+-------+---------+-------+ -20 rows in set (0.02 sec) +PARTITIONS( + "catalog"="", + "database"="", + "table"="
" +) ``` -* PartitionId:分区id -* PartitionName:分区名字 -* VisibleVersion:分区版本 -* VisibleVersionTime:分区版本提交时间 -* State:分区状态 -* PartitionKey:分区key -* Range:分区范围 -* DistributionKey:分布key -* Buckets:分桶数量 -* ReplicationNum:副本数 -* StorageMedium:存储介质 -* CooldownTime:cooldown时间 -* RemoteStoragePolicy:远程存储策略 -* LastConsistencyCheckTime:上次一致性检查时间 -* DataSize:数据大小 -* IsInMemory:是否存在内存 -* ReplicaAllocation:分布策略 -* IsMutable:是否可变 -* SyncWithBaseTables:是否和基表数据同步(针对异步物化视图的分区) -* UnsyncTables:和哪个基表数据不同步(针对异步物化视图的分区) +## 必填参数 (Required Parameters) +| 字段 | 描述 | +|------------------|------------------------------------------| +| **``** | 指定需要查询的集群 catalog 名。 | +| **``** | 指定需要查询的集群数据库名。 | +| **`
`** | 指定需要查询的集群表名。 | + + +## 返回值 + +| 字段名 | 描述 | +|--------------------------|-------------------------| +| PartitionId | 分区ID | +| PartitionName | 分区名称 | +| VisibleVersion | 分区版本 | +| VisibleVersionTime | 分区版本提交时间 | +| State | 分区状态 | +| PartitionKey | 分区键 | +| Range | 分区范围 | +| DistributionKey | 分布键 | +| Buckets | 分桶数量 | +| ReplicationNum | 副本数 | +| StorageMedium | 存储介质 | +| CooldownTime | 冷却时间 | +| RemoteStoragePolicy | 远程存储策略 | +| LastConsistencyCheckTime | 上次一致性检查时间 | +| DataSize | 数据大小 | +| IsInMemory | 是否存在内存 | +| ReplicaAllocation | 分布策略 | +| IsMutable | 是否可变 | +| SyncWithBaseTables | 是否和基表数据同步(针对异步物化视图的分区) | +| UnsyncTables | 和哪个基表数据不同步(针对异步物化视图的分区) | + + +## 示例 + +查看 internal CATALOG 下 test 的 example_table 的分区列表 ```sql -mysql> desc function partitions("catalog"="hive","database"="zdtest","table"="com2"); -+-----------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-----------+------+------+-------+---------+-------+ -| Partition | TEXT | No | false | NULL | NONE | -+-----------+------+------+-------+---------+-------+ -1 row in set (0.11 sec) +select * from partitions("catalog"="internal","database"="test","table"="example_table"); ``` - -* Partition:分区名字 - -## 举例 - -1. 查看 internal CATALOG 下 db1 的 table1 的分区列表 - -```sql -mysql> select * from partitions("catalog"="internal","database"="db1","table"="table1"); +```text ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| 43209 | p1 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [0000-01-01]; ..types: [DATEV2]; keys: [2023-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | +| 43210 | p2 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2023-01-01]; ..types: [DATEV2]; keys: [2024-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | +| 43211 | p3 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2024-01-01]; ..types: [DATEV2]; keys: [2025-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | +| 43212 | p4 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2025-01-01]; ..types: [DATEV2]; keys: [2026-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ ``` -2. 查看 table1 下的分区名称为 partition1 的分区信息 +查看 example_table 下的分区名称为 partition1 的分区信息 ```sql -mysql> select * from partitions("catalog"="internal","database"="db1","table"="table1") where PartitionName = "partition1"; +select * from partitions("catalog"="internal","database"="test","table"="example_table") where PartitionName = "p1"; +``` +```text ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| 43209 | p1 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [0000-01-01]; ..types: [DATEV2]; keys: [2023-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ ``` -3. 查看 table1 下的分区名称为 partition1 的分区 id +查看 user_tab 下的分区名称为 partition1 的分区 id ```sql -mysql> select PartitionId from partitions("catalog"="internal","database"="db1","table"="table1") where PartitionName = "partition1"; +select PartitionId from partitions("catalog"="internal","database"="test","table"="example_table") where PartitionName = "p1"; ``` - -### Keywords - - partitions +```text ++-------------+ +| PartitionId | ++-------------+ +| 43209 | ++-------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-valued-functions/query.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-valued-functions/query.md index 17f183cdc9a50..f6314b344672e 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-valued-functions/query.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-valued-functions/query.md @@ -1,7 +1,7 @@ --- { -"title": "QUERY", -"language": "zh-CN" + "title": "QUERY", + "language": "zh-CN" } --- @@ -24,61 +24,54 @@ 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" = "", + "query" = "" ); ``` -**参数说明** +## 必填参数 +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 | +------+---------+ @@ -86,7 +79,11 @@ select * from query("catalog" = "jdbc", "query" = "select * from test.student"); | 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 | +------+---------+---------+ diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-valued-functions/tasks.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-valued-functions/tasks.md index 1d20eccd10dee..992b76440c33e 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-valued-functions/tasks.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/table-valued-functions/tasks.md @@ -1,7 +1,7 @@ --- { - "title": "TASKS", - "language": "zh-CN" + "title": "TASKS", + "language": "zh-CN" } --- @@ -24,145 +24,98 @@ specific language governing permissions and limitations under the License. --> -## `tasks` +## 描述 -### Name +表函数,生成 tasks 临时表,可以查看当前 doris 集群中的 job 产生的 tasks 信息。 -tasks +## 语法 +```sql +TASKS( + "type"="" +) +``` -## 描述 +## 必填参数 (Required Parameters) +| 字段名 | 描述 | +|--------------|---------------------------------------------------------------| +| **``** | 任务的类型:
`insert`:insert into 类型的任务。
`mv`:物化视图类型的任务。 | -表函数,生成 tasks 临时表,可以查看当前 doris 集群中的 job 产生的 tasks 信息。 -该函数用于 from 子句中。 +## 返回值 -该函数自 2.1.0 版本支持。 +- **`tasks("type"="insert")`** insert 类型的 tasks 返回值 -## 语法 + | 字段名 | 描述 | + |--------------|---------------------------| + | **TaskId** | task id | + | **JobId** | job id | + | **JobName** | job 名称 | + | **Label** | label | + | **Status** | task 状态 | + | **ErrorMsg** | task 失败信息 | + | **CreateTime**| task 创建时间 | + | **FinishTime**| task 结束时间 | + | **TrackingUrl**| task tracking url | + | **LoadStatistic**| task 统计信息 | + | **User** | 执行用户 | -`tasks("type"="insert");` -**参数说明** -| 参数名 | 说明 | 类型 | 是否必填 | -|:-----|:-------|:-------|:-----| -| type | 作业类型 | string | 是 | -type 支持的类型: +- **`tasks("type"="mv")`** MV 类型的 tasks 返回值 -- insert:insert into 类型的任务。 -- mv: mv 类型的任务 + | 字段名 | 描述 | + |-----------------------|--------------------------------| + | **TaskId** | task id | + | **JobId** | job id | + | **JobName** | job 名称 | + | **MvId** | 物化视图 id | + | **MvName** | 物化视图名称 | + | **MvDatabaseId** | 物化视图所属 db id | + | **MvDatabaseName** | 物化视图所属 db 名称 | + | **Status** | task 状态 | + | **ErrorMsg** | task 失败信息 | + | **CreateTime** | task 创建时间 | + | **StartTime** | task 开始运行时间 | + | **FinishTime** | task 结束运行时间 | + | **DurationMs** | task 运行时间 | + | **TaskContext** | task 运行参数 | + | **RefreshMode** | 刷新模式 | + | **NeedRefreshPartitions** | 本次 task 需要刷新的分区信息 | + | **CompletedPartitions** | 本次 task 刷新完成的分区信息 | + | **Progress** | task 运行进度 | -##### Insert tasks -`tasks("type"="insert");`表结构: -``` -mysql> desc function tasks("type"="insert");; -+---------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+---------------+------+------+-------+---------+-------+ -| TaskId | TEXT | No | false | NULL | NONE | -| JobId | TEXT | No | false | NULL | NONE | -| JobName | TEXT | No | false | NULL | NONE | -| Label | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| ErrorMsg | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -| FinishTime | TEXT | No | false | NULL | NONE | -| TrackingUrl | TEXT | No | false | NULL | NONE | -| LoadStatistic | TEXT | No | false | NULL | NONE | -| User | TEXT | No | false | NULL | NONE | -+---------------+------+------+-------+---------+-------+ -11 row in set (0.01 sec) -``` -- TaskId:task id -- JobId:job id -- JobName:job 名称 -- Label:label -- Status:task 状态 -- ErrorMsg:task 失败信息 -- CreateTime:task 创建时间 -- FinishTime:task 结束时间 -- TrackingUrl:task tracking url -- LoadStatistic:task 统计信息 -- User:执行用户 -##### MV tasks -```sql -mysql> desc function tasks("type"="mv"); -+-----------------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-----------------------+------+------+-------+---------+-------+ -| TaskId | TEXT | No | false | NULL | NONE | -| JobId | TEXT | No | false | NULL | NONE | -| JobName | TEXT | No | false | NULL | NONE | -| MvId | TEXT | No | false | NULL | NONE | -| MvName | TEXT | No | false | NULL | NONE | -| MvDatabaseId | TEXT | No | false | NULL | NONE | -| MvDatabaseName | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| ErrorMsg | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -| StartTime | TEXT | No | false | NULL | NONE | -| FinishTime | TEXT | No | false | NULL | NONE | -| DurationMs | TEXT | No | false | NULL | NONE | -| TaskContext | TEXT | No | false | NULL | NONE | -| RefreshMode | TEXT | No | false | NULL | NONE | -| NeedRefreshPartitions | TEXT | No | false | NULL | NONE | -| CompletedPartitions | TEXT | No | false | NULL | NONE | -| Progress | TEXT | No | false | NULL | NONE | -+-----------------------+------+------+-------+---------+-------+ -18 rows in set (0.00 sec) -``` -* TaskId:task id -* JobId:job id -* JobName:job 名称 -* MvId:物化视图 id -* MvName:物化视图名称 -* MvDatabaseId:物化视图所属 db id -* MvDatabaseName:物化视图所属 db 名称 -* Status:task 状态 -* ErrorMsg:task 失败信息 -* CreateTime:task 创建时间 -* StartTime:task 开始运行时间 -* FinishTime:task 结束运行时间 -* DurationMs:task 运行时间 -* TaskContext:task 运行参数 -* RefreshMode:刷新模式 -* NeedRefreshPartitions:本次 task 需要刷新的分区信息 -* CompletedPartitions:本次 task 刷新完成的分区信息 -* Progress:task 运行进度 - -## 举例 -#### Insert Tasks -``` -mysql> select * from tasks("type"="insert") limit 1 \G -*************************** 1. row *************************** - TaskId: 667704038678903 - JobId: 10069 - Label: 10069_667704038678903 - Status: FINISHED - EtlInfo: \N - TaskInfo: cluster:N/A; timeout(s):14400; max_filter_ratio:0.0; priority:NORMAL - ErrorMsg: \N - CreateTimeMs: 2023-12-08 16:46:57 - FinishTimeMs: 2023-12-08 16:46:57 - TrackingUrl: -LoadStatistic: {"Unfinished backends":{},"ScannedRows":0,"TaskNumber":0,"LoadBytes":0,"All backends":{},"FileNumber":0,"FileSize":0} - User: root -1 row in set (0.05 sec) -``` -#### MV Tasks -1. 查看所有物化视图的 task +## 示例 + +查看所有物化视图的 tasks ```sql -mysql> select * from tasks("type"="mv"); +select * from tasks("type"="mv"); +``` +```text ++-----------------+-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+---------+----------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------------------------------+-----------------------------------------------+---------------+-----------------------------------+ +| TaskId | JobId | JobName | MvId | MvName | MvDatabaseId | MvDatabaseName | Status | ErrorMsg | CreateTime | StartTime | FinishTime | DurationMs | TaskContext | RefreshMode | NeedRefreshPartitions | CompletedPartitions | Progress | LastQueryId | ++-----------------+-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+---------+----------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------------------------------+-----------------------------------------------+---------------+-----------------------------------+ +| 509478985247053 | 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 233 | {"triggerMode":"SYSTEM","isComplete":false} | COMPLETE | ["p_20231001_20231101"] | ["p_20231001_20231101"] | 100.00% (1/1) | 71897c47d0d94fd2-9ca52a0e6eb3bff5 | +| 509486915704885 | 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:17 | 2025-01-08 18:19:17 | 2025-01-08 18:19:17 | 227 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | 9bf5ff69d4cc4c78-b50505436c8410c4 | +| 509487197275880 | 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 191 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | 5b3b4525b6774b5b-89b070042cdcbcd5 | +| 509478131194211 | 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 156 | {"triggerMode":"SYSTEM","isComplete":false} | COMPLETE | ["p_20231001_20231101"] | ["p_20231001_20231101"] | 100.00% (1/1) | 6d0a0782819b446e-b9da5d5de513ce00 | +| 509486057129101 | 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:17 | 2025-01-08 18:19:17 | 2025-01-08 18:19:18 | 213 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | f1303483e3db43e7-aa424acc32dc39ca | +| 509486143784554 | 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 151 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | 8d29b11ac41f4fe0-9d7c86372707310b | +| 488317385772600 | 21794 | inner_mtmv_21788 | 21788 | test_tablet_type_mtmv_mv | 16016 | zd | SUCCESS | | 2025-01-08 12:26:29 | 2025-01-08 12:26:29 | 2025-01-08 12:26:29 | 1 | {"triggerMode":"MANUAL","partitions":[],"isComplete":true} | NOT_REFRESH | [] | \N | \N | | +| 437156301250803 | 19508 | inner_mtmv_19494 | 19494 | mv1 | 16016 | zd | SUCCESS | | 2025-01-07 22:13:48 | 2025-01-07 22:13:48 | 2025-01-07 22:17:45 | 236985 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | COMPLETE | ["p_20210101_MAXVALUE","p_20200101_20210101"] | ["p_20210101_MAXVALUE","p_20200101_20210101"] | 100.00% (2/2) | 7965b4ddce8a4480-8884e9701679c1c4 | +| 439689059641969 | 19508 | inner_mtmv_19494 | 19494 | mv1 | 16016 | zd | SUCCESS | | 2025-01-07 22:55:59 | 2025-01-07 22:55:59 | 2025-01-07 22:55:59 | 35 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | NOT_REFRESH | [] | \N | \N | | ++-----------------+-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+---------+----------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------------------------------+-----------------------------------------------+---------------+-----------------------------------+ ``` -2. 查看 jobName 为`inner_mtmv_75043`的所有 task - +查看所有 insert 任务的 tasks ```sql -mysql> select * from tasks("type"="mv") where JobName="inner_mtmv_75043"; +select * from tasks("type"="insert"); ``` - -### keywords - - tasks, job, insert, mv, materilized view +```text ++----------------+----------------+----------------+-------------------------------+---------+----------+---------------------+---------------------+---------------------+-------------+---------------+------+ +| TaskId | JobId | JobName | Label | Status | ErrorMsg | CreateTime | StartTime | FinishTime | TrackingUrl | LoadStatistic | User | ++----------------+----------------+----------------+-------------------------------+---------+----------+---------------------+---------------------+---------------------+-------------+---------------+------+ +| 79133848479750 | 78533940810334 | insert_tab_job | 78533940810334_79133848479750 | SUCCESS | | 2025-01-17 14:42:54 | 2025-01-17 14:42:54 | 2025-01-17 14:42:54 | | | root | ++----------------+----------------+----------------+-------------------------------+---------+----------+---------------------+---------------------+---------------------+-------------+---------------+------+ +``` \ No newline at end of file diff --git a/sidebars.json b/sidebars.json index 878d0ec427d7b..0856ec7080fd3 100644 --- a/sidebars.json +++ b/sidebars.json @@ -1539,7 +1539,6 @@ "sql-manual/sql-functions/table-functions/explode-bitmap-outer", "sql-manual/sql-functions/table-functions/explode-split", "sql-manual/sql-functions/table-functions/explode-split-outer", - "sql-manual/sql-functions/table-functions/numbers", "sql-manual/sql-functions/table-functions/explode-numbers", "sql-manual/sql-functions/table-functions/explode-numbers-outer" ] diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/table-functions/numbers.md b/versioned_docs/version-2.1/sql-manual/sql-functions/table-functions/numbers.md deleted file mode 100644 index 4c15bf202d8b4..0000000000000 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/table-functions/numbers.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -{ - "title": "NUMBERS", - "language": "en" -} ---- - - diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/table-valued-functions/jobs.md b/versioned_docs/version-2.1/sql-manual/sql-functions/table-valued-functions/jobs.md index 3bc7276e08e3e..691f04e1b2405 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/table-valued-functions/jobs.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/table-valued-functions/jobs.md @@ -1,7 +1,7 @@ --- { - "title": "JOBS", - "language": "en" + "title": "JOBS", + "language": "en" } --- @@ -24,127 +24,87 @@ specific language governing permissions and limitations under the License. --> -## `jobs` - -### Name - -jobs - -### description +## Description Table function, generating a temporary task table, which can view job information in a certain task type. -This function is used in the from clause. +## Syntax -This function is supported since 2.1.0. +```sql +JOBS( + "type"="" +) +``` -#### syntax +## Required Parameters +| Field | Description | +|---------------|-----------------------------------------------------------------------------------------------| +| **``** | The type of the job:
`insert`: Insert into type job.
`mv`: Materialized view job. | -`jobs("type"="")` -**parameter description** -| parameter | description | type | required | -|:----------|:------------|:-------|:---------| -| type | job type | string | yes | +## Return Value -the **type** supported types -- insert: insert into type job -- mv: materialized view job +- **`jobs("type"="insert")`** Job return value of type insert -##### insert job -jobs("type"="insert")Table structure: -``` -mysql> desc function jobs("type"="insert"); -+-------------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-------------------+------+------+-------+---------+-------+ -| Id | TEXT | No | false | NULL | NONE | -| Name | TEXT | No | false | NULL | NONE | -| Definer | TEXT | No | false | NULL | NONE | -| ExecuteType | TEXT | No | false | NULL | NONE | -| RecurringStrategy | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| ExecuteSql | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -| SucceedTaskCount | TEXT | No | false | NULL | NONE | -| FailedTaskCount | TEXT | No | false | NULL | NONE | -| CanceledTaskCount | TEXT | No | false | NULL | NONE | -| Comment | TEXT | No | false | NULL | NONE | -+-------------------+------+------+-------+---------+-------+ -12 rows in set (0.01 sec) -``` -* Id: job ID. -* Name: job name. -* Definer: job definer. -* ExecuteType: Execution type -* RecurringStrategy: recurring strategy -* Status: Job status -* ExecuteSql: Execution SQL -* CreateTime: Job creation time -* SucceedTaskCount: Number of successful tasks -* FailedTaskCount: Number of failed tasks -* CanceledTaskCount: Number of canceled tasks -* Comment: job comment - -##### matterialized view job - -jobs("type"="mv")Table structure: -```sql -mysql> desc function jobs("type"="mv"); -+-------------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-------------------+------+------+-------+---------+-------+ -| Id | TEXT | No | false | NULL | NONE | -| Name | TEXT | No | false | NULL | NONE | -| MvId | TEXT | No | false | NULL | NONE | -| MvName | TEXT | No | false | NULL | NONE | -| MvDatabaseId | TEXT | No | false | NULL | NONE | -| MvDatabaseName | TEXT | No | false | NULL | NONE | -| ExecuteType | TEXT | No | false | NULL | NONE | -| RecurringStrategy | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -+-------------------+------+------+-------+---------+-------+ -10 rows in set (0.00 sec) -``` + | Field | Description | + |--------------------|----------------------------| + | Id | Job ID | + | Name | Job name | + | Definer | Job definer | + | ExecuteType | Execution type | + | RecurringStrategy | Recurring strategy | + | Status | Job status | + | ExecuteSql | Execution SQL | + | CreateTime | Job creation time | + | SucceedTaskCount | Number of successful tasks | + | FailedTaskCount | Number of failed tasks | + | CanceledTaskCount | Number of canceled tasks | + | Comment | Job comment | -* Id: job ID. -* Name: job name. -* MvId: Materialized View ID -* MvName: Materialized View Name -* MvDatabaseId: DB ID of the materialized view -* MvDatabaseName: Name of the database to which the materialized view belongs -* ExecuteType: Execution type -* RecurringStrategy: Loop strategy -* Status: Job status -* CreateTime: Task creation time -### example +- **`jobs("type"="mv")`** MV type job return value -1. View jobs in all materialized views + | Field | Description | + |----------------------|-------------------------------------------------------------| + | Id | job ID | + | Name | job name | + | MvId | Materialized View ID | + | MvName | Materialized View Name | + | MvDatabaseId | DB ID of the materialized view | + | MvDatabaseName | Name of the database to which the materialized view belongs | + | ExecuteType | Execution type | + | RecurringStrategy | Loop strategy | + | Status | Job status | + | CreateTime | Task creation time | -```sql -mysql> select * from jobs("type"="mv"); -``` -2. View job with name `inner_mtmv_75043` - -```sql -mysql> select * from jobs("type"="mv") where Name="inner_mtmv_75043"; -``` +## Examples -3. View all insert jobs +View jobs in all materialized views ```sql -mysql> select * from jobs("type"="insert"); +select * from jobs("type"="mv"); +``` +```text ++-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+-------------+-------------------+---------+---------------------+ +| Id | Name | MvId | MvName | MvDatabaseId | MvDatabaseName | ExecuteType | RecurringStrategy | Status | CreateTime | ++-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+-------------+-------------------+---------+---------------------+ +| 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-08 18:19:10 | +| 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-08 18:19:10 | +| 21794 | inner_mtmv_21788 | 21788 | test_tablet_type_mtmv_mv | 16016 | zd | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-08 12:26:06 | +| 19508 | inner_mtmv_19494 | 19494 | mv1 | 16016 | zd | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-07 22:13:31 | ++-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+-------------+-------------------+---------+---------------------+ ``` -4. View job with name `one_insert_job` +View all insert jobs ```sql -mysql> select * from jobs("type"="insert") where Name='one_insert_job'; +select * from jobs("type"="insert"); ``` - -### keywords - - jobs, job, insert, mv, materialized view, schedule +```text ++----------------+----------------+---------+-------------+--------------------------------------------+---------+--------------------------------------------------------------+---------------------+------------------+-----------------+-------------------+---------+ +| Id | Name | Definer | ExecuteType | RecurringStrategy | Status | ExecuteSql | CreateTime | SucceedTaskCount | FailedTaskCount | CanceledTaskCount | Comment | ++----------------+----------------+---------+-------------+--------------------------------------------+---------+--------------------------------------------------------------+---------------------+------------------+-----------------+-------------------+---------+ +| 78533940810334 | insert_tab_job | root | RECURRING | EVERY 10 MINUTE STARTS 2025-01-17 14:42:53 | RUNNING | INSERT INTO test.insert_tab SELECT * FROM test.example_table | 2025-01-17 14:32:53 | 0 | 0 | 0 | | ++----------------+----------------+---------+-------------+--------------------------------------------+---------+--------------------------------------------------------------+---------------------+------------------+-----------------+-------------------+---------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/table-valued-functions/numbers.md b/versioned_docs/version-2.1/sql-manual/sql-functions/table-valued-functions/numbers.md index 723d62154aa89..236f9a51736d1 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/table-valued-functions/numbers.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/table-valued-functions/numbers.md @@ -1,7 +1,7 @@ --- { - "title": "NUMBERS", - "language": "en" + "title": "NUMBERS", + "language": "en" } --- @@ -24,27 +24,44 @@ specific language governing permissions and limitations under the License. --> -## `numbers` -### description +## Description Table function that generates a temporary table containing only one column with the column name `number` and all element values are `const_value` if `const_value` is specified, otherwise they are [0,`number`) incremented. -#### syntax +## Syntax ```sql -numbers( - "number" = "n" - <, "const_value" = "x"> +NUMBERS( + "number" = "" + [, "" = "" ] ); ``` -parameter: -- `number`: Line number. -- `const_value`: the constant value. +## Required Parameters -### example +| Field | Description | +|---------------|---------------------------| +| **number** | The number of rows | + +## Optional Parameters + +| Field | Description | +|-------------------|------------------------------------------| +| **const_value** | Specifies the constant value generated | + + + +## Return Value +| Field | Type | Description | +|----------------|---------|---------------------------------| +| **number** | BIGINT | The value returned for each row | + + +## Examples +```sql +select * from numbers("number" = "5"); ``` -mysql> select * from numbers("number" = "5"); +```text +--------+ | number | +--------+ @@ -54,9 +71,12 @@ mysql> select * from numbers("number" = "5"); | 3 | | 4 | +--------+ -5 rows in set (0.11 sec) +``` -mysql> select * from numbers("number" = "5", "const_value" = "-123"); +```sql +select * from numbers("number" = "5", "const_value" = "-123"); +``` +```text +--------+ | number | +--------+ @@ -66,9 +86,4 @@ mysql> select * from numbers("number" = "5", "const_value" = "-123"); | -123 | | -123 | +--------+ -5 rows in set (0.12 sec) -``` - -### keywords - - numbers, const_value \ No newline at end of file +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/table-valued-functions/partitions.md b/versioned_docs/version-2.1/sql-manual/sql-functions/table-valued-functions/partitions.md index b5ffa054b6c0d..bfaec1d39291b 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/table-valued-functions/partitions.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/table-valued-functions/partitions.md @@ -1,7 +1,7 @@ --- { - "title": "PARTITIONS", - "language": "en" + "title": "PARTITIONS", + "language": "en" } --- @@ -24,105 +24,94 @@ specific language governing permissions and limitations under the License. --> -## `partitions` - -### Name - -partitions - -### Description +## Description The table function generates a temporary partition TABLE, which allows you to view the PARTITION list of a certain TABLE. -This function is used in the from clause. - -#### Syntax +## Syntax -`partitions("catalog"="","database"="","table"="")` - -partitions() Table structure: ```sql -mysql> desc function partitions("catalog"="internal","database"="zd","table"="user"); -+--------------------------+---------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+--------------------------+---------+------+-------+---------+-------+ -| PartitionId | BIGINT | No | false | NULL | NONE | -| PartitionName | TEXT | No | false | NULL | NONE | -| VisibleVersion | BIGINT | No | false | NULL | NONE | -| VisibleVersionTime | TEXT | No | false | NULL | NONE | -| State | TEXT | No | false | NULL | NONE | -| PartitionKey | TEXT | No | false | NULL | NONE | -| Range | TEXT | No | false | NULL | NONE | -| DistributionKey | TEXT | No | false | NULL | NONE | -| Buckets | INT | No | false | NULL | NONE | -| ReplicationNum | INT | No | false | NULL | NONE | -| StorageMedium | TEXT | No | false | NULL | NONE | -| CooldownTime | TEXT | No | false | NULL | NONE | -| RemoteStoragePolicy | TEXT | No | false | NULL | NONE | -| LastConsistencyCheckTime | TEXT | No | false | NULL | NONE | -| DataSize | TEXT | No | false | NULL | NONE | -| IsInMemory | BOOLEAN | No | false | NULL | NONE | -| ReplicaAllocation | TEXT | No | false | NULL | NONE | -| IsMutable | BOOLEAN | No | false | NULL | NONE | -| SyncWithBaseTables | BOOLEAN | No | false | NULL | NONE | -| UnsyncTables | TEXT | No | false | NULL | NONE | -+--------------------------+---------+------+-------+---------+-------+ -20 rows in set (0.02 sec) +PARTITIONS( + "catalog"="", + "database"="", + "table"="
" +) ``` -* PartitionId:partition id -* PartitionName:partition name -* VisibleVersion:visible version -* VisibleVersionTime:visible version time -* State:state -* PartitionKey:partition key -* Range:range -* DistributionKey:distribution key -* Buckets:bucket num -* ReplicationNum:replication num -* StorageMedium:storage medium -* CooldownTime:cooldown time -* RemoteStoragePolicy:remote storage policy -* LastConsistencyCheckTime:last consistency check time -* DataSize:data size -* IsInMemory:is in memory -* ReplicaAllocation:replica allocation -* IsMutable:is mutable -* SyncWithBaseTables:Is it synchronized with the base table data (for partitioning asynchronous materialized views) -* UnsyncTables:Which base table data is not synchronized with (for partitions of asynchronous materialized views) +## Required Parameters +| Field | Description | +|------------------|--------------------------------------------------| +| **``** | Specify the cluster catalog name to be queried. | +| **``** | Specify the cluster database name to be queried. | +| **`
`** | Specify the cluster table name to be queried. | + + +## Return Value +| Field | Description | +|---------------------------|-----------------------------------------------------------------------------| +| PartitionId | Partition ID | +| PartitionName | Name of the partition | +| VisibleVersion | Partition version | +| VisibleVersionTime | Time when the partition version was committed | +| State | State of the partition | +| PartitionKey | Partition key | +| Range | Range of the partition | +| DistributionKey | Distribution key for partitioning | +| Buckets | Number of buckets in the partition | +| ReplicationNum | Number of replicas in the partition | +| StorageMedium | Storage medium used for the partition | +| CooldownTime | Cooldown time for the partition | +| RemoteStoragePolicy | Remote storage policy for the partition | +| LastConsistencyCheckTime | Time of the last consistency check for the partition | +| DataSize | Size of the data in the partition | +| IsInMemory | Whether the partition is stored in memory | +| ReplicaAllocation | Replication strategy for the partition | +| IsMutable | Whether the partition is mutable | +| SyncWithBaseTables | Whether the partition is synchronized with the base table (for async materialized views) | +| UnsyncTables | Which base table is unsynchronized (for async materialized view partitions) | + + + +## Examples +View the partition list of example_table under test in the internal catalog ```sql -mysql> desc function partitions("catalog"="hive","database"="zdtest","table"="com2"); -+-----------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-----------+------+------+-------+---------+-------+ -| Partition | TEXT | No | false | NULL | NONE | -+-----------+------+------+-------+---------+-------+ -1 row in set (0.11 sec) +select * from partitions("catalog"="internal","database"="test","table"="example_table"); ``` - -* Partition:partition name - -### Example - -1. View the partition list of table1 under db1 in the internal catalog - -```sql -mysql> select * from partitions("catalog"="internal","database"="db1","table"="table1"); +```text ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| 43209 | p1 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [0000-01-01]; ..types: [DATEV2]; keys: [2023-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | +| 43210 | p2 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2023-01-01]; ..types: [DATEV2]; keys: [2024-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | +| 43211 | p3 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2024-01-01]; ..types: [DATEV2]; keys: [2025-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | +| 43212 | p4 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2025-01-01]; ..types: [DATEV2]; keys: [2026-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ ``` -2. View the partition information with partition name partition1 under table1 +View the partition information with partition name p1 under example_table ```sql -mysql> select * from partitions("catalog"="internal","database"="db1","table"="table1") where PartitionName = "partition1"; +select * from partitions("catalog"="internal","database"="test","table"="example_table") where PartitionName = "p1"; +``` +```text ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| 43209 | p1 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [0000-01-01]; ..types: [DATEV2]; keys: [2023-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ ``` -3. View the partition ID with the partition name 'partition1' under Table 1 +View the partition ID with the partition name p1 under example_table ```sql -mysql> select PartitionId from partitions("catalog"="internal","database"="db1","table"="table1") where PartitionName = "partition1"; +select PartitionId from partitions("catalog"="internal","database"="test","table"="example_table") where PartitionName = "p1"; +``` +```text ++-------------+ +| PartitionId | ++-------------+ +| 43209 | ++-------------+ ``` -### Keywords - - partitions diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/table-valued-functions/query.md b/versioned_docs/version-2.1/sql-manual/sql-functions/table-valued-functions/query.md index f3f0adfd5f2a3..f26d9c0d3de36 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/table-valued-functions/query.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/table-valued-functions/query.md @@ -24,61 +24,54 @@ 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" = "", + "query" = "" ); ``` -**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 | +------+---------+ @@ -86,7 +79,11 @@ select * from query("catalog" = "jdbc", "query" = "select * from test.student"); | 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 | +------+---------+---------+ diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/table-valued-functions/tasks.md b/versioned_docs/version-2.1/sql-manual/sql-functions/table-valued-functions/tasks.md index ebd279effe65d..431a66efee7fc 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/table-valued-functions/tasks.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/table-valued-functions/tasks.md @@ -1,7 +1,7 @@ --- { - "title": "TASKS", - "language": "en" + "title": "TASKS", + "language": "en" } --- @@ -24,151 +24,99 @@ specific language governing permissions and limitations under the License. --> -## `tasks` -### Name - -:::tip -tasks -- since 2.1 -::: - -### description +## Description Table function, generates a temporary table of tasks, which allows you to view the information of tasks generated by jobs in the current Doris cluster. -This function is used in the FROM clause. - -This functions is supported since 2.1.0. - -#### syntax - -`tasks("type"="insert");` -**parameter description** - -| parameter | description | type | required | -|:----------|:------------|:-------|:---------| -| type | job type | string | yes | - -the **type** supported types -- insert: insert into type job -- mv: materilized view type job - -##### Insert tasks - -The table schema of `tasks("type"="insert");` tvf: - -``` -mysql> desc function tasks("type"="insert");; -+---------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+---------------+------+------+-------+---------+-------+ -| TaskId | TEXT | No | false | NULL | NONE | -| JobId | TEXT | No | false | NULL | NONE | -| JobName | TEXT | No | false | NULL | NONE | -| Label | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| ErrorMsg | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -| FinishTime | TEXT | No | false | NULL | NONE | -| TrackingUrl | TEXT | No | false | NULL | NONE | -| LoadStatistic | TEXT | No | false | NULL | NONE | -| User | TEXT | No | false | NULL | NONE | -+---------------+------+------+-------+---------+-------+ -11 row in set (0.01 sec) -``` -- TaskId: task id -- JobId: job id -- JobName: job name -- Label: label -- Status: task status -- ErrorMsg: task failure information -- CreateTime: task creation time -- FinishTime: task completion time -- TrackingUrl: tracking URL -- LoadStatistic: load statistics -- User: user -##### MV Tasks +## Syntax ```sql -mysql> desc function tasks("type"="mv"); -+-----------------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-----------------------+------+------+-------+---------+-------+ -| TaskId | TEXT | No | false | NULL | NONE | -| JobId | TEXT | No | false | NULL | NONE | -| JobName | TEXT | No | false | NULL | NONE | -| MvId | TEXT | No | false | NULL | NONE | -| MvName | TEXT | No | false | NULL | NONE | -| MvDatabaseId | TEXT | No | false | NULL | NONE | -| MvDatabaseName | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| ErrorMsg | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -| StartTime | TEXT | No | false | NULL | NONE | -| FinishTime | TEXT | No | false | NULL | NONE | -| DurationMs | TEXT | No | false | NULL | NONE | -| TaskContext | TEXT | No | false | NULL | NONE | -| RefreshMode | TEXT | No | false | NULL | NONE | -| NeedRefreshPartitions | TEXT | No | false | NULL | NONE | -| CompletedPartitions | TEXT | No | false | NULL | NONE | -| Progress | TEXT | No | false | NULL | NONE | -+-----------------------+------+------+-------+---------+-------+ -18 rows in set (0.00 sec) -``` - -* TaskId: task id -* JobId: job id -* JobName: job Name -* MvId: Materialized View ID -* MvName: Materialized View Name -* MvDatabaseId: DB ID of the materialized view -* MvDatabaseName: Name of the database to which the materialized view belongs -* Status: task status -* ErrorMsg: Task failure information -* CreateTime: Task creation time -* StartTime: Task start running time -* FinishTime: Task End Run Time -* DurationMs: Task runtime -* TaskContext: Task running parameters -* RefreshMode: refresh mode -* NeedRefreshPartitions: The partition information that needs to be refreshed for this task -* CompletedPartitions: The partition information that has been refreshed for this task -* Progress: Task running progress -### example -#### Insert Tasls -``` -mysql> select * from tasks("type"="insert") limit 1 \G -*************************** 1. row *************************** - TaskId: 667704038678903 - JobId: 10069 - Label: 10069_667704038678903 - Status: FINISHED - EtlInfo: \N - TaskInfo: cluster:N/A; timeout(s):14400; max_filter_ratio:0.0; priority:NORMAL - ErrorMsg: \N - CreateTimeMs: 2023-12-08 16:46:57 - FinishTimeMs: 2023-12-08 16:46:57 - TrackingUrl: -LoadStatistic: {"Unfinished backends":{},"ScannedRows":0,"TaskNumber":0,"LoadBytes":0,"All backends":{},"FileNumber":0,"FileSize":0} - User: root -1 row in set (0.05 sec) - +TASKS( + "type"="" +) ``` -#### MV Tasks -1. View tasks for all materialized views +## Required Parameters +| Field | Description | +|---------------|---------------------------------------------------------------------------------------------------| +| **``** | Type of the task:
`insert`: insert into type task.
`mv`: materialized view type task. | + + +## Return Value + +- **`tasks("type"="insert")`** tasks return value of type insert + + | Field Name | Description | + |--------------|------------------------------------| + | **TaskId** | Task id | + | **JobId** | Job id | + | **JobName** | Job name | + | **Label** | Label | + | **Status** | Task status | + | **ErrorMsg** | Task failure information | + | **CreateTime**| Task creation time | + | **FinishTime**| Task completion time | + | **TrackingUrl**| Tracking URL | + | **LoadStatistic**| Load statistics | + | **User** | User | + +- **`tasks("type"="mv")`** Tasks return value of type MV + + | Field Name | Description | + |-----------------------|-----------------------------------------------------------------------------| + | **TaskId** | Task id | + | **JobId** | Job id | + | **JobName** | Job Name | + | **MvId** | Materialized View ID | + | **MvName** | Materialized View Name | + | **MvDatabaseId** | DB ID of the materialized view | + | **MvDatabaseName** | Name of the database to which the materialized view belongs | + | **Status** | Task status | + | **ErrorMsg** | Task failure information | + | **CreateTime** | Task creation time | + | **StartTime** | Task start running time | + | **FinishTime** | Task End Run Time | + | **DurationMs** | Task runtime | + | **TaskContext** | Task running parameters | + | **RefreshMode** | Refresh mode | + | **NeedRefreshPartitions** | The partition information that needs to be refreshed for this task | + | **CompletedPartitions** | The partition information that has been refreshed for this task | + | **Progress** | Task running progress | + + +## Examples + +View tasks for all materialized views ```sql -mysql> select * from tasks("type"="mv"); +select * from tasks("type"="mv"); +``` +```text ++-----------------+-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+---------+----------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------------------------------+-----------------------------------------------+---------------+-----------------------------------+ +| TaskId | JobId | JobName | MvId | MvName | MvDatabaseId | MvDatabaseName | Status | ErrorMsg | CreateTime | StartTime | FinishTime | DurationMs | TaskContext | RefreshMode | NeedRefreshPartitions | CompletedPartitions | Progress | LastQueryId | ++-----------------+-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+---------+----------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------------------------------+-----------------------------------------------+---------------+-----------------------------------+ +| 509478985247053 | 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 233 | {"triggerMode":"SYSTEM","isComplete":false} | COMPLETE | ["p_20231001_20231101"] | ["p_20231001_20231101"] | 100.00% (1/1) | 71897c47d0d94fd2-9ca52a0e6eb3bff5 | +| 509486915704885 | 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:17 | 2025-01-08 18:19:17 | 2025-01-08 18:19:17 | 227 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | 9bf5ff69d4cc4c78-b50505436c8410c4 | +| 509487197275880 | 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 191 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | 5b3b4525b6774b5b-89b070042cdcbcd5 | +| 509478131194211 | 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 156 | {"triggerMode":"SYSTEM","isComplete":false} | COMPLETE | ["p_20231001_20231101"] | ["p_20231001_20231101"] | 100.00% (1/1) | 6d0a0782819b446e-b9da5d5de513ce00 | +| 509486057129101 | 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:17 | 2025-01-08 18:19:17 | 2025-01-08 18:19:18 | 213 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | f1303483e3db43e7-aa424acc32dc39ca | +| 509486143784554 | 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 151 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | 8d29b11ac41f4fe0-9d7c86372707310b | +| 488317385772600 | 21794 | inner_mtmv_21788 | 21788 | test_tablet_type_mtmv_mv | 16016 | zd | SUCCESS | | 2025-01-08 12:26:29 | 2025-01-08 12:26:29 | 2025-01-08 12:26:29 | 1 | {"triggerMode":"MANUAL","partitions":[],"isComplete":true} | NOT_REFRESH | [] | \N | \N | | +| 437156301250803 | 19508 | inner_mtmv_19494 | 19494 | mv1 | 16016 | zd | SUCCESS | | 2025-01-07 22:13:48 | 2025-01-07 22:13:48 | 2025-01-07 22:17:45 | 236985 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | COMPLETE | ["p_20210101_MAXVALUE","p_20200101_20210101"] | ["p_20210101_MAXVALUE","p_20200101_20210101"] | 100.00% (2/2) | 7965b4ddce8a4480-8884e9701679c1c4 | +| 439689059641969 | 19508 | inner_mtmv_19494 | 19494 | mv1 | 16016 | zd | SUCCESS | | 2025-01-07 22:55:59 | 2025-01-07 22:55:59 | 2025-01-07 22:55:59 | 35 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | NOT_REFRESH | [] | \N | \N | | ++-----------------+-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+---------+----------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------------------------------+-----------------------------------------------+---------------+-----------------------------------+ ``` -2. View all tasks with jobName `inner_mtmv_75043` +View tasks for all insert tasks ```sql -mysql> select * from tasks("type"="mv") where JobName="inner_mtmv_75043"; +select * from tasks("type"="insert"); +``` +```text ++----------------+----------------+----------------+-------------------------------+---------+----------+---------------------+---------------------+---------------------+-------------+---------------+------+ +| TaskId | JobId | JobName | Label | Status | ErrorMsg | CreateTime | StartTime | FinishTime | TrackingUrl | LoadStatistic | User | ++----------------+----------------+----------------+-------------------------------+---------+----------+---------------------+---------------------+---------------------+-------------+---------------+------+ +| 79133848479750 | 78533940810334 | insert_tab_job | 78533940810334_79133848479750 | SUCCESS | | 2025-01-17 14:42:54 | 2025-01-17 14:42:54 | 2025-01-17 14:42:54 | | | root | ++----------------+----------------+----------------+-------------------------------+---------+----------+---------------------+---------------------+---------------------+-------------+---------------+------+ ``` - -### keywords - - tasks, job, insert, mv, materilized view diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/table-functions/numbers.md b/versioned_docs/version-3.0/sql-manual/sql-functions/table-functions/numbers.md deleted file mode 100644 index 4c15bf202d8b4..0000000000000 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/table-functions/numbers.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -{ - "title": "NUMBERS", - "language": "en" -} ---- - - diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/table-valued-functions/jobs.md b/versioned_docs/version-3.0/sql-manual/sql-functions/table-valued-functions/jobs.md index 3bc7276e08e3e..691f04e1b2405 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/table-valued-functions/jobs.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/table-valued-functions/jobs.md @@ -1,7 +1,7 @@ --- { - "title": "JOBS", - "language": "en" + "title": "JOBS", + "language": "en" } --- @@ -24,127 +24,87 @@ specific language governing permissions and limitations under the License. --> -## `jobs` - -### Name - -jobs - -### description +## Description Table function, generating a temporary task table, which can view job information in a certain task type. -This function is used in the from clause. +## Syntax -This function is supported since 2.1.0. +```sql +JOBS( + "type"="" +) +``` -#### syntax +## Required Parameters +| Field | Description | +|---------------|-----------------------------------------------------------------------------------------------| +| **``** | The type of the job:
`insert`: Insert into type job.
`mv`: Materialized view job. | -`jobs("type"="")` -**parameter description** -| parameter | description | type | required | -|:----------|:------------|:-------|:---------| -| type | job type | string | yes | +## Return Value -the **type** supported types -- insert: insert into type job -- mv: materialized view job +- **`jobs("type"="insert")`** Job return value of type insert -##### insert job -jobs("type"="insert")Table structure: -``` -mysql> desc function jobs("type"="insert"); -+-------------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-------------------+------+------+-------+---------+-------+ -| Id | TEXT | No | false | NULL | NONE | -| Name | TEXT | No | false | NULL | NONE | -| Definer | TEXT | No | false | NULL | NONE | -| ExecuteType | TEXT | No | false | NULL | NONE | -| RecurringStrategy | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| ExecuteSql | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -| SucceedTaskCount | TEXT | No | false | NULL | NONE | -| FailedTaskCount | TEXT | No | false | NULL | NONE | -| CanceledTaskCount | TEXT | No | false | NULL | NONE | -| Comment | TEXT | No | false | NULL | NONE | -+-------------------+------+------+-------+---------+-------+ -12 rows in set (0.01 sec) -``` -* Id: job ID. -* Name: job name. -* Definer: job definer. -* ExecuteType: Execution type -* RecurringStrategy: recurring strategy -* Status: Job status -* ExecuteSql: Execution SQL -* CreateTime: Job creation time -* SucceedTaskCount: Number of successful tasks -* FailedTaskCount: Number of failed tasks -* CanceledTaskCount: Number of canceled tasks -* Comment: job comment - -##### matterialized view job - -jobs("type"="mv")Table structure: -```sql -mysql> desc function jobs("type"="mv"); -+-------------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-------------------+------+------+-------+---------+-------+ -| Id | TEXT | No | false | NULL | NONE | -| Name | TEXT | No | false | NULL | NONE | -| MvId | TEXT | No | false | NULL | NONE | -| MvName | TEXT | No | false | NULL | NONE | -| MvDatabaseId | TEXT | No | false | NULL | NONE | -| MvDatabaseName | TEXT | No | false | NULL | NONE | -| ExecuteType | TEXT | No | false | NULL | NONE | -| RecurringStrategy | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -+-------------------+------+------+-------+---------+-------+ -10 rows in set (0.00 sec) -``` + | Field | Description | + |--------------------|----------------------------| + | Id | Job ID | + | Name | Job name | + | Definer | Job definer | + | ExecuteType | Execution type | + | RecurringStrategy | Recurring strategy | + | Status | Job status | + | ExecuteSql | Execution SQL | + | CreateTime | Job creation time | + | SucceedTaskCount | Number of successful tasks | + | FailedTaskCount | Number of failed tasks | + | CanceledTaskCount | Number of canceled tasks | + | Comment | Job comment | -* Id: job ID. -* Name: job name. -* MvId: Materialized View ID -* MvName: Materialized View Name -* MvDatabaseId: DB ID of the materialized view -* MvDatabaseName: Name of the database to which the materialized view belongs -* ExecuteType: Execution type -* RecurringStrategy: Loop strategy -* Status: Job status -* CreateTime: Task creation time -### example +- **`jobs("type"="mv")`** MV type job return value -1. View jobs in all materialized views + | Field | Description | + |----------------------|-------------------------------------------------------------| + | Id | job ID | + | Name | job name | + | MvId | Materialized View ID | + | MvName | Materialized View Name | + | MvDatabaseId | DB ID of the materialized view | + | MvDatabaseName | Name of the database to which the materialized view belongs | + | ExecuteType | Execution type | + | RecurringStrategy | Loop strategy | + | Status | Job status | + | CreateTime | Task creation time | -```sql -mysql> select * from jobs("type"="mv"); -``` -2. View job with name `inner_mtmv_75043` - -```sql -mysql> select * from jobs("type"="mv") where Name="inner_mtmv_75043"; -``` +## Examples -3. View all insert jobs +View jobs in all materialized views ```sql -mysql> select * from jobs("type"="insert"); +select * from jobs("type"="mv"); +``` +```text ++-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+-------------+-------------------+---------+---------------------+ +| Id | Name | MvId | MvName | MvDatabaseId | MvDatabaseName | ExecuteType | RecurringStrategy | Status | CreateTime | ++-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+-------------+-------------------+---------+---------------------+ +| 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-08 18:19:10 | +| 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-08 18:19:10 | +| 21794 | inner_mtmv_21788 | 21788 | test_tablet_type_mtmv_mv | 16016 | zd | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-08 12:26:06 | +| 19508 | inner_mtmv_19494 | 19494 | mv1 | 16016 | zd | MANUAL | MANUAL TRIGGER | RUNNING | 2025-01-07 22:13:31 | ++-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+-------------+-------------------+---------+---------------------+ ``` -4. View job with name `one_insert_job` +View all insert jobs ```sql -mysql> select * from jobs("type"="insert") where Name='one_insert_job'; +select * from jobs("type"="insert"); ``` - -### keywords - - jobs, job, insert, mv, materialized view, schedule +```text ++----------------+----------------+---------+-------------+--------------------------------------------+---------+--------------------------------------------------------------+---------------------+------------------+-----------------+-------------------+---------+ +| Id | Name | Definer | ExecuteType | RecurringStrategy | Status | ExecuteSql | CreateTime | SucceedTaskCount | FailedTaskCount | CanceledTaskCount | Comment | ++----------------+----------------+---------+-------------+--------------------------------------------+---------+--------------------------------------------------------------+---------------------+------------------+-----------------+-------------------+---------+ +| 78533940810334 | insert_tab_job | root | RECURRING | EVERY 10 MINUTE STARTS 2025-01-17 14:42:53 | RUNNING | INSERT INTO test.insert_tab SELECT * FROM test.example_table | 2025-01-17 14:32:53 | 0 | 0 | 0 | | ++----------------+----------------+---------+-------------+--------------------------------------------+---------+--------------------------------------------------------------+---------------------+------------------+-----------------+-------------------+---------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/table-valued-functions/numbers.md b/versioned_docs/version-3.0/sql-manual/sql-functions/table-valued-functions/numbers.md index 723d62154aa89..236f9a51736d1 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/table-valued-functions/numbers.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/table-valued-functions/numbers.md @@ -1,7 +1,7 @@ --- { - "title": "NUMBERS", - "language": "en" + "title": "NUMBERS", + "language": "en" } --- @@ -24,27 +24,44 @@ specific language governing permissions and limitations under the License. --> -## `numbers` -### description +## Description Table function that generates a temporary table containing only one column with the column name `number` and all element values are `const_value` if `const_value` is specified, otherwise they are [0,`number`) incremented. -#### syntax +## Syntax ```sql -numbers( - "number" = "n" - <, "const_value" = "x"> +NUMBERS( + "number" = "" + [, "" = "" ] ); ``` -parameter: -- `number`: Line number. -- `const_value`: the constant value. +## Required Parameters -### example +| Field | Description | +|---------------|---------------------------| +| **number** | The number of rows | + +## Optional Parameters + +| Field | Description | +|-------------------|------------------------------------------| +| **const_value** | Specifies the constant value generated | + + + +## Return Value +| Field | Type | Description | +|----------------|---------|---------------------------------| +| **number** | BIGINT | The value returned for each row | + + +## Examples +```sql +select * from numbers("number" = "5"); ``` -mysql> select * from numbers("number" = "5"); +```text +--------+ | number | +--------+ @@ -54,9 +71,12 @@ mysql> select * from numbers("number" = "5"); | 3 | | 4 | +--------+ -5 rows in set (0.11 sec) +``` -mysql> select * from numbers("number" = "5", "const_value" = "-123"); +```sql +select * from numbers("number" = "5", "const_value" = "-123"); +``` +```text +--------+ | number | +--------+ @@ -66,9 +86,4 @@ mysql> select * from numbers("number" = "5", "const_value" = "-123"); | -123 | | -123 | +--------+ -5 rows in set (0.12 sec) -``` - -### keywords - - numbers, const_value \ No newline at end of file +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/table-valued-functions/partitions.md b/versioned_docs/version-3.0/sql-manual/sql-functions/table-valued-functions/partitions.md index b5ffa054b6c0d..bfaec1d39291b 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/table-valued-functions/partitions.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/table-valued-functions/partitions.md @@ -1,7 +1,7 @@ --- { - "title": "PARTITIONS", - "language": "en" + "title": "PARTITIONS", + "language": "en" } --- @@ -24,105 +24,94 @@ specific language governing permissions and limitations under the License. --> -## `partitions` - -### Name - -partitions - -### Description +## Description The table function generates a temporary partition TABLE, which allows you to view the PARTITION list of a certain TABLE. -This function is used in the from clause. - -#### Syntax +## Syntax -`partitions("catalog"="","database"="","table"="")` - -partitions() Table structure: ```sql -mysql> desc function partitions("catalog"="internal","database"="zd","table"="user"); -+--------------------------+---------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+--------------------------+---------+------+-------+---------+-------+ -| PartitionId | BIGINT | No | false | NULL | NONE | -| PartitionName | TEXT | No | false | NULL | NONE | -| VisibleVersion | BIGINT | No | false | NULL | NONE | -| VisibleVersionTime | TEXT | No | false | NULL | NONE | -| State | TEXT | No | false | NULL | NONE | -| PartitionKey | TEXT | No | false | NULL | NONE | -| Range | TEXT | No | false | NULL | NONE | -| DistributionKey | TEXT | No | false | NULL | NONE | -| Buckets | INT | No | false | NULL | NONE | -| ReplicationNum | INT | No | false | NULL | NONE | -| StorageMedium | TEXT | No | false | NULL | NONE | -| CooldownTime | TEXT | No | false | NULL | NONE | -| RemoteStoragePolicy | TEXT | No | false | NULL | NONE | -| LastConsistencyCheckTime | TEXT | No | false | NULL | NONE | -| DataSize | TEXT | No | false | NULL | NONE | -| IsInMemory | BOOLEAN | No | false | NULL | NONE | -| ReplicaAllocation | TEXT | No | false | NULL | NONE | -| IsMutable | BOOLEAN | No | false | NULL | NONE | -| SyncWithBaseTables | BOOLEAN | No | false | NULL | NONE | -| UnsyncTables | TEXT | No | false | NULL | NONE | -+--------------------------+---------+------+-------+---------+-------+ -20 rows in set (0.02 sec) +PARTITIONS( + "catalog"="", + "database"="", + "table"="
" +) ``` -* PartitionId:partition id -* PartitionName:partition name -* VisibleVersion:visible version -* VisibleVersionTime:visible version time -* State:state -* PartitionKey:partition key -* Range:range -* DistributionKey:distribution key -* Buckets:bucket num -* ReplicationNum:replication num -* StorageMedium:storage medium -* CooldownTime:cooldown time -* RemoteStoragePolicy:remote storage policy -* LastConsistencyCheckTime:last consistency check time -* DataSize:data size -* IsInMemory:is in memory -* ReplicaAllocation:replica allocation -* IsMutable:is mutable -* SyncWithBaseTables:Is it synchronized with the base table data (for partitioning asynchronous materialized views) -* UnsyncTables:Which base table data is not synchronized with (for partitions of asynchronous materialized views) +## Required Parameters +| Field | Description | +|------------------|--------------------------------------------------| +| **``** | Specify the cluster catalog name to be queried. | +| **``** | Specify the cluster database name to be queried. | +| **`
`** | Specify the cluster table name to be queried. | + + +## Return Value +| Field | Description | +|---------------------------|-----------------------------------------------------------------------------| +| PartitionId | Partition ID | +| PartitionName | Name of the partition | +| VisibleVersion | Partition version | +| VisibleVersionTime | Time when the partition version was committed | +| State | State of the partition | +| PartitionKey | Partition key | +| Range | Range of the partition | +| DistributionKey | Distribution key for partitioning | +| Buckets | Number of buckets in the partition | +| ReplicationNum | Number of replicas in the partition | +| StorageMedium | Storage medium used for the partition | +| CooldownTime | Cooldown time for the partition | +| RemoteStoragePolicy | Remote storage policy for the partition | +| LastConsistencyCheckTime | Time of the last consistency check for the partition | +| DataSize | Size of the data in the partition | +| IsInMemory | Whether the partition is stored in memory | +| ReplicaAllocation | Replication strategy for the partition | +| IsMutable | Whether the partition is mutable | +| SyncWithBaseTables | Whether the partition is synchronized with the base table (for async materialized views) | +| UnsyncTables | Which base table is unsynchronized (for async materialized view partitions) | + + + +## Examples +View the partition list of example_table under test in the internal catalog ```sql -mysql> desc function partitions("catalog"="hive","database"="zdtest","table"="com2"); -+-----------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-----------+------+------+-------+---------+-------+ -| Partition | TEXT | No | false | NULL | NONE | -+-----------+------+------+-------+---------+-------+ -1 row in set (0.11 sec) +select * from partitions("catalog"="internal","database"="test","table"="example_table"); ``` - -* Partition:partition name - -### Example - -1. View the partition list of table1 under db1 in the internal catalog - -```sql -mysql> select * from partitions("catalog"="internal","database"="db1","table"="table1"); +```text ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| 43209 | p1 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [0000-01-01]; ..types: [DATEV2]; keys: [2023-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | +| 43210 | p2 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2023-01-01]; ..types: [DATEV2]; keys: [2024-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | +| 43211 | p3 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2024-01-01]; ..types: [DATEV2]; keys: [2025-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | +| 43212 | p4 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [2025-01-01]; ..types: [DATEV2]; keys: [2026-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ ``` -2. View the partition information with partition name partition1 under table1 +View the partition information with partition name p1 under example_table ```sql -mysql> select * from partitions("catalog"="internal","database"="db1","table"="table1") where PartitionName = "partition1"; +select * from partitions("catalog"="internal","database"="test","table"="example_table") where PartitionName = "p1"; +``` +```text ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| PartitionId | PartitionName | VisibleVersion | VisibleVersionTime | State | PartitionKey | Range | DistributionKey | Buckets | ReplicationNum | StorageMedium | CooldownTime | RemoteStoragePolicy | LastConsistencyCheckTime | DataSize | IsInMemory | ReplicaAllocation | IsMutable | SyncWithBaseTables | UnsyncTables | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ +| 43209 | p1 | 1 | 2025-01-17 12:35:22 | NORMAL | created_at | [types: [DATEV2]; keys: [0000-01-01]; ..types: [DATEV2]; keys: [2023-01-01]; ) | id | 10 | 1 | HDD | 9999-12-31 23:59:59 | | \N | 0.000 | 0 | tag.location.default: 1 | 1 | 1 | \N | ++-------------+---------------+----------------+---------------------+--------+--------------+--------------------------------------------------------------------------------+-----------------+---------+----------------+---------------+---------------------+---------------------+--------------------------+----------+------------+-------------------------+-----------+--------------------+--------------+ ``` -3. View the partition ID with the partition name 'partition1' under Table 1 +View the partition ID with the partition name p1 under example_table ```sql -mysql> select PartitionId from partitions("catalog"="internal","database"="db1","table"="table1") where PartitionName = "partition1"; +select PartitionId from partitions("catalog"="internal","database"="test","table"="example_table") where PartitionName = "p1"; +``` +```text ++-------------+ +| PartitionId | ++-------------+ +| 43209 | ++-------------+ ``` -### Keywords - - partitions diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/table-valued-functions/query.md b/versioned_docs/version-3.0/sql-manual/sql-functions/table-valued-functions/query.md index f3f0adfd5f2a3..f26d9c0d3de36 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/table-valued-functions/query.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/table-valued-functions/query.md @@ -24,61 +24,54 @@ 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" = "", + "query" = "" ); ``` -**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 | +------+---------+ @@ -86,7 +79,11 @@ select * from query("catalog" = "jdbc", "query" = "select * from test.student"); | 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 | +------+---------+---------+ diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/table-valued-functions/tasks.md b/versioned_docs/version-3.0/sql-manual/sql-functions/table-valued-functions/tasks.md index ebd279effe65d..431a66efee7fc 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/table-valued-functions/tasks.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/table-valued-functions/tasks.md @@ -1,7 +1,7 @@ --- { - "title": "TASKS", - "language": "en" + "title": "TASKS", + "language": "en" } --- @@ -24,151 +24,99 @@ specific language governing permissions and limitations under the License. --> -## `tasks` -### Name - -:::tip -tasks -- since 2.1 -::: - -### description +## Description Table function, generates a temporary table of tasks, which allows you to view the information of tasks generated by jobs in the current Doris cluster. -This function is used in the FROM clause. - -This functions is supported since 2.1.0. - -#### syntax - -`tasks("type"="insert");` -**parameter description** - -| parameter | description | type | required | -|:----------|:------------|:-------|:---------| -| type | job type | string | yes | - -the **type** supported types -- insert: insert into type job -- mv: materilized view type job - -##### Insert tasks - -The table schema of `tasks("type"="insert");` tvf: - -``` -mysql> desc function tasks("type"="insert");; -+---------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+---------------+------+------+-------+---------+-------+ -| TaskId | TEXT | No | false | NULL | NONE | -| JobId | TEXT | No | false | NULL | NONE | -| JobName | TEXT | No | false | NULL | NONE | -| Label | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| ErrorMsg | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -| FinishTime | TEXT | No | false | NULL | NONE | -| TrackingUrl | TEXT | No | false | NULL | NONE | -| LoadStatistic | TEXT | No | false | NULL | NONE | -| User | TEXT | No | false | NULL | NONE | -+---------------+------+------+-------+---------+-------+ -11 row in set (0.01 sec) -``` -- TaskId: task id -- JobId: job id -- JobName: job name -- Label: label -- Status: task status -- ErrorMsg: task failure information -- CreateTime: task creation time -- FinishTime: task completion time -- TrackingUrl: tracking URL -- LoadStatistic: load statistics -- User: user -##### MV Tasks +## Syntax ```sql -mysql> desc function tasks("type"="mv"); -+-----------------------+------+------+-------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-----------------------+------+------+-------+---------+-------+ -| TaskId | TEXT | No | false | NULL | NONE | -| JobId | TEXT | No | false | NULL | NONE | -| JobName | TEXT | No | false | NULL | NONE | -| MvId | TEXT | No | false | NULL | NONE | -| MvName | TEXT | No | false | NULL | NONE | -| MvDatabaseId | TEXT | No | false | NULL | NONE | -| MvDatabaseName | TEXT | No | false | NULL | NONE | -| Status | TEXT | No | false | NULL | NONE | -| ErrorMsg | TEXT | No | false | NULL | NONE | -| CreateTime | TEXT | No | false | NULL | NONE | -| StartTime | TEXT | No | false | NULL | NONE | -| FinishTime | TEXT | No | false | NULL | NONE | -| DurationMs | TEXT | No | false | NULL | NONE | -| TaskContext | TEXT | No | false | NULL | NONE | -| RefreshMode | TEXT | No | false | NULL | NONE | -| NeedRefreshPartitions | TEXT | No | false | NULL | NONE | -| CompletedPartitions | TEXT | No | false | NULL | NONE | -| Progress | TEXT | No | false | NULL | NONE | -+-----------------------+------+------+-------+---------+-------+ -18 rows in set (0.00 sec) -``` - -* TaskId: task id -* JobId: job id -* JobName: job Name -* MvId: Materialized View ID -* MvName: Materialized View Name -* MvDatabaseId: DB ID of the materialized view -* MvDatabaseName: Name of the database to which the materialized view belongs -* Status: task status -* ErrorMsg: Task failure information -* CreateTime: Task creation time -* StartTime: Task start running time -* FinishTime: Task End Run Time -* DurationMs: Task runtime -* TaskContext: Task running parameters -* RefreshMode: refresh mode -* NeedRefreshPartitions: The partition information that needs to be refreshed for this task -* CompletedPartitions: The partition information that has been refreshed for this task -* Progress: Task running progress -### example -#### Insert Tasls -``` -mysql> select * from tasks("type"="insert") limit 1 \G -*************************** 1. row *************************** - TaskId: 667704038678903 - JobId: 10069 - Label: 10069_667704038678903 - Status: FINISHED - EtlInfo: \N - TaskInfo: cluster:N/A; timeout(s):14400; max_filter_ratio:0.0; priority:NORMAL - ErrorMsg: \N - CreateTimeMs: 2023-12-08 16:46:57 - FinishTimeMs: 2023-12-08 16:46:57 - TrackingUrl: -LoadStatistic: {"Unfinished backends":{},"ScannedRows":0,"TaskNumber":0,"LoadBytes":0,"All backends":{},"FileNumber":0,"FileSize":0} - User: root -1 row in set (0.05 sec) - +TASKS( + "type"="" +) ``` -#### MV Tasks -1. View tasks for all materialized views +## Required Parameters +| Field | Description | +|---------------|---------------------------------------------------------------------------------------------------| +| **``** | Type of the task:
`insert`: insert into type task.
`mv`: materialized view type task. | + + +## Return Value + +- **`tasks("type"="insert")`** tasks return value of type insert + + | Field Name | Description | + |--------------|------------------------------------| + | **TaskId** | Task id | + | **JobId** | Job id | + | **JobName** | Job name | + | **Label** | Label | + | **Status** | Task status | + | **ErrorMsg** | Task failure information | + | **CreateTime**| Task creation time | + | **FinishTime**| Task completion time | + | **TrackingUrl**| Tracking URL | + | **LoadStatistic**| Load statistics | + | **User** | User | + +- **`tasks("type"="mv")`** Tasks return value of type MV + + | Field Name | Description | + |-----------------------|-----------------------------------------------------------------------------| + | **TaskId** | Task id | + | **JobId** | Job id | + | **JobName** | Job Name | + | **MvId** | Materialized View ID | + | **MvName** | Materialized View Name | + | **MvDatabaseId** | DB ID of the materialized view | + | **MvDatabaseName** | Name of the database to which the materialized view belongs | + | **Status** | Task status | + | **ErrorMsg** | Task failure information | + | **CreateTime** | Task creation time | + | **StartTime** | Task start running time | + | **FinishTime** | Task End Run Time | + | **DurationMs** | Task runtime | + | **TaskContext** | Task running parameters | + | **RefreshMode** | Refresh mode | + | **NeedRefreshPartitions** | The partition information that needs to be refreshed for this task | + | **CompletedPartitions** | The partition information that has been refreshed for this task | + | **Progress** | Task running progress | + + +## Examples + +View tasks for all materialized views ```sql -mysql> select * from tasks("type"="mv"); +select * from tasks("type"="mv"); +``` +```text ++-----------------+-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+---------+----------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------------------------------+-----------------------------------------------+---------------+-----------------------------------+ +| TaskId | JobId | JobName | MvId | MvName | MvDatabaseId | MvDatabaseName | Status | ErrorMsg | CreateTime | StartTime | FinishTime | DurationMs | TaskContext | RefreshMode | NeedRefreshPartitions | CompletedPartitions | Progress | LastQueryId | ++-----------------+-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+---------+----------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------------------------------+-----------------------------------------------+---------------+-----------------------------------+ +| 509478985247053 | 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 233 | {"triggerMode":"SYSTEM","isComplete":false} | COMPLETE | ["p_20231001_20231101"] | ["p_20231001_20231101"] | 100.00% (1/1) | 71897c47d0d94fd2-9ca52a0e6eb3bff5 | +| 509486915704885 | 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:17 | 2025-01-08 18:19:17 | 2025-01-08 18:19:17 | 227 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | 9bf5ff69d4cc4c78-b50505436c8410c4 | +| 509487197275880 | 23369 | inner_mtmv_23363 | 23363 | range_date_up_union_mv1 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 191 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | 5b3b4525b6774b5b-89b070042cdcbcd5 | +| 509478131194211 | 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 2025-01-08 18:19:10 | 156 | {"triggerMode":"SYSTEM","isComplete":false} | COMPLETE | ["p_20231001_20231101"] | ["p_20231001_20231101"] | 100.00% (1/1) | 6d0a0782819b446e-b9da5d5de513ce00 | +| 509486057129101 | 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:17 | 2025-01-08 18:19:17 | 2025-01-08 18:19:18 | 213 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | f1303483e3db43e7-aa424acc32dc39ca | +| 509486143784554 | 23377 | inner_mtmv_23371 | 23371 | range_date_up_union_mv2 | 21805 | regression_test_nereids_rules_p0_mv_create_part_and_up | SUCCESS | | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 2025-01-08 18:19:18 | 151 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | PARTIAL | ["p_20231101_20231201"] | ["p_20231101_20231201"] | 100.00% (1/1) | 8d29b11ac41f4fe0-9d7c86372707310b | +| 488317385772600 | 21794 | inner_mtmv_21788 | 21788 | test_tablet_type_mtmv_mv | 16016 | zd | SUCCESS | | 2025-01-08 12:26:29 | 2025-01-08 12:26:29 | 2025-01-08 12:26:29 | 1 | {"triggerMode":"MANUAL","partitions":[],"isComplete":true} | NOT_REFRESH | [] | \N | \N | | +| 437156301250803 | 19508 | inner_mtmv_19494 | 19494 | mv1 | 16016 | zd | SUCCESS | | 2025-01-07 22:13:48 | 2025-01-07 22:13:48 | 2025-01-07 22:17:45 | 236985 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | COMPLETE | ["p_20210101_MAXVALUE","p_20200101_20210101"] | ["p_20210101_MAXVALUE","p_20200101_20210101"] | 100.00% (2/2) | 7965b4ddce8a4480-8884e9701679c1c4 | +| 439689059641969 | 19508 | inner_mtmv_19494 | 19494 | mv1 | 16016 | zd | SUCCESS | | 2025-01-07 22:55:59 | 2025-01-07 22:55:59 | 2025-01-07 22:55:59 | 35 | {"triggerMode":"MANUAL","partitions":[],"isComplete":false} | NOT_REFRESH | [] | \N | \N | | ++-----------------+-------+------------------+-------+--------------------------+--------------+--------------------------------------------------------+---------+----------+---------------------+---------------------+---------------------+------------+-------------------------------------------------------------+-------------+-----------------------------------------------+-----------------------------------------------+---------------+-----------------------------------+ ``` -2. View all tasks with jobName `inner_mtmv_75043` +View tasks for all insert tasks ```sql -mysql> select * from tasks("type"="mv") where JobName="inner_mtmv_75043"; +select * from tasks("type"="insert"); +``` +```text ++----------------+----------------+----------------+-------------------------------+---------+----------+---------------------+---------------------+---------------------+-------------+---------------+------+ +| TaskId | JobId | JobName | Label | Status | ErrorMsg | CreateTime | StartTime | FinishTime | TrackingUrl | LoadStatistic | User | ++----------------+----------------+----------------+-------------------------------+---------+----------+---------------------+---------------------+---------------------+-------------+---------------+------+ +| 79133848479750 | 78533940810334 | insert_tab_job | 78533940810334_79133848479750 | SUCCESS | | 2025-01-17 14:42:54 | 2025-01-17 14:42:54 | 2025-01-17 14:42:54 | | | root | ++----------------+----------------+----------------+-------------------------------+---------+----------+---------------------+---------------------+---------------------+-------------+---------------+------+ ``` - -### keywords - - tasks, job, insert, mv, materilized view diff --git a/versioned_sidebars/version-2.1-sidebars.json b/versioned_sidebars/version-2.1-sidebars.json index 5f6841967796f..798b1eab572af 100644 --- a/versioned_sidebars/version-2.1-sidebars.json +++ b/versioned_sidebars/version-2.1-sidebars.json @@ -1528,7 +1528,6 @@ "sql-manual/sql-functions/table-functions/explode-bitmap-outer", "sql-manual/sql-functions/table-functions/explode-split", "sql-manual/sql-functions/table-functions/explode-split-outer", - "sql-manual/sql-functions/table-functions/numbers", "sql-manual/sql-functions/table-functions/explode-numbers", "sql-manual/sql-functions/table-functions/explode-numbers-outer" ] diff --git a/versioned_sidebars/version-3.0-sidebars.json b/versioned_sidebars/version-3.0-sidebars.json index 511b7e11a0847..bfdc357f9fd4c 100644 --- a/versioned_sidebars/version-3.0-sidebars.json +++ b/versioned_sidebars/version-3.0-sidebars.json @@ -1587,7 +1587,6 @@ "sql-manual/sql-functions/table-functions/explode-bitmap-outer", "sql-manual/sql-functions/table-functions/explode-split", "sql-manual/sql-functions/table-functions/explode-split-outer", - "sql-manual/sql-functions/table-functions/numbers", "sql-manual/sql-functions/table-functions/explode-numbers", "sql-manual/sql-functions/table-functions/explode-numbers-outer" ]