Skip to content

Commit

Permalink
improve query(), number(),tasks(),jobs(),partitions() function articl…
Browse files Browse the repository at this point in the history
…e format (apache#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
  • Loading branch information
DongLiang-0 authored and echo-hhj committed Jan 23, 2025
1 parent 86d4cd6 commit cc39912
Show file tree
Hide file tree
Showing 36 changed files with 1,652 additions and 2,252 deletions.
25 changes: 0 additions & 25 deletions docs/sql-manual/sql-functions/table-functions/numbers.md

This file was deleted.

164 changes: 62 additions & 102 deletions docs/sql-manual/sql-functions/table-valued-functions/jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"="<type>"
)
```

#### syntax
## Required Parameters
| Field | Description |
|---------------|-----------------------------------------------------------------------------------------------|
| **`<type>`** | The type of the job: <br/> `insert`: Insert into type job. <br/> `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 | |
+----------------+----------------+---------+-------------+--------------------------------------------+---------+--------------------------------------------------------------+---------------------+------------------+-----------------+-------------------+---------+
```
53 changes: 34 additions & 19 deletions docs/sql-manual/sql-functions/table-valued-functions/numbers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" = "<number>"
[, "<const_value>" = "<const_value>" ]
);
```

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 |
+--------+
Expand All @@ -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 |
+--------+
Expand All @@ -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
```
Loading

0 comments on commit cc39912

Please sign in to comment.