-
Notifications
You must be signed in to change notification settings - Fork 712
IMPORT INTO: update document for SHOW IMPORT
#21610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
e781ad2
978c792
1c4cbd1
9248b55
af8657a
9970993
e3d312e
8ac1977
2188a5b
074cbb1
caac9a6
54a5a83
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| --- | ||
| title: SHOW IMPORT GROUP | ||
| summary: An overview of the usage of SHOW IMPORT GROUP in TiDB. | ||
| --- | ||
|
|
||
| # SHOW IMPORT GROUP | ||
|
|
||
| The `SHOW IMPORT GROUP` statement is used to show the groups of `IMPORT` jobs created in TiDB. By default, `SHOW IMPORT GROUPS` shows groups created by the current user. To view all import groups, you need the `SUPER` privilege. | ||
|
|
||
| ## Required privileges | ||
|
|
||
| - `SHOW IMPORT GROUPS`: if a user has the `SUPER` privilege, this statement shows all import groups in TiDB. Otherwise, this statement only shows groups created by the current user. | ||
| - `SHOW IMPORT GROUP <group-key>`: only the creator of an import group or users with the `SUPER` privilege can use this statement to view a specific import group. | ||
|
|
||
| ## Synopsis | ||
|
|
||
| ```ebnf+diagram | ||
| ShowImportGroupsStmt ::= | ||
| 'SHOW' 'IMPORT' 'GROUPS' | ||
|
|
||
| ShowImportGroupStmt ::= | ||
| 'SHOW' 'IMPORT' 'GROUP' GroupKey | ||
| ``` | ||
|
|
||
| The output fields of the `SHOW IMPORT GROUP` statement are described as follows: | ||
|
|
||
| | Column | Description | | ||
| |------------------|-------------------------| | ||
| | Group_Key | The key of the group | | ||
| | Total_Jobs | Total number of jobs in this group | | ||
| | Pending | Number of pending jobs in this group | | ||
| | Running | Number of running jobs in this group | | ||
| | Completed | Number of completed jobs in this group | | ||
| | Failed | Number of failed jobs in this group | | ||
| | Cancelled | Number of cancelled jobs in this group | | ||
| | First_Job_Create_Time | The earliest creation time of the jobs in this group | | ||
| | Last_Job_Update_Time | The latest update time of the jobs in this group | | ||
|
|
||
| ## Example | ||
|
|
||
| ```sql | ||
| SHOW IMPORT GROUPS; | ||
| ``` | ||
|
|
||
| ``` | ||
| +--------------+------------+---------+---------+-----------+--------+-----------+----------------------------+----------------------------+ | ||
| | Group_Key | Total_Jobs | Pending | Running | Completed | Failed | Cancelled | First_Job_Create_Time | Last_Job_Update_Time | | ||
| +--------------+------------+---------+---------+-----------+--------+-----------+----------------------------+----------------------------+ | ||
| | import_group_1 | 1 | 0 | 1 | 0 | 0 | 0 | 2025-08-07 01:36:18.479055 | 2025-08-07 01:36:18.479055 | | ||
| +--------------+------------+---------+---------+-----------+--------+-----------+----------------------------+----------------------------+ | ||
| | user_group | 1 | 1 | 0 | 0 | 0 | 0 | 2025-08-07 01:37:26.162268 | NULL | | ||
| +--------------+------------+---------+---------+-----------+--------+-----------+----------------------------+----------------------------+ | ||
| 2 rows in set (0.01 sec) | ||
| ``` | ||
|
|
||
| ```sql | ||
| SHOW IMPORT GROUP "import_group_1"; | ||
| ``` | ||
|
|
||
| ``` | ||
| +--------------+------------+---------+---------+-----------+--------+-----------+----------------------------+----------------------------+ | ||
| | Group_Key | Total_Jobs | Pending | Running | Completed | Failed | Cancelled | First_Job_Create_Time | Last_Job_Update_Time | | ||
| +--------------+------------+---------+---------+-----------+--------+-----------+----------------------------+----------------------------+ | ||
| | import_group_1 | 1 | 0 | 1 | 0 | 0 | 0 | 2025-08-07 01:36:18.479055 | 2025-08-07 01:36:18.479055 | | ||
| +--------------+------------+---------+---------+-----------+--------+-----------+----------------------------+----------------------------+ | ||
| 1 row in set (0.01 sec) | ||
| ``` | ||
|
|
||
| ## MySQL compatibility | ||
|
|
||
| This statement is a TiDB extension to MySQL syntax. | ||
|
|
||
| ## See also | ||
|
|
||
| * [`IMPORT INTO`](/sql-statements/sql-statement-import-into.md) | ||
| * [`SHOW IMPORT JOB`](/sql-statements/sql-statement-show-import-job.md) | ||
| * [`CANCEL IMPORT JOB`](/sql-statements/sql-statement-cancel-import-job.md) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| --- | ||
| title: SHOW IMPORT | ||
| summary: An overview of the usage of SHOW IMPORT in TiDB. | ||
| title: SHOW IMPORT JOB | ||
| summary: An overview of the usage of SHOW IMPORT JOB in TiDB. | ||
| --- | ||
|
|
||
| # SHOW IMPORT | ||
| # SHOW IMPORT JOB | ||
|
|
||
| The `SHOW IMPORT` statement is used to show the IMPORT jobs created in TiDB. This statement can only show jobs created by the current user. | ||
| The `SHOW IMPORT JOB` statement is used to show `IMPORT` jobs created in TiDB. By default, `SHOW IMPORT JOBS` shows jobs created by the current user. To view all import jobs, you need the `SUPER` privilege. | ||
|
|
||
| ## Required privileges | ||
|
|
||
|
|
@@ -16,19 +16,25 @@ | |
|
|
||
| ```ebnf+diagram | ||
| ShowImportJobsStmt ::= | ||
| 'SHOW' 'IMPORT' 'JOBS' | ||
| 'SHOW' 'IMPORT' 'JOBS' ShowLikeOrWhereOpt? | ||
|
|
||
| ShowImportJobStmt ::= | ||
| 'SHOW' 'IMPORT' 'JOB' JobID | ||
|
|
||
| ShowLikeOrWhereOpt ::= | ||
| 'LIKE' SimpleExpr | ||
|
D3Hunter marked this conversation as resolved.
|
||
| | 'WHERE' Expression | ||
| ``` | ||
|
|
||
| The output fields of the `SHOW IMPORT` statement are described as follows: | ||
| The output fields of the `SHOW IMPORT JOB` statement are described as follows: | ||
|
|
||
| | Column | Description | | ||
| |------------------|-------------------------| | ||
| | Job_ID | The ID of the task | | ||
| | Job_ID | The ID of the job | | ||
| | Group_Key | The group key of the job | | ||
| | Data_Source | Information about the data source | | ||
| | Target_Table | The name of the target table | | ||
| | Table_ID | The ID of the target table | | ||
| | Phase | The current phase of the job, including `importing`, `validating`, and `add-index` | | ||
| | Status | The current status of the job, including `pending` (means created but not started yet), `running`, `canceled`, `failed`, and `finished` | | ||
| | Source_File_Size | The size of the source file | | ||
|
|
@@ -38,34 +44,46 @@ | |
| | Start_Time | The time when the task is started | | ||
| | End_Time | The time when the task is ended | | ||
| | Created_By | The name of the database user who creates the task | | ||
| | Last_Update_Time | The time when the job was last updated | | ||
| | Cur_Step | The specific sequential processing step of this job | | ||
| | Cur_Step_Processed_Size | The amount of data that has been processed within the current step | | ||
| | Cur_Step_Total_Size | The total size of the data to be processed in the current step | | ||
| | Cur_Step_Progress_Pct | The estimated completion percentage of the current step | | ||
| | Cur_Step_Speed | The current data processing speed | | ||
| | Cur_Step_ETA | The estimated time remaining for the current step to complete | | ||
|
|
||
| ## Filtering import jobs | ||
|
|
||
| Only `SHOW IMPORT JOBS` supports filtering import jobs with a `WHERE` or `LIKE` clause. `SHOW IMPORT JOB <job-id>` does not support these clauses. | ||
|
|
||
| The `WHERE` clause can reference the output fields of `SHOW IMPORT JOBS`, including `Job_ID`, `Group_Key`, `Data_Source`, `Target_Table`, `Table_ID`, `Phase`, `Status`, `Source_File_Size`, `Imported_Rows`, `Result_Message`, `Create_Time`, `Start_Time`, `End_Time`, `Created_By`, `Last_Update_Time`, `Cur_Step`, `Cur_Step_Processed_Size`, `Cur_Step_Total_Size`, `Cur_Step_Progress_Pct`, `Cur_Step_Speed`, and `Cur_Step_ETA`. | ||
|
|
||
| The `LIKE` clause matches its pattern only against the first column `Job_ID` (compared as a string). For example, `SHOW IMPORT JOBS LIKE '%1'` returns the jobs whose `Job_ID` ends with `1`. | ||
|
|
||
| ## Example | ||
|
|
||
| Show all import jobs that the current user can view: | ||
|
|
||
| ```sql | ||
| SHOW IMPORT JOBS; | ||
| ``` | ||
|
|
||
| ``` | ||
| +--------+-------------------+--------------+----------+-------+----------+------------------+---------------+----------------+----------------------------+----------------------------+----------------------------+------------+ | ||
| | Job_ID | Data_Source | Target_Table | Table_ID | Phase | Status | Source_File_Size | Imported_Rows | Result_Message | Create_Time | Start_Time | End_Time | Created_By | | ||
| +--------+-------------------+--------------+----------+-------+----------+------------------+---------------+----------------+----------------------------+----------------------------+----------------------------+------------+ | ||
| | 1 | /path/to/file.csv | `test`.`foo` | 116 | | finished | 11GB | 950000 | | 2023-06-26 11:23:59.281257 | 2023-06-26 11:23:59.484932 | 2023-06-26 13:04:30.622952 | root@% | | ||
| | 2 | /path/to/file.csv | `test`.`bar` | 130 | | finished | 1.194TB | 49995000 | | 2023-06-26 15:42:45.079237 | 2023-06-26 15:42:45.388108 | 2023-06-26 17:29:43.023568 | root@% | | ||
| +--------+-------------------+--------------+----------+-------+----------+------------------+---------------+----------------+----------------------------+----------------------------+----------------------------+------------+ | ||
| 1 row in set (0.01 sec) | ||
| ``` | ||
| Show a specific import job by job ID: | ||
|
|
||
| ```sql | ||
| SHOW IMPORT JOB 60001; | ||
| SHOW IMPORT JOB 2; | ||
| ``` | ||
|
|
||
| ``` | ||
| +--------+--------------------+--------------+----------+-------+---------+------------------+---------------+----------------+----------------------------+------------+----------+------------+ | ||
| | Job_ID | Data_Source | Target_Table | Table_ID | Phase | Status | Source_File_Size | Imported_Rows | Result_Message | Create_Time | Start_Time | End_Time | Created_By | | ||
| +--------+--------------------+--------------+----------+-------+---------+------------------+---------------+----------------+----------------------------+------------+----------+------------+ | ||
| | 60001 | /path/to/small.csv | `test`.`t` | 361 | | pending | 16B | NULL | | 2023-06-08 15:59:37.047703 | NULL | NULL | root@% | | ||
| +--------+--------------------+--------------+----------+-------+---------+------------------+---------------+----------------+----------------------------+------------+----------+------------+ | ||
| 1 row in set (0.01 sec) | ||
| The output is as follows: | ||
|
|
||
| | Job_ID | Group_Key | Data_Source | Target_Table | Table_ID | Phase | Status | Source_File_Size | Imported_Rows | Result_Message | Create_Time | Start_Time | End_Time | Created_By | Last_Update_Time | Cur_Step | Cur_Step_Processed_Size | Cur_Step_Total_Size | Cur_Step_Progress_Pct | Cur_Step_Speed | Cur_Step_ETA | | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. classic kernel still the old way, we need to keep the old way, and put those new ones somewhere else for Premium
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Classic kernel actually uses this same output format. There's no classic-vs-nextgen branching for
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean it's not in latest 8.5 release. but this PR is for master, it should be fine |
||
| |--------|-----------|-------------|--------------|----------|-------|--------|------------------|---------------|----------------|-------------|------------|----------|------------|------------------|----------|-------------------------|---------------------|-----------------------|----------------|--------------| | ||
| | 2 | import_group_1 | /path/to/file.csv | `test`.`bar` | 118 | global-sorting | running | 277.5GiB | 0 | | 2025-07-09 10:40:18.580706 | 2025-07-09 10:40:19.092528 | NULL | root@% | 2025-07-09 10:47:15 | encode | 4.55GB | 298GB | 1 | 10.96MB/s | 07:26:03 | | ||
|
Check failure on line 81 in sql-statements/sql-statement-show-import-job.md
|
||
|
|
||
| Filter import jobs by output fields: | ||
|
|
||
| ```sql | ||
| SHOW IMPORT JOBS WHERE Group_Key = 'user_group'; | ||
| ``` | ||
|
|
||
| ## MySQL compatibility | ||
|
|
@@ -75,4 +93,5 @@ | |
| ## See also | ||
|
|
||
| * [`IMPORT INTO`](/sql-statements/sql-statement-import-into.md) | ||
| * [`SHOW IMPORT GROUP`](/sql-statements/sql-statement-show-import-group.md) | ||
| * [`CANCEL IMPORT JOB`](/sql-statements/sql-statement-cancel-import-job.md) | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because there is a dedicated doc for SHOW IMPORT GROUPS, adding a simple example of this new
GROUP_KEYoption in the Example section of this doc would be more friendly to our users.For example:
Import a CSV file with a specific group key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, done in joechenrh@caac9a6 .
Added an
Assign a group key to the import jobexample under theIMPORT INTO ... FROM FILEExamples section, with a link over toSHOW IMPORT GROUPSso users can jump to the dedicated doc for monitoring grouped jobs. 👍