diff --git a/.github/workflows/manual-deploy-website.yml b/.github/workflows/manual-deploy-website.yml index 1e2fd6d696830..4114cdf175dc8 100644 --- a/.github/workflows/manual-deploy-website.yml +++ b/.github/workflows/manual-deploy-website.yml @@ -46,6 +46,7 @@ jobs: cp .asf-site.yaml ./build/.asf.yaml cp versions.json ./build/ cp worker.js ./build/ + cp .htaccess ./build/ ls build export DORIS_COMMIT=`git rev-parse HEAD` diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000000000..de377bfe4501e --- /dev/null +++ b/.htaccess @@ -0,0 +1 @@ +ErrorDocument 404 /404.html diff --git a/check_move.py b/check_move.py index 12f7563213343..bebff208cd8a0 100755 --- a/check_move.py +++ b/check_move.py @@ -45,41 +45,49 @@ def process_md_file(file_path): with open(file_path, "r", encoding="utf-8") as f: content = f.read() - links = link_pattern.findall(content) - - for link in links: - if not urlparse(link).scheme and not os.path.isabs(link): - full_path: str = os.path.normpath( - os.path.join(os.path.dirname(file_path), link) - ) - if not full_path.endswith(".md") and not full_path.endswith(".mdx"): - full_path += ".md" - - for [from_path, to_path] in move_pairs: - # Skip change of suffix - from_base, from_ext = os.path.splitext(from_path) - to_base, to_ext = os.path.splitext(to_path) - if ( - from_ext in [".md", ".mdx", ""] or to_ext in [".md", ".mdx", ""] - ) and (from_base == to_base): - continue - # In md, the link relative path starts from the directory where the document is located, not the document - relative_to_path = os.path.relpath( - to_path, os.path.dirname(file_path) + links = link_pattern.findall(content) + + new_content = content + for link in links: + if not urlparse(link).scheme and not os.path.isabs(link): + full_path: str = os.path.normpath( + os.path.join(os.path.dirname(file_path), link) + ) + if not full_path.endswith(".md") and not full_path.endswith(".mdx"): + full_path += ".md" + + for [from_path, to_path] in move_pairs: + # Skip change of suffix + from_base, from_ext = os.path.splitext(from_path) + to_base, to_ext = os.path.splitext(to_path) + if ( + from_ext in [".md", ".mdx", ""] or to_ext in [".md", ".mdx", ""] + ) and (from_base == to_base): + continue + # In md, the link relative path starts from the directory where the document is located, not the document + relative_to_path = os.path.relpath(to_path, os.path.dirname(file_path)) + relative_to_path = remove_suffix(relative_to_path, ".md") + relative_to_path = remove_suffix(relative_to_path, ".mdx") + + if is_same_file(full_path, from_path): + print( + f"{file_path} has a link moved by this commit: from {link} to {relative_to_path}" + ) + change_detected = True + # Replace the old link with the new one + new_content = new_content.replace( + f"({link})", f"({relative_to_path})" ) - relative_to_path = remove_suffix(relative_to_path, ".md") - relative_to_path = remove_suffix(relative_to_path, ".mdx") - if is_same_file(full_path, from_path): - print( - f"{file_path} has a link moved by this commit: from {link} to {relative_to_path}" - ) - change_detected = True + for deleted_path in deletes: + if is_same_file(full_path, deleted_path): + print(f"{file_path} has a link removed by this commit: {link}") + change_detected = True - for deleted_path in deletes: - if is_same_file(full_path, deleted_path): - print(f"{file_path} has a link removed by this commit: {link}") - change_detected = True + # Write the updated content back to the file + if new_content != content: + with open(file_path, "w", encoding="utf-8") as f: + f.write(new_content) def extract_file_changes(git_show_output: List[AnyStr]): @@ -130,4 +138,4 @@ def travel(root_path: str): if change_detected: print("Failed!") - sys.exit(1) + sys.exit(1) \ No newline at end of file diff --git a/docs/admin-manual/auth/authentication/federation.md b/docs/admin-manual/auth/authentication/federation.md index 6b5540e99ea30..06a87de5691aa 100644 --- a/docs/admin-manual/auth/authentication/federation.md +++ b/docs/admin-manual/auth/authentication/federation.md @@ -137,7 +137,7 @@ Note: To log in using other clients, refer to the section "How Clients Use Clear ### LDAP Information Cache -To avoid frequent access to the LDAP service, Doris caches LDAP information in memory. You can configure the `ldap_user_cache_timeout_s` parameter in the `ldap.conf` file to specify the cache time for LDAP users, which defaults to 12 hours. After modifying the information in the LDAP service or modifying the corresponding role permissions in Doris, the changes may not take effect immediately due to caching. You can use the `refresh ldap` statement to refresh the cache. For details, see [REFRESH-LDAP](../../../sql-manual/sql-statements/Utility-Statements/REFRESH-LDAP.md). +To avoid frequent access to the LDAP service, Doris caches LDAP information in memory. You can configure the `ldap_user_cache_timeout_s` parameter in the `ldap.conf` file to specify the cache time for LDAP users, which defaults to 12 hours. After modifying the information in the LDAP service or modifying the corresponding role permissions in Doris, the changes may not take effect immediately due to caching. You can use the `refresh ldap` statement to refresh the cache. For details, see [REFRESH-LDAP](../../../sql-manual/sql-statements/account-management/REFRESH-LDAP). ### Limitations of LDAP Verification diff --git a/docs/admin-manual/auth/authentication/internal.md b/docs/admin-manual/auth/authentication/internal.md index 01658ae20c455..5d357b76d653c 100644 --- a/docs/admin-manual/auth/authentication/internal.md +++ b/docs/admin-manual/auth/authentication/internal.md @@ -71,13 +71,13 @@ Doris supports the following password policies to help users manage passwords be Doris itself does not support a blacklist, only a whitelist function, but we can simulate a blacklist in some ways. Suppose a user named `user@'192.%'` is created, allowing users from 192.* to log in. If you want to prohibit users from 192.168.10.1 from logging in, you can create another user `cmy@'192.168.10.1'` and set a new password. Since 192.168.10.1 has a higher priority than 192.%, users from 192.168.10.1 will no longer be able to log in using the old password. ## Related Commands -- Create User: [CREATE USER](../../../sql-manual/sql-statements/Account-Management-Statements/CREATE-USER.md) -- View User: [SHOW ALL GRANTS](../../../sql-manual/sql-statements/Show-Statements/SHOW-GRANTS.md) -- Modify User: [ALTER USER](../../../sql-manual/sql-statements/Account-Management-Statements/ALTER-USER.md) -- Change Password: [SET PASSWORD](../../../sql-manual/sql-statements/Account-Management-Statements/SET-PASSWORD.md) -- Delete User: [DROP USER](../../../sql-manual/sql-statements/Account-Management-Statements/DROP-USER.md) +- Create User: [CREATE USER](../../../sql-manual/sql-statements/account-management/CREATE-USER) +- View User: [SHOW ALL GRANTS](../../../sql-manual/sql-statements/account-management/SHOW-GRANTS) +- Modify User: [ALTER USER](../../../sql-manual/sql-statements/account-management/ALTER-USER) +- Change Password: [SET PASSWORD](../../../sql-manual/sql-statements/account-management/SET-PASSWORD) +- Delete User: [DROP USER](../../../sql-manual/sql-statements/account-management/DROP-USER) - Set User Attributes: [SET PROPERTY](../../../sql-manual/sql-statements/Account-Management-Statements/SET-PROPERTY.md) -- View User Attributes: [SHOW PROPERTY](../../../sql-manual/sql-statements/Show-Statements/SHOW-PROPERTY.md) +- View User Attributes: [SHOW PROPERTY](../../../sql-manual/sql-statements/account-management/SHOW-PROPERTY) ## Other Explanations 1. User Identity Priority Selection Issue During Login diff --git a/docs/admin-manual/auth/authorization/data.md b/docs/admin-manual/auth/authorization/data.md index 6712537772bdc..1056fc4574103 100644 --- a/docs/admin-manual/auth/authorization/data.md +++ b/docs/admin-manual/auth/authorization/data.md @@ -54,8 +54,8 @@ With column permissions in Doris, you can achieve fine-grained access control ov Currently, column permissions only support Select_priv. ### Related Commands -- Grant: [GRANT](../../../sql-manual/sql-statements/Account-Management-Statements/GRANT.md) -- Revoke: [REVOKE](../../../sql-manual/sql-statements/Account-Management-Statements/REVOKE.md) +- Grant: [GRANT](../../../sql-manual/sql-statements/account-management/GRANT-TO) +- Revoke: [REVOKE](../../../sql-manual/sql-statements/account-management/REVOKE-FROM.md) ### Column Permission Example diff --git a/docs/admin-manual/auth/authorization/internal.md b/docs/admin-manual/auth/authorization/internal.md index ee41c4a7b8bd1..df2dca4741ad6 100644 --- a/docs/admin-manual/auth/authorization/internal.md +++ b/docs/admin-manual/auth/authorization/internal.md @@ -108,15 +108,15 @@ userN has priv1 permission through role3 and priv2 and privN permissions through ## Related Commands -- Grant/assign role: [GRANT](../../../sql-manual/sql-statements/Account-Management-Statements/GRANT.md) -- Revoke/revoke role: [REVOKE](../../../sql-manual/sql-statements/Account-Management-Statements/REVOKE.md) -- Create role: [CREATE ROLE](../../../sql-manual/sql-statements/Account-Management-Statements/CREATE-ROLE.md) -- Delete role: [DROP ROLE](../../../sql-manual/sql-statements/Account-Management-Statements/DROP-ROLE.md) -- Modify role: [ALTER ROLE](../../../sql-manual/sql-statements/Account-Management-Statements/ALTER-ROLE.md) -- View current user permissions and roles: [SHOW GRANTS](../../../sql-manual/sql-statements/Show-Statements/SHOW-GRANTS.md) -- View all user permissions and roles: [SHOW ALL GRANTS](../../../sql-manual/sql-statements/Show-Statements/SHOW-GRANTS.md) -- View created roles: [SHOW ROLES](../../../sql-manual/sql-statements/Show-Statements/SHOW-ROLES.md) -- View supported permissions: [SHOW PRIVILEGES](../../../sql-manual/sql-statements/Show-Statements/SHOW-PRIVILEGES.md) +- Grant/assign role: [GRANT](../../../sql-manual/sql-statements/account-management/GRANT-TO) +- Revoke/revoke role: [REVOKE](../../../sql-manual/sql-statements/account-management/REVOKE-FROM.md) +- Create role: [CREATE ROLE](../../../sql-manual/sql-statements/account-management/CREATE-ROLE) +- Delete role: [DROP ROLE](../../../sql-manual/sql-statements/account-management/DROP-ROLE) +- Modify role: [ALTER ROLE](../../../sql-manual/sql-statements/account-management/ALTER-ROLE) +- View current user permissions and roles: [SHOW GRANTS](../../../sql-manual/sql-statements/account-management/SHOW-GRANTS) +- View all user permissions and roles: [SHOW ALL GRANTS](../../../sql-manual/sql-statements/account-management/SHOW-GRANTS) +- View created roles: [SHOW ROLES](../../../sql-manual/sql-statements/account-management/SHOW-ROLES) +- View supported permissions: [SHOW PRIVILEGES](../../../sql-manual/sql-statements/account-management/SHOW-PRIVILEGES) ## Best Practices diff --git a/docs/admin-manual/config/be-config.md b/docs/admin-manual/config/be-config.md index 5f2929e67f73c..71c0cd381b627 100644 --- a/docs/admin-manual/config/be-config.md +++ b/docs/admin-manual/config/be-config.md @@ -50,7 +50,7 @@ There are two ways to view the configuration items of BE: 2. View by command - You can view the configuration items of the BE in the MySQL client with the following command,Concrete language law reference [SHOW-CONFIG](../../sql-manual/sql-statements/Database-Administration-Statements/SHOW-CONFIG.md): + You can view the configuration items of the BE in the MySQL client with the following command,Concrete language law reference [SHOW-CONFIG](../../sql-manual/sql-statements/cluster-management/instance-management/SHOW-FRONTEND-CONFIG): `SHOW BACKEND CONFIG;` diff --git a/docs/admin-manual/config/fe-config.md b/docs/admin-manual/config/fe-config.md index 15ae67771dd17..475fc1b8ecd55 100644 --- a/docs/admin-manual/config/fe-config.md +++ b/docs/admin-manual/config/fe-config.md @@ -48,7 +48,7 @@ There are two ways to view the configuration items of FE: 2. View by command - After the FE is started, you can view the configuration items of the FE in the MySQL client with the following command,Concrete language law reference [SHOW-CONFIG](../../sql-manual/sql-statements/Database-Administration-Statements/SHOW-CONFIG.md): + After the FE is started, you can view the configuration items of the FE in the MySQL client with the following command,Concrete language law reference [SHOW-CONFIG](../../sql-manual/sql-statements/cluster-management/instance-management/SHOW-FRONTEND-CONFIG): `SHOW FRONTEND CONFIG;` diff --git a/docs/admin-manual/data-admin/backup-restore/backup.md b/docs/admin-manual/data-admin/backup-restore/backup.md index 89eca592b61b2..ec0eaf285bc02 100644 --- a/docs/admin-manual/data-admin/backup-restore/backup.md +++ b/docs/admin-manual/data-admin/backup-restore/backup.md @@ -32,7 +32,7 @@ For concepts related to backup, please refer to [Backup and Restore](./overview. suites/backup_restore/test_create_and_drop_repository.groovy --> -Use the appropriate statement to create a Repository based on your storage choice. For detailed usage, please refer to [Create Repository](../../../sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CREATE-REPOSITORY.md). When backing up using the same path for the Repository across different clusters, ensure to use different labels to avoid conflicts that may cause data confusion. +Use the appropriate statement to create a Repository based on your storage choice. For detailed usage, please refer to [Create Repository](../../../sql-manual/sql-statements/data-modification/backup-and-restore/CREATE-REPOSITORY). When backing up using the same path for the Repository across different clusters, ensure to use different labels to avoid conflicts that may cause data confusion. ### Option 1: Create Repository on S3 @@ -162,7 +162,7 @@ PROPERTIES ## Step 2. Backup -Refer to the following statements to back up databases, tables, or partitions. For detailed usage, please refer to [Backup](../../../sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/BACKUP.md). +Refer to the following statements to back up databases, tables, or partitions. For detailed usage, please refer to [Backup](../../../sql-manual/sql-statements/data-modification/backup-and-restore/BACKUP). It is recommended to use meaningful label names, such as those containing the databases and tables included in the backup. @@ -262,4 +262,4 @@ mysql> SHOW SNAPSHOT ON example_repo; ## Step 5. Cancel Backup (if necessary) -You can use `CANCEL BACKUP FROM db_name;` to cancel a backup task in a database. For more specific usage, refer to [Cancel Backup](../../../sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CANCEL-BACKUP.md). +You can use `CANCEL BACKUP FROM db_name;` to cancel a backup task in a database. For more specific usage, refer to [Cancel Backup](../../../sql-manual/sql-statements/data-modification/backup-and-restore/CANCEL-BACKUP). diff --git a/docs/admin-manual/data-admin/recyclebin.md b/docs/admin-manual/data-admin/recyclebin.md index 9eda0f825f620..e8467b878e4b9 100644 --- a/docs/admin-manual/data-admin/recyclebin.md +++ b/docs/admin-manual/data-admin/recyclebin.md @@ -38,7 +38,7 @@ You can query the Recycle Bin with the following command: SHOW CATALOG RECYCLE BIN [WHERE NAME [= "name" | LIKE "name_matcher"]]; ``` -For more detailed syntax and best practices, please refer to the [SHOW-CATALOG-RECYCLE-BIN](../../sql-manual/sql-statements/Show-Statements/SHOW-CATALOG-RECYCLE-BIN.md) command manual, You can also type `help SHOW CATALOG RECYCLE BIN` on the MySql client command line for more help. +For more detailed syntax and best practices, please refer to the [SHOW-CATALOG-RECYCLE-BIN](../../sql-manual/sql-statements/recycle/SHOW-CATALOG-RECYCLE-BIN) command manual, You can also type `help SHOW CATALOG RECYCLE BIN` on the MySql client command line for more help. ### Start Data Recovery @@ -63,4 +63,4 @@ RECOVER TABLE example_db.example_tbl; RECOVER PARTITION p1 FROM example_tbl; ``` -For more detailed syntax and best practices used by RECOVER, please refer to the [RECOVER](../../sql-manual/sql-statements/Database-Administration-Statements/RECOVER.md) command manual, You can also type `HELP RECOVER` on the MySql client command line for more help. +For more detailed syntax and best practices used by RECOVER, please refer to the [RECOVER](../../sql-manual/sql-statements/recycle/RECOVER) command manual, You can also type `HELP RECOVER` on the MySql client command line for more help. diff --git a/docs/admin-manual/small-file-mgr.md b/docs/admin-manual/small-file-mgr.md index e1a6fc0fe7825..8f32d5da81a7a 100644 --- a/docs/admin-manual/small-file-mgr.md +++ b/docs/admin-manual/small-file-mgr.md @@ -47,7 +47,7 @@ File management has three main commands: `CREATE FILE`, `SHOW FILE` and `DROP FI ### CREATE FILE -This statement is used to create and upload a file to the Doris cluster. For details, see [CREATE FILE](../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FILE.md). +This statement is used to create and upload a file to the Doris cluster. For details, see [CREATE FILE](../sql-manual/sql-statements/security/CREATE-FILE). Examples: @@ -75,7 +75,7 @@ Examples: ### SHOW FILE -This statement can view the files that have been created successfully. For details, see [SHOW FILE](../sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-FILE.md). +This statement can view the files that have been created successfully. For details, see [SHOW FILE](../sql-manual/sql-statements/security/DROP-FILE). Examples: @@ -87,7 +87,7 @@ Examples: ### DROP FILE -This statement can view and delete an already created file. For specific operations, see [DROP FILE](../sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-FILE.md). +This statement can view and delete an already created file. For specific operations, see [DROP FILE](../sql-manual/sql-statements/security/DROP-FILE). Examples: @@ -129,4 +129,4 @@ Because the file meta-information and content are stored in FE memory. So by def ## More Help -For more detailed syntax and best practices used by the file manager, see [CREATE FILE](../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FILE.md), [DROP FILE](../sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-FILE.md) and [SHOW FILE](../sql-manual/sql-statements/Show-Statements/SHOW-FILE.md) command manual, you can also enter `HELP CREATE FILE`, `HELP DROP FILE` and `HELP SHOW FILE` in the MySql client command line to get more help information. +For more detailed syntax and best practices used by the file manager, see [CREATE FILE](../sql-manual/sql-statements/security/CREATE-FILE), [DROP FILE](../sql-manual/sql-statements/security/DROP-FILE) and [SHOW FILE](../sql-manual/sql-statements/security/SHOW-FILE) command manual, you can also enter `HELP CREATE FILE`, `HELP DROP FILE` and `HELP SHOW FILE` in the MySql client command line to get more help information. diff --git a/docs/admin-manual/workload-management/workload-group.md b/docs/admin-manual/workload-management/workload-group.md index a57acb18adffb..b05985c064ea4 100644 --- a/docs/admin-manual/workload-management/workload-group.md +++ b/docs/admin-manual/workload-management/workload-group.md @@ -159,7 +159,7 @@ mysql [information_schema]>create workload group if not exists g1 Query OK, 0 rows affected (0.03 sec) ``` -You can refer to [CREATE-WORKLOAD-GROUP](../../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-WORKLOAD-GROUP)。 +You can refer to [CREATE-WORKLOAD-GROUP](../../sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-GROUP)。 The CPU limit configured at this point is a soft limit. Since version 2.1, Doris will automatically create a group named normal, which cannot be deleted. @@ -213,7 +213,7 @@ If the g1 Workload Group is not visible, you can use the ADMIN account to execut "GRANT USAGE_PRIV ON WORKLOAD GROUP 'g1' TO 'user_1'@'%';" ``` This statement means granting the user_1 the permission to use the Workload Group named g1. -More details can be found in [grant](../../sql-manual/sql-statements/Account-Management-Statements/GRANT)。 +More details can be found in [grant](../../sql-manual/sql-statements/account-management/GRANT-TO)。 **Two ways to bind Workload Group to user** 1. By setting the user property, you can bind the user to a default Workload Group. The default is normal. It's important to note that the value here cannot be left empty; otherwise, the statement will fail. @@ -234,7 +234,7 @@ When both methods are used to specify a Workload Group for the user, the session ``` show workload groups; ``` -More details can be found in [SHOW-WORKLOAD-GROUPS](../../sql-manual/sql-statements/Show-Statements/SHOW-WORKLOAD-GROUPS) +More details can be found in [SHOW-WORKLOAD-GROUPS](../../sql-manual/sql-statements/cluster-management/compute-management/SHOW-WORKLOAD-GROUPS) 2. You can view the Workload Group through the system table: ``` @@ -262,7 +262,7 @@ mysql [information_schema]>select cpu_share from information_schema.workload_gro ``` -More details can be found in [ALTER-WORKLOAD-GROUP](../../sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-WORKLOAD-GROUP) +More details can be found in [ALTER-WORKLOAD-GROUP](../../sql-manual/sql-statements/cluster-management/compute-management/ALTER-WORKLOAD-GROUP) ## Drop Workload Group ``` @@ -270,7 +270,7 @@ mysql [information_schema]>drop workload group g1; Query OK, 0 rows affected (0.01 sec) ``` -More details can be found in[DROP-WORKLOAD-GROUP](../../sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-WORKLOAD-GROUP) +More details can be found in[DROP-WORKLOAD-GROUP](../../sql-manual/sql-statements/cluster-management/compute-management/DROP-WORKLOAD-GROUP) ## Explanation of Switching Between CPU Soft and Hard Limit Modes Currently, Doris does not support running both CPU soft and hard limits simultaneously. At any given time, a Doris cluster can only operate in either CPU soft limit or CPU hard limit mode. diff --git a/docs/compute-storage-decoupled/compilation-and-deployment.md b/docs/compute-storage-decoupled/compilation-and-deployment.md index 587d5feda69b4..7608f99df8c85 100644 --- a/docs/compute-storage-decoupled/compilation-and-deployment.md +++ b/docs/compute-storage-decoupled/compilation-and-deployment.md @@ -194,7 +194,7 @@ Other nodes should also modify the configuration file and start according to the ALTER SYSTEM ADD FOLLOWER "host:port"; ``` -Replace `host:port` with the actual address and editlog port of the FE node. More information refer to [ADD FOLLOWER](../sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-FOLLOWER.md) and [ADD OBSERVER](../sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-OBSERVER.md). +Replace `host:port` with the actual address and editlog port of the FE node. More information refer to [ADD FOLLOWER](../sql-manual/sql-statements/cluster-management/instance-management/ADD-FOLLOWER) and [ADD OBSERVER](../sql-manual/sql-statements/cluster-management/instance-management/ADD-OBSERVER). For production environment, please ensure that the total number of Frontend (FE) nodes in the FOLLOWER role, including the first FE, remains an odd number. In general, three FOLLOWERS are sufficient. Frontend nodes in the OBSERVER role can be any number. @@ -239,7 +239,7 @@ In the `be.conf` file, the following key parameters need to be configured: You can set the computing group for the BE using PROPERTIES. - For more detailed usage, please refer to [ADD BACKEND](../sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-BACKEND.md) and [REMOVE BACKEND](../sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-BACKEND.md). + For more detailed usage, please refer to [ADD BACKEND](../sql-manual/sql-statements/cluster-management/instance-management/ADD-BACKEND) and [REMOVE BACKEND](../sql-manual/sql-statements/cluster-management/instance-management/DROP-BACKEND). 3. Verify Backend Status: @@ -291,7 +291,7 @@ CREATE STORAGE VAULT IF NOT EXISTS s3_vault ); ``` -To create a Storage Vault on other object storage, please refer to [Create Storage Vault](../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-STORAGE-VAULT.md). +To create a Storage Vault on other object storage, please refer to [Create Storage Vault](../sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT). ### 6.3 Set Default Storage Vault diff --git a/docs/compute-storage-decoupled/managing-compute-cluster.md b/docs/compute-storage-decoupled/managing-compute-cluster.md index 001db65d431dd..581b7ab818bf4 100644 --- a/docs/compute-storage-decoupled/managing-compute-cluster.md +++ b/docs/compute-storage-decoupled/managing-compute-cluster.md @@ -72,8 +72,8 @@ SHOW COMPUTE GROUPS; ## Adding Compute Groups -Managing compute groups requires `OPERATOR` privilege, which controls node management permissions. For more details, please refer to [Privilege Management](../sql-manual/sql-statements/Account-Management-Statements/GRANT.md). By default, only the root account has the `OPERATOR` privilege, but it can be granted to other accounts using the `GRANT` command. -To add a BE and assign it to a compute group, use the [Add BE](../sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-BACKEND.md) command. For example: +Managing compute groups requires `OPERATOR` privilege, which controls node management permissions. For more details, please refer to [Privilege Management](../sql-manual/sql-statements/account-management/GRANT-TO). By default, only the root account has the `OPERATOR` privilege, but it can be granted to other accounts using the `GRANT` command. +To add a BE and assign it to a compute group, use the [Add BE](../sql-manual/sql-statements/cluster-management/instance-management/ADD-BACKEND) command. For example: ```sql ALTER SYSTEM ADD BACKEND 'host:9050' PROPERTIES ("tag.compute_group_name" = "new_group"); diff --git a/docs/compute-storage-decoupled/managing-storage-vault.md b/docs/compute-storage-decoupled/managing-storage-vault.md index d3496192509c2..c8151d796e1fe 100644 --- a/docs/compute-storage-decoupled/managing-storage-vault.md +++ b/docs/compute-storage-decoupled/managing-storage-vault.md @@ -44,7 +44,7 @@ PROPERTIES To create an HDFS-based decoupled storage-compute Doris cluster, ensure that all nodes (including FE/BE nodes, Meta Service) have privilege to access the specified HDFS, including completing Kerberos authorization configuration and connectivity checks in advance (which can be tested using Hadoop Client on each corresponding node). ```sql -CREATE STORAGE VAULT IF NOT EXISTS ssb_hdfs_vault +CREATE STORAGE VAULT IF NOT EXISTS hdfs_vault_demo PROPERTIES ( "type"="hdfs", -- required "fs.defaultFS"="hdfs://127.0.0.1:8020", -- required @@ -59,20 +59,21 @@ CREATE STORAGE VAULT IF NOT EXISTS ssb_hdfs_vault ### Create an S3 Storage Vault ```sql -CREATE STORAGE VAULT IF NOT EXISTS ssb_s3_vault - PROPERTIES ( - "type"="S3", -- required - "s3.endpoint" = "oss-cn-beijing.aliyuncs.com", -- required - "s3.region" = "bj", -- required - "s3.bucket" = "bucket", -- required - "s3.root.path" = "big/data/prefix", -- required - "s3.access_key" = "ak", -- required - "s3.secret_key" = "sk", -- required - "provider" = "OSS" -- required - ); +CREATE STORAGE VAULT IF NOT EXISTS s3_vault_demo +PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "oss-cn-beijing.aliyuncs.com", -- required + "s3.region" = "cn-beijing", -- required + "s3.bucket" = "bucket", -- required + "s3.root.path" = "big/data/prefix", -- required + "s3.access_key" = "ak", -- required + "s3.secret_key" = "sk", -- required + "provider" = "OSS", -- required + "use_path_style" = "false" -- optional +); ``` -More parameter explanations and examples can be found in [CREATE-STORAGE-VAULT](../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-STORAGE-VAULT.md). +More parameter explanations and examples can be found in [CREATE-STORAGE-VAULT](../sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT). ## View Storage Vaults @@ -112,7 +113,7 @@ UNIQUE KEY (s_suppkey) DISTRIBUTED BY HASH(s_suppkey) BUCKETS 1 PROPERTIES ( "replication_num" = "1", -"storage_vault_name" = "ssb_hdfs_vault" +"storage_vault_name" = "hdfs_demo_vault" ); ``` @@ -130,7 +131,7 @@ HDFS Storage Vault forbidden properties: - `path_prefix` - `fs.defaultFS` -Properties explanations can be found in [CREATE-STORAGE-VAULT](../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-STORAGE-VAULT.md). +Properties explanations can be found in [CREATE-STORAGE-VAULT](../sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT). **Example** @@ -172,7 +173,7 @@ GRANT Only Admin users have the authority to execute the `GRANT` statement, which is used to grant specified Storage Vault privileges to User/Role. Users/Roles with `USAGE_PRIV` privilege for a certain Storage Vault can perform the following operations: -- View the information of that Storage Vault through `SHOW STORAGE VAULT`; +- View the information of that Storage Vault through `SHOW STORAGE VAULTS`; - Specify the use of that Storage Vault in `PROPERTIES` when creating tables. **Example** diff --git a/docs/data-operate/delete/delete-manual.md b/docs/data-operate/delete/delete-manual.md index b7a89228b98db..a1101208ec5d0 100644 --- a/docs/data-operate/delete/delete-manual.md +++ b/docs/data-operate/delete/delete-manual.md @@ -29,7 +29,7 @@ The DELETE statement conditionally deletes data from a specified table or partit The DELETE statement generally requires the specification of tables and partitions as well as deletion conditions to filter the data to be deleted, and will delete data from both the base and rollup tables. -The syntax of the DELETE statement is detailed in the [DELETE](../../sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/DELETE) syntax. Unlike the Insert into command, Delete cannot specify `label` manually. For the concept of `label` , refer to the [Insert Into](../../data-operate/import/insert-into-manual) documentation. +The syntax of the DELETE statement is detailed in the [DELETE](../../sql-manual/sql-statements/data-modification/DML/DELETE) syntax. Unlike the Insert into command, Delete cannot specify `label` manually. For the concept of `label` , refer to the [Insert Into](../../data-operate/import/insert-into-manual) documentation. ### Delete by Specifying a Filter Predicate diff --git a/docs/data-operate/export/export-manual.md b/docs/data-operate/export/export-manual.md index c493079e86fae..60f7b4ab2ef07 100644 --- a/docs/data-operate/export/export-manual.md +++ b/docs/data-operate/export/export-manual.md @@ -30,7 +30,7 @@ This document will introduce how to use the `EXPORT` command to export the data `Export` is an asynchronously executed command. Once the command is executed successfully, it will return the result immediately. Users can view the detailed information of the Export task through the `Show Export` command. -For the detailed introduction of the `EXPORT` command, please refer to: [EXPORT](../../sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/EXPORT.md) +For the detailed introduction of the `EXPORT` command, please refer to: [EXPORT](../../sql-manual/sql-statements/data-modification/load-and-export/EXPORT) Regarding how to choose between `SELECT INTO OUTFILE` and `EXPORT`, please refer to [Export Overview](../../data-operate/export/export-overview.md). @@ -104,7 +104,7 @@ PROPERTIES ( ### View Export Jobs -After submitting a job, you can query the status of the export job via the [SHOW EXPORT](../../sql-manual/sql-statements/Show-Statements/SHOW-EXPORT.md) command. An example of the result is as follows: +After submitting a job, you can query the status of the export job via the [SHOW EXPORT](../../sql-manual/sql-statements/data-modification/load-and-export/SHOW-EXPORT) command. An example of the result is as follows: ```sql mysql> show export\G @@ -133,11 +133,11 @@ OutfileInfo: [ 1 row in set (0.00 sec) ``` -For the detailed usage of the `show export` command and the meaning of each column in the returned results, please refer to [SHOW EXPORT](../../sql-manual/sql-statements/Show-Statements/SHOW-EXPORT.md). +For the detailed usage of the `show export` command and the meaning of each column in the returned results, please refer to [SHOW EXPORT](../../sql-manual/sql-statements/data-modification/load-and-export/SHOW-EXPORT). ### Cancel Export Jobs -After submitting an Export job, the export job can be cancelled via the [CANCEL EXPORT](../../sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/CANCEL-EXPORT.md) command before the Export task succeeds or fails. An example of the cancellation command is as follows: +After submitting an Export job, the export job can be cancelled via the [CANCEL EXPORT](../../sql-manual/sql-statements/data-modification/load-and-export/CANCEL-EXPORT) command before the Export task succeeds or fails. An example of the cancellation command is as follows: ```sql CANCEL EXPORT FROM dbName WHERE LABEL like "%export_%"; diff --git a/docs/data-operate/export/outfile.md b/docs/data-operate/export/outfile.md index 29565371bb04a..b66772a08237a 100644 --- a/docs/data-operate/export/outfile.md +++ b/docs/data-operate/export/outfile.md @@ -32,7 +32,7 @@ The `SELECT INTO OUTFILE` is a synchronous command, the return of the command me Regarding how to choose between `SELECT INTO OUTFILE` and `EXPORT`, please refer to [Export Overview](./export-overview.md). -For a detailed introduction to the `SELECT INTO OUTFILE` command, please refer to: [SELECT INTO OUTFILE](../../sql-manual/sql-statements/Data-Manipulation-Statements/OUTFILE.md) +For a detailed introduction to the `SELECT INTO OUTFILE` command, please refer to: [SELECT INTO OUTFILE](../../sql-manual/sql-statements/data-modification/load-and-export/OUTFILE) ## Applicable Scenarios diff --git a/docs/data-operate/import/data-source/kafka.md b/docs/data-operate/import/data-source/kafka.md index 51254997a11c8..93807e6c1307f 100644 --- a/docs/data-operate/import/data-source/kafka.md +++ b/docs/data-operate/import/data-source/kafka.md @@ -45,7 +45,7 @@ In most cases, you can directly choose Routine Load for loading data without the ### Operation Example -In Doris, create a persistent Routine Load load task through the CREATE ROUTINE LOAD command, which can be divided into single-table load and multi-table load. For detailed syntax, please refer to [CREATE ROUTINE LOAD](../../../sql-manual/sql-statements/Data-Manipulation-Statements/Load/CREATE-ROUTINE-LOAD). +In Doris, create a persistent Routine Load load task through the CREATE ROUTINE LOAD command, which can be divided into single-table load and multi-table load. For detailed syntax, please refer to [CREATE ROUTINE LOAD](../../../sql-manual/sql-statements/data-modification/load-and-export/CREATE-ROUTINE-LOAD). #### Single Table Load @@ -191,7 +191,7 @@ The Doris Kafka Connector is a tool for loading Kafka data streams into the Dori 2. Configure `config/connect-distributed.properties`: ```Bash -# Modify broker address +# Modify kafka server address bootstrap.servers=127.0.0.1:9092 # Modify group.id, which needs to be consistent across the same cluster diff --git a/docs/data-operate/import/import-way/broker-load-manual.md b/docs/data-operate/import/import-way/broker-load-manual.md index 98c2a0e25e333..00d77273e45b8 100644 --- a/docs/data-operate/import/import-way/broker-load-manual.md +++ b/docs/data-operate/import/import-way/broker-load-manual.md @@ -79,13 +79,13 @@ Currently, BE nodes have built-in support for HDFS and S3 Brokers. Therefore, wh ## Quick start This section shows a demo for S3 Load. -For the specific syntax for usage, please refer to [BROKER LOAD](../../../sql-manual/sql-statements/Data-Manipulation-Statements/Load/BROKER-LOAD) in the SQL manual. +For the specific syntax for usage, please refer to [BROKER LOAD](../../../sql-manual/sql-statements/data-modification/load-and-export/BROKER-LOAD) in the SQL manual. ### Prerequisite check 1. Grant privileges on the table -Broker Load requires `INSERT` privileges on the target table. If there are no `INSERT` privileges, it can be granted to the user through the [GRANT](../../../sql-manual/sql-statements/Account-Management-Statements/GRANT) command. +Broker Load requires `INSERT` privileges on the target table. If there are no `INSERT` privileges, it can be granted to the user through the [GRANT](../../../sql-manual/sql-statements/account-management/GRANT-TO) command. 2. S3 authentication and connection info @@ -167,7 +167,7 @@ If your service is not in the list (such as MinIO), you can try using "S3" (AWS ## Checking import status -Broker Load is an asynchronous import method, and the specific import results can be viewed through the [SHOW LOAD](../../../sql-manual/sql-statements/Show-Statements/SHOW-LOAD) command. +Broker Load is an asynchronous import method, and the specific import results can be viewed through the [SHOW LOAD](../../../sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD) command. ```sql mysql> show load order by createtime desc limit 1\G; @@ -192,7 +192,7 @@ LoadFinishTime: 2022-04-01 18:59:11 ## Cancelling an Import -When the status of a Broker Load job is not CANCELLED or FINISHED, it can be manually cancelled by the user. To cancel, the user needs to specify the label of the import task to be cancelled. The syntax for the cancel import command can be viewed by executing [CANCEL LOAD](../../../sql-manual/sql-statements/Data-Manipulation-Statements/Load/CANCEL-LOAD). +When the status of a Broker Load job is not CANCELLED or FINISHED, it can be manually cancelled by the user. To cancel, the user needs to specify the label of the import task to be cancelled. The syntax for the cancel import command can be viewed by executing [CANCEL LOAD](../../../sql-manual/sql-statements/data-modification/load-and-export/CANCEL-LOAD). For example: To cancel the import job with the label "broker_load_2022_04_01" on the DEMO database. @@ -823,4 +823,4 @@ The `jsonpaths` can also be used in conjunction with the column list and `SET (c ``` ## More Help -For more detailed syntax and best practices for using [Broker Load](../../../sql-manual/sql-statements/Data-Manipulation-Statements/Load/BROKER-LOAD) , please refer to the Broker Load command manual. You can also enter HELP BROKER LOAD in the MySQL client command line to obtain more help information. +For more detailed syntax and best practices for using [Broker Load](../../../sql-manual/sql-statements/data-modification/load-and-export/BROKER-LOAD) , please refer to the Broker Load command manual. You can also enter HELP BROKER LOAD in the MySQL client command line to obtain more help information. diff --git a/docs/data-operate/import/import-way/insert-into-manual.md b/docs/data-operate/import/import-way/insert-into-manual.md index 791aff2094f8b..bc16b674236c6 100644 --- a/docs/data-operate/import/import-way/insert-into-manual.md +++ b/docs/data-operate/import/import-way/insert-into-manual.md @@ -208,7 +208,7 @@ Parameter description: | Status | Visibility of the imported data: If it is visible, it will be displayed as "visible." If not, it will be displayed as "committed." In the "committed" state, the import is completed, but the data may be delayed in becoming visible. There is no need to retry in this case.`visible`: The import is successful and the data is visible.`committed`: The import is completed, but the data may be delayed in becoming visible. There is no need to retry in this case.Label Already Exists: The specified label already exists and needs to be changed to a different one.Fail: The import fails. | | Err | Error message | -You can use the [SHOW LOAD](../../../sql-manual/sql-statements/Show-Statements/SHOW-LOAD/) statement to view the filtered rows. +You can use the [SHOW LOAD](../../../sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD) statement to view the filtered rows. ```SQL SHOW LOAD WHERE label="xxx"; @@ -218,7 +218,7 @@ The result of this statement will include a URL that can be used to query the er The invisible state of data is temporary, and the data will eventually become visible. -You can check the visibility status of a batch of data using the [SHOW TRANSACTION](../../../sql-manual/sql-statements/Show-Statements/SHOW-TRANSACTION/) statement. +You can check the visibility status of a batch of data using the [SHOW TRANSACTION](../../../sql-manual/sql-statements/transaction/SHOW-TRANSACTION) statement. ```SQL SHOW TRANSACTION WHERE id=4005; @@ -396,4 +396,4 @@ FROM s3( ## More help -For more detailed syntax on INSERT INTO, refer to the [INSERT INTO](../../../sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/INSERT/) command manual. You can also type `HELP INSERT` at the MySQL client command line for further information. +For more detailed syntax on INSERT INTO, refer to the [INSERT INTO](../../../sql-manual/sql-statements/data-modification/DML/INSERT) command manual. You can also type `HELP INSERT` at the MySQL client command line for further information. diff --git a/docs/data-operate/import/import-way/mysql-load-manual.md b/docs/data-operate/import/import-way/mysql-load-manual.md index 4b6c9a137e7f3..be9ac69f6d080 100644 --- a/docs/data-operate/import/import-way/mysql-load-manual.md +++ b/docs/data-operate/import/import-way/mysql-load-manual.md @@ -266,4 +266,4 @@ PROPERTIES ("exec_mem_limit"="10737418240"); ## More help -For more detailed syntax and best practices related to MySQL Load, refer to the [MySQL Load](../../../sql-manual/sql-statements/Data-Manipulation-Statements/Load/MYSQL-LOAD/) command manual. +For more detailed syntax and best practices related to MySQL Load, refer to the [MySQL Load](../../../sql-manual/sql-statements/data-modification/load-and-export/MYSQL-LOAD) command manual. diff --git a/docs/data-operate/import/import-way/routine-load-manual.md b/docs/data-operate/import/import-way/routine-load-manual.md index b3ba21d2c761d..2d7d67d977234 100644 --- a/docs/data-operate/import/import-way/routine-load-manual.md +++ b/docs/data-operate/import/import-way/routine-load-manual.md @@ -80,7 +80,7 @@ The specific import process of Routine Load is shown in the following diagram: ### Create Job -In Doris, you can create persistent Routine Load tasks using the `CREATE ROUTINE LOAD` command. For detailed syntax, please refer to [CREATE ROUTINE LOAD](../../../sql-manual/sql-statements/Data-Manipulation-Statements/Load/CREATE-ROUTINE-LOAD). Routine Load supports consuming data in CSV and JSON formats. +In Doris, you can create persistent Routine Load tasks using the `CREATE ROUTINE LOAD` command. For detailed syntax, please refer to [CREATE ROUTINE LOAD](../../../sql-manual/sql-statements/data-modification/load-and-export/CREATE-ROUTINE-LOAD). Routine Load supports consuming data in CSV and JSON formats. **Loading CSV Data** @@ -234,7 +234,7 @@ mysql> SHOW ROUTINE LOAD TASK WHERE jobname = 'example_routine_load_csv'; ### Pausing Jobs -You can pause an load job using the [PAUSE ROUTINE LOAD](../../../sql-manual/sql-statements/Data-Manipulation-Statements/Load/PAUSE-ROUTINE-LOAD) command. When a job is paused, it enters the PAUSED state, but the load job is not terminated and can be resumed using the RESUME ROUTINE LOAD command. +You can pause an load job using the [PAUSE ROUTINE LOAD](../../../sql-manual/sql-statements/data-modification/load-and-export/PAUSE-ROUTINE-LOAD) command. When a job is paused, it enters the PAUSED state, but the load job is not terminated and can be resumed using the RESUME ROUTINE LOAD command. To pause the `testdb.example_routine_load_csv` load job, you can use the following command: @@ -244,7 +244,7 @@ PAUSE ROUTINE LOAD FOR testdb.example_routine_load_csv; ### Resuming Jobs -You can resume a paused load job using the [RESUME ROUTINE LOAD](../../../sql-manual/sql-statements/Data-Manipulation-Statements/Load/RESUME-ROUTINE-LOAD) command. +You can resume a paused load job using the [RESUME ROUTINE LOAD](../../../sql-manual/sql-statements/data-modification/load-and-export/RESUME-ROUTINE-LOAD) command. To resume the `testdb.example_routine_load_csv` job, you can use the following command: @@ -254,7 +254,7 @@ RESUME ROUTINE LOAD FOR testdb.example_routine_load_csv; ### Modifying Jobs -You can modify a created loading job using the [ALTER ROUTINE LOAD](../../../sql-manual/sql-statements/Data-Manipulation-Statements/Load/ALTER-ROUTINE-LOAD) command. Before modifying the job, you need to pause it using the` PAUSE ROUTINE LOAD` command, and after making the modifications, you can resume it using the `RESUME ROUTINE LOAD` command. +You can modify a created loading job using the [ALTER ROUTINE LOAD](../../../sql-manual/sql-statements/data-modification/load-and-export/ALTER-ROUTINE-LOAD) command. Before modifying the job, you need to pause it using the` PAUSE ROUTINE LOAD` command, and after making the modifications, you can resume it using the `RESUME ROUTINE LOAD` command. To modify the `desired_concurrent_number` parameter for the job and update the Kafka topic information, you can use the following command: @@ -271,7 +271,7 @@ FROM KAFKA( ### Canceling Jobs -You can stop and delete a Routine Load job using the [STOP ROUTINE LOAD](../../../sql-manual/sql-statements/Data-Manipulation-Statements/Load/STOP-ROUTINE-LOAD) command. Once deleted, the load job cannot be recovered and cannot be viewed using the `SHOW ROUTINE LOAD` command. +You can stop and delete a Routine Load job using the [STOP ROUTINE LOAD](../../../sql-manual/sql-statements/data-modification/load-and-export/STOP-ROUTINE-LOAD) command. Once deleted, the load job cannot be recovered and cannot be viewed using the `SHOW ROUTINE LOAD` command. To stop and delete the `testdb.example_routine_load_csv` load job, you can use the following command: @@ -386,8 +386,8 @@ Here are the available parameters for the job_properties clause: | max_batch_interval | The maximum running time for each subtask, in seconds. Must be greater than 0, with a default value of 60s. max_batch_interval/max_batch_rows/max_batch_size together form the execution threshold for subtasks. If any of these parameters reaches the threshold, the load subtask ends and a new one is generated. | | max_batch_rows | The maximum number of rows read by each subtask. Must be greater than or equal to 200,000. The default value is 20,000,000. max_batch_interval/max_batch_rows/max_batch_size together form the execution threshold for subtasks. If any of these parameters reaches the threshold, the load subtask ends and a new one is generated. | | max_batch_size | The maximum number of bytes read by each subtask. The unit is bytes, and the range is from 100MB to 10GB. The default value is 1G. max_batch_interval/max_batch_rows/max_batch_size together form the execution threshold for subtasks. If any of these parameters reaches the threshold, the load subtask ends and a new one is generated. | -| max_error_number | The maximum number of error rows allowed within a sampling window. Must be greater than or equal to 0. The default value is 0, which means no error rows are allowed. The sampling window is `max_batch_rows * 10`. If the number of error rows within the sampling window exceeds `max_error_number`, the regular job will be paused and manual intervention is required to check for data quality issues using the [SHOW ROUTINE LOAD](../../../sql-manual/sql-statements/Show-Statements/SHOW-ROUTINE-LOAD) command and `ErrorLogUrls`. Rows filtered out by the WHERE condition are not counted as error rows. | -| strict_mode | Whether to enable strict mode. The default value is disabled. Strict mode applies strict filtering to type conversions during the load process. If enabled, non-null original data that results in a NULL after type conversion will be filtered out. The filtering rules in strict mode are as follows: | +| max_error_number | The maximum number of error rows allowed within a sampling window. Must be greater than or equal to 0. The default value is 0, which means no error rows are allowed. The sampling window is `max_batch_rows * 10`. If the number of error rows within the sampling window exceeds `max_error_number`, the regular job will be paused and manual intervention is required to check for data quality issues using the [SHOW ROUTINE LOAD](../../../sql-manual/sql-statements/data-modification/load-and-export/SHOW-ROUTINE-LOAD) command and `ErrorLogUrls`. Rows filtered out by the WHERE condition are not counted as error rows. | +| strict_mode | Whether to enable strict mode. The default value is disabled. Strict mode applies strict filtering to type conversions during the load process. If enabled, non-null original data that results in a NULL after type conversion will be filtered out. The filtering rules in strict mode are as follows: | | timezone | Specifies the time zone used by the load job. The default is to use the session's timezone parameter. This parameter affects the results of all timezone-related functions involved in the load. | | format | Specifies the data format for the load. The default is CSV, and JSON format is supported. | | jsonpaths | When the data format is JSON, jsonpaths can be used to specify the JSON paths to extract data from nested structures. It is a JSON array of strings, where each string represents a JSON path. | @@ -418,7 +418,7 @@ The available options for the data_source_properties clause are as follows: | kafka_topic | Specifies the Kafka topic to subscribe to. A load job can only consume one Kafka topic. | | kafka_partitions | Specifies the Kafka partitions to subscribe to. If not specified, all partitions are consumed by default. | | kafka_offsets | Specifies the starting consumption offset for Kafka partitions. If a timestamp is specified, consumption starts from the nearest offset equal to or greater than that timestamp. The offset can be a specific offset greater than or equal to 0, or it can use the following formats: | -| property | Specifies custom Kafka parameters. This is equivalent to the "--property" parameter in the Kafka shell. When the value of a parameter is a file, the keyword "FILE:" needs to be added before the value. For creating a file, you can refer to the [CREATE FILE](../../../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FILE) command documentation. For more supported custom parameters, you can refer to the client-side configuration options in the official [CONFIGURATION](https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md) documentation of librdkafka. For example: `"property.client.id" = "12345"`, `"property.group.id" = "group_id_0"`, `"property.ssl.ca.location" = "FILE:ca.pem"` | +| property | Specifies custom Kafka parameters. This is equivalent to the "--property" parameter in the Kafka shell. When the value of a parameter is a file, the keyword "FILE:" needs to be added before the value. For creating a file, you can refer to the [CREATE FILE](../../../sql-manual/sql-statements/security/CREATE-FILE) command documentation. For more supported custom parameters, you can refer to the client-side configuration options in the official [CONFIGURATION](https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md) documentation of librdkafka. For example: `"property.client.id" = "12345"`, `"property.group.id" = "group_id_0"`, `"property.ssl.ca.location" = "FILE:ca.pem"` | By configuring the Kafka property parameter in the `data_source_properties`, you can set up security access options. Currently, Doris supports various Kafka security protocols such as plaintext (default), SSL, PLAIN, and Kerberos. @@ -1723,4 +1723,4 @@ FROM KAFKA ## More Details -Refer to the SQL manual on [Routine Load](../../../sql-manual/sql-statements/Data-Manipulation-Statements/Load/CREATE-ROUTINE-LOAD). You can also enter `HELP ROUTINE LOAD` in the client command line for more help. +Refer to the SQL manual on [Routine Load](../../../sql-manual/sql-statements/data-modification/load-and-export/CREATE-ROUTINE-LOAD). You can also enter `HELP ROUTINE LOAD` in the client command line for more help. diff --git a/docs/data-operate/import/import-way/stream-load-manual.md b/docs/data-operate/import/import-way/stream-load-manual.md index ce931c933dfef..4653dd3334deb 100644 --- a/docs/data-operate/import/import-way/stream-load-manual.md +++ b/docs/data-operate/import/import-way/stream-load-manual.md @@ -70,7 +70,7 @@ For detailed syntax, please refer to [STREAM LOAD](../../../sql-manual/sql-state ### Prerequisite check -Stream Load requires `INSERT` privileges on the target table. If there are no `INSERT` privileges, it can be granted to the user through the [GRANT](../../../sql-manual/sql-statements/Account-Management-Statements/GRANT) command. +Stream Load requires `INSERT` privileges on the target table. If there are no `INSERT` privileges, it can be granted to the user through the [GRANT](../../../sql-manual/sql-statements/account-management/GRANT-TO) command. ### Create load job diff --git a/docs/data-operate/scheduler/job-scheduler.md b/docs/data-operate/scheduler/job-scheduler.md index ecb582ec84d33..1b7758e81cc8e 100644 --- a/docs/data-operate/scheduler/job-scheduler.md +++ b/docs/data-operate/scheduler/job-scheduler.md @@ -50,7 +50,7 @@ Doris Job Scheduler is a task management system that runs based on preset schedu - **Traceable Scheduling Records:** Stores the latest task execution records (configurable), which can be viewed with simple commands to ensure traceability. - **High Availability:** Leveraging Doris’s high-availability mechanisms, Job Scheduler can easily achieve self-recovery and high availability. -**Related Documentation:** [CREATE-JOB](../../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-JOB.md) +**Related Documentation:** [CREATE-JOB](../../sql-manual/sql-statements/job/CREATE-JOB) ## Syntax Overview diff --git a/docs/data-operate/update/unique-update.md b/docs/data-operate/update/unique-update.md index 58386e2679c17..f0bda871a9438 100644 --- a/docs/data-operate/update/unique-update.md +++ b/docs/data-operate/update/unique-update.md @@ -137,4 +137,4 @@ The updated data is as follows: ## More Help -For more detailed syntax on data updates, please refer to the [UPDATE](../../sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/UPDATE) command manual. You can also enter `HELP UPDATE` in the MySQL client command line for more help. +For more detailed syntax on data updates, please refer to the [UPDATE](../../sql-manual/sql-statements/data-modification/DML/UPDATE) command manual. You can also enter `HELP UPDATE` in the MySQL client command line for more help. diff --git a/docs/data-operate/update/update-of-aggregate-model.md b/docs/data-operate/update/update-of-aggregate-model.md index 3fde759a85cb6..8fa858b7a226c 100644 --- a/docs/data-operate/update/update-of-aggregate-model.md +++ b/docs/data-operate/update/update-of-aggregate-model.md @@ -1,4 +1,4 @@ -- +--- { "title": "Updating Data on Aggregate Key Model", "language": "en" diff --git a/docs/ecosystem/doris-kafka-connector.md b/docs/ecosystem/doris-kafka-connector.md index 4bb063590e58b..7baee63a94f10 100644 --- a/docs/ecosystem/doris-kafka-connector.md +++ b/docs/ecosystem/doris-kafka-connector.md @@ -48,7 +48,7 @@ Create the plugins directory under $KAFKA_HOME and put the downloaded doris-kafk Configure config/connect-standalone.properties ```properties -# Modify broker address +# Modify kafka server address bootstrap.servers=127.0.0.1:9092 # Modify to the created plugins directory diff --git a/docs/gettingStarted/what-is-apache-doris.md b/docs/gettingStarted/what-is-apache-doris.md index 9ed4845a2fb0f..1de42dab427da 100644 --- a/docs/gettingStarted/what-is-apache-doris.md +++ b/docs/gettingStarted/what-is-apache-doris.md @@ -83,7 +83,7 @@ Starting from version 3.0, a compute-storage decoupled deployment architecture c - Storage Layer: The storage layer can use shared storage solutions such as S3, HDFS, OSS, COS, OBS, Minio, and Ceph to store Doris's data files, including Segment files and inverted index files. -![Overall Architecture and Technical Features of Compute-Storage Decoupling](/images/getting-started/apache-doris-technical-compute-storage-decouple-overview.png) +![Overall Architecture and Technical Features of Compute-Storage Decoupling](/images/getting-started/apache-doris-technical-compute-storage-decouple-overview.jpg) ## Core Features of Apache Doris diff --git a/docs/install/deploy-manually/storage-compute-decoupled-deploy-manually.md b/docs/install/deploy-manually/storage-compute-decoupled-deploy-manually.md index 1a354de126ae1..193391da8b9a6 100644 --- a/docs/install/deploy-manually/storage-compute-decoupled-deploy-manually.md +++ b/docs/install/deploy-manually/storage-compute-decoupled-deploy-manually.md @@ -1,6 +1,6 @@ --- { - "title": "deploy storage compute decoupled manually", + "title": "Deploy Storage Compute Decoupled Manually", "language": "en" } --- @@ -244,7 +244,7 @@ Other nodes should also modify their configuration files and start following the ALTER SYSTEM ADD FOLLOWER "host:port"; ``` -Replace `host:port` with the actual address of the FE node and edit the log port. For more information, see [ADD FOLLOWER](../../sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-FOLLOWER) and [ADD OBSERVER](../../sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-OBSERVER). +Replace `host:port` with the actual address of the FE node and edit the log port. For more information, see [ADD FOLLOWER](../../sql-manual/sql-statements/cluster-management/instance-management/ADD-FOLLOWER) and [ADD OBSERVER](../../sql-manual/sql-statements/cluster-management/instance-management/ADD-OBSERVER). In a production environment, make sure the total number of FE nodes in the FOLLOWER role, including the first FE, remains odd. Typically, three FOLLOWER nodes are sufficient. The number of FE nodes in the OBSERVER role can be arbitrary. @@ -284,7 +284,7 @@ To add Backend nodes to the cluster, perform the following steps for each Backen You can use PROPERTIES to specify the compute group where the BE is located. - For more detailed usage, refer to [ADD BACKEND](../../sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-BACKEND) and [REMOVE BACKEND](../../sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-BACKEND). + For more detailed usage, refer to [ADD BACKEND](../../sql-manual/sql-statements/cluster-management/instance-management/ADD-BACKEND) and [REMOVE BACKEND](../../sql-manual/sql-statements/cluster-management/instance-management/DROP-BACKEND). 5. Verify BE status @@ -335,7 +335,7 @@ Storage Vault is an important component in Doris' separation of storage and comp ); ``` - To create a Storage Vault on other object storage, please refer to [Create Storage Vault](../../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-STORAGE-VAULT). + To create a Storage Vault on other object storage, please refer to [Create Storage Vault](../../sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT). 3. Set Default Storage Vault diff --git a/docs/lakehouse/catalog-overview.md b/docs/lakehouse/catalog-overview.md index 0cd088b8ef6ad..3f0ec5116fd57 100644 --- a/docs/lakehouse/catalog-overview.md +++ b/docs/lakehouse/catalog-overview.md @@ -112,7 +112,7 @@ mysql> SHOW CATALOGS; +-----------+-----------------+----------+-----------+-------------------------+---------------------+------------------------+ ``` -You can view the statement to create a catalog using [SHOW CREATE CATALOG](../sql-manual/sql-statements/Show-Statements/SHOW-CREATE-CATALOG.md). +You can view the statement to create a catalog using [SHOW CREATE CATALOG](../sql-manual/sql-statements/catalog/SHOW-CREATE-CATALOG). ### Switching Catalog diff --git a/docs/query-acceleration/materialized-view/async-materialized-view/functions-and-demands.md b/docs/query-acceleration/materialized-view/async-materialized-view/functions-and-demands.md index c04b8a6ca025a..c7bfa172df3ff 100644 --- a/docs/query-acceleration/materialized-view/async-materialized-view/functions-and-demands.md +++ b/docs/query-acceleration/materialized-view/async-materialized-view/functions-and-demands.md @@ -147,7 +147,7 @@ SELECT FROM lineitem; Not recommended for frequently changing base tables as it creates frequent materialized refresh tasks, consuming excessive resources. ::: -For more details, see [REFRESH MATERIALIZED VIEW](../../../sql-manual/sql-statements/Utility-Statements/REFRESH-MATERIALIZED-VIEW/) +For more details, see [REFRESH MATERIALIZED VIEW](../../../sql-manual/sql-statements/table-and-view/materialized-view/REFRESH-MATERIALIZED-VIEW) #### Examples Table Creation Statements @@ -482,7 +482,7 @@ SELECT FROM t1; Additionally, if the partition field is of string type, the date format can be specified by setting the materialized view's `partition_date_format` property, for example, `'%Y-%m-%d'`. -For more details, refer to [CREATE ASYNC MATERIALIZED VIEW](../../../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-ASYNC-MATERIALIZED-VIEW). +For more details, refer to [CREATE ASYNC MATERIALIZED VIEW](../../../sql-manual/sql-statements/table-and-view/materialized-view/CREATE-ASYNC-MATERIALIZED-VIEW). ### SQL Definition There are no restrictions on the SQL definition of asynchronous materialized views. @@ -1038,33 +1038,33 @@ SET( "grace_period" = "10" ); ``` -For more details, see [ALTER ASYNC MATERIALIZED VIEW](../../../sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-ASYNC-MATERIALIZED-VIEW) +For more details, see [ALTER ASYNC MATERIALIZED VIEW](../../../sql-manual/sql-statements/table-and-view/materialized-view/ALTER-ASYNC-MATERIALIZED-VIEW) ### Dropping Materialized Views ```sql DROP MATERIALIZED VIEW mv_1; ``` -For more details, see [DROP ASYNC MATERIALIZED VIEW](../../../sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-ASYNC-MATERIALIZED-VIEW) +For more details, see [DROP ASYNC MATERIALIZED VIEW](../../../sql-manual/sql-statements/table-and-view/materialized-view/DROP-ASYNC-MATERIALIZED-VIEW) ### Viewing Materialized View Creation Statement ```sql SHOW CREATE MATERIALIZED VIEW mv_1; ``` -For more details, see [SHOW CREATE MATERIALIZED VIEW](../../../sql-manual/sql-statements/Show-Statements/SHOW-CREATE-MATERIALIZED-VIEW/) +For more details, see [SHOW CREATE MATERIALIZED VIEW](../../../sql-manual/sql-statements/table-and-view/materialized-view/SHOW-CREATE-MATERIALIZED-VIEW) ### Pausing Materialized Views -For more details, see [PAUSE MATERIALIZED VIEW](../../../sql-manual/sql-statements/Utility-Statements/PAUSE-MATERIALIZED-VIEW) +For more details, see [PAUSE MATERIALIZED VIEW](../../../sql-manual/sql-statements/table-and-view/materialized-view/PAUSE-MATERIALIZED-VIEW-JOB) ### Resuming Materialized Views -For more details, see [RESUME MATERIALIZED VIEW](../../../sql-manual/sql-statements/Utility-Statements/RESUME-MATERIALIZED-VIEW) +For more details, see [RESUME MATERIALIZED VIEW](../../../sql-manual/sql-statements/table-and-view/materialized-view/RESUME-MATERIALIZED-VIEW-JOB) ### Canceling Materialized View Refresh Tasks -For more details, see [CANCEL MATERIALIZED VIEW TASK](../../../sql-manual/sql-statements/Utility-Statements/CANCEL-MATERIALIZED-VIEW-TASK) +For more details, see [CANCEL MATERIALIZED VIEW TASK](../../../sql-manual/sql-statements/table-and-view/materialized-view/CANCEL-MATERIALIZED-VIEW-TASK) ### Metadata Queries @@ -1202,11 +1202,11 @@ show partitions from mv11; Check the `SyncWithBaseTables` field - false indicates the partition is not available for transparent rewriting. -For more details, see [SHOW PARTITIONS](../../../sql-manual/sql-statements/Show-Statements/SHOW-PARTITIONS) +For more details, see [SHOW PARTITIONS](../../../sql-manual/sql-statements/table-and-view/table/SHOW-PARTITIONS) #### Viewing Materialized View Table Structure -For more details, see [DESCRIBE](../../../sql-manual/sql-statements/Utility-Statements/DESCRIBE) +For more details, see [DESCRIBE](../../../sql-manual/sql-statements/table-and-view/table/DESC-TABLE) ### Related Configuration #### Session Variables diff --git a/docs/query-data/join.md b/docs/query-data/join.md index fb187a4bb3884..39f6b9a2f26dc 100644 --- a/docs/query-data/join.md +++ b/docs/query-data/join.md @@ -28,7 +28,7 @@ In relational databases, data is distributed across multiple tables, which are i ## JOIN types supported by Doris -- **INNER JOIN**: Comparing each row of the left table with all rows of the right table based on the JOIN condition, returning matching rows from both tables. For more details, refer to the syntax definition for JOIN queries in [SELECT](../sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/SELECT/). +- **INNER JOIN**: Comparing each row of the left table with all rows of the right table based on the JOIN condition, returning matching rows from both tables. For more details, refer to the syntax definition for JOIN queries in [SELECT](../sql-manual/sql-statements/data-query/SELECT). - **LEFT JOIN**: Building on the result set of an INNER JOIN, if a row from the left table does not have a match in the right table, all rows from the left table are returned, with corresponding columns from the right table shown as NULL. diff --git a/docs/query-data/udf/java-user-defined-function.md b/docs/query-data/udf/java-user-defined-function.md index b199bd80378cd..96931bb2621fd 100644 --- a/docs/query-data/udf/java-user-defined-function.md +++ b/docs/query-data/udf/java-user-defined-function.md @@ -112,7 +112,7 @@ When writing a UDF in Java, the main entry point must be the `evaluate` function } ``` -2. Register and create the Java-UDF function in Doris. For more details on the syntax, refer to [CREATE FUNCTION](../../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FUNCTION.md). +2. Register and create the Java-UDF function in Doris. For more details on the syntax, refer to [CREATE FUNCTION](../../sql-manual/sql-statements/function/CREATE-FUNCTION). ```sql CREATE FUNCTION java_udf_add_one(int) RETURNS int PROPERTIES ( @@ -123,7 +123,7 @@ When writing a UDF in Java, the main entry point must be the `evaluate` function ); ``` -3. To utilize UDFs, users must possess the `SELECT` privilege for the corresponding database. And to verify the successful registration of the UDF, you can use the [SHOW FUNCTIONS](../../sql-manual/sql-statements/Show-Statements/SHOW-FUNCTIONS.md) command. +3. To utilize UDFs, users must possess the `SELECT` privilege for the corresponding database. And to verify the successful registration of the UDF, you can use the [SHOW FUNCTIONS](../../sql-manual/sql-statements/function/SHOW-FUNCTIONS) command. ``` sql select id,java_udf_add_one(id) from test_table; @@ -135,7 +135,7 @@ When writing a UDF in Java, the main entry point must be the `evaluate` function +------+----------------------+ ``` -4. If a UDF is no longer needed, it can be dropped using the following command, as detailed in [DROP FUNCTION](../../sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-FUNCTION). +4. If a UDF is no longer needed, it can be dropped using the following command, as detailed in [DROP FUNCTION](../../sql-manual/sql-statements/function/DROP-FUNCTION). Additionally, if your UDF requires loading large resource files or defining global static variables, you can refer to the method for loading static variables described later in this document. @@ -325,7 +325,7 @@ public class MedianUDAF { -2. Register and create the Java-UDAF function in Doris. For more syntax details, please refer to [CREATE FUNCTION](../../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FUNCTION.md). +2. Register and create the Java-UDAF function in Doris. For more syntax details, please refer to [CREATE FUNCTION](../../sql-manual/sql-statements/function/CREATE-FUNCTION). ```sql CREATE AGGREGATE FUNCTION simple_demo(INT) RETURNS INT PROPERTIES ( @@ -378,7 +378,7 @@ UDTF is supported starting from Doris version 3.0. ``` 2. Register and create the Java-UDTF function in Doris. Two UDTF functions will be registered. Table functions in Doris may exhibit different behaviors due to the `_outer` suffix. For more details, refer to [OUTER combinator](../../sql-manual/sql-functions/table-functions/explode-numbers-outer.md). -For more syntax details, please refer to [CREATE FUNCTION](../../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FUNCTION.md). +For more syntax details, please refer to [CREATE FUNCTION](../../sql-manual/sql-statements/function/CREATE-FUNCTION). ```sql CREATE TABLES FUNCTION java-utdf(string, string) RETURNS array PROPERTIES ( diff --git a/docs/releasenotes/v1.1/release-1.1.0.md b/docs/releasenotes/v1.1/release-1.1.0.md index dd94da6816294..e7bb10faf5abf 100644 --- a/docs/releasenotes/v1.1/release-1.1.0.md +++ b/docs/releasenotes/v1.1/release-1.1.0.md @@ -88,11 +88,11 @@ On all 13 SQLs in the SSB test data set, version 1.1 is better than version 0.15 On all 22 SQLs in the TPC-H test data set, version 1.1 is better than version 0.15, the overall performance is improved by about 4.5 times, and the performance of some scenarios is improved by more than ten times; -![](/images/release-note-1.1.0-SSB.png) +![release-note-1.1.0-SSB](/images/release-note-1.1.0-SSB.png)

SSB Benchmark

-![](/images/release-note-1.1.0-TPC-H.png) +![release-note-1.1.0-TPC-H](/images/release-note-1.1.0-TPC-H.png)

TPC-H Benchmark

diff --git a/docs/sql-manual/sql-functions/aggregate-functions/group-concat.md b/docs/sql-manual/sql-functions/aggregate-functions/group-concat.md index cc870e11a43dc..f2abc73843bf7 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/group-concat.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/group-concat.md @@ -24,25 +24,36 @@ specific language governing permissions and limitations under the License. --> -## GROUP_CONCAT -### description -#### Syntax +## Description -`VARCHAR GROUP_CONCAT([DISTINCT] VARCHAR str[, VARCHAR sep] [ORDER BY { col_name | expr} [ASC | DESC]])` +The GROUP_CONCAT function concatenates multiple rows of results in the result set into a string. +## Syntax -This function is an aggregation function similar to sum (), and group_concat links multiple rows of results in the result set to a string. The second parameter, sep, is a connection symbol between strings, which can be omitted. This function usually needs to be used with group by statements. +```sql +GROUP_CONCAT([DISTINCT] [, ] [ORDER BY { | } [ASC | DESC]]) +``` + +## Parameters -Support Order By for sorting multi-row results, sorting and aggregation columns can be different. +| Parameters | Description | +| ------------ | ---------------------- | +| `` | Required. The expression of the value to be concatenated. | +| `` | Optional. The separator between strings. | +| `` | Optional. The column used for sorting. | +| `` | Optional. The expression used for sorting. | -:::caution -`group_concat` don't support using `distinct` with `order by` together. -::: +## Return Value -### example +Returns a value of type VARCHAR. +## Example + +```sql +select value from test; ``` -mysql> select value from test; + +```text +-------+ | value | +-------+ @@ -51,35 +62,52 @@ mysql> select value from test; | c | | c | +-------+ +``` + +```sql +select GROUP_CONCAT(value) from test; +``` -mysql> select GROUP_CONCAT(value) from test; +```text +-----------------------+ | GROUP_CONCAT(`value`) | +-----------------------+ -| a, b, c, c | +| a, b, c, c | +-----------------------+ +``` -mysql> select GROUP_CONCAT(value, " ") from test; -+----------------------------+ -| GROUP_CONCAT(`value`, ' ') | -+----------------------------+ -| a b c c | -+----------------------------+ +```sql +select GROUP_CONCAT(DISTINCT value) from test; +``` -mysql> select GROUP_CONCAT(DISTINCT value) from test; +```text +-----------------------+ | GROUP_CONCAT(`value`) | +-----------------------+ | a, b, c | +-----------------------+ +``` + +```sql +select GROUP_CONCAT(value, " ") from test; +``` -mysql> select GROUP_CONCAT(value, NULL) from test; +```text +----------------------------+ -| GROUP_CONCAT(`value`, NULL)| +| GROUP_CONCAT(`value`, ' ') | +----------------------------+ -| NULL | +| a b c c | +----------------------------+ ``` -### keywords -GROUP_CONCAT,GROUP,CONCAT +```sql +select GROUP_CONCAT(value, NULL) from test; +``` + +```text ++----------------------------+ +| GROUP_CONCAT(`value`, NULL)| ++----------------------------+ +| NULL | ++----------------------------+ +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/aggregate-functions/histogram.md b/docs/sql-manual/sql-functions/aggregate-functions/histogram.md index 20246ec319a30..85d211b3380da 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/histogram.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/histogram.md @@ -24,32 +24,52 @@ specific language governing permissions and limitations under the License. --> -## HISTOGRAM -### description -#### Syntax +## Description -`histogram(expr[, INT num_buckets])` +The histogram function is used to describe the distribution of the data. It uses an "equal height" bucking strategy, and divides the data into buckets according to the value of the data. It describes each bucket with some simple data, such as the number of values that fall in the bucket. -The histogram function is used to describe the distribution of the data. It uses an "equal height" bucking strategy, and divides the data into buckets according to the value of the data. It describes each bucket with some simple data, such as the number of values that fall in the bucket. It is mainly used by the optimizer to estimate the range query. +## Alias -The result of the function returns an empty or Json string. +HIST -Parameter description: -- num_buckets:Optional. Limit the number of histogram buckets. The default value is 128. +## Syntax + +```sql +HISTOGRAM([, ]) +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `expr` | The expression that needs to be obtained. | +| `num_buckets` | Optional. Limit the number of histogram buckets. The default value is 128.| -Alias function: `hist(expr[, INT num_buckets])` -### example +## Return Value +Returns a value of JSON type after histogram estimation. Special cases: +- When the parameter is NULL, it returns NULL. + +## Example + +```sql +SELECT histogram(c_float) FROM histogram_test; ``` -MySQL [test]> SELECT histogram(c_float) FROM histogram_test; + +```text +-------------------------------------------------------------------------------------------------------------------------------------+ | histogram(`c_float`) | +-------------------------------------------------------------------------------------------------------------------------------------+ | {"num_buckets":3,"buckets":[{"lower":"0.1","upper":"0.1","count":1,"pre_sum":0,"ndv":1},...]} | +-------------------------------------------------------------------------------------------------------------------------------------+ +``` + +```sql +SELECT histogram(c_string, 2) FROM histogram_test; +``` -MySQL [test]> SELECT histogram(c_string, 2) FROM histogram_test; +```text +-------------------------------------------------------------------------------------------------------------------------------------+ | histogram(`c_string`) | +-------------------------------------------------------------------------------------------------------------------------------------+ @@ -59,7 +79,7 @@ MySQL [test]> SELECT histogram(c_string, 2) FROM histogram_test; Query result description: -``` +```json { "num_buckets": 3, "buckets": [ @@ -88,6 +108,7 @@ Query result description: } ``` +```text Field description: - num_buckets:The number of buckets - buckets:All buckets @@ -98,7 +119,4 @@ Field description: - ndv:The number of different values in the bucket > Total number of histogram elements = number of elements in the last bucket(count) + total number of elements in the previous bucket(pre_sum). - -### keywords - -HISTOGRAM, HIST +``` diff --git a/docs/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md b/docs/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md index 49d6da2d682b0..0a87ce538719f 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md @@ -24,29 +24,36 @@ specific language governing permissions and limitations under the License. --> -## HLL_UNION_AGG -### description -#### Syntax +## Description -`HLL_UNION_AGG(hll)` +The HLL_UNION_AGG function is an aggregate function, which is mainly used to merge multiple HyperLogLog data structures and estimate the approximate value of the combined cardinality. +## Syntax -HLL is an engineering implementation based on HyperLog algorithm, which is used to save the intermediate results of HyperLog calculation process. +```sql +hll_union_agg() +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The HyperLogLog type expression to be calculated | -It can only be used as the value column type of the table and reduce the amount of data through aggregation to achieve the purpose of speeding up the query. +## Return Value -Based on this, we get an estimate with an error of about 1%. The HLL column is generated by other columns or data imported into the data. +Returns the cardinality value of type BIGINT. -When importing, hll_hash function is used to specify which column in data is used to generate HLL column. It is often used to replace count distinct, and to calculate UV quickly in business by combining rollup. +## Example -### example +```sql +select HLL_UNION_AGG(uv_set) from test_uv; ``` -MySQL > select HLL_UNION_AGG(uv_set) from test_uv;; + +```text +-------------------------+ -THE COURT OF JUSTICE OF THE EUROPEAN COMMUNITIES, +| HLL_UNION_AGG(`uv_set`) | +-------------------------+ | 17721 | +-------------------------+ -``` -### keywords -HLL_UNION_AGG,HLL,UNION,AGG +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/aggregate-functions/intersect-count.md b/docs/sql-manual/sql-functions/aggregate-functions/intersect-count.md index eabb298d94ef7..90cabec51cf25 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/intersect-count.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/intersect-count.md @@ -22,36 +22,51 @@ specific language governing permissions and limitations under the License. --> -## intersect_count -### description -#### Syntax +## Description -`BITMAP INTERSECT_COUNT(bitmap_column, column_to_filter, filter_values)` -Calculate the intersection of two or more bitmaps -Usage: intersect_count(bitmap_column_to_count, filter_column, filter_values ...) -Example: intersect_count(user_id, event, 'A', 'B', 'C'), meaning find the intersect count of user_id in all A/B/C 3 bitmaps +The INTERSECT_COUNT function is used to calculate the number of intersecting elements of the Bitmap data structure. -### example +## Syntax +```sql +INTERSECT_COUNT(, , ) ``` -MySQL [test_query_qa]> select dt,bitmap_to_string(user_id) from pv_bitmap where dt in (3,4); + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The expression that needs to be obtained. | +| `` | The dimension column that needs to be filtered. | +| `` | Different values of the filtering dimension column. | + +## Return Value + +Returns a value of type BIGINT. + +## Example + +```sql +select dt,bitmap_to_string(user_id) from pv_bitmap where dt in (3,4); +``` + +```text +------+-----------------------------+ | dt | bitmap_to_string(`user_id`) | +------+-----------------------------+ -| 4 | 1,2,3 | -| 3 | 1,2,3,4,5 | +| 4 | 1,2,3 | +| 3 | 1,2,3,4,5 | +------+-----------------------------+ -2 rows in set (0.012 sec) +``` + +```sql +select intersect_count(user_id,dt,3,4) from pv_bitmap; +``` -MySQL [test_query_qa]> select intersect_count(user_id,dt,3,4) from pv_bitmap; +```text +----------------------------------------+ | intersect_count(`user_id`, `dt`, 3, 4) | +----------------------------------------+ | 3 | +----------------------------------------+ -1 row in set (0.014 sec) ``` - -### keywords - - INTERSECT_COUNT,BITMAP diff --git a/docs/sql-manual/sql-functions/aggregate-functions/kurt.md b/docs/sql-manual/sql-functions/aggregate-functions/kurt.md index 430118be26061..8056dd0297a52 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/kurt.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/kurt.md @@ -26,42 +26,66 @@ under the License. ## Description -Returns the [kurtosis](https://en.wikipedia.org/wiki/Kurtosis) of the expr expression. -The forumula used for this function is `4-th centrol moment / ((variance)^2) - 3`, when variance is zero, `kurtosis` will return `NULL`. +The KURTOSIS function returns the [kurtosis](https://en.wikipedia.org/wiki/Kurtosis) of the expr expression. +The forumula used for this function is `4-th centrol moment / ((variance)^2) - 3`. + +## Alias + +KURT_POP,KURTOSIS ## Syntax -`kurtosis(expr)` +```sql +KURTOSIS() +``` -## Arguments +## Parameters -TinyInt/SmallInt/Integer/BigInt/Float/Double, Decimal will be casted to a float number. +| Parameters | Description | +| -- | -- | +| `` | The expression needs to be obtained | -## Return value +## Return Value -`Double` +Returns a value of type DOUBLE. Special cases: +- Returns NULL when the variance is zero. ## Example + ```sql -create table statistic_test(tag int, val1 double not null, val2 double null) distributed by hash(tag) properties("replication_num"="1") +select * from statistic_test; +``` -insert into statistic_test values (1, -10, -10),(2, -20, NULL),(3, 100, NULL),(4, 100, NULL),(5, 1000,1000); +```text ++-----+------+------+ +| tag | val1 | val2 | ++-----+------+------+ +| 1 | -10 | -10| +| 2 | -20 | NULL| +| 3 | 100 | NULL| +| 4 | 100 | NULL| +| 5 | 1000 | 1000| ++-----+------+------+ +``` -// NULL is ignored -select kurt(val1), kurt(val2) from statistic_test --------------- +```sql +select kurt(val1), kurt(val2) from statistic_test; +``` +```text +-------------------+--------------------+ | kurt(val1) | kurt(val2) | +-------------------+--------------------+ | 0.162124583734851 | -1.3330994719286338 | +-------------------+--------------------+ -1 row in set (0.02 sec) +``` +```sql // Each group just has one row, result is NULL -select kurt(val1), kurt(val2) from statistic_test group by tag --------------- +select kurt(val1), kurt(val2) from statistic_test group by tag; +``` +```text +------------+------------+ | kurt(val1) | kurt(val2) | +------------+------------+ @@ -71,9 +95,5 @@ select kurt(val1), kurt(val2) from statistic_test group by tag | NULL | NULL | | NULL | NULL | +------------+------------+ -5 rows in set (0.02 sec) ``` -## Related Commands - -[skew](./skew.md) \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/aggregate-functions/linear-histogram.md b/docs/sql-manual/sql-functions/aggregate-functions/linear-histogram.md index 939376c357042..db0e37df42104 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/linear-histogram.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/linear-histogram.md @@ -25,28 +25,45 @@ under the License. --> ## Description -### Syntax -`LINEAR_HISTOGRAM(expr, DOUBLE interval[, DOUBLE offset)` +The LINEAR_HISTOGRAM function is used to describe the data distribution. It uses an "equal width" bucking strategy, and divides the data into buckets according to the value of the data. -The linear_histogram function is used to describe the distribution of the data, It uses an "equal width" bucking strategy, and divides the data into buckets according to the value of the data. +## Syntax -Parameter description: +```sql +`LINEAR_HISTOGRAM(, DOUBLE [, DOUBLE )` +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `interval` | Required. The width of the bucket. | +| `offset` | Optional. The default value is 0, and the range is `[0, interval)`. | -- `interval`: Required. The bucket width. -- `offset`: Optional. Default is 0. It should be in `[0, interval)`. +## Return Value + +Returns a value of the computed JSON type. ## Example +```sql +select linear_histogram(a, 2) from histogram_test; ``` -mysql> select linear_histogram(a, 2) from histogram_test; + +```text +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | linear_histogram(a, cast(2 as DOUBLE)) | +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | {"num_buckets":6,"buckets":[{"lower":0.0,"upper":2.0,"count":2,"acc_count":2},{"lower":2.0,"upper":4.0,"count":4,"acc_count":6},{"lower":4.0,"upper":6.0,"count":4,"acc_count":10},{"lower":6.0,"upper":8.0,"count":4,"acc_count":14},{"lower":8.0,"upper":10.0,"count":4,"acc_count":18},{"lower":10.0,"upper":12.0,"count":2,"acc_count":20}]} | +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +``` -mysql> select linear_histogram(a, 2, 1) from histogram_test; +```sql +select linear_histogram(a, 2, 1) from histogram_test; +``` + +```text +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | linear_histogram(a, cast(2 as DOUBLE), cast(1 as DOUBLE)) | +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ @@ -54,6 +71,7 @@ mysql> select linear_histogram(a, 2, 1) from histogram_test; +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ``` +```text Field description: - `num_buckets`: The number of buckets. @@ -62,8 +80,4 @@ Field description: - `upper`: Upper bound of the bucket. (not included) - `count`: The number of elements contained in the bucket. - `acc_count`: Accumulated count. - - -## Keywords - -LINEAR_HISTOGRAM \ No newline at end of file +``` diff --git a/docs/sql-manual/sql-functions/aggregate-functions/map-agg.md b/docs/sql-manual/sql-functions/aggregate-functions/map-agg.md index b4c5ff616448a..15484436a98f2 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/map-agg.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/map-agg.md @@ -24,18 +24,32 @@ specific language governing permissions and limitations under the License. --> -## MAP_AGG -### description -#### Syntax +## Description -`MAP_AGG(expr1, expr2)` +The MAP_AGG function is used to form a mapping structure based on key-value pairs from multiple rows of data. +## Syntax -Returns a map consists of expr1 as the key and expr2 as the corresponding value. +`MAP_AGG(, )` -### example +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The expression used to specify the key. | +| `` | The expression used to specify the corresponding value. | + +## Return Value + +Returns a value of the MAP type. + +## Example + +```sql +select `n_nationkey`, `n_name`, `n_regionkey` from `nation`; ``` -MySQL > select `n_nationkey`, `n_name`, `n_regionkey` from `nation`; + +```text +-------------+----------------+-------------+ | n_nationkey | n_name | n_regionkey | +-------------+----------------+-------------+ @@ -65,8 +79,13 @@ MySQL > select `n_nationkey`, `n_name`, `n_regionkey` from `nation`; | 23 | UNITED KINGDOM | 3 | | 24 | UNITED STATES | 1 | +-------------+----------------+-------------+ +``` + +```sql +select `n_regionkey`, map_agg(`n_nationkey`, `n_name`) from `nation` group by `n_regionkey`; +``` -MySQL > select `n_regionkey`, map_agg(`n_nationkey`, `n_name`) from `nation` group by `n_regionkey`; +```text +-------------+---------------------------------------------------------------------------+ | n_regionkey | map_agg(`n_nationkey`, `n_name`) | +-------------+---------------------------------------------------------------------------+ @@ -76,8 +95,13 @@ MySQL > select `n_regionkey`, map_agg(`n_nationkey`, `n_name`) from `nation` gro | 4 | {4:"EGYPT", 10:"IRAN", 11:"IRAQ", 13:"JORDAN", 20:"SAUDI ARABIA"} | | 2 | {8:"INDIA", 9:"INDONESIA", 12:"JAPAN", 18:"CHINA", 21:"VIETNAM"} | +-------------+---------------------------------------------------------------------------+ +``` + +```sql +select n_regionkey, map_agg(`n_name`, `n_nationkey` % 5) from `nation` group by `n_regionkey`; +``` -MySQL > select n_regionkey, map_agg(`n_name`, `n_nationkey` % 5) from `nation` group by `n_regionkey`; +```text +-------------+------------------------------------------------------------------------+ | n_regionkey | map_agg(`n_name`, (`n_nationkey` % 5)) | +-------------+------------------------------------------------------------------------+ @@ -88,5 +112,3 @@ MySQL > select n_regionkey, map_agg(`n_name`, `n_nationkey` % 5) from `nation` g | 4 | {"EGYPT":4, "IRAN":0, "IRAQ":1, "JORDAN":3, "SAUDI ARABIA":0} | +-------------+------------------------------------------------------------------------+ ``` -### keywords -MAP_AGG diff --git a/docs/sql-manual/sql-functions/aggregate-functions/max-by.md b/docs/sql-manual/sql-functions/aggregate-functions/max-by.md index df3096287e92b..26ddb78b30546 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/max-by.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/max-by.md @@ -24,18 +24,34 @@ specific language governing permissions and limitations under the License. --> -## MAX_BY -### description -#### Syntax +## Description -`MAX_BY(expr1, expr2)` +The MAX_BY function is used to return the corresponding associated value based on the maximum value of the specified column. +## Syntax -Returns the value of an expr1 associated with the maximum value of expr2 in a group. +```sql +MAX_BY(, ) +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The expression used to specify the corresponding association. | +| `` | The expression used to specify the maximum value for statistics. | + +## Return Value + +Returns the same data type as the input expression . -### example +## Example + +```sql +select * from tbl; ``` -MySQL > select * from tbl; + +```text +------+------+------+------+ | k1 | k2 | k3 | k4 | +------+------+------+------+ @@ -44,13 +60,16 @@ MySQL > select * from tbl; | 4 | 3 | 2 | 1 | | 3 | 4 | 2 | 1 | +------+------+------+------+ +``` + +```sql +select max_by(k1, k4) from tbl; +``` -MySQL > select max_by(k1, k4) from tbl; +```text +--------------------+ | max_by(`k1`, `k4`) | +--------------------+ | 0 | +--------------------+ ``` -### keywords -MAX_BY diff --git a/docs/sql-manual/sql-functions/aggregate-functions/max.md b/docs/sql-manual/sql-functions/aggregate-functions/max.md index 68dd6183217c5..813ca7e5b612a 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/max.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/max.md @@ -24,23 +24,36 @@ specific language governing permissions and limitations under the License. --> -## MAX -### description -#### Syntax +## Description -`MAX(expr)` +The MAX function returns the maximum value of the expression. +## Syntax -Returns the maximum value of an expr expression +```sql +MAX() +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The expression needs to be obtained | + +## Return Value -### example +Returns the same data type as the input expression. + +## Example + +```sql +select max(scan_rows) from log_statis group by datetime; ``` -MySQL > select max(scan_rows) from log_statis group by datetime; + +```text +------------------+ | max(`scan_rows`) | +------------------+ | 4671587 | +------------------+ ``` -### keywords -MAX diff --git a/docs/sql-manual/sql-functions/aggregate-functions/median.md b/docs/sql-manual/sql-functions/aggregate-functions/median.md index 2571e1427db41..ea09cba1122f4 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/median.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/median.md @@ -23,3 +23,37 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## Description + +The MEDIAN function returns the median of the expression. + +## Syntax + +```sql +MEDIAN() +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The expression needs to be obtained | + +## Return Value + +Returns the same data type as the input expression. + +## Example + +```sql +select median(scan_rows) from log_statis group by datetime; +``` + +```text ++---------------------+ +| median(`scan_rows`) | ++---------------------+ +| 50 | ++---------------------+ +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/aggregate-functions/min-by.md b/docs/sql-manual/sql-functions/aggregate-functions/min-by.md index 52373088a4382..3d08da082367b 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/min-by.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/min-by.md @@ -24,18 +24,34 @@ specific language governing permissions and limitations under the License. --> -## MIN_BY -### description -#### Syntax +## Description -`MIN_BY(expr1, expr2)` +The MIN_BY function is used to return the corresponding associated value based on the minimum value of the specified column. +## Syntax -Returns the value of an expr1 associated with the minimum value of expr2 in a group. +```sql +MIN_BY(, ) +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The expression used to specify the corresponding association. | +| `` | The expression used to specify the minimum value for statistics. | + +## Return Value + +Returns the same data type as the input expression . -### example +## Example + +```sql +select * from tbl; ``` -MySQL > select * from tbl; + +```text +------+------+------+------+ | k1 | k2 | k3 | k4 | +------+------+------+------+ @@ -44,13 +60,16 @@ MySQL > select * from tbl; | 4 | 3 | 2 | 1 | | 3 | 4 | 2 | 1 | +------+------+------+------+ +``` + +```sql +select min_by(k1, k4) from tbl; +``` -MySQL > select min_by(k1, k4) from tbl; +```text +--------------------+ | min_by(`k1`, `k4`) | +--------------------+ | 4 | +--------------------+ ``` -### keywords -MIN_BY diff --git a/docs/sql-manual/sql-functions/aggregate-functions/min.md b/docs/sql-manual/sql-functions/aggregate-functions/min.md index 76915e2f1f199..8a6468ee09f4f 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/min.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/min.md @@ -24,23 +24,36 @@ specific language governing permissions and limitations under the License. --> -## MIN -### Description -#### Syntax +## Description -`MIN(expr)` +The MIN function returns the minimum value of the expression. +## Syntax -Returns the minimum value of an expr expression +```sql +MIN() +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The expression needs to be obtained | + +## Return Value -### example +Returns the same data type as the input expression. + +## Example + +```sql +select MIN(scan_rows) from log_statis group by datetime; ``` -MySQL > select min(scan_rows) from log_statis group by datetime; + +```text +------------------+ -| min(`scan_rows`) | +| MIN(`scan_rows`) | +------------------+ | 0 | +------------------+ ``` -### keywords -MIN diff --git a/docs/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md b/docs/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md index 4568d3abad0cc..6d40da959f170 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md @@ -1,6 +1,6 @@ --- { - "title": "orthogonal_bitmap_expr_calculate_count", + "title": "ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT", "language": "en" } --- @@ -23,3 +23,53 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## Description + +The ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT function returns the number of elements in the set after performing intersection, union, and difference calculations on the Bitmap expression. + +## Syntax + +```sql +ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT(, , ) +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The Bitmap type expression needs to be obtained | +| `` | The filtering dimension column, the Key column for calculation | +| `` | The calculation expression string, meaning that the Bitmap intersection, union, and difference set expressions are calculated based on the Key column. The supported operators in the expression: &represents intersection calculation, \| represents union calculation, - represents difference calculation, ^ represents XOR calculation, and \ represents escape characters | + +## Return Value + +Returns a value of type BIGINT. + +## Example + +```sql +select orthogonal_bitmap_expr_calculate_count(user_id, tag, '(833736|999777)&(1308083|231207)&(1000|20000-30000)') from user_tag_bitmap where tag in (833736,999777,130808,231207,1000,20000,30000); +Note: 1000, 20000, 30000 plastic tags represent different labels of users +``` + +```text ++-----------------------------------------------------------------------------------------------------------------+ +| orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(833736|999777)&(1308083|231207)&(1000|20000-30000)') | ++-----------------------------------------------------------------------------------------------------------------+ +| 1000 | ++-----------------------------------------------------------------------------------------------------------------+ +``` + +```sql +select orthogonal_bitmap_expr_calculate_count(user_id, tag, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23') from user_str_tag_bitmap where tag in ('A:a/b', 'B:2-4', 'C:1', 'D:12', 'E:23'); +Note: 'A:a/b', 'B:2-4', etc. are string types tag, representing different labels of users, where 'B:2-4' needs to be escaped as'B:2\\-4' +``` + +```text ++---------------------------------------------------------------------------------------------+ +| orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23') | ++---------------------------------------------------------------------------------------------+ +| 30 | ++---------------------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md b/docs/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md index af32728e3c15d..e49639b73d069 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md @@ -23,3 +23,53 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## Description + +The ORTHOGONAL_BITMAP_EXPR_CALCULATE function returns the set obtained after performing intersection, union, and difference calculations on the Bitmap expression. + +## Syntax + +```sql +ORTHOGONAL_BITMAP_EXPR_CALCULATE(, , ) +``` + +## Parameters + +| 参数 | 说明 | +| -- | -- | +| `` | The Bitmap type expression needs to be obtained | +| `` | The filtering dimension column, the Key column for calculation | +| `` | The calculation expression string, meaning that the Bitmap intersection, union, and difference set expressions are calculated based on the Key column. The supported operators in the expression: &represents intersection calculation, \| represents union calculation, - represents difference calculation, ^ represents XOR calculation, and \ represents escape characters | + +## Return Value + +Returns a set of BITMAP type. + +## Example + +```sql +select bitmap_count(orthogonal_bitmap_expr_calculate(user_id, tag, '(833736|999777)&(1308083|231207)&(1000|20000-30000)')) from user_tag_bitmap where tag in (833736,999777,130808,231207,1000,20000,30000); +Note: 1000, 20000, 30000 plastic tags represent different labels of users +``` + +```text ++-------------------------------------------------------------------------------------------------------------------------------+ +| bitmap_count(orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(833736|999777)&(1308083|231207)&(1000|20000-30000)')) | ++-------------------------------------------------------------------------------------------------------------------------------+ +| 1000 | ++-------------------------------------------------------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_count(orthogonal_bitmap_expr_calculate(user_id, tag, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23')) from user_str_tag_bitmap where tag in ('A:a/b', 'B:2-4', 'C:1', 'D:12', 'E:23'); +Note: 'A:a/b', 'B:2-4', etc. are string types tag, representing different labels of users, where 'B:2-4' needs to be escaped as'B:2\\-4' +``` + +```text ++-----------------------------------------------------------------------------------------------------------+ +| bitmap_count(orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23')) | ++-----------------------------------------------------------------------------------------------------------+ +| 30 | ++-----------------------------------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md b/docs/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md index a4c0e26cad133..57f1f722b36cc 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md @@ -23,3 +23,40 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## Description + +The ORTHOGONAL_BITMAP_INTERSECT_COUNT function returns the number of elements in the set after performing an intersection calculation on the Bitmap expression. + +## Syntax + +```sql +ORTHOGONAL_BITMAP_INTERSECT_COUNT(, , ) +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The Bitmap type expression needs to be obtained | +| `` | Optional. The dimension column that needs to be filtered | +| `` | Optional. A variable-length parameter, used to filter different values of the dimension column | + + +## Return Value + +Returns a value of type BIGINT. + +## Example + +```sql +select orthogonal_bitmap_intersect_count(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); +``` + +```text ++-------------------------------------------------------------------------------------+ +| orthogonal_bitmap_intersect_count(`members`, `tag_group`, 1150000, 1150001, 390006) | ++-------------------------------------------------------------------------------------+ +| 0 | ++-------------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md b/docs/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md index 6e39de0301b2f..bdcbe0b1e39ca 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md @@ -23,3 +23,40 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## Description + +The ORTHOGONAL_BITMAP_INTERSECT function returns the intersection set of the Bitmap expression. + +## Syntax + +```sql +ORTHOGONAL_BITMAP_INTERSECT(, , ) +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The Bitmap type expression needs to be obtained | +| `` | Optional. The dimension column that needs to be filtered | +| `` | Optional. A variable-length parameter, used to filter different values of the dimension column | + +## Return Value + +Returns a set of BITMAP type. + +## Example + +```sql +select orthogonal_bitmap_intersect(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); + +``` + +```text ++-------------------------------------------------------------------------------+ +| orthogonal_bitmap_intersect(`members`, `tag_group`, 1150000, 1150001, 390006) | ++-------------------------------------------------------------------------------+ +| NULL | ++-------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md b/docs/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md index 6b748d871d807..f234df23dd180 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md @@ -23,3 +23,39 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## Description + +The ORTHOGONAL_BITMAP_UNION_COUNT function returns the number of elements in the set after performing a union calculation on the Bitmap expression. + +## Syntax + +```sql +ORTHOGONAL_BITMAP_UNION_COUNT(, , ) +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The Bitmap type expression needs to be obtained | +| `` | Optional. The dimension column that needs to be filtered | +| `` | Optional. A variable-length parameter, used to filter different values of the dimension column | + +## Return Value + +Returns a set of BITMAP type. + +## Example + +```sql +select ORTHOGONAL_BITMAP_UNION_COUNT(members) from tag_map where tag_group in ( 1150000, 1150001, 390006); +``` + +```text ++------------------------------------------+ +| orthogonal_bitmap_union_count(`members`) | ++------------------------------------------+ +| 286957811 | ++------------------------------------------+ +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/aggregate-functions/percentile-approx.md b/docs/sql-manual/sql-functions/aggregate-functions/percentile-approx.md index 627ebc09797a1..e0810d31d902e 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/percentile-approx.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/percentile-approx.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,33 +22,73 @@ specific language governing permissions and limitations under the License. --> -## PERCENTILE_APPROX -### Description -#### Syntax +## Description + +The `PERCENTILE_APPROX` function is used to calculate approximate percentiles, primarily for large datasets. Compared to the `PERCENTILE` function, it has the following features: + +1. Memory Efficiency: Uses fixed-size memory, maintaining low memory consumption even when processing high-cardinality columns (large data volumes) +2. Performance Advantage: Suitable for processing large-scale datasets with faster computation +3. Adjustable Precision: Balance between precision and performance through the compression parameter + + +## Syntax + +```sql +PERCENTILE_APPROX(,

[, ]) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The column to calculate percentiles for | +| `

` | Percentile value, range `[0.0, 1.0]`, e.g., `0.99` represents the `99th` percentile | +| `` | Optional parameter, compression level, range `[2048, 10000]`, higher values increase precision but consume more memory. If not specified or out of range, uses `10000` | + +## Return Value -`PERCENTILE_APPROX(expr, DOUBLE p[, DOUBLE compression])` +Returns a `DOUBLE` value representing the calculated approximate percentile. -Return the approximation of the point p, where the value of P is between 0 and 1. +## Examples -Compression param is optional and can be setted to a value in the range of [2048, 10000]. The bigger compression you set, the more precise result and more time cost you will get. If it is not setted or not setted in the correct range, PERCENTILE_APPROX function will run with a default compression param of 10000. +```sql +-- Create sample table +CREATE TABLE response_times ( + request_id INT, + response_time DECIMAL(10, 2) +) DUPLICATE KEY(`request_id`) +DISTRIBUTED BY HASH(`request_id`) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); -This function uses fixed size memory, so less memory can be used for columns with high cardinality, and can be used to calculate statistics such as tp99. +-- Insert sample data +INSERT INTO response_times VALUES +(1, 10.5), +(2, 15.2), +(3, 20.1), +(4, 25.8), +(5, 30.3), +(6, 35.7), +(7, 40.2), +(8, 45.9), +(9, 50.4), +(10, 100.6); -### example +-- Calculate 99th percentile using different compression levels +SELECT + percentile_approx(response_time, 0.99) as p99_default, -- Default compression + percentile_approx(response_time, 0.99, 2048) as p99_fast, -- Lower compression, faster + percentile_approx(response_time, 0.99, 10000) as p99_accurate -- Higher compression, more accurate +FROM response_times; ``` -MySQL > select `table`, percentile_approx(cost_time,0.99) from log_statis group by `table`; -+---------------------+---------------------------+ -| table | percentile_approx(`cost_time`, 0.99) | -+----------+--------------------------------------+ -| test | 54.22 | -+----------+--------------------------------------+ - -MySQL > select `table`, percentile_approx(cost_time,0.99, 4096) from log_statis group by `table`; -+---------------------+---------------------------+ -| table | percentile_approx(`cost_time`, 0.99, 4096.0) | -+----------+--------------------------------------+ -| test | 54.21 | -+----------+--------------------------------------+ + +```text ++-------------------+-------------------+-------------------+ +| p99_default | p99_fast | p99_accurate | ++-------------------+-------------------+-------------------+ +| 100.5999984741211 | 100.5999984741211 | 100.5999984741211 | ++-------------------+-------------------+-------------------+ ``` -### keywords -PERCENTILE_APPROX,PERCENTILE,APPROX + + diff --git a/docs/sql-manual/sql-functions/aggregate-functions/percentile-array.md b/docs/sql-manual/sql-functions/aggregate-functions/percentile-array.md index 42c697a84e464..70039bda6b239 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/percentile-array.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/percentile-array.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,29 +22,68 @@ specific language governing permissions and limitations under the License. --> -## PERCENTILE_ARRAY -### Description -#### Syntax +## Description + +The `PERCENTILE_ARRAY` function calculates exact percentile arrays, allowing multiple percentile values to be computed at once. This function is primarily suitable for small datasets. -`ARRAY_DOUBLE PERCENTILE_ARRAY(expr, ARRAY_DOUBLE p)` +Key features: +1. Exact Calculation: Provides exact percentile results rather than approximations +2. Batch Processing: Can calculate multiple percentiles in a single operation +3. Scope: Best suited for handling small-scale datasets -Calculate exact percentiles, suitable for small data volumes. Sorts the specified column in descending order first, then takes the exact pth percentile. -The return value is the result of sequentially taking the specified percentages in the array p. -Parameter Description: -expr: Required. Columns whose values are of type integer (up to bigint). -p: The exact percentile is required, an array of constants, taking the value [0.0, 1.0]. -### example +## Syntax + +```sql +PERCENTILE_ARRAY(, ) ``` -mysql> select percentile_array(k1,[0.3,0.5,0.9]) from baseall; -+----------------------------------------------+ -| percentile_array(`k1`, ARRAY(0.3, 0.5, 0.9)) | -+----------------------------------------------+ -| [5.2, 8, 13.6] | -+----------------------------------------------+ -1 row in set (0.02 sec) +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The column to calculate the percentile for | +| `` | Percentile array, each element must be in the range `[0.0, 1.0]`, e.g., `[0.5, 0.95, 0.99]` | + +## Return Value + +Return a `DOUBLE` type array, containing the calculated percentile values. + +## Examples + +```sql +-- Create sample table +CREATE TABLE sales_data ( + id INT, + amount DECIMAL(10, 2) +) DUPLICATE KEY(`id`) +DISTRIBUTED BY HASH(`id`) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- Insert sample data +INSERT INTO sales_data VALUES +(1, 10.5), +(2, 15.2), +(3, 20.1), +(4, 25.8), +(5, 30.3), +(6, 35.7), +(7, 40.2), +(8, 45.9), +(9, 50.4), +(10, 100.6); + +-- Calculate multiple percentiles +SELECT percentile_array(amount, [0.25, 0.5, 0.75, 0.9]) as percentiles +FROM sales_data; ``` -### keywords -PERCENTILE_ARRAY +```text ++-----------------------------------------+ +| percentiles | ++-----------------------------------------+ +| [21.25, 32.5, 43.75, 54.99999999999998] | ++-----------------------------------------+ +``` diff --git a/docs/sql-manual/sql-functions/aggregate-functions/percentile.md b/docs/sql-manual/sql-functions/aggregate-functions/percentile.md index e773da48b8e05..2af92dd63354b 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/percentile.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/percentile.md @@ -1,7 +1,7 @@ --- { - "title": "PERCENTILE", - "language": "en" + "title": "PERCENTILE", + "language": "en" } --- diff --git a/docs/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md b/docs/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md index ae807db60062e..56aa8965c703f 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,36 +22,76 @@ specific language governing permissions and limitations under the License. --> -## PERCENTILE_APPROX_WEIGHTED -### description -#### Syntax +## Description + +The `PERCENTILE_APPROX_WEIGHTED` function calculates weighted approximate percentiles, primarily used in scenarios where value importance needs to be considered. It is a weighted version of `PERCENTILE_APPROX`, allowing a weight to be specified for each value. + +Key features: +1. Weight Support: Each value can be assigned a corresponding weight, affecting the final percentile calculation +2. Memory Efficiency: Uses fixed-size memory, suitable for processing large-scale data +3. Adjustable Precision: Balance between precision and performance through the compression parameter + +## Syntax + +```sql +PERCENTILE_APPROX_WEIGHTED(, ,

[, ]) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The column to calculate the percentile for | +| `` | Weight column, must be positive numbers | +| `

` | Percentile value, range `[0.0, 1.0]`, e.g., `0.99` represents the `99`th percentile | +| `` | Optional parameter, compression ratio, range `[2048, 10000]`. The higher the value, the higher the precision, but the greater the memory consumption. If not specified or outside the range, use `10000`. | -`PERCENTILE_APPROX_WEIGHTED(expr, w ,DOUBLE p [, DOUBLE compression])` +## Return Value +Return a `DOUBLE` type value, representing the calculated weighted approximate percentile. -The function is similar to PERCENTILE_APPROX, with the only difference being an additional parameter w, which represents the number of times expr appears. -Note that the value of parameter W needs to be greater than 0. If the value of a row is less than or equal to 0 during the calculation process, the current row will be skipped. +## Examples -### example +```sql +-- Create sample table +CREATE TABLE weighted_scores ( + student_id INT, + score DECIMAL(10, 2), + weight INT +) DUPLICATE KEY(student_id) +DISTRIBUTED BY HASH(student_id) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- Insert example data +INSERT INTO weighted_scores VALUES +(1, 85.5, 1), -- Normal homework score, weight 1 +(2, 90.0, 2), -- Important homework score, weight 2 +(3, 75.5, 1), +(4, 95.5, 3), -- Very important homework, weight 3 +(5, 88.0, 2), +(6, 92.5, 2), +(7, 78.0, 1), +(8, 89.5, 2), +(9, 94.0, 3), +(10, 83.5, 1); + +-- Calculate weighted scores distribution +SELECT + -- Calculate 90th percentile for different compression ratios + percentile_approx_weighted(score, weight, 0.9) as p90_default, -- Default compression ratio + percentile_approx_weighted(score, weight, 0.9, 2048) as p90_fast, -- Lower compression ratio, faster + percentile_approx_weighted(score, weight, 0.9, 10000) as p90_accurate -- Higher compression ratio, more accurate +FROM weighted_scores; ``` -mysql >select * from quantile_weighted_table order by k; -+------+------+ -| k | w | -+------+------+ -| 1 | 2 | -| 3 | 1 | -| 5 | 2 | -+------+------+ - - -mysql >select percentile_approx_weighted(k,w,0.55) from quantile_weighted_table; -+----------------------------------------------------------------------------------------+ -| percentile_approx_weighted(cast(k as DOUBLE), cast(w as DOUBLE), cast(0.55 as DOUBLE)) | -+----------------------------------------------------------------------------------------+ -| 3.3333332538604736 | -+----------------------------------------------------------------------------------------+ +```text ++------------------+------------------+------------------+ +| p90_default | p90_fast | p90_accurate | ++------------------+------------------+------------------+ +| 95.3499984741211 | 95.3499984741211 | 95.3499984741211 | ++------------------+------------------+------------------+ ``` -### keywords -PERCENTILE_APPROX,PERCENTILE,APPROX,PERCENTILE_APPROX_WEIGHTED + diff --git a/docs/sql-manual/sql-functions/aggregate-functions/quantile-union.md b/docs/sql-manual/sql-functions/aggregate-functions/quantile-union.md index 1eb0e3aee78b5..b70301d9518cf 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/quantile-union.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/quantile-union.md @@ -1,6 +1,6 @@ --- { - "title": "quantile_union", + "title": "QUANTILE_UNION", "language": "en" } --- @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -23,3 +21,73 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## Description + +The `QUANTILE_UNION` function is used to merge intermediate results from multiple quantile calculations. This function typically works in conjunction with `QUANTILE_STATE` and is particularly useful in scenarios requiring multi-stage quantile calculations. + +## Syntax + +```sql +QUANTILE_UNION() +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The intermediate state generated by the `TO_QUANTILE_STATE` function. | + +## Return Value + +Returns an aggregation state that can be used for further quantile calculations. The result of this function remains a `QUANTILE_STATE`. + +## Example + +```sql +-- Create sample table +CREATE TABLE response_times ( + request_id INT, + response_time DOUBLE, + region STRING +) DUPLICATE KEY(request_id) +DISTRIBUTED BY HASH(request_id) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- Insert sample data +INSERT INTO response_times VALUES +(1, 10.5, 'east'), +(2, 15.2, 'east'), +(3, 20.1, 'west'), +(4, 25.8, 'east'), +(5, 30.3, 'west'), +(6, 35.7, 'east'), +(7, 40.2, 'west'), +(8, 45.9, 'east'), +(9, 50.4, 'west'), +(10, 100.6, 'east'); + +-- Calculate 50th percentile of response times by region +SELECT + region, + QUANTILE_PERCENT( + QUANTILE_UNION( + TO_QUANTILE_STATE(response_time, 2048) + ), + 0.5 + ) AS median_response_time +FROM response_times +GROUP BY region; + +``` + +```text ++--------+----------------------+ +| region | median_response_time | ++--------+----------------------+ +| west | 35.25 | +| east | 30.75 | ++--------+----------------------+ +``` diff --git a/docs/sql-manual/sql-functions/aggregate-functions/regr-intercept.md b/docs/sql-manual/sql-functions/aggregate-functions/regr-intercept.md index a6f79566c2601..5f3a375df418f 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/regr-intercept.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/regr-intercept.md @@ -1,6 +1,6 @@ --- { - "title": "regr_intercept", + "title": "REGR_INTERCEPT", "language": "en" } --- @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -23,3 +21,62 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## Description + +Returns the intercept of the univariate linear regression line for non-null pairs in a group. It is computed for non-null pairs using the following formula: + +`AVG(y) - REGR_SLOPE(y, x) * AVG(x)` + +Where `x` is the independent variable and y is the dependent variable. + +## Syntax + +```sql +REGR_INTERCEPT(, ) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The dependent variable. This must be an expression that can be evaluated to a numeric type. | +| `` | The independent variable. This must be an expression that can be evaluated to a numeric type. | + +## Return Value + +Return a `DOUBLE` value, representing the intercept of the univariate linear regression line for non-null pairs in a group. + +## Examples + +```sql +-- Create sample table +CREATE TABLE test_regr_intercept ( + `id` int, + `x` int, + `y` int +) DUPLICATE KEY (`id`) +DISTRIBUTED BY HASH(`id`) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- Insert sample data +INSERT INTO test_regr_intercept VALUES +(1, 18, 13), +(2, 14, 27), +(3, 12, 2), +(4, 5, 6), +(5, 10, 20); + +-- Calculate the linear regression intercept of x and y +SELECT REGR_INTERCEPT(y, x) FROM test_regr_intercept; +``` + +```text ++-------------------------+ +| regr_intercept(y, x) | ++-------------------------+ +| 5.512931034482759 | ++-------------------------+ +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/aggregate-functions/regr-slope.md b/docs/sql-manual/sql-functions/aggregate-functions/regr-slope.md index 976774da85635..57b6f115938ea 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/regr-slope.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/regr-slope.md @@ -1,6 +1,6 @@ --- { - "title": "regr_slope", + "title": "REGR_SLOPE", "language": "en" } --- @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -23,3 +21,59 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## Description + +Returns the slope of the linear regression line for non-null pairs in a group. + + +## Syntax + +```sql +REGR_SLOPE(, ) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The dependent variable. This must be an expression that can be evaluated to a numeric type. | +| `` | The independent variable. This must be an expression that can be evaluated to a numeric type. | + +## Return Value + +Returns a `DOUBLE` value representing the slope of the linear regression line. + +## Examples + +```sql +-- Create example table +CREATE TABLE test_regr_slope ( + `id` int, + `x` int, + `y` int +) DUPLICATE KEY (`id`) +DISTRIBUTED BY HASH(`id`) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- Insert example data +INSERT INTO test_regr_slope VALUES +(1, 18, 13), +(2, 14, 27), +(3, 12, 2), +(4, 5, 6), +(5, 10, 20); + +-- Calculate the linear regression slope of x and y +SELECT REGR_SLOPE(y, x) FROM test_regr_slope; +``` + +```text ++----------------------+ +| regr_slope(y, x) | ++----------------------+ +| 0.6853448275862069 | ++----------------------+ +``` diff --git a/docs/sql-manual/sql-functions/aggregate-functions/retention.md b/docs/sql-manual/sql-functions/aggregate-functions/retention.md index 6f0ea487838aa..043a6ffc8c8b9 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/retention.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/retention.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,118 +22,72 @@ specific language governing permissions and limitations under the License. --> -## RETENTION - -RETENTION - -### Description -#### Syntax - -`retention(event1, event2, ... , eventN);` +## Description The `retention` function takes as arguments a set of conditions from 1 to 32 arguments of type `UInt8` that indicate whether a certain condition was met for the event. Any condition can be specified as an argument. The conditions, except the first, apply in pairs: the result of the second will be true if the first and second are true, of the third if the first and third are true, etc. -To put it simply, the first digit of the return value array indicates whether `event1` is true or false, the second digit represents the truth and falseness of `event1` and `event2`, and the third digit represents whether `event1` is true or false and `event3` is true False and, and so on. If `event1` is false, return an array full of zeros. +To put it simply, the first digit of the return value array indicates whether `event_1` is true or false, the second digit represents the truth and falseness of `event_1` and `event_2`, and the third digit represents whether `event_1` is true or false and `event_3` is true False and, and so on. If `event_1` is false, return an array full of zeros. -#### Arguments +## Syntax -`event` — An expression that returns a `UInt8` result (1 or 0). +```sql +RETENTION( [, , ... , ]); +``` -##### Returned value +## Parameters -An array of 1s and 0s with a maximum length of 32 bits, the final output array has the same length as the input parameter. +| Parameter | Description | +| -- | -- | +| `` | The `n`th event condition, of type `UInt8` and value 1 or 0. | -1 — Condition was met for the event. +## Returned value -0 — Condition wasn’t met for the event. +An array of 1 and 0 with a maximum length of 32, where the final output array length matches the input parameter length. -### example +- 1: Condition is met. +- 0: Condition is not met. -```sql -DROP TABLE IF EXISTS retention_test; +## Examples +```sql +-- Create sample table CREATE TABLE retention_test( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( - "replication_num" = "1" -); - -INSERT into retention_test (uid, date) values (0, '2022-10-12'), - (0, '2022-10-13'), - (0, '2022-10-14'), - (1, '2022-10-12'), - (1, '2022-10-13'), - (2, '2022-10-12'); - -SELECT * from retention_test; - -+------+---------------------+ -| uid | date | -+------+---------------------+ -| 0 | 2022-10-14 00:00:00 | -| 0 | 2022-10-13 00:00:00 | -| 0 | 2022-10-12 00:00:00 | -| 1 | 2022-10-13 00:00:00 | -| 1 | 2022-10-12 00:00:00 | -| 2 | 2022-10-12 00:00:00 | -+------+---------------------+ - + "replication_allocation" = "tag.location.default: 1" +); + +-- Insert sample data +INSERT into retention_test values +(0, '2022-10-12'), +(0, '2022-10-13'), +(0, '2022-10-14'), +(1, '2022-10-12'), +(1, '2022-10-13'), +(2, '2022-10-12'); + +-- Calculate user retention SELECT uid, - retention(date = '2022-10-12') - AS r - FROM retention_test - GROUP BY uid - ORDER BY uid ASC; - -+------+------+ -| uid | r | -+------+------+ -| 0 | [1] | -| 1 | [1] | -| 2 | [1] | -+------+------+ - -SELECT - uid, - retention(date = '2022-10-12', date = '2022-10-13') - AS r - FROM retention_test - GROUP BY uid - ORDER BY uid ASC; - -+------+--------+ -| uid | r | -+------+--------+ -| 0 | [1, 1] | -| 1 | [1, 1] | -| 2 | [1, 0] | -+------+--------+ - -SELECT - uid, - retention(date = '2022-10-12', date = '2022-10-13', date = '2022-10-14') - AS r - FROM retention_test - GROUP BY uid - ORDER BY uid ASC; - -+------+-----------+ -| uid | r | -+------+-----------+ -| 0 | [1, 1, 1] | -| 1 | [1, 1, 0] | -| 2 | [1, 0, 0] | -+------+-----------+ - + RETENTION(date = '2022-10-12') AS r, + RETENTION(date = '2022-10-12', date = '2022-10-13') AS r2, + RETENTION(date = '2022-10-12', date = '2022-10-13', date = '2022-10-14') AS r3 +FROM retention_test +GROUP BY uid +ORDER BY uid ASC; ``` -### keywords - -RETENTION +```text ++------+------+--------+-----------+ +| uid | r | r2 | r3 | ++------+------+--------+-----------+ +| 0 | [1] | [1, 1] | [1, 1, 1] | +| 1 | [1] | [1, 1] | [1, 1, 0] | +| 2 | [1] | [1, 0] | [1, 0, 0] | ++------+------+--------+-----------+ +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/aggregate-functions/sequence-count.md b/docs/sql-manual/sql-functions/aggregate-functions/sequence-count.md index 68abb404dcaad..d0a55625aeb96 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/sequence-count.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/sequence-count.md @@ -1,6 +1,6 @@ --- { - "title": "SEQUENCE-COUNT", + "title": "SEQUENCE_COUNT", "language": "en" } --- @@ -22,11 +22,7 @@ specific language governing permissions and limitations under the License. --> -## SEQUENCE-COUNT -### Description -#### Syntax - -`sequence_count(pattern, timestamp, cond1, cond2, ...);` +## Description Counts the number of event chains that matched the pattern. The function searches event chains that do not overlap. It starts to search for the next chain after the current chain is matched. @@ -34,188 +30,140 @@ Counts the number of event chains that matched the pattern. The function searche Events that occur at the same second may lay in the sequence in an undefined order affecting the result. -#### Arguments +## Syntax + +```sql +SEQUENCE_COUNT(, , [, , ..., ]); +``` + +## Parameters -`pattern` — Pattern string. +| Parameter | Description | +| -- | -- | +| `` | Pattern string, see **Pattern syntax** below. | +| `` | Column considered to contain time data. Typical data types are `Date` and `DateTime`. You can also use any of the supported UInt data types. | +| `` | Conditions that describe the chain of events. Data type: `UInt8`. You can pass up to 32 condition arguments. The function takes only the events described in these conditions into account. If the sequence contains data that isn’t described in a condition, the function skips them. | **Pattern syntax** -`(?N)` — Matches the condition argument at position N. Conditions are numbered in the `[1, 32]` range. For example, `(?1)` matches the argument passed to the `cond1` parameter. - -`.*` — Matches any number of events. You do not need conditional arguments to count this element of the pattern. +- `(?N)` — Matches the condition argument at position N. Conditions are numbered in the `[1, 32]` range. For example, `(?1)` matches the argument passed to the `cond_1` parameter. -`(?t operator value)` — Sets the time in seconds that should separate two events. +- `.*` — Matches any number of events. You do not need conditional arguments to count this element of the pattern. -We define `t` as the difference in seconds between two times, For example, pattern `(?1)(?t>1800)(?2)` matches events that occur more than 1800 seconds from each other. pattern `(?1)(?t>10000)(?2)` matches events that occur more than 10000 seconds from each other. An arbitrary number of any events can lay between these events. You can use the `>=`, `>`, `<`, `<=`, `==` operators. +- `(?t operator value)` — Sets the time in seconds that should separate two events. -`timestamp` — Column considered to contain time data. Typical data types are `Date` and `DateTime`. You can also use any of the supported UInt data types. +- We define `t` as the difference in seconds between two times, For example, pattern `(?1)(?t>1800)(?2)` matches events that occur more than 1800 seconds from each other. pattern `(?1)(?t>10000)(?2)` matches events that occur more than 10000 seconds from each other. An arbitrary number of any events can lay between these events. You can use the `>=`, `>`, `<`, `<=`, `==` operators. -`cond1`, `cond2` — Conditions that describe the chain of events. Data type: `UInt8`. You can pass up to 32 condition arguments. The function takes only the events described in these conditions into account. If the sequence contains data that isn’t described in a condition, the function skips them. -#### Returned value +## Return Value Number of non-overlapping event chains that are matched. -### example +## Examples -**count examples** +**Matching examples** ```sql -DROP TABLE IF EXISTS sequence_count_test2; - -CREATE TABLE sequence_count_test2( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 +-- Create sample table +CREATE TABLE sequence_count_test1( + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_count_test2(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 13:28:02', 2), - (3, '2022-11-02 16:15:01', 1), - (4, '2022-11-02 19:05:04', 2), - (5, '2022-11-02 20:08:44', 3); - -SELECT * FROM sequence_count_test2 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 13:28:02 | 2 | -| 3 | 2022-11-02 16:15:01 | 1 | -| 4 | 2022-11-02 19:05:04 | 2 | -| 5 | 2022-11-02 20:08:44 | 3 | -+------+---------------------+--------+ - -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 3) FROM sequence_count_test2; - -+----------------------------------------------------------------+ -| sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 3) | -+----------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 2) FROM sequence_count_test2; - -+----------------------------------------------------------------+ -| sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 2 | -+----------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?t>=10000)(?2)', date, number = 1, number = 2) FROM sequence_count_test1; +-- Insert sample data +INSERT INTO sequence_count_test1(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 13:28:02', 2), +(3, '2022-11-02 16:15:01', 1), +(4, '2022-11-02 19:05:04', 2), +(5, '2022-11-02 20:08:44', 3); + +-- Query example +SELECT + SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 3) as c1, + SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 2) as c2, + SEQUENCE_COUNT('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) as c3 +FROM sequence_count_test1; +``` -+---------------------------------------------------------------------------+ -| sequence_count('(?1)(?t>=3600)(?2)', `date`, `number` = 1, `number` = 2) | -+---------------------------------------------------------------------------+ -| 2 | -+---------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 1 | 2 | 2 | ++------+------+------+ ``` -**not count examples** +**Non-matching examples** ```sql -DROP TABLE IF EXISTS sequence_count_test1; - -CREATE TABLE sequence_count_test1( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 +-- Create sample table +CREATE TABLE sequence_count_test2( + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_count_test1(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_count_test1 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ - -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 2) FROM sequence_count_test1; - -+----------------------------------------------------------------+ -| sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 0 | -+----------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?2).*', date, number = 1, number = 2) FROM sequence_count_test1; - -+------------------------------------------------------------------+ -| sequence_count('(?1)(?2).*', `date`, `number` = 1, `number` = 2) | -+------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?t>3600)(?2)', date, number = 1, number = 7) FROM sequence_count_test1; +-- Insert sample data +INSERT INTO sequence_count_test2(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); + +-- Query example +SELECT + SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 2) as c1, + SEQUENCE_COUNT('(?1)(?2).*', date, number = 1, number = 2) as c2, + SEQUENCE_COUNT('(?1)(?t>3600)(?2)', date, number = 1, number = 7) as c3 +FROM sequence_count_test2; +``` -+--------------------------------------------------------------------------+ -| sequence_count('(?1)(?t>3600)(?2)', `date`, `number` = 1, `number` = 7) | -+--------------------------------------------------------------------------+ -| 0 | -+--------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 0 | 0 | 0 | ++------+------+------+ ``` -**special examples** +**Special examples** ```sql -DROP TABLE IF EXISTS sequence_count_test3; - +-- Create sample table CREATE TABLE sequence_count_test3( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_count_test3(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_count_test3 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ -``` - -Perform the query: +-- Insert sample data +INSERT INTO sequence_count_test3(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); -```sql -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5) FROM sequence_count_test3; +-- Query example +SELECT SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 5) FROM sequence_count_test3; +``` +```text +----------------------------------------------------------------+ | sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 5) | +----------------------------------------------------------------+ @@ -228,8 +176,10 @@ This is a very simple example. The function found the event chain where number 5 Now, perform this query: ```sql -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM sequence_count_test3; +SELECT SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM sequence_count_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 4) | +------------------------------------------------------------------------------+ @@ -240,15 +190,13 @@ SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM The result is kind of confusing. In this case, the function couldn’t find the event chain matching the pattern, because the event for number 4 occurred between 1 and 5. If in the same case we checked the condition for number 6, the sequence would count the pattern. ```sql -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5, number = 6) FROM sequence_count_test3; +SELECT SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 5, number = 6) FROM sequence_count_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 6) | +------------------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------------------+ ``` - -### keywords - -SEQUENCE_COUNT \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/aggregate-functions/sequence-match.md b/docs/sql-manual/sql-functions/aggregate-functions/sequence-match.md index c088fc2e746f2..a36a00a42f737 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/sequence-match.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/sequence-match.md @@ -22,11 +22,7 @@ specific language governing permissions and limitations under the License. --> -## SEQUENCE-MATCH -### Description -#### Syntax - -`sequence_match(pattern, timestamp, cond1, cond2, ...);` +## Description Checks whether the sequence contains an event chain that matches the pattern. @@ -34,190 +30,135 @@ Checks whether the sequence contains an event chain that matches the pattern. Events that occur at the same second may lay in the sequence in an undefined order affecting the result. -#### Arguments -`pattern` — Pattern string. +## Syntax -**Pattern syntax** +```sql +SEQUENCE_MATCH(, , [, , ..., ]) +``` -`(?N)` — Matches the condition argument at position N. Conditions are numbered in the `[1, 32]` range. For example, `(?1)` matches the argument passed to the `cond1` parameter. +## Parameters -`.*` — Matches any number of events. You do not need conditional arguments to match this element of the pattern. +| Parameter | Description | +| -- | -- | +| `` | Pattern string. See **Pattern syntax** below. | +| `` | Column considered to contain time data. Typical data types are `Date` and `DateTime`. You can also use any of the supported UInt data types. | +| `` | Conditions that describe the chain of events. Data type: `UInt8`. You can pass up to 32 condition arguments. The function takes only the events described in these conditions into account. If the sequence contains data that isn’t described in a condition, the function skips them. | -`(?t operator value)` — Sets the time in seconds that should separate two events. +**Pattern syntax** -We define `t` as the difference in seconds between two times, For example, pattern `(?1)(?t>1800)(?2)` matches events that occur more than 1800 seconds from each other. pattern `(?1)(?t>10000)(?2)` matches events that occur more than 10000 seconds from each other. An arbitrary number of any events can lay between these events. You can use the `>=`, `>`, `<`, `<=`, `==` operators. +- `(?N)` — Matches the condition argument at position N. Conditions are numbered in the `[1, 32]` range. For example, `(?1)` matches the argument passed to the `cond1` parameter. -`timestamp` — Column considered to contain time data. Typical data types are `Date` and `DateTime`. You can also use any of the supported UInt data types. +- `.*` — Matches any number of events. You do not need conditional arguments to match this element of the pattern. -`cond1`, `cond2` — Conditions that describe the chain of events. Data type: `UInt8`. You can pass up to 32 condition arguments. The function takes only the events described in these conditions into account. If the sequence contains data that isn’t described in a condition, the function skips them. +- `(?t operator value)` — Sets the time in seconds that should separate two events. -#### Returned value +- We define `t` as the difference in seconds between two times, For example, pattern `(?1)(?t>1800)(?2)` matches events that occur more than 1800 seconds from each other. pattern `(?1)(?t>10000)(?2)` matches events that occur more than 10000 seconds from each other. An arbitrary number of any events can lay between these events. You can use the `>=`, `>`, `<`, `<=`, `==` operators. -1, if the pattern is matched. +## Return value -0, if the pattern isn’t matched. +1: if the pattern is matched. -### example +0: if the pattern isn’t matched. -**match examples** +## Examples -```sql -DROP TABLE IF EXISTS sequence_match_test1; +**Match examples** +```sql CREATE TABLE sequence_match_test1( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_match_test1(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 13:28:02', 2), - (3, '2022-11-02 16:15:01', 1), - (4, '2022-11-02 19:05:04', 2), - (5, '2022-11-02 20:08:44', 3); - -SELECT * FROM sequence_match_test1 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 13:28:02 | 2 | -| 3 | 2022-11-02 16:15:01 | 1 | -| 4 | 2022-11-02 19:05:04 | 2 | -| 5 | 2022-11-02 20:08:44 | 3 | -+------+---------------------+--------+ +INSERT INTO sequence_match_test1(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 13:28:02', 2), +(3, '2022-11-02 16:15:01', 1), +(4, '2022-11-02 19:05:04', 2), +(5, '2022-11-02 20:08:44', 3); -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 3) FROM sequence_match_test1; -+----------------------------------------------------------------+ -| sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 3) | -+----------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 2) FROM sequence_match_test1; - -+----------------------------------------------------------------+ -| sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) FROM sequence_match_test1; +SELECT +sequence_match('(?1)(?2)', date, number = 1, number = 3) as c1, +sequence_match('(?1)(?2)', date, number = 1, number = 2) as c2, +sequence_match('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) as c3 +FROM sequence_match_test1; +``` -+---------------------------------------------------------------------------+ -| sequence_match('(?1)(?t>=3600)(?2)', `date`, `number` = 1, `number` = 2) | -+---------------------------------------------------------------------------+ -| 1 | -+---------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 1 | 1 | 1 | ++------+------+------+ ``` -**not match examples** +**Not match examples** ```sql -DROP TABLE IF EXISTS sequence_match_test2; - CREATE TABLE sequence_match_test2( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_match_test2(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_match_test2 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ - -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 2) FROM sequence_match_test2; - -+----------------------------------------------------------------+ -| sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 0 | -+----------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?2).*', date, number = 1, number = 2) FROM sequence_match_test2; - -+------------------------------------------------------------------+ -| sequence_match('(?1)(?2).*', `date`, `number` = 1, `number` = 2) | -+------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?t>3600)(?2)', date, number = 1, number = 7) FROM sequence_match_test2; +INSERT INTO sequence_match_test2(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); + +SELECT +sequence_match('(?1)(?2)', date, number = 1, number = 2) as c1, +sequence_match('(?1)(?2).*', date, number = 1, number = 2) as c2, +sequence_match('(?1)(?t>3600)(?2)', date, number = 1, number = 7) as c3 +FROM sequence_match_test2; +``` -+--------------------------------------------------------------------------+ -| sequence_match('(?1)(?t>3600)(?2)', `date`, `number` = 1, `number` = 7) | -+--------------------------------------------------------------------------+ -| 0 | -+--------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 0 | 0 | 0 | ++------+------+------+ ``` -**special examples** +**Special examples** ```sql -DROP TABLE IF EXISTS sequence_match_test3; - CREATE TABLE sequence_match_test3( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_match_test3(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_match_test3 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ -``` +INSERT INTO sequence_match_test3(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); -Perform the query: - -```sql -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5) FROM sequence_match_test3; +SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5) +FROM sequence_match_test3; +``` +```text +----------------------------------------------------------------+ | sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 5) | +----------------------------------------------------------------+ @@ -230,8 +171,11 @@ This is a very simple example. The function found the event chain where number 5 Now, perform this query: ```sql -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM sequence_match_test3; +SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 4) +FROM sequence_match_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 4) | +------------------------------------------------------------------------------+ @@ -242,15 +186,14 @@ SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM The result is kind of confusing. In this case, the function couldn’t find the event chain matching the pattern, because the event for number 4 occurred between 1 and 5. If in the same case we checked the condition for number 6, the sequence would match the pattern. ```sql -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 6) FROM sequence_match_test3; +SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 6) +FROM sequence_match_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 6) | +------------------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------------------+ ``` - -### keywords - -SEQUENCE_MATCH \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/aggregate-functions/skew.md b/docs/sql-manual/sql-functions/aggregate-functions/skew.md index 7185ca7f00287..6b05a54dbbeb1 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/skew.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/skew.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,50 +22,79 @@ specific language governing permissions and limitations under the License. --> -## skewness,skew,skew_pop -### Description +## Description Returns the [skewness](https://en.wikipedia.org/wiki/Skewness) of the expr expression. -The forumula used for this function is `3-th centrol moment / ((variance)^{1.5})`, when variance is zero, `skewness` will return `NULL`. +The forumula used for this function is `3-th centrol moment / ((variance)^{1.5})`, when variance is zero, `SKEWNESS` will return `NULL`. -### Syntax +**Related Commands** -`skewness(expr)` +[kurt](./kurt.md) -### Arguments +## Alias -TinyInt/SmallInt/Integer/BigInt/Float/Double, Decimal will be casted to a float number. +- SKEW +- SKEW_POP -### Return value +## Syntax -`Double` - -### Example ```sql -create table statistic_test (tag int, val1 double not null, val2 double null) - distributed by hash(tag) properties("replication_num"="1") +SKEWNESS() +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The column to be calculated skewness | + +## Return Value -insert into statistic_test values (1, -10, -10), - (2, -20, NULL), - (3, 100, NULL), - (4, 100, NULL), - (5, 1000,1000); +Returns the skewness of the expr expression, which is a `Double` type. -// NULL is ignored -select skew(val1), skew(val2) from statistic_test --------------- +## Examples +```sql +CREATE TABLE statistic_test( + tag int, + val1 double not null, + val2 double null +) DISTRIBUTED BY HASH(tag) +PROPERTIES ( + "replication_num"="1" +); + +INSERT INTO statistic_test VALUES +(1, -10, -10), +(2, -20, NULL), +(3, 100, NULL), +(4, 100, NULL), +(5, 1000,1000); + +-- NULL is ignored +SELECT + skew(val1), + skew(val2) +FROM statistic_test; +``` +```text +--------------------+--------------------+ | skew(val1) | skew(val2) | +--------------------+--------------------+ | 1.4337199628825619 | 1.1543940205711711 | +--------------------+--------------------+ -1 row in set (0.01 sec) +``` -// Each group just has one row, result is NULL -select skew(val1), skew(val2) from statistic_test group by tag --------------- +```sql +-- Each group just has one row, result is NULL +SELECT + skew(val1), + skew(val2) +FROM statistic_test +GROUP BY tag; +``` +```text +------------+------------+ | skew(val1) | skew(val2) | +------------+------------+ @@ -77,8 +104,4 @@ select skew(val1), skew(val2) from statistic_test group by tag | NULL | NULL | | NULL | NULL | +------------+------------+ -5 rows in set (0.04 sec) -``` -### Related Commands - -[kurt](./kurt.md) \ No newline at end of file +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/aggregate-functions/stddev-samp.md b/docs/sql-manual/sql-functions/aggregate-functions/stddev-samp.md index 086c7b4d84113..45be4c6c9c7d5 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/stddev-samp.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/stddev-samp.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,23 +22,54 @@ specific language governing permissions and limitations under the License. --> -## STDDEV_SAMP -### Description -#### Syntax +## Description + +Returns the sample standard deviation of the expr expression -`STDDEV SAMP (expr)` +## Syntax +```sql +STDDEV_SAMP() +``` -Returns the sample standard deviation of the expr expression +## Parameters -### example +| Parameter | Description | +| -- | -- | +| `` | The value to be calculated standard deviation | + +## Return Value + +Return the sample standard deviation of the expr expression + +### Examples +```sql +-- Create sample tables +CREATE TABLE score_table ( + student_id INT, + score DOUBLE +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO score_table VALUES +(1, 85), +(2, 90), +(3, 82), +(4, 88), +(5, 95); + +-- Calculate the sample standard deviation of all students' scores +SELECT STDDEV_SAMP(score) as score_stddev +FROM score_table; ``` -MySQL > select stddev_samp(scan_rows) from log_statis group by datetime; -+--------------------------+ -| stddev_samp(`scan_rows`) | -+--------------------------+ -| 2.372044195280762 | -+--------------------------+ + +```text ++-------------------+ +| score_stddev | ++-------------------+ +| 4.949747468305831 | ++-------------------+ ``` -### keywords -STDDEV SAMP,STDDEV,SAMP diff --git a/docs/sql-manual/sql-functions/aggregate-functions/stddev.md b/docs/sql-manual/sql-functions/aggregate-functions/stddev.md index d22a6d771792a..f31d41efacf49 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/stddev.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/stddev.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,30 +22,58 @@ specific language governing permissions and limitations under the License. --> -## STDDEV,STDDEV_POP -### Description -#### Syntax +## Description -`stddev (expl)` +Returns the standard deviation of the expr expression +## Alias -Returns the standard deviation of the expr expression +- STDDEV_POP + +## Syntax + +```sql +STDDEV() +``` -### example +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The value to be calculated standard deviation | + +## Return Value + +Return the standard deviation of the expr expression + +## Examples +```sql +-- Create sample tables +CREATE TABLE score_table ( + student_id INT, + score DOUBLE +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO score_table VALUES +(1, 85), +(2, 90), +(3, 82), +(4, 88), +(5, 95); + +-- Calculate the standard deviation of all students' scores +SELECT STDDEV(score) as score_stddev +FROM score_table; ``` -MySQL > select stddev(scan_rows) from log_statis group by datetime; -+---------------------+ -| stddev(`scan_rows`) | -+---------------------+ -| 2.3736656687790934 | -+---------------------+ - -MySQL > select stddev_pop(scan_rows) from log_statis group by datetime; -+-------------------------+ -| stddev_pop(`scan_rows`) | -+-------------------------+ -| 2.3722760595994914 | -+-------------------------+ + +```text ++-------------------+ +| score_stddev | ++-------------------+ +| 4.427188724235729 | ++-------------------+ ``` -### keywords -STDDEV,STDDEV_POP,POP diff --git a/docs/sql-manual/sql-functions/aggregate-functions/sum.md b/docs/sql-manual/sql-functions/aggregate-functions/sum.md index 10802b4707ae3..669c0dbdd724b 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/sum.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/sum.md @@ -24,23 +24,55 @@ specific language governing permissions and limitations under the License. --> -## SUM -### Description -#### Syntax +## Description -`Sum (Expr)` +Used to return the sum of all values of the selected field +## Syntax -Used to return the sum of all values of the selected field +```sql +SUM() +``` + +## Parameters + +| Parameter | Description | +| --- | --- | +| `` | The field to calculate the sum of | -### example +## Return Value + +Return the sum of all values of the selected field. + +## Examples +```sql +-- Create sample tables +CREATE TABLE sales_table ( + product_id INT, + price DECIMAL(10,2), + quantity INT +) DISTRIBUTED BY HASH(product_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO sales_table VALUES +(1, 99.99, 2), +(2, 159.99, 1), +(3, 49.99, 5), +(4, 299.99, 1), +(5, 79.99, 3); + +-- Calculate the total sales amount +SELECT SUM(price * quantity) as total_sales +FROM sales_table; ``` -MySQL > select sum(scan_rows) from log_statis group by datetime; -+------------------+ -| sum(`scan_rows`) | -+------------------+ -| 8217360135 | -+------------------+ + +```text ++-------------+ +| total_sales | ++-------------+ +| 1149.88 | ++-------------+ ``` -### keywords -SUM diff --git a/docs/sql-manual/sql-functions/aggregate-functions/sum0.md b/docs/sql-manual/sql-functions/aggregate-functions/sum0.md index 745b70b3043c6..adf052f8b98d6 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/sum0.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/sum0.md @@ -1,7 +1,6 @@ --- { - "title": "sum0 - ", + "title": "SUM0", "language": "en" } --- @@ -24,3 +23,60 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## Description + +Used to return the sum of all values of the selected field. Unlike the SUM function, when all input values are NULL, SUM0 returns 0 instead of NULL. + +## Syntax + +```sql +SUM0() +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The field to calculate the sum of | + +## Return Value + +Returns the sum of all values of the selected field. If all values are NULL, returns 0. + +## Examples + +```sql +-- Create example table +CREATE TABLE sales_table ( + product_id INT, + price DECIMAL(10,2), + quantity INT, + discount DECIMAL(10,2) +) DISTRIBUTED BY HASH(product_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO sales_table VALUES +(1, 99.99, 2, NULL), +(2, 159.99, 1, NULL), +(3, 49.99, 5, NULL), +(4, 299.99, 1, NULL), +(5, 79.99, 3, NULL); + +-- Compare SUM and SUM0 +SELECT + SUM(discount) as sum_discount, -- Returns NULL + SUM0(discount) as sum0_discount -- Returns 0 +FROM sales_table; +``` + +```text ++--------------+---------------+ +| sum_discount | sum0_discount | ++--------------+---------------+ +| NULL | 0.00 | ++--------------+---------------+ +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/aggregate-functions/topn-array.md b/docs/sql-manual/sql-functions/aggregate-functions/topn-array.md index 0cb0b177a8b31..f3710a434434e 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/topn-array.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/topn-array.md @@ -24,38 +24,60 @@ specific language governing permissions and limitations under the License. --> -## TOPN_ARRAY -### description -#### Syntax +## Description -`ARRAY topn_array(expr, INT top_num[, INT space_expand_rate])` +TOPN_ARRAY returns an array of the N most frequent values in the specified column. It is an approximate calculation function that returns results ordered by count in descending order. -The topn function uses the Space-Saving algorithm to calculate the top_num frequent items in expr, -and return an array about the top n nums, which is an approximation +## Syntax -The space_expand_rate parameter is optional and is used to set the number of counters used in the Space-Saving algorithm +```sql +TOPN_ARRAY(, [, ]) ``` -counter numbers = top_num * space_expand_rate -``` -The higher value of space_expand_rate, the more accurate result will be. The default value is 50 -### example +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The column or expression to be counted. | +| `` | The number of the most frequent values to return. It must be a positive integer. | +| `` | Optional parameter, which is used to set the number of counters used in the Space-Saving algorithm. `counter_numbers = top_num * space_expand_rate` , the larger the value of space_expand_rate, the more accurate the result, and the default value is 50. | + +## Return Value + +Return an array containing the N most frequent values. + +## Examples +```sql +-- Create sample table +CREATE TABLE page_visits ( + page_id INT, + user_id INT, + visit_date DATE +) DISTRIBUTED BY HASH(page_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO page_visits VALUES +(1, 101, '2024-01-01'), +(2, 102, '2024-01-01'), +(1, 103, '2024-01-01'), +(3, 101, '2024-01-01'), +(1, 104, '2024-01-01'), +(2, 105, '2024-01-01'), +(1, 106, '2024-01-01'), +(4, 107, '2024-01-01'); + +-- Find top 3 most visited pages +SELECT TOPN_ARRAY(page_id, 3) as top_pages +FROM page_visits; ``` -mysql> select topn_array(k3,3) from baseall; -+--------------------------+ -| topn_array(`k3`, 3) | -+--------------------------+ -| [3021, 2147483647, 5014] | -+--------------------------+ -1 row in set (0.02 sec) - -mysql> select topn_array(k3,3,100) from baseall; -+--------------------------+ -| topn_array(`k3`, 3, 100) | -+--------------------------+ -| [3021, 2147483647, 5014] | -+--------------------------+ -1 row in set (0.02 sec) + +```text ++-----------+ +| top_pages | ++-----------+ +| [1, 2, 4] | ++-----------+ ``` -### keywords -TOPN, TOPN_ARRAY \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/aggregate-functions/topn-weighted.md b/docs/sql-manual/sql-functions/aggregate-functions/topn-weighted.md index 805ba0ac134ca..627abf9ce9ad0 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/topn-weighted.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/topn-weighted.md @@ -24,37 +24,61 @@ specific language governing permissions and limitations under the License. --> -## TOPN_WEIGHTED -### description -#### Syntax +## Description -`ARRAY topn_weighted(expr, BigInt weight, INT top_num[, INT space_expand_rate])` +The TOPN_WEIGHTED function returns the N most frequent values in the specified column with weighted counting. Unlike the regular TOPN function, TOPN_WEIGHTED allows adjusting the importance of values through weights. -The topn_weighted function is calculated using the Space-Saving algorithm, and the sum of the weights in expr is the result of the top n numbers, which is an approximate value +## Syntax -The space_expand_rate parameter is optional and is used to set the number of counters used in the Space-Saving algorithm +```sql +TOPN_WEIGHTED(, , [, ]) ``` -counter numbers = top_num * space_expand_rate -``` -The higher value of space_expand_rate, the more accurate result will be. The default value is 50 -### example +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The column or expression to be counted | +| `` | The column or expression to adjust the weight | +| `` | The number of the most frequent values to return. It must be a positive integer. | +| `` | Optional, the value to set the counter_numbers used in the Space-Saving algorithm. `counter_numbers = top_num * space_expand_rate`. The value of space_expand_rate should be greater than 1, and the default value is 50. | + +## Return Value + +Return an array containing values and weighted counts. + +## Examples +```sql +-- create example table +CREATE TABLE product_sales ( + product_id INT, + sale_amount DECIMAL(10,2), + sale_date DATE +) DISTRIBUTED BY HASH(product_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- insert test data +INSERT INTO product_sales VALUES +(1, 100.00, '2024-01-01'), +(2, 50.00, '2024-01-01'), +(1, 150.00, '2024-01-01'), +(3, 75.00, '2024-01-01'), +(1, 200.00, '2024-01-01'), +(2, 80.00, '2024-01-01'), +(1, 120.00, '2024-01-01'), +(4, 90.00, '2024-01-01'); + +-- find the top 3 products with highest sales amount +SELECT TOPN_WEIGHTED(product_id, sale_amount, 3) as top_products +FROM product_sales; ``` -mysql> select topn_weighted(k5,k1,3) from baseall; -+------------------------------+ -| topn_weighted(`k5`, `k1`, 3) | -+------------------------------+ -| [0, 243.325, 100.001] | -+------------------------------+ -1 row in set (0.02 sec) - -mysql> select topn_weighted(k5,k1,3,100) from baseall; -+-----------------------------------+ -| topn_weighted(`k5`, `k1`, 3, 100) | -+-----------------------------------+ -| [0, 243.325, 100.001] | -+-----------------------------------+ -1 row in set (0.02 sec) + +```text ++--------------+ +| top_products | ++--------------+ +| [1, 2, 4] | ++--------------+ ``` -### keywords -TOPN, TOPN_WEIGHTED \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/aggregate-functions/topn.md b/docs/sql-manual/sql-functions/aggregate-functions/topn.md index 8ca8840b44533..eb25148fe58d2 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/topn.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/topn.md @@ -24,38 +24,59 @@ specific language governing permissions and limitations under the License. --> -## TOPN -### description -#### Syntax +## Description -`topn(expr, INT top_num[, INT space_expand_rate])` +The TOPN function returns the N most frequent values in the specified column. It is an approximate calculation function that returns results ordered by count in descending order. -The topn function uses the Space-Saving algorithm to calculate the top_num frequent items in expr, and the result is the -frequent items and their occurrence times, which is an approximation +## Syntax -The space_expand_rate parameter is optional and is used to set the number of counters used in the Space-Saving algorithm +```sql +TOPN(, [, ]) ``` -counter numbers = top_num * space_expand_rate -``` -The higher value of space_expand_rate, the more accurate result will be. The default value is 50 -### example -``` -MySQL [test]> select topn(keyword,10) from keyword_table where date>= '2020-06-01' and date <= '2020-06-19' ; -+------------------------------------------------------------------------------------------------------------+ -| topn(`keyword`, 10) | -+------------------------------------------------------------------------------------------------------------+ -| a:157, b:138, c:133, d:133, e:131, f:127, g:124, h:122, i:117, k:117 | -+------------------------------------------------------------------------------------------------------------+ - -MySQL [test]> select date,topn(keyword,10,100) from keyword_table where date>= '2020-06-17' and date <= '2020-06-19' group by date; -+------------+-----------------------------------------------------------------------------------------------+ -| date | topn(`keyword`, 10, 100) | -+------------+-----------------------------------------------------------------------------------------------+ -| 2020-06-19 | a:11, b:8, c:8, d:7, e:7, f:7, g:7, h:7, i:7, j:7 | -| 2020-06-18 | a:10, b:8, c:7, f:7, g:7, i:7, k:7, l:7, m:6, d:6 | -| 2020-06-17 | a:9, b:8, c:8, j:8, d:7, e:7, f:7, h:7, i:7, k:7 | -+------------+-----------------------------------------------------------------------------------------------+ +## Parameters +| Parameter | Description | +| -- | -- | +| `` | The column or expression to be counted. | +| `` | The number of the most frequent values to return. It must be a positive integer. | +| `` | Optional parameter, which is used to set the number of counters used in the Space-Saving algorithm. `counter_numbers = top_num * space_expand_rate` , the larger the value of space_expand_rate, the more accurate the result, and the default value is 50. | + +## Return Value + +Returns a JSON string containing values and their corresponding occurrence counts. + +## Examples +```sql +-- Create sample table +CREATE TABLE page_visits ( + page_id INT, + user_id INT, + visit_date DATE +) DISTRIBUTED BY HASH(page_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO page_visits VALUES +(1, 101, '2024-01-01'), +(2, 102, '2024-01-01'), +(1, 103, '2024-01-01'), +(3, 101, '2024-01-01'), +(1, 104, '2024-01-01'), +(2, 105, '2024-01-01'), +(1, 106, '2024-01-01'), +(4, 107, '2024-01-01'); + +-- Find top 3 most visited pages +SELECT TOPN(page_id, 3) as top_pages +FROM page_visits; ``` -### keywords -TOPN \ No newline at end of file + +```text ++---------------------+ +| top_pages | ++---------------------+ +| {"1":4,"2":2,"4":1} | ++---------------------+ +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/aggregate-functions/var-samp.md b/docs/sql-manual/sql-functions/aggregate-functions/var-samp.md index 8fe7ad5a39f7e..40b7abfae8dd0 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/var-samp.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/var-samp.md @@ -1,6 +1,6 @@ --- { - "title": "VARIANCE_SAMP,VARIANCE_SAMP", + "title": "VAR_SAMP,VARIANCE_SAMP", "language": "en" } --- @@ -24,23 +24,62 @@ specific language governing permissions and limitations under the License. --> -## VARIANCE_SAMP,VARIANCE_SAMP -### Description -#### Syntax +## Description -`VAR SAMP (expr)` +The VAR_SAMP function calculates the sample variance of a specified expression. Unlike VARIANCE (population variance), VAR_SAMP uses n-1 as the divisor, which is considered an unbiased estimate of the population variance in statistics. +## Alias -Returns the sample variance of the expr expression +- VARIANCE_SAMP -### example +## Syntax + +```sql +VAR_SAMP() ``` -MySQL > select var_samp(scan_rows) from log_statis group by datetime; -+-----------------------+ -| var_samp(`scan_rows`) | -+-----------------------+ -| 5.6227132145741789 | -+-----------------------+ + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The column or expression to calculate sample variance for. Must be numeric type | + +## Return Value +Returns a DOUBLE value representing the calculated sample variance. + +## Examples +```sql +-- Create sample table +CREATE TABLE student_scores ( + student_id INT, + score DECIMAL(4,1) +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO student_scores VALUES +(1, 85.5), +(2, 92.0), +(3, 78.5), +(4, 88.0), +(5, 95.5), +(6, 82.0), +(7, 90.0), +(8, 87.5); + +-- Calculate sample variance of student scores +SELECT + VAR_SAMP(score) as sample_variance, + VARIANCE(score) as population_variance +FROM student_scores; +``` + +```text ++------------------+---------------------+ +| sample_variance | population_variance | ++------------------+---------------------+ +| 29.4107142857143 | 25.73437500000001 | ++------------------+---------------------+ ``` -### keywords -VAR SAMP, VARIANCE SAMP,VAR,SAMP,VARIANCE diff --git a/docs/sql-manual/sql-functions/aggregate-functions/variance.md b/docs/sql-manual/sql-functions/aggregate-functions/variance.md index f58da61bf708f..5e43d59eddfd8 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/variance.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/variance.md @@ -24,30 +24,59 @@ specific language governing permissions and limitations under the License. --> -## VARIANCE,VAR_POP,VARIANCE_POP -### Description -#### Syntax +## Description -`VARIANCE(expr)` +The VARIANCE function calculates the statistical variance of the specified expression. It measures how far a set of numbers are spread out from their arithmetic mean. +## Alias -Returns the variance of the expr expression +- VAR_POP +- VARIANCE_POP -### example +## Syntax + +```sql +VARIANCE() ``` -MySQL > select variance(scan_rows) from log_statis group by datetime; -+-----------------------+ -| variance(`scan_rows`) | -+-----------------------+ -| 5.6183332881176211 | -+-----------------------+ - -MySQL > select var_pop(scan_rows) from log_statis group by datetime; -+----------------------+ -| var_pop(`scan_rows`) | -+----------------------+ -| 5.6230744719006163 | -+----------------------+ + +## Parameters +| Parameter | Description | +| -- | -- | +| `` | The column or expression to calculate variance for. Must be numeric type | + +## Return Value +Returns a DOUBLE value representing the calculated variance. + +## Examples +```sql +-- Create sample table +CREATE TABLE student_scores ( + student_id INT, + score DECIMAL(4,1) +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO student_scores VALUES +(1, 85.5), +(2, 92.0), +(3, 78.5), +(4, 88.0), +(5, 95.5), +(6, 82.0), +(7, 90.0), +(8, 87.5); +-- Calculate variance of student scores +SELECT VARIANCE(score) as score_variance +FROM student_scores; +``` + +```text ++-------------------+ +| score_variance | ++-------------------+ +| 25.73437499999998 | ++-------------------+ ``` -### keywords -VARIANCE,VAR_POP,VARIANCE_POP,VAR,POP diff --git a/docs/sql-manual/sql-functions/aggregate-functions/window-funnel.md b/docs/sql-manual/sql-functions/aggregate-functions/window-funnel.md index 47d440b958049..4e4e361e72f37 100644 --- a/docs/sql-manual/sql-functions/aggregate-functions/window-funnel.md +++ b/docs/sql-manual/sql-functions/aggregate-functions/window-funnel.md @@ -11,19 +11,9 @@ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> -## WINDOW FUNCTION WINDOW_FUNNEL -### description +## Description -Searches for event chains in a sliding time window and calculates the maximum number of events that occurred from the chain. - -- window is the length of time window in seconds. -- mode can be one of the followings: - - "default": Defualt mode. - - "deduplication": If the same event holds for the sequence of events, then such repeating event interrupts further processing. E.g. the array parameter is [event1='A', event2='B', event3='C', event4='D'], and the original event chain is "A-B-C-B-D". Since event B repeats, the filtered event chain can only be "A-B-C" and the max event level is 3. - - "fixed": Don't allow interventions of other events. E.g. the array parameter is [event1='A', event2='B', event3='C', event4='D'], and the original event chain is A->B->D->C, it stops finding A->B->C at the D and the max event level is 2. - - "increase": Apply conditions only to events with strictly increasing timestamps. -- timestamp_column specifies column of DATETIME type, sliding time window works on it. -- evnetN is boolean expression like eventID = 1004. +The WINDOW_FUNNEL function analyzes user behavior sequences by searching for event chains within a specified time window and calculating the maximum number of completed steps in the event chain. This function is particularly useful for conversion funnel analysis, such as analyzing user conversion from website visits to final purchases. The function works according to the algorithm: @@ -31,15 +21,35 @@ The function works according to the algorithm: - If events from the chain occur sequentially within the window, the counter is incremented. If the sequence of events is disrupted, the counter is not incremented. - If the data has multiple event chains at varying points of completion, the function will only output the size of the longest chain. +## Syntax + ```sql -window_funnel(window, mode, timestamp_column, event1, event2, ... , eventN) +WINDOW_FUNNEL(, , , [, event_2, ... , event_n]) ``` -### example +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | window is the length of time window in seconds | +| `` | There are four modes in total, `default`, `deduplication`, `fixed`, and `increase`. For details, please refer to the **Mode** below. | +| `` | timestamp specifies column of DATETIME type, sliding time window works on it | +| `` | evnet_n is boolean expression like eventID = 1004 | + +**Mode** + - `default`: Defualt mode. + - `deduplication`: If the same event holds for the sequence of events, then such repeating event interrupts further processing. E.g. the array parameter is [event1='A', event2='B', event3='C', event4='D'], and the original event chain is "A-B-C-B-D". Since event B repeats, the filtered event chain can only be "A-B-C" and the max event level is 3. + - `fixed`: Don't allow interventions of other events. E.g. the array parameter is [event1='A', event2='B', event3='C', event4='D'], and the original event chain is A->B->D->C, it stops finding A->B->C at the D and the max event level is 2. + - `increase`: Apply conditions only to events with strictly increasing timestamps. -#### example1: default mode +## Return Value +Returns an integer representing the maximum number of consecutive steps completed within the specified time window. -Using the ```default``` mode, find out the maximum number of consecutive events corresponding to different ```user_id```, with a time window of ```5``` minutes: +## Examples + +### example1: default mode + +Using the `default` mode, find out the maximum number of consecutive events corresponding to different `user_id`, with a time window of `5` minutes: ```sql CREATE TABLE events( @@ -82,7 +92,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -93,11 +105,11 @@ order BY +---------+-------+ ``` -For ```uesr_id=100123```, because the time when the ```payment``` event occurred exceeds the time window, the matched event chain is ```login-visit-order```. +For `uesr_id=100123`, because the time when the `payment` event occurred exceeds the time window, the matched event chain is `login-visit-order`. -#### example2: deduplication mode +### example2: deduplication mode -Use the ```deduplication``` mode to find out the maximum number of consecutive events corresponding to different user_ids, with a time window of 1 hour: +Use the `deduplication` mode to find out the maximum number of consecutive events corresponding to different user_ids, with a time window of 1 hour: ```sql CREATE TABLE events( @@ -141,7 +153,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -151,11 +165,11 @@ order BY | 100127 | 2 | +---------+-------+ ``` -For ```uesr_id=100123```, after matching the ```visit``` event, the ```login``` event appears repeatedly, so the matched event chain is ```login-visit```. +For `uesr_id=100123`, after matching the `visit` event, the `login` event appears repeatedly, so the matched event chain is `login-visit`. -#### example3: fixed mode +### example3: fixed mode -Use the ```fixed``` mode to find out the maximum number of consecutive events corresponding to different ```user_id```, with a time window of ```1``` hour: +Use the `fixed` mode to find out the maximum number of consecutive events corresponding to different `user_id`, with a time window of `1` hour: ```sql CREATE TABLE events( @@ -199,7 +213,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -209,11 +225,11 @@ order BY | 100127 | 2 | +---------+-------+ ``` -For ```uesr_id=100123```, after matching the ```order``` event, the event chain is interrupted by the ```login2``` event, so the matched event chain is ```login-visit-order```. +For `uesr_id=100123`, after matching the `order` event, the event chain is interrupted by the `login2` event, so the matched event chain is `login-visit-order`. -#### example4: increase mode +### example4: increase mode -Use the ```increase``` mode to find out the maximum number of consecutive events corresponding to different ```user_id```, with a time window of ```1``` hour: +Use the `increase` mode to find out the maximum number of consecutive events corresponding to different `user_id`, with a time window of `1` hour: ```sql CREATE TABLE events( @@ -256,7 +272,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -266,9 +284,4 @@ order BY | 100127 | 2 | +---------+-------+ ``` -For ```uesr_id=100123```, the timestamp of the ```payment``` event and the timestamp of the ```order``` event occur in the same second and are not incremented, so the matched event chain is ```login-visit-order```. - - -### keywords - - WINDOW,FUNCTION,WINDOW_FUNNEL +For `uesr_id=100123`, the timestamp of the `payment` event and the timestamp of the `order` event occur in the same second and are not incremented, so the matched event chain is `login-visit-order`. diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md index ddd3ee704c4b1..9863806bac137 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md @@ -24,27 +24,37 @@ specific language governing permissions and limitations under the License. --> -## hours_add -### description -#### Syntax +## Description -`DATETIME HOURS_ADD(DATETIME date, INT hours)` +Returns a new datetime value that is the result of adding a specified number of hours to the input datetime. -Add specified hours from date time or date +## Syntax -The parameter date can be DATETIME or DATE, and the return type is DATETIME. +```sql +HOURS_ADD(, ) +``` -### example +## Parameters -``` -mysql> select hours_add("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| hours_add('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-02-02 03:02:02 | -+-------------------------------------+ -``` +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATETIME or DATE | +| `` | The number of hours to add, of type INT | + +## Return Value -### keywords +Returns a value of type DATETIME, representing the time value after adding the specified number of hours to the input datetime. - HOURS_ADD +## Example + +```sql +SELECT HOURS_ADD('2020-02-02 02:02:02', 1); +``` + +```text ++------------------------------------------------------------+ +| hours_add(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), 1) | ++------------------------------------------------------------+ +| 2020-02-02 03:02:02 | ++------------------------------------------------------------+ +``` diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md index f299f8d15c6d8..78e690f7bf8ea 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md @@ -24,25 +24,37 @@ specific language governing permissions and limitations under the License. --> -## hours_diff -### description -#### Syntax +## Description -`INT hours_diff(DATETIME enddate, DATETIME startdate)` +Calculates the difference in hours between the start time and the end time. -The difference between the start time and the end time is a few hours +## Syntax -### example - -``` -mysql> select hours_diff('2020-12-25 22:00:00','2020-12-25 21:00:00'); -+----------------------------------------------------------+ -| hours_diff('2020-12-25 22:00:00', '2020-12-25 21:00:00') | -+----------------------------------------------------------+ -| 1 | -+----------------------------------------------------------+ +```sql +HOURS_DIFF(, ) ``` -### keywords +## Parameters + +| Parameter | Description | +|------------|-------------------------------------------------| +| `` | The end time, which can be of type DATETIME or DATE | +| `` | The start time, which can be of type DATETIME or DATE | + +## Return Value + +Returns an INT type representing the number of hours between the start time and the end time. + +## Example + +```sql +SELECT HOURS_DIFF('2020-12-25 22:00:00', '2020-12-25 21:00:00'); +``` - hours_diff +```text ++--------------------------------------------------------------------------------------------------------+ +| hours_diff(cast('2020-12-25 22:00:00' as DATETIMEV2(0)), cast('2020-12-25 21:00:00' as DATETIMEV2(0))) | ++--------------------------------------------------------------------------------------------------------+ +| 1 | ++--------------------------------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md index 7bb2ba1f75d0b..234d0c5ef41cd 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md @@ -24,27 +24,37 @@ specific language governing permissions and limitations under the License. --> -## hours_sub -### description -#### Syntax +## Description -`DATETIME HOURS_SUB(DATETIME date, INT hours)` +Returns a new datetime value that is the result of subtracting a specified number of hours from the input datetime. -Subtracts a specified number of hours from a datetime or date +## Syntax -The parameter date can be DATETIME or DATE, and the return type is DATETIME. +```sql +HOURS_SUB(, ) +``` -### example +## Parameters -``` -mysql> select hours_sub("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| hours_sub('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-02-02 01:02:02 | -+-------------------------------------+ -``` +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATETIME or DATE | +| `` | The number of hours to subtract, of type INT | + +## Return Value -### keywords +Returns a value of type DATETIME, representing the time value after subtracting the specified number of hours from the input datetime. - HOURS_SUB +## Example + +```sql +SELECT HOURS_SUB('2020-02-02 02:02:02', 1); +``` + +```text ++------------------------------------------------------------+ +| hours_sub(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), 1) | ++------------------------------------------------------------+ +| 2020-02-02 01:02:02 | ++------------------------------------------------------------+ +``` diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md index 0eb3956f4bb84..6e2dc10cf0e09 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md @@ -22,28 +22,40 @@ specific language governing permissions and limitations under the License. --> -## last_day -### Description -#### Syntax +## Description -`DATE last_day(DATETIME date)` +Returns the date of the last day of the month for the given input date. The returned day varies depending on the month: +- 28th - For February in non-leap years +- 29th - For February in leap years +- 30th - For April, June, September, and November +- 31st - For January, March, May, July, August, October, and December -Return the last day of the month, the return day may be : -'28'(February and not a leap year), -'29'(February and a leap year), -'30'(April, June, September, November), -'31'(January, March, May, July, August, October, December) - -### example +## Syntax +```sql +LAST_DAY() ``` -mysql > select last_day('2000-02-03'); -+-------------------+ -| last_day('2000-02-03 00:00:00') | -+-------------------+ -| 2000-02-29 | -+-------------------+ + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | Input datetime value, type can be DATETIME or DATE | + +## Return Value + +Returns a value of type DATE representing the last day of the month for the given input date. + +## Example + +```sql +SELECT LAST_DAY('2000-02-03'); ``` -### keywords - LAST_DAY,DAYS +```text ++-----------------------------------------------+ +| last_day(cast('2000-02-03' as DATETIMEV2(0))) | ++-----------------------------------------------+ +| 2000-02-29 | ++-----------------------------------------------+ +``` diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md index 83b091409d934..19461f14de550 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md @@ -24,22 +24,42 @@ specific language governing permissions and limitations under the License. --> -## makedate -### Description -#### Syntax -`DATE MAKEDATE(INT year, INT dayofyear)` +## Description -Returns a date, given year and day-of-year values. dayofyear must be greater than 0 or the result is NULL. +Returns a date based on the specified year and the day of the year (dayofyear). -### example +Special cases: +- Returns NULL when `dayofyear` is less than or equal to 0. +- Automatically rolls over to the next year if `dayofyear` exceeds the number of days in the year. + +## Syntax + +```sql +MAKEDATE(, ) +``` + +## Parameters + +| Parameter | Description | +|-------------|-------------------------------------------| +| `` | The specified year, of type INT | +| `` | The day of the year (1-366), of type INT | + +## Return Value + +Returns a value of type DATE, constructed from the specified year and the given day of the year. + +## Example + +```sql +SELECT MAKEDATE(2021, 1), MAKEDATE(2021, 100), MAKEDATE(2021, 400); ``` -mysql> select makedate(2021,1), makedate(2021,100), makedate(2021,400); + +```text +-------------------+---------------------+---------------------+ | makedate(2021, 1) | makedate(2021, 100) | makedate(2021, 400) | +-------------------+---------------------+---------------------+ | 2021-01-01 | 2021-04-10 | 2022-02-04 | +-------------------+---------------------+---------------------+ ``` -### keywords - MAKEDATE diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md index a99ad0b4c8e33..2a5191e01cb5e 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md @@ -24,25 +24,37 @@ specific language governing permissions and limitations under the License. --> -## microsecond -### description -#### Syntax -`INT MICROSECOND(DATETIMEV2 date)` +## Description -Returns microsecond information in the time type. +Extracts the microsecond part from a datetime value. The returned range is from 0 to 999999. -The parameter is Datetime type +## Syntax -### example +```sql +MICROSECOND() +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, of type DATETIMEV2, with a precision greater than 0 | + +## Return Value +Returns an INT type representing the microsecond part of the datetime value. The range is from 0 to 999999. For inputs with a precision less than 6, the missing digits are padded with zeros. + +## Example + +```sql +SELECT MICROSECOND(CAST('1999-01-02 10:11:12.000123' AS DATETIMEV2(6))) AS microsecond; ``` -mysql> select microsecond(cast('1999-01-02 10:11:12.000123' as datetimev2(6))) as microsecond; + +```text +-------------+ | microsecond | +-------------+ | 123 | +-------------+ ``` -### keywords - MICROSECOND diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md index 106e015dfa70d..f0fef6608c18e 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md @@ -24,27 +24,42 @@ specific language governing permissions and limitations under the License. --> -## microseconds_add -### description -#### Syntax -`DATETIMEV2 microseconds_add(DATETIMEV2 basetime, INT delta)` -- basetime: Base time whose type is DATETIMEV2 -- delta: Microseconds to add to basetime -- Return type of this function is DATETIMEV2 +## Description -### example +Adds a specified number of microseconds to a datetime value and returns a new datetime value. + +## Syntax + +```sql +MICROSECONDS_ADD(, ) ``` -mysql> select now(3), microseconds_add(now(3), 100000); -+-------------------------+----------------------------------+ -| now(3) | microseconds_add(now(3), 100000) | -+-------------------------+----------------------------------+ -| 2023-02-21 11:35:56.556 | 2023-02-21 11:35:56.656 | -+-------------------------+----------------------------------+ + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, of type DATETIMEV2 | +| `` | The number of microseconds to add, of type INT; 1 second = 1,000,000 microseconds | + +## Return Value + +Returns a value of type DATETIMEV2, representing the time value after adding the specified number of microseconds to the input datetime. The precision of the return value is the same as that of the input parameter basetime. + +## Example + +```sql +SELECT NOW(3) AS current_time, MICROSECONDS_ADD(NOW(3), 100000) AS after_add; ``` -`now(3)` returns current time as type DATETIMEV2 with precision 3d,`microseconds_add(now(3), 100000)` means 100000 microseconds after current time -### keywords - microseconds_add +```text ++-------------------------+----------------------------+ +| current_time | after_add | ++-------------------------+----------------------------+ +| 2025-01-16 11:48:10.505 | 2025-01-16 11:48:10.605000 | ++-------------------------+----------------------------+ +``` - \ No newline at end of file +**Note:** +- `NOW(3)` returns the current time with a precision of 3 decimal places. +- After adding 100000 microseconds (0.1 seconds), the time increases by 0.1 seconds. diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md index 7a48fc117b59c..04254f2cd54d0 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md @@ -24,26 +24,41 @@ specific language governing permissions and limitations under the License. --> -## microseconds_diff -### description -#### Syntax -`INT microseconds_diff(DATETIME enddate, DATETIME startdate)` +## Description -How many microseconds is the difference between the start time and the end time. +Calculates the microsecond difference between two datetime values. The result is the number of microseconds from `` subtracted from ``. -### example +## Syntax +```sql +MICROSECONDS_DIFF(, ) ``` -mysql> select microseconds_diff('2020-12-25 21:00:00.623000','2020-12-25 21:00:00.123000'); + +## Parameters + +| Parameter | Description | +|------------|-------------------------------------------------| +| `` | The end time, of type DATETIMEV2 | +| `` | The start time, of type DATETIMEV2 | + +## Return Value + +Returns an INT type representing the microsecond difference between the two times. +- Returns a positive number if `` is greater than ``. +- Returns a negative number if `` is less than ``. +- 1 second = 1,000,000 microseconds. + +## Example + +```sql +SELECT MICROSECONDS_DIFF('2020-12-25 21:00:00.623000', '2020-12-25 21:00:00.123000'); +``` + +```text +-----------------------------------------------------------------------------------------------------------------------------+ -| microseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(6)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(6))) | +| microseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(3)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(3))) | +-----------------------------------------------------------------------------------------------------------------------------+ | 500000 | +-----------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.12 sec) ``` - -### keywords - - microseconds_diff diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md index 439bc2a37429b..c7a61d509bce4 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md @@ -24,25 +24,43 @@ specific language governing permissions and limitations under the License. --> -## microseconds_sub -### description -#### Syntax -`DATETIMEV2 microseconds_sub(DATETIMEV2 basetime, INT delta)` -- basetime: Base time whose type is DATETIMEV2 -- delta: Microseconds to subtract from basetime -- Return type of this function is DATETIMEV2 +## Description -### example +Subtracts a specified number of microseconds from a datetime value and returns a new datetime value. + +## Syntax + +```sql +MICROSECONDS_SUB(, ) +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, of type DATETIMEV2 | +| `` | The number of microseconds to subtract, of type INT; 1 second = 1,000,000 microseconds | + +## Return Value + +Returns a value of type DATETIMEV2, representing the time value after subtracting the specified number of microseconds from the input datetime. The precision of the return value is the same as that of the input parameter basetime. + +## Example + +```sql +SELECT NOW(3) AS current_time, MICROSECONDS_SUB(NOW(3), 100000) AS after_sub; ``` -mysql> select now(3), microseconds_sub(now(3), 100000); -+-------------------------+----------------------------------+ -| now(3) | microseconds_sub(now(3), 100000) | -+-------------------------+----------------------------------+ -| 2023-02-25 02:03:05.174 | 2023-02-25 02:03:05.074 | -+-------------------------+----------------------------------+ + +```text ++-------------------------+----------------------------+ +| current_time | after_sub | ++-------------------------+----------------------------+ +| 2025-01-16 11:52:22.296 | 2025-01-16 11:52:22.196000 | ++-------------------------+----------------------------+ ``` -`now(3)` returns current time as type DATETIMEV2 with precision `3`,`microseconds_sub(now(3), 100000)` means 100000 microseconds before current time -### keywords - microseconds_sub +**Note:** +- `NOW(3)` returns the current time with a precision of 3 decimal places. +- After subtracting 100000 microseconds (0.1 seconds), the time decreases by 0.1 seconds. +- The function's result is dependent on the precision of the input time. diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md index 4d2c2f27d2221..bdd66319310ce 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md @@ -24,28 +24,43 @@ specific language governing permissions and limitations under the License. --> -## milliseconds_add -### description -#### Syntax -`DATETIMEV2 milliseconds_add(DATETIMEV2 basetime, INT delta)` -- basetime: Base time whose type is DATETIMEV2 -- delta:Milliseconds to add to basetime -- Return type of this function is DATETIMEV2 +## Description -### example +Adds a specified number of milliseconds to a datetime value and returns a new datetime value. + +## Syntax + +```sql +MILLISECONDS_ADD(, ) +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, of type DATETIMEV2 | +| `` | The number of milliseconds to add, of type INT; 1 second = 1,000 milliseconds = 1,000,000 microseconds | + +## Return Value + +Returns a value of type DATETIMEV2, representing the time value after adding the specified number of milliseconds to the input datetime. The precision of the return value is the same as that of the input parameter basetime. + +## Example + +```sql +SELECT MILLISECONDS_ADD('2023-09-08 16:02:08.435123', 1); ``` -mysql> select milliseconds_add('2023-09-08 16:02:08.435123', 1); + +```text +--------------------------------------------------------------------------+ | milliseconds_add(cast('2023-09-08 16:02:08.435123' as DATETIMEV2(6)), 1) | +--------------------------------------------------------------------------+ | 2023-09-08 16:02:08.436123 | +--------------------------------------------------------------------------+ -1 row in set (0.04 sec) ``` - -### keywords - milliseconds_add - - \ No newline at end of file +**Note:** +- In the example, after adding 1 millisecond, the time increases from .435123 to .436123. +- 1 millisecond equals 1000 microseconds. +- The function's result is dependent on the precision of the input time; the example uses a precision of 6 decimal places. diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md index 94f4b678e3a47..071bf8fac6e77 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md @@ -24,26 +24,47 @@ specific language governing permissions and limitations under the License. --> -## milliseconds_diff -### description -#### Syntax -`INT milliseconds_diff(DATETIME enddate, DATETIME startdate)` +## Description -How many milliseconds is the difference between the start time and the end time? +Calculates the millisecond difference between two datetime values. The result is the number of milliseconds from `` subtracted from ``. -### example +## Syntax +```sql +MILLISECONDS_DIFF(, ) ``` -mysql> select milliseconds_diff('2020-12-25 21:00:00.623000','2020-12-25 21:00:00.123000'); + +## Parameters + +| Parameter | Description | +|------------|-------------------------------------------------| +| `` | The end time, of type DATETIMEV2 | +| `` | The start time, of type DATETIMEV2 | + +## Return Value + +Returns an INT type representing the millisecond difference between the two times. +- Returns a positive number if `` is greater than ``. +- Returns a negative number if `` is less than ``. +- 1 second = 1,000 milliseconds. +- 1 millisecond = 1,000 microseconds. + +## Example + +```sql +SELECT MILLISECONDS_DIFF('2020-12-25 21:00:00.623000', '2020-12-25 21:00:00.123000'); +``` + +```text +-----------------------------------------------------------------------------------------------------------------------------+ -| milliseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(6)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(6))) | +| milliseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(3)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(3))) | +-----------------------------------------------------------------------------------------------------------------------------+ | 500 | +-----------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) ``` -### keywords - - milliseconds_diff +**Note:** +- The time difference in the example is 0.5 seconds, which equals 500 milliseconds. +- The function's result is dependent on the precision of the input time; the example uses a precision of 3 decimal places. +- The result only returns the millisecond difference and does not include the microsecond part. diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md index 500579d5a07cb..806b96d80ad5c 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md @@ -24,18 +24,35 @@ specific language governing permissions and limitations under the License. --> -## milliseconds_sub -### description -#### Syntax -`DATETIMEV2 milliseconds_sub(DATETIMEV2 basetime, INT delta)` -- basetime: Base time whose type is DATETIMEV2 -- delta: Milliseconds to subtract from basetime -- Return type of this function is DATETIMEV2 +## Description -### example +Subtracts a specified number of milliseconds from a datetime value and returns a new datetime value. + +## Syntax + +```sql +MILLISECONDS_SUB(, ) +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, of type DATETIMEV2 | +| `` | The number of milliseconds to subtract, of type INT; 1 second = 1,000 milliseconds = 1,000,000 microseconds | + +## Return Value + +Returns a value of type DATETIMEV2, representing the time value after subtracting the specified number of milliseconds from the input datetime. The precision of the return value is the same as that of the input parameter basetime. + +## Example + +```sql +SELECT MILLISECONDS_SUB('2023-09-08 16:02:08.435123', 1); ``` -mysql> select milliseconds_sub('2023-09-08 16:02:08.435123', 1); + +```text +--------------------------------------------------------------------------+ | milliseconds_sub(cast('2023-09-08 16:02:08.435123' as DATETIMEV2(6)), 1) | +--------------------------------------------------------------------------+ @@ -44,8 +61,8 @@ mysql> select milliseconds_sub('2023-09-08 16:02:08.435123', 1); 1 row in set (0.11 sec) ``` - -### keywords - milliseconds_sub - - \ No newline at end of file +**Note:** +- In the example, after subtracting 1 millisecond, the time decreases from .435123 to .434123. +- 1 millisecond equals 1000 microseconds. +- The function's result is dependent on the precision of the input time; the example uses a precision of 6 decimal places. +- The result retains microsecond-level precision. diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-ceil.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-ceil.md index 36e8b809e1ca6..e2eb8911a3ed5 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-ceil.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-ceil.md @@ -1,6 +1,6 @@ --- { - "title": "minute_ceil", + "title": "MINUTE_CEIL", "language": "en" } --- @@ -24,39 +24,51 @@ specific language governing permissions and limitations under the License. --> -## minute_ceil -### description -#### Syntax + +## Description + +Rounds up a datetime value to the nearest specified minute interval. If a starting time (origin) is provided, it uses that time as the reference for calculating the interval. + +## Syntax ```sql -DATETIME MINUTE_CEIL(DATETIME datetime) -DATETIME MINUTE_CEIL(DATETIME datetime, DATETIME origin) -DATETIME MINUTE_CEIL(DATETIME datetime, INT period) -DATETIME MINUTE_CEIL(DATETIME datetime, INT period, DATETIME origin) +MINUTE_CEIL() +MINUTE_CEIL(, ) +MINUTE_CEIL(, ) +MINUTE_CEIL(, , ) ``` -Convert the date to the nearest rounding up time of the specified time interval period. +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The datetime value to round up, of type DATETIME or DATETIMEV2 | +| `` | The minute interval value, of type INT, representing the number of minutes in each interval | +| `` | The starting point for the interval, of type DATETIME or DATETIMEV2; defaults to 0001-01-01 00:00:00 | -- datetime: a valid date expression. -- period: specifies how many minutes each cycle consists of. -- origin: starting from 0001-01-01T00:00:00. +## Return Value -### example +Returns a value of type DATETIMEV2, representing the rounded-up datetime value based on the specified minute interval. The precision of the return value is the same as that of the input parameter datetime. +## Example + +```sql +SELECT MINUTE_CEIL("2023-07-13 22:28:18", 5); ``` -mysql> select minute_ceil("2023-07-13 22:28:18", 5); + +```text +--------------------------------------------------------------+ | minute_ceil(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +--------------------------------------------------------------+ | 2023-07-13 22:30:00 | +--------------------------------------------------------------+ -1 row in set (0.21 sec) ``` -### keywords - - MINUTE_CEIL, MINUTE, CEIL +**Note:** +- If no period is specified, it defaults to a 1-minute interval. +- The period must be a positive integer. +- The result is always rounded up to a future time. -### Best Practice +## Best Practices See also [date_ceil](./date_ceil) diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md index afe9f8ac3e89c..bf644db01d0f3 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md @@ -1,6 +1,6 @@ --- { - "title": "minute_floor", + "title": "MINUTE_FLOOR", "language": "en" } --- @@ -24,39 +24,52 @@ specific language governing permissions and limitations under the License. --> -## minute_floor -### description -#### Syntax + +## Description + +Rounds down a datetime value to the nearest specified minute interval. If a starting time (origin) is provided, it uses that time as the reference for calculating the interval. + +## Syntax ```sql -DATETIME MINUTE_FLOOR(DATETIME datetime) -DATETIME MINUTE_FLOOR(DATETIME datetime, DATETIME origin) -DATETIME MINUTE_FLOOR(DATETIME datetime, INT period) -DATETIME MINUTE_FLOOR(DATETIME datetime, INT period, DATETIME origin) +MINUTE_FLOOR() +MINUTE_FLOOR(, ) +MINUTE_FLOOR(, ) +MINUTE_FLOOR(, , ) ``` -Convert the date to the nearest rounding down time of the specified time interval period. +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The datetime value to round down, of type DATETIME or DATETIMEV2 | +| `` | The minute interval value, of type INT, representing the number of minutes in each interval | +| `` | The starting point for the interval, of type DATETIME or DATETIMEV2; defaults to 0001-01-01 00:00:00 | -- datetime: a valid date expression. -- period: specifies how many minutes each cycle consists of. -- origin: starting from 0001-01-01T00:00:00. +## Return Value -### example +Returns a value of type DATETIMEV2, representing the rounded-down datetime value. +## Example + +```sql +SELECT MINUTE_FLOOR("2023-07-13 22:28:18", 5); ``` -mysql> select minute_floor("2023-07-13 22:28:18", 5); + +```text +---------------------------------------------------------------+ | minute_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +---------------------------------------------------------------+ | 2023-07-13 22:25:00 | +---------------------------------------------------------------+ -1 row in set (0.06 sec) ``` -### keywords - - MINUTE_FLOOR, MINUTE, FLOOR +**Note:** +- If no period is specified, it defaults to a 1-minute interval. +- The period must be a positive integer. +- The result is always rounded down to a past time. +- Unlike MINUTE_CEIL, MINUTE_FLOOR always discards the portion that exceeds the interval. -### Best Practice +## Best Practices See also [date_floor](./date_floor) diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md index cfa348e739933..09a224da048d2 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md @@ -27,21 +27,39 @@ under the License. ## Description -Returns minute information in the time type, ranging from 0,59 +Extracts the minute part from a datetime value. The returned value ranges from 0 to 59. -The parameter is Date or Datetime or Time type ## Syntax -`INT MINUTE(DATETIME date)` + +```sql +MINUTE() +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATE, DATETIME, DATETIMEV2, or TIME | + +## Return Value + +Returns an INT type representing the minute value, with a range of 0-59. ## Example ```sql -mysql> select minute('2018-12-31 23:59:59'); -+-----------------------------+ -| minute('2018-12-31 23:59:59') | -+-----------------------------+ -| 59 | -+-----------------------------+ +SELECT MINUTE('2018-12-31 23:59:59'); ``` -## Keywords - MINUTE + +```text ++------------------------------------------------------+ +| minute(cast('2018-12-31 23:59:59' as DATETIMEV2(0))) | ++------------------------------------------------------+ +| 59 | ++------------------------------------------------------+ +``` + +**Note:** +- The input parameter can be of various time-related types. +- The returned value is always an integer between 0 and 59. +- If the input parameter is NULL, the function returns NULL. diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md index 7c4636db8c855..04479f476828a 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md @@ -24,27 +24,43 @@ specific language governing permissions and limitations under the License. --> -## minutes_add -### description -#### Syntax -`DATETIME MINUTES_ADD(DATETIME date, INT minutes)` +## Description -Add specified minutes from date time or date +Adds a specified number of minutes to a datetime value and returns a new datetime value. -The parameter date can be DATETIME or DATE, and the return type is DATETIME. - -### example +## Syntax +```sql +MINUTES_ADD(, ) ``` -mysql> select minutes_add("2020-02-02", 1); -+---------------------------------------+ -| minutes_add('2020-02-02 00:00:00', 1) | -+---------------------------------------+ -| 2020-02-02 00:01:00 | -+---------------------------------------+ + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATE, DATETIME, or DATETIMEV2 | +| `` | The number of minutes to add, of type INT; can be positive or negative | + +## Return Value + +Returns a value of type DATETIME, representing the datetime value after adding the specified number of minutes. + +## Example + +```sql +SELECT MINUTES_ADD("2020-02-02", 1); ``` -### keywords +```text ++-----------------------------------------------------+ +| minutes_add(cast('2020-02-02' as DATETIMEV2(0)), 1) | ++-----------------------------------------------------+ +| 2020-02-02 00:01:00 | ++-----------------------------------------------------+ +``` - MINUTES_ADD +**Note:** +- When the number of minutes added is negative, it effectively subtracts the corresponding number of minutes. +- The function automatically handles cases that cross hours and days. +- If the input parameter is NULL, the function returns NULL. diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md index b8c7fd1c1b880..ff3ccd818844f 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md @@ -24,25 +24,45 @@ specific language governing permissions and limitations under the License. --> -## minutes_diff -### description -#### Syntax -`INT minutes_diff(DATETIME enddate, DATETIME startdate)` +## Description -The difference between the start time and the end time is a few minutes +Calculates the minute difference between two datetime values. The result is the number of minutes from `` subtracted from ``. -### example +## Syntax +```sql +MINUTES_DIFF(, ) ``` -mysql> select minutes_diff('2020-12-25 22:00:00','2020-12-25 21:00:00'); -+------------------------------------------------------------+ -| minutes_diff('2020-12-25 22:00:00', '2020-12-25 21:00:00') | -+------------------------------------------------------------+ -| 60 | -+------------------------------------------------------------+ + +## Parameters + +| Parameter | Description | +|------------|-------------------------------------------------| +| `` | The end time, which can be of type DATE, DATETIME, or DATETIMEV2 | +| `` | The start time, which can be of type DATE, DATETIME, or DATETIMEV2 | + +## Return Value + +Returns an INT type representing the minute difference between the two times. +- Returns a positive number if `` is greater than ``. +- Returns a negative number if `` is less than ``. + +## Example + +```sql +SELECT MINUTES_DIFF('2020-12-25 22:00:00', '2020-12-25 21:00:00'); ``` -### keywords +```text ++----------------------------------------------------------------------------------------------------------+ +| minutes_diff(cast('2020-12-25 22:00:00' as DATETIMEV2(0)), cast('2020-12-25 21:00:00' as DATETIMEV2(0))) | ++----------------------------------------------------------------------------------------------------------+ +| 60 | ++----------------------------------------------------------------------------------------------------------+ +``` - minutes_diff +**Note:** +- The calculation only considers complete minutes; seconds and milliseconds are ignored. +- If either input parameter is NULL, the function returns NULL. +- It can handle time differences that span days, months, or years. diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md index 42612d96f501f..0d502ca9a0697 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md @@ -24,27 +24,44 @@ specific language governing permissions and limitations under the License. --> -## minutes_sub -### description -#### Syntax -`DATETIME MINUTES_SUB(DATETIME date, INT minutes)` +## Description -Subtracts a specified number of minutes from a datetime or date +Subtracts a specified number of minutes from a datetime value and returns a new datetime value. -The parameter date can be DATETIME or DATE, and the return type is DATETIME. - -### example +## Syntax +```sql +MINUTES_SUB(, ) ``` -mysql> select minutes_sub("2020-02-02 02:02:02", 1); -+---------------------------------------+ -| minutes_sub('2020-02-02 02:02:02', 1) | -+---------------------------------------+ -| 2020-02-02 02:01:02 | -+---------------------------------------+ + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATE, DATETIME, or DATETIMEV2 | +| `` | The number of minutes to subtract, of type INT; can be positive or negative | + +## Return Value + +Returns a value of type DATETIME, representing the datetime value after subtracting the specified number of minutes. + +## Example + +```sql +SELECT MINUTES_SUB("2020-02-02 02:02:02", 1); ``` -### keywords +```text ++--------------------------------------------------------------+ +| minutes_sub(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), 1) | ++--------------------------------------------------------------+ +| 2020-02-02 02:01:02 | ++--------------------------------------------------------------+ +``` - MINUTES_SUB +**Note:** +- When the number of minutes subtracted is negative, it effectively adds the corresponding number of minutes. +- The function automatically handles cases that cross hours and days. +- If the input parameter is NULL, the function returns NULL. +- The result retains the seconds portion of the original time. diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md index dd50bc4342bb4..d27c4d4102065 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md @@ -1,6 +1,6 @@ --- { - "title": "month_ceil", + "title": "MONTH_CEIL", "language": "en" } --- @@ -24,39 +24,52 @@ specific language governing permissions and limitations under the License. --> -## month_ceil -### description -#### Syntax + +## Description + +Rounds up a datetime value to the nearest specified month interval. If a starting time (origin) is provided, it uses that time as the reference for calculating the interval. + +## Syntax ```sql -DATETIME MONTH_CEIL(DATETIME datetime) -DATETIME MONTH_CEIL(DATETIME datetime, DATETIME origin) -DATETIME MONTH_CEIL(DATETIME datetime, INT period) -DATETIME MONTH_CEIL(DATETIME datetime, INT period, DATETIME origin) +MONTH_CEIL() +MONTH_CEIL(, ) +MONTH_CEIL(, ) +MONTH_CEIL(, , ) ``` -Convert the date to the nearest rounding up time of the specified time interval period. +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The datetime value to round up, of type DATETIME or DATETIMEV2 | +| `` | The month interval value, of type INT, representing the number of months in each interval | +| `` | The starting point for the interval, of type DATETIME or DATETIMEV2; defaults to 0001-01-01 00:00:00 | -- datetime: a valid date expression. -- period: specifies how many months each cycle consists of. -- origin: starting from 0001-01-01T00:00:00. +## Return Value -### example +Returns a value of type DATETIME, representing the rounded-up datetime value. The time portion of the result will be set to 00:00:00. +## Example + +```sql +SELECT MONTH_CEIL("2023-07-13 22:28:18", 5); ``` -mysql> select month_ceil("2023-07-13 22:28:18", 5); + +```text +-------------------------------------------------------------+ | month_ceil(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +-------------------------------------------------------------+ | 2023-10-01 00:00:00 | +-------------------------------------------------------------+ -1 row in set (0.02 sec) ``` -### keywords - - MONTH_CEIL, MONTH, CEIL +**Note:** +- If no period is specified, it defaults to a 1-month interval. +- The period must be a positive integer. +- The result is always rounded up to a future time. +- The time portion of the returned value is always set to 00:00:00. -### Best Practice +## Best Practices See also [date_ceil](./date_ceil) diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md index 60684714fb1c3..e6e672c246e69 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md @@ -1,6 +1,6 @@ --- { - "title": "month_floor", + "title": "MONTH_FLOOR", "language": "en" } --- @@ -24,39 +24,53 @@ specific language governing permissions and limitations under the License. --> -## month_floor -### description -#### Syntax + +## Description + +Rounds down a datetime value to the nearest specified month interval. If a starting time (origin) is provided, it uses that time as the reference for calculating the interval. + +## Syntax ```sql -DATETIME MONTH_FLOOR(DATETIME datetime) -DATETIME MONTH_FLOOR(DATETIME datetime, DATETIME origin) -DATETIME MONTH_FLOOR(DATETIME datetime, INT period) -DATETIME MONTH_FLOOR(DATETIME datetime, INT period, DATETIME origin) +MONTH_FLOOR() +MONTH_FLOOR(, ) +MONTH_FLOOR(, ) +MONTH_FLOOR(, , ) ``` -Convert the date to the nearest rounding down time of the specified time interval period. +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The datetime value to round down, of type DATETIME or DATETIMEV2 | +| `` | The month interval value, of type INT, representing the number of months in each interval | +| `` | The starting point for the interval, of type DATETIME or DATETIMEV2; defaults to 0001-01-01 00:00:00 | -- datetime: a valid date expression. -- period: specifies how many months each cycle consists of. -- origin: starting from 0001-01-01T00:00:00. +## Return Value -### example +Returns a value of type DATETIME, representing the rounded-down datetime value. The time portion of the result will be set to 00:00:00. +## Example + +```sql +SELECT MONTH_FLOOR("2023-07-13 22:28:18", 5); ``` -mysql> select month_floor("2023-07-13 22:28:18", 5); + +```text +--------------------------------------------------------------+ | month_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +--------------------------------------------------------------+ | 2023-05-01 00:00:00 | +--------------------------------------------------------------+ -1 row in set (0.12 sec) ``` -### keywords - - MONTH_FLOOR, MONTH, FLOOR +**Note:** +- If no period is specified, it defaults to a 1-month interval. +- The period must be a positive integer. +- The result is always rounded down to a past time. +- The time portion of the returned value is always set to 00:00:00. +- Unlike MONTH_CEIL, MONTH_FLOOR always discards the portion that exceeds the interval. -### Best Practice +## Best Practices See also [date_floor](./date_floor) diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md index 9a3a71f15be76..3dfc9779fc380 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md @@ -24,26 +24,40 @@ specific language governing permissions and limitations under the License. --> -## month -### Description -#### Syntax -`INT MONTH (DATETIME date)` +## Description +Extracts the month value from a datetime value. The returned value ranges from 1 to 12, representing the 12 months of the year. -Returns month information in the time type, ranging from 1,12 +## Syntax -The parameter is Date or Datetime type +```sql +MONTH() +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATE, DATETIME, or DATETIMEV2 | -### example +## Return Value +Returns an INT type representing the month value: +- Range: 1 to 12 +- 1 represents January, and 12 represents December. +- If the input is NULL, the function returns NULL. + +## Example + +```sql +SELECT MONTH('1987-01-01'); ``` -mysql> select month('1987-01-01'); -+-----------------------------+ -| month('1987-01-01 00:00:00') | -+-----------------------------+ -| 1 | -+-----------------------------+ + +```text ++--------------------------------------------+ +| month(cast('1987-01-01' as DATETIMEV2(0))) | ++--------------------------------------------+ +| 1 | ++--------------------------------------------+ ``` -### keywords - MONTH diff --git a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md index ae1852d1aa8cc..bd597c431fe14 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md +++ b/docs/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md @@ -24,26 +24,40 @@ specific language governing permissions and limitations under the License. --> -## monthname -### Description -#### Syntax -`VARCHAR MONTHNAME (DATE)` +## Description +Returns the English name of the month corresponding to a given date. The returned value is the full English name of the month (from January to December). -Month name corresponding to return date +## Syntax -The parameter is Date or Datetime type +```sql +MONTHNAME() +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATE, DATETIME, or DATETIMEV2 | -### example +## Return Value +Returns a value of type VARCHAR representing the English name of the month: +- Possible return values: January, February, March, April, May, June, July, August, September, October, November, December +- If the input is NULL, the function returns NULL. +- The first letter of the return value is capitalized, and the remaining letters are in lowercase. + +## Example + +```sql +SELECT MONTHNAME('2008-02-03 00:00:00'); ``` -mysql> select monthname('2008-02-03 00:00:00'); -+----------------------------------+ -| monthname('2008-02-03 00:00:00') | -+----------------------------------+ -| February | -+----------------------------------+ + +```text ++---------------------------------------------------------+ +| monthname(cast('2008-02-03 00:00:00' as DATETIMEV2(0))) | ++---------------------------------------------------------+ +| February | ++---------------------------------------------------------+ ``` -### keywords - MONTHNAME diff --git a/docs/sql-manual/sql-functions/scalar-functions/json-functions/jsonb-extract.md b/docs/sql-manual/sql-functions/scalar-functions/json-functions/jsonb-extract.md deleted file mode 100644 index eccf2ad4ea754..0000000000000 --- a/docs/sql-manual/sql-functions/scalar-functions/json-functions/jsonb-extract.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -{ - "title": "JSON_EXTRACT", - "language": "en" -} ---- - - diff --git a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md index e5957fdc9e416..70bba730c0902 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md +++ b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md @@ -24,50 +24,37 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Determines whether the given `map` contains a specific key `key` -`BOOLEAN map_contains_key(Map map, K key)` +## Syntax -Determines whether the given `map` contains a particular key `key`. +```sql +MAP_CONTAINS_KEY(, ) +``` -### Example +## Parameters -```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +| Parameter | Description | +| -- | -- | +| `` | Input map content | +| `` | The key to be retrieved | -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## Return Value -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +Determines whether the given `map` contains a specific key `key`, and returns 1 if it exists, otherwise returns 0. -mysql> select map_contains_key(map(null, 1, 2, null), null); -+-----------------------------------------------+ -| map_contains_key(map(NULL, 1, 2, NULL), NULL) | -+-----------------------------------------------+ -| 1 | -+-----------------------------------------------+ -1 row in set (0.14 sec) -``` +## Example -### Keywords +```sql +select map_contains_key(map(null, 1, 2, null), null),map_contains_key(map(1, "100", 0.1, 2), 0.11); +``` -MAP, CONTAINS, KEY, MAP_CONTAINS_KEY +```text ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_key(map(NULL, 1, 2, NULL), NULL) | map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast(0.11 as DECIMALV3(3, 2))) | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md index 68c280c05b0af..1eea84a410cc7 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md +++ b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md @@ -24,66 +24,37 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Determines whether the given `map` contains a specific value `value` -`BOOLEAN map_contains_value(Map map, V value)` - -Determines whether the given `map` contains a particular value `value`. - -### Example +## Syntax ```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +MAP_CONTAINS_VALUE(, ) +``` -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## Parameters -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +| Parameter | Description | +| -- | -- | +| `` | Input map content | +| `` | The value to be retrieved | -mysql> select map_contains_value(map(1, "100", 0.1, 2), 100.0); -+--------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(100.0 as VARCHAR(3))) | -+--------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+--------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## Return Value -mysql> select map_contains_value(map(1, "100", 0.1, 2), 101); -+------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | -+------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.14 sec) +Determines whether the given `map` contains a specific value `value`, and returns 1 if it exists, otherwise returns 0. -mysql> select map_contains_value(map(null, 1, 2, null), null); -+-------------------------------------------------+ -| map_contains_value(map(NULL, 1, 2, NULL), NULL) | -+-------------------------------------------------+ -| 1 | -+-------------------------------------------------+ -1 row in set (0.15 sec) -``` +## Example -### Keywords +```sql +select map_contains_value(map(null, 1, 2, null), null),map_contains_value(map(1, "100", 0.1, 2), 101); +``` -MAP, CONTAINS, VALUE, MAP_CONTAINS_VALUE +```text ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_value(map(NULL, 1, 2, NULL), NULL) | map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md index 04e20a1cfb261..5bde39f09b926 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md +++ b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md @@ -23,35 +23,36 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> +## Description -### Description +Extract the keys of the given `map` into an `ARRAY` of the corresponding type -#### Syntax +## Syntax -`ARRAY map_keys(Map map)` +```sql +MAP_KEYS() +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | Input map content | -Extracts the keys of a given `map` into an `ARRAY` of the corresponding type. +## Return Value -### Example +Extract the keys of the given `map` into an `ARRAY` of the corresponding type + +## Example ```sql -mysql> select map_keys(map(1, "100", 0.1, 2)); -+-------------------------------------------------------------------------------------------------+ -| map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+-------------------------------------------------------------------------------------------------+ -| [1.0, 0.1] | -+-------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) - -mysql> select map_keys(map()); -+-----------------+ -| map_keys(map()) | -+-----------------+ -| [] | -+-----------------+ -1 row in set (0.12 sec) +select map_keys(map()),map_keys(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, KEYS, MAP_KEYS +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_keys(map()) | map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| [] | [1.0, 0.1] | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md index 79f097a3ff53d..15c78086b80c3 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md +++ b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md @@ -1,7 +1,6 @@ --- { - "title": "MAP_SIZE - ", + "title": "MAP_SIZE", "language": "en" } --- @@ -24,3 +23,37 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## Description + +Count the number of elements in a Map + +## Syntax + +```sql +MAP_SIZE() +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | Input map content | + +## Return Value + +Returns the number of elements in the Map + +## Example + +```sql +select map_size(map()),map_size(map(1, "100", 0.1, 2)); +``` + +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_size(map()) | map_size(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| 0 | 2 | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md index 6fef8da25aab1..160fcb91ee7cf 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md +++ b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md @@ -24,34 +24,36 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Extract the values of the given `map` into an `ARRAY` of the corresponding type -`ARRAY map_values(Map map)` +## Syntax -Extracts the value of a given `map` into an `ARRAY` of the corresponding type. +```sql +MAP_VALUES() +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | Input map content | -### Example +## Return Value + +Extract the values of the given `map` into an `ARRAY` of the corresponding type + +## Example ```sql -mysql> select map_values(map(1, "100", 0.1, 2)); -+---------------------------------------------------------------------------------------------------+ -| map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+---------------------------------------------------------------------------------------------------+ -| ["100", "2"] | -+---------------------------------------------------------------------------------------------------+ -1 row in set (0.12 sec) - -mysql> select map_values(map()); -+-------------------+ -| map_values(map()) | -+-------------------+ -| [] | -+-------------------+ -1 row in set (0.11 sec) +select map_values(map()),map_values(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, VALUES, MAP_VALUES +```text ++-------------------+---------------------------------------------------------------------------------------------------+ +| map_values(map()) | map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-------------------+---------------------------------------------------------------------------------------------------+ +| [] | ["100", "2"] | ++-------------------+---------------------------------------------------------------------------------------------------+ +``` diff --git a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map.md b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map.md index 8ffda7f10305b..f19716c0dc13f 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/map-functions/map.md +++ b/docs/sql-manual/sql-functions/scalar-functions/map-functions/map.md @@ -24,34 +24,37 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Constructs a `Map` of a specific type using some set of key-value pairs -`MAP map(K key0, V value0, K key1, V value1, ..., K keyn, V valuen)` +## Syntax -Construct a type-specific `Map` using a set of key-value pairs. +```sql +MAP( , [, , ... ]) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | Constructing the key of the map | +| `` | Constructing the value of the map | -### Example +## Return Value + +Returns a specific type `Map` constructed from a number of key-value pairs + +## Example ```sql -mysql> select map(1, "100", 0.1, 2); -+---------------------------------------------------------------------------------------+ -| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | -+---------------------------------------------------------------------------------------+ -| {1.0:"100", 0.1:"2"} | -+---------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) - -mysql> select map(1, "100", 0.1, 2)[1]; -+-------------------------------------------------------------------------------------------------------------------------------+ -| element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | -+-------------------------------------------------------------------------------------------------------------------------------+ -| 100 | -+-------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +select map(1, "100", 0.1, 2),map(1, "100", 0.1, 2)[1]; ``` -### Keywords - -MAP +```text ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| {1.0:"100", 0.1:"2"} | 100 | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md index ca99aeb9125dd..401c2ac7c0a0f 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md +++ b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md @@ -24,36 +24,52 @@ specific language governing permissions and limitations under the License. --> -## ST_Angle_Sphere -### description -#### Syntax +## Description -`DOUBLE ST_Angle_Sphere(DOUBLE x_lng, DOUBLE x_lat, DOUBLE y_lng, DOUBLE y_lat)` +Calculate the center Angle between two points on the Earth's surface in degrees. The parameters passed in are the longitude of point X, latitude of point X, longitude of point Y, and latitude of point Y. +## Syntax -Calculates the central angle between two points on the Earth's surface. The incoming parameters are the longitude of point X, the latitude of point X, the longitude of point Y and the latitude of point Y. +```sql +ST_Angle_Sphere( , , , ) +``` + +## Parameters + +| Parameters | Instructions | +| -- | -- | +| `` | Longitude data, reasonable value range is [-180, 180] | +| `` | Longitude data, reasonable value range is [-180, 180] | +| `` | Latitude data, reasonable value range is [-90, 90] | +| `` | Latitude data, reasonable value range is [-90, 90] | -x_lng and y_lng are Longitude values, must be in the range [-180, 180]. -x_lat and y_lat are Latitude values, must be in the range [-90, 90]. +## Return Value -### example +The Angle of the center between two points +## Examples + +```sql +select ST_Angle_Sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); ``` -mysql> select ST_Angle_Sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); + +```text +---------------------------------------------------------------------------+ | st_angle_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219) | +---------------------------------------------------------------------------+ | 0.0659823452409903 | +---------------------------------------------------------------------------+ -1 row in set (0.06 sec) +``` + +```sql +select ST_Angle_Sphere(0, 0, 45, 0); +``` -mysql> select ST_Angle_Sphere(0, 0, 45, 0); +```text +----------------------------------------+ | st_angle_sphere(0.0, 0.0, 45.0, 0.0) | +----------------------------------------+ | 45 | +----------------------------------------+ -1 row in set (0.06 sec) ``` -### keywords -ST_ANGLE_SPHERE,ST,ANGLE,SPHERE + diff --git a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md index bccc92b06034c..bc5e44b4e443a 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md +++ b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md @@ -24,66 +24,95 @@ specific language governing permissions and limitations under the License. --> -## ST_Angle +## Description -### Syntax +Enter three points that represent two intersecting lines. Return the Angle between these lines. -`DOUBLE ST_Angle(GEOPOINT point1, GEOPOINT point2, GEOPOINT point3)` +## Syntax -### description +```sql +ST_Angle( , , ) +``` + +## Parameters + +| Parameters | Instructions | +|----------|---------------------------------------------------------------------------| +| `` | The first point of the first line | +| `` | The second point of the first line and the first point of the second line | +| `` | The second point of the second line | -Enter three point, which represent two intersecting lines. Returns the angle between these lines. Point 2 and point 1 represent the first line and point 2 and point 3 represent the second line. The angle between these lines is in radians, in the range [0, 2pi). The angle is measured clockwise from the first line to the second line. +## Return Value + +The Angle between these lines is expressed in radians and ranges from [0, 2pi]. The Angle is measured clockwise from the first line to the second line. ST_ANGLE has the following edge cases: -* If points 2 and 3 are the same, returns NULL. -* If points 2 and 1 are the same, returns NULL. -* If points 2 and 3 are exactly antipodal, returns NULL. -* If points 2 and 1 are exactly antipodal, returns NULL. -* If any of the input geographies are not single points or are the empty geography, then throws an error. +- If point 2 and point 3 are the same, NULL is returned +- If point 2 and point 1 are the same, NULL is returned +- NULL is returned if points 2 and 3 are perfect Antipodes +- NULL is returned if points 2 and 1 are perfect AntipodesL +- If any input geography is not a single point or is an empty geography, an error is thrown -### example +## Examples +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1)); ``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1)); + +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------------------------+ | 4.71238898038469 | +----------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1)); +``` -mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1)); +```text +----------------------------------------------------------------------+ | st_angle(st_point(0.0, 0.0), st_point(1.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------------------------+ | 0.78547432161873854 | +----------------------------------------------------------------------+ -1 row in set (0.02 sec) +``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0)); +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0)); +``` + +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(1.0, 0.0)) | +----------------------------------------------------------------------+ | 0 | +----------------------------------------------------------------------+ -1 row in set (0.02 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 0)); +``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 0)); +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 0.0)) | +----------------------------------------------------------------------+ | NULL | +----------------------------------------------------------------------+ -1 row in set (0.03 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(0, 0),ST_Point(-30, 0),ST_Point(150, 0)); +``` -mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(-30, 0),ST_Point(150, 0)); +```text +--------------------------------------------------------------------------+ | st_angle(st_point(0.0, 0.0), st_point(-30.0, 0.0), st_point(150.0, 0.0)) | +--------------------------------------------------------------------------+ | NULL | +--------------------------------------------------------------------------+ -1 row in set (0.02 sec) ``` -### keywords -ST_ANGLE,ST,ANGLE + diff --git a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md index d349861bbf19d..c4282f10a1654 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md +++ b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md @@ -24,45 +24,63 @@ specific language governing permissions and limitations under the License. --> -## ST_AsBinary +## Description -### Syntax +Convert a geometric figure to a standard WKB (Well-known binary) representation. -`VARCHAR ST_AsBinary(GEOMETRY geo)` +At present, the supported geometry is: Point, LineString, Polygon. -### Description +## Syntax -Converting a geometric figure into a standard WKB (Well-known binary) representation +```sql +ST_AsBinary( ) +``` + +## Parameters + +| Parameters | Instructions | +| -- |----------| +| `` | The graph that needs to be converted | + +## Return Value -Currently supported geometric figures are: Point, LineString, Polygon. +The WKB representation of the geometry: -### example +## Examples +```sql +select ST_AsBinary(st_point(24.7, 56.7)); ``` -mysql> select ST_AsBinary(st_point(24.7, 56.7)); + +```text +----------------------------------------------+ | st_asbinary(st_point(24.7, 56.7)) | +----------------------------------------------+ | \x01010000003333333333b338409a99999999594c40 | +----------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> select ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); +```sql +select ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); +``` + +```text +--------------------------------------------------------------------------------------+ | st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +--------------------------------------------------------------------------------------+ | \x010200000002000000000000000000f03f000000000000f03f00000000000000400000000000000040 | +--------------------------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` + +```sql +select ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")); +``` -mysql> select ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")); +```text +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')) | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | \x01030000000100000006000000f3380ce6af865c402d05a4fd0f8c364041ef8d2100865c403049658a398c3640b9fb1c1f2d865c409d9b36e334883640de921cb0ab865c40cf876709328a36402cefaa07cc865c407b319413ed8a3640f3380ce6af865c402d05a4fd0f8c3640 | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.02 sec) - ``` -### keywords -ST_ASBINARY,ST,ASBINARY + diff --git a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md index b1990bb38353a..984ccdb156767 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md +++ b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_AsText,ST_AsWKT -### Description -#### Syntax +## Description -`VARCHAR ST_AsText (GEOMETRY geo)` +Convert a geometric figure to a representation of WKT (Well Known Text) +## Syntax -Converting a geometric figure into a WKT (Well Known Text) representation +```sql +ST_AsText( ) +``` + +## Parameters + +| Parameters | Instructions | +| -- |----------| +| `` | The graph that needs to be converted | -### example +## Return Value +The WKT representation of the geometry: + +## Examples + +```sql +SELECT ST_AsText(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_AsText(ST_Point(24.7, 56.7)); + +```text +---------------------------------+ | st_astext(st_point(24.7, 56.7)) | +---------------------------------+ | POINT (24.7 56.7) | +---------------------------------+ ``` -### keywords -ST_ASTEXT,ST_ASWKT,ST,ASTEXT,ASWKT diff --git a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md index bb7b9ed19e41a..88744e119f173 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md +++ b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md @@ -24,72 +24,84 @@ specific language governing permissions and limitations under the License. --> -## ST_Azimuth +## Description -### Syntax +Enter two points and return the azimuth of the line segment formed by points 1 and 2. Azimuth is the arc of the Angle between the true north line of point 1 and the line segment formed by points 1 and 2. -`DOUBLE ST_Azimuth(GEOPOINT point1, GEOPOINT point2)` +## Syntax -### description +```sql +ST_Azimuth( , ) +``` +## Parameters + +| Parameters | Instructions | +|----------|------------------------------------------------| +| `` | The first point used to calculate the azimuth | +| `` | The second point used to calculate the azimuth | -Enter two point, and returns the azimuth of the line segment formed by points 1 and 2. The azimuth is the angle in radians measured between the line from point 1 facing true North to the line segment from point 1 to point 2. +## Return Value -The positive angle is measured clockwise on the surface of a sphere. For example, the azimuth for a line segment: +Positive angles are measured clockwise on the sphere. For example, the azimuth of a line segment: -* Pointing North is 0 -* Pointing East is PI/2 -* Pointing South is PI -* Pointing West is 3PI/2 +- North is 0 +- East is PI/2 +- The guide is PI +- The west is 3PI/2 ST_Azimuth has the following edge cases: -* If the two input points are the same, returns NULL. -* If the two input points are exactly antipodal, returns NULL. -* If either of the input geographies are not single points or are the empty geography, throws an error. +- Return NULL if both input points are the same. +- NULL is returned if the two input points are perfect mapping points. +- An error is thrown if any of the input geographies are not a single point or are empty geographies -### example +## Examples +```sql +SELECT st_azimuth(ST_Point(1, 0),ST_Point(0, 0)); ``` -mysql> SELECT st_azimuth(ST_Point(1, 0),ST_Point(0, 0)); + +```text +----------------------------------------------------+ | st_azimuth(st_point(1.0, 0.0), st_point(0.0, 0.0)) | +----------------------------------------------------+ | 4.71238898038469 | +----------------------------------------------------+ -1 row in set (0.03 sec) +``` -mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(1, 0)); +```sql +SELECT st_azimuth(ST_Point(0, 0),ST_Point(1, 0)); +``` + +```text +----------------------------------------------------+ | st_azimuth(st_point(0.0, 0.0), st_point(1.0, 0.0)) | +----------------------------------------------------+ | 1.5707963267948966 | +----------------------------------------------------+ -1 row in set (0.01 sec) +``` + +```sql +SELECT st_azimuth(ST_Point(0, 0),ST_Point(0, 1)); +``` -mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(0, 1)); +```text +----------------------------------------------------+ | st_azimuth(st_point(0.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------+ | 0 | +----------------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> SELECT st_azimuth(ST_Point(0, 1),ST_Point(0, 1)); -+----------------------------------------------------+ -| st_azimuth(st_point(0.0, 1.0), st_point(0.0, 1.0)) | -+----------------------------------------------------+ -| NULL | -+----------------------------------------------------+ -1 row in set (0.02 sec) +```sql +SELECT st_azimuth(ST_Point(-30, 0),ST_Point(150, 0)); +``` -mysql> SELECT st_azimuth(ST_Point(-30, 0),ST_Point(150, 0)); +```text +--------------------------------------------------------+ | st_azimuth(st_point(-30.0, 0.0), st_point(150.0, 0.0)) | +--------------------------------------------------------+ | NULL | +--------------------------------------------------------+ -1 row in set (0.02 sec) - ``` -### keywords -ST_AZIMUTH,ST,AZIMUTH + diff --git a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md index 5b9750a1cf021..8e16a6befe79d 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md +++ b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md @@ -24,25 +24,41 @@ specific language governing permissions and limitations under the License. --> -## ST_Circle -### Description -#### Syntax +## Description -`GEOMETRY ST_Circle(DOUBLE center_lng, DOUBLE center_lat, DOUBLE radius)` +Convert a WKT (Well Known Text) to a circle on the sphere of the Earth. +## Syntax -Convert a WKT (Well Known Text) into a circle on the earth's sphere. Where `center_lng'denotes the longitude of the center of a circle, -` Center_lat` denotes the latitude of the center of a circle, radius` denotes the radius of a circle in meters. +```sql +ST_Circle( , , ) +``` + +## Parameters + +| Parameters | Instructions | +| -- | -- | +| `` | Longitude of the center of the circle | +| `` | The latitude of the center of the circle | +| `` | Radius of a circle | + +- The unit of radius is meters. A maximum of 9999999 RADIUS is supported -### example +## Return Value +A circle on a sphere based on basic information about the circle + +## Examples + +```sql +SELECT ST_AsText(ST_Circle(111, 64, 10000)); ``` -mysql> SELECT ST_AsText(ST_Circle(111, 64, 10000)); + +```text +--------------------------------------------+ | st_astext(st_circle(111.0, 64.0, 10000.0)) | +--------------------------------------------+ | CIRCLE ((111 64), 10000) | +--------------------------------------------+ ``` -### keywords -ST_CIRCLE,ST,CIRCLE + diff --git a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md index a3ab1214b0ccf..6454cce61403a 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md +++ b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md @@ -24,32 +24,52 @@ specific language governing permissions and limitations under the License. --> -## ST_Contains -### Description -#### Syntax +## Description -`BOOL ST_Contains(GEOMETRY shape1, GEOMETRY shape2)` +Determines whether the geometry shape1 is fully capable of containing the geometry shape2 +## Syntax -Judging whether geometric shape 1 can contain geometric shape 2 completely +```sql +ST_Contains( , ) +``` + +## Parameters + +| Parameters | Instructions | +|----------|------------------------| +| `` | The passed geometry used to determine whether shape2 is included | +| `` | The passed geometry is used to determine whether shape1 is included | + +## Return Value + +Return 1:shape1 The graph can contain the graph shape2 -### example +Return 0:shape1 Graph cannot contain graph shape2 +## Examples + +```sql +SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(5, 5)); ``` -mysql> SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(5, 5)); + +```text +----------------------------------------------------------------------------------------+ | st_contains(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'), st_point(5.0, 5.0)) | +----------------------------------------------------------------------------------------+ | 1 | +----------------------------------------------------------------------------------------+ +``` + +```sql +SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(50, 50)); +``` -mysql> SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(50, 50)); +```text +------------------------------------------------------------------------------------------+ | st_contains(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'), st_point(50.0, 50.0)) | +------------------------------------------------------------------------------------------+ | 0 | +------------------------------------------------------------------------------------------+ ``` -### keywords -ST_CONTAINS,ST,CONTAINS diff --git a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md index a50fc65625b1f..e1b5c76a90d9d 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md +++ b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md @@ -24,27 +24,40 @@ specific language governing permissions and limitations under the License. --> -## ST_Distance_Sphere -### description -#### Syntax +## Description -`DOUBLE ST_Distance_Sphere(DOUBLE x_lng, DOUBLE x_lat, DOUBLE y_lng, DOUBLE y_lat)` +Calculate the spherical distance in meters between two points on the Earth. The parameters passed in are the longitude of point X, latitude of point X, longitude of point Y, and latitude of point Y. +## Syntax -Calculate the spherical distance between two points of the earth in meters. The incoming parameters are the longitude of point X, the latitude of point X, the longitude of point Y and the latitude of point Y. +```sql +ST_Distance_Sphere( , , , ) +``` + +## Parameters + +| Parameters | Instructions | +| -- | -- | +| `` | Longitude data, reasonable value range is [-180, 180] | +| `` | Longitude data, reasonable value range is [-180, 180] | +| `` | Latitude data, reasonable value range is [-90, 90] | +| `` | Latitude data, reasonable value range is [-90, 90] | -x_lng and y_lng are Longitude values, must be in the range [-180, 180]. -x_lat and y_lat are Latitude values, must be in the range [-90, 90]. +## Return Value -### example +The spherical distance between two points +## Examples + +```sql +select st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); ``` -mysql> select st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); + +```text +----------------------------------------------------------------------------+ | st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219) | +----------------------------------------------------------------------------+ | 7336.9135549995917 | +----------------------------------------------------------------------------+ ``` -### keywords -ST_DISTANCE_SPHERE,ST,DISTANCE,SPHERE + diff --git a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md index 28072a02016d0..b0068482233f0 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md +++ b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md @@ -24,24 +24,35 @@ specific language governing permissions and limitations under the License. --> -## ST_GeometryFromText,ST_GeomFromText -### Description -#### Syntax +## Description -`GEOMETRY ST_GeometryFromText (VARCHAR wkt)` +Convert a linear WKT (Well Known Text) to the corresponding memory geometry +## Syntax -Converting a WKT (Well Known Text) into a corresponding memory geometry +```sql +ST_GeometryFromText( ) +``` +## Parameters + +| Parameters | Instructions | +|------------|---------| +| `` | The memory form of the graph | + +## Return Value -### example +The corresponding geometric storage form of WKB +## Examples + +```sql +SELECT ST_AsText(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); ``` -mysql> SELECT ST_AsText(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); + +```text +---------------------------------------------------------+ | st_astext(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +---------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +---------------------------------------------------------+ -``` -### keywords -ST_GEOMETRYFROMTEXT,ST_GEOMFROMTEXT,ST,GEOMETRYFROMTEXT,GEOMFROMTEXT +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md index bf0a47f4b5903..ed7366c2e0939 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md +++ b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md @@ -24,59 +24,83 @@ specific language governing permissions and limitations under the License. --> -## ST_GeometryFromWKB,ST_GeomFromWKB +## Description -### Syntax +Converts a standard figure WKB (Well-known binary) to the corresponding memory geometry -`GEOMETRY ST_GeometryFromWKB(VARCHAR WKB)` +## Syntax -### Description +```sql +ST_GeometryFromWKB( ) +``` +## Parameters + +| Parameters | Instructions | +|------------|---------| +| `` | The memory form of the graph | + +## Return Value -Converting a standard WKB (Well-known binary) into a corresponding memory geometry +The corresponding geometric storage form of WKB -### example +## Examples +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); ``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); + +```text +------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_point(24.7, 56.7)))) | +------------------------------------------------------------------+ | POINT (24.7 56.7) | +------------------------------------------------------------------+ -1 row in set (0.05 sec) +``` -mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); +```sql +select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); +``` + +```text +--------------------------------------------------------------+ | st_astext(st_geomfromwkb(st_asbinary(st_point(24.7, 56.7)))) | +--------------------------------------------------------------+ | POINT (24.7 56.7) | +--------------------------------------------------------------+ -1 row in set (0.03 sec) +``` + +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")))); +``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")))); +```text +------------------------------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')))) | +------------------------------------------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +------------------------------------------------------------------------------------------+ -1 row in set (0.06 sec) +``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +``` + +```text +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) +``` -mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +```sql +select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +``` + +```text +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_astext(st_geomfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) | +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) | +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) - -``` -### keywords -ST_GEOMETRYFROMWKB,ST_GEOMFROMWKB,ST,GEOMETRYFROMWKB,GEOMFROMWKB,WKB +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md index 3a033103b1580..9fa5f0f4b8e37 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md +++ b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_LineFromText,ST_LineStringFromText -### Description -#### Syntax +## Description -`GEOMETRY ST LineFromText (VARCHAR wkt)` +Converts a WKT (Well Known Text) to a memory representation in the form of a Line +## Syntax -Converting a WKT (Well Known Text) into a Line-style memory representation +```sql +ST_LineFromText( ) +``` + +## Parameters + +| Parameters | Instructions | +|-----|------------| +| `` | A line segment consisting of two coordinates | + +## Return Value -### example +The memory form of a line segment. +## Examples + +```sql +SELECT ST_AsText(ST_LineFromText("LINESTRING (1 1, 2 2)")); ``` -mysql> SELECT ST_AsText(ST_LineFromText("LINESTRING (1 1, 2 2)")); + +```text +---------------------------------------------------------+ | st_astext(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +---------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +---------------------------------------------------------+ -``` -### keywords -ST_LINEFROMTEXT, ST_LINESTRINGFROMTEXT,ST,LINEFROMTEXT,LINESTRINGFROMTEXT +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md index 050f41a31ad88..661fdac7ee6e1 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md +++ b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md @@ -24,25 +24,38 @@ specific language governing permissions and limitations under the License. --> -## St_Point -### Description -#### Syntax +## Description -`POINT ST_Point(DOUBLE x, DOUBLE y)` +With the given X coordinate value, the Y coordinate value returns the corresponding Point. +The current value is only meaningful in the sphere set, X/Y corresponds to longitude/latitude; -Given the X coordinate value, the Y coordinate value returns the corresponding Point. -The current value is meaningful only for spherical sets, and X/Y corresponds to longitude/latitude. +## Syntax -### example +```sql +ST_Point( , ) +``` +## Parameters + +| Parameters | Instructions | +|-----|--------------| +| `` | x-coordinate | +| `` | y-coordinate | + +## Return Value + +Given horizontal coordinate and vertical coordinate corresponding position information +## Examples + +```sql +SELECT ST_AsText(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_AsText(ST_Point(24.7, 56.7)); + +```text +---------------------------------+ | st_astext(st_point(24.7, 56.7)) | +---------------------------------+ | POINT (24.7 56.7) | +---------------------------------+ -``` -### keywords -ST_POINT,ST,POINT +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md index 226736bb2d64c..aa282b328bab1 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md +++ b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md @@ -24,25 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_Polygon,ST_PolyFromText,ST_PolygonFromText -### Description -#### Syntax +## Description -`GEOMETRY ST_Polygon (VARCHAR wkt)` +Convert a WKT (Well Known Text) to the corresponding polygonal memory form +## Syntax -Converting a WKT (Well Known Text) into a corresponding polygon memory form +```sql +ST_Polygon( ) +``` + +## Parameters + +| Parameters | Instructions | +|------|--------------------| +| `` | A POLYGON generated by the polygon function | +## Return Value -#### example +Memory form of polygon +## Examples + +```sql +SELECT ST_AsText(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))")); ``` -mysql> SELECT ST_AsText(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))")); + +```text +------------------------------------------------------------------+ | st_astext(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))')) | +------------------------------------------------------------------+ | POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0)) | +------------------------------------------------------------------+ ``` -### keywords -ST_POLYGON,ST_POLYFROMTEXT,ST_POLYGONFROMTEXT,ST,POLYGON,POLYFROMTEXT,POLYGONFROMTEXT diff --git a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md index a00eb050cfc13..7324fe6226bb1 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md +++ b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_X -### Description -#### Syntax +## Description -`DOUBLE ST_X(POINT point)` +When point is a valid POINT type, return the corresponding x-coordinate value +## Syntax -When point is a valid POINT type, the corresponding X coordinate value is returned. +```sql +ST_X( ) +``` + +## Parameters + +| Parameters | Instructions | +|------|----------| +| `` | The geometric coordinates of a two-dimensional point | + +## Return Value -### example +X value in geometric coordinates +## Examples + +```sql +SELECT ST_X(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_X(ST_Point(24.7, 56.7)); + +```text +----------------------------+ | st_x(st_point(24.7, 56.7)) | +----------------------------+ | 24.7 | +----------------------------+ -``` -### keywords -ST_X,ST,X +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md index eec67131b9ad3..de27d59df8015 100644 --- a/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md +++ b/docs/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_Y -### Description -#### Syntax +## Description -`DOUBLE ST_Y(POINT point)` +When point is a valid POINT type, return the corresponding y-coordinate value +## Syntax -When point is a valid POINT type, the corresponding Y coordinate value is returned. +```sql +ST_Y( ) +``` + +## Parameters + +| Parameters | Instructions | +|------|----------| +| `` | The geometric coordinates of a two-dimensional point | + +## Return Value -### example +Y value in geometric coordinates +## Examples + +```sql +SELECT ST_Y(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_Y(ST_Point(24.7, 56.7)); + +```text +----------------------------+ -| st_y(st_point(24.7, 56.7)) | +| st_x(st_point(24.7, 56.7)) | +----------------------------+ -| 56.7 | +| 24.7 | +----------------------------+ -``` -### keywords -ST_Y,ST,Y +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-functions/table-valued-functions/hdfs.md b/docs/sql-manual/sql-functions/table-valued-functions/hdfs.md index 7748a302ab48b..bc67b22c632a5 100644 --- a/docs/sql-manual/sql-functions/table-valued-functions/hdfs.md +++ b/docs/sql-manual/sql-functions/table-valued-functions/hdfs.md @@ -92,7 +92,7 @@ File format parameters: other kinds of parameters: - `path_partition_keys`: (optional) Specifies the column names carried in the file path. For example, if the file path is /path/to/city=beijing/date="2023-07-09", you should fill in `path_partition_keys="city,date"`. It will automatically read the corresponding column names and values from the path during load process. -- `resource`:(optional)Specify the resource name. Hdfs Tvf can use the existing Hdfs resource to directly access Hdfs. You can refer to the method for creating an Hdfs resource: [CREATE-RESOURCE](../../sql-statements/Data-Definition-Statements/Create/CREATE-RESOURCE.md). This property is supported starting from version 2.1.4. +- `resource`:(optional)Specify the resource name. Hdfs Tvf can use the existing Hdfs resource to directly access Hdfs. You can refer to the method for creating an Hdfs resource: [CREATE-RESOURCE](../../sql-statements/cluster-management/compute-management/CREATE-RESOURCE). This property is supported starting from version 2.1.4. :::tip Tip To directly query a TVF or create a VIEW based on that TVF, you need to have usage permission for that resource. To query a VIEW created based on TVF, you only need select permission for that VIEW. diff --git a/docs/sql-manual/sql-functions/table-valued-functions/s3.md b/docs/sql-manual/sql-functions/table-valued-functions/s3.md index b27a504d4b9f4..efb98941dab98 100644 --- a/docs/sql-manual/sql-functions/table-valued-functions/s3.md +++ b/docs/sql-manual/sql-functions/table-valued-functions/s3.md @@ -104,7 +104,7 @@ The following 2 parameters are used for loading in csv format other parameter: - `path_partition_keys`: (optional) Specifies the column names carried in the file path. For example, if the file path is /path/to/city=beijing/date="2023-07-09", you should fill in `path_partition_keys="city,date"`. It will automatically read the corresponding column names and values from the path during load process. -- `resource`:(optional)Specify the resource name. S3 tvf can use the existing S3 resource to directly access S3. You can refer to the method for creating an S3 resource: [CREATE-RESOURCE](../../sql-statements/Data-Definition-Statements/Create/CREATE-RESOURCE.md). This property is supported starting from version 2.1.4 . +- `resource`:(optional)Specify the resource name. S3 tvf can use the existing S3 resource to directly access S3. You can refer to the method for creating an S3 resource: [CREATE-RESOURCE](../../sql-statements/cluster-management/compute-management/CREATE-RESOURCE). This property is supported starting from version 2.1.4 . :::tip Tip To directly query a TVF or create a VIEW based on that TVF, you need to have usage permission for that resource. To query a VIEW created based on TVF, you only need select permission for that VIEW. diff --git a/docs/sql-manual/sql-statements/Account-Management-Statements/ALTER-ROLE.md b/docs/sql-manual/sql-statements/Account-Management-Statements/ALTER-ROLE.md deleted file mode 100644 index 7c2885e91f463..0000000000000 --- a/docs/sql-manual/sql-statements/Account-Management-Statements/ALTER-ROLE.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -{ - "title": "ALTER-ROLE", - "language": "en" -} ---- - - - -## ALTER ROLE - -### Name - -ALTER ROLE - -### Description - -Statement used to modify a role - -```sql - ALTER ROLE role_name comment; -``` - -### Example - -1. Modify the role's comment - - ```sql - ALTER ROLE role1 COMMENT "this is my first role"; - ``` - -### Keywords - - ALTER, ROLE - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Account-Management-Statements/ALTER-USER.md b/docs/sql-manual/sql-statements/Account-Management-Statements/ALTER-USER.md deleted file mode 100644 index 21751f32008cb..0000000000000 --- a/docs/sql-manual/sql-statements/Account-Management-Statements/ALTER-USER.md +++ /dev/null @@ -1,106 +0,0 @@ ---- -{ - "title": "ALTER-USER", - "language": "en" -} ---- - - - -## ALTER USER - -### Name - -ALTER USER - -### Description - -The ALTER USER command is used to modify a user's account attributes, including passwords, and password policies, etc. - ->Note that. -> ->This command give over supports modifying user roles from versions 2.0. Please use [GRANT](./GRANT.md) and [REVOKE](./REVOKE.md) for related operations - -```sql -ALTER USER [IF EXISTS] user_identity [IDENTIFIED BY 'password'] -[password_policy] -[comment] - -user_identity: - 'user_name'@'host' - -password_policy: - - 1. PASSWORD_HISTORY [n|DEFAULT] - 2. PASSWORD_EXPIRE [DEFAULT|NEVER|INTERVAL n DAY/HOUR/SECOND] - 3. FAILED_LOGIN_ATTEMPTS n - 4. PASSWORD_LOCK_TIME [n DAY/HOUR/SECOND|UNBOUNDED] - 5. ACCOUNT_UNLOCK -``` - -About `user_identity` and `password_policy`, Please refer to `CREATE USER`. - -`ACCOUNT_UNLOCK` is used to unlock a locked user. - -In an ALTER USER command, only one of the following account attributes can be modified at the same time: - -1. Change password -2. Modify `PASSWORD_HISTORY` -3. Modify `PASSWORD_EXPIRE` -4. Modify `FAILED_LOGIN_ATTEMPTS` and `PASSWORD_LOCK_TIME` -5. Unlock users - -### Example - -1. Change the user's password - - ``` - ALTER USER jack@'%' IDENTIFIED BY "12345"; - ``` - -2. Modify the user's password policy - - ``` - ALTER USER jack@'%' FAILED_LOGIN_ATTEMPTS 3 PASSWORD_LOCK_TIME 1 DAY; - ``` - -3. Unlock a user - - ``` - ALTER USER jack@'%' ACCOUNT_UNLOCK - ``` - -4. Modify the user's comment - - ``` - ALTER USER jack@'%' COMMENT "this is my first user" - ``` - -### Keywords - - ALTER, USER - -### Best Practice - -1. Modify the password policy - - 1. Modify `PASSWORD_EXPIRE` will reset the timing of password expiration time. - - 2. Modify `FAILED_LOGIN_ATTEMPTS` or `PASSWORD_LOCK_TIME` will unlock the user. \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/Account-Management-Statements/CREATE-ROLE.md b/docs/sql-manual/sql-statements/Account-Management-Statements/CREATE-ROLE.md deleted file mode 100644 index cade9de366063..0000000000000 --- a/docs/sql-manual/sql-statements/Account-Management-Statements/CREATE-ROLE.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -{ - "title": "CREATE-ROLE", - "language": "en" -} ---- - - - -## CREATE-ROLE - -### Name - -CREATE ROLE - -### Description - -The statement user creates a role - -```sql - CREATE ROLE role_name [comment]; -``` - -This statement creates an unprivileged role, which can be subsequently granted with the GRANT command. - -### Example - -1. Create a role - - ```sql - CREATE ROLE role1; - ``` - -2. Create a role with comment - - ```sql - CREATE ROLE role2 COMMENT "this is my first role"; - ``` - -### Keywords - - CREATE, ROLE - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Account-Management-Statements/CREATE-USER.md b/docs/sql-manual/sql-statements/Account-Management-Statements/CREATE-USER.md deleted file mode 100644 index 7fdcf924ad0b1..0000000000000 --- a/docs/sql-manual/sql-statements/Account-Management-Statements/CREATE-USER.md +++ /dev/null @@ -1,139 +0,0 @@ ---- -{ - "title": "CREATE-USER", - "language": "en" -} ---- - - - -## CREATE-USER - -### Name - -CREATE USER - -### Description - -The CREATE USER command is used to create a Doris user. - -```sql -CREATE USER [IF EXISTS] user_identity [IDENTIFIED BY 'password'] -[DEFAULT ROLE 'role_name'] -[password_policy] -[comment] - -user_identity: - 'user_name'@'host' - -password_policy: - - 1. PASSWORD_HISTORY [n|DEFAULT] - 2. PASSWORD_EXPIRE [DEFAULT|NEVER|INTERVAL n DAY/HOUR/SECOND] - 3. FAILED_LOGIN_ATTEMPTS n - 4. PASSWORD_LOCK_TIME [n DAY/HOUR/SECOND|UNBOUNDED] -``` - -In Doris, a user_identity uniquely identifies a user. user_identity consists of two parts, user_name and host, where username is the username. host Identifies the host address where the client connects. The host part can use % for fuzzy matching. If no host is specified, it defaults to '%', which means the user can connect to Doris from any host. - -The host part can also be specified as a domain, the syntax is: 'user_name'@['domain'], even if it is surrounded by square brackets, Doris will think this is a domain and try to resolve its ip address. . - -If a role (ROLE) is specified, the newly created user will be automatically granted the permissions of the role. If not specified, the user has no permissions by default. The specified ROLE must already exist. - -`password_policy` is a clause used to specify policies related to password authentication login. Currently, the following policies are supported: - -1. `PASSWORD_HISTORY` - - Whether to allow the current user to use historical passwords when resetting their passwords. For example, `PASSWORD_HISTORY 10` means that it is forbidden to use the password set in the past 10 times as a new password. If set to `PASSWORD_HISTORY DEFAULT`, the value in the global variable `password_history` will be used. `0` means do not enable this feature. Default is 0. - -2. `PASSWORD_EXPIRE` - - Set the expiration time of the current user's password. For example `PASSWORD_EXPIRE INTERVAL 10 DAY` means the password will expire in 10 days. `PASSWORD_EXPIRE NEVER` means that the password does not expire. If set to `PASSWORD_EXPIRE DEFAULT`, the value in the global variable `default_password_lifetime` is used. Defaults to NEVER (or 0), which means it will not expire. - -3. `FAILED_LOGIN_ATTEMPTS` and `PASSWORD_LOCK_TIME` - - When the current user logs in, if the user logs in with the wrong password for n times, the account will be locked, and the lock time is set. For example, `FAILED_LOGIN_ATTEMPTS 3 PASSWORD_LOCK_TIME 1 DAY` means that if you log in wrongly for 3 times, the account will be locked for one day. - - A locked account can be actively unlocked through the `ALTER USER` statement. - -### Example - -1. Create a passwordless user (if host is not specified, it is equivalent to jack@'%') - - ```sql - CREATE USER 'jack'; - ``` - -2. Create a user with a password to allow login from '172.10.1.10' - - ```sql - CREATE USER jack@'172.10.1.10' IDENTIFIED BY '123456'; - ``` - -3. In order to avoid passing plaintext, use case 2 can also be created in the following way - - ```sql - CREATE USER jack@'172.10.1.10' IDENTIFIED BY PASSWORD '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9'; - The encrypted content can be obtained through PASSWORD(), for example: - SELECT PASSWORD('123456'); - ``` - -4. Create a user that is allowed to log in from the '192.168' subnet, and specify its role as example_role - - ```sql - CREATE USER 'jack'@'192.168.%' DEFAULT ROLE 'example_role'; - ``` - -5. Create a user that is allowed to log in from the domain 'example_domain' - - ```sql - CREATE USER 'jack'@['example_domain'] IDENTIFIED BY '12345'; - ``` - -6. Create a user and assign a role - - ```sql - CREATE USER 'jack'@'%' IDENTIFIED BY '12345' DEFAULT ROLE 'my_role'; - ``` - -7. Create a user, set the password to expire after 10 days, and set the account to be locked for one day if you log in failed for 3 times. - - ```sql - CREATE USER 'jack' IDENTIFIED BY '12345' PASSWORD_EXPIRE INTERVAL 10 DAY FAILED_LOGIN_ATTEMPTS 3 PASSWORD_LOCK_TIME 1 DAY; - ``` - -8. Create a user and restrict non-resetable passwords to the last 8 passwords used. - - ```sql - CREATE USER 'jack' IDENTIFIED BY '12345' PASSWORD_HISTORY 8; - ``` - -9. Create a user with comment - - ```sql - CREATE USER 'jack' COMMENT "this is my first user"; - ``` - -### Keywords - - CREATE, USER - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Account-Management-Statements/DROP-ROLE.md b/docs/sql-manual/sql-statements/Account-Management-Statements/DROP-ROLE.md deleted file mode 100644 index b8196ef7504c6..0000000000000 --- a/docs/sql-manual/sql-statements/Account-Management-Statements/DROP-ROLE.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -{ - "title": "DROP-ROLE", - "language": "en" -} ---- - - - -## DROP-ROLE - -### Description - -The statement user removes a role - -```sql - DROP ROLE [IF EXISTS] role1; -``` - -Deleting a role does not affect the permissions of users who previously belonged to the role. It is only equivalent to decoupling the role from the user. The permissions that the user has obtained from the role will not change - -### Example - -1. Drop a role1 - -```sql -DROP ROLE role1; -``` - -### Keywords - - DROP, ROLE - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Account-Management-Statements/DROP-USER.md b/docs/sql-manual/sql-statements/Account-Management-Statements/DROP-USER.md deleted file mode 100644 index ee5a877b2058a..0000000000000 --- a/docs/sql-manual/sql-statements/Account-Management-Statements/DROP-USER.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -{ - "title": "DROP-USER", - "language": "en" -} ---- - - - -## DROP-USER - -### Name - -DROP USER - -### Description - -Delete a user - -```sql - DROP USER 'user_identity' - - `user_identity`: - - user@'host' - user@['domain'] -``` - - Delete the specified user identitiy. - -### Example - -1. Delete user jack@'192.%' - - ```sql - DROP USER 'jack'@'192.%' - ``` - -### Keywords - - DROP, USER - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Account-Management-Statements/GRANT.md b/docs/sql-manual/sql-statements/Account-Management-Statements/GRANT.md deleted file mode 100644 index e98dca480983c..0000000000000 --- a/docs/sql-manual/sql-statements/Account-Management-Statements/GRANT.md +++ /dev/null @@ -1,188 +0,0 @@ ---- -{ - "title": "GRANT", - "language": "en" -} ---- - - - -## Description - -The GRANT command is used to: - -1. Grant specified privileges to a user or role. -2. Grant specified roles to a user. - -## Syntax - -GRANT privilege_list ON priv_level TO user_identity [ROLE role_name] - -GRANT privilege_list ON RESOURCE resource_name TO user_identity [ROLE role_name] - -GRANT privilege_list ON WORKLOAD GROUP workload_group_name TO user_identity [ROLE role_name] - -GRANT privilege_list ON COMPUTE GROUP compute_group_name TO user_identity [ROLE role_name] - -GRANT privilege_list ON STORAGE VAULT storage_vault_name TO user_identity [ROLE role_name] - -GRANT role_list TO user_identity - -## Parameters - -### privilege_list - -A comma-separated list of privileges to be granted. Currently supported privileges include: - -- NODE_PRIV: Cluster node operation permissions, including node online and offline operations. -- ADMIN_PRIV: All privileges except NODE_PRIV. -- GRANT_PRIV: Privilege for operation privileges, including creating and deleting users, roles, authorization and revocation, setting passwords, etc. -- SELECT_PRIV: Read permission on the specified database or table. -- LOAD_PRIV: Import privileges on the specified database or table. -- ALTER_PRIV: Schema change permission for the specified database or table. -- CREATE_PRIV: Create permission on the specified database or table. -- DROP_PRIV: Drop privilege on the specified database or table. -- USAGE_PRIV: Access to the specified resource and Workload Group permissions. -- SHOW_VIEW_PRIV: Permission to view `view` creation statements. - -Legacy privilege conversion: -- ALL and READ_WRITE will be converted to: SELECT_PRIV, LOAD_PRIV, ALTER_PRIV, CREATE_PRIV, DROP_PRIV. -- READ_ONLY is converted to SELECT_PRIV. - -### priv_level - -Supports the following four forms: - -- *.*.*: Privileges can be applied to all catalogs and all databases and tables within them. -- catalog_name.*.*: Privileges can be applied to all databases and tables in the specified catalog. -- catalog_name.db.*: Privileges can be applied to all tables under the specified database. -- catalog_name.db.tbl: Privileges can be applied to the specified table under the specified database. - -### resource_name - -Specifies the resource name, supporting `%` and `*` to match all resources, but does not support wildcards, such as res*. - -### workload_group_name - -Specifies the workload group name, supporting `%` and `*` to match all workload groups, but does not support wildcards. - -### compute_group_name - -Specifies the compute group name, supporting `%` and `*` to match all compute groups, but does not support wildcards. - -### storage_vault_name - -Specifies the storage vault name, supporting `%` and `*` to match all storage vaults, but does not support wildcards. - -### user_identity - -Specifies the user to receive the privileges. Must be a user_identity created with CREATE USER. The host in user_identity can be a domain name. If it is a domain name, the effective time of the authority may be delayed by about 1 minute. - -### role_name - -Specifies the role to receive the privileges. If the specified role does not exist, it will be created automatically. - -### role_list - -A comma-separated list of roles to be assigned. The specified roles must exist. - -## Examples - -1. Grant permissions to all catalogs and databases and tables to the user: - - GRANT SELECT_PRIV ON *.*.* TO 'jack'@'%'; - -2. Grant permissions to the specified database table to the user: - - GRANT SELECT_PRIV,ALTER_PRIV,LOAD_PRIV ON ctl1.db1.tbl1 TO 'jack'@'192.8.%'; - -3. Grant permissions to the specified database table to the role: - - GRANT LOAD_PRIV ON ctl1.db1.* TO ROLE 'my_role'; - -4. Grant access to all resources to users: - - GRANT USAGE_PRIV ON RESOURCE * TO 'jack'@'%'; - -5. Grant the user permission to use the specified resource: - - GRANT USAGE_PRIV ON RESOURCE 'spark_resource' TO 'jack'@'%'; - -6. Grant access to specified resources to roles: - - GRANT USAGE_PRIV ON RESOURCE 'spark_resource' TO ROLE 'my_role'; - -7. Grant the specified role to a user: - - GRANT 'role1','role2' TO 'jack'@'%'; - -8. Grant the specified workload group 'g1' to user jack: - - GRANT USAGE_PRIV ON WORKLOAD GROUP 'g1' TO 'jack'@'%'; - -9. Match all workload groups granted to user jack: - - GRANT USAGE_PRIV ON WORKLOAD GROUP '%' TO 'jack'@'%'; - -10. Grant the workload group 'g1' to the role my_role: - - GRANT USAGE_PRIV ON WORKLOAD GROUP 'g1' TO ROLE 'my_role'; - -11. Allow jack to view the creation statement of view1 under db1: - - GRANT SHOW_VIEW_PRIV ON db1.view1 TO 'jack'@'%'; - -12. Grant user permission to use the specified compute group: - - GRANT USAGE_PRIV ON COMPUTE GROUP 'group1' TO 'jack'@'%'; - -13. Grant role permission to use the specified compute group: - - GRANT USAGE_PRIV ON COMPUTE GROUP 'group1' TO ROLE 'my_role'; - -14. Grant user permission to use all compute groups: - - GRANT USAGE_PRIV ON COMPUTE GROUP '*' TO 'jack'@'%'; - -15. Grant user permission to use the specified storage vault: - - GRANT USAGE_PRIV ON STORAGE VAULT 'vault1' TO 'jack'@'%'; - -16. Grant role permission to use the specified storage vault: - - GRANT USAGE_PRIV ON STORAGE VAULT 'vault1' TO ROLE 'my_role'; - -17. Grant user permission to use all storage vaults: - - GRANT USAGE_PRIV ON STORAGE VAULT '*' TO 'jack'@'%'; - -## Related Commands - -- [REVOKE](./REVOKE.md) -- [SHOW GRANTS](../Show-Statements/SHOW-GRANTS.md) -- [CREATE ROLE](./CREATE-ROLE.md) -- [CREATE WORKLOAD GROUP](../Administration-Statements/CREATE-WORKLOAD-GROUP.md) -- [CREATE COMPUTE GROUP](../Administration-Statements/CREATE-COMPUTE-GROUP.md) -- [CREATE RESOURCE](../Administration-Statements/CREATE-RESOURCE.md) -- [CREATE STORAGE VAULT](../Administration-Statements/CREATE-STORAGE-VAULT.md) - -## Keywords - - GRANT, WORKLOAD GROUP, COMPUTE GROUP, RESOURCE diff --git a/docs/sql-manual/sql-statements/Account-Management-Statements/LDAP.md b/docs/sql-manual/sql-statements/Account-Management-Statements/LDAP.md deleted file mode 100644 index 1df5e667f1c91..0000000000000 --- a/docs/sql-manual/sql-statements/Account-Management-Statements/LDAP.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -{ - "title": "LDAP", - "language": "en" -} ---- - - - -## LDAP - -### Name - -LDAP - -### Description - -SET LDAP_ADMIN_PASSWORD - -```sql - SET LDAP_ADMIN_PASSWORD = PASSWORD('plain password') -``` - - The SET LDAP_ADMIN_PASSWORD command is used to set the LDAP administrator password. When using LDAP authentication, doris needs to use the administrator account and password to query the LDAP service for login user information. - -### Example - -1. Set the LDAP administrator password - -```sql -SET LDAP_ADMIN_PASSWORD = PASSWORD('123456') -``` - -### Keywords - - LDAP, PASSWORD, LDAP_ADMIN_PASSWORD - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Account-Management-Statements/REVOKE.md b/docs/sql-manual/sql-statements/Account-Management-Statements/REVOKE.md deleted file mode 100644 index 722afe606647f..0000000000000 --- a/docs/sql-manual/sql-statements/Account-Management-Statements/REVOKE.md +++ /dev/null @@ -1,156 +0,0 @@ ---- -{ - "title": "REVOKE", - "language": "en" -} ---- - - - -## Description - -The REVOKE command is used to: - -1. Revoke specified privileges from a user or role. -2. Revoke specified roles previously granted to a user. - -## Syntax - -REVOKE privilege_list ON priv_level FROM user_identity [ROLE role_name] - -REVOKE privilege_list ON RESOURCE resource_name FROM user_identity [ROLE role_name] - -REVOKE privilege_list ON WORKLOAD GROUP workload_group_name FROM user_identity [ROLE role_name] - -REVOKE privilege_list ON COMPUTE GROUP compute_group_name FROM user_identity [ROLE role_name] - -REVOKE privilege_list ON STORAGE VAULT storage_vault_name FROM user_identity [ROLE role_name] - -REVOKE role_list FROM user_identity - -## Parameters - -### privilege_list - -A comma-separated list of privileges to be revoked. Supported privileges include: - -- NODE_PRIV: Cluster node operation permissions -- ADMIN_PRIV: Administrator privileges -- GRANT_PRIV: Authorization privileges -- SELECT_PRIV: Query privileges -- LOAD_PRIV: Data import privileges -- ALTER_PRIV: Modification privileges -- CREATE_PRIV: Creation privileges -- DROP_PRIV: Deletion privileges -- USAGE_PRIV: Usage privileges -- SHOW_VIEW_PRIV: Privileges to view view definitions - -### priv_level - -Specifies the scope of the privileges. Supported formats: - -- *.*.*: All catalogs, databases, and tables -- catalog_name.*.*: All databases and tables in the specified catalog -- catalog_name.db.*: All tables in the specified database -- catalog_name.db.tbl: Specific table in the specified database - -### resource_name - -Specifies the resource scope. Supports % (matches any string) and _ (matches any single character) wildcards. - -### workload_group_name - -Specifies the workload group name. Supports % (matches any string) and _ (matches any single character) wildcards. - -### compute_group_name - -Specifies the compute group name. Supports % (matches any string) and _ (matches any single character) wildcards. - -### storage_vault_name - -Specifies the storage vault name. Supports % (matches any string) and _ (matches any single character) wildcards. - -### user_identity - -Specifies the user from whom privileges are being revoked. Must be a user created with CREATE USER. The host in user_identity can be a domain name. If it's a domain name, the revocation of privileges may be delayed by about 1 minute. - -### role_name - -Specifies the role from which privileges are being revoked. The role must exist. - -### role_list - -A comma-separated list of roles to be revoked. All specified roles must exist. - -## Examples - -1. Revoke SELECT privilege on a specific database from a user: - - REVOKE SELECT_PRIV ON db1.* FROM 'jack'@'192.%'; - -2. Revoke usage privilege on a resource from a user: - - REVOKE USAGE_PRIV ON RESOURCE 'spark_resource' FROM 'jack'@'192.%'; - -3. Revoke roles from a user: - - REVOKE 'role1','role2' FROM 'jack'@'192.%'; - -4. Revoke usage privilege on a workload group from a user: - - REVOKE USAGE_PRIV ON WORKLOAD GROUP 'g1' FROM 'jack'@'%'; - -5. Revoke usage privilege on all workload groups from a user: - - REVOKE USAGE_PRIV ON WORKLOAD GROUP '%' FROM 'jack'@'%'; - -6. Revoke usage privilege on a workload group from a role: - - REVOKE USAGE_PRIV ON WORKLOAD GROUP 'g1' FROM ROLE 'test_role'; - -7. Revoke usage privilege on a compute group from a user: - - REVOKE USAGE_PRIV ON COMPUTE GROUP 'group1' FROM 'jack'@'%'; - -8. Revoke usage privilege on a compute group from a role: - - REVOKE USAGE_PRIV ON COMPUTE GROUP 'group1' FROM ROLE 'my_role'; - -9. Revoke usage privilege on a storage vault from a user: - - REVOKE USAGE_PRIV ON STORAGE VAULT 'vault1' FROM 'jack'@'%'; - -10. Revoke usage privilege on a storage vault from a role: - - REVOKE USAGE_PRIV ON STORAGE VAULT 'vault1' FROM ROLE 'my_role'; - -## Related Commands - -- [GRANT](./GRANT.md) -- [SHOW GRANTS](../Show-Statements/SHOW-GRANTS.md) -- [CREATE ROLE](./CREATE-ROLE.md) -- [CREATE WORKLOAD GROUP](../Administration-Statements/CREATE-WORKLOAD-GROUP.md) -- [CREATE COMPUTE GROUP](../Administration-Statements/CREATE-COMPUTE-GROUP.md) -- [CREATE RESOURCE](../Administration-Statements/CREATE-RESOURCE.md) -- [CREATE STORAGE VAULT](../Administration-Statements/CREATE-STORAGE-VAULT.md) - -## Keywords - - REVOKE, WORKLOAD GROUP, COMPUTE GROUP, RESOURCE, STORAGE VAULT \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/Account-Management-Statements/SET-PASSWORD.md b/docs/sql-manual/sql-statements/Account-Management-Statements/SET-PASSWORD.md deleted file mode 100644 index eec4fb019659f..0000000000000 --- a/docs/sql-manual/sql-statements/Account-Management-Statements/SET-PASSWORD.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -{ - "title": "SET-PASSWORD", - "language": "en" -} ---- - - - -## SET-PASSWORD - -### Name - -SET PASSWORD - -### Description - -The SET PASSWORD command can be used to modify a user's login password. If the [FOR user_identity] field does not exist, then change the current user's password - -```sql -SET PASSWORD [FOR user_identity] = - [PASSWORD('plain password')]|['hashed password'] -``` - -Note that the user_identity here must exactly match the user_identity specified when creating a user with CREATE USER, otherwise an error will be reported that the user does not exist. If user_identity is not specified, the current user is 'username'@'ip', which may not match any user_identity. Current users can be viewed through SHOW GRANTS. - -The plaintext password is input in the PASSWORD() method; when using a string directly, the encrypted password needs to be passed. -To modify the passwords of other users, administrator privileges are required. - -### Example - -1. Modify the current user's password - - ```sql - SET PASSWORD = PASSWORD('123456') - SET PASSWORD = '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' - ``` - -2. Modify the specified user password - - ```sql - SET PASSWORD FOR 'jack'@'192.%' = PASSWORD('123456') - SET PASSWORD FOR 'jack'@['domain'] = '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' - ``` - -### Keywords - - SET, PASSWORD - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Account-Management-Statements/SET-PROPERTY.md b/docs/sql-manual/sql-statements/Account-Management-Statements/SET-PROPERTY.md deleted file mode 100644 index aab3003756a2a..0000000000000 --- a/docs/sql-manual/sql-statements/Account-Management-Statements/SET-PROPERTY.md +++ /dev/null @@ -1,128 +0,0 @@ ---- -{ - "title": "SET-PROPERTY", - "language": "en" -} ---- - - - -## Description - -Set user attributes, including resources assigned to users, importing clusters, compute groups etc. - -## Syntax - -```sql -SET PROPERTY [FOR 'user'] 'key' = 'value' [, 'key' = 'value'] -``` - -The user attribute set here is for user, not user_identity. That is, if two users 'jack'@'%' and 'jack'@'192.%' are created through the CREATE USER statement, the SET PROPERTY statement can only be used for the user jack, not 'jack'@'% ' or 'jack'@'192.%' - -## Parameters - -### user - -The username for which to set attributes. If omitted, the attributes are set for the current user. - -### key - -The attribute key to set. Available keys include: - -- `max_user_connections`: The maximum number of connections. -- `max_query_instances`: The number of instances that a user can use to execute a query at the same time. -- `sql_block_rules`: Set SQL block rules. Once set, queries sent by this user will be rejected if they match the rules. -- `cpu_resource_limit`: Limit the CPU resources for queries. See the introduction to the session variable `cpu_resource_limit` for details. -1 means not set. -- `exec_mem_limit`: Limit the memory usage of the query. See the introduction to the session variable `exec_mem_limit` for details. -1 means not set. -- `resource_tags`: Specifies the user's resource tag permissions. -- `query_timeout`: Specifies the user's query timeout. -- `default_workload_group`: Specifies the user's default workload group. -- `default_compute_group`: Specifies the user's default compute group. - -Note: If the attributes `cpu_resource_limit` and `exec_mem_limit` are not set, the value in the session variable will be used by default. - -### value - -The value to set for the specified key. - -## Example - -1. Modify the maximum number of user jack connections to 1000 - - ```sql - SET PROPERTY FOR 'jack' 'max_user_connections' = '1000'; - ``` - -2. Modify the number of available instances for user jack's query to 3000 - - ```sql - SET PROPERTY FOR 'jack' 'max_query_instances' = '3000'; - ``` - -3. Modify the sql block rule of user jack - - ```sql - SET PROPERTY FOR 'jack' 'sql_block_rules' = 'rule1, rule2'; - ``` - -4. Modify the cpu usage limit of user jack - - ```sql - SET PROPERTY FOR 'jack' 'cpu_resource_limit' = '2'; - ``` - -5. Modify the user's resource tag permissions - - ```sql - SET PROPERTY FOR 'jack' 'resource_tags.location' = 'group_a, group_b'; - ``` - -6. Modify the user's query memory usage limit, in bytes - - ```sql - SET PROPERTY FOR 'jack' 'exec_mem_limit' = '2147483648'; - ``` - -7. Modify the user's query timeout limit, in second - - ```sql - SET PROPERTY FOR 'jack' 'query_timeout' = '500'; - ``` - -8. Set the default workload group for user 'jack': - - ```sql - SET PROPERTY FOR 'jack' 'default_workload_group' = 'group1'; - ``` - -9. Set the default compute group for user 'jack': - - ```sql - SET PROPERTY FOR 'jack' 'default_compute_group' = 'compute_group1'; - ``` - -## Related Commands - -- [CREATE USER](./CREATE-USER.md) -- [SHOW PROPERTY](../Show-Statements/SHOW-PROPERTY.md) - -## Keywords - - SET, PROPERTY, COMPUTE GROUP, WORKLOAD GROUP diff --git a/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-BACKEND.md b/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-BACKEND.md deleted file mode 100644 index bb82e4b546a79..0000000000000 --- a/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-BACKEND.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -{ - "title": "ALTER-SYSTEM-ADD-BACKEND", - "language": "en" -} ---- - - - -## Description - -The ADD BACKEND command is used to add one or more backend nodes to a Doris OLAP database cluster. This command allows administrators to specify the host and port of the new backend nodes, along with optional properties that configure their behavior. - -## Syntax - -```sql --- Add nodes (add this method if you do not use the multi-tenancy function) - ALTER SYSTEM ADD BACKEND "host:heartbeat_port"[,"host:heartbeat_port"...] [PROPERTIES ("key"="value", ...)]; -``` - -## Parameters - -* `host` can be a hostname or an ip address of the backend node while `heartbeat_port` is the heartbeat port of the node -* `PROPERTIES ("key"="value", ...)`: (Optional) A set of key-value pairs that define additional properties for the backend nodes. These properties can be used to customize the configuration of the backends being added. Available properties include: - - * tag.location: Specifies the resource group where the backend node belongs. For example, PROPERTIES ("tag.location" = "groupb"). - * tag.compute_group_name: Specifies the resource group where the backend node belongs. For example, PROPERTIES ("tag.compute_group_name" = "groupb"). - -## Example - - 1. Adding Backends Without Additional Properties - - ```sql - ALTER SYSTEM ADD BACKEND "host1:9050,host2:9050"; - ```` - - This command adds two backend nodes to the cluster: - - * host1 with port 9050 - * host2 with port 9050 - - No additional properties are specified, so the default settings will apply to these backends. - -2. Adding Backends With Resource Group - - ```sql - ALTER SYSTEM ADD BACKEND "host3:9050" PROPERTIES ("tag.location" = "groupb"); - ```` - - This command adds a single backend node (host3 with port 9050) to the cluster in resource group `groupb`: - -3. Adding Backends With Compute Group - - ```sql - ALTER SYSTEM ADD BACKEND "host3:9050" PROPERTIES ("tag.compute_group_name" = "groupb"); - ```` - - This command adds a single backend node (host3 with port 9050) to the cluster in compute group `groupb`: - -## Keywords - - ALTER, SYSTEM, ADD, BACKEND, PROPERTIES - -## Best Practice diff --git a/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-BROKER.md b/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-BROKER.md deleted file mode 100644 index f880bf881f2ee..0000000000000 --- a/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-BROKER.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -{ - "title": "ALTER-SYSTEM-ADD-BROKER", - "language": "en" -} - ---- - - - -## ALTER-SYSTEM-ADD-BROKER - -### Name - -ALTER SYSTEM ADD BROKER - -### Description - -This statement is used to add a BROKER node. (Administrator only!) - -grammar: - -```sql -ALTER SYSTEM ADD BROKER broker_name "broker_host1:broker_ipc_port1","broker_host2:broker_ipc_port2",...; -``` - -### Example - -1. Add two brokers - - ```sql - ALTER SYSTEM ADD BROKER "host1:port", "host2:port"; - ``` -2. When fe enable fqdn([fqdn](../../../admin-manual/cluster-management/fqdn.md)),add one Broker - - ```sql - ALTER SYSTEM ADD BROKER "broker_fqdn1:port"; - ``` - -### Keywords - - ALTER, SYSTEM, ADD, FOLLOWER, ALTER SYSTEM - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-FOLLOWER.md b/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-FOLLOWER.md deleted file mode 100644 index c8ab559da737f..0000000000000 --- a/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-FOLLOWER.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -{ - "title": "ALTER-SYSTEM-ADD-FOLLOWER", - "language": "en" -} ---- - - - -## ALTER-SYSTEM-ADD-FOLLOWER - -### Name - -ALTER SYSTEM ADD FOLLOWER - -### Description - -This statement is to increase the node of the FOLLOWER role of FRONTEND, (only for administrators!) - -grammar: - -```sql -ALTER SYSTEM ADD FOLLOWER "follower_host:edit_log_port" -``` - -illustrate: - -1. host can be a hostname or an ip address -2. edit_log_port : edit_log_port in its configuration file fe.conf - -### Example - -1. Add a FOLLOWER node - - ```sql - ALTER SYSTEM ADD FOLLOWER "host_ip:9010" - ``` - -### Keywords - - ALTER, SYSTEM, ADD, FOLLOWER, ALTER SYSTEM - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-OBSERVER.md b/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-OBSERVER.md deleted file mode 100644 index 51c75502f6e3b..0000000000000 --- a/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-OBSERVER.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -{ - "title": "ALTER-SYSTEM-ADD-OBSERVER", - "language": "en" -} ---- - - - -## ALTER-SYSTEM-ADD-OBSERVER - -### Name - -ALTER SYSTEM ADD OBSERVER - -### Description - -This statement is to increase the node of the OBSERVER role of FRONTEND, (only for administrators!) - -grammar: - -```sql -ALTER SYSTEM ADD OBSERVER "follower_host:edit_log_port" -``` - -illustrate: - -1. host can be a hostname or an ip address -2. edit_log_port : edit_log_port in its configuration file fe.conf - -### Example - -1. Add an OBSERVER node - - ```sql - ALTER SYSTEM ADD OBSERVER "host_ip:9010" - ``` - -### Keywords - - ALTER, SYSTEM, ADD, OBSERVER, ALTER SYSTEM - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DECOMMISSION-BACKEND.md b/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DECOMMISSION-BACKEND.md deleted file mode 100644 index e4a948217c24d..0000000000000 --- a/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DECOMMISSION-BACKEND.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -{ - "title": "ALTER-SYSTEM-DECOMMISSION-BACKEND", - "language": "en" -} ---- - - - -## ALTER-SYSTEM-DECOMMISSION-BACKEND - -### Name - -ALTER SYSTEM DECOMMISSION BACKEND - -### Description - -The node offline operation is used to safely log off the node. The operation is asynchronous. If successful, the node is eventually removed from the metadata. If it fails, the logout will not be done (only for admins!) - -grammar: - -- Find backend through host and port - -```sql -ALTER SYSTEM DECOMMISSION BACKEND "host:heartbeat_port"[,"host:heartbeat_port"...]; -``` - -- Find backend through backend_id - -```sql -ALTER SYSTEM DECOMMISSION BACKEND "id1","id2"...; -``` - - illustrate: - -1. host can be a hostname or an ip address -2. heartbeat_port is the heartbeat port of the node -3. The node offline operation is used to safely log off the node. The operation is asynchronous. If successful, the node is eventually removed from the metadata. If it fails, the logout will not be completed. -4. You can manually cancel the node offline operation. See CANCEL DECOMMISSION - -### Example - -1. Offline two nodes - - ```sql - ALTER SYSTEM DECOMMISSION BACKEND "host1:port", "host2:port"; - ``` - - ```sql - ALTER SYSTEM DECOMMISSION BACKEND "id1", "id2"; - ``` - -### Keywords - - ALTER, SYSTEM, DECOMMISSION, BACKEND, ALTER SYSTEM - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-BACKEND.md b/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-BACKEND.md deleted file mode 100644 index decedf91607e5..0000000000000 --- a/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-BACKEND.md +++ /dev/null @@ -1,73 +0,0 @@ ---- -{ - "title": "ALTER-SYSTEM-DROP-BACKEND", - "language": "en" -} ---- - - - -## ALTER-SYSTEM-DROP-BACKEND - -### Name - -ALTER SYSTEM DROP BACKEND - -### Description - -This statement is used to delete the BACKEND node (administrator only!) - -grammar: - -- Find backend through host and port - -```sql -ALTER SYSTEM DROP BACKEND "host:heartbeat_port"[,"host:heartbeat_port"...] -``` -- Find backend through backend_id - -```sql -ALTER SYSTEM DROP BACKEND "id1","id2"...; -``` - -illustrate: - -1. host can be a hostname or an ip address -2. heartbeat_port is the heartbeat port of the node -3. Adding and deleting nodes is a synchronous operation. These two operations do not consider the existing data on the node, and the node is directly deleted from the metadata, please use it with caution. - -### Example - -1. Delete two nodes - - ```sql - ALTER SYSTEM DROP BACKEND "host1:port", "host2:port"; - ``` - - ```sql - ALTER SYSTEM DROP BACKEND "ids1", "ids2"; - ``` - -### Keywords - - ALTER, SYSTEM, DROP, BACKEND, ALTER SYSTEM - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-BROKER.md b/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-BROKER.md deleted file mode 100644 index dc02eb9b55950..0000000000000 --- a/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-BROKER.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -{ - "title": "ALTER-SYSTEM-DROP-BROKER", - "language": "en" -} - ---- - - - -## ALTER-SYSTEM-DROP-BROKER - -### Name - -ALTER SYSTEM DROP BROKER - -### Description - -This statement is to delete the BROKER node, (administrator only) - -grammar: - -```sql --- Delete all brokers -ALTER SYSTEM DROP ALL BROKER broker_name --- Delete a Broker node -ALTER SYSTEM DROP BROKER broker_name "host:port"[,"host:port"...]; -``` - -### Example - -1. Delete all brokers - - ```sql - ALTER SYSTEM DROP ALL BROKER broker_name - ``` - -2. Delete a Broker node - - ```sql - ALTER SYSTEM DROP BROKER broker_name "host:port"[,"host:port"...]; - ``` - -### Keywords - - ALTER, SYSTEM, DROP, FOLLOWER, ALTER SYSTEM - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-FOLLOWER.md b/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-FOLLOWER.md deleted file mode 100644 index 6d58250d96000..0000000000000 --- a/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-FOLLOWER.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -{ - "title": "ALTER-SYSTEM-DROP-FOLLOWER", - "language": "en" -} ---- - - - - -## Name - -ALTER SYSTEM DROP FOLLOWER - -## Description - -This statement is to delete the node of the FOLLOWER role of FRONTEND, (only for administrators!) - -Grammar: - -```sql -ALTER SYSTEM DROP FOLLOWER "follower_host:edit_log_port" -``` - -Illustration: - -1. host can be a hostname or an ip address - -2. edit_log_port : edit_log_port in its configuration file fe.conf - -## Example - -1. Delete a FOLLOWER node - - ```sql - ALTER SYSTEM DROP FOLLOWER "host_ip:9010" - ``` - -## Keywords - -ALTER, SYSTEM, DROP, FOLLOWER, ALTER SYSTEM - - diff --git a/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-OBSERVER.md b/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-OBSERVER.md deleted file mode 100644 index 1a47c79e56a97..0000000000000 --- a/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-OBSERVER.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -{ - "title": "ALTER-SYSTEM-DROP-OBSERVER", - "language": "en" -} ---- - - - -## ALTER-SYSTEM-DROP-OBSERVER - -### Name - -ALTER SYSTEM DROP OBSERVER - -### Description - -This statement is to delete the node of the OBSERVER role of FRONTEND, (only for administrators!) - -grammar: - -```sql -ALTER SYSTEM DROP OBSERVER "follower_host:edit_log_port" -``` - -illustrate: - -1. host can be a hostname or an ip address -2. edit_log_port : edit_log_port in its configuration file fe.conf - -### Example - -1. Add a FOLLOWER node - - ```sql - ALTER SYSTEM DROP OBSERVER "host_ip:9010" - ``` - -### Keywords - - ALTER, SYSTEM, DROP, OBSERVER, ALTER SYSTEM - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-MODIFY-BACKEND.md b/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-MODIFY-BACKEND.md deleted file mode 100644 index 158a9aec2c06d..0000000000000 --- a/docs/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-MODIFY-BACKEND.md +++ /dev/null @@ -1,104 +0,0 @@ ---- -{ - "title": "ALTER-SYSTEM-MODIFY-BACKEND", - "language": "en" -} - ---- - - - -## ALTER-SYSTEM-MODIFY-BACKEND - -### Name - -ALTER SYSTEM MKDIFY BACKEND - -### Description - -Modify BE node properties (administrator only!) - -grammar: - -- Find backend through host and port - -```sql -ALTER SYSTEM MODIFY BACKEND "host:heartbeat_port" SET ("key" = "value"[, ...]); -``` - -- Find backend through backend_id - -```sql -ALTER SYSTEM MODIFY BACKEND "id1" SET ("key" = "value"[, ...]); -``` - - illustrate: - -1. host can be a hostname or an ip address -2. heartbeat_port is the heartbeat port of the node -3. Modify BE node properties The following properties are currently supported: - -- tag.xxxx: resource tag -- disable_query: query disable attribute -- disable_load: import disable attribute - -Note: -1. A backend can be set multi resource tags. But must contain "tag.location" type. - -### Example - -1. Modify the resource tag of BE - - ```sql - ALTER SYSTEM MODIFY BACKEND "host1:heartbeat_port" SET ("tag.location" = "group_a"); - ALTER SYSTEM MODIFY BACKEND "host1:heartbeat_port" SET ("tag.location" = "group_a", "tag.compute" = "c1"); - ``` - - ```sql - ALTER SYSTEM MODIFY BACKEND "id1" SET ("tag.location" = "group_a"); - ALTER SYSTEM MODIFY BACKEND "id1" SET ("tag.location" = "group_a", "tag.compute" = "c1"); - ``` - -2. Modify the query disable property of BE - - ```sql - ALTER SYSTEM MODIFY BACKEND "host1:heartbeat_port" SET ("disable_query" = "true"); - ``` - - ```sql - ALTER SYSTEM MODIFY BACKEND "id1" SET ("disable_query" = "true"); - ``` - -3. Modify the import disable property of BE - - ```sql - ALTER SYSTEM MODIFY BACKEND "host1:heartbeat_port" SET ("disable_load" = "true"); - ``` - - ```sql - ALTER SYSTEM MODIFY BACKEND "id1" SET ("disable_load" = "true"); - ``` - -### Keywords - - ALTER, SYSTEM, ADD, BACKEND, ALTER SYSTEM - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Cluster-Management-Statements/CANCEL-ALTER-SYSTEM.md b/docs/sql-manual/sql-statements/Cluster-Management-Statements/CANCEL-ALTER-SYSTEM.md deleted file mode 100644 index 604f286509473..0000000000000 --- a/docs/sql-manual/sql-statements/Cluster-Management-Statements/CANCEL-ALTER-SYSTEM.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -{ - "title": "CANCEL-ALTER-SYSTEM", - "language": "en" -} ---- - - - -## CANCEL-ALTER-SYSTEM - -### Name - -CANCEL DECOMMISSION - -### Description - -This statement is used to undo a node offline operation. (Administrator only!) - -grammar: - -- Find backend through host and port - -```sql -CANCEL DECOMMISSION BACKEND "host:heartbeat_port"[,"host:heartbeat_port"...]; -``` - -- Find backend through backend_id - -```sql -CANCEL DECOMMISSION BACKEND "id1","id2","id3..."; -``` - -### Example - - 1. Cancel the offline operation of both nodes: - - ```sql - CANCEL DECOMMISSION BACKEND "host1:port", "host2:port"; - ``` - - 2. Cancel the offline operation of the node with backend_id 1: - - ```sql - CANCEL DECOMMISSION BACKEND "1","2"; - ``` - -### Keywords - - CANCEL, DECOMMISSION, CANCEL ALTER - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-ASYNC-MATERIALIZED-VIEW.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-ASYNC-MATERIALIZED-VIEW.md deleted file mode 100644 index f03862af38210..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-ASYNC-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,98 +0,0 @@ ---- -{ - "title": "ALTER-ASYNC-MATERIALIZED-VIEW", - "language": "en" -} ---- - - - -## ALTER-ASYNC-MATERIALIZED-VIEW - -### Name - -ALTER ASYNC MATERIALIZED VIEW - -### Description - -This statement is used to modify asynchronous materialized views. - -#### syntax - -```sql -ALTER MATERIALIZED VIEW mvName=multipartIdentifier ((RENAME newName=identifier) - | (REFRESH (refreshMethod | refreshTrigger | refreshMethod refreshTrigger)) - | REPLACE WITH MATERIALIZED VIEW newName=identifier propertyClause? - | (SET LEFT_PAREN fileProperties=propertyItemList RIGHT_PAREN)) -``` - -#### illustrate - -##### RENAME - -Used to change the name of the materialized view - -For example, changing the name of mv1 to mv2 -```sql -ALTER MATERIALIZED VIEW mv1 rename mv2; -``` - -##### refreshMethod - -Same as [creating asynchronous materialized views](../Create/CREATE-ASYNC-MATERIALIZED-VIEW.md) - -##### refreshTrigger - -Same as [creating asynchronous materialized views](../Create/CREATE-ASYNC-MATERIALIZED-VIEW.md) - -##### SET -Modify properties unique to materialized views - -For example, modifying the grace_period of mv1 to 3000ms -```sql -ALTER MATERIALIZED VIEW mv1 set("grace_period"="3000"); -``` - -##### REPLACE -```sql -ALTER MATERIALIZED VIEW [db.]mv1 REPLACE WITH MATERIALIZED VIEW mv2 -[PROPERTIES('swap' = 'true')]; -``` -Replacing atoms with two materialized views - -swap default is TRUE -- If the swap parameter is set to TRUE, it is equivalent to renaming the materialized view mv1 to mv2, and renaming mv2 to mv1 at the same time -- If the swap parameter is set to FALSE, it is equivalent to renaming mv2 to mv1 and deleting the original mv1 - -For example, if you want to swap the names of mv1 and mv2 -```sql -ALTER MATERIALIZED VIEW db1.mv1 REPLACE WITH MATERIALIZED VIEW mv2; -``` - -For example, if you want to rename mv2 to mv1 and delete the original mv1 -```sql -ALTER MATERIALIZED VIEW db1.mv1 REPLACE WITH MATERIALIZED VIEW mv2 -PROPERTIES('swap' = 'false'); -``` - -### Keywords - - ALTER, ASYNC, MATERIALIZED, VIEW - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-CATALOG.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-CATALOG.md deleted file mode 100644 index 3a18da64892af..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-CATALOG.md +++ /dev/null @@ -1,94 +0,0 @@ ---- -{ - "title": "ALTER-CATALOG", - "language": "en" -} ---- - - - -## ALTER-CATALOG - -### Name - -ALTER CATALOG - -### Description - -This statement is used to set properties of the specified catalog. (administrator only) - -1) Rename the catalog - -```sql -ALTER CATALOG catalog_name RENAME new_catalog_name; -``` - -illustrate: -- The builtin catalog `internal` cannot be renamed -- Only the one who has at least Alter privilege can rename a catalog -- After renaming the catalog, use the REVOKE and GRANT commands to modify the appropriate user permissions - -2) Modify / add properties for the catalog - -```sql -ALTER CATALOG catalog_name SET PROPERTIES ('key1' = 'value1' [, 'key' = 'value2']); -``` - -Update values of specified keys. If a key does not exist in the catalog properties, it will be added. - -illustrate: -- property `type` cannot be modified. -- properties of builtin catalog `internal` cannot be modified. - -3) Modify comment for the catalog - -```sql -ALTER CATALOG catalog_name MODIFY COMMENT "new catalog comment"; -``` - -illustrate: -- The builtin catalog `internal` cannot be modified - -### Example - -1. rename catalog ctlg_hive to hive - -```sql -ALTER CATALOG ctlg_hive RENAME hive; -``` - -3. modify property `hive.metastore.uris` of catalog hive - -```sql -ALTER CATALOG hive SET PROPERTIES ('hive.metastore.uris'='thrift://172.21.0.1:9083'); -``` - -4. modify comment of catalog hive - -```sql -ALTER CATALOG hive MODIFY COMMENT "new catalog comment"; -``` - -### Keywords - -ALTER,CATALOG,RENAME,PROPERTY - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-COLOCATE-GROUP.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-COLOCATE-GROUP.md deleted file mode 100644 index 243032f3a98a6..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-COLOCATE-GROUP.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -{ -"title": "ALTER-COLOCATE-GROUP", -"language": "en" -} ---- - - - -## ALTER-COLOCATE-GROUP - -### Name - -ALTER COLOCATE GROUP - -### Description - -This statement is used to modify the colocation group. - -Syntax: - -```sql -ALTER COLOCATE GROUP [database.]group -SET ( - property_list -); -``` - -NOTE: - -1. If the colocate group is global, that is, its name starts with `__global__`, then it does not belong to any database; - -2. property_list is a colocation group attribute, currently only supports modifying `replication_num` and `replication_allocation`. After modifying these two attributes of the colocation group, at the same time, change the attribute `default.replication_allocation`, the attribute `dynamic.replication_allocation` of the table of the group, and the `replication_allocation` of the existing partition to be the same as it. - -### Example - -1. Modify the number of copies of a global group - - ```sql - # Set "colocate_with" = "__global__foo" when creating the table - - ALTER COLOCATE GROUP __global__foo - SET ( - "replication_num"="1" - ); - ``` - -2. Modify the number of copies of a non-global group - - ```sql - # Set "colocate_with" = "bar" when creating the table, and the Database is "example_db" - - ALTER COLOCATE GROUP example_db.bar - SET ( - "replication_num"="1" - ); - ``` - -### Keywords - -```sql -ALTER, COLOCATE, GROUP -``` - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-DATABASE.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-DATABASE.md deleted file mode 100644 index f1b361e3edf75..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-DATABASE.md +++ /dev/null @@ -1,110 +0,0 @@ ---- -{ - "title": "ALTER-DATABASE", - "language": "en" -} ---- - - - -## ALTER-DATABASE - -### Name - -ALTER DATABASE - -### Description - -This statement is used to set properties of the specified database. (administrator only) - -1) Set the database data quota, the unit is B/K/KB/M/MB/G/GB/T/TB/P/PB - -```sql -ALTER DATABASE db_name SET DATA QUOTA quota; -``` - -2) Rename the database - -```sql -ALTER DATABASE db_name RENAME new_db_name; -``` - -3) Set the quota for the number of copies of the database - -```sql -ALTER DATABASE db_name SET REPLICA QUOTA quota; -``` - -illustrate: - After renaming the database, use the REVOKE and GRANT commands to modify the appropriate user permissions, if necessary. - The default data quota for the database is 1024GB, and the default replica quota is 1073741824. - -4) Modify the properties of an existing database - -```sql -ALTER DATABASE db_name SET PROPERTIES ("key"="value", ...); -``` - -### Example - -1. Set the specified database data volume quota - -```sql -ALTER DATABASE example_db SET DATA QUOTA 10995116277760; -The above unit is bytes, which is equivalent to -ALTER DATABASE example_db SET DATA QUOTA 10T; - -ALTER DATABASE example_db SET DATA QUOTA 100G; - -ALTER DATABASE example_db SET DATA QUOTA 200M; -``` - -2. Rename the database example_db to example_db2 - -```sql -ALTER DATABASE example_db RENAME example_db2; -``` - -3. Set the quota for the number of copies of the specified database - -```sql -ALTER DATABASE example_db SET REPLICA QUOTA 102400; -``` - -4. Modify the default replica distribution policy for tables in db (this operation only applies to newly created tables and will not modify existing tables in db) - -```sql -ALTER DATABASE example_db SET PROPERTIES("replication_allocation" = "tag.location.default:2"); -``` - -5. Cancel the default replica distribution policy for tables in db (this operation only applies to newly created tables and will not modify existing tables in db) - -```sql -ALTER DATABASE example_db SET PROPERTIES("replication_allocation" = ""); -``` - -### Keywords - -```text -ALTER,DATABASE,RENAME -``` - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-RESOURCE.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-RESOURCE.md deleted file mode 100644 index fc5c3ba1dc5e1..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-RESOURCE.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -{ -"title": "ALTER-RESOURCE", -"language": "en" -} ---- - - - -## ALTER-RESOURCE - -### Name - -ALTER RESOURCE - -### Description - -This statement is used to modify an existing resource. Only the root or admin user can modify resources. -Syntax: -```sql -ALTER RESOURCE 'resource_name' -PROPERTIES ("key"="value", ...); -``` - -Note: The resource type does not support modification. - -### Example - -1. Modify the working directory of the Spark resource named spark0: - -```sql -ALTER RESOURCE 'spark0' PROPERTIES ("working_dir" = "hdfs://127.0.0.1:10000/tmp/doris_new"); -``` -2. Modify the maximum number of connections to the S3 resource named remote_s3: - -```sql -ALTER RESOURCE 'remote_s3' PROPERTIES ("s3.connection.maximum" = "100"); -``` - -3. Modify information related to cold and hot separation S3 resources -- Support - - `s3.access_key` s3 ak - - `s3.secret_key` s3 sk - - `s3.session_token` s3 token - - `s3.connection.maximum` default 50 - - `s3.connection.timeout` default 1000ms - - `s3.connection.request.timeout` default 3000ms -- Not Support - - `s3.region` - - `s3.bucket"` - - `s3.root.path` - - `s3.endpoint` - -```sql - ALTER RESOURCE "showPolicy_1_resource" PROPERTIES("s3.connection.maximum" = "1111"); -``` -### Keywords - -```text -ALTER, RESOURCE -``` - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-SQL-BLOCK-RULE.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-SQL-BLOCK-RULE.md deleted file mode 100644 index 7740972beb579..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-SQL-BLOCK-RULE.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -{ - "title": "ALTER-SQL-BLOCK-RULE", - "language": "en" -} ---- - - - -## ALTER-SQL-BLOCK-RULE - -### Name - -ALTER SQL BLOCK RULE - -### Description - -Modify SQL blocking rules to allow modification of each item such as sql/sqlHash/partition_num/tablet_num/cardinality/global/enable. - -grammar: - -```sql -ALTER SQL_BLOCK_RULE rule_name -[PROPERTIES ("key"="value", ...)]; -``` - -illustrate: - -- sql and sqlHash cannot be set at the same time. This means that if a rule sets sql or sqlHash, the other attribute cannot be modified; -- sql/sqlHash and partition_num/tablet_num/cardinality cannot be set at the same time. For example, if a rule sets partition_num, then sql or sqlHash cannot be modified; - -### Example - -1. Modify according to SQL properties - -```sql -ALTER SQL_BLOCK_RULE test_rule PROPERTIES("sql"="select \\* from test_table","enable"="true") -``` - -2. If a rule sets partition_num, then sql or sqlHash cannot be modified - -```sql -ALTER SQL_BLOCK_RULE test_rule2 PROPERTIES("partition_num" = "10","tablet_num"="300","enable"="true") -``` - -### Keywords - -```text -ALTER,SQL_BLOCK_RULE -``` - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-STORAGE-POLICY.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-STORAGE-POLICY.md deleted file mode 100644 index 30b44285c050e..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-STORAGE-POLICY.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -{ -"title": "ALTER-POLICY", -"language": "en" -} ---- - - - -## ALTER-POLICY - -### Name - -ALTER STORAGE POLICY - -### Description - -This statement is used to modify an existing cold and hot separation migration strategy. Only root or admin users can modify resources. - -```sql -ALTER STORAGE POLICY 'policy_name' -PROPERTIES ("key"="value", ...); -``` - -### Example - -1. Modify the name to coolown_datetime Cold and hot separation data migration time point: -```sql -ALTER STORAGE POLICY has_test_policy_to_alter PROPERTIES("cooldown_datetime" = "2023-06-08 00:00:00"); -``` -2. Modify the name to coolown_countdown of hot and cold separation data migration of ttl -```sql -ALTER STORAGE POLICY has_test_policy_to_alter PROPERTIES ("cooldown_ttl" = "10000"); -ALTER STORAGE POLICY has_test_policy_to_alter PROPERTIES ("cooldown_ttl" = "1h"); -ALTER STORAGE POLICY has_test_policy_to_alter PROPERTIES ("cooldown_ttl" = "3d"); -``` -### Keywords - -```sql -ALTER, STORAGE, POLICY -``` - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-AND-GENERATED-COLUMN.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-AND-GENERATED-COLUMN.md deleted file mode 100644 index 92793613bdfa3..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-AND-GENERATED-COLUMN.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -{ - "title": "ALTER-TABLE-AND-GENERATED-COLUMN", - "language": "en" -} ---- - - - -## ALTER TABLE and generated columns -The ALTER TABLE ADD COLUMN is not supported for adding a generated column, and the ALTER TABLE MODIFY COLUMN is not supported for modifying generated column information. -The ALTER TABLE syntax is supported for modifying the order of generated columns, modifying the names of generated columns, and deleting generated columns. - -The following error is reported for unsupported scenarios: - -```sql -mysql> CREATE TABLE test_alter_add_column(a int, b int) properties("replication_num"="1"); -Query OK, 0 rows affected (0.14 sec) -mysql> ALTER TABLE test_alter_add_column ADD COLUMN c int AS (a+b); -ERROR 1105 (HY000): errCode = 2, detailMessage = Not supporting alter table add generated columns. -mysql> ALTER TABLE test_alter MODIFY COLUMN c int KEY AS (a+b+1); -ERROR 1105 (HY000): errCode = 2, detailMessage = Not supporting alter table modify generated columns. -``` - -### REORDER COLUMN - -```sql -ALTER TABLE products ORDER BY (product_id, total_value, price, quantity); -``` - -Note: -The modified column order still needs to meet the order restrictions when generating columns and creating tables. -### RENAME COLUMN - -```sql -ALTER TABLE products RENAME COLUMN total_value new_name; -``` - -Note: -If a column in a table (generated column or common column) is referenced by other generated columns, you need to delete the other generated columns before you can modify the name of this generated column. -### DROP COLUMN - -```sql -ALTER TABLE products DROP COLUMN total_value; -``` - -Note: -If a column in a table (generated column or ordinary column) is referenced by other generated columns, you need to delete the other generated columns first before deleting the referenced generated column or ordinary column. diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-COLUMN.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-COLUMN.md deleted file mode 100644 index 7897540a60d57..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-COLUMN.md +++ /dev/null @@ -1,309 +0,0 @@ ---- -{ - "title": "ALTER-TABLE-COLUMN", - "language": "en" -} ---- - - - -## Name - -ALTER TABLE COLUMN - -### Description - -This statement is used to perform a schema change operation on an existing table. The schema change is asynchronous, and the task is returned when the task is submitted successfully. After that, you can use the [SHOW ALTER TABLE COLUMN](../../Show-Statements/SHOW-ALTER.md) command to view the progress. - -Doris has the concept of materialized index after table construction. After successful table construction, it is the base table and the materialized index is the base index. rollup index can be created based on the base table. Both base index and rollup index are materialized indexes. If rollup_index_name is not specified during the schema change operation, the operation is based on the base table by default. - -:::tip -Doris 1.2.0 supports light schema change for light scale structure changes, and addition and subtraction operations for value columns can be completed more quickly and synchronously. You can manually specify "light_schema_change" = 'true' when creating a table. This parameter is enabled by default for versions 2.0.0 and later. -::: - -### Grammar: - -```sql -ALTER TABLE [database.]table alter_clause; -``` - -The alter_clause of schema change supports the following modification methods: - -**1. Add a column to the specified position at the specified index** - -**Grammar** - -```sql -ALTER TABLE [database.]table table_name ADD COLUMN column_name column_type [KEY | agg_type] [DEFAULT "default_value"] -[AFTER column_name|FIRST] -[TO rollup_index_name] -[PROPERTIES ("key"="value", ...)] -``` - -**Example** - -1. Add a key column new_col to example_db.my_table after key_1 (non-aggregated model) - - ```sql - ALTER TABLE example_db.my_table - ADD COLUMN new_col INT KEY DEFAULT "0" AFTER key_1; - ``` - -2. Add a value column new_col to example_db.my_table after value_1 (non-aggregate model) - - ```sql - ALTER TABLE example_db.my_table - ADD COLUMN new_col INT DEFAULT "0" AFTER value_1; - ``` - -3. Add a key column new_col (aggregate model) to example_db.my_table after key_1 - - ```sql - ALTER TABLE example_db.my_table - ADD COLUMN new_col INT KEY DEFAULT "0" AFTER key_1; - ``` - -4. Add a value column to example_db.my_table after value_1 new_col SUM Aggregation type (aggregation model) - - ```sql - ALTER TABLE example_db.my_table - ADD COLUMN new_col INT SUM DEFAULT "0" AFTER value_1; - ``` - -5. Add new_col to the first column position of the example_db.my_table table (non-aggregated model) - - ```sql - ALTER TABLE example_db.my_table - ADD COLUMN new_col INT KEY DEFAULT "0" FIRST; - ``` - -:::tip -- If you add a value column to the aggregation model, you need to specify agg_type -- For non-aggregated models (such as DUPLICATE KEY), if you add a key column, you need to specify the KEY keyword -- You cannot add columns that already exist in the base index to the rollup index (you can recreate a rollup index if necessary) -::: - - -**2. Add multiple columns to the specified index** - -**Grammar** - -```sql -ALTER TABLE [database.]table table_name ADD COLUMN (column_name1 column_type [KEY | agg_type] DEFAULT "default_value", ...) -[TO rollup_index_name] -[PROPERTIES ("key"="value", ...)] -``` - - -**Example** - -1. Add multiple columns to example_db.my_table, where new_col and new_col2 are SUM aggregate types (aggregate model) - - ```sql - ALTER TABLE example_db.my_table - ADD COLUMN (new_col1 INT SUM DEFAULT "0" ,new_col2 INT SUM DEFAULT "0"); - ``` - -2. Add multiple columns to example_db.my_table (non-aggregated model), where new_col1 is the KEY column and new_col2 is the value column - - ```sql - ALTER TABLE example_db.my_table - ADD COLUMN (new_col1 INT key DEFAULT "0" , new_col2 INT DEFAULT "0"); - ``` - -:::tip - - If you add a value column to the aggregation model, you need to specify agg_type - - If you add a key column to the aggregation model, you need to specify the KEY keyword - - You cannot add columns that already exist in the base index to the rollup index (you can recreate a rollup index if necessary) -::: - -**3. Delete a column from the specified index** - -**Grammar*** - - ```sql - ALTER TABLE [database.]table table_name DROP COLUMN column_name - [FROM rollup_index_name] - ``` - -**Example** - -1. Delete column col1 from example_db.my_table - - ```sql - ALTER TABLE example_db.my_table DROP COLUMN col1; - ``` - -:::tip - - Cannot drop partition column - - The aggregate model cannot delete KEY columns - - If the column is removed from the base index, it will also be removed if it is included in the rollup index -::: - -**4. Modify the column type and column position of the specified index** - -**Grammar** - -```sql -ALTER TABLE [database.]table table_name MODIFY COLUMN column_name column_type [KEY | agg_type] [NULL | NOT NULL] [DEFAULT "default_value"] -[AFTER column_name|FIRST] -[FROM rollup_index_name] -[PROPERTIES ("key"="value", ...)] -``` - -**Example** - -1. Modify the type of the key column col1 of the base index to BIGINT and move it to the back of the col2 column - - ```sql - ALTER TABLE example_db.my_table - MODIFY COLUMN col1 BIGINT KEY DEFAULT "1" AFTER col2; - ``` - - :::tip - Whether you modify the key column or the value column, you need to declare complete column information - ::: - -2. Modify the maximum length of the val1 column of base index. The original val1 is (val1 VARCHAR(32) REPLACE DEFAULT "abc") - - ```sql - ALTER TABLE example_db.my_table - MODIFY COLUMN val1 VARCHAR(64) REPLACE DEFAULT "abc"; - ``` - - :::tip - You can only modify the column's data type; other attributes of the column must remain unchanged. - ::: - -3. Modify the length of a field in the Key column of the Duplicate key table - - ```sql - ALTER TABLE example_db.my_table - MODIFY COLUMN k3 VARCHAR(50) KEY NULL COMMENT 'to 50'; - ``` - -:::tip - - If you modify the value column in the aggregation model, you need to specify agg_type - - If you modify the key column for non-aggregate types, you need to specify the KEY keyword - - Only the type of the column can be modified, and other attributes of the column remain as they are (that is, other attributes need to be explicitly written in the statement according to the original attributes, see example 8) - - Partitioning and bucketing columns cannot be modified in any way - - The following types of conversions are currently supported (loss of precision is guaranteed by the user) - - Conversion of TINYINT/SMALLINT/INT/BIGINT/LARGEINT/FLOAT/DOUBLE types to larger numeric types - - Convert TINTINT/SMALLINT/INT/BIGINT/LARGEINT/FLOAT/DOUBLE/DECIMAL to VARCHAR - - VARCHAR supports modifying the maximum length - - VARCHAR/CHAR converted to TINTINT/SMALLINT/INT/BIGINT/LARGEINT/FLOAT/DOUBLE - - Convert VARCHAR/CHAR to DATE (currently supports "%Y-%m-%d", "%y-%m-%d", "%Y%m%d", "%y%m%d", "%Y/%m/%d, "%y/%m/%d" six formats) - - Convert DATETIME to DATE (only keep year-month-day information, for example: `2019-12-09 21:47:05` <--> `2019-12-09`) - - DATE is converted to DATETIME (hours, minutes and seconds are automatically filled with zeros, for example: `2019-12-09` <--> `2019-12-09 00:00:00`) - - Convert FLOAT to DOUBLE - - INT is converted to DATE (if the INT type data is illegal, the conversion fails, and the original data remains unchanged) - - All can be converted to STRING except DATE and DATETIME, but STRING cannot be converted to any other type -::: - -**5. Reorder the column at the specified index** - -**Grammar** - - ```sql - ALTER TABLE [database.]table table_name ORDER BY (column_name1, column_name2, ...) - [FROM rollup_index_name] - [PROPERTIES ("key"="value", ...)] - ``` - -**Example** - -1. Adjust the order of the key and value columns of example_db.my_table (non-aggregate model) - - ```sql - CREATE TABLE `my_table`( - `k_1` INT NULL, - `k_2` INT NULL, - `v_1` INT NULL, - `v_2` varchar NULL, - `v_3` varchar NULL - ) ENGINE=OLAP - DUPLICATE KEY(`k_1`, `k_2`) - COMMENT 'OLAP' - DISTRIBUTED BY HASH(`k_1`) BUCKETS 5 - PROPERTIES ( - "replication_allocation" = "tag.location.default: 1" - ); - - ALTER TABLE example_db.my_table ORDER BY (k_2,k_1,v_3,v_2,v_1); - - mysql> desc my_table; - +-------+------------+------+-------+---------+-------+ - | Field | Type | Null | Key | Default | Extra | - +-------+------------+------+-------+---------+-------+ - | k_2 | INT | Yes | true | NULL | | - | k_1 | INT | Yes | true | NULL | | - | v_3 | VARCHAR(*) | Yes | false | NULL | NONE | - | v_2 | VARCHAR(*) | Yes | false | NULL | NONE | - | v_1 | INT | Yes | false | NULL | NONE | - +-------+------------+------+-------+---------+-------+ - ``` - -2. Do two actions simultaneously - - ```sql - CREATE TABLE `my_table` ( - `k_1` INT NULL, - `k_2` INT NULL, - `v_1` INT NULL, - `v_2` varchar NULL, - `v_3` varchar NULL - ) ENGINE=OLAP - DUPLICATE KEY(`k_1`, `k_2`) - COMMENT 'OLAP' - DISTRIBUTED BY HASH(`k_1`) BUCKETS 5 - PROPERTIES ( - "replication_allocation" = "tag.location.default: 1" - ); - - ALTER TABLE example_db.my_table - ADD COLUMN col INT DEFAULT "0" AFTER v_1, - ORDER BY (k_2,k_1,v_3,v_2,v_1,col); - - mysql> desc my_table; - +-------+------------+------+-------+---------+-------+ - | Field | Type | Null | Key | Default | Extra | - +-------+------------+------+-------+---------+-------+ - | k_2 | INT | Yes | true | NULL | | - | k_1 | INT | Yes | true | NULL | | - | v_3 | VARCHAR(*) | Yes | false | NULL | NONE | - | v_2 | VARCHAR(*) | Yes | false | NULL | NONE | - | v_1 | INT | Yes | false | NULL | NONE | - | col | INT | Yes | false | 0 | NONE | - +-------+------------+------+-------+---------+-------+ - ``` - -:::tip - - All columns in index are written out - - the value column comes after the key column - - You can adjust the key column only within the range of the key column. The same applies to the value column -::: - -### Keywords - -```text -ALTER, TABLE, COLUMN, ALTER TABLE -``` - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-COMMENT.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-COMMENT.md deleted file mode 100644 index 4957ae25038f4..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-COMMENT.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -{ - "title": "ALTER-TABLE-COMMENT", - "language": "en" -} ---- - - - -## ALTER-TABLE-COMMENT - -### Name - -ALTER TABLE COMMENT - -### Description - -This statement is used to modify the comment of an existing table. The operation is synchronous, and the command returns to indicate completion. - -grammar: - -```sql -ALTER TABLE [database.]table alter_clause; -``` - -1. Modify table comment - -grammar: - -```sql -MODIFY COMMENT "new table comment"; -``` - -2. Modify column comment - -grammar: - -```sql -MODIFY COLUMN col1 COMMENT "new column comment"; -``` - -### Example - -1. Change the table1's comment to table1_comment - -```sql -ALTER TABLE table1 MODIFY COMMENT "table1_comment"; -``` - -2. Change the table1's col1 comment to table1_comment - -```sql -ALTER TABLE table1 MODIFY COLUMN col1 COMMENT "table1_col1_comment"; -``` - -### Keywords - -```text -ALTER, TABLE, COMMENT, ALTER TABLE -``` - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-PARTITION.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-PARTITION.md deleted file mode 100644 index 7288d1ccb64a3..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-PARTITION.md +++ /dev/null @@ -1,186 +0,0 @@ ---- -{ - "title": "ALTER-TABLE-PARTITION", - "language": "en" -} ---- - - - -## ALTER-TABLE-PARTITION - -### Name - -ALTER TABLE PARTITION - -### Description - -This statement is used to modify a table with a partition. - -This operation is synchronous, and the return of the command indicates the completion of the execution. - -grammar: - -```sql -ALTER TABLE [database.]table alter_clause; -``` - -The alter_clause of partition supports the following modification methods - -1. Add partition - -grammar: - -```sql -ADD PARTITION [IF NOT EXISTS] partition_name -partition_desc ["key"="value"] -[DISTRIBUTED BY HASH (k1[,k2 ...]) [BUCKETS num]] -``` - -Notice: - -- partition_desc supports the following two ways of writing - - VALUES LESS THAN [MAXVALUE|("value1", ...)] - - VALUES [("value1", ...), ("value1", ...)) -- The partition is left closed and right open. If the user only specifies the right boundary, the system will automatically determine the left boundary -- If the bucketing method is not specified, the bucketing method and bucket number used for creating the table would be automatically used -- If the bucketing method is specified, only the number of buckets can be modified, not the bucketing method or the bucketing column. If the bucketing method is specified but the number of buckets not be specified, the default value `10` will be used for bucket number instead of the number specified when the table is created. If the number of buckets modified, the bucketing method needs to be specified simultaneously. -- The ["key"="value"] section can set some attributes of the partition, see [CREATE TABLE](../Create/CREATE-TABLE.md) -- If the user does not explicitly create a partition when creating a table, adding a partition by ALTER is not supported -- If the user uses list partition then they can add default partition to the table. The default partition will store all data not satisfying prior partition key's constraints. - - ALTER TABLE table_name ADD PARTITION partition_name - -2. Delete the partition - -grammar: - -```sql -DROP PARTITION [IF EXISTS] partition_name [FORCE] -``` - - Notice: - -- At least one partition must be reserved for tables using partitioning. -- After executing DROP PARTITION for a period of time, the deleted partition can be recovered through the RECOVER statement. For details, see SQL Manual - Database Management - RECOVER Statement -- If you execute DROP PARTITION FORCE, the system will not check whether there are unfinished transactions in the partition, the partition will be deleted directly and cannot be recovered, this operation is generally not recommended - -3. Modify the partition properties - - grammar: - -```sql -MODIFY PARTITION p1|(p1[, p2, ...]) SET ("key" = "value", ...) -``` - -illustrate: - -- Currently supports modifying the following properties of partitions: - - storage_medium - -storage_cooldown_time - - replication_num - - in_memory -- For single-partition tables, partition_name is the same as the table name. - -### Example - -1. Add partition, existing partition [MIN, 2013-01-01), add partition [2013-01-01, 2014-01-01), use default bucketing method - -```sql -ALTER TABLE example_db.my_table -ADD PARTITION p1 VALUES LESS THAN ("2014-01-01"); -``` - -2. Increase the partition and use the new number of buckets - -```sql -ALTER TABLE example_db.my_table -ADD PARTITION p1 VALUES LESS THAN ("2015-01-01") -DISTRIBUTED BY HASH(k1) BUCKETS 20; -``` - -3. Increase the partition and use the new number of replicas - -```sql -ALTER TABLE example_db.my_table -ADD PARTITION p1 VALUES LESS THAN ("2015-01-01") -("replication_num"="1"); -``` - -4. Modify the number of partition replicas - -```sql -ALTER TABLE example_db.my_table -MODIFY PARTITION p1 SET("replication_num"="1"); -``` - -5. Batch modify the specified partition - -```sql -ALTER TABLE example_db.my_table -MODIFY PARTITION (p1, p2, p4) SET("replication_num"="1"); -``` - -6. Batch modify all partitions - -```sql -ALTER TABLE example_db.my_table -MODIFY PARTITION (*) SET("storage_medium"="HDD"); -``` - -7. Delete partition - -```sql -ALTER TABLE example_db.my_table -DROP PARTITION p1; -``` - -8. Batch delete partition - -```sql -ALTER TABLE example_db.my_table -DROP PARTITION p1, -DROP PARTITION p2, -DROP PARTITION p3; -``` - -9. Add a partition specifying upper and lower bounds - -```sql -ALTER TABLE example_db.my_table -ADD PARTITION p1 VALUES [("2014-01-01"), ("2014-02-01")); -``` - -10. Add partitions of number type and time type in batches - -```sql -ALTER TABLE example_db.my_table ADD PARTITIONS FROM (1) TO (100) INTERVAL 10; -ALTER TABLE example_db.my_table ADD PARTITIONS FROM ("2023-01-01") TO ("2025-01-01") INTERVAL 1 YEAR; -ALTER TABLE example_db.my_table ADD PARTITIONS FROM ("2023-01-01") TO ("2025-01-01") INTERVAL 1 MONTH; -ALTER TABLE example_db.my_table ADD PARTITIONS FROM ("2023-01-01") TO ("2025-01-01") INTERVAL 1 WEEK; -ALTER TABLE example_db.my_table ADD PARTITIONS FROM ("2023-01-01") TO ("2025-01-01") INTERVAL 1 DAY; -``` - -### Keywords - -```text -ALTER, TABLE, PARTITION, ALTER TABLE -``` - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-PROPERTY.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-PROPERTY.md deleted file mode 100644 index 741754ba58b47..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-PROPERTY.md +++ /dev/null @@ -1,294 +0,0 @@ ---- -{ - "title": "ALTER-TABLE-PROPERTY", - "language": "en" -} ---- - - - -## ALTER-TABLE-PROPERTY - -### Name - -ALTER TABLE PROPERTY - -:::caution -Differences between Partition Attributes and Table Attributes -- Partition attributes generally focus on the number of buckets (buckets), storage medium (storage_medium), replication num (replication_num), and hot/cold data separation policies (storage_policy). - - For existing partitions, you can use ALTER TABLE {tableName} MODIFY PARTITION ({partitionName}) SET ({key}={value}) to modify them, but the number of buckets (buckets) cannot be changed. - - For not-created dynamic partitions, you can use ALTER TABLE {tableName} SET (dynamic_partition.{key} = {value}) to modify their attributes. - - For not-created auto partitions, you can use ALTER TABLE {tableName} SET ({key} = {value}) to modify their attributes. - - If users want to modify partition attributes, they need to modify the attributes of the already created partitions, as well as the attributes of not-created partitions. -- Aside from the above attributes, all others are at the table level. -- For the specific attributes, please refer to [create table attributes](../../../../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE.md#properties) -::: - -### Description - -This statement is used to modify the properties of an existing table. This operation is synchronous, and the return of the command indicates the completion of the execution. - -Modify the properties of the table, currently supports modifying the bloom filter column, the colocate_with attribute and the dynamic_partition attribute, the replication_num and default.replication_num. - -grammar: - -```sql -ALTER TABLE [database.]table alter_clause; -``` - -The alter_clause of property supports the following modification methods. - -Note: - -Can also be merged into the above schema change operation to modify, see the example below - -1. Modify the bloom filter column of the table - -```sql -ALTER TABLE example_db.my_table SET ("bloom_filter_columns"="k1,k2,k3"); -``` - -Can also be incorporated into the schema change operation above (note that the syntax for multiple clauses is slightly different) - -```sql -ALTER TABLE example_db.my_table -DROP COLUMN col2 -PROPERTIES ("bloom_filter_columns"="k1,k2,k3"); -``` - -2. Modify the Colocate property of the table - -```sql -ALTER TABLE example_db.my_table set ("colocate_with" = "t1"); -``` - -3. Change the bucketing method of the table from Hash Distribution to Random Distribution - -```sql -ALTER TABLE example_db.my_table set ("distribution_type" = "random"); -``` - -4. Modify the dynamic partition attribute of the table (support adding dynamic partition attribute to the table without dynamic partition attribute) - -```sql -ALTER TABLE example_db.my_table set ("dynamic_partition.enable" = "false"); -``` - -If you need to add dynamic partition attributes to tables without dynamic partition attributes, you need to specify all dynamic partition attributes - (Note: adding dynamic partition attributes is not supported for non-partitioned tables) - -```sql -ALTER TABLE example_db.my_table set ( - "dynamic_partition.enable" = "true", - "dynamic_partition.time_unit" = "DAY", - "dynamic_partition.end" = "3", - "dynamic_partition.prefix" = "p", - "dynamic_partition. buckets" = "32" -); -``` - -5. Modify the in_memory attribute of the table, only can set value 'false' - -```sql -ALTER TABLE example_db.my_table set ("in_memory" = "false"); -``` - -6. Enable batch delete function - -```sql -ALTER TABLE example_db.my_table ENABLE FEATURE "BATCH_DELETE"; -``` - -Note: - -- Only support unique tables -- Batch deletion is supported for old tables, while new tables are already supported when they are created - -7. Enable the function of ensuring the import order according to the value of the sequence column - -```sql -ALTER TABLE example_db.my_table ENABLE FEATURE "SEQUENCE_LOAD" WITH PROPERTIES ( - "function_column.sequence_type" = "Date" -); -``` - -Note: - -- Only support unique tables -- The sequence_type is used to specify the type of the sequence column, which can be integral and time type -- Only the orderliness of newly imported data is supported. Historical data cannot be changed - -8. Change the default number of buckets for the table to 50 - -```sql -ALTER TABLE example_db.my_table MODIFY DISTRIBUTION DISTRIBUTED BY HASH(k1) BUCKETS 50; -``` - -Note: - -- Only support non colocate table with RANGE partition and HASH distribution - -9. Modify table comments - -```sql -ALTER TABLE example_db.my_table MODIFY COMMENT "new comment"; -``` - -10. Modify column comments - -```sql -ALTER TABLE example_db.my_table MODIFY COLUMN k1 COMMENT "k1", MODIFY COLUMN k2 COMMENT "k2"; -``` - -11. Modify the engine type - -Only the MySQL type can be changed to the ODBC type. The value of driver is the name of the driver in the odbc.init configuration. - -```sql -ALTER TABLE example_db.mysql_table MODIFY ENGINE TO odbc PROPERTIES("driver" = "MySQL"); -``` - -12. Modify the number of copies - -```sql -ALTER TABLE example_db.mysql_table SET ("replication_num" = "2"); -ALTER TABLE example_db.mysql_table SET ("default.replication_num" = "2"); -ALTER TABLE example_db.mysql_table SET ("replication_allocation" = "tag.location.default: 1"); -ALTER TABLE example_db.mysql_table SET ("default.replication_allocation" = "tag.location.default: 1"); -``` - -Note: -1. The property with the default prefix indicates the default replica distribution for the modified table. This modification does not modify the current actual replica distribution of the table, but only affects the replica distribution of newly created partitions on the partitioned table. -2. For non-partitioned tables, modifying the replica distribution property without the default prefix will modify both the default replica distribution and the actual replica distribution of the table. That is, after the modification, through the `show create table` and `show partitions from tbl` statements, you can see that the replica distribution has been modified. -changed. -3. For partitioned tables, the actual replica distribution of the table is at the partition level, that is, each partition has its own replica distribution, which can be viewed through the `show partitions from tbl` statement. If you want to modify the actual replica distribution, see `ALTER TABLE PARTITION`. - -13\. **[Experimental]** turn on `light_schema_change` - - For tables that were not created with light_schema_change enabled, you can enable it by using the following statement. - -```sql -ALTER TABLE example_db.mysql_table SET ("light_schema_change" = "true"); -``` - -### Example - -1. Modify the bloom filter column of the table - -```sql -ALTER TABLE example_db.my_table SET ("bloom_filter_columns"="k1,k2,k3"); -``` - -Can also be incorporated into the schema change operation above (note that the syntax for multiple clauses is slightly different) - -```sql -ALTER TABLE example_db.my_table -DROP COLUMN col2 -PROPERTIES ("bloom_filter_columns"="k1,k2,k3"); -``` - -2. Modify the Colocate property of the table - -```sql -ALTER TABLE example_db.my_table set ("colocate_with" = "t1"); -``` - -3. Change the bucketing method of the table from Hash Distribution to Random Distribution - -```sql -ALTER TABLE example_db.my_table set ("distribution_type" = "random"); -``` - -4. Modify the dynamic partition attribute of the table (support adding dynamic partition attribute to the table without dynamic partition attribute) - -```sql -ALTER TABLE example_db.my_table set ("dynamic_partition.enable" = "false"); -``` - -If you need to add dynamic partition attributes to tables without dynamic partition attributes, you need to specify all dynamic partition attributes - (Note: adding dynamic partition attributes is not supported for non-partitioned tables) - -```sql -ALTER TABLE example_db.my_table set ("dynamic_partition.enable" = "true", "dynamic_partition.time_unit" = "DAY", "dynamic_partition.end" = "3", "dynamic_partition.prefix" = "p", "dynamic_partition. buckets" = "32"); -``` - -5. Modify the in_memory attribute of the table, only can set value 'false' - -```sql -ALTER TABLE example_db.my_table set ("in_memory" = "false"); -``` - -6. Enable batch delete function - -```sql -ALTER TABLE example_db.my_table ENABLE FEATURE "BATCH_DELETE"; -``` - -7. Enable the function of ensuring the import order according to the value of the sequence column - -```sql -ALTER TABLE example_db.my_table ENABLE FEATURE "SEQUENCE_LOAD" WITH PROPERTIES ("function_column.sequence_type" = "Date"); -``` - -8. Change the default number of buckets for the table to 50 - -```sql -ALTER TABLE example_db.my_table MODIFY DISTRIBUTION DISTRIBUTED BY HASH(k1) BUCKETS 50; -``` - -9. Modify table comments - -```sql -ALTER TABLE example_db.my_table MODIFY COMMENT "new comment"; -``` - -10. Modify column comments - -```sql -ALTER TABLE example_db.my_table MODIFY COLUMN k1 COMMENT "k1", MODIFY COLUMN k2 COMMENT "k2"; -``` - -11. Modify the engine type - -```sql -ALTER TABLE example_db.mysql_table MODIFY ENGINE TO odbc PROPERTIES("driver" = "MySQL"); -``` - -12. Add a cold and hot separation data migration strategy to the table -```sql - ALTER TABLE create_table_not_have_policy set ("storage_policy" = "created_create_table_alter_policy"); -``` -NOTE:The table can be successfully added only if it hasn't been associated with a storage policy. A table just can have one storage policy. - -13. Add a hot and cold data migration strategy to the partition of the table -```sql -ALTER TABLE create_table_partition MODIFY PARTITION (*) SET("storage_policy"="created_create_table_partition_alter_policy"); -``` -NOTE:The table's partition can be successfully added only if it hasn't been associated with a storage policy. A table just can have one storage policy. - - -### Keywords - -```text -ALTER, TABLE, PROPERTY, ALTER TABLE -``` - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-RENAME.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-RENAME.md deleted file mode 100644 index 34639ea14a573..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-RENAME.md +++ /dev/null @@ -1,116 +0,0 @@ ---- -{ - "title": "ALTER-TABLE-RENAME", - "language": "en" -} ---- - - - -## ALTER-TABLE-RENAME - -### Name - -ALTER TABLE RENAME - -### Description - -This statement is used to rename certain names of existing table properties. This operation is synchronous, and the return of the command indicates the completion of the execution. - -grammar: - -```sql -ALTER TABLE [database.]table alter_clause; -``` - -The alter_clause of rename supports modification of the following names - -1. Modify the table name - -grammar: - -```sql -RENAME new_table_name; -``` - -2. Modify the rollup index name - - grammar: - -```sql -RENAME ROLLUP old_rollup_name new_rollup_name; -``` - -3. Modify the partition name - -grammar: - -```sql -RENAME PARTITION old_partition_name new_partition_name; -``` - -4. Modify the column name - -Modify the column name - -grammar: - -```sql -RENAME COLUMN old_column_name new_column_name; -``` - -Notice: -- When creating a table, you need to set 'light_schema_change=true' in the property. - - -### Example - -1. Modify the table named table1 to table2 - -```sql -ALTER TABLE table1 RENAME table2; -``` - -2. Modify the rollup index named rollup1 in the table example_table to rollup2 - -```sql -ALTER TABLE example_table RENAME ROLLUP rollup1 rollup2; -``` - -3. Modify the partition named p1 in the table example_table to p2 - -```sql -ALTER TABLE example_table RENAME PARTITION p1 p2; -``` - -4. Modify the column named c1 in the table example_table to c2 - -```sql -ALTER TABLE example_table RENAME COLUMN c1 c2; -``` - -### Keywords - -```text -ALTER, TABLE, RENAME, ALTER TABLE -``` - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-REPLACE.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-REPLACE.md deleted file mode 100644 index 7bafd34890000..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-REPLACE.md +++ /dev/null @@ -1,98 +0,0 @@ ---- -{ - "title": "ALTER-TABLE-REPLACE", - "language": "en" -} ---- - - - -## ALTER-TABLE-REPLACE - -### Name - -ALTER TABLE REPLACE - -### Description - -Atomic substitution of two tables. This operation applies only to OLAP tables. - -```sql -ALTER TABLE [db.]tbl1 REPLACE WITH TABLE tbl2 -[PROPERTIES('swap' = 'true')] FORCE?; -``` - -Replace table tbl1 with table tbl2. - -If the `swap` parameter is `true`, the data in the table named `tbl1` will be the data in the original table named `tbl2` after the replacement. The data in the table named `tbl2` is the data in the original `tbl1` table. That is, two tables of data have been swapped. - -If the `swap` parameter is `false`, the data in the `tbl1` table will be the data in the `tbl2` table after the replacement. The table named `tbl2` is deleted. - -#### Theory - -The replace table function actually turns the following set of operations into an atomic operation. - -If you want to replace table A with table B and `swap` is `true`, do the following: - -1. Rename table B as table A. -2. Rename table A as table B. - -If `swap` is `false`, do as follows: - -1. Delete table A. -2. Rename table B as table A. - -#### Notice -1. The default `swap` parameter is `true`. That is, a table replacement operation is equivalent to an exchange of data between two tables. -2. If the `swap` parameter is set to false, for a period of time, the replaced table (table A) can be recovered through the RECOVER statement. See [RECOVER](../../../../sql-manual/sql-statements/Database-Administration-Statements/RECOVER) statement for details. If you execute command with FORCE, the table will be deleted directly and cannot be recovered, this operation is generally not recommended. -3. The replacement operation can only occur between two OLAP tables and does not check whether the table structure of the two tables is consistent. -4. The original permission Settings are not changed. Because the permission check is based on the table name. - -### Example - -1. Atomic swap `tbl1` with `tbl2` without dropping any tables(Note: if you delete it, you actually delete tbl1 and rename tbl2 to tbl1.) - -```sql -ALTER TABLE tbl1 REPLACE WITH TABLE tbl2; -``` -or -```sql -ALTER TABLE tbl1 REPLACE WITH TABLE tbl2 PROPERTIES('swap' = 'true'); -``` - -2. Atomic swap `tbl1` with `tbl2` and deleting the `tbl2` table(Keep `tbl1` and the data of the original `tbl2`) - -```sql -ALTER TABLE tbl1 REPLACE WITH TABLE tbl2 PROPERTIES('swap' = 'false'); -``` - -This case data in tb1 data will moved to recycle-bin and can be recovered using recover statement. -If you execute command with FORCE, the table data (tb1) will be deleted directly and cannot be recovered, this operation is generally not recommended. - -### Keywords - -```text -ALTER, TABLE, REPLACE, ALTER TABLE -``` - -### Best Practice -1. Atomic overlay write operations - - In some cases, the user wants to be able to rewrite the data of a certain table, but if the data is deleted first and then imported, the data cannot be viewed for a period of time in between. At this time, the user can first use the `CREATE TABLE LIKE` statement to create a new table with the same structure, import the new data into the new table, and use the replacement operation to atomically replace the old table to achieve the goal. Atomic overwrite write operations at the partition level, see [temp partition documentation](../../../../advanced/partition/table-temp-partition.md). diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-ROLLUP.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-ROLLUP.md deleted file mode 100644 index 45c4c34bb9092..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-ROLLUP.md +++ /dev/null @@ -1,140 +0,0 @@ ---- -{ - "title": "ALTER-TABLE-ROLLUP", - "language": "en" -} ---- - - - -## ALTER-TABLE-ROLLUP - -### Name - -ALTER TABLE ROLLUP - -### Description - -This statement is used to perform a rollup modification operation on an existing table. The rollup is an asynchronous operation, and the task is returned when the task is submitted successfully. After that, you can use the [SHOW ALTER](../../Show-Statements/SHOW-ALTER.md) command to view the progress. - -grammar: - -```sql -ALTER TABLE [database.]table alter_clause; -``` - -The alter_clause of rollup supports the following creation methods - -1. Create a rollup index - -grammar: - -```sql -ADD ROLLUP rollup_name (column_name1, column_name2, ...) -[FROM from_index_name] -[PROPERTIES ("key"="value", ...)] -``` - -properties: Support setting timeout time, the default timeout time is 1 day. - -2. Create rollup indexes in batches - -grammar: - -```sql -ADD ROLLUP [rollup_name (column_name1, column_name2, ...) - [FROM from_index_name] - [PROPERTIES ("key"="value", ...)],...] -``` - -Notice: - -- If from_index_name is not specified, it will be created from base index by default -- Columns in rollup table must be columns already in from_index -- In properties, the storage format can be specified. For details, see [CREATE TABLE](../Create/CREATE-TABLE.md) - -3. Delete rollup index - - grammar: - -```sql -DROP ROLLUP rollup_name [PROPERTIES ("key"="value", ...)] -``` - -4. Batch delete rollup index - -grammar: - -```sql -DROP ROLLUP [rollup_name [PROPERTIES ("key"="value", ...)],...] -``` - -Notice: - -- cannot delete base index - -### Example - -1. Create index: example_rollup_index, based on base index (k1,k2,k3,v1,v2). Columnar storage. - -```sql -ALTER TABLE example_db.my_table -ADD ROLLUP example_rollup_index(k1, k3, v1, v2); -``` - -2. Create index: example_rollup_index2, based on example_rollup_index (k1,k3,v1,v2) - -```sql -ALTER TABLE example_db.my_table -ADD ROLLUP example_rollup_index2 (k1, v1) -FROM example_rollup_index; -``` - -3. Create index: example_rollup_index3, based on base index (k1,k2,k3,v1), with a custom rollup timeout of one hour. - -```sql -ALTER TABLE example_db.my_table -ADD ROLLUP example_rollup_index(k1, k3, v1) -PROPERTIES("timeout" = "3600"); -``` - -4. Delete index: example_rollup_index2 - -```sql -ALTER TABLE example_db.my_table -DROP ROLLUP example_rollup_index2; -``` - -5. Batch Delete rollup index - -```sql -ALTER TABLE example_db.my_table -DROP ROLLUP example_rollup_index2,example_rollup_index3; -``` - -### - -4. Keywords - -```text -ALTER, TABLE, ROLLUP, ALTER TABLE -``` - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-VIEW.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-VIEW.md deleted file mode 100644 index b471b034e16c4..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-VIEW.md +++ /dev/null @@ -1,73 +0,0 @@ ---- -{ - "title": "ALTER-VIEW", - "language": "en" -} ---- - - - -## ALTER-VIEW - -### Name - -ALTER VIEW - -### Description - -This statement is used to modify the definition of a view - -grammar: - -```sql -ALTER VIEW -[db_name.]view_name -(column1[ COMMENT "col comment"][, column2, ...]) -AS query_stmt -``` - -illustrate: - -- Views are all logical, and the data in them will not be stored on physical media. When querying, the view will be used as a subquery in the statement. Therefore, modifying the definition of the view is equivalent to modifying query_stmt. -- query_stmt is any supported SQL - -### Example - -1. Modify the view example_view on example_db - -```sql -ALTER VIEW example_db.example_view -( -c1 COMMENT "column 1", -c2 COMMENT "column 2", -c3 COMMENT "column 3" -) -AS SELECT k1, k2, SUM(v1) FROM example_table -GROUP BY k1, k2 -``` - -### Keywords - -```text -ALTER, VIEW -``` - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-WORKLOAD-GROUP.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-WORKLOAD-GROUP.md deleted file mode 100644 index 2fe3fc023590e..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-WORKLOAD-GROUP.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -{ -"title": "ALTER-WORKLOAD-GROUP", -"language": "en" -} ---- - - - -## ALTER-WORKLOAD-GROUP - -### Name - -ALTER WORKLOAD GROUP - -### Description - -This statement is used to modify the workload group. - -Syntax: - -```sql -ALTER WORKLOAD GROUP "rg_name" -PROPERTIES ( - property_list -); -``` - -NOTE: - -* Modify the memory_limit property in such a way that the sum of all memory_limit values does not exceed 100%; -* Support modifying some properties, for example, if only cpu_share is modified, just fill in cpu_share in properties. - -### Example - -1. Modify the workload group named g1: - - ```sql - alter workload group g1 - properties ( - "cpu_share"="30", - "memory_limit"="30%" - ); - ``` - -### Keywords - -```sql -ALTER, WORKLOAD, GROUP -``` - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/CANCEL-ALTER-TABLE.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/CANCEL-ALTER-TABLE.md deleted file mode 100644 index ba825fbc4c29b..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/CANCEL-ALTER-TABLE.md +++ /dev/null @@ -1,110 +0,0 @@ ---- -{ - "title": "CANCEL-ALTER-TABLE", - "language": "en" -} ---- - - - -## CANCEL-ALTER-TABLE - -### Name - -CANCEL ALTER TABLE - -### Description - -This statement is used to undo an ALTER operation. - -1. Undo the ALTER TABLE COLUMN operation - -grammar: - -```sql -CANCEL ALTER TABLE COLUMN -FROM db_name.table_name -``` - -2. Undo the ALTER TABLE ROLLUP operation - -grammar: - -```sql -CANCEL ALTER TABLE ROLLUP -FROM db_name.table_name -``` - -3. Batch cancel rollup operations based on job id - -grammar: - -```sql -CANCEL ALTER TABLE ROLLUP -FROM db_name.table_name (jobid,...) -``` - -Notice: - -- This command is an asynchronous operation. You need to use `show alter table rollup` to check the task status to confirm whether the execution is successful or not. - -4. Undo the ALTER CLUSTER operation - -grammar: - -``` -(To be implemented...) -``` - -### Example - -1. Undo the ALTER COLUMN operation on my_table. - - [CANCEL ALTER TABLE COLUMN] - -```sql -CANCEL ALTER TABLE COLUMN -FROM example_db.my_table; -``` - -1. Undo the ADD ROLLUP operation under my_table. - - [CANCEL ALTER TABLE ROLLUP] - -```sql -CANCEL ALTER TABLE ROLLUP -FROM example_db.my_table; -``` - -1. Undo the ADD ROLLUP operation under my_table according to the job id. - - [CANCEL ALTER TABLE ROLLUP] - -```sql -CANCEL ALTER TABLE ROLLUP -FROM example_db.my_table(12801,12802); -``` - -### Keywords - - CANCEL, ALTER, TABLE, CANCEL ALTER - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/PAUSE-JOB.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/PAUSE-JOB.md deleted file mode 100644 index 5920c14398a7d..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/PAUSE-JOB.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -{ -"title": "PAUSE-JOB", -"language": "en" -} ---- - - - -## PAUSE-JOB - -### Name - -PAUSE JOB - -### Description - -User suspends a JOB. A stopped job can be resumed with RESUME JOB. - -```sql -PAUSE JOB where jobName = 'job_name'; -``` - -### Example - -1. Pause the job named test1. - - ```sql - PAUSE JOB where jobName = 'test1'; - ``` - -### Keywords - - PAUSE, JOB - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/RESUME-JOB.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/RESUME-JOB.md deleted file mode 100644 index 69608f1416b0b..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Alter/RESUME-JOB.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ -"title": "RESUME-JOB", -"language": "en" -} ---- - - - -## RESUME-JOB - -### Name - -RESUME JOB - -### Description - -Used to restart a JOB in PAUSE state. The restarted job will continue to be executed periodically. A JOB in STOP state cannot be resumed. - -```sql -RESUME JOB WHERE jobName = 'job_name'; -``` - -### Example - -1. Restart the JOB named test1. - - ```sql - RESUME JOB WHERE jobName = 'test1'; - ``` - -### Keywords - - RESUME, JOB - -### Best Practice - - - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/BACKUP.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/BACKUP.md deleted file mode 100644 index f6ea2a1a26e5c..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/BACKUP.md +++ /dev/null @@ -1,112 +0,0 @@ ---- -{ - "title": "BACKUP", - "language": "en" -} ---- - - - -## BACKUP - -### Name - -BACKUP - -### Description - -This statement is used to back up the data under the specified database. This command is an asynchronous operation. After the submission is successful, you need to check the progress through the SHOW BACKUP command. Only backing up tables of type OLAP is supported. - - Only root or superuser users can create repositories. - -grammar: - -```sql -BACKUP SNAPSHOT [db_name].{snapshot_name} -TO `repository_name` -[ON|EXCLUDE] ( - `table_name` [PARTITION (`p1`, ...)], - ... -) -PROPERTIES ("key"="value", ...); -``` - -illustrate: - -- There can only be one executing BACKUP or RESTORE task under the same database. -- The ON clause identifies the tables and partitions that need to be backed up. If no partition is specified, all partitions of the table are backed up by default -- Tables and partitions that do not require backup are identified in the EXCLUDE clause. Back up all partition data for all tables in this database except the specified table or partition. -- PROPERTIES currently supports the following properties: - - "type" = "full": indicates that this is a full update (default) - - "timeout" = "3600": The task timeout period, the default is one day. in seconds. - -### Example - -1. Fully backup the table example_tbl under example_db to the warehouse example_repo: - -```sql -BACKUP SNAPSHOT example_db.snapshot_label1 -TO example_repo -ON (example_tbl) -PROPERTIES ("type" = "full"); -``` - -2. Under the full backup example_db, the p1, p2 partitions of the table example_tbl, and the table example_tbl2 to the warehouse example_repo: - -```sql -BACKUP SNAPSHOT example_db.snapshot_label2 -TO example_repo -ON -( - example_tbl PARTITION (p1,p2), - example_tbl2 -); -``` - -3. Full backup of all tables except table example_tbl under example_db to warehouse example_repo: - -```sql -BACKUP SNAPSHOT example_db.snapshot_label3 -TO example_repo -EXCLUDE (example_tbl); -``` - -4. Fully back up tables under example_db to the repository example_repo: - -```sql -BACKUP SNAPSHOT example_db.snapshot_label3 -TO example_repo; -``` - -### Keywords - -BACKUP - -### Best Practice - -1. Only one backup operation can be performed under the same database. - -2. The backup operation will back up the underlying table and [Synchronous materialized view](../../../../query/view-materialized-view/materialized-view.md) of the specified table or partition, and only one replica will be backed up. [Asynchronous materialized view](../../../../query/view-materialized-view/async-materialized-view.md) is not supported. - -3. Efficiency of backup operations - - The efficiency of backup operations depends on the amount of data, the number of Compute Nodes, and the number of files. Each Compute Node where the backup data shard is located will participate in the upload phase of the backup operation. The greater the number of nodes, the higher the upload efficiency. - - The amount of file data refers only to the number of shards, and the number of files in each shard. If there are many shards, or there are many small files in the shards, the backup operation time may be increased. diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CANCEL-BACKUP.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CANCEL-BACKUP.md deleted file mode 100644 index 9ecbc9b9c25cf..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CANCEL-BACKUP.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -{ - "title": "CANCEL-BACKUP", - "language": "en" -} ---- - - - -## CANCEL-BACKUP - -### Name - -CANCEL BACKUP - -### Description - -This statement is used to cancel an ongoing BACKUP task. - -grammar: - -```sql -CANCEL BACKUP FROM db_name; -``` - -### Example - -1. Cancel the BACKUP task under example_db. - -```sql -CANCEL BACKUP FROM example_db; -``` - -### Keywords - - CANCEL, BACKUP - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CANCEL-RESTORE.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CANCEL-RESTORE.md deleted file mode 100644 index fbc0e9d315c2d..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CANCEL-RESTORE.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -{ - "title": "CANCEL-RESTORE", - "language": "en" -} ---- - - - -## CANCEL-RESTORE - -### Name - -CANCEL RESTORE - -### Description - -This statement is used to cancel an ongoing RESTORE task. - -grammar: - -```sql -CANCEL RESTORE FROM db_name; -``` - -Notice: - -- When cancellation is around a COMMIT or later stage of recovery, the table being recovered may be rendered inaccessible. At this time, data recovery can only be performed by executing the recovery job again. - -### Example - -1. Cancel the RESTORE task under example_db. - -```sql -CANCEL RESTORE FROM example_db; -``` - -### Keywords - - CANCEL, RESTORE - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CREATE-REPOSITORY.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CREATE-REPOSITORY.md deleted file mode 100644 index f76196c2d0f7e..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CREATE-REPOSITORY.md +++ /dev/null @@ -1,142 +0,0 @@ ---- -{ - "title": "CREATE-REPOSITORY", - "language": "en" -} ---- - - - -## CREATE-REPOSITORY - -### Name - -CREATE REPOSITORY - -### Description - -This statement is used to create a repository. Repositories are used for backup or restore. Only root or superuser users can create repositories. - -grammar: - -```sql -CREATE [READ ONLY] REPOSITORY `repo_name` -WITH [S3|hdfs] -ON LOCATION `repo_location` -PROPERTIES ("key"="value", ...); -``` - -illustrate: - -- Creation of repositories, accessing cloud storage directly through AWS S3 protocol, or accessing HDFS directly. -- If it is a read-only repository, restores can only be done on the repository. If not, backup and restore operations are available. -- PROPERTIES are different according to different types of S3 or hdfs, see the example for details. -- ON LOCATION : if it is S3 , here followed by the Bucket Name. - -### Example - -1. Create a repository named s3_repo. - -```sql -CREATE REPOSITORY `s3_repo` -WITH S3 -ON LOCATION "s3://s3-repo" -PROPERTIES -( - "s3.endpoint" = "http://s3-REGION.amazonaws.com", - "s3.region" = "s3-REGION", - "s3.access_key" = "AWS_ACCESS_KEY", - "s3.secret_key"="AWS_SECRET_KEY", - "s3.region" = "REGION" -); -``` - -2. Create a repository named hdfs_repo. - -```sql -CREATE REPOSITORY `hdfs_repo` -WITH hdfs -ON LOCATION "hdfs://hadoop-name-node:54310/path/to/repo/" -PROPERTIES -( - "fs.defaultFS"="hdfs://hadoop-name-node:54310", - "hadoop.username"="user" -); - -### Keywords - -``` -6. Create a repository named minio_repo to link minio storage directly through the S3 protocol. - -```sql -CREATE REPOSITORY `minio_repo` -WITH S3 -ON LOCATION "s3://minio_repo" -PROPERTIES -( - "s3.endpoint" = "http://minio.com", - "s3.access_key" = "MINIO_USER", - "s3.secret_key"="MINIO_PASSWORD", - "s3.region" = "REGION", - "use_path_style" = "true" -); -``` - - -7. Create a repository named minio_repo via temporary security credentials. - -```sql -CREATE REPOSITORY `minio_repo` -WITH S3 -ON LOCATION "s3://minio_repo" -PROPERTIES -( - "s3.endpoint" = "AWS_ENDPOINT", - "s3.access_key" = "AWS_TEMP_ACCESS_KEY", - "s3.secret_key" = "AWS_TEMP_SECRET_KEY", - "s3.session_token" = "AWS_TEMP_TOKEN", - "s3.region" = "AWS_REGION" -) -``` - -1. Create repository using Tencent COS - -```sql -CREATE REPOSITORY `cos_repo` -WITH S3 -ON LOCATION "s3://backet1/" -PROPERTIES -( - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.endpoint" = "http://cos.ap-beijing.myqcloud.com", - "s3.region" = "ap-beijing" -); -``` - -### Keywords - - CREATE, REPOSITORY - -### Best Practice - -1. A cluster can create multiple warehouses. Only users with ADMIN privileges can create repositories. -2. Any user can view the created repositories through the [SHOW REPOSITORIES](../../Show-Statements/SHOW-REPOSITORIES.md) command. -3. When performing data migration operations, it is necessary to create the exact same warehouse in the source cluster and the destination cluster, so that the destination cluster can view the data snapshots backed up by the source cluster through this warehouse. diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/DROP-REPOSITORY.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/DROP-REPOSITORY.md deleted file mode 100644 index 7a0b937cdc7b9..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/DROP-REPOSITORY.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -{ - "title": "DROP-REPOSITORY", - "language": "en" -} ---- - - - -## DROP-REPOSITORY - -### Name - -DROP REPOSITORY - -### Description - -This statement is used to delete a created repository. Only root or superuser users can delete repositories. - -grammar: - -```sql -DROP REPOSITORY `repo_name`; -``` - -illustrate: - -- Deleting a warehouse just deletes the warehouse's mapping in Doris, not the actual warehouse data. Once deleted, it can be mapped to the repository again by specifying the same LOCATION. - -### Example - -1. Delete the repository named example_repo: - -```sql -DROP REPOSITORY `example_repo`; -``` - -### Keywords - - DROP, REPOSITORY - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/RESTORE.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/RESTORE.md deleted file mode 100644 index 12fa68ad394e0..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/RESTORE.md +++ /dev/null @@ -1,126 +0,0 @@ ---- -{ - "title": "RESTORE", - "language": "en" -} ---- - - - -## RESTORE - -### Name - -RESTORE - -### Description - -This statement is used to restore the data backed up by the BACKUP command to the specified database. This command is an asynchronous operation. After the submission is successful, you need to check the progress through the SHOW RESTORE command. Restoring tables of type OLAP is only supported. - -grammar: - -```sql -RESTORE SNAPSHOT [db_name].{snapshot_name} -FROM `repository_name` -[ON|EXCLUDE] ( - `table_name` [PARTITION (`p1`, ...)] [AS `tbl_alias`], - ... -) -PROPERTIES ("key"="value", ...); -``` - -illustrate: - -- There can only be one executing BACKUP or RESTORE task under the same database. -- The tables and partitions that need to be restored are identified in the ON clause. If no partition is specified, all partitions of the table are restored by default. The specified table and partition must already exist in the warehouse backup. -- Tables and partitions that do not require recovery are identified in the EXCLUDE clause. All partitions of all other tables in the warehouse except the specified table or partition will be restored. -- The table name backed up in the warehouse can be restored to a new table through the AS statement. But the new table name cannot already exist in the database. The partition name cannot be modified. -- You can restore the backed up tables in the warehouse to replace the existing tables of the same name in the database, but you must ensure that the table structures of the two tables are exactly the same. The table structure includes: table name, column, partition, Rollup, etc. -- You can specify some partitions of the recovery table, and the system will check whether the partition Range or List can match. -- PROPERTIES currently supports the following properties: - - "backup_timestamp" = "2018-05-04-16-45-08": Specifies which time version of the corresponding backup to restore, required. This information can be obtained with the `SHOW SNAPSHOT ON repo;` statement. - - "replication_num" = "3": Specifies the number of replicas for the restored table or partition. Default is 3. If restoring an existing table or partition, the number of replicas must be the same as the number of replicas of the existing table or partition. At the same time, there must be enough hosts to accommodate multiple replicas. - - "reserve_replica" = "true": Default is false. When this property is true, the replication_num property is ignored and the restored table or partition will have the same number of replication as before the backup. Supports multiple tables or multiple partitions within a table with different replication number. - - "reserve_dynamic_partition_enable" = "true": Default is false. When this property is true, the restored table will have the same value of 'dynamic_partition_enable' as before the backup. if this property is not true, the restored table will set 'dynamic_partition_enable=false'. - - "timeout" = "3600": The task timeout period, the default is one day. in seconds. - - "meta_version" = 40: Use the specified meta_version to read the previously backed up metadata. Note that this parameter is used as a temporary solution and is only used to restore the data backed up by the old version of Doris. The latest version of the backup data already contains the meta version, no need to specify it. - - "clean_tables": Indicates whether to clean up tables that do not belong to the restore target. For example, if the target db before the restore has tables that are not present in the snapshot, specifying `clean_tables` can drop these extra tables and move them into the recycle bin during the restore. - - "clean_partitions": Indicates whether to clean up partitions that do not belong to the restore target. For example, if the target table before the restore has partitions that are not present in the snapshot, specifying `clean_partitions` can drop these extra partitions and move them into the recycle bin during the restore. - -### Example - -1. Restore the table backup_tbl in backup snapshot_1 from example_repo to database example_db1, the time version is "2018-05-04-16-45-08". Revert to 1 copy: - -```sql -RESTORE SNAPSHOT example_db1.`snapshot_1` -FROM `example_repo` -ON ( `backup_tbl` ) -PROPERTIES -( - "backup_timestamp"="2018-05-04-16-45-08", - "replication_num" = "1" -); -``` - -2. Restore partitions p1, p2 of table backup_tbl in backup snapshot_2 from example_repo, and table backup_tbl2 to database example_db1, rename it to new_tbl, and the time version is "2018-05-04-17-11-01". The default reverts to 3 replicas: - -```sql -RESTORE SNAPSHOT example_db1.`snapshot_2` -FROM `example_repo` -ON -( - `backup_tbl` PARTITION (`p1`, `p2`), - `backup_tbl2` AS `new_tbl` -) -PROPERTIES -( - "backup_timestamp"="2018-05-04-17-11-01" -); -``` - -3. Restore all tables except for table backup_tbl in backup snapshot_3 from example_repo to database example_db1, the time version is "2018-05-04-18-12-18". - -```sql -RESTORE SNAPSHOT example_db1.`snapshot_3` -FROM `example_repo` -EXCLUDE ( `backup_tbl` ) -PROPERTIES -( - "backup_timestamp"="2018-05-04-18-12-18" -); -``` - -### Keywords - -``` -RESTORE -``` - -### Best Practice - -1. There can only be one ongoing recovery operation under the same database. - -2. The table backed up in the warehouse can be restored and replaced with the existing table of the same name in the database, but the table structure of the two tables must be completely consistent. The table structure includes: table name, columns, partitions, materialized views, and so on. - -3. When specifying a partial partition of the recovery table, the system will check whether the partition range can match. - -4. Efficiency of recovery operations: - - In the case of the same cluster size, the time-consuming of the restore operation is basically the same as the time-consuming of the backup operation. If you want to speed up the recovery operation, you can first restore only one copy by setting the `replication_num` parameter, and then adjust the number of copies by [ALTER TABLE PROPERTY](../../Data-Definition-Statements/Alter/ALTER-TABLE-PROPERTY.md), complete the copy. diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-ASYNC-MATERIALIZED-VIEW.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-ASYNC-MATERIALIZED-VIEW.md deleted file mode 100644 index 4e588733f7199..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-ASYNC-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,249 +0,0 @@ ---- -{ - "title": "CREATE-ASYNC-MATERIALIZED-VIEW", - "language": "en" -} ---- - - - -## CREATE-ASYNC-MATERIALIZED-VIEW - -### Name - -CREATE ASYNC MATERIALIZED VIEW - -### Description - -This statement is used to create an asynchronous materialized view. - -#### syntax - -```sql -CREATE MATERIALIZED VIEW (IF NOT EXISTS)? mvName=multipartIdentifier - (LEFT_PAREN cols=simpleColumnDefs RIGHT_PAREN)? buildMode? - (REFRESH refreshMethod? refreshTrigger?)? - ((DUPLICATE)? KEY keys=identifierList)? - (COMMENT STRING_LITERAL)? - (PARTITION BY LEFT_PAREN mvPartition RIGHT_PAREN)? - (DISTRIBUTED BY (HASH hashKeys=identifierList | RANDOM) (BUCKETS (INTEGER_VALUE | AUTO))?)? - propertyClause? - AS query -``` - -#### illustrate - -##### simpleColumnDefs - -Used to define the materialized view column information, if not defined, it will be automatically derived - -```sql -simpleColumnDefs -: cols+=simpleColumnDef (COMMA cols+=simpleColumnDef)* - ; - -simpleColumnDef -: colName=identifier (COMMENT comment=STRING_LITERAL)? - ; -``` - -For example, define two columns aa and bb, where the annotation for aa is "name" -```sql -CREATE MATERIALIZED VIEW mv1 -(aa comment "name",bb) -``` - -##### buildMode - -Used to define whether the materialized view is refreshed immediately after creation, default to IMMEDIATE - -IMMEDIATE:Refresh Now - -DEFERRED:Delay refresh - -```sql -buildMode -: BUILD (IMMEDIATE | DEFERRED) -; -``` - -For example, specifying the materialized view to refresh immediately - -```sql -CREATE MATERIALIZED VIEW mv1 -BUILD IMMEDIATE -``` - -##### refreshMethod - -Used to define the refresh method for materialized views, default to AUTO - -COMPLETE:Full refresh - -AUTO:Try to refresh incrementally as much as possible. If incremental refresh is not possible, refresh in full - -The SQL definition and partition fields of the materialized view need to meet the following conditions for partition incremental updates: - -- At least one of the base tables used by the materialized view is a partitioned table. -- The base tables used by the materialized view must use list or range partitioning strategies. -- The `partition by` clause in the SQL definition of the materialized view can only have one partitioning column. -- The partitioning column specified in the `partition by` clause of the materialized view's SQL must come after the `SELECT` statement. -- If the materialized view's SQL includes a `group by` clause, the columns used for partitioning must come after the `group by` clause. -- If the materialized view's SQL includes window functions, the columns used for partitioning must come after the `partition by` clause. -- Data changes should occur on partitioned tables. If data changes occur on non-partitioned tables, the materialized view needs to be fully rebuilt. -- If a field from the null-generating side of a join is used as a partitioning column for the materialized view, it cannot be incrementally updated by partition. For example, for a LEFT OUTER JOIN, the partitioning column must be on the left side, not the right. - -```sql -refreshMethod -: COMPLETE | AUTO -; -``` - -For example, specifying full refresh of materialized views -```sql -CREATE MATERIALIZED VIEW mv1 -REFRESH COMPLETE -``` - -##### refreshTrigger - -Trigger method for refreshing data in materialized views, default to MANUAL - -MANUAL:Manual refresh - -SCHEDULE:Timed refresh - -COMMIT: Trigger-based refresh. When the base table data changes, a task to refresh the materialized view is automatically generated. - -```sql -refreshTrigger -: ON MANUAL -| ON SCHEDULE refreshSchedule -| ON COMMIT -; - -refreshSchedule -: EVERY INTEGER_VALUE mvRefreshUnit (STARTS STRING_LITERAL)? -; - -mvRefreshUnit -: MINUTE | HOUR | DAY | WEEK -; -``` - -For example: executed every 2 hours, starting from 21:07:09 on December 13, 2023 -```sql -CREATE MATERIALIZED VIEW mv1 -REFRESH ON SCHEDULE EVERY 2 HOUR STARTS "2023-12-13 21:07:09" -``` - -##### key -The materialized view is the DUPLICATE KEY model, therefore the specified columns are arranged in sequence - -```sql -identifierList -: LEFT_PAREN identifierSeq RIGHT_PAREN - ; - -identifierSeq -: ident+=errorCapturingIdentifier (COMMA ident+=errorCapturingIdentifier)* -; -``` - -For example, specifying k1 and k2 as sorting sequences -```sql -CREATE MATERIALIZED VIEW mv1 -KEY(k1,k2) -``` - -##### partition -There are two types of partitioning methods for materialized views. If no partitioning is specified, there will be a default single partition. If a partitioning field is specified, the system will automatically deduce the source base table of that field and synchronize all partitions of the base table (currently supporting `OlapTable` and `hive`). (Limitation: If the base table is an `OlapTable`, it can only have one partition field) - -For example, if the base table is a range partition with a partition field of `create_time` and partitioning by day, and `partition by(ct) as select create_time as ct from t1` is specified when creating a materialized view, -then the materialized view will also be a range partition with a partition field of 'ct' and partitioning by day - -Materialized views can also reduce the number of partitions by using partition roll-up. Currently, the partition roll-up function supports `date_trunc`, and the roll-up units supported are `year`, `month`, and `day`. - -The selection of partition fields and the definition of materialized views must meet the conditions for partition incremental updates for the materialized view to be created successfully; otherwise, an error "Unable to find a suitable base table for partitioning" will occur. - -```sql -mvPartition - : partitionKey = identifier - | partitionExpr = functionCallExpression - ; -``` - -For example, if the base table is partitioned by day, the materialized view is also partitioned by day. -```sql -partition by (`k2`) -``` - -For example, if the base table is partitioned by day, the materialized view is partitioned by month. -```sql -partition by (date_trunc(`k2`,'month')) -``` - -#### property -The materialized view can specify both the properties of the table and the properties unique to the materialized view. - -The properties unique to materialized views include: - -`grace_period`: When performing query rewrites, there is a maximum allowed delay time (measured in seconds) for the data of the materialized view. If there is a discrepancy between the data of partition A and the base table, and the last refresh time of partition A of the materialized view was 1, while the current system time is 2, then this partition will not undergo transparent rewriting. However, if the grace_period is greater than or equal to 1, this partition will be used for transparent rewriting. - -`excluded_trigger_tables`: Table names ignored during data refresh, separated by commas. For example, ` table1, table2` - -`refresh_partition_num`: The number of partitions refreshed by a single insert statement is set to 1 by default. When refreshing a materialized view, the system first calculates the list of partitions to be refreshed and then splits it into multiple insert statements that are executed in sequence according to this configuration. If any insert statement fails, the entire task will stop executing. The materialized view ensures the transactionality of individual insert statements, meaning that failed insert statements will not affect partitions that have already been successfully refreshed. - -`workload_group`: The name of the workload_group used by the materialized view when performing refresh tasks. This is used to limit the resources used for refreshing data in the materialized view, in order to avoid affecting the operation of other business processes. For details on how to create and use workload_group, refer to [WORKLOAD-GROUP](../../../../admin-manual/workload-group.md) - -`query`: Create a query statement for the materialized view, and the result is the data in the materialized view - -`enable_nondeterministic_function`: Whether the SQL definition of the materialized view allows containing nondeterministic -functions, such as current_date(), now(), random(), etc. If true, they are allowed; otherwise, they are not allowed. -By default, they are not allowed. - -### Example - -1. Create a materialized view mv1 that refreshes immediately and then once a week, with the data source being the hive catalog - - ```sql - CREATE MATERIALIZED VIEW mv1 BUILD IMMEDIATE REFRESH COMPLETE ON SCHEDULE EVERY 1 WEEK - DISTRIBUTED BY RANDOM BUCKETS 2 - PROPERTIES ( - "replication_num" = "1" - ) - AS SELECT * FROM hive_catalog.db1.user; - ``` - -2. Create a materialized view with multiple table joins - - ```sql - CREATE MATERIALIZED VIEW mv1 BUILD IMMEDIATE REFRESH COMPLETE ON SCHEDULE EVERY 1 WEEK - DISTRIBUTED BY RANDOM BUCKETS 2 - PROPERTIES ( - "replication_num" = "1" - ) - AS select user.k1,user.k3,com.k4 from user join com on user.k1=com.k1; - ``` - -### Keywords - - CREATE, ASYNC, MATERIALIZED, VIEW - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-CATALOG.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-CATALOG.md deleted file mode 100644 index c3d59ccc4a328..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-CATALOG.md +++ /dev/null @@ -1,175 +0,0 @@ ---- -{ - "title": "CREATE-CATALOG", - "language": "en" -} ---- - - - -## CREATE-CATALOG - -### Name - -CREATE CATALOG - -### Description - -This statement is used to create an external catalog - -Syntax: - -```sql -CREATE CATALOG [IF NOT EXISTS] catalog_name [comment] - PROPERTIES ("key"="value", ...); -``` - -### Example - -1. Create catalog hive - - ```sql - CREATE CATALOG hive comment 'hive catalog' PROPERTIES ( - 'type'='hms', - 'hive.metastore.uris' = 'thrift://127.0.0.1:7004', - 'dfs.nameservices'='HANN', - 'dfs.ha.namenodes.HANN'='nn1,nn2', - 'dfs.namenode.rpc-address.HANN.nn1'='nn1_host:rpc_port', - 'dfs.namenode.rpc-address.HANN.nn2'='nn2_host:rpc_port', - 'dfs.client.failover.proxy.provider.HANN'='org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider' - ); - ``` - -2. Create catalog es - - ```sql - CREATE CATALOG es PROPERTIES ( - "type"="es", - "hosts"="http://127.0.0.1:9200" - ); - ``` - -3. Create catalog jdbc - - **mysql** - - ```sql - CREATE CATALOG jdbc PROPERTIES ( - "type"="jdbc", - "user"="root", - "password"="123456", - "jdbc_url" = "jdbc:mysql://127.0.0.1:3316/doris_test?useSSL=false", - "driver_url" = "https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/jdbc_driver/mysql-connector-java-8.0.25.jar", - "driver_class" = "com.mysql.cj.jdbc.Driver" - ); - ``` - - **postgresql** - - ```sql - CREATE CATALOG jdbc PROPERTIES ( - "type"="jdbc", - "user"="postgres", - "password"="123456", - "jdbc_url" = "jdbc:postgresql://127.0.0.1:5432/demo", - "driver_url" = "file:///path/to/postgresql-42.5.1.jar", - "driver_class" = "org.postgresql.Driver" - ); - ``` - - **clickhouse** - - ```sql - CREATE CATALOG jdbc PROPERTIES ( - "type"="jdbc", - "user"="default", - "password"="123456", - "jdbc_url" = "jdbc:clickhouse://127.0.0.1:8123/demo", - "driver_url" = "file:///path/to/clickhouse-jdbc-0.3.2-patch11-all.jar", - "driver_class" = "com.clickhouse.jdbc.ClickHouseDriver" - ) - ``` - - **oracle** - ```sql - CREATE CATALOG jdbc PROPERTIES ( - "type"="jdbc", - "user"="doris", - "password"="123456", - "jdbc_url" = "jdbc:oracle:thin:@127.0.0.1:1521:helowin", - "driver_url" = "file:///path/to/ojdbc8.jar", - "driver_class" = "oracle.jdbc.driver.OracleDriver" - ); - ``` - - **SQLServer** - ```sql - CREATE CATALOG sqlserver_catalog PROPERTIES ( - "type"="jdbc", - "user"="SA", - "password"="Doris123456", - "jdbc_url" = "jdbc:sqlserver://localhost:1433;DataBaseName=doris_test", - "driver_url" = "file:///path/to/mssql-jdbc-11.2.3.jre8.jar", - "driver_class" = "com.microsoft.sqlserver.jdbc.SQLServerDriver" - ); - ``` - - **SAP HANA** - ```sql - CREATE CATALOG saphana_catalog PROPERTIES ( - "type"="jdbc", - "user"="SYSTEM", - "password"="SAPHANA", - "jdbc_url" = "jdbc:sap://localhost:31515/TEST", - "driver_url" = "file:///path/to/ngdbc.jar", - "driver_class" = "com.sap.db.jdbc.Driver" - ); - ``` - - **Trino** - ```sql - CREATE CATALOG trino_catalog PROPERTIES ( - "type"="jdbc", - "user"="hadoop", - "password"="", - "jdbc_url" = "jdbc:trino://localhost:8080/hive", - "driver_url" = "file:///path/to/trino-jdbc-389.jar", - "driver_class" = "io.trino.jdbc.TrinoDriver" - ); - ``` - - **OceanBase** - ```sql - CREATE CATALOG oceanbase_catalog PROPERTIES ( - "type"="jdbc", - "user"="root", - "password"="", - "jdbc_url" = "jdbc:oceanbase://localhost:2881/demo", - "driver_url" = "file:///path/to/oceanbase-client-2.4.2.jar", - "driver_class" = "com.oceanbase.jdbc.Driver" - ); - ``` - -### Keywords - -CREATE, CATALOG - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-DATABASE.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-DATABASE.md deleted file mode 100644 index 2856206d3698e..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-DATABASE.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -{ - "title": "CREATE-DATABASE", - "language": "en" -} ---- - - - -## CREATE-DATABASE - -### Name - -CREATE DATABASE - -### Description - -This statement is used to create a new database (database) - -grammar: - -```sql -CREATE DATABASE [IF NOT EXISTS] db_name - [PROPERTIES ("key"="value", ...)]; -``` - -`PROPERTIES` Additional information about the database, which can be defaulted. - -- If you want to specify the default replica distribution for tables in db, you need to specify `replication_allocation` (the `replication_allocation` attribute of table will have higher priority than db) - - ```sql - PROPERTIES ( - "replication_allocation" = "tag.location.default:3" - ) - ``` - -### Example - -1. Create a new database db_test - - ```sql - CREATE DATABASE db_test; - ``` - -2. Create a new database with default replica distribution: - - ```sql - CREATE DATABASE `iceberg_test` - PROPERTIES ( - "replication_allocation" = "tag.location.group_1:3" - ); - ``` - -:::caution -If the create table statement has attributes replication_allocation or replication_num, then the default replica distribution policy of the database will not take effect. -::: - -### Keywords - -```text -CREATE, DATABASE -``` - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-ENCRYPT-KEY.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-ENCRYPT-KEY.md deleted file mode 100644 index 0b299983eddef..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-ENCRYPT-KEY.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -{ - "title": "CREATE-ENCRYPT-KEY", - "language": "en" -} ---- - - - -## CREATE-ENCRYPT-KEY - -### Name - -CREATE ENCRYPTKEY - -### Description - -This statement creates a custom key. Executing this command requires the user to have `ADMIN` privileges. - -grammar: - -```sql -CREATE ENCRYPTKEY key_name AS "key_string" -``` - -illustrate: - -`key_name`: The name of the key to be created, may contain the name of the database. For example: `db1.my_key`. - -`key_string`: The string to create the key with. - -If `key_name` contains the database name, then the custom key will be created in the corresponding database, otherwise this function will create the database in the current session. The name of the new key cannot be the same as the existing key in the corresponding database, otherwise the creation will fail. - -### Example - -1. Create a custom key - - ```sql - CREATE ENCRYPTKEY my_key AS "ABCD123456789"; - ``` - -2. Use a custom key - - To use a custom key, you need to add the keyword `KEY`/`key` before the key, separated from the `key_name` space. - - ```sql - mysql> SELECT HEX(AES_ENCRYPT("Doris is Great", KEY my_key)); - +------------------------------------------------+ - | hex(aes_encrypt('Doris is Great', key my_key)) | - +------------------------------------------------+ - | D26DB38579D6A343350EDDC6F2AD47C6 | - +------------------------------------------------+ - 1 row in set (0.02 sec) - - mysql> SELECT AES_DECRYPT(UNHEX('D26DB38579D6A343350EDDC6F2AD47C6'), KEY my_key); - +------------------------------------------------- -------------------+ - | aes_decrypt(unhex('D26DB38579D6A343350EDDC6F2AD47C6'), key my_key) | - +------------------------------------------------- -------------------+ - | Doris is Great | - +------------------------------------------------- -------------------+ - 1 row in set (0.01 sec) - ``` - -### Keywords - - CREATE, ENCRYPTKEY - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FILE.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FILE.md deleted file mode 100644 index ef3b72d88b3c6..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FILE.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -{ - "title": "CREATE-FILE", - "language": "en" -} ---- - - - -## CREATE-FILE - -### Name - -CREATE FILE - -### Description - -This statement is used to create and upload a file to the Doris cluster. -This function is usually used to manage files that need to be used in some other commands, such as certificates, public and private keys, and so on. - -This command can only be executed by users with `admin` privileges. -A certain file belongs to a certain database. This file can be used by any user with access rights to database. - -A single file size is limited to 1MB. -A Doris cluster can upload up to 100 files. - -grammar: - -```sql -CREATE FILE "file_name" [IN database] -PROPERTIES("key"="value", ...) -``` - -illustrate: - -- file_name: custom file name. -- database: The file belongs to a certain db, if not specified, the db of the current session is used. -- properties supports the following parameters: - - url: Required. Specifies the download path for a file. Currently only unauthenticated http download paths are supported. After the command executes successfully, the file will be saved in doris and the url will no longer be needed. - - catalog: Required. The classification name of the file can be customized. However, in some commands, files in the specified catalog are looked up. For example, in the routine import, when the data source is kafka, the file under the catalog name kafka will be searched. - - md5: optional. md5 of the file. If specified, verification will be performed after the file is downloaded. - -### Example - -1. Create a file ca.pem , classified as kafka - - ```sql - CREATE FILE "ca.pem" - PROPERTIES - ( - "url" = "https://test.bj.bcebos.com/kafka-key/ca.pem", - "catalog" = "kafka" - ); - ``` - -2. Create a file client.key, classified as my_catalog - - ```sql - CREATE FILE "client.key" - IN my_database - PROPERTIES - ( - "url" = "https://test.bj.bcebos.com/kafka-key/client.key", - "catalog" = "my_catalog", - "md5" = "b5bb901bf10f99205b39a46ac3557dd9" - ); - ``` - -### Keywords - -```text -CREATE, FILE -``` - -### Best Practice - -1. This command can only be executed by users with amdin privileges. A certain file belongs to a certain database. This file can be used by any user with access rights to database. - -2. File size and quantity restrictions. - - This function is mainly used to manage some small files such as certificates. So a single file size is limited to 1MB. A Doris cluster can upload up to 100 files. - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FUNCTION.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FUNCTION.md deleted file mode 100644 index 43cbeb36ac334..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FUNCTION.md +++ /dev/null @@ -1,133 +0,0 @@ ---- -{ - "title": "CREATE-FUNCTION", - "language": "en" -} ---- - - - -## CREATE-FUNCTION - -### Name - -CREATE FUNCTION - -### Description - -This statement creates a custom function. Executing this command requires the user to have `ADMIN` privileges. - -If `function_name` contains the database name, then the custom function will be created in the corresponding database, otherwise the function will be created in the database where the current session is located. The name and parameters of the new function cannot be the same as the existing functions in the current namespace, otherwise the creation will fail. But only with the same name and different parameters can be created successfully. - -grammar: - -```sql -CREATE [GLOBAL] [AGGREGATE] [ALIAS] FUNCTION function_name - (arg_type [, ...]) - [RETURNS ret_type] - [INTERMEDIATE inter_type] - [WITH PARAMETER(param [,...]) AS origin_function] - [PROPERTIES ("key" = "value" [, ...]) ] -``` - -Parameter Description: - -- `GLOBAL`: If there is this item, it means that the created function is a global function. - -- `AGGREGATE`: If there is this item, it means that the created function is an aggregate function. - - -- `ALIAS`: If there is this item, it means that the created function is an alias function. - - - If the above two items are absent, it means that the created function is a scalar function - -- `function_name`: The name of the function to be created, which can include the name of the database. For example: `db1.my_func`. - - -- `arg_type`: The parameter type of the function, which is the same as the type defined when creating the table. Variable-length parameters can be represented by `, ...`. If it is a variable-length type, the type of the variable-length parameter is the same as that of the last non-variable-length parameter. - - **NOTE**: `ALIAS FUNCTION` does not support variable-length arguments and must have at least one argument. - -- `ret_type`: Required for creating new functions. If you are aliasing an existing function, you do not need to fill in this parameter. - - -- `inter_type`: The data type used to represent the intermediate stage of the aggregation function. - - -- `param`: used to represent the parameter of the alias function, including at least one. - - -- `origin_function`: used to represent the original function corresponding to the alias function. - - -- `properties`: Used to set function-related properties, the properties that can be set include: - - - `file`: Indicates the jar package containing the user UDF. In a multi-machine environment, you can also use http to download the jar package. This parameter is mandatory. - - - `symbol`: Indicates the name of the class containing the UDF class. This parameter must be set - - - `type`: Indicates the UDF call type, the default is Native, and JAVA_UDF is passed when using Java UDF. - - - `always_nullable`: Indicates whether NULL values may appear in the UDF return result, is an optional parameter, and the default value is true. - - -### Example - -1. Create a custom UDF function - - ```sql - CREATE FUNCTION java_udf_add_one(int) RETURNS int PROPERTIES ( - "file"="file:///path/to/java-udf-demo-jar-with-dependencies.jar", - "symbol"="org.apache.doris.udf.AddOne", - "always_nullable"="true", - "type"="JAVA_UDF" - ); - ``` - - -2. Create a custom UDAF function - - ```sql - CREATE AGGREGATE FUNCTION simple_sum(INT) RETURNS INT PROPERTIES ( - "file"="file:///pathTo/java-udaf.jar", - "symbol"="org.apache.doris.udf.demo.SimpleDemo", - "always_nullable"="true", - "type"="JAVA_UDF" - ); - ``` - -3. Create a custom alias function - - ```sql - CREATE ALIAS FUNCTION id_masking(INT) WITH PARAMETER(id) AS CONCAT(LEFT(id, 3), '****', RIGHT(id, 4)); - ``` - -4. Create a global custom alias function - - ```sql - CREATE GLOBAL ALIAS FUNCTION id_masking(INT) WITH PARAMETER(id) AS CONCAT(LEFT(id, 3), '****', RIGHT(id, 4)); - ``` - -### Keywords - - CREATE, FUNCTION - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-INDEX.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-INDEX.md deleted file mode 100644 index 3fb8465a3bde4..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-INDEX.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -{ - "title": "CREATE-INDEX", - "language": "en" -} ---- - - - -## CREATE-INDEX - -### Name - -CREATE INDEX - -### Description - -This statement is used to create an index -grammar: - -```sql -CREATE INDEX [IF NOT EXISTS] index_name ON table_name (column [, ...],) [USING INVERTED] [COMMENT 'balabala']; -``` -Notice: -- INVERTED indexes are only created on a single column - -### Example - -1. Create a inverted index for siteid on table1 - - ```sql - CREATE INDEX [IF NOT EXISTS] index_name ON table1 (siteid) USING INVERTED COMMENT 'balabala'; - ``` - - -### Keywords - -```text -CREATE, INDEX -``` - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-JOB.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-JOB.md deleted file mode 100644 index 3cebd60404bf4..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-JOB.md +++ /dev/null @@ -1,173 +0,0 @@ ---- -{ -"title": "CREATE-JOB", -"language": "en" -} - ---- - - -## CREATE-JOB - -### Name - -:::tip -CREATE JOB -- since 2.1 -::: - -### Description - -Doris Job is a task that runs according to a predefined schedule, triggering predefined actions at specific times or intervals to help automate certain tasks. In terms of functionality, it is similar to scheduled tasks on operating systems (e.g., cron in Linux, scheduled tasks in Windows).↳ - -There are two types of Jobs: ONE_TIME and RECURRING. The ONE_TIME type of Job triggers at a specified time point and is mainly used for one-time tasks, while the RECURRING type of Job triggers at specified time intervals and is used for periodically recurring tasks. The RECURRING type of Job can specify a start time and an end time using STARTS\ENDS. If the start time is not specified, the first execution time is set to the current time plus one scheduling period. If the end time is specified and the task completes execution by reaching the end time (or exceeds it, or the next execution period exceeds the end time), the Job status is updated to FINISHED, and no more Tasks are generated. - -#### Job Status - -A Job has four states (RUNNING, STOPPED, PAUSED, FINISHED), with the initial state being RUNNING. A Job in the RUNNING state generates Tasks based on the specified scheduling period. When a Job completes execution and reaches the end time, the status changes to FINISHED. - -A Job in the RUNNING state can be paused, which means it will no longer generate Tasks. - -A Job in the PAUSED state can be resumed by performing the RESUME operation, changing the state to RUNNING. - -A Job in the STOPPED state is triggered by the user, which cancels the running Job and then deletes it. - -A Job in the FINISHED state remains in the system for 24 hours and is deleted after that. - -#### Task status - -A Job only describes the job information, and the execution generates Tasks. The Task status can be PENDING, RUNNING, SUCCESS, FAILED, or CANCELED. - -PENDING indicates that the trigger time has been reached but resources are awaited for running. Once resources are allocated, the status changes to RUNNING. When the execution is successful or fails, the status changes to SUCCESS or FAILED, respectively. - -CANCELED indicates the cancellation status. The final status of a Task is persisted as SUCCESS or FAILED. Other statuses can be queried while the Task is running, but they become invisible after a restart. Only the latest 100 Task records are retained. - -#### Permissions - -Currently, only users with the ADMIN role can perform this operation. - -#### Related Documentation - -- [PAUSE-JOB](../Alter/PAUSE-JOB.md) -- [RESUME-JOB](../Alter/RESUME-JOB.md) -- [DROP-JOB](../Drop/DROP-JOB.md) -- [VIEW-JOB](../../../sql-functions/table-valued-functions/jobs.md), -- [VIEW-TASKS](../../../sql-functions/table-valued-functions/tasks.md) - -### Grammar - -```sql -CREATE - job - job_name - ON SCHEDULE schedule - [COMMENT 'string'] - DO sql_body; - -schedule: { - AT timestamp - | EVERY interval - [STARTS timestamp] - [ENDS timestamp ] -} - -interval: - quantity { DAY | HOUR | MINUTE | - WEEK | SECOND } -``` - -A valid Job statement must contain the following - -- The keyword CREATE JOB plus the job name, which uniquely identifies the event within a database. The job name must be globally unique, and if a JOB with the same name already exists, an error will be reported. We reserve the inner_ prefix for internal use, so users cannot create names starting with ***inner_***. -- The ON SCHEDULE clause, which specifies the type of Job and when and how often to trigger it. -- The DO clause, which specifies the actions that need to be performed when the Job is triggered. - -Here is a minimal example: - -```sql -CREATE JOB my_job ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO db1.tbl1 SELECT * FROM db2.tbl2; -``` - -This statement means to create a job named my_job to be executed every minute, and the operation performed is to import the data in db2.tbl2 into db1.tbl1. - -The SCHEDULE statement is used to define the execution time, frequency and duration of the job, which can specify a one-time job or a periodic job. -- AT timestamp - -Format: 'YYYY-MM-DD HH:MM:SS'. Used for one-time events, it specifies that the event should only be executed once at the given date and time. Once the execution is complete, the Job status changes to FINISHED. - -- EVERY - - Indicates that the operation is repeated periodically, which specifies the execution frequency of the job. After the keyword, a time interval should be specified, which can be days, hours, minutes, seconds, and weeks. - - - interval - - Used to specify the Job execution frequency, which can be `day`, `hour`, `minute`, or `week`. For example, 1 `DAY` means the Job will run once every day, 1 `HOUR` means once every hour, 1 `MINUTE` means once every minute, and `1 The CREATE JOB statement is used to create a job in a database. A job is a task that can be scheduled to run at specific times or intervals to automate certain actions. - - - STARTS timestamp(optional) - - Format: 'YYYY-MM-DD HH:MM:SS'. It is used to specify the start time of the job. If not specified, the job starts executing from the next occurrence based on the current time. The start time must be greater than the current time. - - - ENDS timestamp(optional) - - Format: 'YYYY-MM-DD HH:MM:SS'. It is used to specify the end time of the job. If not specified, it means the job executes indefinitely. The end date must be greater than the current time. If a start time (↳STARTS) is specified, the end time must be greater than the start time. - -- DO - - It is used to specify the operation that needs to be performed when the job is triggered. Currently, all ***INSERT*** operations are supported. We will support more operations in the future. - -### Example - -Create a one-time job, which will be executed once at 2020-01-01 00:00:00, and the operation performed is to import the data in db2.tbl2 into db1.tbl1. - -```sql - -CREATE JOB my_job ON SCHEDULE AT '2020-01-01 00:00:00' DO INSERT INTO db1.tbl1 SELECT * FROM db2.tbl2; - -``` - -Create a periodic Job, which will start to execute at 2020-01-01 00:00:00, once a day, and the operation is to import the data in db2.tbl2 into db1.tbl1. - -```sql -CREATE JOB my_job ON SCHEDULE EVERY 1 DAY STARTS '2020-01-01 00:00:00' DO INSERT INTO db1.tbl1 SELECT * FROM db2.tbl2 WHERE create_time >= days_add(now(),-1); -``` - -Create a periodic Job, which will start to execute at 2020-01-01 00:00:00, and execute once a day. The operation performed is to import the data in db2.tbl2 into db1.tbl1. This Job will be executed in 2020 Ends at -01-01 00:10:00. - -```sql -CREATE JOB my_job ON SCHEDULE EVERY 1 DAY STARTS '2020-01-01 00:00:00' ENDS '2020-01-01 00:10:00' DO INSERT INTO db1.tbl1 SELECT * FROM db2.tbl2 create_time >= days_add (now(),-1); -``` - -### CONFIG - -#### fe.conf - -- job_dispatch_timer_job_thread_num: Number of threads used for dispatching scheduled tasks. Default value is 2. If there are a large number of periodically executed tasks, this parameter can be increased. -- job_dispatch_timer_job_queue_size: Size of the queue used for storing scheduled tasks when there is task accumulation. Default value is 1024. If there are a large number of tasks triggered at the same time, this parameter can be increased. Otherwise, the queue may become full and submitting tasks will be blocked, causing subsequent tasks to be unable to submit. -- finished_job_cleanup_threshold_time_hour: Time threshold, in hours, for cleaning up completed tasks. Default value is 24 hours. -- job_insert_task_consumer_thread_num: Number of threads used for executing Insert tasks. The value should be greater than 0, otherwise the default value is 5. - -### Best Practice - -- Properly manage Jobs to avoid triggering a large number of Jobs simultaneously, which can lead to task accumulation and affect the normal operation of the system. -- Set the execution interval of tasks within a reasonable range, ensuring that it is at least greater than the task execution time. - -### Keywords - - CREATE, JOB, SCHEDULE diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-MATERIALIZED-VIEW.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-MATERIALIZED-VIEW.md deleted file mode 100644 index 6221bff117ab9..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,235 +0,0 @@ ---- -{ - "title": "CREATE-MATERIALIZED-VIEW", - "language": "en" -} ---- - - - -## CREATE-MATERIALIZED-VIEW - -### Name - -CREATE MATERIALIZED VIEW - -### Description - -This statement is used to create a materialized view. - -This operation is an asynchronous operation. After the submission is successful, you need to view the job progress through [SHOW ALTER TABLE MATERIALIZED VIEW](../../Show-Statements/SHOW-ALTER-TABLE-MATERIALIZED-VIEW.md). After displaying FINISHED, you can use the `desc [table_name] all` command to view the schema of the materialized view. - -grammar: - -```sql -CREATE MATERIALIZED VIEW < MV name > as < query > -[PROPERTIES ("key" = "value")] -``` - -illustrate: - -- `MV name`: The name of the materialized view, required. Materialized view names for the same table cannot be repeated. - -- `query`: The query statement used to construct the materialized view, the result of the query statement is the data of the materialized view. Currently supported query formats are: - - ```sql - SELECT select_expr[, select_expr ...] - FROM [Base view name] - GROUP BY column_name[, column_name ...] - ORDER BY column_name[, column_name ...] - ``` - - The syntax is the same as the query syntax. - - - `select_expr`: All columns in the schema of the materialized view. - - Contains at least one single column. - - `base view name`: The original table name of the materialized view, required. - - Must be a single table and not a subquery - - `group by`: The grouping column of the materialized view, optional. - - If not filled, the data will not be grouped. - - `order by`: the sorting column of the materialized view, optional. - - The declaration order of the sort column must be the same as the column declaration order in select_expr. - - If order by is not declared, the sorting column is automatically supplemented according to the rules. If the materialized view is an aggregate type, all grouping columns are automatically supplemented as sort columns. If the materialized view is of a non-aggregate type, the first 36 bytes are automatically supplemented as the sort column. - - If the number of auto-supplemented sorts is less than 3, the first three are used as the sort sequence. If query contains a grouping column, the sorting column must be the same as the grouping column. - -- properties - - Declare some configuration of the materialized view, optional. - - ```text - PROPERTIES ("key" = "value", "key" = "value" ...) - ``` - - The following configurations can be declared here: - - ```text - short_key: The number of sorting columns. - timeout: The timeout for materialized view construction. - ``` - -### Example - -Base table structure is - -```sql -mysql> desc duplicate_table; -+-------+--------+------+------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-------+--------+------+------+---------+-------+ -| k1 | INT | Yes | true | N/A | | -| k2 | INT | Yes | true | N/A | | -| k3 | BIGINT | Yes | true | N/A | | -| k4 | BIGINT | Yes | true | N/A | | -+-------+--------+------+------+---------+-------+ -``` -```sql -create table duplicate_table( - k1 int null, - k2 int null, - k3 bigint null, - k4 bigint null -) -duplicate key (k1,k2,k3,k4) -distributed BY hash(k4) buckets 3 -properties("replication_num" = "1"); -``` -attention:If the materialized view contains partitioned and distributed columns of the Base table, these columns must be used as key columns in the materialized view - -1. Create a materialized view that contains only the columns of the original table (k1, k2) - - ```sql - create materialized view k2_k1 as - select k2, k1 from duplicate_table; - ``` - - The schema of the materialized view is as follows, the materialized view contains only two columns k1, k2 without any aggregation - - ```text - +-------+-------+--------+------+------+ ---------+-------+ - | IndexName | Field | Type | Null | Key | Default | Extra | - +-------+-------+--------+------+------+ ---------+-------+ - | k2_k1 | k2 | INT | Yes | true | N/A | | - | | k1 | INT | Yes | true | N/A | | - +-------+-------+--------+------+------+ ---------+-------+ - ``` - -2. Create a materialized view with k2 as the sort column - - ```sql - create materialized view k2_order as - select k2, k1 from duplicate_table order by k2; - ``` - - The schema of the materialized view is shown in the figure below. The materialized view contains only two columns k2, k1, where k2 is the sorting column without any aggregation. - - ```text - +-------+-------+--------+------+------- +---------+-------+ - | IndexName | Field | Type | Null | Key | Default | Extra | - +-------+-------+--------+------+------- +---------+-------+ - | k2_order | k2 | INT | Yes | true | N/A | | - | | k1 | INT | Yes | false | N/A | NONE | - +-------+-------+--------+------+------- +---------+-------+ - ``` - -3. Create a materialized view with k1, k2 grouping and k3 column aggregated by SUM - - ```sql - create materialized view k1_k2_sumk3 as - select k1, k2, sum(k3) from duplicate_table group by k1, k2; - ``` - - The schema of the materialized view is shown in the figure below. The materialized view contains two columns k1, k2, sum(k3) where k1, k2 are the grouping columns, and sum(k3) is the sum value of the k3 column grouped by k1, k2. - - Since the materialized view does not declare a sorting column, and the materialized view has aggregated data, the system defaults to supplement the grouping columns k1 and k2 as sorting columns. - - ```text - +-------+-------+--------+------+------- +---------+-------+ - | IndexName | Field | Type | Null | Key | Default | Extra | - +-------+-------+--------+------+------- +---------+-------+ - | k1_k2_sumk3 | k1 | INT | Yes | true | N/A | | - | | k2 | INT | Yes | true | N/A | | - | | k3 | BIGINT | Yes | false | N/A | SUM | - +-------+-------+--------+------+------- +---------+-------+ - ``` - -4. Create a materialized view that removes duplicate rows - - ```sql - create materialized view deduplicate as - select k1, k2, k3, k4 from duplicate_table group by k1, k2, k3, k4; - ``` - - The materialized view schema is as shown below. The materialized view contains columns k1, k2, k3, and k4, and there are no duplicate rows. - - ```text - +-------+-------+--------+------+------- +---------+-------+ - | IndexName | Field | Type | Null | Key | Default | Extra | - +-------+-------+--------+------+------- +---------+-------+ - | deduplicate | k1 | INT | Yes | true | N/A | | - | | k2 | INT | Yes | true | N/A | | - | | k3 | BIGINT | Yes | true | N/A | | - | | k4 | BIGINT | Yes | true | N/A | | - +-------+-------+--------+------+------- +---------+-------+ - ``` - -5. Create a non-aggregate materialized view that does not declare a sort column - - The schema of all_type_table is as follows - - ``` - +-------+--------------+------+-------+---------+- ------+ - | Field | Type | Null | Key | Default | Extra | - +-------+--------------+------+-------+---------+- ------+ - | k1 | TINYINT | Yes | true | N/A | | - | k2 | SMALLINT | Yes | true | N/A | | - | k3 | INT | Yes | true | N/A | | - | k4 | BIGINT | Yes | true | N/A | | - | k5 | DECIMAL(9,0) | Yes | true | N/A | | - | k6 | DOUBLE | Yes | false | N/A | NONE | - | k7 | VARCHAR(20) | Yes | false | N/A | NONE | - +-------+--------------+------+-------+---------+- ------+ - ``` - - The materialized view contains k3, k4, k5, k6, k7 columns, and does not declare a sort column, the creation statement is as follows: - - ```sql - create materialized view mv_1 as - select k3, k4, k5, k6, k7 from all_type_table; - ``` - - The default added sorting column of the system is k3, k4, k5 three columns. The sum of the bytes of these three column types is 4(INT) + 8(BIGINT) + 16(DECIMAL) = 28 < 36. So the addition is that these three columns are used as sorting columns. The schema of the materialized view is as follows, you can see that the key field of the k3, k4, k5 columns is true, that is, the sorting column. The key field of the k6, k7 columns is false, which is a non-sorted column. - - ```sql - +----------------+-------+--------------+------+-- -----+---------+-------+ - | IndexName | Field | Type | Null | Key | Default | Extra | - +----------------+-------+--------------+------+-- -----+---------+-------+ - | mv_1 | k3 | INT | Yes | true | N/A | | - | | k4 | BIGINT | Yes | true | N/A | | - | | k5 | DECIMAL(9,0) | Yes | true | N/A | | - | | k6 | DOUBLE | Yes | false | N/A | NONE | - | | k7 | VARCHAR(20) | Yes | false | N/A | NONE | - +----------------+-------+--------------+------+-- -----+---------+-------+ - ``` - -### Keywords - - CREATE, MATERIALIZED, VIEW - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-POLICY.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-POLICY.md deleted file mode 100644 index 86f3dc6f76757..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-POLICY.md +++ /dev/null @@ -1,126 +0,0 @@ ---- -{ - "title": "CREATE-POLICY", - "language": "en" -} ---- - - - -## CREATE-POLICY - -### Name - -CREATE POLICY - -### Description - -Create policies,such as: -1. Create security policies(ROW POLICY) and explain to view the rewritten SQL. -2. Create storage migration policy(STORAGE POLICY), used for cold and hot data transform - -#### Grammar: - -1. ROW POLICY -```sql -CREATE ROW POLICY test_row_policy_1 ON test.table1 -AS {RESTRICTIVE|PERMISSIVE} TO test USING (id in (1, 2)); -``` - -illustrate: - -- filterType:It is usual to constrict a set of policies through AND. PERMISSIVE to constrict a set of policies through OR -- Configure multiple policies. First, merge the RESTRICTIVE policy with the PERMISSIVE policy -- It is connected with AND between RESTRICTIVE AND PERMISSIVE -- It cannot be created for users root and admin - -2. STORAGE POLICY -```sql -CREATE STORAGE POLICY test_storage_policy_1 -PROPERTIES ("key"="value", ...); -``` -illustrate: -- PROPERTIES has such keys: - 1. storage_resource:storage resource name for policy - 2. cooldown_datetime:cool down time for tablet, can't be set with cooldown_ttl. - 3. cooldown_ttl:hot data stay time. The time cost between the time of tablet created and - the time of migrated to cold data, formatted as: - 1d:1 day - 1h:1 hour - 50000: 50000 second - -### Example - -1. Create a set of row security policies - - ```sql - CREATE ROW POLICY test_row_policy_1 ON test.table1 - AS RESTRICTIVE TO test USING (c1 = 'a'); - ``` - ```sql - CREATE ROW POLICY test_row_policy_2 ON test.table1 - AS RESTRICTIVE TO test USING (c2 = 'b'); - ``` - ```sql - CREATE ROW POLICY test_row_policy_3 ON test.table1 - AS PERMISSIVE TO test USING (c3 = 'c'); - ``` - ```sql - CREATE ROW POLICY test_row_policy_3 ON test.table1 - AS PERMISSIVE TO test USING (c4 = 'd'); - ``` - - When we execute the query on Table1, the rewritten SQL is - - ```sql - select * from (select * from table1 where c1 = 'a' and c2 = 'b' or c3 = 'c' or c4 = 'd') - ``` - -2. Create policy for storage - 1. NOTE - - To create a cold hot separation policy, you must first create a resource, and then associate the created resource name when creating a migration policy - - Currently, the drop data migration policy is not supported to prevent data from being migrated. If the policy has been deleted, then the system cannot retrieve the data - 2. Create policy on cooldown_datetime - ```sql - CREATE STORAGE POLICY testPolicy - PROPERTIES( - "storage_resource" = "s3", - "cooldown_datetime" = "2022-06-08 00:00:00" - ); - ``` - 3. Create policy on cooldown_ttl - ```sql - CREATE STORAGE POLICY testPolicy - PROPERTIES( - "storage_resource" = "s3", - "cooldown_ttl" = "1d" - ); - ``` - Relevant parameters are as follows: - - `storage_resource`: the storage resource of create - - `cooldown_datetime`: Data migration time - - `cooldown_ttl`: Countdown of the distance between the migrated data and the current time - -### Keywords - - CREATE, POLICY - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-RESOURCE.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-RESOURCE.md deleted file mode 100644 index 3158dd0ae1912..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-RESOURCE.md +++ /dev/null @@ -1,249 +0,0 @@ ---- -{ - "title": "CREATE-RESOURCE", - "language": "en" -} ---- - - - -## CREATE-RESOURCE - -### Name - -CREATE RESOURCE - -### Description - -This statement is used to create a resource. Only the root or admin user can create resources. Currently supports Spark, ODBC, S3 external resources. -In the future, other external resources may be added to Doris for use, such as Spark/GPU for query, HDFS/S3 for external storage, MapReduce for ETL, etc. - -grammar: - -```sql -CREATE [EXTERNAL] RESOURCE "resource_name" -PROPERTIES ("key"="value", ...); -``` - -illustrate: - -- The type of resource needs to be specified in PROPERTIES "type" = "[spark|odbc_catalog|s3]", currently supports spark, odbc_catalog, s3. -- PROPERTIES differs depending on the resource type, see the example for details. - -### Example - -1. Create a Spark resource named spark0 in yarn cluster mode. - - ```sql - CREATE EXTERNAL RESOURCE "spark0" - PROPERTIES - ( - "type" = "spark", - "spark.master" = "yarn", - "spark.submit.deployMode" = "cluster", - "spark.jars" = "xxx.jar,yyy.jar", - "spark.files" = "/tmp/aaa,/tmp/bbb", - "spark.executor.memory" = "1g", - "spark.yarn.queue" = "queue0", - "spark.hadoop.yarn.resourcemanager.address" = "127.0.0.1:9999", - "spark.hadoop.fs.defaultFS" = "hdfs://127.0.0.1:10000", - "working_dir" = "hdfs://127.0.0.1:10000/tmp/doris", - "broker" = "broker0", - "broker.username" = "user0", - "broker.password" = "password0" - ); - ``` - - Spark related parameters are as follows: - - spark.master: Required, currently supports yarn, spark://host:port. - - spark.submit.deployMode: The deployment mode of the Spark program, required, supports both cluster and client. - - spark.hadoop.yarn.resourcemanager.address: Required when master is yarn. - - spark.hadoop.fs.defaultFS: Required when master is yarn. - - Other parameters are optional, refer to [here](http://spark.apache.org/docs/latest/configuration.html) - - - - Working_dir and broker need to be specified when Spark is used for ETL. described as follows: - - - working_dir: The directory used by the ETL. Required when spark is used as an ETL resource. For example: hdfs://host:port/tmp/doris. - - broker: broker name. Required when spark is used as an ETL resource. Configuration needs to be done in advance using the `ALTER SYSTEM ADD BROKER` command. - - broker.property_key: The authentication information that the broker needs to specify when reading the intermediate file generated by ETL. - -2. Create an ODBC resource - - ```sql - CREATE EXTERNAL RESOURCE `oracle_odbc` - PROPERTIES ( - "type" = "odbc_catalog", - "host" = "192.168.0.1", - "port" = "8086", - "user" = "test", - "password" = "test", - "database" = "test", - "odbc_type" = "oracle", - "driver" = "Oracle 19 ODBC driver" - ); - ``` - - The relevant parameters of ODBC are as follows: - - hosts: IP address of the external database - - driver: The driver name of the ODBC appearance, which must be the same as the Driver name in be/conf/odbcinst.ini. - - odbc_type: the type of the external database, currently supports oracle, mysql, postgresql - - user: username of the foreign database - - password: the password information of the corresponding user - - charset: connection charset - - There is also support for implementing custom parameters per ODBC Driver, see the description of the corresponding ODBC Driver - -3. Create S3 resource - - ```sql - CREATE RESOURCE "remote_s3" - PROPERTIES - ( - "type" = "s3", - "s3.endpoint" = "bj.s3.com", - "s3.region" = "bj", - "s3.access_key" = "bbb", - "s3.secret_key" = "aaaa", - -- the followings are optional - "s3.connection.maximum" = "50", - "s3.connection.request.timeout" = "3000", - "s3.connection.timeout" = "1000" - ); - ``` - - If S3 resource is used for [cold hot separation](../../../../../docs/advanced/cold_hot_separation.md), we should add more required fields. - ```sql - CREATE RESOURCE "remote_s3" - PROPERTIES - ( - "type" = "s3", - "s3.endpoint" = "bj.s3.com", - "s3.region" = "bj", - "s3.access_key" = "bbb", - "s3.secret_key" = "aaaa", - -- required by cooldown - "s3.root.path" = "/path/to/root", - "s3.bucket" = "test-bucket" - ); - ``` - - S3 related parameters are as follows: - - Required parameters - - `s3.endpoint`: s3 endpoint - - `s3.region`:s3 region - - `s3.root.path`: s3 root directory - - `s3.access_key`: s3 access key - - `s3.secret_key`: s3 secret key - - `s3.bucket`:s3 bucket - - optional parameter - - `s3.connection.maximum`: the maximum number of s3 connections, the default is 50 - - `s3.connection.request.timeout`: s3 request timeout, in milliseconds, the default is 3000 - - `s3.connection.timeout`: s3 connection timeout, in milliseconds, the default is 1000 - -4. Create JDBC resource - - ```sql - CREATE RESOURCE mysql_resource PROPERTIES ( - "type"="jdbc", - "user"="root", - "password"="123456", - "jdbc_url" = "jdbc:mysql://127.0.0.1:3316/doris_test?useSSL=false", - "driver_url" = "https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/jdbc_driver/mysql-connector-java-8.0.25.jar", - "driver_class" = "com.mysql.cj.jdbc.Driver" - ); - ``` - - JDBC related parameters are as follows: - - user:The username used to connect to the database - - password:The password used to connect to the database - - jdbc_url: The identifier used to connect to the specified database - - driver_url: The url of JDBC driver package - - driver_class: The class of JDBC driver - -5. Create HDFS resource - - ```sql - CREATE RESOURCE hdfs_resource PROPERTIES ( - "type"="hdfs", - "hadoop.username"="user", - "root_path"="your_path", - "dfs.nameservices" = "my_ha", - "dfs.ha.namenodes.my_ha" = "my_namenode1, my_namenode2", - "dfs.namenode.rpc-address.my_ha.my_namenode1" = "nn1_host:rpc_port", - "dfs.namenode.rpc-address.my_ha.my_namenode2" = "nn2_host:rpc_port", - "dfs.client.failover.proxy.provider.my_ha" = "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider" - ); - ``` - - HDFS related parameters are as follows: - - fs.defaultFS: namenode address and port - - hadoop.username: hdfs username - - dfs.nameservices: if hadoop enable HA, please set fs nameservice. See hdfs-site.xml - - dfs.ha.namenodes.[nameservice ID]:unique identifiers for each NameNode in the nameservice. See hdfs-site.xml - - dfs.namenode.rpc-address.[nameservice ID].[name node ID]`:the fully-qualified RPC address for each NameNode to listen on. See hdfs-site.xml - - dfs.client.failover.proxy.provider.[nameservice ID]:the Java class that HDFS clients use to contact the Active NameNode, usually it is org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider - -6. Create HMS resource - - HMS resource is used to create [hms catalog](../../../../lakehouse/multi-catalog/multi-catalog.md) - ```sql - CREATE RESOURCE hms_resource PROPERTIES ( - 'type'='hms', - 'hive.metastore.uris' = 'thrift://127.0.0.1:7004', - 'dfs.nameservices'='HANN', - 'dfs.ha.namenodes.HANN'='nn1,nn2', - 'dfs.namenode.rpc-address.HANN.nn1'='nn1_host:rpc_port', - 'dfs.namenode.rpc-address.HANN.nn2'='nn2_host:rpc_port', - 'dfs.client.failover.proxy.provider.HANN'='org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider' - ); - ``` - - HMS related parameters are as follows: - - hive.metastore.uris: hive metastore server address - Optional: - - dfs.*: If hive data is on hdfs, HDFS resource parameters should be added, or copy hive-site.xml into fe/conf. - - s3.*: If hive data is on s3, S3 resource parameters should be added. If using [Aliyun Data Lake Formation](https://www.aliyun.com/product/bigdata/dlf), copy hive-site.xml into fe/conf. - -7. Create ES resource - - ```sql - CREATE RESOURCE es_resource PROPERTIES ( - "type"="es", - "hosts"="http://127.0.0.1:29200", - "nodes_discovery"="false", - "enable_keyword_sniff"="true" - ); - ``` - - ES related parameters are as follows: - - hosts: ES Connection Address, maybe one or more node, load-balance is also accepted - - user: username for ES - - password: password for the user - - enable_docvalue_scan: whether to enable ES/Lucene column storage to get the value of the query field, the default is true - - enable_keyword_sniff: Whether to probe the string segmentation type text.fields in ES, query by keyword (the default is true, false matches the content after the segmentation) - - nodes_discovery: Whether or not to enable ES node discovery, the default is true. In network isolation, set this parameter to false. Only the specified node is connected - - http_ssl_enabled: Whether ES cluster enables https access mode, the current FE/BE implementation is to trust all - -### Keywords - - CREATE, RESOURCE - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-SQL-BLOCK-RULE.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-SQL-BLOCK-RULE.md deleted file mode 100644 index f9083249186c5..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-SQL-BLOCK-RULE.md +++ /dev/null @@ -1,158 +0,0 @@ ---- -{ - "title": "CREATE-SQL-BLOCK-RULE", - "language": "en" -} ---- - - - -## CREATE-SQL-BLOCK-RULE - -### Name - -CREATE SQL BLOCK RULE - -### Description - -This statement creates a SQL blocking rule. it can restrict any kind of sql statements(no matter DDL or DML statement). - -Supports configuring SQL blacklists by user: - -- Refuse to specify SQL by regular matching -- Check if a sql reaches one of these limits by setting partition_num, tablet_num, cardinality - - partition_num, tablet_num, cardinality can be set together, once a query reaches one of these limits, the query will be intercepted - -grammar: - -```sql -CREATE SQL_BLOCK_RULE rule_name -[PROPERTIES ("key"="value", ...)]; -``` - -Parameter Description: - -- sql: matching rule (based on regular matching, special characters need to be translated,for example`select *`use`select \\*`), optional, the default value is "NULL" -- sqlHash: sql hash value, used for exact matching, we will print this value in `fe.audit.log`, optional, this parameter and sql can only be selected one, the default value is "NULL" -- partition_num: the maximum number of partitions a scan node will scan, the default value is 0L -- tablet_num: The maximum number of tablets that a scanning node will scan, the default value is 0L -- cardinality: the rough scan line number of a scan node, the default value is 0L -- global: Whether to take effect globally (all users), the default is false -- enable: whether to enable blocking rules, the default is true - -### Example - -1. Create a block rule named test_rule - - ```sql - CREATE SQL_BLOCK_RULE test_rule - PROPERTIES( - "sql"="select \\* from order_analysis", - "global"="false", - "enable"="true" - ); - ``` - - >Notes: - > - >That the sql statement here does not end with a semicolon - - When we execute the sql we just defined in the rule, an exception error will be returned. The example is as follows: - - ```sql - select * from order_analysis; - ERROR 1064 (HY000): errCode = 2, detailMessage = sql match regex sql block rule: order_analysis_rule - ``` - - -2. Create test_rule2, limit the maximum number of scanned partitions to 30, and limit the maximum scan base to 10 billion rows. The example is as follows: - - ```sql - CREATE SQL_BLOCK_RULE test_rule2 - PROPERTIES ( - "partition_num" = "30", - "cardinality" = "10000000000", - "global" = "false", - "enable" = "true" - ); - ``` -3. Create SQL BLOCK RULE with special chars - - ```sql - CREATE SQL_BLOCK_RULE test_rule3 - PROPERTIES - ( - "sql" = "select count\\(1\\) from db1.tbl1" - ); - CREATE SQL_BLOCK_RULE test_rule4 - PROPERTIES - ( - "sql" = "select \\* from db1.tbl1" - ); - ``` -4. In SQL_BLOCK_RULE, SQL matching is based on regular expressions. If want to match more patterns of SQL, need to write the corresponding regex. For example, to ignore spaces in SQL and not query tables that start with 'order_', as shown below: - - ```sql - CREATE SQL_BLOCK_RULE test_rule4 - PROPERTIES( - "sql"="\\s*select\\s*\\*\\s*from order_\\w*\\s*", - "global"="false", - "enable"="true" - ); - ``` - -### APPENDIX -Here are some commonly used regular expressions: -> . :Matches any single character except for a newline character \n. -> -> * :Matches the preceding element zero or more times. For example, a matches zero or more 'a'. -> -> + :Matches the preceding element one or more times. For example, a+ matches one or more 'a'. -> -> ? :Matches the preceding element zero or one time. For example, a? matches zero or one 'a'. -> -> [] :Used to define a character set. For example, [aeiou] matches any one vowel letter. -> -> [^] :In a character set, use ^ to indicate negation, matching characters that are not in the set. For example, [^0-9] matches any non-digit character. -> -> () :Used for grouping expressions and applying quantifiers. For example, (ab)+ matches consecutive 'ab'. -> -> | :Represents logical OR. For example, a|b matches 'a' or 'b'. -> -> ^ :Matches the beginning of a string. For example, ^abc matches a string that starts with 'abc'. -> -> $ :Matches the end of a string. For example, xyz$ matches a string that ends with 'xyz'. -> -> \ :Used to escape special characters to treat them as ordinary characters. For example, \\. matches the period character '.'. -> -> \s :Matches any whitespace character, including spaces, tabs, newline characters, etc. -> -> \d :Matches any digit character, equivalent to [0-9]. -> -> \w :Matches any word character, including letters, digits, and underscores, equivalent to [a-zA-Z0-9_]. - -### Keywords - -```text -CREATE, SQL_BLCOK_RULE -``` - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-STORAGE-VAULT.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-STORAGE-VAULT.md deleted file mode 100644 index f1f5214c74bb8..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-STORAGE-VAULT.md +++ /dev/null @@ -1,177 +0,0 @@ ---- -{ - "title": "CREATE-STORAGE-VAULT", - "language": "en", - "toc_min_heading_level": 2, - "toc_max_heading_level": 4 -} ---- - - - -## CREATE-STORAGE-VAULT - -### Description - -This command is used to create a storage vault. The subject of this document describes the syntax for creating Doris self-maintained storage vault. - -```sql -CREATE STORAGE VAULT [IF NOT EXISTS] vault -[properties] -``` - - -#### properties - -| param | is required | desc | -|:-------|:------------|:-------------------------------------------------------| -| `type` | required | Only two types of vaults are allowed: `S3` and `HDFS`. | - -##### S3 Vault - -| param | is required | desc | -|:----------------|:------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `s3.endpoint` | required | The endpoint used for object storage.
**Notice**, please don't provide the endpoint with any `http://` or `https://`. And for Azure Blob Storage, the endpoint should be like `${ak}.blob.core.windows.net/`. | -| `s3.region` | required | The region of your bucket.(Not required when you'r using GCP or AZURE). | -| `s3.root.path` | required | The path where the data would be stored. | -| `s3.bucket` | required | The bucket of your object storage account. (StorageAccount if you're using Azure). | -| `s3.access_key` | required | The access key of your object storage account. (AccountName if you're using Azure). | -| `s3.secret_key` | required | The secret key of your object storage account. (AccountKey if you're using Azure). | -| `provider` | required | The cloud vendor which provides the object storage service. The supported values include `COS`, `OSS`, `S3`, `OBS`, `BOS`, `AZURE`, `GCP` | -| `use_path_style` | optional | Indicate using `path-style URL`(private environment recommended) or `virtual-hosted-style URL`(public cloud recommended), default `true` (`path-style`) | - -##### HDFS Vault - -| param | is required | desc | -|:---------------------------------|:------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `fs.defaultFS` | required | Hadoop configuration property that specifies the default file system to use. | -| `path_prefix` | optional | The path prefix to where the data would be stored. It would be the root_path of your Hadoop user if you don't provide any prefix. | -| `hadoop.username` | optional | Hadoop configuration property that specifies the user accessing the file system. It would be the user starting Hadoop process if you don't provide any user. | -| `hadoop.security.authentication` | optional | The authentication way used for hadoop. If you'd like to use kerberos you can provide with `kerboros`. | -| `hadoop.kerberos.principal` | optional | The path to your kerberos principal. | -| `hadoop.kerberos.keytab` | optional | The path to your kerberos keytab. | - -### Example - -1. create a HDFS storage vault. - ```sql - CREATE STORAGE VAULT IF NOT EXISTS hdfs_vault - PROPERTIES ( - "type"="hdfs", - "fs.defaultFS"="hdfs://127.0.0.1:8020" - ); - ``` - -2. create a S3 storage vault using azure. - ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="ak.blob.core.windows.net/", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "AZURE" - ); - ``` - -3. create a S3 storage vault using OSS. - ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="oss.aliyuncs.com", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.region" = "cn-hangzhou", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "OSS", - "use_path_style" = "false" - ); - ``` - -4. create a S3 storage vault using COS. - ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="cos.ap-guangzhou.myqcloud.com", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.region" = "ap-guangzhou", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "COS", - "use_path_style" = "false" - ); - ``` - -5. create a S3 storage vault using OBS. - ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="obs.cn-north-4.myhuaweicloud.com", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.region" = "cn-north-4", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "OBS", - "use_path_style" = "false" - ); - ``` - -6. create a S3 storage vault using AWS. - ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="s3.us-east-1.amazonaws.com", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.region" = "us-east-1", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "S3", - "use_path_style" = "false" - ); - ``` -7. create a S3 storage vault using MinIO. - ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="127.0.0.1:9000", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.region" = "us-east-1", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "S3", - "use_path_style" = "true" - ); - ``` - -### Keywords - - CREATE, STORAGE VAULT diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-AND-GENERATED-COLUMN.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-AND-GENERATED-COLUMN.md deleted file mode 100644 index 5c9c758122ca5..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-AND-GENERATED-COLUMN.md +++ /dev/null @@ -1,254 +0,0 @@ ---- -{ - "title": "CREATE-TABLE-AND-GENERATED-COLUMN", - "language": "en" -} ---- - - -A generated column is a special database table column whose value is calculated from the values of other columns rather than directly inserted or updated by the user. This feature supports pre-computing the results of expressions and storing them in the database, which is suitable for scenarios that require frequent queries or complex calculations. - -Generated columns can automatically calculate results based on predefined expressions when data is imported or updated, and store these results persistently. In this way, during subsequent queries, you can directly access these calculated results without performing complex calculations during queries, thereby significantly reducing the computational burden during queries and improving query performance. - -Here is an example using a generated column: - -```sql -CREATE TABLE products ( -product_id INT, -price DECIMAL(10,2), -quantity INT, -total_value DECIMAL(10,2) GENERATED ALWAYS AS (price * quantity) -) UNIQUE KEY(product_id) -DISTRIBUTED BY HASH(product_id) PROPERTIES ("replication_num" = "1"); - -INSERT INTO products VALUES(1, 10.00, 10, default); -INSERT INTO products(product_id, price, quantity) VALUES(1, 20.00, 10); -``` - -Query data from the table: - -```sql -mysql> SELECT * FROM products; -+------------+-------+----------+-------------+ -| product_id | price | quantity | total_value | -+------------+-------+----------+-------------+ -| 1 | 10.00 | 10 | 100.00 | -| 1 | 20.00 | 10 | 200.00 | -+------------+-------+----------+-------------+ -``` - -In this example, the total_value column is a generated column whose value is calculated by multiplying the values ​​of the price and quantity columns. -The values of generated columns are calculated and stored in the table when importing or updating. -## Grammar - -```sql -col_name data_type [GENERATED ALWAYS] AS (expr) -[NOT NULL | NULL] [COMMENT 'string'] -``` - -## Restrictions on generated columns -1. The functions used can only be built-in scalar functions and operators. UDF, aggregate functions, etc. are not allowed. -2. Variables, subqueries, and Lambda expressions are not allowed. -3. AUTO_INCREMENT columns cannot be used as base columns in generated column definitions. -4. Generated column definitions can reference other generated columns, but only columns that appear earlier in the table definition. Generated column definitions can reference any base (non-generated) column in the table, regardless of whether its definition occurs earlier or later. -5. In the aggregate model, when the generated column is a VALUE column, only REPLACE and REPLACE_IF_NOT_NULL aggregate types are allowed. -## Import data -When importing data, if the NOT NULL restriction of the generated column is violated, for example, when importing data, the column referenced by the generated column is not specified, and this column has no default value, the import will fail. -### INSERT -When specifying columns, the specified columns cannot contain generated columns, otherwise an error will be reported. - -```sql -INSERT INTO products(product_id, price, quantity) VALUES(1, 20.00, 10); -``` - -When no columns are specified, the DEFAULT keyword must be used as a placeholder for the generated columns.。 - -```sql -INSERT INTO products VALUES(1, 10.00, 10, default); -``` - -### Load -When using the load method to import data, you need to explicitly specify the import column. You should not specify a generated column as an import column. When you specify an import generated column and there is corresponding data in the data file, the generated column will not use the value in the data file, and the value of the generated column is still the result of the expression calculation. -#### Stream Load -Create table: - -```sql -mysql> CREATE TABLE gen_col_stream_load(a INT,b INT,c DOUBLE GENERATED ALWAYS AS (abs(a+b)) not null) -DISTRIBUTED BY HASH(a) -PROPERTIES("replication_num" = "1"); -``` - -Prepare data and perform stream loading: - -```shell -cat gen_col_data.csv -1,2 -3,5 -2,9 - -curl --location-trusted -u root: \ --H "Expect:100-continue" \ --H "column_separator:," \ --H "columns:a,b" \ --T gen_col_data.csv \ --XPUT http://127.0.0.1:8030/api/testdb/gen_col_stream_load/_stream_load -{ - "TxnId": 223227, - "Label": "d4a615c9-6e73-4d95-a8a4-e4c30d3b2262", - "Comment": "", - "TwoPhaseCommit": "false", - "Status": "Success", - "Message": "OK", - "NumberTotalRows": 3, - "NumberLoadedRows": 3, - "NumberFilteredRows": 0, - "NumberUnselectedRows": 0, - "LoadBytes": 12, - "LoadTimeMs": 152, - "BeginTxnTimeMs": 5, - "StreamLoadPutTimeMs": 39, - "ReadDataTimeMs": 0, - "WriteDataTimeMs": 66, - "CommitAndPublishTimeMs": 37 -} -``` - -View the data import results: - -```sql -mysql> SELECT * FROM gen_col_stream_load; -+------+------+------+ -| a | b | c | -+------+------+------+ -| 1 | 2 | 3 | -| 2 | 9 | 11 | -| 3 | 5 | 8 | -+------+------+------+ -3 rows in set (0.07 sec) -``` - -#### HTTP Stream Load -Create table: - -```sql -mysql> CREATE TABLE gencol_refer_gencol_http_load(a INT,c DOUBLE GENERATED ALWAYS AS (abs(a+b)) NOT NULL,b INT, d INT GENERATED ALWAYS AS(c+1)) -DISTRIBUTED BY HASH(a) -PROPERTIES("replication_num" = "1"); -``` - -Prepare data and perform HTTP stream loading: - -```shell -curl --location-trusted -u root: -T gen_col_data.csv -H "Expect: 100-Continue" \ --H "sql:insert into testdb.gencol_refer_gencol_http_load(a, b) select * from http_stream(\"format\" = \"CSV\", \"column_separator\" = \",\" )" \ -http://127.0.0.1:8030/api/_http_stream -{ - "TxnId": 223244, - "Label": "label_824464cba2a1eabc_bee78e427ea55e81", - "Comment": "", - "TwoPhaseCommit": "false", - "Status": "Success", - "Message": "OK", - "NumberTotalRows": 3, - "NumberLoadedRows": 3, - "NumberFilteredRows": 0, - "NumberUnselectedRows": 0, - "LoadBytes": 12, - "LoadTimeMs": 142, - "BeginTxnTimeMs": 0, - "StreamLoadPutTimeMs": 45, - "ReadDataTimeMs": 46, - "WriteDataTimeMs": 59, - "CommitAndPublishTimeMs": 36 -} -``` - -View the data import results: - -```sql -mysql> SELECT * FROM gencol_refer_gencol_http_load; +------+------+------+------+ -| a | c | b | d | -+------+------+------+------+ -| 2 | 11 | 9 | 12 | -| 1 | 3 | 2 | 4 | -| 3 | 8 | 5 | 9 | -+------+------+------+------+ -3 rows in set (0.04 sec) -``` - -#### MySQL Load -The process of creating a table, loading data and querying is as follows: - -```sql -mysql> CREATE TABLE gen_col_mysql_load(a INT,b INT,c DOUBLE GENERATED ALWAYS AS (abs(a+b)) NOT NULL) -DISTRIBUTED BY HASH(a) -PROPERTIES("replication_num" = "1"); - -mysql> LOAD DATA LOCAL -INFILE '/path_to_data/gen_col_data.csv' -INTO TABLE gen_col_mysql_load -COLUMNS TERMINATED BY ',' -(a,b); -Query OK, 3 rows affected (0.14 sec) -Records: 3 Deleted: 0 Skipped: 0 Warnings: 0 - -mysql> SELECT * FROM gen_col_mysql_load; -+------+------+------+ -| a | b | c | -+------+------+------+ -| 2 | 9 | 11 | -| 3 | 5 | 8 | -| 1 | 2 | 3 | -+------+------+------+ -3 rows in set (0.06 sec) -``` - -#### Other Load -BROKER LOAD, ROUTINE LOAD and other methods can import data into a table with generated columns, which will not be listed here. -## Generated columns and partial update -When updating some columns, you must specify all the common columns referenced by the generated columns in columns, otherwise an error will be reported. - -The following is an example to create a table, insert a row of data, and set the session variable: - -```sql -CREATE TABLE test_partial_column_unique_gen_col (a INT, b INT, c INT AS (a+b), d INT AS (c+1), e INT) -UNIQUE KEY(a) DISTRIBUTED BY HASH(a) PROPERTIES( - "enable_unique_key_merge_on_write" = "true", - "replication_num"="1" -); -SET enable_unique_key_partial_update=true; -SET enable_insert_strict=false; -SET enable_fallback_to_original_planner=false; -INSERT INTO test_partial_column_unique_gen_col(a,b,e) VALUES(1,2,7); -``` - -If all referenced normal columns are not specified, an error will be reported: - -```sql -mysql> INSERT INTO test_partial_column_unique_gen_col(a) VALUES(3); -ERROR 1105 (HY000): errCode = 2, detailMessage = Partial update should include all ordinary columns referenced by generated columns, missing: b -``` - -The same is true for LOAD. All referenced normal columns need to be specified in -H "columns: a, b". The following is an example of using stream load: - -```shell -curl --location-trusted -u root: -H "Expect:100-continue" -H "column_separator:," \ --H "columns: a, b" -H "partial_columns:true" \ --T /Users/moailing/Documents/tmp/gen_col_data.csv \ -http://127.0.0.1:8030/api/testdb/partial_column_unique_gen_col/_stream_load -``` diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT.md deleted file mode 100644 index 3cc87b52e7f88..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT.md +++ /dev/null @@ -1,100 +0,0 @@ ---- -{ - "title": "CREATE-TABLE-AS-SELECT", - "language": "en" -} ---- - - - -## CREATE-TABLE-AS-SELECT - -### Name - -CREATE TABLE AS SELECT - -### Description - -This statement creates the table structure by returning the results from the Select statement and imports the data at the same time - -grammar: - -```sql -CREATE TABLE table_name [( column_name_list )] - opt_engine:engineName - opt_keys:keys - opt_comment:tableComment - opt_partition:partition - opt_distribution:distribution - opt_rollup:index - opt_properties:tblProperties - opt_ext_properties:extProperties - KW_AS query_stmt:query_def - ``` - -illustrate: - -- The user needs to have`SELECT`permission for the source table and`CREATE`permission for the target database -- After a table is created, data is imported. If the import fails, the table is deleted -- You can specify the key type. The default key type is `Duplicate Key` - -- All columns of type string (varchar/var/string) are created as type "string". -- If the created source is an external table and the first column is of type String, the first column is automatically set to VARCHAR(65533). Because of Doris internal table, String column is not allowed as first column. - -### Example - -1. Using the field names in the SELECT statement - - ```sql - create table `test`.`select_varchar` - PROPERTIES("replication_num" = "1") - as select * from `test`.`varchar_table` - ``` - -2. Custom field names (need to match the number of fields returned) - ```sql - create table `test`.`select_name`(user, testname, userstatus) - PROPERTIES("replication_num" = "1") - as select vt.userId, vt.username, jt.status - from `test`.`varchar_table` vt join - `test`.`join_table` jt on vt.userId=jt.userId - ``` - -3. Specify table model, partitions, and buckets - ```sql - CREATE TABLE t_user(dt, id, name) - ENGINE=OLAP - UNIQUE KEY(dt, id) - COMMENT "OLAP" - PARTITION BY RANGE(dt) - ( - FROM ("2020-01-01") TO ("2021-12-31") INTERVAL 1 YEAR - ) - DISTRIBUTED BY HASH(id) BUCKETS 1 - PROPERTIES("replication_num"="1") - AS SELECT cast('2020-05-20' as date) as dt, 1 as id, 'Tom' as name; - ``` - -### Keywords - - CREATE, TABLE, AS, SELECT - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-LIKE.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-LIKE.md deleted file mode 100644 index 159945a66e82e..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-LIKE.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -{ - "title": "CREATE-TABLE-LIKE", - "language": "en" -} ---- - - - -## CREATE-TABLE-LIKE - -### Name - -CREATE TABLE LIKE - -### Description - -This statement is used to create an empty table with the exact same table structure as another table, and can optionally replicate some rollups. - -grammar: - -```sql -CREATE [EXTERNAL] TABLE [IF NOT EXISTS] [database.]table_name LIKE [database.]table_name [WITH ROLLUP (r1,r2,r3,...)] -``` - -illustrate: - -- The copied table structure includes Column Definition, Partitions, Table Properties, etc. -- The user needs to have `SELECT` permission on the copied original table -- Support for copying external tables such as MySQL -- Support the rollup of copying OLAP Table - -### Example - -1. Create an empty table with the same table structure as table1 under the test1 library, the table name is table2 - - ```sql - CREATE TABLE test1.table2 LIKE test1.table1 - ``` - -2. Create an empty table with the same table structure as test1.table1 under the test2 library, the table name is table2 - - ```sql - CREATE TABLE test2.table2 LIKE test1.table1 - ``` - -3. Create an empty table with the same table structure as table1 under the test1 library, the table name is table2, and copy the two rollups of r1 and r2 of table1 at the same time - - ```sql - CREATE TABLE test1.table2 LIKE test1.table1 WITH ROLLUP (r1,r2) - ``` - -4. Create an empty table with the same table structure as table1 under the test1 library, the table name is table2, and copy all the rollups of table1 at the same time - - ```sql - CREATE TABLE test1.table2 LIKE test1.table1 WITH ROLLUP - ``` - -5. Create an empty table with the same table structure as test1.table1 under the test2 library, the table name is table2, and copy the two rollups of r1 and r2 of table1 at the same time - - ```sql - CREATE TABLE test2.table2 LIKE test1.table1 WITH ROLLUP (r1,r2) - ``` - -6. Create an empty table with the same table structure as test1.table1 under the test2 library, the table name is table2, and copy all the rollups of table1 at the same time - - ```sql - CREATE TABLE test2.table2 LIKE test1.table1 WITH ROLLUP - ``` - -7. Create an empty table under the test1 library with the same table structure as the MySQL outer table1, the table name is table2 - - ```sql - CREATE TABLE test1.table2 LIKE test1.table1 - ``` - -### Keywords - - CREATE, TABLE, LIKE - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE.md deleted file mode 100644 index 96e574c7d7713..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE.md +++ /dev/null @@ -1,857 +0,0 @@ ---- -{ - "title": "CREATE-TABLE", - "language": "en", - "toc_min_heading_level": 2, - "toc_max_heading_level": 4 -} ---- - - - -## CREATE-TABLE - -### Description - -This command is used to create a table. The subject of this document describes the syntax for creating Doris self-maintained tables. - -```sql -CREATE TABLE [IF NOT EXISTS] [database.]table -( - column_definition_list - [, index_definition_list] -) -[engine_type] -[keys_type] -[table_comment] -[partition_info] -distribution_desc -[rollup_list] -[properties] -[extra_properties] -``` - -#### column_definition_list - -Column definition list: - -`column_definition[, column_definition]` - -* `column_definition` - - Column definition: - - `column_name column_type [KEY] [aggr_type] [NULL] [AUTO_INCREMENT(auto_inc_start_value)] [default_value] [on update current_timestamp] [column_comment]` - - * `column_type` - - Column type, the following types are supported: - - ``` - TINYINT (1 byte) - Range: -2^7 + 1 ~ 2^7-1 - SMALLINT (2 bytes) - Range: -2^15 + 1 ~ 2^15-1 - INT (4 bytes) - Range: -2^31 + 1 ~ 2^31-1 - BIGINT (8 bytes) - Range: -2^63 + 1 ~ 2^63-1 - LARGEINT (16 bytes) - Range: -2^127 + 1 ~ 2^127-1 - FLOAT (4 bytes) - Support scientific notation - DOUBLE (12 bytes) - Support scientific notation - DECIMAL[(precision, scale)] (16 bytes) - The decimal type with guaranteed precision. The default is DECIMAL(10, 0) - precision: 1 ~ 27 - scale: 0 ~ 9 - Where the integer part is 1 ~ 18 - Does not support scientific notation - DATE (3 bytes) - Range: 0000-01-01 ~ 9999-12-31 - DATETIME (8 bytes) - Range: 0000-01-01 00:00:00 ~ 9999-12-31 23:59:59 - CHAR[(length)] - Fixed-length character string. Length range: 1 ~ 255. Default is 1 - VARCHAR[(length)] - Variable length character string. Length range: 1 ~ 65533. Default is 65533 - HLL (1~16385 bytes) - HyperLogLog column type, do not need to specify the length and default value. The length is controlled within the system according to the degree of data aggregation. - Must be used with HLL_UNION aggregation type. - BITMAP - The bitmap column type does not need to specify the length and default value. Represents a collection of integers, and the maximum number of elements supported is 2^64-1. - Must be used with BITMAP_UNION aggregation type. - ``` - - * `aggr_type` - - Aggregation type, the following aggregation types are supported: - - ``` - SUM: Sum. Applicable numeric types. - MIN: Find the minimum value. Suitable for numeric types. - MAX: Find the maximum value. Suitable for numeric types. - REPLACE: Replace. For rows with the same dimension column, the index column will be imported in the order of import, and the last imported will replace the first imported. - REPLACE_IF_NOT_NULL: non-null value replacement. The difference with REPLACE is that there is no replacement for null values. It should be noted here that the default value should be NULL, not an empty string. If it is an empty string, you should replace it with an empty string. - HLL_UNION: The aggregation method of HLL type columns, aggregated by HyperLogLog algorithm. - BITMAP_UNION: The aggregation mode of BIMTAP type columns, which performs the union aggregation of bitmaps. - ``` - - * `AUTO_INCREMENT(auto_inc_start_value)` - - To indicate if the column is a auto-increment column. Auto-increment column can be used to generate a unique identity for new row. If no values are assgined for auto-increment column when inserting, Doris will generate sequence numbers automatically. You can also assign the auto-increment column with NULL literal to indicate Doris to generate sequence numbers. It should be noted that, for performance reasons, BE will cache some values of auto-increment column in memory. Therefore, the values generated by auto-increment column can only guarantee monotonicity and uniqueness, but not strict continuity. - A table can have at most one auto-incremnt column. The auto-increment column should be BIGINT type and be NOT NULL. - Both Duplicate model table and Unique model table support auto-increment column. - You can specify the starting value for an auto-increment column by providing `auto_inc_start_value. If not specified, the default starting value is 1. - - * `default_value` - - Default value of the column. If the load data does not specify a value for this column, the system will assign a default value to this column. - - The syntax is: `default default_value`. - - Currently, the default value supports two forms: - - 1. The user specifies a fixed value, such as: - - ```SQL - k1 INT DEFAULT '1', - k2 CHAR(10) DEFAULT 'aaaa' - ``` - 2. Keywords are provided by the system. Currently, the following keywords are supported: - - ```SQL - // This keyword is used only for DATETIME type. If the value is missing, the system assigns the current timestamp. - dt DATETIME DEFAULT CURRENT_TIMESTAMP - ``` - - * `on update current_timestamp` - - To indicate that whether the value of this column should be updated to the current timestamp (`current_timestamp`) when there is an update on the row. The feature is only available on unique table with merge-on-write enabled. Columns with this feature enabled must declare a default value, and the default value must be `current_timestamp`. If the precision of the timestamp is declared here, the timestamp precision in the default value of the column must be the same as the precision declared here." - - Example: - - ``` - k1 TINYINT, - k2 DECIMAL(10,2) DEFAULT "10.5", - k4 BIGINT NULL DEFAULT "1000" COMMENT "This is column k4", - v1 VARCHAR(10) REPLACE NOT NULL, - v2 BITMAP BITMAP_UNION, - v3 HLL HLL_UNION, - v4 INT SUM NOT NULL DEFAULT "1" COMMENT "This is column v4" - dt datetime(6) default current_timestamp(6) on update current_timestamp(6) - ``` - -#### index_definition_list - -Index list definition: - -`index_definition[, index_definition]` - -* `index_definition` - - Index definition: - - ```sql - INDEX index_name (col_name) [USING INVERTED] COMMENT'xxxxxx' - ``` - - Example: - - ```sql - INDEX idx1 (k1) USING INVERTED COMMENT "This is a inverted index1", - INDEX idx2 (k2) USING INVERTED COMMENT "This is a inverted index2", - ... - ``` - -#### engine_type - -Table engine type. Example: - - `ENGINE=olap` - -#### keys_type - -Data model. - -`key_type(col1, col2, ...)` - -`key_type` supports the following models: - -* DUPLICATE KEY (default): The subsequent specified column is the sorting column. -* AGGREGATE KEY: The specified column is the dimension column. -* UNIQUE KEY: The subsequent specified column is the primary key column. - -NOTE: when set table property `"enable_duplicate_without_keys_by_default" = "true"`, will create a duplicate model without sorting columns and prefix indexes by default. - -Example: - -``` -DUPLICATE KEY(col1, col2), -AGGREGATE KEY(k1, k2, k3), -UNIQUE KEY(k1, k2) -``` - -#### table_comment - -Table notes. Example: - - ``` - COMMENT "This is my first DORIS table" - ``` - -#### partition_info - -Partition information supports three writing methods: - -1. LESS THAN: Only define the upper boundary of the partition. The lower bound is determined by the upper bound of the previous partition. - - ``` - PARTITION BY RANGE(col1[, col2, ...]) - ( - PARTITION partition_name1 VALUES LESS THAN MAXVALUE|("value1", "value2", ...), - PARTITION partition_name2 VALUES LESS THAN MAXVALUE|("value1", "value2", ...) - ) - ``` - -2. FIXED RANGE: Define the left closed and right open interval of the zone. - - ``` - PARTITION BY RANGE(col1[, col2, ...]) - ( - PARTITION partition_name1 VALUES [("k1-lower1", "k2-lower1", "k3-lower1",...), ("k1-upper1", "k2-upper1", "k3-upper1", ... )), - PARTITION partition_name2 VALUES [("k1-lower1-2", "k2-lower1-2", ...), ("k1-upper1-2", MAXVALUE, )) - ) - ``` - -3. MULTI RANGE: Multi build RANGE partitions,Define the left closed and right open interval of the zone, Set the time unit and step size, the time unit supports year, month, day, week and hour. - - ``` - PARTITION BY RANGE(col) - ( - FROM ("2000-11-14") TO ("2021-11-14") INTERVAL 1 YEAR, - FROM ("2021-11-14") TO ("2022-11-14") INTERVAL 1 MONTH, - FROM ("2022-11-14") TO ("2023-01-03") INTERVAL 1 WEEK, - FROM ("2023-01-03") TO ("2023-01-14") INTERVAL 1 DAY - ) - ``` - - -4. MULTI RANGE: Multi build integer RANGE partitions,Define the left closed and right open interval of the zone, and step size. - - ``` - PARTITION BY RANGE(int_col) - ( - FROM (1) TO (100) INTERVAL 10 - ) - ``` - -#### distribution_desc - -Define the data bucketing method. - -1. Hash - Syntax: - `DISTRIBUTED BY HASH (k1[,k2 ...]) [BUCKETS num|auto]` - Explain: - Hash bucketing using the specified key column. - -2. Random - Syntax: - `DISTRIBUTED BY RANDOM [BUCKETS num|auto]` - Explain: - Use random numbers for bucketing. - -#### rollup_list - -Multiple materialized views (ROLLUP) can be created at the same time as the table is built. - -`ROLLUP (rollup_definition[, rollup_definition, ...])` - -* `rollup_definition` - - `rollup_name (col1[, col2, ...]) [DUPLICATE KEY(col1[, col2, ...])] [PROPERTIES("key" = "value")]` - - Example: - - ``` - ROLLUP ( - r1 (k1, k3, v1, v2), - r2 (k1, v1) - ) - ``` - -#### properties - -Set table properties. The following attributes are currently supported: - -* `replication_num` - - Number of copies. The default number of copies is 3. If the number of BE nodes is less than 3, you need to specify that the number of copies is less than or equal to the number of BE nodes. - - After version 0.15, this attribute will be automatically converted to the `replication_allocation` attribute, such as: - - `"replication_num" = "3"` will be automatically converted to `"replication_allocation" = "tag.location.default:3"` - -* `replication_allocation` - - Set the copy distribution according to Tag. This attribute can completely cover the function of the `replication_num` attribute. - -* `min_load_replica_num` - - The minimum required successful replica num for loading data. The default value is `-1`. If set less than or equal to 0, loading data requires a majority replicas to succeed. - -* `is_being_synced` - - Used to identify whether this table is copied by CCR and is being synchronized by syncer. The default is `false`. - - If set to `true`: - `colocate_with`, `storage_policy` properties will be erased - `dynamic partition`, `auto bucket` features will be disabled, that is, they will be displayed as enabled in `show create table`, but will not actually take effect. When `is_being_synced` is set to `false`, these features will resume working. - - This property is for CCR peripheral modules only and should not be manually set during CCR synchronization. - -* `storage_medium/storage_cooldown_time` - - Data storage medium. `storage_medium` is used to declare the initial storage medium of the table data, and `storage_cooldown_time` is used to set the expiration time. Example: - - ``` - "storage_medium" = "SSD", - "storage_cooldown_time" = "2020-11-20 00:00:00" - ``` - - This example indicates that the data is stored in the SSD and will be automatically migrated to the HDD storage after the expiration of 2020-11-20 00:00:00. - -* `colocate_with` - - When you need to use the Colocation Join function, use this parameter to set the Colocation Group. - - `"colocate_with" = "group1"` - -* `bloom_filter_columns` - - The user specifies the list of column names that need to be added to the Bloom Filter index. The Bloom Filter index of each column is independent, not a composite index. - - `"bloom_filter_columns" = "k1, k2, k3"` - -* `in_memory` - - Deprecated. - -* `function_column.sequence_col` - - When using the UNIQUE KEY model, you can specify a sequence column. When the KEY columns are the same, REPLACE will be performed according to the sequence column (the larger value replaces the smaller value, otherwise it cannot be replaced) - - The `function_column.sequence_col` is used to specify the mapping of the sequence column to a column in the table, which can be integral and time (DATE, DATETIME). The type of this column cannot be changed after creation. If `function_column.sequence_col` is set, `function_column.sequence_type` is ignored. - - `"function_column.sequence_col" ='column_name'` - -* `function_column.sequence_type` - - When using the UNIQUE KEY model, you can specify a sequence column. When the KEY columns are the same, REPLACE will be performed according to the sequence column (the larger value replaces the smaller value, otherwise it cannot be replaced) - - Here we only need to specify the type of sequence column, support time type or integer type. Doris will create a hidden sequence column. - - `"function_column.sequence_type" ='Date'` - -* `compression` - - The default compression method for Doris tables is LZ4. After version 1.1, it is supported to specify the compression method as ZSTD to obtain a higher compression ratio. - - `"compression"="zstd"` - -* `enable_unique_key_merge_on_write` - - Wheather the unique table use merge-on-write implementation. - - The property is disabled by default before version 2.1 and is enabled by default since version 2.1. - -* `light_schema_change` - - Whether to use the Light Schema Change optimization. - - If set to true, the addition and deletion of value columns can be done more quickly and synchronously. - - `"light_schema_change"="true"` - - This feature is enabled by default after v2.0.0. - -* `disable_auto_compaction` - - Whether to disable automatic compaction for this table. - - If this property is set to 'true', the background automatic compaction process will skip all the tables of this table. - - `"disable_auto_compaction" = "false"` - -* `enable_single_replica_compaction` - - Whether to enable single replica compaction for this table. - - If this property is set to 'true', all replicas of the tablet will only have one replica performing compaction, while the others fetch rowsets from that replica. - - `"enable_single_replica_compaction" = "false"` - -* `enable_duplicate_without_keys_by_default` - - When `true`, if Unique, Aggregate, or Duplicate is not specified when creating a table, a Duplicate model table without sorting columns and prefix indexes will be created by default. - - `"enable_duplicate_without_keys_by_default" = "false"` - -* `skip_write_index_on_load` - - Whether to enable skip inverted index on load for this table. - - If this property is set to 'true', skip writting index (only inverted index now) on first time load and delay writting - index to compaction. It can reduce CPU and IO resource usage for high throughput load. - - `"skip_write_index_on_load" = "false"` - -* `compaction_policy` - - Configure the compaction strategy in the compression phase. Only support configuring the compaction policy as "time_series" or "size_based". - - time_series: When the disk size of a rowset accumulates to a certain threshold, version merging takes place. The merged rowset is directly promoted to the base compaction stage. This approach effectively reduces the write amplification rate of compaction, especially in scenarios with continuous imports in a time series context. - - In the case of time series compaction, the execution of compaction is adjusted using parameters that have the prefix time_series_compaction. - - `"compaction_policy" = ""` - -* `group_commit_interval_ms` - - Configures the group commit batch interval for this table. The unit is milliseconds, with a default value of 10000ms (10 seconds). - - The flushing timing of group commit depends on which value is reached first: `group_commit_interval_ms` or `group_commit_data_bytes`. - - `"group_commit_interval_ms" = "10000"` - -* `group_commit_data_bytes` - - Configures the group commit batch data size for this table. The unit is bytes, with a default value of 134217728 bytes (128MB). - - The flushing timing of group commit depends on which value is reached first: `group_commit_interval_ms` or `group_commit_data_bytes`. - - `"group_commit_data_bytes" = "134217728"` - -* `time_series_compaction_goal_size_mbytes` - - Time series compaction policy will utilize this parameter to adjust the size of input files for each compaction. The output file size will be approximately equal to the input file size. - - `"time_series_compaction_goal_size_mbytes" = "1024"` - -* `time_series_compaction_file_count_threshold` - - Time series compaction policy will utilize this parameter to adjust the minimum number of input files for each compaction. - - If the number of files in a tablet exceeds the configured threshold, it will trigger a compaction process. - - `"time_series_compaction_file_count_threshold" = "2000"` - -* `time_series_compaction_time_threshold_seconds` - - When time series compaction policy is applied, a significant duration passes without a compaction being executed, a compaction will be triggered. - - `"time_series_compaction_time_threshold_seconds" = "3600"` - -* `enable_mow_light_delete` - - If modify delete predicate for the DELETE statement on the unique merge-on-write table. If enabled, it will improve the performance of the DELETE statement, but errors may occur in partial column updates after deletion. If disabled, it will reduce the performance of the DELETE statement to ensure correctness. - - The default value for this property is false. - - This propertiy can only be enabled on unique merge-on-write tables. - - `"enable_mow_light_delete" = "true"` - -* Dynamic partition related - - References related to dynamic partitioning[Data Partitioning-Dynamic partitioning](../../../../table-design/data-partitioning/dynamic-partitioning) - -* `file_cache_ttl_seconds`: - - Expiration time of TTL Cache in compute-storage decoupled mode. - -### Example - -1. Create a detailed model table - - ```sql - CREATE TABLE example_db.table_hash - ( - k1 TINYINT, - k2 DECIMAL(10, 2) DEFAULT "10.5", - k3 CHAR(10) COMMENT "string column", - k4 INT NOT NULL DEFAULT "1" COMMENT "int column" - ) - COMMENT "my first table" - DISTRIBUTED BY HASH(k1) BUCKETS 32 - ``` - -2. Create a detailed model table, partition, specify the sorting column, and set the number of copies to 1 - - ```sql - CREATE TABLE example_db.table_hash - ( - k1 DATE, - k2 DECIMAL(10, 2) DEFAULT "10.5", - k3 CHAR(10) COMMENT "string column", - k4 INT NOT NULL DEFAULT "1" COMMENT "int column" - ) - DUPLICATE KEY(k1, k2) - COMMENT "my first table" - PARTITION BY RANGE(k1) - ( - PARTITION p1 VALUES LESS THAN ("2020-02-01"), - PARTITION p2 VALUES LESS THAN ("2020-03-01"), - PARTITION p3 VALUES LESS THAN ("2020-04-01") - ) - DISTRIBUTED BY HASH(k1) BUCKETS 32 - PROPERTIES ( - "replication_num" = "1" - ); - ``` - -3. Create a table with a unique model of the primary key, set the initial storage medium and cooling time - - ```sql - CREATE TABLE example_db.table_hash - ( - k1 BIGINT, - k2 LARGEINT, - v1 VARCHAR(2048), - v2 SMALLINT DEFAULT "10" - ) - UNIQUE KEY(k1, k2) - DISTRIBUTED BY HASH (k1, k2) BUCKETS 32 - PROPERTIES( - "storage_medium" = "SSD", - "storage_cooldown_time" = "2015-06-04 00:00:00" - ); - ``` - -4. Create an aggregate model table, using a fixed range partition description - - ```sql - CREATE TABLE table_range - ( - k1 DATE, - k2 INT, - k3 SMALLINT, - v1 VARCHAR(2048) REPLACE, - v2 INT SUM DEFAULT "1" - ) - AGGREGATE KEY(k1, k2, k3) - PARTITION BY RANGE (k1, k2, k3) - ( - PARTITION p1 VALUES [("2014-01-01", "10", "200"), ("2014-01-01", "20", "300")), - PARTITION p2 VALUES [("2014-06-01", "100", "200"), ("2014-07-01", "100", "300")) - ) - DISTRIBUTED BY HASH(k2) BUCKETS 32 - ``` - -5. Create an aggregate model table with HLL and BITMAP column types - - ```sql - CREATE TABLE example_db.example_table - ( - k1 TINYINT, - k2 DECIMAL(10, 2) DEFAULT "10.5", - v1 HLL HLL_UNION, - v2 BITMAP BITMAP_UNION - ) - ENGINE=olap - AGGREGATE KEY(k1, k2) - DISTRIBUTED BY HASH(k1) BUCKETS 32 - ``` - -6. Create two self-maintained tables of the same Colocation Group. - - ```sql - CREATE TABLE t1 ( - id int(11) COMMENT "", - value varchar(8) COMMENT "" - ) - DUPLICATE KEY(id) - DISTRIBUTED BY HASH(id) BUCKETS 10 - PROPERTIES ( - "colocate_with" = "group1" - ); - - CREATE TABLE t2 ( - id int(11) COMMENT "", - value1 varchar(8) COMMENT "", - value2 varchar(8) COMMENT "" - ) - DUPLICATE KEY(`id`) - DISTRIBUTED BY HASH(`id`) BUCKETS 10 - PROPERTIES ( - "colocate_with" = "group1" - ); - ``` - -7. Create a table with inverted index and bloom filter index - - ```sql - CREATE TABLE example_db.table_hash - ( - k1 TINYINT, - k2 DECIMAL(10, 2) DEFAULT "10.5", - v1 CHAR(10) REPLACE, - v2 INT SUM, - INDEX k1_idx (k1) USING INVERTED COMMENT'my first index' - ) - AGGREGATE KEY(k1, k2) - DISTRIBUTED BY HASH(k1) BUCKETS 32 - PROPERTIES ( - "bloom_filter_columns" = "k2" - ); - ``` - -8. Create a dynamic partition table. - - The table creates partitions 3 days in advance every day, and deletes the partitions 3 days ago. For example, if today is `2020-01-08`, partitions named `p20200108`, `p20200109`, `p20200110`, `p20200111` will be created. The partition ranges are: - - ``` - [types: [DATE]; keys: [2020-01-08]; ‥types: [DATE]; keys: [2020-01-09];) - [types: [DATE]; keys: [2020-01-09]; ‥types: [DATE]; keys: [2020-01-10];) - [types: [DATE]; keys: [2020-01-10]; ‥types: [DATE]; keys: [2020-01-11];) - [types: [DATE]; keys: [2020-01-11]; ‥types: [DATE]; keys: [2020-01-12];) - ``` - - ```sql - CREATE TABLE example_db.dynamic_partition - ( - k1 DATE, - k2 INT, - k3 SMALLINT, - v1 VARCHAR(2048), - v2 DATETIME DEFAULT "2014-02-04 15:36:00" - ) - DUPLICATE KEY(k1, k2, k3) - PARTITION BY RANGE (k1) () - DISTRIBUTED BY HASH(k2) BUCKETS 32 - PROPERTIES( - "dynamic_partition.time_unit" = "DAY", - "dynamic_partition.start" = "-3", - "dynamic_partition.end" = "3", - "dynamic_partition.prefix" = "p", - "dynamic_partition.buckets" = "32" - ); - ``` - -9. Create a table with a materialized view (ROLLUP). - - ```sql - CREATE TABLE example_db.rolup_index_table - ( - event_day DATE, - siteid INT DEFAULT '10', - citycode SMALLINT, - username VARCHAR(32) DEFAULT'', - pv BIGINT SUM DEFAULT '0' - ) - AGGREGATE KEY(event_day, siteid, citycode, username) - DISTRIBUTED BY HASH(siteid) BUCKETS 10 - ROLLUP ( - r1(event_day,siteid), - r2(event_day,citycode), - r3(event_day) - ) - PROPERTIES("replication_num" = "3"); - ``` - -10. Set the replica of the table through the `replication_allocation` property. - - ```sql - CREATE TABLE example_db.table_hash - ( - k1 TINYINT, - k2 DECIMAL(10, 2) DEFAULT "10.5" - ) - DISTRIBUTED BY HASH(k1) BUCKETS 32 - PROPERTIES ( - "replication_allocation"="tag.location.group_a:1, tag.location.group_b:2" - ); - ``` - ```sql - CREATE TABLE example_db.dynamic_partition - ( - k1 DATE, - k2 INT, - k3 SMALLINT, - v1 VARCHAR(2048), - v2 DATETIME DEFAULT "2014-02-04 15:36:00" - ) - PARTITION BY RANGE (k1) () - DISTRIBUTED BY HASH(k2) BUCKETS 32 - PROPERTIES( - "dynamic_partition.time_unit" = "DAY", - "dynamic_partition.start" = "-3", - "dynamic_partition.end" = "3", - "dynamic_partition.prefix" = "p", - "dynamic_partition.buckets" = "32", - "dynamic_partition.replication_allocation" = "tag.location.group_a:3" - ); - ``` - -11. Set the table hot and cold separation policy through the `storage_policy` property. - ```sql - CREATE TABLE IF NOT EXISTS create_table_use_created_policy - ( - k1 BIGINT, - k2 LARGEINT, - v1 VARCHAR(2048) - ) - UNIQUE KEY(k1) - DISTRIBUTED BY HASH (k1) BUCKETS 3 - PROPERTIES( - "storage_policy" = "test_create_table_use_policy", - "replication_num" = "1" - ); - ``` -NOTE: Need to create the s3 resource and storage policy before the table can be successfully associated with the migration policy - -12. Add a hot and cold data migration strategy for the table partition - ```sql - CREATE TABLE create_table_partion_use_created_policy - ( - k1 DATE, - k2 INT, - V1 VARCHAR(2048) REPLACE - ) PARTITION BY RANGE (k1) ( - PARTITION p1 VALUES LESS THAN ("2022-01-01") ("storage_policy" = "test_create_table_partition_use_policy_1" ,"replication_num"="1"), - PARTITION p2 VALUES LESS THAN ("2022-02-01") ("storage_policy" = "test_create_table_partition_use_policy_2" ,"replication_num"="1") - ) DISTRIBUTED BY HASH(k2) BUCKETS 1; - ``` -NOTE: Need to create the s3 resource and storage policy before the table can be successfully associated with the migration policy - -1. Multi Partition by a partition desc - ```sql - CREATE TABLE create_table_multi_partion_date - ( - k1 DATE, - k2 INT, - V1 VARCHAR(20) - ) PARTITION BY RANGE (k1) ( - FROM ("2000-11-14") TO ("2021-11-14") INTERVAL 1 YEAR, - FROM ("2021-11-14") TO ("2022-11-14") INTERVAL 1 MONTH, - FROM ("2022-11-14") TO ("2023-01-03") INTERVAL 1 WEEK, - FROM ("2023-01-03") TO ("2023-01-14") INTERVAL 1 DAY, - PARTITION p_20230114 VALUES [('2023-01-14'), ('2023-01-15')) - ) DISTRIBUTED BY HASH(k2) BUCKETS 1 - PROPERTIES( - "replication_num" = "1" - ); - ``` - ```sql - CREATE TABLE create_table_multi_partion_date_hour - ( - k1 DATETIME, - k2 INT, - V1 VARCHAR(20) - ) PARTITION BY RANGE (k1) ( - FROM ("2023-01-03 12") TO ("2023-01-14 22") INTERVAL 1 HOUR - ) DISTRIBUTED BY HASH(k2) BUCKETS 1 - PROPERTIES( - "replication_num" = "1" - ); - ``` - ```sql - CREATE TABLE create_table_multi_partion_integer - ( - k1 BIGINT, - k2 INT, - V1 VARCHAR(20) - ) PARTITION BY RANGE (k1) ( - FROM (1) TO (100) INTERVAL 10 - ) DISTRIBUTED BY HASH(k2) BUCKETS 1 - PROPERTIES( - "replication_num" = "1" - ); - ``` - -NOTE: Multi Partition can be mixed with conventional manual creation of partitions. When using, you need to limit the partition column to only one, The default maximum number of partitions created in multi partition is 4096, This parameter can be adjusted in fe configuration `max_multi_partition_num`. - - -1. Add a duplicate without sorting column table - - ```sql - CREATE TABLE example_db.table_hash - ( - k1 DATE, - k2 DECIMAL(10, 2) DEFAULT "10.5", - k3 CHAR(10) COMMENT "string column", - k4 INT NOT NULL DEFAULT "1" COMMENT "int column" - ) - COMMENT "duplicate without keys" - PARTITION BY RANGE(k1) - ( - PARTITION p1 VALUES LESS THAN ("2020-02-01"), - PARTITION p2 VALUES LESS THAN ("2020-03-01"), - PARTITION p3 VALUES LESS THAN ("2020-04-01") - ) - DISTRIBUTED BY HASH(k1) BUCKETS 32 - PROPERTIES ( - "replication_num" = "1", - "enable_duplicate_without_keys_by_default" = "true" - ); - ``` - -### Keywords - - CREATE, TABLE - -### Best Practice - -#### Partitioning and bucketing - -A table must specify the bucket column, but it does not need to specify the partition. For the specific introduction of partitioning and bucketing, please refer to the [Data Partitioning](../../../../table-design/data-partitioning/basic-concepts) document. - -Tables in Doris can be divided into partitioned tables and non-partitioned tables. This attribute is determined when the table is created and cannot be changed afterwards. That is, for partitioned tables, you can add or delete partitions in the subsequent use process, and for non-partitioned tables, you can no longer perform operations such as adding partitions afterwards. - -At the same time, partitioning columns and bucketing columns cannot be changed after the table is created. You can neither change the types of partitioning and bucketing columns, nor do any additions or deletions to these columns. - -Therefore, it is recommended to confirm the usage method to build the table reasonably before building the table. - -#### Dynamic Partition - -The dynamic partition function is mainly used to help users automatically manage partitions. By setting certain rules, the Doris system regularly adds new partitions or deletes historical partitions. Please refer to [Dynamic Partition](../../../../table-design/data-partitioning/dynamic-partitioning) document for more help. - -#### Auto Partition - -See in [Auto Partition](../../../../table-design/data-partitioning/auto-partitioning). - -#### Materialized View - -Users can create multiple materialized views (ROLLUP) while building a table. Materialized views can also be added after the table is built. It is convenient for users to create all materialized views at one time by writing in the table creation statement. - -If the materialized view is created when the table is created, all subsequent data import operations will synchronize the data of the materialized view to be generated. The number of materialized views may affect the efficiency of data import. - -If you add a materialized view in the subsequent use process, if there is data in the table, the creation time of the materialized view depends on the current amount of data. - -For the introduction of materialized views, please refer to the [Materialized View](../../../../query/view-materialized-view/materialized-view) document. - -#### Index - -Users can create indexes on multiple columns while building a table. Indexes can also be added after the table is built. - -If you add an index in the subsequent use process, if there is data in the table, you need to rewrite all the data, so the creation time of the index depends on the current data volume. - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-VIEW.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-VIEW.md deleted file mode 100644 index c2a6fda5dc9df..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-VIEW.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -{ - "title": "CREATE-VIEW", - "language": "en" -} ---- - - - -## CREATE-VIEW - -### Name - -CREATE VIEW - -### Description - -This statement is used to create a logical view -grammar: - -```sql -CREATE VIEW [IF NOT EXISTS] - [db_name.]view_name - (column1[ COMMENT "col comment"][, column2, ...]) -AS query_stmt -``` - - -illustrate: - -- Views are logical views and have no physical storage. All queries on the view are equivalent to the sub-queries corresponding to the view. -- query_stmt is any supported SQL - -### Example - -1. Create the view example_view on example_db - - ```sql - CREATE VIEW example_db.example_view (k1, k2, k3, v1) - AS - SELECT c1 as k1, k2, k3, SUM(v1) FROM example_table - WHERE k1 = 20160112 GROUP BY k1,k2,k3; - ``` - -2. Create a view with a comment - - ```sql - CREATE VIEW example_db.example_view - ( - k1 COMMENT "first key", - k2 COMMENT "second key", - k3 COMMENT "third key", - v1 COMMENT "first value" - ) - COMMENT "my first view" - AS - SELECT c1 as k1, k2, k3, SUM(v1) FROM example_table - WHERE k1 = 20160112 GROUP BY k1,k2,k3; - ``` - -### Keywords - - CREATE, VIEW - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-WORKLOAD-GROUP.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-WORKLOAD-GROUP.md deleted file mode 100644 index e754655d6aa77..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-WORKLOAD-GROUP.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -{ - "title": "CREATE-WORKLOAD-GORUP", - "language": "en" -} ---- - - - -## CREATE-WORKLOAD-GROUP - -### Name - -CREATE WORKLOAD GROUP - -### Description - -This statement is used to create a workload group. Workload groups enable the isolation of cpu resources and memory resources on a single be. - -grammar: - -```sql -CREATE WORKLOAD GROUP [IF NOT EXISTS] "rg_name" -PROPERTIES ( - property_list -); -``` - -illustrate: - -Properties supported by property_list: - -* cpu_share: Required, used to set how much cpu time the workload group can acquire, which can achieve soft isolation of cpu resources. cpu_share is a relative value indicating the weight of cpu resources available to the running workload group. For example, if a user creates 3 workload groups rg-a, rg-b and rg-c with cpu_share of 10, 30 and 40 respectively, and at a certain moment rg-a and rg-b are running tasks while rg-c has no tasks, then rg-a can get (10 / (10 + 30)) = 25% of the cpu resources while workload group rg-b can get 75% of the cpu resources. If the system has only one workload group running, it gets all the cpu resources regardless of the value of its cpu_share. - -* memory_limit: Required, set the percentage of be memory that can be used by the workload group. The absolute value of the workload group memory limit is: `physical_memory * mem_limit * memory_limit`, where mem_limit is a be configuration item. The total memory_limit of all workload groups in the system must not exceed 100%. Workload groups are guaranteed to use the memory_limit for the tasks in the group in most cases. When the workload group memory usage exceeds this limit, tasks in the group with larger memory usage may be canceled to release the excess memory, refer to enable_memory_overcommit. - -* enable_memory_overcommit: Optional, enable soft memory isolation for the workload group, default is false. if set to false, the workload group is hard memory isolated and the tasks with the largest memory usage will be canceled immediately after the workload group memory usage exceeds the limit to release the excess memory. if set to true, the workload group is hard memory isolated and the tasks with the largest memory usage will be canceled immediately after the workload group memory usage exceeds the limit to release the excess memory. if set to true, the workload group is softly isolated, if the system has free memory resources, the workload group can continue to use system memory after exceeding the memory_limit limit, and when the total system memory is tight, it will cancel several tasks in the group with the largest memory occupation, releasing part of the excess memory to relieve the system memory pressure. It is recommended that when this configuration is enabled for a workload group, the total memory_limit of all workload groups should be less than 100%, and the remaining portion should be used for workload group memory overcommit. - -### Example - -1. Create a workload group named g1: - - ```sql - create workload group if not exists g1 - properties ( - "cpu_share"="10", - "memory_limit"="30%", - "enable_memory_overcommit"="true" - ); - ``` - -### Keywords - - CREATE, WORKLOAD, GROUP - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-ASYNC-MATERIALIZED-VIEW.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-ASYNC-MATERIALIZED-VIEW.md deleted file mode 100644 index a8bf6abafd1d1..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-ASYNC-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -{ - "title": "DROP-ASYNC-MATERIALIZED-VIEW", - "language": "en" -} ---- - - - -## DROP-ASYNC-MATERIALIZED-VIEW - -### Name - -DROP ASYNC MATERIALIZED VIEW - -### Description - -This statement is used to delete asynchronous materialized views. - -syntax: - -```sql -DROP MATERIALIZED VIEW (IF EXISTS)? mvName=multipartIdentifier -``` - - -1. IF EXISTS: - If the materialized view does not exist, do not throw an error. If this keyword is not declared and the materialized view does not exist, an error will be reported. - -2. mv_name: - The name of the materialized view to be deleted. Required field. - -### Example - -1. Delete table materialized view mv1 - -```sql -DROP MATERIALIZED VIEW mv1; -``` -2.If present, delete the materialized view of the specified database - -```sql -DROP MATERIALIZED VIEW IF EXISTS db1.mv1; -``` - -### Keywords - - DROP, ASYNC, MATERIALIZED, VIEW - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-CATALOG-RECYCLE-BIN.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-CATALOG-RECYCLE-BIN.md deleted file mode 100644 index c6207bcfe3058..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-CATALOG-RECYCLE-BIN.md +++ /dev/null @@ -1,90 +0,0 @@ ---- -{ - "title": "DROP-CATALOG-RECYCLE-BIN", - "language": "en" -} ---- - - - -## DROP-CATALOG-RECYCLE-BIN - -### Name - -DROP CATALOG RECYCLE BIN - -### Description - -This statement is used to delete db/table/partition in catalog recycle bin instantly. - -You can get all meta informations that can be deleted by statement `SHOW CATALOG RECYCLE BIN`. - -grammar: - -1. delete database by DbId - - ```sql - DROP CATALOG RECYCLE BIN WHERE 'DbId' = db_id; - ``` - -2. delete table by TableId - - ```sql - DROP CATALOG RECYCLE BIN WHERE 'TableId' = table_id; - ``` - - 3. delete partition by PartitionId - - ```sql - DROP CATALOG RECYCLE BIN WHERE 'PartitionId' = partition_id; - ``` - -illustrate: - -- When drop db/table/partition, the catalog recycle bin will delete them after catalog_trash_expire_second(in fe.conf) seconds. This statement will delete them to free disk usage timely. -- `'DbId'`, `'TableId'` and `'PartitionId'` will be case-insensitive and not distinguish between `'` and `''`. -- When drop a database which is not in catalog recycle bin, it will also delete all tables and partitions with same DbId in catalog recycle bin. Only if nothing is deleted,it will report an error. When drop a table which is not in catalog recycle bin, the treatment is similar. - -### Example - -1. Delete the database(include tables and partitions with same DbId) with id example_db_id - - ```sql - DROP CATALOG RECYCLE BIN WHERE 'DbId' = example_db_id; - ``` - -2. Delete the table(include partitions with same TableId) with id example_tbl_id - - ```sql - DROP CATALOG RECYCLE BIN WHERE 'TableId' = example_tbl_id; - ``` - -3. Delete the partition with id p1_id - - ```sql - DROP CATALOG RECYCLE BIN WHERE 'PartitionId' = p1_id; - ``` - -### Keywords - -DROP, CATALOG, RECYCLE, BIN - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-CATALOG.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-CATALOG.md deleted file mode 100644 index 8ce48c1fe2846..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-CATALOG.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "DROP-CATALOG", - "language": "en" -} ---- - - - -## DROP-CATALOG - -### Name - -CREATE CATALOG - -### Description - -This statement is used to delete the external catalog. - -Syntax: - -```sql -DROP CATALOG [I EXISTS] catalog_name; -``` - -### Example - -1. Drop catalog hive - - ```sql - DROP CATALOG hive; - ``` - -### Keywords - -DROP, CATALOG - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-DATABASE.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-DATABASE.md deleted file mode 100644 index 15cfdbd413d78..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-DATABASE.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -{ - "title": "DROP-DATABASE", - "language": "en" -} ---- - - - -## DROP-DATABASE - -### Name - -DOPR DATABASE - -### Description - -This statement is used to delete the database (database) -grammar: - -```sql -DROP DATABASE [IF EXISTS] db_name [FORCE]; -``` - -illustrate: - -- During the execution of DROP DATABASE, the deleted database can be recovered through the RECOVER statement. See the [RECOVER](../../Database-Administration-Statements/RECOVER.md) statement for details -- If you execute DROP DATABASE FORCE, the system will not check the database for unfinished transactions, the database will be deleted directly and cannot be recovered, this operation is generally not recommended - -### Example - -1. Delete the database db_test - - ```sql - DROP DATABASE db_test; - ``` - -### Keywords - - DROP, DATABASE - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-ENCRYPT-KEY.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-ENCRYPT-KEY.md deleted file mode 100644 index aa24d5aa58e2d..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-ENCRYPT-KEY.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -{ - "title": "DROP-ENCRYPT-KEY", - "language": "en" -} ---- - - - -## DROP-ENCRYPT-KEY - -### Name - -DROP ENCRYPTKEY - -### Description - -grammar: - -```sql -DROP ENCRYPTKEY key_name -``` - -Parameter Description: - -- `key_name`: The name of the key to delete, can include the name of the database. For example: `db1.my_key`. - -Delete a custom key. The name of the key is exactly the same to be deleted. - -Executing this command requires the user to have `ADMIN` privileges. - -### Example - -1. Delete a key - - ```sql - DROP ENCRYPTKEY my_key; - ``` - -### Keywords - - DROP, ENCRYPT, KEY - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-FILE.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-FILE.md deleted file mode 100644 index c72671e4d2af5..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-FILE.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -{ - "title": "DROP-FILE", - "language": "en" -} ---- - - - -## DROP-FILE - -### Name - -DROP FILE - -### Description - -This statement is used to delete an uploaded file. - -grammar: - -```sql -DROP FILE "file_name" [FROM database] -[properties] -``` - -illustrate: - -- file_name: file name. -- database: a db to which the file belongs, if not specified, the db of the current session is used. -- properties supports the following parameters: - - `catalog`: Required. The category the file belongs to. - -### Example - -1. Delete the file ca.pem - - ```sql - DROP FILE "ca.pem" properties("catalog" = "kafka"); - ``` - -### Keywords - - DROP, FILE - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-FUNCTION.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-FUNCTION.md deleted file mode 100644 index fabe70e749ddf..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-FUNCTION.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -{ - "title": "DROP-FUNCTION", - "language": "en" -} ---- - - - -## DROP-FUNCTION - -### Name - -DROP FUNCTION - -### Description - -Delete a custom function. Function names and parameter types are exactly the same to be deleted. - -grammar: - -```sql -DROP [GLOBAL] FUNCTION function_name - (arg_type [, ...]) -``` - -Parameter Description: - -- `function_name`: the name of the function to delete -- `arg_type`: the argument list of the function to delete - -### Example - -1. Delete a function - - ```sql - DROP FUNCTION my_add(INT, INT) - ``` -2. Delete a global function - - ```sql - DROP GLOBAL FUNCTION my_add(INT, INT) - ``` - -### Keywords - - DROP, FUNCTION - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-INDEX.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-INDEX.md deleted file mode 100644 index 8c36b3a834c56..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-INDEX.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -{ - "title": "DROP-INDEX", - "language": "en" -} ---- - - - -## DROP-INDEX - -### Name - -DROP INDEX - -### Description - -This statement is used to delete the index of the specified name from a table. -grammar: - -```sql -DROP INDEX [IF EXISTS] index_name ON [db_name.]table_name; -``` - -### Example - -1. Delete the index - - ```sql - DROP INDEX [IF NOT EXISTS] index_name ON table1 ; - ``` - -### Keywords - - DROP, INDEX - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-JOB.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-JOB.md deleted file mode 100644 index ecbc1837ee938..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-JOB.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -{ -"title": "DROP-JOB", -"language": "en" -} ---- - - - -## DROP-JOB - -### Name - -DROP JOB - -### Description - -User stops a JOB. A stopped job cannot be resumed. - -```sql -DROP JOB WHERE jobName = 'job_name'; -``` - -### Example - -1. DROP the job named test1. - - ```sql - DROP JOB where jobName = 'test1'; - ``` - -### Keywords - - DROP, JOB - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-MATERIALIZED-VIEW.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-MATERIALIZED-VIEW.md deleted file mode 100644 index 30cb5f0ab70aa..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,119 +0,0 @@ ---- -{ - "title": "DROP-MATERIALIZED-VIEW", - "language": "en" -} ---- - - - -## DROP-MATERIALIZED-VIEW - -### Name - -DROP MATERIALIZED VIEW - -### Description - -This statement is used to drop a materialized view. Synchronous syntax - -grammar: - -```sql -DROP MATERIALIZED VIEW [IF EXISTS] mv_name ON table_name; -``` - - -1. IF EXISTS: - Do not throw an error if the materialized view does not exist. If this keyword is not declared, an error will be reported if the materialized view does not exist. - -2. mv_name: - The name of the materialized view to delete. Required. - -3. table_name: - The name of the table to which the materialized view to be deleted belongs. Required. - -### Example - -The table structure is - -```sql -mysql> desc all_type_table all; -+----------------+-------+----------+------+------ -+---------+-------+ -| IndexName | Field | Type | Null | Key | Default | Extra | -+----------------+-------+----------+------+------ -+---------+-------+ -| all_type_table | k1 | TINYINT | Yes | true | N/A | | -| | k2 | SMALLINT | Yes | false | N/A | NONE | -| | k3 | INT | Yes | false | N/A | NONE | -| | k4 | BIGINT | Yes | false | N/A | NONE | -| | k5 | LARGEINT | Yes | false | N/A | NONE | -| | k6 | FLOAT | Yes | false | N/A | NONE | -| | k7 | DOUBLE | Yes | false | N/A | NONE | -| | | | | | | | | -| k1_sumk2 | k1 | TINYINT | Yes | true | N/A | | -| | k2 | SMALLINT | Yes | false | N/A | SUM | -+----------------+-------+----------+------+------ -+---------+-------+ -``` - -1. Drop the materialized view named k1_sumk2 of the table all_type_table - - ```sql - drop materialized view k1_sumk2 on all_type_table; - ``` - - The table structure after the materialized view is deleted - - ```text - +----------------+-------+----------+------+------ -+---------+-------+ - | IndexName | Field | Type | Null | Key | Default | Extra | - +----------------+-------+----------+------+------ -+---------+-------+ - | all_type_table | k1 | TINYINT | Yes | true | N/A | | - | | k2 | SMALLINT | Yes | false | N/A | NONE | - | | k3 | INT | Yes | false | N/A | NONE | - | | k4 | BIGINT | Yes | false | N/A | NONE | - | | k5 | LARGEINT | Yes | false | N/A | NONE | - | | k6 | FLOAT | Yes | false | N/A | NONE | - | | k7 | DOUBLE | Yes | false | N/A | NONE | - +----------------+-------+----------+------+------ -+---------+-------+ - ``` - -2. Drop a non-existent materialized view in the table all_type_table - - ```sql - drop materialized view k1_k2 on all_type_table; - ERROR 1064 (HY000): errCode = 2, detailMessage = Materialized view [k1_k2] does not exist in table [all_type_table] - ``` - - The delete request reports an error directly - -3. Delete the materialized view k1_k2 in the table all_type_table, if it does not exist, no error will be reported. - - ```sql - drop materialized view if exists k1_k2 on all_type_table; - Query OK, 0 rows affected (0.00 sec) - ``` - - If it exists, delete it, if it does not exist, no error is reported. - -### Keywords - - DROP, MATERIALIZED, VIEW - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-POLICY.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-POLICY.md deleted file mode 100644 index 2de113d2e001e..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-POLICY.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -{ - "title": "DROP-MATERIALIZED-VIEW", - "language": "en" -} ---- - - - -## DROP-POLICY - -### Name - -DROP POLICY - -### Description - -drop policy for row or storage - -#### ROW POLICY - -Grammar: - -1. Drop row policy -```sql -DROP ROW POLICY test_row_policy_1 on table1 [FOR user| ROLE role]; -``` - -2. Drop storage policy -```sql -DROP STORAGE POLICY policy_name1 -``` - -### Example - -1. Drop the row policy for table1 named test_row_policy_1 - - ```sql - DROP ROW POLICY test_row_policy_1 on table1 - ``` - -2. Drop the row policy for table1 using by user test - - ```sql - DROP ROW POLICY test_row_policy_1 on table1 for test - ``` - -3. Drop the row policy for table1 using by role1 - - ```sql - DROP ROW POLICY test_row_policy_1 on table1 for role role1 - ``` - -4. Drop the storage policy named policy_name1 -```sql -DROP STORAGE POLICY policy_name1 -``` - -### Keywords - - DROP, POLICY - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-RESOURCE.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-RESOURCE.md deleted file mode 100644 index 208a767604c1d..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-RESOURCE.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "DROP-RESOURCE", - "language": "en" -} ---- - - - -## DROP-RESOURCE - -### Name - -DROP RESOURCE - -### Description - -This statement is used to delete an existing resource. Only the root or admin user can delete resources. -grammar: - -```sql -DROP RESOURCE 'resource_name' -``` - -Note: ODBC/S3 resources in use cannot be deleted. - -### Example - -1. Delete the Spark resource named spark0: - - ```sql - DROP RESOURCE 'spark0'; - ``` - -### Keywords - - DROP, RESOURCE - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-SQL-BLOCK-RULE.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-SQL-BLOCK-RULE.md deleted file mode 100644 index dbd6c875761a3..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-SQL-BLOCK-RULE.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -{ - "title": "DROP-SQL-BLOCK-RULE", - "language": "en" -} ---- - - - -## DROP-SQL-BLOCK-RULE - -### Name - -DROP SQL BLOCK RULE - -### Description - -Delete SQL blocking rules, support multiple rules, separated by , - -grammar: - -```sql -DROP SQL_BLOCK_RULE test_rule1,... -``` - -### Example - -1. Delete the test_rule1 and test_rule2 blocking rules - - ```sql - mysql> DROP SQL_BLOCK_RULE test_rule1,test_rule2; - Query OK, 0 rows affected (0.00 sec) - ``` - -### Keywords - -```text -DROP, SQL_BLOCK_RULE -``` - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-TABLE.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-TABLE.md deleted file mode 100644 index a03767104c537..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-TABLE.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -{ - "title": "DROP-TABLE", - "language": "en" -} ---- - - - -## DROP-TABLE - -### Name - -DROP TABLE - -### Description - -This statement is used to drop a table. -grammar: - -```sql -DROP TABLE [IF EXISTS] [db_name.]table_name [FORCE]; -``` - - -illustrate: - -- After executing `DROP TABLE` for a period of time, the dropped table can be recovered through the RECOVER statement. See [RECOVER](../../../../sql-manual/sql-statements/Database-Administration-Statements/RECOVER) statement for details -- If you execute `DROP TABLE FORCE`, the system will not check whether there are unfinished transactions in the table, the table will be deleted directly and cannot be recovered, this operation is generally not recommended - -### Example - -1. Delete a table - - ```sql - DROP TABLE my_table; - ``` - -2. If it exists, delete the table of the specified database - - ```sql - DROP TABLE IF EXISTS example_db.my_table; - ``` - -### Keywords - - DROP, TABLE - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-WORKLOAD-GROUP.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-WORKLOAD-GROUP.md deleted file mode 100644 index 25453e9cbd82d..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-WORKLOAD-GROUP.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -{ - "title": "DROP-WORKLOAD-GROUP", - "language": "en" -} ---- - - - -## DROP-WORKLOAD-GROUP - -### Name - -DROP WORKLOAD GROUP - -### Description - -This statement is used to delete a workload group. - -```sql -DROP WORKLOAD GROUP [IF EXISTS] 'rg_name' -``` - -### Example - -1. Delete the workload group named g1: - - ```sql - drop workload group if exists g1; - ``` - -### Keywords - - DROP, WORKLOAD, GROUP - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/TRUNCATE-TABLE.md b/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/TRUNCATE-TABLE.md deleted file mode 100644 index d7779d3901c49..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Definition-Statements/Drop/TRUNCATE-TABLE.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -{ - "title": "TRUNCATE-TABLE", - "language": "en" -} ---- - - - -## TRUNCATE-TABLE - -### Name - -TRUNCATE TABLE - -### Description - -This statement is used to clear the data of the specified table and partition -grammar: - -```sql -TRUNCATE TABLE [db.]tbl[ PARTITION(p1, p2, ...)]; -``` - -illustrate: - -- The statement clears the data, but leaves the table or partition. -- Unlike DELETE, this statement can only clear the specified table or partition as a whole, and cannot add filter conditions. -- Unlike DELETE, using this method to clear data will not affect query performance. -- The data deleted by this operation cannot be recovered. -- When using this command, the table status needs to be NORMAL, that is, operations such as SCHEMA CHANGE are not allowed. -- This command may cause the ongoing load to fail - -### Example - -1. Clear the table tbl under example_db - - ```sql - TRUNCATE TABLE example_db.tbl; - ``` - -2. Empty p1 and p2 partitions of table tbl - - ```sql - TRUNCATE TABLE tbl PARTITION(p1, p2); - ``` - -### Keywords - - TRUNCATE, TABLE - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/ALTER-ROUTINE-LOAD.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/ALTER-ROUTINE-LOAD.md deleted file mode 100644 index ec9b81ff789a9..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/ALTER-ROUTINE-LOAD.md +++ /dev/null @@ -1,129 +0,0 @@ ---- -{ - "title": "ALTER-ROUTINE-LOAD", - "language": "en" -} ---- - - - -## ALTER-ROUTINE-LOAD - -### Name - -ALTER ROUTINE LOAD - -### Description - -This syntax is used to modify an already created routine import job. - -Only jobs in the PAUSED state can be modified. - -grammar: - -```sql -ALTER ROUTINE LOAD FOR [db.]job_name -[job_properties] -FROM data_source -[data_source_properties] -``` - -1. `[db.]job_name` - - Specifies the job name to modify. - -2. `tbl_name` - - Specifies the name of the table to be imported. - -3. `job_properties` - - Specifies the job parameters that need to be modified. Currently, only the modification of the following parameters is supported: - - 1. `desired_concurrent_number` - 2. `max_error_number` - 3. `max_batch_interval` - 4. `max_batch_rows` - 5. `max_batch_size` - 6. `jsonpaths` - 7. `json_root` - 8. `strip_outer_array` - 9. `strict_mode` - 10. `timezone` - 11. `num_as_string` - 12. `fuzzy_parse` - 13. `partial_columns` - 14. `max_filter_ratio` - - -4. `data_source` - - The type of data source. Currently supports: - - KAFKA - -5. `data_source_properties` - - Relevant properties of the data source. Currently only supports: - - 1. `kafka_partitions` - 2. `kafka_offsets` - 3. `kafka_broker_list` - 4. `kafka_topic` - 5. Custom properties, such as `property.group.id` - - Note: - - 1. `kafka_partitions` and `kafka_offsets` are used to modify the offset of the kafka partition to be consumed, only the currently consumed partition can be modified. Cannot add partition. - -### Example - -1. Change `desired_concurrent_number` to 1 - - ```sql - ALTER ROUTINE LOAD FOR db1.label1 - PROPERTIES - ( - "desired_concurrent_number" = "1" - ); - ``` - -2. Modify `desired_concurrent_number` to 10, modify the offset of the partition, and modify the group id. - - ```sql - ALTER ROUTINE LOAD FOR db1.label1 - PROPERTIES - ( - "desired_concurrent_number" = "10" - ) - FROM kafka - ( - "kafka_partitions" = "0, 1, 2", - "kafka_offsets" = "100, 200, 100", - "property.group.id" = "new_group" - ); - ``` - -### Keywords - - ALTER, ROUTINE, LOAD - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/BROKER-LOAD.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/BROKER-LOAD.md deleted file mode 100644 index 1a89dcf461b06..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/BROKER-LOAD.md +++ /dev/null @@ -1,571 +0,0 @@ ---- -{ - "title": "BROKER-LOAD", - "language": "en" -} ---- - - - -## BROKER-LOAD - -### Name - -BROKER LOAD - -### Description - -This command is mainly used to import data on remote storage (such as S3, HDFS) through the Broker service process. - -```sql -LOAD LABEL load_label -( -data_desc1[, data_desc2, ...] -) -WITH BROKER broker_name -[broker_properties] -[load_properties] -[COMMENT "comment"]; -``` - -- `load_label` - - Each import needs to specify a unique Label. You can use this label to view the progress of the job later. - - `[database.]label_name` - -- `data_desc1` - - Used to describe a set of files that need to be imported. - - ```sql - [MERGE|APPEND|DELETE] - DATA INFILE - ( - "file_path1"[, file_path2, ...] - ) - [NEGATIVE] - INTO TABLE `table_name` - [PARTITION (p1, p2, ...)] - [COLUMNS TERMINATED BY "column_separator"] - [LINES TERMINATED BY "line_delimiter"] - [FORMAT AS "file_type"] - [COMPRESS_TYPE AS "compress_type"] - [(column_list)] - [COLUMNS FROM PATH AS (c1, c2, ...)] - [SET (column_mapping)] - [PRECEDING FILTER predicate] - [WHERE predicate] - [DELETE ON expr] - [ORDER BY source_sequence] - [PROPERTIES ("key1"="value1", ...)] - ``` - - - `[MERGE|APPEND|DELETE]` - - Data merge type. The default is APPEND, indicating that this import is a normal append write operation. The MERGE and DELETE types are only available for Unique Key model tables. The MERGE type needs to be used with the `[DELETE ON]` statement to mark the Delete Flag column. The DELETE type indicates that all data imported this time are deleted data. - - - `DATA INFILE` - - Specify the file path to be imported. Can be multiple. Wildcards can be used. The path must eventually match to a file, if it only matches a directory the import will fail. - - - `NEGATIVE` - - This keyword is used to indicate that this import is a batch of "negative" imports. This method is only for aggregate data tables with integer SUM aggregate type. This method will reverse the integer value corresponding to the SUM aggregate column in the imported data. Mainly used to offset previously imported wrong data. - - - `PARTITION(p1, p2, ...)` - - You can specify to import only certain partitions of the table. Data that is no longer in the partition range will be ignored. - - - `COLUMNS TERMINATED BY` - - Specifies the column separator. Only valid in CSV format. Only single-byte delimiters can be specified. - - - `LINES TERMINATED BY` - - Specifies the line delimiter. Only valid in CSV format. Only single-byte delimiters can be specified. - - - `FORMAT AS` - - Specifies the file type, CSV, PARQUET and ORC formats are supported. Default is CSV. - - - `COMPRESS_TYPE AS` - Specifies the file compress type, GZ/LZO/BZ2/LZ4FRAME/DEFLATE/LZOP - - - `column list` - - Used to specify the column order in the original file. For a detailed introduction to this part, please refer to the [Column Mapping, Conversion and Filtering](../../../../data-operate/import/import-scenes/load-data-convert.md) document. - - `(k1, k2, tmpk1)` - - - `COLUMNS FROM PATH AS` - - Specifies the columns to extract from the import file path. - - - `SET (column_mapping)` - - Specifies the conversion function for the column. - - - `PRECEDING FILTER predicate` - - Pre-filter conditions. The data is first concatenated into raw data rows in order according to `column list` and `COLUMNS FROM PATH AS`. Then filter according to the pre-filter conditions. For a detailed introduction to this part, please refer to the [Column Mapping, Conversion and Filtering](../../../../data-operate/import/import-scenes/load-data-convert.md) document. - - - `WHERE predicate` - - Filter imported data based on conditions. For a detailed introduction to this part, please refer to the [Column Mapping, Conversion and Filtering](../../../../data-operate/import/import-scenes/load-data-convert.md) document. - - - `DELETE ON expr` - - It needs to be used with the MEREGE import mode, only for the table of the Unique Key model. Used to specify the columns and calculated relationships in the imported data that represent the Delete Flag. - - - `ORDER BY` - - Tables only for the Unique Key model. Used to specify the column in the imported data that represents the Sequence Col. Mainly used to ensure data order when importing. - - - `PROPERTIES ("key1"="value1", ...)` - - Specify some parameters of the imported format. For example, if the imported file is in `json` format, you can specify parameters such as `json_root`, `jsonpaths`, `fuzzy parse`, etc. - - - enclose - - When the csv data field contains row delimiters or column delimiters, to prevent accidental truncation, single-byte characters can be specified as brackets for protection. For example, the column separator is ",", the bracket is "'", and the data is "a,'b,c'", then "b,c" will be parsed as a field. Note: when the bracket is `"`, trim\_double\_quotes must be set to true. - - - escape - - Used to escape characters that appear in a csv field identical to the enclosing characters. For example, if the data is "a,'b,'c'", enclose is "'", and you want "b,'c to be parsed as a field, you need to specify a single-byte escape character, such as "\", and then modify the data to "a,' b,\'c'". - -- `WITH BROKER broker_name` - - Specify the Broker service name to be used. In the public cloud Doris. Broker service name is `bos` - -- `broker_properties` - - Specifies the information required by the broker. This information is usually used by the broker to be able to access remote storage systems. Such as BOS or HDFS. See the [Broker](../../../../advanced/broker.md) documentation for specific information. - - ```text - ( - "key1" = "val1", - "key2" = "val2", - ... - ) - ``` - -- `load_properties` - - Specifies import-related parameters. The following parameters are currently supported: - - - `timeout` - - Import timeout. The default is 4 hours. in seconds. - - - `max_filter_ratio` - - The maximum tolerable proportion of data that can be filtered (for reasons such as data irregularity). Zero tolerance by default. The value range is 0 to 1. - - - `exec_mem_limit` - - Load memory limit. Default is 2GB. The unit is bytes. - - - `strict_mode` - - Whether to impose strict restrictions on data. Defaults to false. - - - `partial_columns` - - Boolean type, True means that use partial column update, the default value is false, this parameter is only allowed to be set when the table model is Unique and Merge on Write is used. - - - `timezone` - - Specify the time zone for some functions that are affected by time zones, such as `strftime/alignment_timestamp/from_unixtime`, etc. Please refer to the [timezone](../../../../advanced/time-zone.md) documentation for details. If not specified, the "Asia/Shanghai" timezone is used - - - `load_parallelism` - - It allows the user to set the parallelism of the load execution plan - on a single node when the broker load is submitted, default value is 1. - - - `send_batch_parallelism` - - Used to set the default parallelism for sending batch, if the value for parallelism exceed `max_send_batch_parallelism_per_job` in BE config, then the coordinator BE will use the value of `max_send_batch_parallelism_per_job`. - - - `load_to_single_tablet` - - Boolean type, True means that one task can only load data to one tablet in the corresponding partition at a time. The default value is false. The number of tasks for the job depends on the overall concurrency. This parameter can only be set when loading data into the OLAP table with random bucketing. - - - priority - - Set the priority of the load job, there are three options: `HIGH/NORMAL/LOW`, use `NORMAL` priority as default. The pending broker load jobs which have higher priority will be chosen to execute earlier. - -- comment - - Specify the comment for the import job. The comment can be viewed in the `show load` statement. - -### Example - -1. Import a batch of data from HDFS - - ```sql - LOAD LABEL example_db.label1 - ( - DATA INFILE("hdfs://hdfs_host:hdfs_port/input/file.txt") - INTO TABLE `my_table` - COLUMNS TERMINATED BY "," - ) - WITH BROKER hdfs - ( - "username"="hdfs_user", - "password"="hdfs_password" - ); - ``` - - Import the file `file.txt`, separated by commas, into the table `my_table`. - -2. Import data from HDFS, using wildcards to match two batches of files in two batches. into two tables separately. - - ```sql - LOAD LABEL example_db.label2 - ( - DATA INFILE("hdfs://hdfs_host:hdfs_port/input/file-10*") - INTO TABLE `my_table1` - PARTITION (p1) - COLUMNS TERMINATED BY "," - (k1, tmp_k2, tmp_k3) - SET ( - k2 = tmp_k2 + 1, - k3 = tmp_k3 + 1 - ) - DATA INFILE("hdfs://hdfs_host:hdfs_port/input/file-20*") - INTO TABLE `my_table2` - COLUMNS TERMINATED BY "," - (k1, k2, k3) - ) - WITH BROKER hdfs - ( - "username"="hdfs_user", - "password"="hdfs_password" - ); - ``` - - Import two batches of files `file-10*` and `file-20*` using wildcard matching. Imported into two tables `my_table1` and `my_table2` respectively. Where `my_table1` specifies to import into partition `p1`, and will import the values of the second and third columns in the source file +1. - -3. Import a batch of data from HDFS. - - ```sql - LOAD LABEL example_db.label3 - ( - DATA INFILE("hdfs://hdfs_host:hdfs_port/user/doris/data/*/*") - INTO TABLE `my_table` - COLUMNS TERMINATED BY "\\x01" - ) - WITH BROKER my_hdfs_broker - ( - "username" = "", - "password" = "", - "dfs.nameservices" = "my_ha", - "dfs.ha.namenodes.my_ha" = "my_namenode1, my_namenode2", - "dfs.namenode.rpc-address.my_ha.my_namenode1" = "nn1_host:rpc_port", - "dfs.namenode.rpc-address.my_ha.my_namenode2" = "nn2_host:rpc_port", - "dfs.client.failover.proxy.provider.my_ha" = "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider" - ); - ``` - - Specify the delimiter as Hive's default delimiter `\\x01`, and use the wildcard * to specify all files in all directories under the `data` directory. Use simple authentication while configuring namenode HA. - -4. Import data in Parquet format and specify FORMAT as parquet. The default is to judge by the file suffix - - ```sql - LOAD LABEL example_db.label4 - ( - DATA INFILE("hdfs://hdfs_host:hdfs_port/input/file") - INTO TABLE `my_table` - FORMAT AS "parquet" - (k1, k2, k3) - ) - WITH BROKER hdfs - ( - "username"="hdfs_user", - "password"="hdfs_password" - ); - ``` - -5. Import the data and extract the partition field in the file path - - ```sql - LOAD LABEL example_db.label10 - ( - DATA INFILE("hdfs://hdfs_host:hdfs_port/input/city=beijing/*/*") - INTO TABLE `my_table` - FORMAT AS "csv" - (k1, k2, k3) - COLUMNS FROM PATH AS (city, utc_date) - ) - WITH BROKER hdfs - ( - "username"="hdfs_user", - "password"="hdfs_password" - ); - ``` - - The columns in the `my_table` table are `k1, k2, k3, city, utc_date`. - - The `hdfs://hdfs_host:hdfs_port/user/doris/data/input/dir/city=beijing` directory includes the following files: - - ```text - hdfs://hdfs_host:hdfs_port/input/city=beijing/utc_date=2020-10-01/0000.csv - hdfs://hdfs_host:hdfs_port/input/city=beijing/utc_date=2020-10-02/0000.csv - hdfs://hdfs_host:hdfs_port/input/city=tianji/utc_date=2020-10-03/0000.csv - hdfs://hdfs_host:hdfs_port/input/city=tianji/utc_date=2020-10-04/0000.csv - ``` - - The file only contains three columns of `k1, k2, k3`, and the two columns of `city, utc_date` will be extracted from the file path. - -6. Filter the data to be imported. - - ```sql - LOAD LABEL example_db.label6 - ( - DATA INFILE("hdfs://host:port/input/file") - INTO TABLE `my_table` - (k1, k2, k3) - SET ( - k2 = k2 + 1 - ) - PRECEDING FILTER k1 = 1 - WHERE k1 > k2 - ) - WITH BROKER hdfs - ( - "username"="user", - "password"="pass" - ); - ``` - - Only in the original data, k1 = 1, and after transformation, rows with k1 > k2 will be imported. - -7. Import data, extract the time partition field in the file path, and the time contains %3A (in the hdfs path, ':' is not allowed, all ':' will be replaced by %3A) - - ```sql - LOAD LABEL example_db.label7 - ( - DATA INFILE("hdfs://host:port/user/data/*/test.txt") - INTO TABLE `tbl12` - COLUMNS TERMINATED BY "," - (k2,k3) - COLUMNS FROM PATH AS (data_time) - SET ( - data_time=str_to_date(data_time, '%Y-%m-%d %H%%3A%i%%3A%s') - ) - ) - WITH BROKER hdfs - ( - "username"="user", - "password"="pass" - ); - ``` - - There are the following files in the path: - - ```text - /user/data/data_time=2020-02-17 00%3A00%3A00/test.txt - /user/data/data_time=2020-02-18 00%3A00%3A00/test.txt - ``` - - The table structure is: - - ```text - data_time DATETIME, - k2 INT, - k3 INT - ``` - -8. Import a batch of data from HDFS, specify the timeout and filter ratio. Broker with clear text my_hdfs_broker. Simple authentication. And delete the columns in the original data that match the columns with v2 greater than 100 in the imported data, and other columns are imported normally - - ```sql - LOAD LABEL example_db.label8 - ( - MERGE DATA INFILE("HDFS://test:802/input/file") - INTO TABLE `my_table` - (k1, k2, k3, v2, v1) - DELETE ON v2 > 100 - ) - WITH HDFS - ( - "hadoop.username"="user", - "password"="pass" - ) - PROPERTIES - ( - "timeout" = "3600", - "max_filter_ratio" = "0.1" - ); - ``` - - Import using the MERGE method. `my_table` must be a table with Unique Key. When the value of the v2 column in the imported data is greater than 100, the row is considered a delete row. - - The import task timeout is 3600 seconds, and the error rate is allowed to be within 10%. - -9. Specify the source_sequence column when importing to ensure the replacement order in the UNIQUE_KEYS table: - - ```sql - LOAD LABEL example_db.label9 - ( - DATA INFILE("HDFS://test:802/input/file") - INTO TABLE `my_table` - COLUMNS TERMINATED BY "," - (k1,k2,source_sequence,v1,v2) - ORDER BY source_sequence - ) - WITH HDFS - ( - "hadoop.username"="user", - "password"="pass" - ) - ``` - - `my_table` must be an Unique Key model table with Sequence Col specified. The data will be ordered according to the value of the `source_sequence` column in the source data. - -10. Import a batch of data from HDFS, specify the file format as `json`, and specify parameters of `json_root` and `jsonpaths`. - - ```sql - LOAD LABEL example_db.label10 - ( - DATA INFILE("HDFS://test:port/input/file.json") - INTO TABLE `my_table` - FORMAT AS "json" - PROPERTIES( - "json_root" = "$.item", - "jsonpaths" = "[$.id, $.city, $.code]" - ) - ) - with HDFS ( - "hadoop.username" = "user" - "password" = "" - ) - PROPERTIES - ( - "timeout"="1200", - "max_filter_ratio"="0.1" - ); - ``` - - `jsonpaths` can be use with `column list` and `SET(column_mapping)`: - - ```sql - LOAD LABEL example_db.label10 - ( - DATA INFILE("HDFS://test:port/input/file.json") - INTO TABLE `my_table` - FORMAT AS "json" - (id, code, city) - SET (id = id * 10) - PROPERTIES( - "json_root" = "$.item", - "jsonpaths" = "[$.id, $.code, $.city]" - ) - ) - with HDFS ( - "hadoop.username" = "user" - "password" = "" - ) - PROPERTIES - ( - "timeout"="1200", - "max_filter_ratio"="0.1" - ); - ``` - -11. Load data in csv format from cos(Tencent Cloud Object Storage). - - ```SQL - LOAD LABEL example_db.label10 - ( - DATA INFILE("cosn://my_bucket/input/file.csv") - INTO TABLE `my_table` - (k1, k2, k3) - ) - WITH BROKER "broker_name" - ( - "fs.cosn.userinfo.secretId" = "xxx", - "fs.cosn.userinfo.secretKey" = "xxxx", - "fs.cosn.bucket.endpoint_suffix" = "cos.xxxxxxxxx.myqcloud.com" - ) - ``` - -12. Load CSV date and trim double quotes and skip first 5 lines - - ```SQL - LOAD LABEL example_db.label12 - ( - DATA INFILE("cosn://my_bucket/input/file.csv") - INTO TABLE `my_table` - (k1, k2, k3) - PROPERTIES("trim_double_quotes" = "true", "skip_lines" = "5") - ) - WITH BROKER "broker_name" - ( - "fs.cosn.userinfo.secretId" = "xxx", - "fs.cosn.userinfo.secretKey" = "xxxx", - "fs.cosn.bucket.endpoint_suffix" = "cos.xxxxxxxxx.myqcloud.com" - ) - ``` - -### Keywords - - BROKER, LOAD - -### Best Practice - -1. Check the import task status - - Broker Load is an asynchronous import process. The successful execution of the statement only means that the import task is submitted successfully, and does not mean that the data import is successful. The import status needs to be viewed through the [SHOW LOAD](../../Show-Statements/SHOW-LOAD.md) command. - -2. Cancel the import task - - Import tasks that have been submitted but not yet completed can be canceled by the [CANCEL LOAD](./CANCEL-LOAD.md) command. After cancellation, the written data will also be rolled back and will not take effect. - -3. Label, import transaction, multi-table atomicity - - All import tasks in Doris are atomic. And the import of multiple tables in the same import task can also guarantee atomicity. At the same time, Doris can also use the Label mechanism to ensure that the data imported is not lost or heavy. For details, see the [Import Transactions and Atomicity](../../../../data-operate/import/import-scenes/load-atomicity.md) documentation. - -4. Column mapping, derived columns and filtering - - Doris can support very rich column transformation and filtering operations in import statements. Most built-in functions and UDFs are supported. For how to use this function correctly, please refer to the [Column Mapping, Conversion and Filtering](../../../../data-operate/import/import-scenes/load-data-convert.md) document. - -5. Error data filtering - - Doris' import tasks can tolerate a portion of malformed data. Tolerated via `max_filter_ratio` setting. The default is 0, which means that the entire import task will fail when there is an error data. If the user wants to ignore some problematic data rows, the secondary parameter can be set to a value between 0 and 1, and Doris will automatically skip the rows with incorrect data format. - - For some calculation methods of the tolerance rate, please refer to the [Column Mapping, Conversion and Filtering](../../../../data-operate/import/import-scenes/load-data-convert.md) document. - -6. Strict Mode - - The `strict_mode` attribute is used to set whether the import task runs in strict mode. The format affects the results of column mapping, transformation, and filtering. For a detailed description of strict mode, see the [strict mode](../../../../data-operate/import/import-scenes/load-strict-mode.md) documentation. - -7. Timeout - - The default timeout for Broker Load is 4 hours. from the time the task is submitted. If it does not complete within the timeout period, the task fails. - -8. Limits on data volume and number of tasks - - Broker Load is suitable for importing data within 100GB in one import task. Although theoretically there is no upper limit on the amount of data imported in one import task. But committing an import that is too large results in a longer run time, and the cost of retrying after a failure increases. - - At the same time, limited by the size of the cluster, we limit the maximum amount of imported data to the number of ComputeNode nodes * 3GB. In order to ensure the rational use of system resources. If there is a large amount of data to be imported, it is recommended to divide it into multiple import tasks. - - Doris also limits the number of import tasks running simultaneously in the cluster, usually ranging from 3 to 10. Import jobs submitted after that are queued. The maximum queue length is 100. Subsequent submissions will be rejected outright. Note that the queue time is also calculated into the total job time. If it times out, the job is canceled. Therefore, it is recommended to reasonably control the frequency of job submission by monitoring the running status of the job. - diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CANCEL-LOAD.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CANCEL-LOAD.md deleted file mode 100644 index ff56e16342fe0..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CANCEL-LOAD.md +++ /dev/null @@ -1,79 +0,0 @@ ---- -{ - "title": "CANCEL-LOAD", - "language": "en" -} ---- - - - -## CANCEL-LOAD - -### Name - -CANCEL LOAD - -### Description - -This statement is used to undo an import job for the specified label. Or batch undo import jobs via fuzzy matching - -```sql -CANCEL LOAD -[FROM db_name] -WHERE [LABEL = "load_label" | LABEL like "label_pattern" | STATE = "PENDING/ETL/LOADING"] -``` - -Notice: Cancel by State is supported since 1.2.0. - -### Example - -1. Cancel the import job whose label is `example_db_test_load_label` on the database example_db - - ```sql - CANCEL LOAD - FROM example_db - WHERE LABEL = "example_db_test_load_label"; - ``` - -2. Cancel all import jobs containing example* on the database example*db. - - ```sql - CANCEL LOAD - FROM example_db - WHERE LABEL like "example_"; - ``` - -3. Cancel all import jobs which state are "LOADING" - - ```sql - CANCEL LOAD - FROM example_db - WHERE STATE = "loading"; - ``` - -### Keywords - - CANCEL, LOAD - -### Best Practice - -1. Only pending import jobs in PENDING, ETL, LOADING state can be canceled. -2. When performing batch undo, Doris does not guarantee the atomic undo of all corresponding import jobs. That is, it is possible that only some of the import jobs were successfully undone. The user can view the job status through the SHOW LOAD statement and try to execute the CANCEL LOAD statement repeatedly. - diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CLEAN-LABEL.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CLEAN-LABEL.md deleted file mode 100644 index 8f7abe201e136..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CLEAN-LABEL.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -{ - "title": "CLEAN-LABEL", - "language": "en" -} ---- - - - -## CLEAN-LABEL - -### Name - -CLEAN LABEL - -### Description - -For manual cleanup of historical load jobs. After cleaning, the Label can be reused. - -Syntax: - -```sql -CLEAN LABEL [label] FROM db; -``` - -### Example - -1. Clean label label1 from database db1 - - ```sql - CLEAN LABEL label1 FROM db1; - ``` - -2. Clean all labels from database db1 - - ```sql - CLEAN LABEL FROM db1; - ``` - -### Keywords - - CLEAN, LABEL - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CLEAN-PROFILE.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CLEAN-PROFILE.md deleted file mode 100644 index e6c178fd4d3f7..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CLEAN-PROFILE.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "CLEAN-PROFILE", - "language": "en" -} ---- - - - -## CLEAN-PROFILE - -### Name - -CLEAN PROFILE - -### Description - -For manual cleanup all of historical query or load profile. - -Syntax: - -```sql -CLEAN ALL PROFILE; -``` - -### Example - -1. Clean all profile - - ```sql - CLEAN ALL PROFILE; - ``` - -### Keywords - - CLEAN, PROFILE - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CREATE-ROUTINE-LOAD.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CREATE-ROUTINE-LOAD.md deleted file mode 100644 index d3e2bfc07ebb1..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CREATE-ROUTINE-LOAD.md +++ /dev/null @@ -1,627 +0,0 @@ ---- -{ - "title": "CREATE-ROUTINE-LOAD", - "language": "en" -} ---- - - - -## CREATE-ROUTINE-LOAD - -### Name - -CREATE ROUTINE LOAD - -### Description - -The Routine Load function allows users to submit a resident import task, and import data into Doris by continuously reading data from a specified data source. - -Currently, only data in CSV or Json format can be imported from Kakfa through unauthenticated or SSL authentication. [Example of importing data in Json format](../../../../data-operate/import/import-way/routine-load-manual.md#Example_of_importing_data_in_Json_format) - -grammar: - -```sql -CREATE ROUTINE LOAD [db.]job_name [ON tbl_name] -[merge_type] -[load_properties] -[job_properties] -FROM data_source [data_source_properties] -[COMMENT "comment"] -``` - -- `[db.]job_name` - - The name of the import job. Within the same database, only one job with the same name can be running. - -- `tbl_name` - - Specifies the name of the table to be imported.Optional parameter, If not specified, the dynamic table method will - be used, which requires the data in Kafka to contain table name information. Currently, only the table name can be - obtained from the Kafka value, and it needs to conform to the format of "table_name|{"col1": "val1", "col2": "val2"}" - for JSON data. The "tbl_name" represents the table name, and "|" is used as the delimiter between the table name and - the table data. The same format applies to CSV data, such as "table_name|val1,val2,val3". It is important to note that - the "table_name" must be consistent with the table name in Doris, otherwise it may cause import failures. - - Tips: The `columns_mapping` parameter is not supported for dynamic tables. If your table structure is consistent with - the table structure in Doris and there is a large amount of table information to be imported, this method will be the - best choice. - -- `merge_type` - - Data merge type. The default is APPEND, which means that the imported data are ordinary append write operations. The MERGE and DELETE types are only available for Unique Key model tables. The MERGE type needs to be used with the [DELETE ON] statement to mark the Delete Flag column. The DELETE type means that all imported data are deleted data. - - Tips: When using dynamic multiple tables, please note that this parameter should be consistent with the type of each dynamic table, otherwise it will result in import failure. - -- load_properties - - Used to describe imported data. The composition is as follows: - - ```SQL - [column_separator], - [columns_mapping], - [preceding_filter], - [where_predicates], - [partitions], - [DELETE ON], - [ORDER BY] - ``` - - - `column_separator` - - Specifies the column separator, defaults to `\t` - - `COLUMNS TERMINATED BY ","` - - - `columns_mapping` - - It is used to specify the mapping relationship between file columns and columns in the table, as well as various column transformations. For a detailed introduction to this part, you can refer to the [Column Mapping, Transformation and Filtering] document. - - `(k1, k2, tmpk1, k3 = tmpk1 + 1)` - - Tips: Dynamic multiple tables are not supported. - - - `preceding_filter` - - Filter raw data. For a detailed introduction to this part, you can refer to the [Column Mapping, Transformation and Filtering] document. - - Tips: Dynamic multiple tables are not supported. - - - `where_predicates` - - Filter imported data based on conditions. For a detailed introduction to this part, you can refer to the [Column Mapping, Transformation and Filtering] document. - - `WHERE k1 > 100 and k2 = 1000` - - Tips: When using dynamic multiple tables, please note that this parameter should be consistent with the type of each dynamic table, otherwise it will result in import failure. - - - `partitions` - - Specify in which partitions of the import destination table. If not specified, it will be automatically imported into the corresponding partition. - - `PARTITION(p1, p2, p3)` - - Tips: When using dynamic multiple tables, please note that this parameter should conform to each dynamic table, otherwise it may cause import failure. - - - `DELETE ON` - - It needs to be used with the MEREGE import mode, only for the table of the Unique Key model. Used to specify the columns and calculated relationships in the imported data that represent the Delete Flag. - - `DELETE ON v3 >100` - - Tips: When using dynamic multiple tables, please note that this parameter should conform to each dynamic table, otherwise it may cause import failure. - - - `ORDER BY` - - Tables only for the Unique Key model. Used to specify the column in the imported data that represents the Sequence Col. Mainly used to ensure data order when importing. - - Tips: When using dynamic multiple tables, please note that this parameter should conform to each dynamic table, otherwise it may cause import failure. - -- `job_properties` - - Common parameters for specifying routine import jobs. - - ```text - PROPERTIES ( - "key1" = "val1", - "key2" = "val2" - ) - ``` - - Currently we support the following parameters: - - 1. `desired_concurrent_number` - - Desired concurrency. A routine import job will be divided into multiple subtasks for execution. This parameter specifies the maximum number of tasks a job can execute concurrently. Must be greater than 0. Default is 5. - - This degree of concurrency is not the actual degree of concurrency. The actual degree of concurrency will be comprehensively considered by the number of nodes in the cluster, the load situation, and the situation of the data source. - - `"desired_concurrent_number" = "3"` - - 2. `max_batch_interval/max_batch_rows/max_batch_size` - - These three parameters represent: - - 1. The maximum execution time of each subtask, in seconds. Must be greater than or equal to 1. The default is 10. - 2. The maximum number of lines read by each subtask. Must be greater than or equal to 200000. The default is 200000. - 3. The maximum number of bytes read by each subtask. The unit is bytes and the range is 100MB to 10GB. The default is 100MB. - - These three parameters are used to control the execution time and processing volume of a subtask. When either one reaches the threshold, the task ends. - - ```text - "max_batch_interval" = "20", - "max_batch_rows" = "300000", - "max_batch_size" = "209715200" - ``` - - 3. `max_error_number` - - The maximum number of error lines allowed within the sampling window. Must be greater than or equal to 0. The default is 0, which means no error lines are allowed. - - The sampling window is `max_batch_rows * 10`. That is, if the number of error lines is greater than `max_error_number` within the sampling window, the routine operation will be suspended, requiring manual intervention to check data quality problems. - - Rows that are filtered out by where conditions are not considered error rows. - - 4. `strict_mode` - - Whether to enable strict mode, the default is off. If enabled, the column type conversion of non-null raw data will be filtered if the result is NULL. Specify as: - - `"strict_mode" = "true"` - - The strict mode mode means strict filtering of column type conversions during the load process. The strict filtering strategy is as follows: - - 1. For column type conversion, if strict mode is true, the wrong data will be filtered. The error data here refers to the fact that the original data is not null, and the result is a null value after participating in the column type conversion. - 2. When a loaded column is generated by a function transformation, strict mode has no effect on it. - 3. For a column type loaded with a range limit, if the original data can pass the type conversion normally, but cannot pass the range limit, strict mode will not affect it. For example, if the type is decimal(1,0) and the original data is 10, it is eligible for type conversion but not for column declarations. This data strict has no effect on it. - - **strict mode and load relationship of source data** - - Here is an example of a column type of TinyInt. - - > Note: When a column in a table allows a null value to be loaded - - | source data | source data example | string to int | strict_mode | result | - | ----------- | ------------------- | ------------- | ------------- | ---------------------- | - | null | \N | N/A | true or false | NULL | - | not null | aaa or 2000 | NULL | true | invalid data(filtered) | - | not null | aaa | NULL | false | NULL | - | not null | 1 | 1 | true or false | correct data | - - Here the column type is Decimal(1,0) - - > Note: When a column in a table allows a null value to be loaded - - | source data | source data example | string to int | strict_mode | result | - | ----------- | ------------------- | ------------- | ------------- | ---------------------- | - | null | \N | N/A | true or false | NULL | - | not null | aaa | NULL | true | invalid data(filtered) | - | not null | aaa | NULL | false | NULL | - | not null | 1 or 10 | 1 | true or false | correct data | - - > Note: 10 Although it is a value that is out of range, because its type meets the requirements of decimal, strict mode has no effect on it. 10 will eventually be filtered in other ETL processing flows. But it will not be filtered by strict mode. - - 5. `timezone` - - Specifies the time zone used by the import job. The default is to use the Session's timezone parameter. This parameter affects the results of all time zone-related functions involved in the import. - - 6. `format` - - Specify the import data format, the default is csv, and the json format is supported. - - 7. `jsonpaths` - - When the imported data format is json, the fields in the Json data can be extracted by specifying jsonpaths. - - `-H "jsonpaths: [\"$.k2\", \"$.k1\"]"` - - 8. `strip_outer_array` - - When the imported data format is json, strip_outer_array is true, indicating that the Json data is displayed in the form of an array, and each element in the data will be regarded as a row of data. The default value is false. - - `-H "strip_outer_array: true"` - - 9. `json_root` - - When the import data format is json, you can specify the root node of the Json data through json_root. Doris will extract the elements of the root node through json_root for parsing. Default is empty. - - `-H "json_root: $.RECORDS"` - 10. `send_batch_parallelism` - - Integer, Used to set the default parallelism for sending batch, if the value for parallelism exceed `max_send_batch_parallelism_per_job` in BE config, then the coordinator BE will use the value of `max_send_batch_parallelism_per_job`. - - 11. `load_to_single_tablet` - Boolean type, True means that one task can only load data to one tablet in the corresponding partition at a time. The default value is false. This parameter can only be set when loading data into the OLAP table with random bucketing. - - 12. `partial_columns` - Boolean type, True means that use partial column update, the default value is false, this parameter is only allowed to be set when the table model is Unique and Merge on Write is used. Multi-table does not support this parameter. - - 13. `max_filter_ratio` - The maximum allowed filtering rate within the sampling window. Must be between 0 and 1. The default value is 0. - - The sampling window is `max_batch_rows * 10`. That is, if the number of error lines / total lines is greater than `max_filter_ratio` within the sampling window, the routine operation will be suspended, requiring manual intervention to check data quality problems. - - Rows that are filtered out by where conditions are not considered error rows. - - 14. `enclose` - When the csv data field contains row delimiters or column delimiters, to prevent accidental truncation, single-byte characters can be specified as brackets for protection. For example, the column separator is ",", the bracket is "'", and the data is "a,'b,c'", then "b,c" will be parsed as a field. - Note: when the bracket is `"`, trim\_double\_quotes must be set to true. - - 15. `escape` - Used to escape characters that appear in a csv field identical to the enclosing characters. For example, if the data is "a,'b,'c'", enclose is "'", and you want "b,'c to be parsed as a field, you need to specify a single-byte escape character, such as "\", and then modify the data to "a,' b,\'c'". - -- `FROM data_source [data_source_properties]` - - The type of data source. Currently supports: - - ```text - FROM KAFKA - ( - "key1" = "val1", - "key2" = "val2" - ) - ``` - - `data_source_properties` supports the following data source properties: - - 1. `kafka_broker_list` - - Kafka's broker connection information. The format is ip:host. Separate multiple brokers with commas. - - `"kafka_broker_list" = "broker1:9092,broker2:9092"` - - 2. `kafka_topic` - - Specifies the Kafka topic to subscribe to. - - `"kafka_topic" = "my_topic"` - - 3. `kafka_partitions/kafka_offsets` - - Specify the kafka partition to be subscribed to, and the corresponding starting offset of each partition. If a time is specified, consumption will start at the nearest offset greater than or equal to the time. - - offset can specify a specific offset from 0 or greater, or: - - - `OFFSET_BEGINNING`: Start subscription from where there is data. - - `OFFSET_END`: subscribe from the end. - - Time format, such as: "2021-05-22 11:00:00" - - If not specified, all partitions under topic will be subscribed from `OFFSET_END` by default. - - ```text - "kafka_partitions" = "0,1,2,3", - "kafka_offsets" = "101,0,OFFSET_BEGINNING,OFFSET_END" - ``` - - ```text - "kafka_partitions" = "0,1,2,3", - "kafka_offsets" = "2021-05-22 11:00:00,2021-05-22 11:00:00,2021-05-22 11:00:00" - ``` - - Note that the time format cannot be mixed with the OFFSET format. - - 4. `property` - - Specify custom kafka parameters. The function is equivalent to the "--property" parameter in the kafka shell. - - When the value of the parameter is a file, you need to add the keyword: "FILE:" before the value. - - For how to create a file, please refer to the [CREATE FILE](../../../Data-Definition-Statements/Create/CREATE-FILE) command documentation. - - For more supported custom parameters, please refer to the configuration items on the client side in the official CONFIGURATION document of librdkafka. Such as: - - ```text - "property.client.id" = "12345", - "property.ssl.ca.location" = "FILE:ca.pem" - ``` - - 1. When connecting to Kafka using SSL, you need to specify the following parameters: - - ```text - "property.security.protocol" = "ssl", - "property.ssl.ca.location" = "FILE:ca.pem", - "property.ssl.certificate.location" = "FILE:client.pem", - "property.ssl.key.location" = "FILE:client.key", - "property.ssl.key.password" = "abcdefg" - ``` - - in: - - `property.security.protocol` and `property.ssl.ca.location` are required to indicate the connection method is SSL and the location of the CA certificate. - - If client authentication is enabled on the Kafka server side, thenAlso set: - - ```text - "property.ssl.certificate.location" - "property.ssl.key.location" - "property.ssl.key.password" - ``` - - They are used to specify the client's public key, private key, and password for the private key, respectively. - - 2. Specify the default starting offset of the kafka partition - - If `kafka_partitions/kafka_offsets` is not specified, all partitions are consumed by default. - - At this point, you can specify `kafka_default_offsets` to specify the starting offset. Defaults to `OFFSET_END`, i.e. subscribes from the end. - - Example: - - ```text - "property.kafka_default_offsets" = "OFFSET_BEGINNING" - ``` -- comment - Comment for the routine load job. -### Example - -1. Create a Kafka routine import task named test1 for example_tbl of example_db. Specify the column separator and group.id and client.id, and automatically consume all partitions by default, and start subscribing from the location where there is data (OFFSET_BEGINNING) - - - - ```sql - CREATE ROUTINE LOAD example_db.test1 ON example_tbl - COLUMNS TERMINATED BY ",", - COLUMNS(k1, k2, k3, v1, v2, v3 = k1 * 100) - PROPERTIES - ( - "desired_concurrent_number"="3", - "max_batch_interval" = "20", - "max_batch_rows" = "300000", - "max_batch_size" = "209715200", - "strict_mode" = "false" - ) - FROM KAFKA - ( - "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", - "kafka_topic" = "my_topic", - "property.group.id" = "xxx", - "property.client.id" = "xxx", - "property.kafka_default_offsets" = "OFFSET_BEGINNING" - ); - ``` - -2. Create a Kafka routine dynamic multiple tables import task named "test1" for the "example_db". Specify the column delimiter, group.id, and client.id, and automatically consume all partitions, subscribing from the position with data (OFFSET_BEGINNING). - -Assuming that we need to import data from Kafka into tables "test1" and "test2" in the "example_db", we create a routine import task named "test1". At the same time, we write the data in "test1" and "test2" to a Kafka topic named "my_topic" so that data from Kafka can be imported into both tables through a routine import task. - - ```sql - CREATE ROUTINE LOAD example_db.test1 - PROPERTIES - ( - "desired_concurrent_number"="3", - "max_batch_interval" = "20", - "max_batch_rows" = "300000", - "max_batch_size" = "209715200", - "strict_mode" = "false" - ) - FROM KAFKA - ( - "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", - "kafka_topic" = "my_topic", - "property.group.id" = "xxx", - "property.client.id" = "xxx", - "property.kafka_default_offsets" = "OFFSET_BEGINNING" - ); - ``` - -3. Create a Kafka routine import task named test1 for example_tbl of example_db. Import tasks are in strict mode. - - - - ```sql - CREATE ROUTINE LOAD example_db.test1 ON example_tbl - COLUMNS(k1, k2, k3, v1, v2, v3 = k1 * 100), - PRECEDING FILTER k1 = 1, - WHERE k1 > 100 and k2 like "%doris%" - PROPERTIES - ( - "desired_concurrent_number"="3", - "max_batch_interval" = "20", - "max_batch_rows" = "300000", - "max_batch_size" = "209715200", - "strict_mode" = "true" - ) - FROM KAFKA - ( - "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", - "kafka_topic" = "my_topic", - "kafka_partitions" = "0,1,2,3", - "kafka_offsets" = "101,0,0,200" - ); - ``` - -4. Import data from the Kafka cluster through SSL authentication. Also set the client.id parameter. The import task is in non-strict mode and the time zone is Africa/Abidjan - - - - ```sql - CREATE ROUTINE LOAD example_db.test1 ON example_tbl - COLUMNS(k1, k2, k3, v1, v2, v3 = k1 * 100), - WHERE k1 > 100 and k2 like "%doris%" - PROPERTIES - ( - "desired_concurrent_number"="3", - "max_batch_interval" = "20", - "max_batch_rows" = "300000", - "max_batch_size" = "209715200", - "strict_mode" = "false", - "timezone" = "Africa/Abidjan" - ) - FROM KAFKA - ( - "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", - "kafka_topic" = "my_topic", - "property.security.protocol" = "ssl", - "property.ssl.ca.location" = "FILE:ca.pem", - "property.ssl.certificate.location" = "FILE:client.pem", - "property.ssl.key.location" = "FILE:client.key", - "property.ssl.key.password" = "abcdefg", - "property.client.id" = "my_client_id" - ); - ``` - -5. Import data in Json format. By default, the field name in Json is used as the column name mapping. Specify to import three partitions 0, 1, and 2, and the starting offsets are all 0 - - - - ```sql - CREATE ROUTINE LOAD example_db.test_json_label_1 ON table1 - COLUMNS(category,price,author) - PROPERTIES - ( - "desired_concurrent_number"="3", - "max_batch_interval" = "20", - "max_batch_rows" = "300000", - "max_batch_size" = "209715200", - "strict_mode" = "false", - "format" = "json" - ) - FROM KAFKA - ( - "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", - "kafka_topic" = "my_topic", - "kafka_partitions" = "0,1,2", - "kafka_offsets" = "0,0,0" - ); - ``` - -6. Import Json data, extract fields through Jsonpaths, and specify the root node of the Json document - - - - ```sql - CREATE ROUTINE LOAD example_db.test1 ON example_tbl - COLUMNS(category, author, price, timestamp, dt=from_unixtime(timestamp, '%Y%m%d')) - PROPERTIES - ( - "desired_concurrent_number"="3", - "max_batch_interval" = "20", - "max_batch_rows" = "300000", - "max_batch_size" = "209715200", - "strict_mode" = "false", - "format" = "json", - "jsonpaths" = "[\"$.category\",\"$.author\",\"$.price\",\"$.timestamp\"]", - "json_root" = "$.RECORDS" - "strip_outer_array" = "true" - ) - FROM KAFKA - ( - "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", - "kafka_topic" = "my_topic", - "kafka_partitions" = "0,1,2", - "kafka_offsets" = "0,0,0" - ); - ``` - -7. Create a Kafka routine import task named test1 for example_tbl of example_db. And use conditional filtering. - - - - ```sql - CREATE ROUTINE LOAD example_db.test1 ON example_tbl - WITH MERGE - COLUMNS(k1, k2, k3, v1, v2, v3), - WHERE k1 > 100 and k2 like "%doris%", - DELETE ON v3 >100 - PROPERTIES - ( - "desired_concurrent_number"="3", - "max_batch_interval" = "20", - "max_batch_rows" = "300000", - "max_batch_size" = "209715200", - "strict_mode" = "false" - ) - FROM KAFKA - ( - "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", - "kafka_topic" = "my_topic", - "kafka_partitions" = "0,1,2,3", - "kafka_offsets" = "101,0,0,200" - ); - ``` - -8. Import data to Unique with sequence column Key model table - - - - ```sql - CREATE ROUTINE LOAD example_db.test_job ON example_tbl - COLUMNS TERMINATED BY ",", - COLUMNS(k1,k2,source_sequence,v1,v2), - ORDER BY source_sequence - PROPERTIES - ( - "desired_concurrent_number"="3", - "max_batch_interval" = "30", - "max_batch_rows" = "300000", - "max_batch_size" = "209715200" - ) FROM KAFKA - ( - "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", - "kafka_topic" = "my_topic", - "kafka_partitions" = "0,1,2,3", - "kafka_offsets" = "101,0,0,200" - ); - ``` - -9. Consume from a specified point in time - - - - ```sql - CREATE ROUTINE LOAD example_db.test_job ON example_tbl - PROPERTIES - ( - "desired_concurrent_number"="3", - "max_batch_interval" = "30", - "max_batch_rows" = "300000", - "max_batch_size" = "209715200" - ) FROM KAFKA - ( - "kafka_broker_list" = "broker1:9092,broker2:9092", - "kafka_topic" = "my_topic", - "kafka_default_offsets" = "2021-05-21 10:00:00" - ); - ``` - -### Keywords - - CREATE, ROUTINE, LOAD, CREATE LOAD - -### Best Practice - -Partition and Offset for specified consumption - -Doris supports the specified Partition and Offset to start consumption, and also supports the function of consumption at a specified time point. The configuration relationship of the corresponding parameters is described here. - -There are three relevant parameters: - -- `kafka_partitions`: Specify a list of partitions to be consumed, such as "0, 1, 2, 3". -- `kafka_offsets`: Specify the starting offset of each partition, which must correspond to the number of `kafka_partitions` list. For example: "1000, 1000, 2000, 2000" -- `property.kafka_default_offsets`: Specifies the default starting offset of the partition. - -When creating an import job, these three parameters can have the following combinations: - -| Composition | `kafka_partitions` | `kafka_offsets` | `property.kafka_default_offsets` | Behavior | -| ----------- | ------------------ | --------------- | ------------------------------- | ------------------------------------------------------------ | -| 1 | No | No | No | The system will automatically find all partitions corresponding to the topic and start consumption from OFFSET_END | -| 2 | No | No | Yes | The system will automatically find all partitions corresponding to the topic and start consumption from the location specified by default offset | -| 3 | Yes | No | No | The system will start consumption from OFFSET_END of the specified partition | -| 4 | Yes | Yes | No | The system will start consumption from the specified offset of the specified partition | -| 5 | Yes | No | Yes | The system will start consumption from the specified partition, the location specified by default offset | diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CREATE-SYNC-JOB.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CREATE-SYNC-JOB.md deleted file mode 100644 index 45d41a26befe1..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CREATE-SYNC-JOB.md +++ /dev/null @@ -1,161 +0,0 @@ ---- -{ - "title": "CREATE-SYNC-JOB", - "language": "en" -} ---- - - - -## CREATE-SYNC-JOB - -### Name - -CREATE SYNC JOB - -### Description - -The data synchronization (Sync Job) function supports users to submit a resident data synchronization job, and incrementally synchronizes the CDC (Change Data Capture) of the user's data update operation in the Mysql database by reading the Binlog log from the specified remote address. Features. - -Currently, the data synchronization job only supports connecting to Canal, obtaining the parsed Binlog data from the Canal Server and importing it into Doris. - -Users can view the data synchronization job status through [SHOW SYNC JOB](../../Show-Statements/SHOW-SYNC-JOB.md). - -grammar: - -```sql -CREATE SYNC [db.]job_name - ( - channel_desc, - channel_desc - ... - ) -binlog_desc -``` - -1. `job_name` - - The synchronization job name is the unique identifier of the job in the current database. Only one job with the same `job_name` can be running. - -2. `channel_desc` - - The data channel under the job is used to describe the mapping relationship between the mysql source table and the doris target table. - - grammar: - - ```sql - FROM mysql_db.src_tbl INTO des_tbl - [columns_mapping] - ``` - - 1. `mysql_db.src_tbl` - - Specify the database and source table on the mysql side. - - 2. `des_tbl` - - Specify the target table on the doris side. Only unique tables are supported, and the batch delete function of the table needs to be enabled (see the 'batch delete function' of help alter table for how to enable it). - - 4. `column_mapping` - - Specifies the mapping relationship between the columns of the mysql source table and the doris target table. If not specified, FE will default the columns of the source table and the target table to one-to-one correspondence in order. - - The form col_name = expr is not supported for columns. - - Example: - - ``` - Suppose the target table column is (k1, k2, v1), - - Change the order of columns k1 and k2 - (k2, k1, v1) - - Ignore the fourth column of the source data - (k2, k1, v1, dummy_column) - ``` - -3. `binlog_desc` - - Used to describe the remote data source, currently only one canal is supported. - - grammar: - - ```sql - FROM BINLOG - ( - "key1" = "value1", - "key2" = "value2" - ) - ``` - - 1. The properties corresponding to the Canal data source, prefixed with `canal.` - - 1. canal.server.ip: address of canal server - 2. canal.server.port: the port of the canal server - 3. canal.destination: the identity of the instance - 4. canal.batchSize: The maximum batch size obtained, the default is 8192 - 5. canal.username: username of instance - 6. canal.password: the password of the instance - 7. canal.debug: optional, when set to true, the batch and details of each row of data will be printed out - -### Example - -1. Simply create a data synchronization job named `job1` for `test_tbl` of `test_db`, connect to the local Canal server, corresponding to the Mysql source table `mysql_db1.tbl1`. - - ```SQL - CREATE SYNC `test_db`.`job1` - ( - FROM `mysql_db1`.`tbl1` INTO `test_tbl` - ) - FROM BINLOG - ( - "type" = "canal", - "canal.server.ip" = "127.0.0.1", - "canal.server.port" = "11111", - "canal.destination" = "example", - "canal.username" = "", - "canal.password" = "" - ); - ``` - -2. Create a data synchronization job named `job1` for multiple tables of `test_db`, corresponding to multiple Mysql source tables one-to-one, and explicitly specify the column mapping. - - ```SQL - CREATE SYNC `test_db`.`job1` - ( - FROM `mysql_db`.`t1` INTO `test1` (k1, k2, v1) , - FROM `mysql_db`.`t2` INTO `test2` (k3, k4, v2) - ) - FROM BINLOG - ( - "type" = "canal", - "canal.server.ip" = "xx.xxx.xxx.xx", - "canal.server.port" = "12111", - "canal.destination" = "example", - "canal.username" = "username", - "canal.password" = "password" - ); - ``` - -### Keywords - - CREATE, SYNC, JOB - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/MULTI-LOAD.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/MULTI-LOAD.md deleted file mode 100644 index bfb4a9ca3e27f..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/MULTI-LOAD.md +++ /dev/null @@ -1,123 +0,0 @@ ---- -{ - "title": "MULTI-LOAD", - "language": "en" -} ---- - - - -## MULTI-LOAD - -### Name - -MULTI LOAD - -### Description - -Users submit multiple import jobs through the HTTP protocol. Multi Load can ensure the atomic effect of multiple import jobs - -``` -Syntax: - curl --location-trusted -u user:passwd -XPOST http://host:port/api/{db}/_multi_start?label=xxx - curl --location-trusted -u user:passwd -T data.file http://host:port/api/{db}/{table1}/_load?label=xxx\&sub_label=yyy - curl --location-trusted -u user:passwd -T data.file http://host:port/api/{db}/{table2}/_load?label=xxx\&sub_label=zzz - curl --location-trusted -u user:passwd -XPOST http://host:port/api/{db}/_multi_commit?label=xxx - curl --location-trusted -u user:passwd -XPOST http://host:port/api/{db}/_multi_desc?label=xxx - -On the basis of 'MINI LOAD', 'MULTI LOAD' can support users to import to multiple tables at the same time. The specific commands are shown above. -'/api/{db}/_multi_start' starts a multi-table import task -'/api/{db}/{table}/_load' adds a table to be imported to an import task. The main difference from 'MINI LOAD' is that the 'sub_label' parameter needs to be passed in -'/api/{db}/_multi_commit' submits the entire multi-table import task, and starts processing in the background -'/api/{db}/_multi_abort' Abort a multi-table import task -'/api/{db}/_multi_desc' can display the number of jobs submitted by a multi-table import task - -Description of the HTTP protocol - Authorization Authentication Currently, Doris uses HTTP Basic authorization authentication. So you need to specify the username and password when importing - This method is to pass the password in clear text, since we are currently in an intranet environment. . . - - Expect Doris needs to send the http request, it needs to have 'Expect' header information, the content is '100-continue' - why? Because we need to redirect the request, before transmitting the data content, - This can avoid causing multiple transmissions of data, thereby improving efficiency. - - Content-Length Doris needs to send the request with the 'Content-Length' header. If the content sent is greater than - If the 'Content-Length' is less, then Palo thinks that there is a problem with the transmission, and fails to submit the task. - NOTE: If more data is sent than 'Content-Length', then Doris only reads 'Content-Length' - length content and import - -Parameter Description: - user: If the user is in the default_cluster, the user is the user_name. Otherwise user_name@cluster_name. - - label: Used to specify the label number imported in this batch, which is used for later job status query, etc. - This parameter is required. - - sub_label: Used to specify the subversion number inside a multi-table import task. For loads imported from multiple tables, this parameter must be passed in. - - columns: used to describe the corresponding column names in the import file. - If it is not passed in, then the order of the columns in the file is considered to be the same as the order in which the table was created. - The specified method is comma-separated, for example: columns=k1,k2,k3,k4 - - column_separator: used to specify the separator between columns, the default is '\t' - NOTE: url encoding is required, for example, '\t' needs to be specified as the delimiter, - Then you should pass in 'column_separator=%09' - - max_filter_ratio: used to specify the maximum ratio of non-standard data allowed to filter, the default is 0, no filtering is allowed - The custom specification should be as follows: 'max_filter_ratio=0.2', which means 20% error rate is allowed - Passing in has effect when '_multi_start' - -NOTE: - 1. This import method currently completes the import work on one machine, so it is not suitable for import work with a large amount of data. - It is recommended that the amount of imported data should not exceed 1GB - - 2. Currently it is not possible to submit multiple files using `curl -T "{file1, file2}"`, because curl splits them into multiple files - The request is sent. Multiple requests cannot share a label number, so it cannot be used. - - 3. Supports the use of curl to import data into Doris in a way similar to streaming, but only after the streaming ends Doris - The real import behavior will occur, and the amount of data in this way cannot be too large. -``` - -### Example - -``` -1. Import the data in the local file 'testData1' into the table 'testTbl1' in the database 'testDb', and -Import the data of 'testData2' into table 'testTbl2' in 'testDb' (user is in defalut_cluster) - curl --location-trusted -u root -XPOST http://host:port/api/testDb/_multi_start?label=123 - curl --location-trusted -u root -T testData1 http://host:port/api/testDb/testTbl1/_load?label=123\&sub_label=1 - curl --location-trusted -u root -T testData2 http://host:port/api/testDb/testTbl2/_load?label=123\&sub_label=2 - curl --location-trusted -u root -XPOST http://host:port/api/testDb/_multi_commit?label=123 - -2. Abandoned in the middle of multi-table import (user is in defalut_cluster) - curl --location-trusted -u root -XPOST http://host:port/api/testDb/_multi_start?label=123 - curl --location-trusted -u root -T testData1 http://host:port/api/testDb/testTbl1/_load?label=123\&sub_label=1 - curl --location-trusted -u root -XPOST http://host:port/api/testDb/_multi_abort?label=123 - -3. Multi-table import to see how much content has been submitted (the user is in the defalut_cluster) - curl --location-trusted -u root -XPOST http://host:port/api/testDb/_multi_start?label=123 - curl --location-trusted -u root -T testData1 http://host:port/api/testDb/testTbl1/_load?label=123\&sub_label=1 - curl --location-trusted -u root -XPOST http://host:port/api/testDb/_multi_desc?label=123 -``` - -### Keywords - -``` -MULTI, MINI, LOAD -``` - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/MYSQL-LOAD.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/MYSQL-LOAD.md deleted file mode 100644 index 18f46f61ffa9f..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/MYSQL-LOAD.md +++ /dev/null @@ -1,173 +0,0 @@ ---- -{ - "title": "MYSQL-LOAD", - "language": "en" -} ---- - - - -## MYSQL-LOAD - -### Name - - MYSQL LOAD - -### Description - -mysql-load: Import local data using the MySql client - -``` -LOAD DATA -[LOCAL] -INFILE 'file_name' -INTO TABLE tbl_name -[PARTITION (partition_name [, partition_name] ...)] -[COLUMNS TERMINATED BY 'string'] -[LINES TERMINATED BY 'string'] -[IGNORE number {LINES | ROWS}] -[(col_name_or_user_var [, col_name_or_user_var] ...)] -[SET (col_name={expr | DEFAULT} [, col_name={expr | DEFAULT}] ...)] -[PROPERTIES (key1 = value1 [, key2=value2]) ] -``` - -This statement is used to import data to the specified table. Unlike normal Load, this import method is a synchronous import. - -This import method can still guarantee the atomicity of a batch of import tasks, either all data imports are successful or all fail. - -1. MySQL Load starts with the syntax `LOAD DATA`, without specifying `LABEL` -2. Specify `LOCAL` to read client side files. Not specified to read FE server side local files. Server side load was disabled by default. It can be enabled by setting a secure path in FE configuration `mysql_load_server_secure_path` -3. The local fill path will be filled after `INFILE`, which can be a relative path or an absolute path. Currently only a single file is supported, and multiple files are not supported -4. The table name after `INTO TABLE` can specify the database name, as shown in the case. It can also be omitted, and the database where the current user is located will be used. -5. `PARTITION` syntax supports specified partition to import -6. `COLUMNS TERMINATED BY` specifies the column separator -7. `LINES TERMINATED BY` specifies the line separator -8. `IGNORE num LINES` The user skips the header of the CSV and can skip any number of lines. This syntax can also be replaced by'IGNORE num ROWS ' -9. Column mapping syntax, please refer to the column mapping chapter of [Imported Data Transformation](../../../../data-operate/import/import-way/mysql-load-manual.md) -10. `PROPERTIES` parameter configuration, see below for details - -### PROPERTIES - -1. max_filter_ratio: The maximum tolerable data ratio that can be filtered (for reasons such as data irregularity). Zero tolerance by default. Data irregularities do not include rows filtered out by where conditions. - -2. timeout: Specify the import timeout. in seconds. The default is 600 seconds. The setting range is from 1 second to 259200 seconds. - -3. strict_mode: The user specifies whether to enable strict mode for this import. The default is off. - -4. timezone: Specify the time zone used for this import. The default is Dongba District. This parameter affects the results of all time zone-related functions involved in the import. - -5. exec_mem_limit: Load memory limit. Default is 2GB. The unit is bytes. - -6. trim_double_quotes: Boolean type, The default value is false. True means that the outermost double quotes of each field in the load file are trimmed. - -7. enclose: When the csv data field contains row delimiters or column delimiters, to prevent accidental truncation, single-byte characters can be specified as brackets for protection. For example, the column separator is ",", the bracket is "'", and the data is "a,'b,c'", then "b,c" will be parsed as a field. Note: when the bracket is `"`, trim\_double\_quotes must be set to true. - -8. escape: Used to escape characters that appear in a csv field identical to the enclosing characters. For example, if the data is "a,'b,'c'", enclose is "'", and you want "b,'c to be parsed as a field, you need to specify a single-byte escape character, such as "\", and then modify the data to "a,' b,\'c'". - -### Example - -1. Import the data from the client side local file `testData` into the table `testTbl` in the database `testDb`. Specify a timeout of 100 seconds - - ```sql - LOAD DATA LOCAL - INFILE 'testData' - INTO TABLE testDb.testTbl - PROPERTIES ("timeout"="100") - ``` - -2. Import the data from the server side local file `/root/testData` (set FE config `mysql_load_server_secure_path` to be `root` already) into the table `testTbl` in the database `testDb`. Specify a timeout of 100 seconds - - ```sql - LOAD DATA - INFILE '/root/testData' - INTO TABLE testDb.testTbl - PROPERTIES ("timeout"="100") - ``` - -3. Import data from client side local file `testData` into table `testTbl` in database `testDb`, allowing 20% error rate - - ```sql - LOAD DATA LOCAL - INFILE 'testData' - INTO TABLE testDb.testTbl - PROPERTIES ("max_filter_ratio"="0.2") - ``` - -4. Import the data from the client side local file `testData` into the table `testTbl` in the database `testDb`, allowing a 20% error rate and specifying the column names of the file - - ```sql - LOAD DATA LOCAL - INFILE 'testData' - INTO TABLE testDb.testTbl - (k2, k1, v1) - PROPERTIES ("max_filter_ratio"="0.2") - ``` - -5. Import the data in the local file `testData` into the p1, p2 partitions in the table of `testTbl` in the database `testDb`, allowing a 20% error rate. - - ```sql - LOAD DATA LOCAL - INFILE 'testData' - INTO TABLE testDb.testTbl - PARTITION (p1, p2) - PROPERTIES ("max_filter_ratio"="0.2") - ``` - -6. Import the data in the CSV file `testData` with a local row delimiter of `0102` and a column delimiter of `0304` into the table `testTbl` in the database `testDb`. - - ```sql - LOAD DATA LOCAL - INFILE 'testData' - INTO TABLE testDb.testTbl - COLUMNS TERMINATED BY '0304' - LINES TERMINATED BY '0102' - ``` - -7. Import the data from the local file `testData` into the p1, p2 partitions in the table of `testTbl` in the database `testDb` and skip the first 3 lines. - - ```sql - LOAD DATA LOCAL - INFILE 'testData' - INTO TABLE testDb.testTbl - PARTITION (p1, p2) - IGNORE 1 LINES - ``` - -8. Import data for strict schema filtering and set the time zone to Africa/Abidjan - - ```sql - LOAD DATA LOCAL - INFILE 'testData' - INTO TABLE testDb.testTbl - PROPERTIES ("strict_mode"="true", "timezone"="Africa/Abidjan") - ``` - -9. Import data is limited to 10GB of load memory and timed out in 10 minutes - - ```sql - LOAD DATA LOCAL - INFILE 'testData' - INTO TABLE testDb.testTbl - PROPERTIES ("exec_mem_limit"="10737418240", "timeout"="600") - ``` - -### Keywords - - MYSQL, LOAD diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/PAUSE-ROUTINE-LOAD.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/PAUSE-ROUTINE-LOAD.md deleted file mode 100644 index 07adc2179fecd..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/PAUSE-ROUTINE-LOAD.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -{ - "title": "PAUSE-ROUTINE-LOAD", - "language": "en" -} ---- - - - -## PAUSE-ROUTINE-LOAD - -### Name - -PAUSE ROUTINE LOAD - -### Description - -Used to pause a Routine Load job. A suspended job can be rerun with the RESUME command. - -```sql -PAUSE [ALL] ROUTINE LOAD FOR job_name -``` - -### Example - -1. Pause the routine import job named test1. - - ```sql - PAUSE ROUTINE LOAD FOR test1; - ``` - -2. Pause all routine import jobs. - - ```sql - PAUSE ALL ROUTINE LOAD; - ``` - -### Keywords - - PAUSE, ROUTINE, LOAD - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/PAUSE-SYNC-JOB.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/PAUSE-SYNC-JOB.md deleted file mode 100644 index c2f6b125b9355..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/PAUSE-SYNC-JOB.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "PAUSE-SYNC-JOB", - "language": "en" -} ---- - - - -## PAUSE-SYNC-JOB - -### Name - -PAUSE SYNC JOB - -### Description - -Pause a running resident data synchronization job in a database via `job_name`. The suspended job will stop synchronizing data and keep the latest position of consumption until it is resumed by the user. - -grammar: - -```sql -PAUSE SYNC JOB [db.]job_name -``` - -### Example - -1. Pause the data sync job named `job_name`. - - ```sql - PAUSE SYNC JOB `job_name`; - ``` - -### Keywords - - PAUSE, SYNC, JOB - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/RESUME-ROUTINE-LOAD.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/RESUME-ROUTINE-LOAD.md deleted file mode 100644 index a3f40515a740d..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/RESUME-ROUTINE-LOAD.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -{ - "title": "RESUME-ROUTINE-LOAD", - "language": "en" -} ---- - - - -## RESUME-ROUTINE-LOAD - -### Name - -RESUME ROUTINE LOAD - -### Description - -Used to restart a suspended Routine Load job. The restarted job will continue to consume from the previously consumed offset. - -```sql -RESUME [ALL] ROUTINE LOAD FOR job_name -``` - -### Example - -1. Restart the routine import job named test1. - - ```sql - RESUME ROUTINE LOAD FOR test1; - ``` - -2. Restart all routine import jobs. - - ```sql - RESUME ALL ROUTINE LOAD; - ``` - -### Keywords - - RESUME, ROUTINE, LOAD - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/RESUME-SYNC-JOB.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/RESUME-SYNC-JOB.md deleted file mode 100644 index a2cd1d62a076e..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/RESUME-SYNC-JOB.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "RESUME-SYNC-JOB", - "language": "en" -} ---- - - - -## RESUME-SYNC-JOB - -### Name - -RESUME SYNC JOB - -### Description - -Resume a resident data synchronization job whose current database has been suspended by `job_name`, and the job will continue to synchronize data from the latest position before the last suspension. - -grammar: - -```sql -RESUME SYNC JOB [db.]job_name -``` - -### Example - -1. Resume the data synchronization job named `job_name` - - ```sql - RESUME SYNC JOB `job_name`; - ``` - -### Keywords - - RESUME, SYNC, LOAD - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/STOP-ROUTINE-LOAD.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/STOP-ROUTINE-LOAD.md deleted file mode 100644 index cf91652459b25..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/STOP-ROUTINE-LOAD.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -{ - "title": "STOP-ROUTINE-LOAD", - "language": "en" -} ---- - - - -## STOP-ROUTINE-LOAD - -### Name - -STOP ROUTINE LOAD - -### Description - -User stops a Routine Load job. A stopped job cannot be rerun. - -```sql -STOP ROUTINE LOAD FOR job_name; -``` - -### Example - -1. Stop the routine import job named test1. - - ```sql - STOP ROUTINE LOAD FOR test1; - ``` - -### Keywords - - STOP, ROUTINE, LOAD - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/STOP-SYNC-JOB.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/STOP-SYNC-JOB.md deleted file mode 100644 index 358b5f01ac58d..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/STOP-SYNC-JOB.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "STOP-SYNC-JOB", - "language": "en" -} ---- - - - -## STOP-SYNC-JOB - -### Name - -STOP SYNC JOB - -### Description - -Stop a non-stop resident data synchronization job in a database by `job_name`. - -grammar: - -```sql -STOP SYNC JOB [db.]job_name -``` - -### Example - -1. Stop the data sync job named `job_name` - - ```sql - STOP SYNC JOB `job_name`; - ``` - -### Keywords - - STOP, SYNC, JOB - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/STREAM-LOAD.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/STREAM-LOAD.md deleted file mode 100644 index 268a6237b9692..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Load/STREAM-LOAD.md +++ /dev/null @@ -1,476 +0,0 @@ ---- -{ - "title": "STREAM-LOAD", - "language": "en" -} ---- - - - -## STREAM-LOAD - -### Name - -STREAM LOAD - -### Description - -stream-load: load data to table in streaming - -``` -curl --location-trusted -u user:passwd [-H ""...] -T data.file -XPUT http://fe_host:http_port/api/{db}/{table}/_stream_load -``` - -This statement is used to import data into the specified table. The difference from ordinary Load is that this import method is synchronous import. - - This import method can still ensure the atomicity of a batch of import tasks, either all data is imported successfully or all of them fail. - - This operation will update the data of the rollup table related to this base table at the same time. - - This is a synchronous operation. After the entire data import work is completed, the import result is returned to the user. - - Currently, HTTP chunked and non-chunked uploads are supported. For non-chunked methods, Content-Length must be used to indicate the length of the uploaded content, which can ensure the integrity of the data. - -In addition, it is best for users to set the content of the Expect Header field to 100-continue, which can avoid unnecessary data transmission in some error scenarios. - -Parameter introduction: - Users can pass in import parameters through the Header part of HTTP - -1. label: The label imported once, the data of the same label cannot be imported multiple times. Users can avoid the problem of duplicate data import by specifying Label. - - Currently, Doris retains the most recent successful label within 30 minutes. - -2. column_separator: used to specify the column separator in the import file, the default is \t. If it is an invisible character, you need to add \x as a prefix and use hexadecimal to represent the separator. - - For example, the separator \x01 of the hive file needs to be specified as -H "column_separator:\x01". - - You can use a combination of multiple characters as column separators. - -3. line_delimiter: used to specify the newline character in the imported file, the default is \n. Combinations of multiple characters can be used as newlines. - -4. columns: used to specify the correspondence between the columns in the import file and the columns in the table. If the column in the source file corresponds exactly to the content in the table, then there is no need to specify the content of this field. - - If the source file does not correspond to the table schema, then this field is required for some data conversion. There are two forms of column, one is directly corresponding to the field in the imported file, which is directly represented by the field name; - - One is derived column, the syntax is `column_name` = expression. Give a few examples to help understand. - - Example 1: There are 3 columns "c1, c2, c3" in the table, and the three columns in the source file correspond to "c3, c2, c1" at a time; then you need to specify -H "columns: c3, c2, c1 " - - Example 2: There are 3 columns "c1, c2, c3" in the table, the first three columns in the source file correspond in turn, but there is more than 1 column; then you need to specify -H "columns: c1, c2, c3, xxx"; - - The last column can be arbitrarily assigned a name and placeholder - - Example 3: There are three columns "year, month, day" in the table, and there is only one time column in the source file, which is in "2018-06-01 01:02:03" format; - - Then you can specify -H "columns: col, year = year(col), month=month(col), day=day(col)" to complete the import - -5. where: used to extract part of the data. If the user needs to filter out the unnecessary data, he can achieve this by setting this option. - - Example 1: Only import data greater than k1 column equal to 20180601, then you can specify -H "where: k1 = 20180601" when importing - -6. max_filter_ratio: The maximum tolerable data ratio that can be filtered (for reasons such as data irregularity). Zero tolerance by default. Data irregularities do not include rows filtered out by where conditions. - -7. partitions: used to specify the partition designed for this import. If the user can determine the partition corresponding to the data, it is recommended to specify this item. Data that does not satisfy these partitions will be filtered out. - - For example, specify import to p1, p2 partition, -H "partitions: p1, p2" - -8. timeout: Specify the import timeout. in seconds. The default is 600 seconds. The setting range is from 1 second to 259200 seconds. - -9. strict_mode: The user specifies whether to enable strict mode for this import. The default is off. The enable mode is -H "strict_mode: true". - -10. timezone: Specifies the timezone used for this import. The default is "+08:00". This variable replaces the session variable `time_zone` in this import transaction. See the section "Importing with timezones" in [Best Practice](#best-practice) for more information. - -11. exec_mem_limit: Load memory limit. Default is 2GB. The unit is bytes. - -12. format: Specify load data format, support csv, json, csv_with_names(support csv file line header filter), csv_with_names_and_types(support csv file first two lines filter), parquet, orc, default is csv. - -13. jsonpaths: The way of importing json is divided into: simple mode and matching mode. - - Simple mode: The simple mode is not set the jsonpaths parameter. In this mode, the json data is required to be an object type, for example: - - ``` - {"k1":1, "k2":2, "k3":"hello"}, where k1, k2, k3 are column names. - ``` - - Matching mode: It is relatively complex for json data and needs to match the corresponding value through the jsonpaths parameter. - -14. strip_outer_array: Boolean type, true indicates that the json data starts with an array object and flattens the array object, the default value is false. E.g: - - ``` - [ - {"k1" : 1, "v1" : 2}, - {"k1" : 3, "v1" : 4} - ] - ``` - When strip_outer_array is true, the final import into doris will generate two rows of data. - - -15. json_root: json_root is a valid jsonpath string, used to specify the root node of the json document, the default value is "". - -16. merge_type: The merge type of data, which supports three types: APPEND, DELETE, and MERGE. Among them, APPEND is the default value, which means that this batch of data needs to be appended to the existing data, and DELETE means to delete all the data with the same key as this batch of data. Line, the MERGE semantics need to be used in conjunction with the delete condition, which means that the data that meets the delete condition is processed according to the DELETE semantics and the rest is processed according to the APPEND semantics, for example: `-H "merge_type: MERGE" -H "delete: flag=1"` - -17. delete: Only meaningful under MERGE, indicating the deletion condition of the data - -18. function_column.sequence_col: Only applicable to UNIQUE_KEYS. Under the same key column, ensure that the value column is REPLACEed according to the source_sequence column. The source_sequence can be a column in the data source or a column in the table structure. - -19. fuzzy_parse: Boolean type, true means that json will be parsed with the schema of the first row. Enabling this option can improve the efficiency of json import, but requires that the order of the keys of all json objects is the same as the first row, the default is false, only use in json format - -20. num_as_string: Boolean type, true means that when parsing json data, the numeric type will be converted to a string, and then imported without losing precision. - -21. read_json_by_line: Boolean type, true to support reading one json object per line, the default value is false. - -22. send_batch_parallelism: Integer, used to set the parallelism of sending batch data. If the value of parallelism exceeds `max_send_batch_parallelism_per_job` in the BE configuration, the BE as a coordination point will use the value of `max_send_batch_parallelism_per_job`. - -23. hidden_columns: Specify hidden column when no `columns` in Headers, multi hidden column shoud be -separated by commas. - - ``` - hidden_columns: __DORIS_DELETE_SIGN__,__DORIS_SEQUENCE_COL__ - The system will use the order specified by user. in case above, data should be ended - with __DORIS_SEQUENCE_COL__. - ``` -24. load_to_single_tablet: Boolean type, True means that one task can only load data to one tablet in the corresponding partition at a time. The default value is false. This parameter can only be set when loading data into the OLAP table with random bucketing. - -25. compress_type: Specify compress type file. Only support compressed csv file now. Support gz, lzo, bz2, lz4, lzop, deflate. - -26. trim_double_quotes: Boolean type, The default value is false. True means that the outermost double quotes of each field in the csv file are trimmed. - -27. skip_lines: Integer type, the default value is 0. It will skip some lines in the head of csv file. It will be disabled when format is `csv_with_names` or `csv_with_names_and_types`. - -28. comment: String type, the default value is "". - -29. enclose: When the csv data field contains row delimiters or column delimiters, to prevent accidental truncation, single-byte characters can be specified as brackets for protection. For example, the column separator is ",", the bracket is "'", and the data is "a,'b,c'", then "b,c" will be parsed as a field. Note: when the bracket is `"`, trim\_double\_quotes must be set to true. - -30. escape: Used to escape characters that appear in a csv field identical to the enclosing characters. For example, if the data is "a,'b,'c'", enclose is "'", and you want "b,'c to be parsed as a field, you need to specify a single-byte escape character, such as "\", and then modify the data to "a,' b,\'c'". - -### Example - -1. Import the data in the local file 'testData' into the table 'testTbl' in the database 'testDb', and use Label for deduplication. Specify a timeout of 100 seconds - - ``` - curl --location-trusted -u root -H "label:123" -H "timeout:100" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - -2. Import the data in the local file 'testData' into the table 'testTbl' in the database 'testDb', use Label for deduplication, and only import data whose k1 is equal to 20180601 - - ``` - curl --location-trusted -u root -H "label:123" -H "where: k1=20180601" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - -3. Import the data in the local file 'testData' into the table 'testTbl' in the database 'testDb', allowing a 20% error rate (the user is in the defalut_cluster) - - ``` - curl --location-trusted -u root -H "label:123" -H "max_filter_ratio:0.2" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - -4. Import the data in the local file 'testData' into the table 'testTbl' in the database 'testDb', allow a 20% error rate, and specify the column name of the file (the user is in the defalut_cluster) - - ``` - curl --location-trusted -u root -H "label:123" -H "max_filter_ratio:0.2" -H "columns: k2, k1, v1" -T testData http://host:port/api/testDb/testTbl /_stream_load - ``` - -5. Import the data in the local file 'testData' into the p1, p2 partitions of the table 'testTbl' in the database 'testDb', allowing a 20% error rate. - - ``` - curl --location-trusted -u root -H "label:123" -H "max_filter_ratio:0.2" -H "partitions: p1, p2" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - -6. Import using streaming (user is in defalut_cluster) - - ``` - seq 1 10 | awk '{OFS="\t"}{print $1, $1 * 10}' | curl --location-trusted -u root -T - http://host:port/api/testDb/testTbl/ _stream_load - ``` - -7. Import a table containing HLL columns, which can be columns in the table or columns in the data to generate HLL columns, or use hll_empty to supplement columns that are not in the data - - ``` - curl --location-trusted -u root -H "columns: k1, k2, v1=hll_hash(k1), v2=hll_empty()" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - -8. Import data for strict mode filtering and set the time zone to Africa/Abidjan - - ``` - curl --location-trusted -u root -H "strict_mode: true" -H "timezone: Africa/Abidjan" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - -9. Import a table with a BITMAP column, which can be a column in the table or a column in the data to generate a BITMAP column, or use bitmap_empty to fill an empty Bitmap - ``` - curl --location-trusted -u root -H "columns: k1, k2, v1=to_bitmap(k1), v2=bitmap_empty()" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - -10. Simple mode, import json data - Table Structure: - ``` - `category` varchar(512) NULL COMMENT "", - `author` varchar(512) NULL COMMENT "", - `title` varchar(512) NULL COMMENT "", - `price` double NULL COMMENT "" - ``` - json data format: - ``` - {"category":"C++","author":"avc","title":"C++ primer","price":895} - ``` - - Import command: - - ``` - curl --location-trusted -u root -H "label:123" -H "format: json" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - - In order to improve throughput, it supports importing multiple pieces of json data at one time, each line is a json object, and \n is used as a newline by default. You need to set read_json_by_line to true. The json data format is as follows: - - ``` - {"category":"C++","author":"avc","title":"C++ primer","price":89.5} - {"category":"Java","author":"avc","title":"Effective Java","price":95} - {"category":"Linux","author":"avc","title":"Linux kernel","price":195} - ``` - -11. Match pattern, import json data - json data format: - - ``` - [ - {"category":"xuxb111","author":"1avc","title":"SayingsoftheCentury","price":895},{"category":"xuxb222","author":"2avc"," title":"SayingsoftheCentury","price":895}, - {"category":"xuxb333","author":"3avc","title":"SayingsoftheCentury","price":895} - ] - ``` - - Precise import by specifying jsonpath, such as importing only three attributes of category, author, and price - - ``` - curl --location-trusted -u root -H "columns: category, price, author" -H "label:123" -H "format: json" -H "jsonpaths: [\"$.category\",\" $.price\",\"$.author\"]" -H "strip_outer_array: true" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - - illustrate: - 1) If the json data starts with an array, and each object in the array is a record, you need to set strip_outer_array to true, which means flatten the array. - 2) If the json data starts with an array, and each object in the array is a record, when setting jsonpath, our ROOT node is actually an object in the array. - -12. User specified json root node - json data format: - - ``` - { - "RECORDS":[ - {"category":"11","title":"SayingsoftheCentury","price":895,"timestamp":1589191587}, - {"category":"22","author":"2avc","price":895,"timestamp":1589191487}, - {"category":"33","author":"3avc","title":"SayingsoftheCentury","timestamp":1589191387} - ] - } - ``` - - Precise import by specifying jsonpath, such as importing only three attributes of category, author, and price - - ``` - curl --location-trusted -u root -H "columns: category, price, author" -H "label:123" -H "format: json" -H "jsonpaths: [\"$.category\",\" $.price\",\"$.author\"]" -H "strip_outer_array: true" -H "json_root: $.RECORDS" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - -13. Delete the data with the same import key as this batch - - ``` - curl --location-trusted -u root -H "merge_type: DELETE" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - -14. Delete the columns in this batch of data that match the data whose flag is listed as true, and append other rows normally - - ``` - curl --location-trusted -u root: -H "column_separator:," -H "columns: siteid, citycode, username, pv, flag" -H "merge_type: MERGE" -H "delete: flag=1" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - -15. Import data into UNIQUE_KEYS table with sequence column - - ``` - curl --location-trusted -u root -H "columns: k1,k2,source_sequence,v1,v2" -H "function_column.sequence_col: source_sequence" -T testData http://host:port/api/testDb/testTbl/ _stream_load - ``` - -16. csv file line header filter import - - file data: - - ``` - id,name,age - 1,doris,20 - 2,flink,10 - ``` - Filter the first line import by specifying `format=csv_with_names` - ``` - curl --location-trusted -u root -T test.csv -H "label:1" -H "format:csv_with_names" -H "column_separator:," http://host:port/api/testDb/testTbl/_stream_load - ``` - -17. Import data into a table whose table field contains DEFAULT CURRENT_TIMESTAMP - - Table Structure: - - ```sql - `id` bigint(30) NOT NULL, - `order_code` varchar(30) DEFAULT NULL COMMENT '', - `create_time` datetimev2(3) DEFAULT CURRENT_TIMESTAMP - ``` - - JSON data format: - - ``` - {"id":1,"order_Code":"avc"} - ``` - - Import command: - - ``` - curl --location-trusted -u root -T test.json -H "label:1" -H "format:json" -H 'columns: id, order_code, create_time=CURRENT_TIMESTAMP()' http://host:port/api/testDb/testTbl/_stream_load - ``` - -### Keywords - - STREAM, LOAD - -### Best Practice - -1. Check the import task status - - Stream Load is a synchronous import process. The successful execution of the statement means that the data is imported successfully. The imported execution result will be returned synchronously through the HTTP return value. And display it in Json format. An example is as follows: - - ```json - { - "TxnId": 17, - "Label": "707717c0-271a-44c5-be0b-4e71bfeacaa5", - "Status": "Success", - "Message": "OK", - "NumberTotalRows": 5, - "NumberLoadedRows": 5, - "NumberFilteredRows": 0, - "NumberUnselectedRows": 0, - "LoadBytes": 28, - "LoadTimeMs": 27, - "BeginTxnTimeMs": 0, - "StreamLoadPutTimeMs": 2, - "ReadDataTimeMs": 0, - "WriteDataTimeMs": 3, - "CommitAndPublishTimeMs": 18 - } - ``` - - The following main explanations are given for the Stream load import result parameters: - - + TxnId: The imported transaction ID. Users do not perceive. - - + Label: Import Label. User specified or automatically generated by the system. - - + Status: Import completion status. - - "Success": Indicates successful import. - - "Publish Timeout": This state also indicates that the import has been completed, except that the data may be delayed and visible without retrying. - - "Label Already Exists": Label duplicate, need to be replaced Label. - - "Fail": Import failed. - - + ExistingJobStatus: The state of the load job corresponding to the existing Label. - - This field is displayed only when the status is "Label Already Exists". The user can know the status of the load job corresponding to Label through this state. "RUNNING" means that the job is still executing, and "FINISHED" means that the job is successful. - - + Message: Import error messages. - - + NumberTotalRows: Number of rows imported for total processing. - - + NumberLoadedRows: Number of rows successfully imported. - - + NumberFilteredRows: Number of rows that do not qualify for data quality. - - + NumberUnselectedRows: Number of rows filtered by where condition. - - + LoadBytes: Number of bytes imported. - - + LoadTimeMs: Import completion time. Unit milliseconds. - - + BeginTxnTimeMs: The time cost for RPC to Fe to begin a transaction, Unit milliseconds. - - + StreamLoadPutTimeMs: The time cost for RPC to Fe to get a stream load plan, Unit milliseconds. - - + ReadDataTimeMs: Read data time, Unit milliseconds. - - + WriteDataTimeMs: Write data time, Unit milliseconds. - - + CommitAndPublishTimeMs: The time cost for RPC to Fe to commit and publish a transaction, Unit milliseconds. - - + ErrorURL: If you have data quality problems, visit this URL to see specific error lines. - - > Note: Since Stream load is a synchronous import mode, import information will not be recorded in Doris system. Users cannot see Stream load asynchronously by looking at import commands. You need to listen for the return value of the create import request to get the import result. - -2. How to correctly submit the Stream Load job and process the returned results. - - Stream Load is a synchronous import operation, so the user needs to wait for the return result of the command synchronously, and decide the next processing method according to the return result. - - The user's primary concern is the `Status` field in the returned result. - - If it is `Success`, everything is fine and you can do other operations after that. - - If the returned result shows a large number of `Publish Timeout`, it may indicate that some resources (such as IO) of the cluster are currently under strain, and the imported data cannot take effect finally. The import task in the state of `Publish Timeout` has succeeded and does not need to be retried. However, it is recommended to slow down or stop the submission of new import tasks and observe the cluster load. - - If the returned result is `Fail`, the import failed, and you need to check the problem according to the specific reason. Once resolved, you can retry with the same Label. - - In some cases, the user's HTTP connection may be disconnected abnormally and the final returned result cannot be obtained. At this point, you can use the same Label to resubmit the import task, and the resubmitted task may have the following results: - - 1. `Status` status is `Success`, `Fail` or `Publish Timeout`. At this point, it can be processed according to the normal process. - 2. The `Status` status is `Label Already Exists`. At this time, you need to continue to view the `ExistingJobStatus` field. If the value of this field is `FINISHED`, it means that the import task corresponding to this Label has been successful, and there is no need to retry. If it is `RUNNING`, it means that the import task corresponding to this Label is still running. At this time, you need to use the same Label to continue to submit repeatedly at intervals (such as 10 seconds) until `Status` is not `Label Already Exists' `, or until the value of the `ExistingJobStatus` field is `FINISHED`. - -3. Cancel the import task - - Import tasks that have been submitted and not yet completed can be canceled with the CANCEL LOAD command. After cancellation, the written data will also be rolled back and will not take effect. - -4. Label, import transaction, multi-table atomicity - - All import tasks in Doris are atomic. And the import of multiple tables in the same import task can also guarantee atomicity. At the same time, Doris can also use the Label mechanism to ensure that the data imported is not lost or heavy. For details, see the [Import Transactions and Atomicity](../../../../data-operate/import/import-scenes/load-atomicity.md) documentation. - -5. Column mapping, derived columns and filtering - - Doris can support very rich column transformation and filtering operations in import statements. Most built-in functions and UDFs are supported. For how to use this function correctly, please refer to the [Column Mapping, Conversion and Filtering](../../../../data-operate/import/import-scenes/load-data-convert.md) document. - -6. Error data filtering - - Doris' import tasks can tolerate a portion of malformed data. The tolerance ratio is set via `max_filter_ratio`. The default is 0, which means that the entire import task will fail when there is an error data. If the user wants to ignore some problematic data rows, the secondary parameter can be set to a value between 0 and 1, and Doris will automatically skip the rows with incorrect data format. - - For some calculation methods of the tolerance rate, please refer to the [Column Mapping, Conversion and Filtering](../../../../data-operate/import/import-scenes/load-data-convert.md) document. - -7. Strict Mode - - The `strict_mode` attribute is used to set whether the import task runs in strict mode. The format affects the results of column mapping, transformation, and filtering, and it also controls the behavior of partial updates. For a detailed description of strict mode, see the [strict mode](../../../../data-operate/import/import-scenes/load-strict-mode.md) documentation. - -8. Timeout - - The default timeout for Stream Load is 10 minutes. from the time the task is submitted. If it does not complete within the timeout period, the task fails. - -9. Limits on data volume and number of tasks - - Stream Load is suitable for importing data within a few GB. Because the data is processed by single-threaded transmission, the performance of importing excessively large data cannot be guaranteed. When a large amount of local data needs to be imported, multiple import tasks can be submitted in parallel. - - Doris also limits the number of import tasks running at the same time in the cluster, usually ranging from 10-20. Import jobs submitted after that will be rejected. - -10. Importing with timezones - - Since Doris currently has no built-in time types for time zones, all `DATETIME` related types only represent absolute points in time, and do not contain time zone information, which does not change due to time zone changes in the Doris system. Therefore, for importing data with a time zone, we uniformly handle it as **converting it to data in a specific target time zone**. In the Doris system, this is the time zone represented by the session variable `time_zone`. - - In the import, on the other hand, our target timezone is specified by the parameter `timezone`, which will replace the session variable `time_zone` when timezone conversions occur, and when computing timezone-sensitive functions. Therefore, if there are no special circumstances, `timezone` should be set in the import transaction to match the `time_zone` of the current Doris cluster. This means that all time data with a time zone will be converted to that time zone. - For example, if the Doris system timezone is "+08:00", and the time column in the imported data contains two pieces of data, "2012-01-01 01:00:00Z" and "2015-12-12 12:12:12-08:00", then after we specify the timezone of the imported transaction via `-H "timezone: +08:00"` during import, both pieces of data will be converted to that timezone, resulting in the results "2012-01-01 09:00:00" and "2015-12-13 04:12:12". - - For a more detailed understanding, see [time-zone](../../../../advanced/time-zone) document. - -11. The Execution Engine Choice - - The Session Variable `enable_pipeline_load` determines whether to attempt to enable the Pipeline engine for Streamload tasks. See [Import](../../../../data-operate/import/load-manual) document for more. diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/ANALYZE.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/ANALYZE.md deleted file mode 100644 index 95a11c7d2a4d2..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/ANALYZE.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -{ - "title": "ANALYZE", - "language": "en" -} ---- - - - -## ANALYZE - -### Name - -ANALYZE - -### Description - -This statement is used to collect statistical information for various columns. - -```sql -ANALYZE < TABLE | DATABASE table_name | db_name > - [ (column_name [, ...]) ] - [ [ WITH SYNC ] [ WITH SAMPLE PERCENT | ROWS ] ]; -``` - -- `table_name`: The specified target table. It can be in the format `db_name.table_name`. -- `column_name`: The specified target column. It must be an existing column in `table_name`. You can specify multiple column names separated by commas. -- `sync`: Collect statistics synchronously. Returns after collection. If not specified, it executes asynchronously and returns a JOB ID. -- `sample percent | rows`: Collect statistics with sampling. You can specify a sampling percentage or a number of sampling rows. - -### Example - -Collect statistical data for a table with a 10% sampling rate: - -```sql -ANALYZE TABLE lineitem WITH SAMPLE PERCENT 10; -``` - -Collect statistical data for a table with a sample of 100,000 rows: - -```sql -ANALYZE TABLE lineitem WITH SAMPLE ROWS 100000; -``` - -### Keywords - -ANALYZE \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/CANCEL-EXPORT.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/CANCEL-EXPORT.md deleted file mode 100644 index d2f4f8e5dd14f..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/CANCEL-EXPORT.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -{ - "title": "CANCEL-EXPORT", - "language": "en" -} ---- - - - -## CANCEL-EXPORT - -### Name - -CANCEL EXPORT - -### Description - -This statement is used to undo an export job for the specified label. Or batch undo export jobs via fuzzy matching - -```sql -CANCEL EXPORT -[FROM db_name] -WHERE [LABEL = "export_label" | LABEL like "label_pattern" | STATE = "PENDING/IN_QUEUE/EXPORTING"] -``` - -### Example - -1. Cancel the export job whose label is `example_db_test_export_label` on the database example_db - - ```sql - CANCEL EXPORT - FROM example_db - WHERE LABEL = "example_db_test_export_label" and STATE = "EXPORTING"; - ``` - -2. Cancel all export jobs containing example* on the database example*db. - - ```sql - CANCEL EXPORT - FROM example_db - WHERE LABEL like "%example%"; - ``` - -3. Cancel all export jobs which state are "PENDING" - - ```sql - CANCEL EXPORT - FROM example_db - WHERE STATE = "PENDING"; - ``` - -### Keywords - - CANCEL, EXPORT - -### Best Practice - -1. Only pending export jobs in PENDING, IN_QUEUE,EXPORTING state can be canceled. -2. When performing batch undo, Doris does not guarantee the atomic undo of all corresponding export jobs. That is, it is possible that only some of the export jobs were successfully undone. The user can view the job status through the SHOW EXPORT statement and try to execute the CANCEL EXPORT statement repeatedly. -3. When the job of the `EXPORTING` state is revoked, part of the data may have been exported to the storage system, and the user needs to process (delete) this section to export data. diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/DELETE.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/DELETE.md deleted file mode 100644 index 8c58f8ac576b8..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/DELETE.md +++ /dev/null @@ -1,258 +0,0 @@ ---- -{ - "title": "DELETE", - "language": "en" -} ---- - - - -## DELETE - -### Name - -DELETE - -### Description - -This statement is used to conditionally delete data in the specified table (base index) partition. - -This operation will also delete the data of the rollup index related to this base index. - -#### Syntax - -Syntax 1: This syntax can only specify filter predicates - -```SQL -DELETE FROM table_name [PARTITION partition_name | PARTITIONS (partition_name [, partition_name])] -WHERE -column_name op { value | value_list } [ AND column_name op { value | value_list } ...]; -``` - -Syntax 2: This syntax can only used on UNIQUE KEY model - -```sql -[cte] -DELETE FROM table_name - [PARTITION partition_name | PARTITIONS (partition_name [, partition_name])] - [USING additional_tables] - WHERE condition -``` - -#### Required Parameters - -+ table_name: Specifies the table from which rows are removed. -+ column_name: column belong to table_name -+ op: Logical comparison operator, The optional types of op include: =, >, <, >=, <=, !=, in, not in -+ value | value_list: value or value list used for logial comparison -+ WHERE condition: Specifies a condition to use to select rows for removal - -#### Optional Parameters - -+ cte: Common Table Expression, e.g. 'WITH a AS SELECT * FROM tbl'. -+ PARTITION partition_name | PARTITIONS (partition_name [, partition_name]): Specifies the partition or partitions to select rows for removal -+ table_alias: alias of table -+ USING additional_tables: If you need to refer to additional tables in the WHERE clause to help identify the rows to be removed, then specify those table names in the USING clause. You can also use the USING clause to specify subqueries that identify the rows to be removed. - -#### Returned Results - -Delete command is a SQL command that return results synchronously. The results are classified as follows: - -##### Implementation Success - -If Delete completes successfully and is visible, the following results are returned.`Query OK`indicates success. - -```sql -Query OK, 0 rows affected (0.04 sec) -{'label':'delete_e7830c72-eb14-4cb9-bbb6-eebd4511d251', 'status':'VISIBLE', 'txnId':'4005'} -``` - -##### Submitted Successfully but Invisible - -Doris transaction commit is divided into two steps: commit and release version, only after the completion of the release version step, the results will be visible to the user. - -If the commit has been successful, then it can be assumed that it will eventually be published successfully, Doris will try to wait for a certain period of time after the commit is completed, if the timeout period is exceeded even if the published version is not yet complete, it will be preferred to return to the user, prompting the user that the commit has been completed. - - If Delete has been submitted and executed, but the release version is still not published and visible, the following result will be returned: - -```sql -Query OK, 0 rows affected (0.04 sec) -{'label':'delete_e7830c72-eb14-4cb9-bbb6-eebd4511d251', 'status':'COMMITTED', 'txnId':'4005', 'err':'delete job is committed but may be taking effect later' } -``` - -The result will also return a json string: - -- `affected rows`:Indicates the rows affected by this deletion. Since Doris deletion is currently a logical deletion, this value is constant at 0; - -- `label`:The automatically generated label identifies the import job. Each import job has a Label that is unique within a single database; - -- `status`:Indicates whether the data deletion is visible. If it's visible, the result displays `VISIBLE`; if it's invisible, the result displays `COMMITTED`; - -- `txnId`:The transaction id corresponding to Delete; - -- `err`:This field will display the details of Delete. - -##### Commit Failed, Transaction Cancelled - -If the Delete statement fails to commit, the transaction will be automatically aborted by Doris and the following result will be returned: - -```sql -ERROR 1064 (HY000): errCode = 2, detailMessage = {Cause of error} -``` - -For example, a timeout deletion will return the timeout time and the outstanding `(tablet=replica)` - -```sql -ERROR 1064 (HY000): errCode = 2, detailMessage = failed to delete replicas from job: 4005, Unfinished replicas:10000=60000, 10001=60000, 10002=60000 -``` - -#### Note - -1. Only conditions on the key column can be specified when using AGGREGATE (UNIQUE) model. -2. When the selected key column does not exist in a rollup, delete cannot be performed. -3. Wheny you use syntax 1, conditions can only have an "and" relationship. If you want to achieve an "or" relationship, you need to write the conditions in two DELETE statements. -4. In syntax 1, if it is a partitioned table, you can specify a partition. If not specified, Doris will infer partition from the given conditions. In two cases, Doris cannot infer the partition from conditions: 1) the conditions do not contain partition columns; 2) The operator of the partition column is not in. When a partition table does not specify the partition, or the partition cannot be inferred from the conditions, the session variable delete_without_partition needs to be true to make delete statement be applied to all partitions. -1. This statement may reduce query efficiency for a period of time after execution. The degree of impact depends on the number of delete conditions specified in the statement. The more conditions you specify, the greater the impact. - -### Example - -1. Delete the data row whose k1 column value is 3 in my_table partition p1 - - ```sql - DELETE FROM my_table PARTITION p1 - WHERE k1 = 3; - ``` - -2. Delete the data rows where the value of column k1 is greater than or equal to 3 and the value of column k2 is "abc" in my_table partition p1 - - ```sql - DELETE FROM my_table PARTITION p1 - WHERE k1 >= 3 AND k2 = "abc"; - ``` - -3. Delete the data rows where the value of column k1 is greater than or equal to 3 and the value of column k2 is "abc" in my_table partition p1, p2 - - ```sql - DELETE FROM my_table PARTITIONS (p1, p2) - WHERE k1 >= 3 AND k2 = "abc"; - ``` - -4. use the result of `t2` join `t3` to romve rows from `t1`,delete table only support unique key model - - ```sql - -- create t1, t2, t3 tables - CREATE TABLE t1 - (id INT, c1 BIGINT, c2 STRING, c3 DOUBLE, c4 DATE) - UNIQUE KEY (id) - DISTRIBUTED BY HASH (id) - PROPERTIES('replication_num'='1', "function_column.sequence_col" = "c4"); - - CREATE TABLE t2 - (id INT, c1 BIGINT, c2 STRING, c3 DOUBLE, c4 DATE) - DISTRIBUTED BY HASH (id) - PROPERTIES('replication_num'='1'); - - CREATE TABLE t3 - (id INT) - DISTRIBUTED BY HASH (id) - PROPERTIES('replication_num'='1'); - - -- insert data - INSERT INTO t1 VALUES - (1, 1, '1', 1.0, '2000-01-01'), - (2, 2, '2', 2.0, '2000-01-02'), - (3, 3, '3', 3.0, '2000-01-03'); - - INSERT INTO t2 VALUES - (1, 10, '10', 10.0, '2000-01-10'), - (2, 20, '20', 20.0, '2000-01-20'), - (3, 30, '30', 30.0, '2000-01-30'), - (4, 4, '4', 4.0, '2000-01-04'), - (5, 5, '5', 5.0, '2000-01-05'); - - INSERT INTO t3 VALUES - (1), - (4), - (5); - - -- remove rows from t1 - DELETE FROM t1 - USING t2 INNER JOIN t3 ON t2.id = t3.id - WHERE t1.id = t2.id; - ``` - - the expect result is only remove the row where id = 1 in table t1 - - ``` - +----+----+----+--------+------------+ - | id | c1 | c2 | c3 | c4 | - +----+----+----+--------+------------+ - | 2 | 2 | 2 | 2.0 | 2000-01-02 | - | 3 | 3 | 3 | 3.0 | 2000-01-03 | - +----+----+----+--------+------------+ - ``` - -5. using cte - - ```sql - create table orders( - o_orderkey bigint, - o_totalprice decimal(15, 2) - ) unique key(o_orderkey) - distributed by hash(o_orderkey) buckets 1 - properties ( - "replication_num" = "1" - ); - - insert into orders values - (1, 34.1), - (2, 432.8); - - create table lineitem( - l_linenumber int, - o_orderkey bigint, - l_discount decimal(15, 2) - ) unique key(l_linenumber) - distributed by hash(l_linenumber) buckets 1 - properties ( - "replication_num" = "1" - ); - - insert into lineitem values - (1, 1, 1.23), - (2, 1, 3.21), - (3, 2, 18.08), - (4, 2, 23.48); - - with discount_orders as ( - select * from orders - where o_totalprice > 100 - ) - delete from lineitem - using discount_orders - where lineitem.o_orderkey = discount_orders.o_orderkey; - ``` - -### Keywords - - DELETE - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/EXPORT.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/EXPORT.md deleted file mode 100644 index bb38113eaf032..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/EXPORT.md +++ /dev/null @@ -1,383 +0,0 @@ ---- -{ - "title": "EXPORT", - "language": "en" -} ---- - - - -## EXPORT - -### Name - -EXPORT - -### Description - -The `EXPORT` command is used to export the data of a specified table to a designated location as a file. Currently, it supports exporting to remote storage such as HDFS, S3, BOS, and COS (Tencent Cloud) through Broker process, S3 protocol, or HDFS protocol. - -`EXPORT` is an asynchronous operation, and the command submits an `EXPORT JOB` to Doris. The task will be successfully submitted and returns immediately. After execution, you can use the [SHOW EXPORT](../../Show-Statements/SHOW-EXPORT.md) to view the progress. - -**grammar** - - ```sql - EXPORT TABLE table_name - [PARTITION (p1[,p2])] - [WHERE] - TO export_path - [opt_properties] - WITH BROKER/S3/HDFS - [broker_properties]; - ``` - -**principle** - -The bottom layer of the `Export` statement actually executes the `select...outfile..` statement. The `Export` task will be decomposed into multiple `select...outfile..` statements to execute concurrently according to the value of the `parallelism` parameter. Each `select...outfile..` is responsible for exporting some tablets of table. - -**illustrate:** - -- `table_name` - - The table name of the table currently being exported. Only the export of Doris local table / View / External Table data is supported. - -- `partition` - - It is possible to export only some specified partitions of the specified table - -- `export_path` - - The exported file path can be a directory or a file directory with a file prefix, for example: `hdfs://path/to/my_file_` - -- `opt_properties` - - Used to specify some export parameters. - - ```sql - [PROPERTIES ("key"="value", ...)] - ``` - - The following parameters can be specified: - - - `label`: This parameter is optional, specifies the label of the export task. If this parameter is not specified, the system randomly assigns a label to the export task. - - - `column_separator`: Specifies the exported column separator, default is `\t`, mulit-bytes is supported. This parameter is only used for `CSV` file format. - - - `line_delimiter`: Specifies the line delimiter for export, the default is `\n`, mulit-bytes is supported. This parameter is only used for `CSV` file format. - - - `timeout`: The timeout period of the export job, the default is 2 hours, the unit is seconds. - - - `columns`: Specifies certain columns of the export job table - - - `format`: Specifies the file format, support: parquet, orc, csv, csv_with_names, csv_with_names_and_types.The default is csv format. - - - `parallelism`: The concurrency degree of the `export` job, the default is `1`. The export job will be divided into `select..outfile..` statements of the number of `parallelism` to execute concurrently. (If the value of `parallelism` is greater than the number of tablets in the table, the system will automatically set `parallelism` to the number of tablets, that is, each `select..outfile..` statement is responsible for one tablet) - - - `delete_existing_files`: default `false`. If it is specified as true, you will first delete all files specified in the directory specified by the file_path, and then export the data to the directory.For example: "file_path" = "/user/tmp", then delete all files and directory under "/user/"; "file_path" = "/user/tmp/", then delete all files and directory under "/user/tmp/" - - - `max_file_size`: it is the limit for the size of a single file in the export job. If the result file exceeds this value, it will be split into multiple files. The valid range for `max_file_size` is [5MB, 2GB], with a default value of 1GB. (When exporting to the ORC file format, the actual size of the split files will be multiples of 64MB, for example, if max_file_size is specified as 5MB, the actual split size will be 64MB; if max_file_size is specified as 65MB, the actual split size will be 128MB.) - - - `with_bom`: The default is false. If it is set to true, the exported file is encoded in UTF8 with BOM (valid only for CSV-related file format). - - - `timeout`: This is the timeout parameter of the export job, the default timeout is 2 hours, and the unit is seconds. - - - `compress_type`: (since 2.1.5) When specifying the export file format as Parquet or ORC, you can choose the compression method for the Parquet or ORC files. For Parquet file format, you can specify the compression method as SNAPPY, GZIP, BROTLI, ZSTD, LZ4, or PLAIN, with the default being SNAPPY. For ORC file format, you can specify the compression method as PLAIN, SNAPPY, ZLIB, or ZSTD, with the default being ZLIB. This parameter is supported starting from version 2.1.5. (PLAIN means no compression is used.) - - > Note that to use the `delete_existing_files` parameter, you also need to add the configuration `enable_delete_existing_files = true` to the fe.conf file and restart the FE. Only then will the `delete_existing_files` parameter take effect. Setting `delete_existing_files = true` is a dangerous operation and it is recommended to only use it in a testing environment. - -- `WITH BROKER` - - The export function needs to write data to the remote storage through the Broker process. Here you need to define the relevant connection information for the broker to use. - - ```sql - WITH BROKER "broker_name" - ("key"="value"[,...]) - - Broker related properties: - username: user name - password: password - hadoop.security.authentication: specify the authentication method as kerberos - kerberos_principal: specifies the principal of kerberos - kerberos_keytab: specifies the path to the keytab file of kerberos. The file must be the absolute path to the file on the server where the broker process is located. and can be accessed by the Broker process - ``` - -- `WITH HDFS` - - You can directly write data to the remote HDFS. - - - ```sql - WITH HDFS ("key"="value"[,...]) - - HDFS related properties: - fs.defaultFS: namenode address and port - hadoop.username: hdfs username - dfs.nameservices: if hadoop enable HA, please set fs nameservice. See hdfs-site.xml - dfs.ha.namenodes.[nameservice ID]:unique identifiers for each NameNode in the nameservice. See hdfs-site.xml - dfs.namenode.rpc-address.[nameservice ID].[name node ID]: the fully-qualified RPC address for each NameNode to listen on. See hdfs-site.xml - dfs.client.failover.proxy.provider.[nameservice ID]:the Java class that HDFS clients use to contact the Active NameNode, usually it is org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider - - For a kerberos-authentication enabled Hadoop cluster, additional properties need to be set: - dfs.namenode.kerberos.principal: HDFS namenode service principal - hadoop.security.authentication: kerberos - hadoop.kerberos.principal: the Kerberos pincipal that Doris will use when connectiong to HDFS. - hadoop.kerberos.keytab: HDFS client keytab location. - ``` - -- `WITH S3` - - You can directly write data to a remote S3 object store - - ```sql - WITH S3 ("key"="value"[,...]) - - S3 related properties: - AWS_ENDPOINT - AWS_ACCESS_KEY - AWS_SECRET_KEY - AWS_REGION - use_path_style: (optional) default false . The S3 SDK uses the virtual-hosted style by default. However, some object storage systems may not be enabled or support virtual-hosted style access. At this time, we can add the use_path_style parameter to force the use of path style access method. - ``` - -### Example - -#### export to local - -> Export data to the local file system needs to add `enable_outfile_to_local = true` to the fe.conf and restart the Fe. - -1. You can export the `test` table to a local store. Export csv format file by default. - -```sql -EXPORT TABLE test TO "file:///home/user/tmp/"; -``` - -2. You can export the k1 and k2 columns in `test` table to a local store, and set export label. Export csv format file by default. - -```sql -EXPORT TABLE test TO "file:///home/user/tmp/" -PROPERTIES ( - "label" = "label1", - "columns" = "k1,k2" -); -``` - -3. You can export the rows where `k1 < 50` in `test` table to a local store, and set column_separator to `,`. Export csv format file by default. - -```sql -EXPORT TABLE test WHERE k1 < 50 TO "file:///home/user/tmp/" -PROPERTIES ( - "columns" = "k1,k2", - "column_separator"="," -); -``` - -4. Export partitions p1 and p2 from the test table to local storage, with the default exported file format being csv. - -```sql -EXPORT TABLE test PARTITION (p1,p2) TO "file:///home/user/tmp/" -PROPERTIES ("columns" = "k1,k2"); - ``` - -5. Export all data in the test table to local storage with a non-default file format. - -```sql -// parquet file format -EXPORT TABLE test TO "file:///home/user/tmp/" -PROPERTIES ( - "columns" = "k1,k2", - "format" = "parquet" -); - -// orc file format -EXPORT TABLE test TO "file:///home/user/tmp/" -PROPERTIES ( - "columns" = "k1,k2", - "format" = "orc" -); - -// csv_with_names file format. Using 'AA' as the column delimiter and 'zz' as the line delimiter. -EXPORT TABLE test TO "file:///home/user/tmp/" -PROPERTIES ( - "format" = "csv_with_names", - "column_separator"="AA", - "line_delimiter" = "zz" -); - -// csv_with_names_and_types file format -EXPORT TABLE test TO "file:///home/user/tmp/" -PROPERTIES ( - "format" = "csv_with_names_and_types" -); - -``` - -6. set max_file_sizes - -```sql -EXPORT TABLE test TO "file:///home/user/tmp/" -PROPERTIES ( - "format" = "parquet", - "max_file_size" = "5MB" -); -``` - -When the exported file size is larger than 5MB, the data will be split into multiple files, with each file containing a maximum of 5MB. - -7. set parallelism -```sql -EXPORT TABLE test TO "file:///home/user/tmp/" -PROPERTIES ( - "format" = "parquet", - "max_file_size" = "5MB", - "parallelism" = "5" -); -``` - -8. set delete_existing_files - -```sql -EXPORT TABLE test TO "file:///home/user/tmp" -PROPERTIES ( - "format" = "parquet", - "max_file_size" = "5MB", - "delete_existing_files" = "true" -) -``` - -Before exporting data, all files and directories in the `/home/user/` directory will be deleted, and then the data will be exported to that directory. - -#### export with S3 - -1. Export all data from the `testTbl` table to S3 using invisible character '\x07' as a delimiter for columns and rows.If you want to export data to minio, you also need to specify use_path_style=true. - - ```sql - EXPORT TABLE testTbl TO "s3://bucket/a/b/c" - PROPERTIES ( - "column_separator"="\\x07", - "line_delimiter" = "\\x07" - ) WITH s3 ( - "s3.endpoint" = "xxxxx", - "s3.region" = "xxxxx", - "s3.secret_key"="xxxx", - "s3.access_key" = "xxxxx" - ) - ``` - -2. Export all data in the test table to HDFS in the format of parquet, limit the size of a single file to 1024MB, and reserve all files in the specified directory. - -#### export with HDFS -1. Export all data from the `test` table to HDFS in `Parquet` format, with a limit of 512MB for the size of a single file in the export job, and retain all files under the specified directory. - - ```sql - EXPORT TABLE test TO "hdfs://hdfs_host:port/a/b/c/" - PROPERTIES( - "format" = "parquet", - "max_file_size" = "512MB", - "delete_existing_files" = "false" - ) - with HDFS ( - "fs.defaultFS"="hdfs://hdfs_host:port", - "hadoop.username" = "hadoop" - ); - ``` - -#### export with Broker -You need to first start the broker process and add it to the FE before proceeding. -1. Export the `test` table to hdfs - - ```sql - EXPORT TABLE test TO "hdfs://hdfs_host:port/a/b/c" - WITH BROKER "broker_name" - ( - "username"="xxx", - "password"="yyy" - ); - ``` - -2. Export partitions 'p1' and 'p2' from the 'testTbl' table to HDFS using ',' as the column delimiter and specifying a label. - - ```sql - EXPORT TABLE testTbl PARTITION (p1,p2) TO "hdfs://hdfs_host:port/a/b/c" - PROPERTIES ( - "label" = "mylabel", - "column_separator"="," - ) - WITH BROKER "broker_name" - ( - "username"="xxx", - "password"="yyy" - ); - ``` - -3. Export all data from the 'testTbl' table to HDFS using the non-visible character '\x07' as the column and row delimiter. - -```sql -EXPORT TABLE testTbl TO "hdfs://hdfs_host:port/a/b/c" -PROPERTIES ( - "column_separator"="\\x07", - "line_delimiter" = "\\x07" -) -WITH BROKER "broker_name" -( - "username"="xxx", - "password"="yyy" -) -``` - -### Keywords - - EXPORT - -### Best Practice - - #### Concurrent Export - - An Export job can be configured with the `parallelism` parameter to concurrently export data. The `parallelism` parameter specifies the number of threads to execute the `EXPORT Job`. Each thread is responsible for exporting a subset of the total tablets. - - The underlying execution logic of an `Export Job `is actually the `SELECT INTO OUTFILE` statement. Each thread specified by the `parallelism` parameter executes independent `SELECT INTO OUTFILE` statements. - - The specific logic for splitting an `Export Job` into multiple `SELECT INTO OUTFILE` is, to evenly distribute all the tablets of the table among all parallel threads. For example: - - - If num(tablets) = 40 and parallelism = 3, then the three threads will be responsible for 14, 13, and 13 tablets, respectively. - - If num(tablets) = 2 and parallelism = 3, then Doris automatically sets the parallelism to 2, and each thread is responsible for one tablet. - - When the number of tablets responsible for a thread exceeds the `maximum_tablets_of_outfile_in_export` value (default is 10, and can be modified by adding the `maximum_tablets_of_outfile_in_export` parameter in fe.conf), the thread will split the tablets which are responsibled for this thread into multiple `SELECT INTO OUTFILE` statements. For example: - - - If a thread is responsible for 14 tablets and `maximum_tablets_of_outfile_in_export = 10`, then the thread will be responsible for two `SELECT INTO OUTFILE` statements. The first `SELECT INTO OUTFILE` statement exports 10 tablets, and the second `SELECT INTO OUTFILE` statement exports 4 tablets. The two `SELECT INTO OUTFILE` statements are executed serially by this thread. - - #### memory limit - - The query plan for an `Export Job` typically involves only `scanning and exporting`, and does not involve compute logic that requires a lot of memory. Therefore, the default memory limit of 2GB is usually sufficient to meet the requirements. - - However, in certain scenarios, such as a query plan that requires scanning too many tablets on the same BE, or when there are too many data versions of tablets, it may result in insufficient memory. In these cases, you can adjust the session variable `exec_mem_limit` to increase the memory usage limit. - - #### Precautions - - - Exporting a large amount of data at one time is not recommended. The maximum recommended export data volume for an Export job is several tens of GB. An overly large export results in more junk files and higher retry costs. If the amount of table data is too large, it is recommended to export by partition. - - - If the Export job fails, the generated files will not be deleted, and the user needs to delete it manually. - - - The Export job only exports the data of the Base table / View / External table, not the data of the materialized view. - - - The export job scans data and occupies IO resources, which may affect the query latency of the system. - - - Currently, The `Export Job` is simply check whether the `Tablets version` is the same, it is recommended not to import data during the execution of the `Export Job`. - - - The maximum number of partitions that an `Export job` allows is 2000. You can add a parameter to the fe.conf `maximum_number_of_export_partitions` and restart FE to modify the setting. diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/INSERT-OVERWRITE.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/INSERT-OVERWRITE.md deleted file mode 100644 index 35e944476a2a2..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/INSERT-OVERWRITE.md +++ /dev/null @@ -1,300 +0,0 @@ ---- -{ - "title": "INSERT-OVERWRITE", - "language": "en" -} - ---- - - - -## INSERT OVERWRITE - -### Name - -INSERT OVERWRITE - -### Description - -The function of this statement is to overwrite a table or some partitions of a table - -```sql -INSERT OVERWRITE table table_name - [ PARTITION (p1, ... | *) ] - [ WITH LABEL label] - [ (column [, ...]) ] - [ [ hint [, ...] ] ] - { VALUES ( { expression | DEFAULT } [, ...] ) [, ...] | query } -``` - - Parameters - -> table_name: the destination table to overwrite. This table must exist. It can be of the form `db_name.table_name` -> -> partitions: the table partitions that needs to be overwritten. The following two formats are supported -> ->> 1. partition names. must be one of the existing partitions in `table_name` separated by a comma ->> 2. asterisk(*)。Enable [auto-detect-partition](#overwrite-auto-detect-partition). The write operation will automatically detect the partitions involved in the data and overwrite those partitions. -> -> label: specify a label for the Insert task -> -> column_name: the specified destination column must be one of the existing columns in `table_name` -> -> expression: the corresponding expression that needs to be assigned to a column -> -> DEFAULT: let the column use the default value -> -> query: a common query, the result of the query will overwrite the target. -> -> hint: some indicator used to indicate the execution behavior of `INSERT`. You can choose one of this values: `/*+ STREAMING */`, `/*+ SHUFFLE */` or `/*+ NOSHUFFLE */. -> -> 1. STREAMING: At present, it has no practical effect and is only reserved for compatibility with previous versions. (In the previous version, adding this hint would return a label, but now it defaults to returning a label) -> 2. SHUFFLE: When the target table is a partition table, enabling this hint will do repartiiton. -> 3. NOSHUFFLE: Even if the target table is a partition table, repartiiton will not be performed, but some other operations will be performed to ensure that the data is correctly dropped into each partition. - -Notice: - -1. In the current version, the session variable `enable_insert_strict` is set to `true` by default. If some data that does not conform to the format of the target table is filtered out during the execution of the `INSERT OVERWRITE` statement, such as when overwriting a partition and not all partition conditions are satisfied, overwriting the target table will fail. -2. The `INSERT OVERWRITE` statement first creates a new table, inserts the data to be overwritten into the new table, and then atomically replaces the old table with the new table and modifies its name. Therefore, during the process of overwriting the table, the data in the old table can still be accessed normally until the overwriting is completed. - -#### For Auto Partition Table - -If the target table of the INSERT OVERWRITE is an autopartitioned table, the behaviour is controlled by the [Session Variable](../#variable) `enable_auto_create_when_overwrite` controls the behaviour as follows: -1. If PARTITION is not specified (overwrite the whole table), when `enable_auto_create_when_overwrite` is `true`, the table is overwritten and partitions are created according to the table's auto-partitioning rules for data that does not have a corresponding partition, and those datas is admit. If `enable_auto_create_when_overwrite` is `false`, data for which no partition is found will accumulate error rows until it fails. -2. If an overwrite PARTITION is specified, the AUTO PARTITION table behaves as a normal partitioned table during this process, and data that does not satisfy the conditions of an existing partition is filtered instead of creating a new partition. -3. If you specify PARTITION as `partition(*)` (auto detect partition and overwrite), when `enable_auto_create_when_overwrite` is `true`, for the data that have corresponding partitions in the table, overwrite their corresponding partitions, and leave the other existing partitions unchanged. At the same time, for data without corresponding partitions, create partitions according to the table's auto-partitioning rules, and accommodate the data without corresponding partitions. If `enable_auto_create_when_overwrite` is `false`, data for which no partition is found will accumulate error rows until it fails. - -In versions without `enable_auto_create_when_overwrite`, the behaviour is as if the variable had a value of `false`. - -Examples are shown below: - -```sql -mysql> create table auto_list( - -> k0 varchar null - -> ) - -> auto partition by list (k0) - -> ( - -> PARTITION p1 values in (("Beijing"), ("BEIJING")), - -> PARTITION p2 values in (("Shanghai"), ("SHANGHAI")), - -> PARTITION p3 values in (("xxx"), ("XXX")), - -> PARTITION p4 values in (("list"), ("LIST")), - -> PARTITION p5 values in (("1234567"), ("7654321")) - -> ) - -> DISTRIBUTED BY HASH(`k0`) BUCKETS 1 - -> properties("replication_num" = "1"); -Query OK, 0 rows affected (0.14 sec) - -mysql> insert into auto_list values ("Beijing"),("Shanghai"),("xxx"),("list"),("1234567"); -Query OK, 5 rows affected (0.22 sec) - -mysql> insert overwrite table auto_list partition(*) values ("BEIJING"), ("new1"); -Query OK, 2 rows affected (0.28 sec) - -mysql> select * from auto_list; -+----------+ --- p1 is overwritten, new1 gets the new partition, and the other partitions remain unchanged. -| k0 | -+----------+ -| 1234567 | -| BEIJING | -| list | -| xxx | -| new1 | -| Shanghai | -+----------+ -6 rows in set (0.48 sec) - -mysql> insert overwrite table auto_list values ("SHANGHAI"), ("new2"); -Query OK, 2 rows affected (0.17 sec) - -mysql> select * from auto_list; -+----------+ --- The whole table is overwritten, and new2 gets the new partition. -| k0 | -+----------+ -| new2 | -| SHANGHAI | -+----------+ -2 rows in set (0.15 sec) -``` - -### Example - -Assuming there is a table named `test`. The table contains two columns `c1` and `c2`, and two partitions `p1` and `p2` - -```sql -CREATE TABLE IF NOT EXISTS test ( - `c1` int NOT NULL DEFAULT "1", - `c2` int NOT NULL DEFAULT "4" -) ENGINE=OLAP -UNIQUE KEY(`c1`) -PARTITION BY LIST (`c1`) -( -PARTITION p1 VALUES IN ("1","2","3"), -PARTITION p2 VALUES IN ("4","5","6") -) -DISTRIBUTED BY HASH(`c1`) BUCKETS 3 -PROPERTIES ( - "replication_allocation" = "tag.location.default: 1", - "in_memory" = "false", - "storage_format" = "V2" -); -``` - -#### Overwrite Table - -1. Overwrite the `test` table using the form of `VALUES`. - - ```sql - // Single-row overwrite. - INSERT OVERWRITE table test VALUES (1, 2); - INSERT OVERWRITE table test (c1, c2) VALUES (1, 2); - INSERT OVERWRITE table test (c1, c2) VALUES (1, DEFAULT); - INSERT OVERWRITE table test (c1) VALUES (1); - // Multi-row overwrite. - INSERT OVERWRITE table test VALUES (1, 2), (3, 2 + 2); - INSERT OVERWRITE table test (c1, c2) VALUES (1, 2), (3, 2 * 2); - INSERT OVERWRITE table test (c1, c2) VALUES (1, DEFAULT), (3, DEFAULT); - INSERT OVERWRITE table test (c1) VALUES (1), (3); - ``` - -- The first and second statements have the same effect. If the target column is not specified during overwriting, the column order in the table will be used as the default target column. After the overwrite is successful, there is only one row of data in the `test` table. -- The third and fourth statements have the same effect. The unspecified column `c2` will be overwritten with the default value 4. After the overwrite is successful, there is only one row of data in the `test` table. -- The fifth and sixth statements have the same effect. Expressions (such as `2+2`, `2*2`) can be used in the statement. The result of the expression will be computed during the execution of the statement and then overwritten into the `test` table. After the overwrite is successful, there are two rows of data in the `test` table. -- The seventh and eighth statements have the same effect. The unspecified column `c2` will be overwritten with the default value 4. After the overwrite is successful, there are two rows of data in the `test` table. - -2. Overwrite the `test` table in the form of a query statement. The data format of the `test2` table and the `test` table must be consistent. If they are not consistent, implicit data type conversion will be triggered. - - ```sql - INSERT OVERWRITE table test SELECT * FROM test2; - INSERT OVERWRITE table test (c1, c2) SELECT * from test2; - ``` - -- The first and second statements have the same effect. The purpose of these statements is to take data from the `test2` table and overwrite the `test` table with the taken data. After the overwrite is successful, the data in the `test` table will be consistent with the data in the `test2` table. - -3. Overwrite the `test` table and specify a label. - - ```sql - INSERT OVERWRITE table test WITH LABEL `label1` SELECT * FROM test2; - INSERT OVERWRITE table test WITH LABEL `label2` (c1, c2) SELECT * from test2; - ``` - -- Users can use the `SHOW LOAD;` command to check the status of the job imported by this `label`. It should be noted that the label is unique. - - -#### Overwrite Table Partition - -When using INSERT OVERWRITE to rewrite partitions, we actually encapsulate the following three steps into a single transaction and execute it. If it fails halfway through, the operations that have been performed will be rolled back: -1. Assuming that partition `p1` is specified to be rewritten, first create an empty temporary partition `pTMP` with the same structure as the target partition to be rewritten. -2. Write data to `pTMP`. -3. replace `p1` with the `pTMP` atom - -The following is examples: - -1. Overwrite partitions `P1` and `P2` of the `test` table using the form of `VALUES`. - - ```sql - // Single-row overwrite. - INSERT OVERWRITE table test PARTITION(p1,p2) VALUES (1, 2); - INSERT OVERWRITE table test PARTITION(p1,p2) (c1, c2) VALUES (1, 2); - INSERT OVERWRITE table test PARTITION(p1,p2) (c1, c2) VALUES (1, DEFAULT); - INSERT OVERWRITE table test PARTITION(p1,p2) (c1) VALUES (1); - // Multi-row overwrite. - INSERT OVERWRITE table test PARTITION(p1,p2) VALUES (1, 2), (4, 2 + 2); - INSERT OVERWRITE table test PARTITION(p1,p2) (c1, c2) VALUES (1, 2), (4, 2 * 2); - INSERT OVERWRITE table test PARTITION(p1,p2) (c1, c2) VALUES (1, DEFAULT), (4, DEFAULT); - INSERT OVERWRITE table test PARTITION(p1,p2) (c1) VALUES (1), (4); - ``` - - Unlike overwriting an entire table, the above statements are overwriting partitions in the table. Partitions can be overwritten one at a time or multiple partitions can be overwritten at once. It should be noted that only data that satisfies the corresponding partition filtering condition can be overwritten successfully. If there is data in the overwritten data that does not satisfy any of the partitions, the overwrite will fail. An example of a failure is shown below. - - ```sql - INSERT OVERWRITE table test PARTITION(p1,p2) VALUES (7, 2); - ``` - - The data overwritten by the above statements (`c1=7`) does not satisfy the conditions of partitions `P1` and `P2`, so the overwrite will fail. - -2. Overwrite partitions `P1` and `P2` of the `test` table in the form of a query statement. The data format of the `test2` table and the `test` table must be consistent. If they are not consistent, implicit data type conversion will be triggered. - - ```sql - INSERT OVERWRITE table test PARTITION(p1,p2) SELECT * FROM test2; - INSERT OVERWRITE table test PARTITION(p1,p2) (c1, c2) SELECT * from test2; - ``` - -3. Overwrite partitions `P1` and `P2` of the `test` table and specify a label. - - ```sql - INSERT OVERWRITE table test PARTITION(p1,p2) WITH LABEL `label3` SELECT * FROM test2; - INSERT OVERWRITE table test PARTITION(p1,p2) WITH LABEL `label4` (c1, c2) SELECT * from test2; - ``` - - -#### Overwrite Auto Detect Partition - -> This feature is available since version 2.1.3. - -When the PARTITION clause specified by the INSERT OVERWRITE command is `PARTITION(*)`, this overwrite will automatically detect the partition where the data is located. Example: - -```sql -mysql> create table test( - -> k0 int null - -> ) - -> partition by range (k0) - -> ( - -> PARTITION p10 values less than (10), - -> PARTITION p100 values less than (100), - -> PARTITION pMAX values less than (maxvalue) - -> ) - -> DISTRIBUTED BY HASH(`k0`) BUCKETS 1 - -> properties("replication_num" = "1"); -Query OK, 0 rows affected (0.11 sec) - -mysql> insert into test values (1), (2), (15), (100), (200); -Query OK, 5 rows affected (0.29 sec) - -mysql> select * from test order by k0; -+------+ -| k0 | -+------+ -| 1 | -| 2 | -| 15 | -| 100 | -| 200 | -+------+ -5 rows in set (0.23 sec) - -mysql> insert overwrite table test partition(*) values (3), (1234); -Query OK, 2 rows affected (0.24 sec) - -mysql> select * from test order by k0; -+------+ -| k0 | -+------+ -| 3 | -| 15 | -| 1234 | -+------+ -3 rows in set (0.20 sec) -``` - -As you can see, all data in partitions `p10` and `pMAX`, where data 3 and 1234 are located, are overwritten, while partition `p100` remains unchanged. This operation can be interpreted as syntactic sugar for specifying a specific partition to be overwritten by the PARTITION clause during an INSERT OVERWRITE operation, which is implemented in the same way as [specify a partition to overwrite](#overwrite-table-partition). The `PARTITION(*)` syntax eliminates the need to manually fill in all the partition names when overwriting a large number of partitions. - -### Keywords - - INSERT OVERWRITE, OVERWRITE, AUTO DETECT diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/INSERT.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/INSERT.md deleted file mode 100644 index 445f72170f7e1..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/INSERT.md +++ /dev/null @@ -1,234 +0,0 @@ ---- -{ - "title": "INSERT", - "language": "en" -} ---- - - - -## INSERT - -### Name - -INSERT - -### Description - -The change statement is to complete the data insertion operation. - -```sql -INSERT INTO table_name - [ PARTITION (p1, ...) ] - [ WITH LABEL label] - [ (column [, ...]) ] - [ [ hint [, ...] ] ] - { VALUES ( { expression | DEFAULT } [, ...] ) [, ...] | query } -``` - - Parameters - -> tablet_name: The destination table for importing data. Can be of the form `db_name.table_name` -> -> partitions: Specify the partitions to be imported, which must be partitions that exist in `table_name`. Multiple partition names are separated by commas -> -> label: specify a label for the Insert task -> -> column_name: The specified destination column, must be a column that exists in `table_name` -> -> expression: the corresponding expression that needs to be assigned to a column -> -> DEFAULT: let the corresponding column use the default value -> -> query: a common query, the result of the query will be written to the target -> -> hint: some indicator used to indicate the execution behavior of `INSERT`. You can choose one of this values: `/*+ STREAMING */`, `/*+ SHUFFLE */` or `/*+ NOSHUFFLE */. -> 1. STREAMING: At present, it has no practical effect and is only reserved for compatibility with previous versions. (In the previous version, adding this hint would return a label, but now it defaults to returning a label) -> 2. SHUFFLE: When the target table is a partition table, enabling this hint will do repartiiton. -> 3. NOSHUFFLE: Even if the target table is a partition table, repartiiton will not be performed, but some other operations will be performed to ensure that the data is correctly dropped into each partition. - -For a Unique table with merge-on-write enabled, you can also perform partial columns updates using the insert statement. To perform partial column updates with the insert statement, you need to set the session variable enable_unique_key_partial_update to true (the default value for this variable is false, meaning partial columns updates with the insert statement are not allowed by default). When performing partial columns updates, the columns being inserted must contain at least all the Key columns and specify the columns you want to update. If the Key column values for the inserted row already exist in the original table, the data in the row with the same key column values will be updated. If the Key column values for the inserted row do not exist in the original table, a new row will be inserted into the table. In this case, columns not specified in the insert statement must either have default values or be nullable. These missing columns will first attempt to be populated with default values, and if a column has no default value, it will be filled with null. If a column cannot be null, the insert operation will fail. - -Please note that the default value of the session variable `enable_insert_strict`, which controls whether the insert statement operates in strict mode, is true. In other words, the insert statement is in strict mode by default, and in this mode, updating non-existing keys in partial column updates is not allowed. Therefore, when using the insert statement for partial columns update and wishing to insert non-existing keys, you need to set `enable_unique_key_partial_update` to true and simultaneously set `enable_insert_strict` to false. - -Notice: - -When executing the `INSERT` statement, the default behavior is to filter the data that does not conform to the target table format, such as the string is too long. However, for business scenarios that require data not to be filtered, you can set the session variable `enable_insert_strict` to `true` to ensure that `INSERT` will not be executed successfully when data is filtered out. - -### Example - -The `test` table contains two columns `c1`, `c2`. - -1. Import a row of data into the `test` table - -```sql -INSERT INTO test VALUES (1, 2); -INSERT INTO test (c1, c2) VALUES (1, 2); -INSERT INTO test (c1, c2) VALUES (1, DEFAULT); -INSERT INTO test (c1) VALUES (1); -``` - -The first and second statements have the same effect. When no target column is specified, the column order in the table is used as the default target column. -The third and fourth statements express the same meaning, use the default value of the `c2` column to complete the data import. - -2. Import multiple rows of data into the `test` table at one time - -```sql -INSERT INTO test VALUES (1, 2), (3, 2 + 2); -INSERT INTO test (c1, c2) VALUES (1, 2), (3, 2 * 2); -INSERT INTO test (c1) VALUES (1), (3); -INSERT INTO test (c1, c2) VALUES (1, DEFAULT), (3, DEFAULT); -``` - -The first and second statements have the same effect, import two pieces of data into the `test` table at one time -The effect of the third and fourth statements is known, and the default value of the `c2` column is used to import two pieces of data into the `test` table - -3. Import a query result into the `test` table - -```sql -INSERT INTO test SELECT * FROM test2; -INSERT INTO test (c1, c2) SELECT * from test2; -``` - -4. Import a query result into the `test` table, specifying the partition and label - -```sql -INSERT INTO test PARTITION(p1, p2) WITH LABEL `label1` SELECT * FROM test2; -INSERT INTO test WITH LABEL `label1` (c1, c2) SELECT * from test2; -``` - - -### Keywords - - INSERT - -### Best Practice - -1. View the returned results - - The INSERT operation is a synchronous operation, and the return of the result indicates the end of the operation. Users need to perform corresponding processing according to the different returned results. - - 1. The execution is successful, the result set is empty - - If the result set of the insert corresponding to the select statement is empty, it will return as follows: - - ```sql - mysql> insert into tbl1 select * from empty_tbl; - Query OK, 0 rows affected (0.02 sec) - ``` - - `Query OK` indicates successful execution. `0 rows affected` means that no data was imported. - - 2. The execution is successful, the result set is not empty - - In the case where the result set is not empty. The returned results are divided into the following situations: - - 1. Insert executes successfully and is visible: - - ```sql - mysql> insert into tbl1 select * from tbl2; - Query OK, 4 rows affected (0.38 sec) - {'label':'insert_8510c568-9eda-4173-9e36-6adc7d35291c', 'status':'visible', 'txnId':'4005'} - - mysql> insert into tbl1 with label my_label1 select * from tbl2; - Query OK, 4 rows affected (0.38 sec) - {'label':'my_label1', 'status':'visible', 'txnId':'4005'} - - mysql> insert into tbl1 select * from tbl2; - Query OK, 2 rows affected, 2 warnings (0.31 sec) - {'label':'insert_f0747f0e-7a35-46e2-affa-13a235f4020d', 'status':'visible', 'txnId':'4005'} - - mysql> insert into tbl1 select * from tbl2; - Query OK, 2 rows affected, 2 warnings (0.31 sec) - {'label':'insert_f0747f0e-7a35-46e2-affa-13a235f4020d', 'status':'committed', 'txnId':'4005'} - ``` - - `Query OK` indicates successful execution. `4 rows affected` means that a total of 4 rows of data were imported. `2 warnings` indicates the number of lines to be filtered. - - Also returns a json string: - - ```json - {'label':'my_label1', 'status':'visible', 'txnId':'4005'} - {'label':'insert_f0747f0e-7a35-46e2-affa-13a235f4020d', 'status':'committed', 'txnId':'4005'} - {'label':'my_label1', 'status':'visible', 'txnId':'4005', 'err':'some other error'} - ``` - - `label` is a user-specified label or an automatically generated label. Label is the ID of this Insert Into import job. Each import job has a unique Label within a single database. - - `status` indicates whether the imported data is visible. Show `visible` if visible, `committed` if not visible. - - `txnId` is the id of the import transaction corresponding to this insert. - - The `err` field shows some other unexpected errors. - - When you need to view the filtered rows, the user can pass the following statement - - ```sql - show load where label="xxx"; - ``` - - The URL in the returned result can be used to query the wrong data. For details, see the summary of **Viewing Error Lines** later. - - **Invisibility of data is a temporary state, this batch of data will eventually be visible** - - You can view the visible status of this batch of data with the following statement: - - ```sql - show transaction where id=4005; - ``` - - If the `TransactionStatus` column in the returned result is `visible`, the representation data is visible. - - 3. Execution failed - - Execution failure indicates that no data was successfully imported, and the following is returned: - - ```sql - mysql> insert into tbl1 select * from tbl2 where k1 = "a"; - ERROR 1064 (HY000): all partitions have no load data. url: http://10.74.167.16:8042/api/_load_error_log?file=__shard_2/error_log_insert_stmt_ba8bb9e158e4879-ae8de8507c0bf8a2_ba8bb9e158e4879_ae8de8507c0 - ``` - - Where `ERROR 1064 (HY000): all partitions have no load data` shows the reason for the failure. The following url can be used to query the wrong data: - - ```sql - show load warnings on "url"; - ``` - - You can view the specific error line. - -2. Timeout time - - The timeout for INSERT operations is controlled by [session variable](../../../../advanced/variables.md) `insert_timeout`. The default is 4 hours. If it times out, the job will be canceled. - -3. Label and atomicity - - The INSERT operation also guarantees the atomicity of imports, see the [Import Transactions and Atomicity](../../../../data-operate/import/import-scenes/load-atomicity.md) documentation. - - When using `CTE(Common Table Expressions)` as the query part in an insert operation, the `WITH LABEL` and `column` parts must be specified. - -4. Filter Threshold - - Unlike other import methods, INSERT operations cannot specify a filter threshold (`max_filter_ratio`). The default filter threshold is 1, which means that rows with errors can be ignored. - - For business scenarios that require data not to be filtered, you can set [session variable](../../../../advanced/variables.md) `enable_insert_strict` to `true` to ensure that when there is data When filtered out, `INSERT` will not be executed successfully. - -5. Performance issues - - There is no single row insertion using the `VALUES` method. If you must use it this way, combine multiple rows of data into one INSERT statement for bulk commit. diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/SELECT.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/SELECT.md deleted file mode 100644 index 5f67ff2f3c220..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/SELECT.md +++ /dev/null @@ -1,414 +0,0 @@ ---- -{ - "title": "SELECT", - "language": "en" -} - ---- - - - -## SELECT - -### Name - -SELECT - -### description - -Mainly introduces the use of Select syntax - -grammar: - -```sql -SELECT - [hint_statement, ...] - [ALL | DISTINCT | DISTINCTROW | ALL EXCEPT ( col_name1 [, col_name2, col_name3, ...] )] - select_expr [, select_expr ...] - [FROM table_references - [PARTITION partition_list] - [TABLET tabletid_list] - [TABLESAMPLE sample_value [ROWS | PERCENT] - [REPEATABLE pos_seek]] - [WHERE where_condition] - [GROUP BY [GROUPING SETS | ROLLUP | CUBE] {col_name | expr | position}] - [HAVING where_condition] - [ORDER BY {col_name | expr | position} - [ASC | DESC], ...] - [LIMIT {[offset,] row_count | row_count OFFSET offset}] - [INTO OUTFILE 'file_name'] -``` - -1. **Syntax Description:** - - 1. select_expr, ... Columns retrieved and displayed in the result, when using an alias, as is optional. - - 2. select_expr, ... Retrieved target table (one or more tables (including temporary tables generated by subqueries) - - 3. where_definition retrieves the condition (expression), if there is a WHERE clause, the condition filters the row data. where_condition is an expression that evaluates to true for each row to be selected. Without the WHERE clause, the statement selects all rows. In WHERE expressions, you can use any MySQL supported functions and operators except aggregate functions - - 4. `ALL | DISTINCT ` : to refresh the result set, all is all, distinct/distinctrow will refresh the duplicate columns, the default is all - - 5. `ALL EXCEPT`: Filter on the full (all) result set, except specifies the name of one or more columns to be excluded from the full result set. All matching column names will be ignored in the output. - - 6. `INTO OUTFILE 'file_name' ` : save the result to a new file (which did not exist before), the difference lies in the save format. - - 7. `Group by having`: Group the result set, and brush the result of group by when having appears. `Grouping Sets`, `Rollup`, `Cube` are extensions of group by, please refer to [GROUPING SETS DESIGN](https://doris.apache.org/community/design/grouping_sets_design) for details. - - 8. `Order by`: Sort the final result, Order by sorts the result set by comparing the size of one or more columns. - - Order by is a time-consuming and resource-intensive operation, because all data needs to be sent to 1 node before it can be sorted, and the sorting operation requires more memory than the non-sorting operation. - - If you need to return the top N sorted results, you need to use the LIMIT clause; in order to limit memory usage, if the user does not specify the LIMIT clause, the first 65535 sorted results are returned by default. - - 9. `Limit n`: limit the number of lines in the output result, `limit m,n` means output n records starting from the mth line.You should use `order by` before you use `limit m,n`, otherwise the data may be inconsistent each time it is executed. - - 10. The `Having` clause does not filter the row data in the table, but filters the results produced by the aggregate function. - - Typically `having` is used with aggregate functions (eg :`COUNT(), SUM(), AVG(), MIN(), MAX()`) and `group by` clauses. - - 11. SELECT supports explicit partition selection using PARTITION containing a list of partitions or subpartitions (or both) following the name of the table in `table_reference` - - 12. `[TABLET tids] TABLESAMPLE n [ROWS | PERCENT] [REPEATABLE seek]`: Limit the number of rows read from the table in the FROM clause, select a number of Tablets pseudo-randomly from the table according to the specified number of rows or percentages, and specify the number of seeds in REPEATABLE to return the selected samples again. In addition, you can also manually specify the TableID, Note that this can only be used for OLAP tables. - - 13. `hint_statement`: hint in front of the selectlist indicates that hints can be used to influence the behavior of the optimizer in order to obtain the desired execution plan. Details refer to [joinHint using document] (https://doris.apache.org/en/docs/query-acceleration/hint/joinHint.md) - -**Syntax constraints:** - -1. SELECT can also be used to retrieve calculated rows without referencing any table. -2. All clauses must be ordered strictly according to the above format, and a HAVING clause must be placed after the GROUP BY clause and before the ORDER BY clause. -3. The alias keyword AS is optional. Aliases can be used for group by, order by and having -4. Where clause: The WHERE statement is executed to determine which rows should be included in the GROUP BY section, and HAVING is used to determine which rows in the result set should be used. -5. The HAVING clause can refer to the total function, but the WHERE clause cannot refer to, such as count, sum, max, min, avg, at the same time, the where clause can refer to other functions except the total function. Column aliases cannot be used in the Where clause to define conditions. -6. Group by followed by with rollup can count the results one or more times. - -**Join query:** - -Doris supports JOIN syntax - -```sql -JOIN -table_references: - table_reference [, table_reference] … -table_reference: - table_factor - | join_table -table_factor: - tbl_name [[AS] alias] - [{USE|IGNORE|FORCE} INDEX (key_list)] - | ( table_references ) - | { OJ table_reference LEFT OUTER JOIN table_reference - ON conditional_expr } -join_table: - table_reference [INNER | CROSS] JOIN table_factor [join_condition] - | table_reference LEFT [OUTER] JOIN table_reference join_condition - | table_reference NATURAL [LEFT [OUTER]] JOIN table_factor - | table_reference RIGHT [OUTER] JOIN table_reference join_condition - | table_reference NATURAL [RIGHT [OUTER]] JOIN table_factor -join_condition: - ON conditional_expr -``` - -**UNION Grammar:** - -```sql -SELECT ... -UNION [ALL| DISTINCT] SELECT ...... -[UNION [ALL| DISTINCT] SELECT ...] -``` - -`UNION` is used to combine the results of multiple `SELECT` statements into a single result set. - -The column names in the first `SELECT` statement are used as the column names in the returned results. The selected columns listed in the corresponding position of each `SELECT` statement should have the same data type. (For example, the first column selected by the first statement should be of the same type as the first column selected by other statements.) - -The default behavior of `UNION` is to remove duplicate rows from the result. The optional `DISTINCT` keyword has no effect other than the default, since it also specifies duplicate row removal. With the optional `ALL` keyword, no duplicate row removal occurs, and the result includes all matching rows in all `SELECT` statements - -**WITH statement**: - -To specify common table expressions, use the `WITH` clause with one or more comma-separated clauses. Each subclause provides a subquery that generates the result set and associates the name with the subquery. The following example defines `WITH` clauses in CTEs named `cte1` and `cte2`, and refers to the `WITH` clause below their top-level `SELECT`: - -```sql -WITH - cte1 AS (SELECT a,b FROM table1), - cte2 AS (SELECT c,d FROM table2) -SELECT b,d FROM cte1 JOIN cte2 -WHERE cte1.a = cte2.c; -``` - -In a statement containing the `WITH` clause, each CTE name can be referenced to access the corresponding CTE result set. - -CTE names can be referenced in other CTEs, allowing CTEs to be defined based on other CTEs. - -Recursive CTE is currently not supported. - -### example - -1. Query the names of students whose ages are 18, 20, 25 - - ```sql - select Name from student where age in (18,20,25); - ``` -2. ALL EXCEPT Example - ```sql - -- Query all information except the students' age - select * except(age) from student; - ``` - -3. GROUP BY Example - - ```sql - --Query the tb_book table, group by type, and find the average price of each type of book, - select type,avg(price) from tb_book group by type; - ``` - -4. DISTINCT Use - - ``` - --Query the tb_book table to remove duplicate type data - select distinct type from tb_book; - ``` - -5. ORDER BY Example - - Sort query results in ascending (default) or descending (DESC) order. Ascending NULL is first, descending NULL is last - - ```sql - --Query all records in the tb_book table, sort them in descending order by id, and display three records - select * from tb_book order by id desc limit 3; - ``` - -6. LIKE fuzzy query - - Can realize fuzzy query, it has two wildcards: `%` and `_`, `%` can match one or more characters, `_` can match one character - - ``` - --Find all books whose second character is h - select * from tb_book where name like('_h%'); - ``` - -7. LIMIT limits the number of result rows - - ```sql - --1. Display 3 records in descending order - select * from tb_book order by price desc limit 3; - - --2. Display 4 records from id=1 - select * from tb_book where id limit 1,4; - ``` - -8. CONCAT join multiple columns - - ```sql - --Combine name and price into a new string output - select id,concat(name,":",price) as info,type from tb_book; - ``` - -9. Using functions and expressions - - ```sql - --Calculate the total price of various books in the tb_book table - select sum(price) as total,type from tb_book group by type; - --20% off price - select *,(price * 0.8) as "20%" from tb_book; - ``` - -10. UNION Example - - ```sql - SELECT a FROM t1 WHERE a = 10 AND B = 1 ORDER by LIMIT 10 - UNION - SELECT a FROM t2 WHERE a = 11 AND B = 2 ORDER by LIMIT 10; - ``` - -11. WITH clause example - - ```sql - WITH cte AS - ( - SELECT 1 AS col1, 2 AS col2 - UNION ALL - SELECT 3, 4 - ) - SELECT col1, col2 FROM cte; - ``` - -12. JOIN Exampel - - ```sql - SELECT * FROM t1 LEFT JOIN (t2, t3, t4) - ON (t2.a = t1.a AND t3.b = t1.b AND t4.c = t1.c) - ``` - - Equivalent to - - ```sql - SELECT * FROM t1 LEFT JOIN (t2 CROSS JOIN t3 CROSS JOIN t4) - ON (t2.a = t1.a AND t3.b = t1.b AND t4.c = t1.c) - ``` - -13. INNER JOIN - - ```sql - SELECT t1.name, t2.salary - FROM employee AS t1 INNER JOIN info AS t2 ON t1.name = t2.name; - - SELECT t1.name, t2.salary - FROM employee t1 INNER JOIN info t2 ON t1.name = t2.name; - ``` - -14. LEFT JOIN - - ```sql - SELECT left_tbl.* - FROM left_tbl LEFT JOIN right_tbl ON left_tbl.id = right_tbl.id - WHERE right_tbl.id IS NULL; - ``` - -15. RIGHT JOIN - - ```sql - mysql> SELECT * FROM t1 RIGHT JOIN t2 ON (t1.a = t2.a); - +------+------+------+------+ - | a | b | a | c | - +------+------+------+------+ - | 2 | y | 2 | z | - | NULL | NULL | 3 | w | - +------+------+------+------+ - ``` - -16. TABLESAMPLE - - ```sql - --Pseudo-randomly sample 1000 rows in t1. Note that several Tablets are actually selected according to the statistics of the table, and the total number of selected Tablet rows may be greater than 1000, so if you want to explicitly return 1000 rows, you need to add Limit. - SELECT * FROM t1 TABLET(10001) TABLESAMPLE(1000 ROWS) REPEATABLE 2 limit 1000; - ``` - -### keywords - - SELECT - -### Best Practice - -1. ome additional knowledge about the SELECT clause - - - An alias can be specified for select_expr using AS alias_name. Aliases are used as column names in expressions and can be used in GROUP BY, ORDER BY or HAVING clauses. The AS keyword is a good habit to use when specifying aliases for columns. - - - table_references after FROM indicates one or more tables participating in the query. If more than one table is listed, a JOIN operation is performed. And for each specified table, you can define an alias for it - - - The selected column after SELECT can be referenced in ORDER IN and GROUP BY by column name, column alias or integer (starting from 1) representing the column position - - ```sql - SELECT college, region, seed FROM tournament - ORDER BY region, seed; - - SELECT college, region AS r, seed AS s FROM tournament - ORDER BY r, s; - - SELECT college, region, seed FROM tournament - ORDER BY 2, 3; - ``` - - - If ORDER BY appears in a subquery and also applies to the outer query, the outermost ORDER BY takes precedence. - - - If GROUP BY is used, the grouped columns are automatically sorted in ascending order (as if there was an ORDER BY statement followed by the same columns). If you want to avoid the overhead of GROUP BY due to automatic sorting, adding ORDER BY NULL can solve it: - - ```sql - SELECT a, COUNT(b) FROM test_table GROUP BY a ORDER BY NULL; - ``` - - - - - When sorting columns in a SELECT using ORDER BY or GROUP BY, the server sorts values using only the initial number of bytes indicated by the max_sort_length system variable. - - - Having clauses are generally applied last, just before the result set is returned to the MySQL client, and is not optimized. (while LIMIT is applied after HAVING) - - The SQL standard requires: HAVING must refer to a column in the GROUP BY list or used by an aggregate function. However, MySQL extends this by allowing HAVING to refer to columns in the Select clause list, as well as columns from outer subqueries. - - A warning is generated if the column referenced by HAVING is ambiguous. In the following statement, col2 is ambiguous: - - ```sql - SELECT COUNT(col1) AS col2 FROM t GROUP BY col2 HAVING col2 = 2; - ``` - - - Remember not to use HAVING where WHERE should be used. HAVING is paired with GROUP BY. - - - The HAVING clause can refer to aggregate functions, while WHERE cannot. - - ```sql - SELECT user, MAX(salary) FROM users - GROUP BY user HAVING MAX(salary) > 10; - ``` - - - The LIMIT clause can be used to constrain the number of rows returned by a SELECT statement. LIMIT can have one or two arguments, both of which must be non-negative integers. - - ```sql - /*Retrieve 6~15 rows in the result set*/ - SELECT * FROM tbl LIMIT 5,10; - /*Then if you want to retrieve all rows after a certain offset is set, you can set a very large constant for the second parameter. The following query fetches all data from row 96 onwards */ - SELECT * FROM tbl LIMIT 95,18446744073709551615; - /*If LIMIT has only one parameter, the parameter specifies the number of rows that should be retrieved, and the offset defaults to 0, that is, starting from the first row*/ - ``` - - - SELECT...INTO allows query results to be written to a file - -2. Modifiers of the SELECT keyword - - - deduplication - - The ALL and DISTINCT modifiers specify whether to deduplicate rows in the result set (should not be a column). - - ALL is the default modifier, that is, all rows that meet the requirements are to be retrieved. - - DISTINCT removes duplicate rows. - -2. The main advantage of subqueries - - - Subqueries allow structured queries so that each part of a statement can be isolated. - - Some operations require complex unions and associations. Subqueries provide other ways to perform these operations - -3. Speed up queries - - - Use Doris's partition and bucket as data filtering conditions as much as possible to reduce the scope of data scanning - - Make full use of Doris's prefix index fields as data filter conditions to speed up query speed - -4. UNION - - - Using only the union keyword has the same effect as using union disitnct. Since the deduplication work is more memory-intensive, the query speed using the union all operation will be faster and the memory consumption will be less. If users want to perform order by and limit operations on the returned result set, they need to put the union operation in the subquery, then select from subquery, and finally put the subquery and order by outside the subquery. - - ```sql - select * from (select age from student_01 union all select age from student_02) as t1 - order by age limit 4; - - +-------------+ - | age | - +-------------+ - | 18 | - | 19 | - | 20 | - | 21 | - +-------------+ - 4 rows in set (0.01 sec) - ``` - -6. JOIN - - - In the inner join condition, in addition to supporting equal-valued joins, it also supports unequal-valued joins. For performance reasons, it is recommended to use equal-valued joins. - - Other joins only support equivalent joins - diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/UPDATE.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/UPDATE.md deleted file mode 100644 index 63c62a704b0d8..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/UPDATE.md +++ /dev/null @@ -1,183 +0,0 @@ ---- -{ - "title": "UPDATE", - "language": "en" -} ---- - - - -## UPDATE - -### Name - -UPDATE - -### Description - -This statement is used to update the data. The UPDATE statement currently only supports the UNIQUE KEY model. - -The UPDATE operation currently only supports updating the Value column. The update of the Key column can refer to [Using FlinkCDC to update Key column](../../../../ecosystem/flink-doris-connector.md#use-flinkcdc-to-update-key-column). -#### Syntax - -```sql -[cte] -UPDATE target_table [table_alias] - SET assignment_list - [ FROM additional_tables] - WHERE condition -``` - -#### Required Parameters - -+ target_table: The target table of the data to be updated. Can be of the form 'db_name.table_name' -+ assignment_list: The target column to be updated, in the format 'col_name = value, col_name = value' -+ where condition: the condition that is expected to be updated, an expression that returns true or false can be - -#### Optional Parameters - -+ cte: Common Table Expression, eg 'WITH a AS SELECT * FROM tbl' -+ table_alias: alias of table -+ FROM additional_tables: Specifies one or more tables to use for selecting rows to update or for setting new values. Note that if you want use target table here, you should give it a alias explicitly. - -#### Note - -The current UPDATE statement only supports row updates on the UNIQUE KEY model. - -### Example - -The `test` table is a unique model table, which contains four columns: k1, k2, v1, v2. Where k1, k2 are keys, v1, v2 are values, and the aggregation method is Replace. - -1. Update the v1 column in the 'test' table that satisfies the conditions k1 =1 , k2 =2 to 1 - -```sql -UPDATE test SET v1 = 1 WHERE k1=1 and k2=2; -``` - -2. Increment the v1 column of the k1=1 column in the 'test' table by 1 - -```sql -UPDATE test SET v1 = v1+1 WHERE k1=1; -``` - -3. use the result of `t2` join `t3` to update `t1` - -```sql --- create t1, t2, t3 tables -CREATE TABLE t1 - (id INT, c1 BIGINT, c2 STRING, c3 DOUBLE, c4 DATE) -UNIQUE KEY (id) -DISTRIBUTED BY HASH (id) -PROPERTIES('replication_num'='1', "function_column.sequence_col" = "c4"); - -CREATE TABLE t2 - (id INT, c1 BIGINT, c2 STRING, c3 DOUBLE, c4 DATE) -DISTRIBUTED BY HASH (id) -PROPERTIES('replication_num'='1'); - -CREATE TABLE t3 - (id INT) -DISTRIBUTED BY HASH (id) -PROPERTIES('replication_num'='1'); - --- insert data -INSERT INTO t1 VALUES - (1, 1, '1', 1.0, '2000-01-01'), - (2, 2, '2', 2.0, '2000-01-02'), - (3, 3, '3', 3.0, '2000-01-03'); - -INSERT INTO t2 VALUES - (1, 10, '10', 10.0, '2000-01-10'), - (2, 20, '20', 20.0, '2000-01-20'), - (3, 30, '30', 30.0, '2000-01-30'), - (4, 4, '4', 4.0, '2000-01-04'), - (5, 5, '5', 5.0, '2000-01-05'); - -INSERT INTO t3 VALUES - (1), - (4), - (5); - --- update t1 -UPDATE t1 - SET t1.c1 = t2.c1, t1.c3 = t2.c3 * 100 - FROM t2 INNER JOIN t3 ON t2.id = t3.id - WHERE t1.id = t2.id; -``` - -the expect result is only update the row where id = 1 in table t1 - -``` -+----+----+----+--------+------------+ -| id | c1 | c2 | c3 | c4 | -+----+----+----+--------+------------+ -| 1 | 10 | 1 | 1000.0 | 2000-01-01 | -| 2 | 2 | 2 | 2.0 | 2000-01-02 | -| 3 | 3 | 3 | 3.0 | 2000-01-03 | -+----+----+----+--------+------------+ -``` - -4. using cte - -```sql -create table orders( - o_orderkey bigint, - o_totalprice decimal(15, 2) -) unique key(o_orderkey) -distributed by hash(o_orderkey) buckets 1 -properties ( - "replication_num" = "1" -); - -insert into orders values -(1, 34.1), -(2, 432.8); - -create table lineitem( - l_linenumber int, - o_orderkey bigint, - l_discount decimal(15, 2) -) unique key(l_linenumber) -distributed by hash(l_linenumber) buckets 1 -properties ( - "replication_num" = "1" -); - -insert into lineitem values -(1, 1, 1.23), -(2, 1, 3.21), -(3, 2, 18.08), -(4, 2, 23.48); - -with discount_orders as ( - select * from orders - where o_totalprice > 100 -) -update lineitem set l_discount = l_discount*0.9 -from discount_orders -where lineitem.o_orderkey = discount_orders.o_orderkey; -``` - -### Keywords - - UPDATE - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/OUTFILE.md b/docs/sql-manual/sql-statements/Data-Manipulation-Statements/OUTFILE.md deleted file mode 100644 index 9d3ba368db606..0000000000000 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/OUTFILE.md +++ /dev/null @@ -1,416 +0,0 @@ ---- -{ - "title": "OUTFILE", - "language": "en" -} ---- - - - -## OUTFILE -### Name - -OUTFILE - -### description - -This statement is used to export query results to a file using the `SELECT INTO OUTFILE` command. Currently, it supports exporting to remote storage, such as HDFS, S3, BOS, COS (Tencent Cloud), through the Broker process, S3 protocol, or HDFS protocol. - -#### grammar: - -```sql -query_stmt -INTO OUTFILE "file_path" -[format_as] -[properties] -``` - -#### illustrate: - -1. file_path - - file_path points to the path where the file is stored and the file prefix. Such as `hdfs://path/to/my_file_`. - - ``` - The final filename will consist of `my_file_`, the file number and the file format suffix. The file serial number starts from 0, and the number is the number of files to be divided. Such as: - - my_file_abcdefg_0.csv - my_file_abcdefg_1.csv - my_file_abcdegf_2.csv - ``` - You can also omit the file prefix and specify only the file directory, such as: `hdfs://path/to/` - -2. format_as - - ``` - FORMAT AS CSV - ``` - - Specifies the export format. Supported formats include CSV, PARQUET, CSV_WITH_NAMES, CSV_WITH_NAMES_AND_TYPES and ORC. Default is CSV. - > Note: PARQUET, CSV_WITH_NAMES, CSV_WITH_NAMES_AND_TYPES, and ORC are supported starting in version 1.2 . - -3. properties - - Specify related properties. Currently exporting via the Broker process, S3 protocol, or HDFS protocol is supported. - - ``` - grammar: - [PROPERTIES ("key"="value", ...)] - The following properties are supported: - - File related properties - column_separator: column separator,is only for CSV format. mulit-bytes is supported starting in version 1.2, such as: "\\x01", "abc". - line_delimiter: line delimiter,is only for CSV format. mulit-bytes supported starting in version 1.2, such as: "\\x01", "abc". - max_file_size: the size limit of a single file, if the result exceeds this value, it will be cut into multiple files, the value range of max_file_size is [5MB, 2GB] and the default is 1GB. (When specified that the file format is ORC, the size of the actual division file will be a multiples of 64MB, such as: specify max_file_size = 5MB, and actually use 64MB as the division; specify max_file_size = 65MB, and will actually use 128MB as cut division points.) - delete_existing_files: default `false`. If it is specified as true, you will first delete all files specified in the directory specified by the file_path, and then export the data to the directory.For example: "file_path" = "/user/tmp", then delete all files and directory under "/user/"; "file_path" = "/user/tmp/", then delete all files and directory under "/user/tmp/" - file_suffix: Specify the suffix of the export file. If this parameter is not specified, the default suffix for the file format will be used. - compress_type: When specifying the export file format as Parquet or ORC, you can choose the compression method for the Parquet or ORC files. For Parquet file format, you can specify the compression method as SNAPPY, GZIP, BROTLI, ZSTD, LZ4, or PLAIN, with the default being SNAPPY. For ORC file format, you can specify the compression method as PLAIN, SNAPPY, ZLIB, or ZSTD, with the default being ZLIB. This parameter is supported starting from version 2.1.5. (PLAIN means no compression is used.) - - Broker related properties need to be prefixed with `broker.`: - broker.name: broker name - broker.hadoop.security.authentication: specify the authentication method as kerberos - broker.kerberos_principal: specifies the principal of kerberos - broker.kerberos_keytab: specifies the path to the keytab file of kerberos. The file must be the absolute path to the file on the server where the broker process is located. and can be accessed by the Broker process - - HDFS related properties: - fs.defaultFS: namenode address and port - hadoop.username: hdfs username - dfs.nameservices: if hadoop enable HA, please set fs nameservice. See hdfs-site.xml - dfs.ha.namenodes.[nameservice ID]:unique identifiers for each NameNode in the nameservice. See hdfs-site.xml - dfs.namenode.rpc-address.[nameservice ID].[name node ID]: the fully-qualified RPC address for each NameNode to listen on. See hdfs-site.xml - dfs.client.failover.proxy.provider.[nameservice ID]:the Java class that HDFS clients use to contact the Active NameNode, usually it is org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider - - For a kerberos-authentication enabled Hadoop cluster, additional properties need to be set: - dfs.namenode.kerberos.principal: HDFS namenode service principal - hadoop.security.authentication: kerberos - hadoop.kerberos.principal: the Kerberos pincipal that Doris will use when connectiong to HDFS. - hadoop.kerberos.keytab: HDFS client keytab location. - - For the S3 protocol, you can directly execute the S3 protocol configuration: - s3.endpoint - s3.access_key - s3.secret_key - s3.region - use_path_style: (optional) default false . The S3 SDK uses the virtual-hosted style by default. However, some object storage systems may not be enabled or support virtual-hosted style access. At this time, we can add the use_path_style parameter to force the use of path style access method. - ``` - - > Note that to use the `delete_existing_files` parameter, you also need to add the configuration `enable_delete_existing_files = true` to the fe.conf file and restart the FE. Only then will the `delete_existing_files` parameter take effect. Setting `delete_existing_files = true` is a dangerous operation and it is recommended to only use it in a testing environment. - -4. Data Types for Export - - All file formats support the export of basic data types, while only csv/orc/csv_with_names/csv_with_names_and_types currently support the export of complex data types (ARRAY/MAP/STRUCT). Nested complex data types are not supported. - -5. Concurrent Export - - Setting the session variable `set enable_parallel_outfile = true;` enables concurrent export using outfile. For detailed usage, see [Export Query Result](../../../data-operate/export/outfile.md). - -6. Export to Local - - To export to a local file, you need configure `enable_outfile_to_local=true` in fe.conf. - - ```sql - select * from tbl1 limit 10 - INTO OUTFILE "file:///home/work/path/result_"; - ``` - -#### Explanation of the returned results: - -- **FileNumber**: The number of generated files. -- **TotalRows**: The number of rows in the result set. -- **FileSize**: The total size of the exported files in bytes. -- **URL**: The prefix of the exported file paths. Multiple files will be numbered sequentially with suffixes `_0`, `_1`, etc. - -#### DataType Mapping - -Parquet and ORC file formats have their own data types. The export function of Doris can automatically export the Doris data types to the corresponding data types of the Parquet/ORC file format. The following are the data type mapping relationship of the Doris data types and the Parquet/ORC file format data types: - -1. The mapping relationship between the Doris data types to the ORC data types is: - - | Doris Type | Orc Type | - | --- | --- | - | boolean | boolean | - | tinyint | tinyint | - | smallint | smallint | - | int | int | - | bigint | bigint | - | largeInt | string | - | date | string | - | datev2 | string | - | datetime | string | - | datetimev2 | timestamp | - | float | float | - | double | double | - | char / varchar / string | string | - | decimal | decimal | - | struct | struct | - | map | map | - | array | array | - -2. When Doris exports data to the Parquet file format, the Doris memory data will be converted to Arrow memory data format first, and then the paraquet file format is written by Arrow. The mapping relationship between the Doris data types to the ARROW data types is: - - | Doris Type | Arrow Type | - | --- | --- | - | boolean | boolean | - | tinyint | int8 | - | smallint | int16 | - | int | int32 | - | bigint | int64 | - | largeInt | utf8 | - | date | utf8 | - | datev2 | utf8 | - | datetime | utf8 | - | datetimev2 | utf8 | - | float | float32 | - | double | float64 | - | char / varchar / string | utf8 | - | decimal | decimal128 | - | struct | struct | - | map | map | - | array | list | - - - - -### example - -1. Use the broker method to export, and export the simple query results to the file `hdfs://path/to/result.txt`. Specifies that the export format is CSV. Use `my_broker` and set kerberos authentication information. Specify the column separator as `,` and the row separator as `\n`. - - ```sql - SELECT * FROM tbl - INTO OUTFILE "hdfs://path/to/result_" - FORMAT AS CSV - PROPERTIES - ( - "broker.name" = "my_broker", - "broker.hadoop.security.authentication" = "kerberos", - "broker.kerberos_principal" = "doris@YOUR.COM", - "broker.kerberos_keytab" = "/home/doris/my.keytab", - "column_separator" = ",", - "line_delimiter" = "\n", - "max_file_size" = "100MB" - ); - ``` - - If the final generated file is not larger than 100MB, it will be: `result_0.csv`. - If larger than 100MB, it may be `result_0.csv, result_1.csv, ...`. - -2. Export the simple query results to the file `hdfs://path/to/result.parquet`. Specify the export format as PARQUET. Use `my_broker` and set kerberos authentication information. - - ```sql - SELECT c1, c2, c3 FROM tbl - INTO OUTFILE "hdfs://path/to/result_" - FORMAT AS PARQUET - PROPERTIES - ( - "broker.name" = "my_broker", - "broker.hadoop.security.authentication" = "kerberos", - "broker.kerberos_principal" = "doris@YOUR.COM", - "broker.kerberos_keytab" = "/home/doris/my.keytab" - ); - ``` - -3. Export the query result of the CTE statement to the file `hdfs://path/to/result.txt`. The default export format is CSV. Use `my_broker` and set hdfs high availability information. Use the default row and column separators. - - ```sql - WITH - x1 AS - (SELECT k1, k2 FROM tbl1), - x2 AS - (SELECT k3 FROM tbl2) - SELEC k1 FROM x1 UNION SELECT k3 FROM x2 - INTO OUTFILE "hdfs://path/to/result_" - PROPERTIES - ( - "broker.name" = "my_broker", - "broker.username"="user", - "broker.password"="passwd", - "broker.dfs.nameservices" = "my_ha", - "broker.dfs.ha.namenodes.my_ha" = "my_namenode1, my_namenode2", - "broker.dfs.namenode.rpc-address.my_ha.my_namenode1" = "nn1_host:rpc_port", - "broker.dfs.namenode.rpc-address.my_ha.my_namenode2" = "nn2_host:rpc_port", - "broker.dfs.client.failover.proxy.provider.my_ha" = "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider" - ); - ``` - - If the final generated file is not larger than 1GB, it will be: `result_0.csv`. - If larger than 1GB, it may be `result_0.csv, result_1.csv, ...`. - -4. Export the query result of the UNION statement to the file `bos://bucket/result.txt`. Specify the export format as PARQUET. Use `my_broker` and set hdfs high availability information. The PARQUET format does not require a column delimiter to be specified. - After the export is complete, an identity file is generated. - - ```sql - SELECT k1 FROM tbl1 UNION SELECT k2 FROM tbl1 - INTO OUTFILE "bos://bucket/result_" - FORMAT AS PARQUET - PROPERTIES - ( - "broker.name" = "my_broker", - "broker.bos_endpoint" = "http://bj.bcebos.com", - "broker.bos_accesskey" = "xxxxxxxxxxxxxxxxxxxxxxxxxxx", - "broker.bos_secret_accesskey" = "yyyyyyyyyyyyyyyyyyyyyyyyy" - ); - ``` - -5. Export the query result of the select statement to the file `s3a://${bucket_name}/path/result.txt`. Specify the export format as csv. - After the export is complete, an identity file is generated. - - ```sql - select k1,k2,v1 from tbl1 limit 100000 - into outfile "s3a://my_bucket/export/my_file_" - FORMAT AS CSV - PROPERTIES - ( - "broker.name" = "hdfs_broker", - "broker.fs.s3a.access.key" = "xxx", - "broker.fs.s3a.secret.key" = "xxxx", - "broker.fs.s3a.endpoint" = "https://cos.xxxxxx.myqcloud.com/", - "column_separator" = ",", - "line_delimiter" = "\n", - "max_file_size" = "1024MB", - "success_file_name" = "SUCCESS" - ) - ``` - - If the final generated file is not larger than 1GB, it will be: `my_file_0.csv`. - If larger than 1GB, it may be `my_file_0.csv, result_1.csv, ...`. - Verify on cos - - 1. A path that does not exist will be automatically created - 2. Access.key/secret.key/endpoint needs to be confirmed with students of cos. Especially the value of endpoint does not need to fill in bucket_name. - -6. Use the s3 protocol to export to bos, and enable concurrent export. - - ```sql - set enable_parallel_outfile = true; - select k1 from tb1 limit 1000 - into outfile "s3://my_bucket/export/my_file_" - format as csv - properties - ( - "s3.endpoint" = "http://s3.bd.bcebos.com", - "s3.access_key" = "xxxx", - "s3.secret_key" = "xxx", - "s3.region" = "bd" - ) - ``` - - The resulting file is prefixed with `my_file_{fragment_instance_id}_`. - -7. Use the s3 protocol to export to bos, and enable concurrent export of session variables. - Note: However, since the query statement has a top-level sorting node, even if the concurrently exported session variable is enabled for this query, it cannot be exported concurrently. - - ```sql - set enable_parallel_outfile = true; - select k1 from tb1 order by k1 limit 1000 - into outfile "s3://my_bucket/export/my_file_" - format as csv - properties - ( - "s3.endpoint" = "http://s3.bd.bcebos.com", - "s3.access_key" = "xxxx", - "s3.secret_key" = "xxx", - "s3.region" = "bd" - ) - ``` - -8. Use hdfs export to export simple query results to the file `hdfs://${host}:${fileSystem_port}/path/to/result.txt`. Specify the export format as CSV and the user name as work. Specify the column separator as `,` and the row separator as `\n`. - - ```sql - -- the default port of fileSystem_port is 9000 - SELECT * FROM tbl - INTO OUTFILE "hdfs://${host}:${fileSystem_port}/path/to/result_" - FORMAT AS CSV - PROPERTIES - ( - "fs.defaultFS" = "hdfs://ip:port", - "hadoop.username" = "work" - ); - ``` - - If the Hadoop cluster is highly available and Kerberos authentication is enabled, you can refer to the following SQL statement: - - ```sql - SELECT * FROM tbl - INTO OUTFILE "hdfs://path/to/result_" - FORMAT AS CSV - PROPERTIES - ( - 'fs.defaultFS'='hdfs://hacluster/', - 'dfs.nameservices'='hacluster', - 'dfs.ha.namenodes.hacluster'='n1,n2', - 'dfs.namenode.rpc-address.hacluster.n1'='192.168.0.1:8020', - 'dfs.namenode.rpc-address.hacluster.n2'='192.168.0.2:8020', - 'dfs.client.failover.proxy.provider.hacluster'='org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider', - 'dfs.namenode.kerberos.principal'='hadoop/_HOST@REALM.COM' - 'hadoop.security.authentication'='kerberos', - 'hadoop.kerberos.principal'='doris_test@REALM.COM', - 'hadoop.kerberos.keytab'='/path/to/doris_test.keytab' - ); - - If the final generated file is not larger than 100MB, it will be: `result_0.csv`. - If larger than 100MB, it may be `result_0.csv, result_1.csv, ...`. - -9. Export the query result of the select statement to the file `cosn://${bucket_name}/path/result.txt` on Tencent Cloud Object Storage (COS). Specify the export format as csv. - After the export is complete, an identity file is generated. - - ```sql - select k1,k2,v1 from tbl1 limit 100000 - into outfile "cosn://my_bucket/export/my_file_" - FORMAT AS CSV - PROPERTIES - ( - "broker.name" = "broker_name", - "broker.fs.cosn.userinfo.secretId" = "xxx", - "broker.fs.cosn.userinfo.secretKey" = "xxxx", - "broker.fs.cosn.bucket.endpoint_suffix" = "cos.xxxxxx.myqcloud.com", - "column_separator" = ",", - "line_delimiter" = "\n", - "max_file_size" = "1024MB", - "success_file_name" = "SUCCESS" - ) - ``` - -### keywords - -OUTFILE - -### Best Practice - -1. Export data volume and export efficiency - - This function essentially executes an SQL query command. The final result is a single-threaded output. Therefore, the time-consuming of the entire export includes the time-consuming of the query itself and the time-consuming of writing the final result set. If the query is large, you need to set the session variable `query_timeout` to appropriately extend the query timeout. - -2. Management of export files - - Doris does not manage exported files. Including the successful export, or the remaining files after the export fails, all need to be handled by the user. - -3. Export to local file - - The ability to export to a local file is not available for public cloud users, only for private deployments. And the default user has full control over the cluster nodes. Doris will not check the validity of the export path filled in by the user. If the process user of Doris does not have write permission to the path, or the path does not exist, an error will be reported. At the same time, for security reasons, if a file with the same name already exists in this path, the export will also fail. - - Doris does not manage files exported locally, nor does it check disk space, etc. These files need to be managed by the user, such as cleaning and so on. - -4. Results Integrity Guarantee - - This command is a synchronous command, so it is possible that the task connection is disconnected during the execution process, so that it is impossible to live the exported data whether it ends normally, or whether it is complete. At this point, you can use the `success_file_name` parameter to request that a successful file identifier be generated in the directory after the task is successful. Users can use this file to determine whether the export ends normally. - -5. Other Points to Note - - See [Export Query Result](../../../data-operate/export/outfile.md) \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CANCEL-REBALANCE-DISK.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CANCEL-REBALANCE-DISK.md deleted file mode 100644 index 28acb5eba1cb8..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CANCEL-REBALANCE-DISK.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -{ - "title": "ADMIN-CANCEL-REBALANCE-DISK", - "language": "en" -} ---- - - - -## ADMIN-CANCEL-REBALANCE-DISK - -### Name - -ADMIN CANCEL REBALANCE DISK - -### Description - -This statement is used to cancel rebalancing disks of specified backends with high priority - -Grammar: - -ADMIN CANCEL REBALANCE DISK [ON ("BackendHost1:BackendHeartBeatPort1", "BackendHost2:BackendHeartBeatPort2", ...)]; - -Explain: - -1. This statement only indicates that the system no longer rebalance disks of specified backends with high priority. The system will still rebalance disks by default scheduling. - -### Example - -1. Cancel High Priority Disk Rebalance of all of backends of the cluster - -ADMIN CANCEL REBALANCE DISK; - -2. Cancel High Priority Disk Rebalance of specified backends - -ADMIN CANCEL REBALANCE DISK ON ("192.168.1.1:1234", "192.168.1.2:1234"); - -### Keywords - -ADMIN,CANCEL,REBALANCE DISK - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CANCEL-REPAIR.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CANCEL-REPAIR.md deleted file mode 100644 index 6308d9809415d..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CANCEL-REPAIR.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -{ - "title": "ADMIN-CANCEL-REPAIR", - "language": "en" -} ---- - - - -## ADMIN-CANCEL-REPAIR - -### Name - -ADMIN CANCEL REPAIR - -### Description - -This statement is used to cancel the repair of the specified table or partition with high priority - -grammar: - -```sql -ADMIN CANCEL REPAIR TABLE table_name[ PARTITION (p1,...)]; -``` - -illustrate: - -1. This statement simply means that the system will no longer repair shard copies of the specified table or partition with high priority. Replicas are still repaired with the default schedule. - -### Example - - 1. Cancel high priority repair - - ```sql - ADMIN CANCEL REPAIR TABLE tbl PARTITION(p1); - ``` - -### Keywords - - ADMIN, CANCEL, REPAIR - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CHECK-TABLET.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CHECK-TABLET.md deleted file mode 100644 index 4c9ce77e6bc4e..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CHECK-TABLET.md +++ /dev/null @@ -1,67 +0,0 @@ ---- -{ - "title": "ADMIN-CHECK-TABLET", - "language": "en" -} ---- - - - -## ADMIN-CHECK-TABLET - -### Name - -ADMIN CHECK TABLET - -### Description - -This statement is used to perform the specified check operation on a set of tablets. - -grammar: - -```sql -ADMIN CHECK TABLET (tablet_id1, tablet_id2, ...) -PROPERTIES("type" = "..."); -``` - -illustrate: - -1. A list of tablet ids must be specified along with the type property in PROPERTIES. -2. Type only supports: - - * consistency: Check the consistency of the replica of the tablet. This command is an asynchronous command. After sending, Doris will start to execute the consistency check job of the corresponding tablet. The final result will be reflected in the InconsistentTabletNum column in the result of `SHOW PROC "/cluster_health/tablet_health";`. - - -### Example - -1. Perform a replica data consistency check on a specified set of tablets. - - ``` - ADMIN CHECK TABLET (10000, 10001) - PROPERTIES("type" = "consistency"); - ``` - -### Keywords - - ADMIN, CHECK, TABLET - -### Best Practice - - diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CLEAN-TRASH.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CLEAN-TRASH.md deleted file mode 100644 index c7baf24018567..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CLEAN-TRASH.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -{ - "title": "ADMIN-CLEAN-TRASH", - "language": "en" -} - - ---- - - - -## ADMIN-CLEAN-TRASH - -### Name - -ADMIN CLEAN TRASH - -### Description - -This statement is used to clean up garbage data in the backend - -grammar: - -```sql -ADMIN CLEAN TRASH [ON ("BackendHost1:BackendHeartBeatPort1", "BackendHost2:BackendHeartBeatPort2", ...)]; -``` - -illustrate: - -1. Use BackendHost:BackendHeartBeatPort to indicate the backend that needs to be cleaned up, and clean up all backends without adding the on limit. - -### Example - -1. Clean up the junk data of all be nodes. - - ADMIN CLEAN TRASH; - -2. Clean up the junk data of '192.168.0.1:9050' and '192.168.0.2:9050'. - - ADMIN CLEAN TRASH ON ("192.168.0.1:9050","192.168.0.2:9050"); - -### Keywords \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-COPY-TABLET.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-COPY-TABLET.md deleted file mode 100644 index dc30a5f327837..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-COPY-TABLET.md +++ /dev/null @@ -1,101 +0,0 @@ ---- -{ - "title": "ADMIN-COPY-TABLET", - "language": "en" -} ---- - - - -## ADMIN-COPY-TABLET - -### Name - -ADMIN COPY TABLET - -### Description - -This statement is used to make a snapshot for the specified tablet, mainly used to load the tablet locally to reproduce the problem. - -syntax: - -```sql -ADMIN COPY TABLET tablet_id PROPERTIES("xxx"); -``` - -Notes: - -This command requires ROOT privileges. - -PROPERTIES supports the following properties: - -1. backend_id: Specifies the id of the BE node where the replica is located. If not specified, a replica is randomly selected. - -2. version: Specifies the version of the snapshot. The version must be less than or equal to the largest version of the replica. If not specified, the largest version is used. - -3. expiration_minutes: Snapshot retention time. The default is 1 hour. It will automatically clean up after a timeout. Unit minutes. - -The results are shown below: - -``` - TabletId: 10020 - BackendId: 10003 - Ip: 192.168.10.1 - Path: /path/to/be/storage/snapshot/20220830101353.2.3600 -ExpirationMinutes: 60 - CreateTableStmt: CREATE TABLE `tbl1` ( - `k1` int(11) NULL, - `k2` int(11) NULL -) ENGINE=OLAP -DUPLICATE KEY(`k1`, `k2`) -DISTRIBUTED BY HASH(k1) BUCKETS 1 -PROPERTIES ( -"replication_num" = "1", -"version_info" = "2" -); -``` - -* TabletId: tablet id -* BackendId: BE node id -* Ip: BE node ip -* Path: The directory where the snapshot is located -* ExpirationMinutes: snapshot expiration time -* CreateTableStmt: The table creation statement for the table corresponding to the tablet. This statement is not the original table-building statement, but a simplified table-building statement for later loading the tablet locally. - -### Example - -1. Take a snapshot of the replica on the specified BE node - - ```sql - ADMIN COPY TABLET 10010 PROPERTIES("backend_id" = "10001"); - ``` - -2. Take a snapshot of the specified version of the replica on the specified BE node - - ```sql - ADMIN COPY TABLET 10010 PROPERTIES("backend_id" = "10001", "version" = "10"); - ``` - -### Keywords - - ADMIN, COPY, TABLET - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-REBALANCE-DISK.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-REBALANCE-DISK.md deleted file mode 100644 index 1d1d551e9a5f8..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-REBALANCE-DISK.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -{ - "title": "ADMIN-REBALANCE-DISK", - "language": "en" -} ---- - - - -## ADMIN-REBALANCE-DISK - -### Name - -ADMIN REBALANCE DISK - -### Description - -This statement is used to try to rebalance disks of the specified backends first, no matter if the cluster is balanced - -Grammar: - -``` -ADMIN REBALANCE DISK [ON ("BackendHost1:BackendHeartBeatPort1", "BackendHost2:BackendHeartBeatPort2", ...)]; -``` - -Explain: - -1. This statement only means that the system attempts to rebalance disks of specified backends with high priority, no matter if the cluster is balanced. -2. The default timeout is 24 hours. Timeout means that the system will no longer rebalance disks of specified backends with high priority. The command settings need to be reused. - -### Example - -1. Attempt to rebalance disks of all backends - -``` -ADMIN REBALANCE DISK; -``` - -2. Attempt to rebalance disks oof the specified backends - -``` -ADMIN REBALANCE DISK ON ("192.168.1.1:1234", "192.168.1.2:1234"); -``` - -### Keywords - -ADMIN,REBALANCE,DISK - -### Best Practice \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-REPAIR-TABLE.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-REPAIR-TABLE.md deleted file mode 100644 index 928358a988551..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-REPAIR-TABLE.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -{ - "title": "ADMIN-REPAIR-TABLE", - "language": "en" -} ---- - - - -## ADMIN-REPAIR-TABLE - -### Name - -ADMIN REPAIR TABLE - -### Description - -statement used to attempt to preferentially repair the specified table or partition - -grammar: - -```sql -ADMIN REPAIR TABLE table_name[ PARTITION (p1,...)] -``` - -illustrate: - -1. This statement only means to let the system try to repair the shard copy of the specified table or partition with high priority, and does not guarantee that the repair can be successful. Users can view the repair status through the SHOW REPLICA STATUS command. -2. The default timeout is 14400 seconds (4 hours). A timeout means that the system will no longer repair shard copies of the specified table or partition with high priority. Need to re-use this command to set - -### Example - -1. Attempt to repair the specified table - - ADMIN REPAIR TABLE tbl1; - -2. Try to repair the specified partition - - ADMIN REPAIR TABLE tbl1 PARTITION (p1, p2); - -### Keywords - - ADMIN, REPAIR, TABLE - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-CONFIG.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-CONFIG.md deleted file mode 100644 index 1683a87a114f7..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-CONFIG.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -{ - "title": "ADMIN-SET-CONFIG", - "language": "en" -} ---- - - - -## ADMIN-SET-CONFIG - -### Name - -ADMIN SET CONFIG - -### Description - -This statement is used to set the configuration items of the cluster (currently only supports setting FE configuration items). - -The configurable items can be viewed using the `SHOW FRONTEND CONFIG;` command. - -Syntax: - -```sql -ADMIN SET FRONTEND CONFIG ("key" = "value") [ALL]; --- or -ADMIN SET ALL FRONTENDS CONFIG ("key" = "value"); -``` - -:::tip Explanation - -- Starting from versions 2.0.11 and 2.1.5, the `ALL` keyword is supported. When using the `ALL` keyword, the configuration parameters will be applied to all FEs (except for the `master_only` parameter). -- This syntax does not persistently modify the configuration. After an FE restarts, the modified configuration becomes invalid. To persist the changes, the configuration items need to be synchronously added in fe.conf. -::: - -### Example - -1. Set `disable_balance` to true - - `ADMIN SET FRONTEND CONFIG ("disable_balance" = "true");` - -### Keywords - -ADMIN, SET, CONFIG - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md deleted file mode 100644 index 14e63036bdc3b..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md +++ /dev/null @@ -1,67 +0,0 @@ ---- -{ - "title": "ADMIN-SET-PARTITION-VERSION", - "language": "en" -} ---- - - - -## ADMIN-SET-PARTITION-VERSION - -### Name - -ADMIN SET PARTITION VERSION - -### Description - -This statement is used to set the version of the specified partition. - -In certain cases, the version of the partition in the metadata may not be consistent with the version of the actual replica. This command can manually set the version of the partition in the metadata. - -grammar: - -```sql -ADMIN SET TABLE table_name PARTITION VERSION - PROPERTIES ("key" = "value", ...); -``` - -The following properties are currently supported: - -1. "partition_id": Required. Specify a Partition Id. -2. "visible_version": Required. Specify Version. - -> Note: -> -> It is necessary to first confirm the version of the actual replica on the Be before set the version of the partition. This command is generally only used for emergency troubleshooting, please proceed with caution. - -### Example - -1. Set the version of partition 1769152 to 100. - -```sql -ADMIN SET TABLE tbl1 PARTITION VERSION PROPERTIES("partition_id" = "1769152", "visible_version" = "100"); -``` - -### Keywords - - ADMIN, SET, PARTITION, VERSION - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-REPLICA-STATUS.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-REPLICA-STATUS.md deleted file mode 100644 index 0a04039b3ca66..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-REPLICA-STATUS.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -{ - "title": "ADMIN-SET-REPLICA-STATUS", - "language": "en" -} ---- - - - -## ADMIN-SET-REPLICA-STATUS - -### Name - -ADMIN SET REPLICA STATUS - -### Description - -This statement is used to set the state of the specified replica. - -This command is currently only used to manually set the status of certain replicas to BAD, DROP or OK, allowing the system to automatically repair these replicas - -grammar: - -```sql -ADMIN SET REPLICA STATUS - PROPERTIES ("key" = "value", ...); -``` - - The following properties are currently supported: - -1. "tablet_id": Required. Specify a Tablet Id. -2. "backend_id": Required. Specify Backend Id. -3. "status": Required. Specifies the state. Currently only "bad", "drop" or "ok" are supported - -If the specified replica does not exist, or the status is already bad, it will be ignored. - -> Note: -> -> A replica set to Bad, it will not be able to read or write. In addition, sometimes the setting may not working, when be report tablet ok, fe will auto change its status to ok. This operation may delete the replica immediately, so please operate with caution. -> -> A replica set to Drop, it can still be read and written. A healthy replica will be added to other machines first, and then this replica will be deleted. Compared with setting Bad, setting Drop is safer. - -### Example - - 1. Set the replica status of tablet 10003 on BE 10001 to bad. - - ```sql - ADMIN SET REPLICA STATUS PROPERTIES("tablet_id" = "10003", "backend_id" = "10001", "status" = "bad"); - ``` - - 2. Set the replica status of tablet 10003 on BE 10001 to drop. - - ```sql - ADMIN SET REPLICA STATUS PROPERTIES("tablet_id" = "10003", "backend_id" = "10001", "status" = "drop"); - ``` - - - 3. Set the replica status of tablet 10003 on BE 10001 to ok. - - ```sql - ADMIN SET REPLICA STATUS PROPERTIES("tablet_id" = "10003", "backend_id" = "10001", "status" = "ok"); - ``` - -### Keywords - - ADMIN, SET, REPLICA, STATUS - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-REPLICA-VERSION.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-REPLICA-VERSION.md deleted file mode 100644 index aae7f93bbfa34..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-REPLICA-VERSION.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -{ - "title": "ADMIN-SET-REPLICA-VERSION", - "language": "en" -} ---- - - - -## ADMIN-SET-REPLICA-VERSION - -### Name - -ADMIN SET REPLICA VERSION - -### Description - -This statement is used to set the version, maximum success version, and maximum failure version of the specified replica. - -This command is currently only used to manually repair the replica version when the program is abnormal, so that the replica can recover from the abnormal state. - -grammar: - -```sql -ADMIN SET REPLICA VERSION - PROPERTIES ("key" = "value", ...); -``` - -The following properties are currently supported: - -1. `tablet_id`: Required. Specify a Tablet Id. -2. `backend_id`: Required. Specify Backend Id. -3. `version`: Optional. Set the replica version. -4. `last_success_version`: Optional. Set the replica max success version. -5. `last_failed_version`: Optional. Set the replica max failed version. - -If the specified replica does not exist, it will be ignored. - -> Note: -> -> Modifying these values ​​may cause subsequent data reading and writing failures, resulting in data inconsistency. Please operate with caution! -> -> Record the original value before modifying it. After the modification is completed, verify the read and write of the table. If the read and write fail, please restore the original value! But recovery may fail! -> -> It is strictly prohibited to operate the tablet that is writing data! - -### Example - - 1. Clear the replica failed version of tablet 10003 on BE 10001. - - ```sql -ADMIN SET REPLICA VERSION PROPERTIES("tablet_id" = "10003", "backend_id" = "10001", "last_failed_version" = "-1"); - ``` - -2. Set the replica status of tablet 10003 on BE 10001 to ok. - -```sql -ADMIN SET REPLICA VERSION PROPERTIES("tablet_id" = "10003", "backend_id" = "10001", "version" = "1004"); -``` - -### Keywords - - ADMIN, SET, REPLICA, VERSION - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-TABLE-STATUS.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-TABLE-STATUS.md deleted file mode 100644 index 088ed699e442b..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-TABLE-STATUS.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -{ - "title": "ADMIN-SET-TABLE-STATUS", - "language": "en" -} ---- - - - -## ADMIN-SET-TABLE-STATUS - -### Name - -ADMIN SET TABLE STATUS - -### Description - -This statement is used to set the state of the specified table. Only supports OLAP tables. - -This command is currently only used to manually set the OLAP table state to the specified state, allowing some jobs that are stuck by the table state to continue running. - -grammar: - -```sql -ADMIN SET TABLE table_name STATUS - PROPERTIES ("key" = "value", ...); -``` - -The following properties are currently supported: - -1. "state":Required. Specifying a target state then the state of the OLAP table will change to this state. - -> The current target states include: -> -> 1. NORMAL -> 2. ROLLUP -> 3. SCHEMA_CHANGE -> 4. BACKUP -> 5. RESTORE -> 6. WAITING_STABLE -> -> If the current state of the table is already the specified state, it will be ignored. - -**Note: This command is generally only used for emergency fault repair, please proceed with caution.** - -### Example - -1. Set the state of table tbl1 to NORMAL. - -```sql -admin set table tbl1 status properties("state" = "NORMAL"); -``` - -2. Set the state of table tbl2 to SCHEMA_CHANGE - -```sql -admin set table test_set_table_status status properties("state" = "SCHEMA_CHANGE"); -``` - -### Keywords - - ADMIN, SET, TABLE, STATUS - -### Best Practice \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/INSTALL-PLUGIN.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/INSTALL-PLUGIN.md deleted file mode 100644 index a2b766be19444..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/INSTALL-PLUGIN.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -{ - "title": "INSTALL-PLUGIN", - "language": "en" -} ---- - - - -## INSTALL-PLUGIN - -### Name - -INSTALL PLUGIN - -### Description - -This statement is used to install a plugin. - -grammar: - -```sql -INSTALL PLUGIN FROM [source] [PROPERTIES ("key"="value", ...)] -``` - -source supports three types: - -1. An absolute path to a zip file. -2. An absolute path to a plugin directory. -3. Point to a zip file download path with http or https protocol - -### Example - -1. Install a local zip file plugin: - - ```sql - INSTALL PLUGIN FROM "/home/users/doris/auditdemo.zip"; - ``` - -2. Install the plugin in a local directory: - - ```sql - INSTALL PLUGIN FROM "/home/users/doris/auditdemo/"; - ``` - -3. Download and install a plugin: - - ```sql - INSTALL PLUGIN FROM "http://mywebsite.com/plugin.zip"; - ``` - - Note than an md5 file with the same name as the `.zip` file needs to be placed, such as `http://mywebsite.com/plugin.zip.md5` . - The content is the MD5 value of the .zip file. - -4. Download and install a plugin, and set the md5sum value of the zip file at the same time: - - ```sql - INSTALL PLUGIN FROM "http://mywebsite.com/plugin.zip" PROPERTIES("md5sum" = "73877f6029216f4314d712086a146570"); - ``` - -### Keywords - - INSTALL, PLUGIN - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/KILL.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/KILL.md deleted file mode 100644 index 63f8155ffed03..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/KILL.md +++ /dev/null @@ -1,98 +0,0 @@ ---- -{ - "title": "KILL", - "language": "en" -} ---- - - - -## KILL - -### Name - -KILL - -### Description - -Each Doris connection runs in a separate thread. You can kill a thread with the KILL processlist_id statement. - -The thread process list identifier can be queried from the Id column output by SHOW PROCESSLIST or SELECT CONNECTION_ID() to query the current connection id. - -grammar: - -```sql -KILL [CONNECTION] processlist_id -``` - -In addition, you can also use processlist_id or query_id terminates the executing query command - -grammar: - -```sql -KILL QUERY processlist_id | query_id -``` - - -### Example - - -1. View the connection id of the current connection. - -```sql -mysql> select connection_id(); -+-----------------+ -| connection_id() | -+-----------------+ -| 48 | -+-----------------+ -1 row in set (0.00 sec) -``` - -2. View the connection ids of all connections. - -```sql -mysql> SHOW PROCESSLIST; -+------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ -| CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | -+------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ -| Yes | 48 | root | 10.16.xx.xx:44834 | 2023-12-29 16:49:47 | internal | test | Query | 0 | OK | e6e4ce9567b04859-8eeab8d6b5513e38 | SHOW PROCESSLIST | -| | 50 | root | 192.168.xx.xx:52837 | 2023-12-29 16:51:34 | internal | | Sleep | 1837 | EOF | deaf13c52b3b4a3b-b25e8254b50ff8cb | SELECT @@session.transaction_isolation | -| | 51 | root | 192.168.xx.xx:52843 | 2023-12-29 16:51:35 | internal | | Sleep | 907 | EOF | 437f219addc0404f-9befe7f6acf9a700 | /* ApplicationName=DBeaver Ultimate 23.1.3 - Metadata */ SHOW STATUS | -| | 55 | root | 192.168.xx.xx:55533 | 2023-12-29 17:09:32 | internal | test | Sleep | 271 | EOF | f02603dc163a4da3-beebbb5d1ced760c | /* ApplicationName=DBeaver Ultimate 23.1.3 - SQLEditor */ SELECT DATABASE() | -| | 47 | root | 10.16.xx.xx:35678 | 2023-12-29 16:21:56 | internal | test | Sleep | 3528 | EOF | f4944c543dc34a99-b0d0f3986c8f1c98 | select * from test | -+------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ -5 rows in set (0.00 sec) -``` - -3. Terminate the running query. The running query will appear canceled. - -```sql -mysql> kill query 55; -Query OK, 0 rows affected (0.01 sec) -``` - - -### Keywords - - KILL - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/RECOVER.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/RECOVER.md deleted file mode 100644 index 0eaa888bcca95..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/RECOVER.md +++ /dev/null @@ -1,163 +0,0 @@ ---- -{ - "title": "RECOVER", - "language": "en" -} ---- - - - -## RECOVER - -### Name - -RECOVER - -### Description - -This statement is used to restore a previously deleted database, table or partition. It supports recover meta information by name or id, and you can set new name for recovered meta information. - -You can get all meta informations that can be recovered by statement `SHOW CATALOG RECYCLE BIN`. - -grammar: - -1. restore database by name - - ```sql - RECOVER DATABASE db_name; - ``` - -2. restore table by name - - ```sql - RECOVER TABLE [db_name.]table_name; - ``` - - 3. restore partition by name - - ```sql - RECOVER PARTITION partition_name FROM [db_name.]table_name; - ``` - -4. restore database by name and id - - ```sql - RECOVER DATABASE db_name db_id; - ``` - -5. restore table by name and id - - ```sql - RECOVER TABLE [db_name.]table_name table_id; - ``` - -6. restore partition by name and id - - ```sql - RECOVER PARTITION partition_name partition_id FROM [db_name.]table_name; - ``` - -7. restore database by name, and set new db name - - ```sql - RECOVER DATABASE db_name AS new_db_name; - ``` - -8. restore table by name and id, and set new table name - - ```sql - RECOVER TABLE [db_name.]table_name table_id AS new_table_name; - ``` - -9. restore partition by name and id, and set new partition name - - ```sql - RECOVER PARTITION partition_name partition_id AS new_partition_name FROM [db_name.]table_name; - ``` - -illustrate: - -- This operation can only restore meta information that was deleted in the previous period. Default is 1 day. (Configurable through the `catalog_trash_expire_second` parameter in fe.conf) -- If you recover a meta information by name without id, it will recover the last dropped one which has same name. -- You can get all meta informations that can be recovered by statement `SHOW CATALOG RECYCLE BIN`. - -### Example - -1. Restore the database named example_db - -```sql -RECOVER DATABASE example_db; -``` - -2. Restore the table named example_tbl - -```sql -RECOVER TABLE example_db.example_tbl; -``` - -3. Restore the partition named p1 in table example_tbl - -```sql -RECOVER PARTITION p1 FROM example_tbl; -``` - -4. Restore the database named example_db with id example_db_id - -```sql -RECOVER DATABASE example_db example_db_id; -``` - -5. Restore the table named example_tbl with id example_tbl_id - -```sql -RECOVER TABLE example_db.example_tbl example_tbl_id; -``` - -6. Restore the partition named p1 with id p1_id in table example_tbl - -```sql -RECOVER PARTITION p1 p1_id FROM example_tbl; -``` - -7. Restore the database named example_db with id example_db_id, and set new name new_example_db - -```sql -RECOVER DATABASE example_db example_db_id AS new_example_db; -``` - -8. Restore the table named example_tbl, and set new name new_example_tbl - -```sql -RECOVER TABLE example_db.example_tbl AS new_example_tbl; -``` - -9. Restore the partition named p1 with id p1_id in table example_tbl, and new name new_p1 - -```sql -RECOVER PARTITION p1 p1_id AS new_p1 FROM example_tbl; -``` - -### Keywords - - RECOVER - -### Best Practice - - diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/SET-DEFAULT-STORAGE-VAULT.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/SET-DEFAULT-STORAGE-VAULT.md deleted file mode 100644 index 85ecbb3766f7e..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/SET-DEFAULT-STORAGE-VAULT.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -{ - "title": "SET-DEFAULT-STORAGE-VAULT", - "language": "en" -} ---- - - - -## Description - -This statement is used to set the default storage vault in Doris. The default storage vault is used to store data for internal or system tables. If the default storage vault is not set, Doris will not function properly. Once the default storage vault is set, it cannot be removed. - -## Syntax - -```sql -SET vault_name DEFAULT STORAGE VAULT -``` - -> Note: -> -> 1. Only ADMIN users can set the default storage vault. - -## Example - -1. Set the storage vault named 's3_vault' as the default storage vault. - - ```sql - SET s3_vault AS DEFAULT STORAGE VAULT; - ``` - -## Related Commands - -## Keywords - - SET, DEFAULT, STORAGE, VAULT \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/SET-VARIABLE.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/SET-VARIABLE.md deleted file mode 100644 index f7caca36ea597..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/SET-VARIABLE.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -{ - "title": "SET-VARIABLE", - "language": "en" -} ---- - - - -## SET-VARIABLE - -### Name - -SET VARIABLE - -### Description - -This statement is mainly used to modify Doris system variables. These system variables can be modified at the global and session level, and some can also be modified dynamically. You can also view these system variables with `SHOW VARIABLE`. - -grammar: - -```sql -SET variable_assignment [, variable_assignment] ... -``` - -illustrate: - -1. variable_assignment: - user_var_name = expr - | [GLOBAL | SESSION] system_var_name = expr - -> Note: -> -> 1. Only ADMIN users can set variables to take effect globally -> 2. The globally effective variable affects the current session and new sessions thereafter, but does not affect other sessions that currently exist. - -### Example - -1. Set the time zone to Dongba District - - ``` - SET time_zone = "Asia/Shanghai"; - ``` - -2. Set the global execution memory size - - ``` - SET GLOBAL exec_mem_limit = 137438953472 - ``` - -### Keywords - - SET, VARIABLE - diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/SHOW-CONFIG.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/SHOW-CONFIG.md deleted file mode 100644 index 8220a09a1aad5..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/SHOW-CONFIG.md +++ /dev/null @@ -1,102 +0,0 @@ ---- -{ - "title": "SHOW-CONFIG", - "language": "en" -} ---- - - - -## SHOW-CONFIG - -### Name - -SHOW CONFIG - -### Description - -This statement is used to display the configuration of the current cluster. - -grammar: - -```sql -SHOW (FRONTEND|BACKEND) CONFIG [LIKE "pattern"]; -```` - -The columns in the results of showing FE configuration have the following meanings: - -1. Key: Configuration item name -2. Value: Configuration item value -3. Type: Configuration item type -4. IsMutable: Whether it can be set by ADMIN SET CONFIG command -5. MasterOnly: Is it only applicable to Master FE -6. Comment: Configuration item description - -The columns in the results of showing BE configuration have the following meanings: - -1. BackendId: ID of a backend -2. Host: Host of a backend -3. Key: Configuration item name -4. Value: Configuration item value -5. Type: Configuration item type -6. IsMutable: Whether it can be modified - -### Example - -1. View the configuration of the current FE node - - ```sql - SHOW FRONTEND CONFIG; - ``` - -2. Use the like predicate to search the configuration of the current Fe node - - ``` - mysql> SHOW FRONTEND CONFIG LIKE '%check_java_version%'; - +--------------------+-------+---------+---------- -+------------+---------+ - | Key | Value | Type | IsMutable | MasterOnly | Comment | - +--------------------+-------+---------+---------- -+------------+---------+ - | check_java_version | true | boolean | false | false | | - +--------------------+-------+---------+---------- -+------------+---------+ - 1 row in set (0.01 sec) - ``` - -3. View the configuration for a specific BE using the backend ID `10001` - - ```sql - SHOW BACKEND CONFIG FROM 10001; - ``` -4. View the configuration useing both a pattern and a backend ID - ``` - mysql> SHOW BACKEND CONFIG LIKE "be_port" FROM 10001; - +-----------+---------------+---------+-------+---------+-----------+ - | BackendId | Host | Key | Value | Type | IsMutable | - +-----------+---------------+---------+-------+---------+-----------+ - | 10001 | xx.xx.xxx.xxx | be_port | 9060 | int32_t | false | - +-----------+---------------+---------+-------+---------+-----------+ - ``` - - -### Keywords - - SHOW, CONFIG - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/SHOW-REPLICA-DISTRIBUTION.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/SHOW-REPLICA-DISTRIBUTION.md deleted file mode 100644 index 4389412c4297d..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/SHOW-REPLICA-DISTRIBUTION.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -{ - "title": "SHOW-REPLICA-DISTRIBUTION", - "language": "en" -} ---- - - - -## SHOW-REPLICA-DISTRIBUTION - -### Name - -SHOW REPLICA DISTRIBUTION - -### Description - -This statement is used to display the distribution status of a table or partition replica - -grammar: - -```sql -SHOW REPLICA DISTRIBUTION FROM [db_name.]tbl_name [PARTITION (p1, ...)]; -``` - -illustrate: - -1. The Graph column in the result shows the replica distribution ratio in the form of a graph - -### Example - -1. View the replica distribution of the table - - ```sql - SHOW REPLICA DISTRIBUTION FROM tbl1; - ``` - - 2. View the replica distribution of the partitions of the table - - ```sql - SHOW REPLICA DISTRIBUTION FROM db1.tbl1 PARTITION(p1, p2); - ``` - -### Keywords - - ADMIN, SHOW, REPLICA, DISTRIBUTION - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/SHOW-REPLICA-STATUS.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/SHOW-REPLICA-STATUS.md deleted file mode 100644 index e7cea56012f27..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/SHOW-REPLICA-STATUS.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -{ - "title": "SHOW-REPLICA-STATUS", - "language": "en" -} ---- - - - -## SHOW-REPLICA-STATUS - -### Name - -SHOW REPLICA STATUS - -### Description - -This statement is used to display replica status information for a table or partition. - -grammar: - -```sql -SHOW REPLICA STATUS FROM [db_name.]tbl_name [PARTITION (p1, ...)] -[where_clause]; -``` - -illustrate - -1. where_clause: - WHERE STATUS [!]= "replica_status" - -2. replica_status: - OK: replica is healthy - DEAD: The Backend where the replica is located is unavailable - VERSION_ERROR: replica data version is missing - SCHEMA_ERROR: The schema hash of the replica is incorrect - MISSING: replica does not exist - -### Example - -1. View the status of all replicas of the table - - ```sql - SHOW REPLICA STATUS FROM db1.tbl1; - ``` - -2. View a copy of a table with a partition status of VERSION_ERROR - - ```sql - SHOW REPLICA STATUS FROM tbl1 PARTITION (p1, p2) - WHERE STATUS = "VERSION_ERROR"; - ``` - -3. View all unhealthy replicas of the table - - ```sql - SHOW REPLICA STATUS FROM tbl1 - WHERE STATUS != "OK"; - ``` - -### Keywords - - SHOW, REPLICA, STATUS - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/SHOW-TABLET-DIAGNOSIS.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/SHOW-TABLET-DIAGNOSIS.md deleted file mode 100644 index bba8b7bd7cba5..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/SHOW-TABLET-DIAGNOSIS.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -{ - "title": "SHOW TABLET DIAGNOSIS", - "language": "en" -} ---- - - - -## SHOW TABLET DIAGNOSIS -### Description - - This statement is used to diagnose the specified tablet. The results will show information about the tablet and some potential problems. - - grammar: - - SHOW TABLET DIAGNOSE TABLET tablet_id - - illustrate: - - The lines of information in the result are as follows: - 1. TabletExist: Whether the Tablet exists - 2. TabletId: Tablet ID - 3. Database: The DB to which the Tablet belongs and its ID - 4. Table: The Table to which Tablet belongs and its ID - 5. Partition: The Partition to which the Tablet belongs and its ID - 6. MaterializedIndex: The materialized view to which the Tablet belongs and its ID - 7. Replicas(ReplicaId -> BackendId): Tablet replicas and their BE. - 8. ReplicasNum: Whether the number of replicas is correct. - 9. ReplicaBackendStatus: Whether the BE node where the replica is located is normal. - 10.ReplicaVersionStatus: Whether the version number of the replica is normal. - 11.ReplicaStatus: Whether the replica status is normal. - 12.ReplicaCompactionStatus: Whether the replica Compaction status is normal. - -### Example - - 1. Diagnose tablet 10001 - - SHOW TABLET DIAGNOSE TABLET 10001; - -### Keywords - - SHOW, DIAGNOSIS, TABLET diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/SHOW-TABLET-STORAGE-FORMAT.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/SHOW-TABLET-STORAGE-FORMAT.md deleted file mode 100644 index 6f5fddc5c28f2..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/SHOW-TABLET-STORAGE-FORMAT.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -{ - "title": "SHOW TABLET STORAGE FORMAT", - "language": "en" -} ---- - - - -## SHOW TABLET STORAGE FORMAT -### description - - This statement is used to display tablet storage foramt information (for administrators only) - Grammar: - SHOW TABLET STORAGE FORMAT [VERBOSE] - -### example - - ``` - MySQL [(none)]> show tablet storage format; - +-----------+---------+---------+ - | BackendId | V1Count | V2Count | - +-----------+---------+---------+ - | 10002 | 0 | 2867 | - +-----------+---------+---------+ - 1 row in set (0.003 sec) - MySQL [test_query_qa]> show tablet storage format verbose; - +-----------+----------+---------------+ - | BackendId | TabletId | StorageFormat | - +-----------+----------+---------------+ - | 10002 | 39227 | V2 | - | 10002 | 39221 | V2 | - | 10002 | 39215 | V2 | - | 10002 | 39199 | V2 | - +-----------+----------+---------------+ - 4 rows in set (0.034 sec) - ``` - -### keywords - SHOW, TABLET, STORAGE, FORMAT - diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/UNINSTALL-PLUGIN.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/UNINSTALL-PLUGIN.md deleted file mode 100644 index 7602dd95841ea..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/UNINSTALL-PLUGIN.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -{ - "title": "UNINSTALL-PLUGIN", - "language": "en" -} ---- - - - -## UNINSTALL-PLUGIN - -### Name - -UNINSTALL PLUGIN - -### Description - -This statement is used to uninstall a plugin. - -grammar: - -```sql -UNINSTALL PLUGIN plugin_name; -``` - - plugin_name can be viewed with the `SHOW PLUGINS;` command. - -Only non-builtin plugins can be uninstalled. - -### Example - -1. Uninstall a plugin: - - ```sql - UNINSTALL PLUGIN auditdemo; - ``` - -### Keywords - - UNINSTALL, PLUGIN - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/UNSET-VARIABLE.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/UNSET-VARIABLE.md deleted file mode 100644 index 4be86f1f52e95..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/UNSET-VARIABLE.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -{ - "title": "UNSET-VARIABLE", - "language": "en" -} ---- - - - -## UNSET-VARIABLE - -### Name - -UNSET VARIABLE - -### Description - -This statement is used to restore Doris system variables. These system variables can be modified at global or session level. - -grammar: - -```sql -UNSET [SESSION|GLOBAL] VARIABLE (variable_name | ALL) -``` - -illustrate: - -1. (variable_name | ALL): statement must be ended with a variable name or keyword `ALL`. - -> Note: -> -> 1. Only ADMIN users can unset variables to take effect globally -> 2. When restore a variable with `GLOBAL`, it only affect your current using session and new open sessions. It does not affect other current open sessions. - -### Example - -1. Restore value of the time zone - - ``` - UNSET VARIABLE time_zone; - ``` - -2. Restore the global execution memory size - - ``` - UNSET GLOBAL VARIABLE exec_mem_limit; - ``` -3. Restore all variables globally - - ``` - UNSET GLOBAL VARIABLE ALL; - ``` -### Keywords - - UNSET, VARIABLE - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Database-Administration-Statements/WARM-UP-COMPUTE-GROUP.md b/docs/sql-manual/sql-statements/Database-Administration-Statements/WARM-UP-COMPUTE-GROUP.md deleted file mode 100644 index ba6e1e4f3c918..0000000000000 --- a/docs/sql-manual/sql-statements/Database-Administration-Statements/WARM-UP-COMPUTE-GROUP.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -{ - "title": "WARM UP COMPUTE GROUP", - "language": "en" -} ---- - - - -## Description - -The WARM UP COMPUTE GROUP statement is used to warm up data in a compute group to improve query performance. The warming operation can either retrieve resources from another compute group or specify particular tables and partitions for warming. The warming operation returns a job ID that can be used to track the status of the warming job. - -## Syntax - -```sql -WARM UP COMPUTE GROUP WITH COMPUTE GROUP ; - -WARM UP COMPUTE GROUP WITH ; - -warm_up_list ::= warm_up_item [AND warm_up_item...]; - -warm_up_item ::= TABLE [PARTITION ]; - -``` - -## Parameters - -* destination_compute_group_name: The name of the destination compute group that is to be warmed up. - -* source_compute_group_name(Optional) The name of the source cluster from which resources will be warmed up. - -* warm_up_list: (Optional) A list of specific items to warm up, which can include tables and partitions. - -* table_name: The name of the table is used to warmup. - -* partition_name: The name of the partition is used to warmup. - -## Return Values - -* JobId: the id of warm-up job. - -## Example - -1. Warm up a compute group named destination_group_name with a compute group named source_group_name. - -```sql - WARM UP COMPUTE GROUP destination_group_name WITH COMPUTE GROUP source_group_name; - -``` - -2. Warm up a compute group named destination_group with table sales_data and customer_info and partition q1_2024 of table orders . - -``` - WARM UP COMPUTE GROUP destination_group WITH - TABLE sales_data - AND TABLE customer_info - AND TABLE orders PARTITION q1_2024; - -``` - -## Keywords - - WARM UP, COMPUTE GROUP, CACHE diff --git a/docs/sql-manual/sql-statements/Operators/in.md b/docs/sql-manual/sql-statements/Operators/in.md deleted file mode 100644 index 143e06cbc6e67..0000000000000 --- a/docs/sql-manual/sql-statements/Operators/in.md +++ /dev/null @@ -1,78 +0,0 @@ ---- -{ - "title": "IN", - "language": "en" -} ---- - - - -## IN - -IN - -### description - -#### Syntax - -`expr IN (value, ...)` - -`expr IN (subquery)` - -If expr is equal to any value in the IN list, return true; otherwise, return false. - -Subquery can only return one column, and the column types returned by subquery must be compatible with expr types. - -If subquery returns a bitmap data type column, expr must be an integer. - -### example - -``` -mysql> select id from cost where id in (1, 2); -+------+ -| id | -+------+ -| 2 | -| 1 | -+------+ -``` -``` -mysql> select id from tbl1 where id in (select id from tbl2); -+------+ -| id | -+------+ -| 1 | -| 4 | -| 5 | -+------+ -``` -``` -mysql> select id from tbl1 where id in (select bitmap_col from tbl3); -+------+ -| id | -+------+ -| 1 | -| 3 | -+------+ -``` - -### keywords - - IN diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-ALTER-TABLE-MATERIALIZED-VIEW.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-ALTER-TABLE-MATERIALIZED-VIEW.md deleted file mode 100644 index 24498cda880df..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-ALTER-TABLE-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,120 +0,0 @@ ---- -{ - "title": "SHOW ALTER TABLE MATERIALIZED VIEW", - "language": "en" -} ---- - - - -## SHOW ALTER TABLE MATERIALIZED VIEW - -### Name - -SHOW ALTER TABLE MATERIALIZED VIEW - -### Description - -This command is used to view the execution of the Create Materialized View job submitted through the [CREATE-MATERIALIZED-VIEW](../../sql-statements/Data-Definition-Statements/Create/CREATE-MATERIALIZED-VIEW.md) statement. - -> This statement is equivalent to `SHOW ALTER TABLE ROLLUP`; - -```sql -SHOW ALTER TABLE MATERIALIZED VIEW -[FROM database] -[WHERE] -[ORDER BY] -[LIMIT OFFSET] -``` - -- database: View jobs under the specified database. If not specified, the current database is used. -- WHERE: You can filter the result column, currently only the following columns are supported: - - TableName: Only equal value filtering is supported. - - State: Only supports equivalent filtering. - - Createtime/FinishTime: Support =, >=, <=, >, <, != -- ORDER BY: The result set can be sorted by any column. -- LIMIT: Use ORDER BY to perform page-turning query. - -Return result description: - -```sql -mysql> show alter table materialized view\G -**************************** 1. row ******************** ****** - JobId: 11001 - TableName: tbl1 - CreateTime: 2020-12-23 10:41:00 - FinishTime: NULL - BaseIndexName: tbl1 -RollupIndexName: r1 - RollupId: 11002 - TransactionId: 5070 - State: WAITING_TXN - Msg: - Progress: NULL - Timeout: 86400 -1 row in set (0.00 sec) -``` - -- `JobId`: Job unique ID. - -- `TableName`: base table name - -- `CreateTime/FinishTime`: Job creation time and end time. - -- `BaseIndexName/RollupIndexName`: Base table name and materialized view name. - -- `RollupId`: The unique ID of the materialized view. - -- `TransactionId`: See the description of the State field. - -- `State`: job status. - - - PENDING: The job is in preparation. - - - WAITING_TXN: - - Before officially starting to generate materialized view data, it will wait for the current running import transaction on this table to complete. And the `TransactionId` field is the current waiting transaction ID. When all previous imports for this ID are complete, the job will actually start. - - - RUNNING: The job is running. - - - FINISHED: The job ran successfully. - - - CANCELLED: The job failed to run. - -- `Msg`: error message - -- `Progress`: job progress. The progress here means `completed tablets/total tablets`. Materialized views are created at tablet granularity. - -- `Timeout`: Job timeout, in seconds. - -### Example - -1. View the materialized view jobs under the database example_db - - ```sql - SHOW ALTER TABLE MATERIALIZED VIEW FROM example_db; - ``` - -### Keywords - - SHOW, ALTER, TABLE, MATERIALIZED, VIEW - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-ALTER.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-ALTER.md deleted file mode 100644 index 49ef908001c55..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-ALTER.md +++ /dev/null @@ -1,92 +0,0 @@ ---- -{ - "title": "SHOW-ALTER", - "language": "en" -} - ---- - - - -## Description - -This statement is used to display the execution status of various modification tasks currently in progress. - -```sql -SHOW ALTER [TABLE [COLUMN | ROLLUP] [FROM db_name]]; -``` - -Notes: - -1. TABLE COLUMN: Displays ALTER tasks for modifying columns. -2. Supports syntax [WHERE TableName|CreateTime|FinishTime|State] [ORDER BY] [LIMIT]. -3. TABLE ROLLUP: Displays tasks for creating or deleting ROLLUP. -4. If db_name is not specified, the current default database is used. - -## Result - -*SHOW ALTER TABLE COLUMN* - -| Field Name | Description | -|-----------------------|------------------------------------------------------------------| -| JobId | Unique ID for each Schema Change job. | -| TableName | The name of the base table corresponding to the Schema Change. | -| CreateTime | Job creation time. | -| FinishedTime | Job completion time. Displays "N/A" if not completed. | -| IndexName | The name of a base table/synchronized materialized view involved in this modification. | -| IndexId | ID of the new base table/synchronized materialized view. | -| OriginIndexId | ID of a base table/synchronized materialized view involved in this modification. | -| SchemaVersion | Displays in M:N format. M represents the version of the Schema Change, and N represents the corresponding hash value. Each Schema Change increments the version. | -| TransactionId | Transaction ID for converting historical data. | -| State | The phase of the job. | -| | - PENDING: The job is waiting to be scheduled in the queue. | -| | - WAITING_TXN: Waiting for import tasks before the boundary transaction ID to complete. | -| | - RUNNING: Currently performing historical data conversion. | -| | - FINISHED: The job has successfully completed. | -| | - CANCELLED: The job has failed. | -| Msg | If the job fails, displays the failure message. | -| Progress | Job progress. Only displayed in RUNNING state. Progress is shown in M/N format. N is the total number of replicas involved in the Schema Change. M is the number of replicas for which historical data conversion has been completed. | -| Timeout | Job timeout duration in seconds. | - -## Examples - -1. Display the execution status of all modification column tasks for the default database. - - ```sql - SHOW ALTER TABLE COLUMN; - ``` - -2. Display the execution status of the most recent modification column task for a specific table. - - ```sql - SHOW ALTER TABLE COLUMN WHERE TableName = "table1" ORDER BY CreateTime DESC LIMIT 1; - ``` - -3. Display the execution status of tasks for creating or deleting ROLLUP for a specified database. - - ```sql - SHOW ALTER TABLE ROLLUP FROM example_db; - ``` - -### Keywords - - SHOW, ALTER - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-ANALYZE.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-ANALYZE.md deleted file mode 100644 index 9723da1e013ac..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-ANALYZE.md +++ /dev/null @@ -1,109 +0,0 @@ ---- -{ - "title": "SHOW-ANALYZE", - "language": "en" -} ---- - - - -## SHOW-ANALYZE - -### Name - -SHOW ANALYZE - -### Description - -Use `SHOW ANALYZE` to view information about statistics collection jobs. - -Syntax: - -```SQL -SHOW [AUTO] ANALYZE < table_name | job_id > - [ WHERE [ STATE = [ "PENDING" | "RUNNING" | "FINISHED" | "FAILED" ] ] ]; -``` - -- AUTO: Show historical information for automatic collection jobs only. Note that, by default, the status of only the last 20,000 completed automatic collection jobs is retained. -- table_name: Table name, specify to view statistics job information for that table. It can be in the format `db_name.table_name`. When not specified, it returns information for all statistics jobs. -- job_id: Job ID for statistics collection, obtained when executing `ANALYZE`. When not specified, this command returns information for all statistics jobs. - -Output: - -| Column Name | Description | -| :--------------------- | :--------------- | -| `job_id` | Job ID | -| `catalog_name` | Catalog Name | -| `db_name` | Database Name | -| `tbl_name` | Table Name | -| `col_name` | Column Name List | -| `job_type` | Job Type | -| `analysis_type` | Analysis Type | -| `message` | Job Information | -| `last_exec_time_in_ms` | Last Execution Time | -| `state` | Job Status | -| `schedule_type` | Scheduling Method | - -Here's an example: - -```sql -mysql> show analyze 245073\G; -*************************** 1. row *************************** - job_id: 245073 - catalog_name: internal - db_name: default_cluster:tpch - tbl_name: lineitem - col_name: [l_returnflag,l_receiptdate,l_tax,l_shipmode,l_suppkey,l_shipdate,l_commitdate,l_partkey,l_orderkey,l_quantity,l_linestatus,l_comment,l_extendedprice,l_linenumber,l_discount,l_shipinstruct] - job_type: MANUAL - analysis_type: FUNDAMENTALS - message: -last_exec_time_in_ms: 2023-11-07 11:00:52 - state: FINISHED - progress: 16 Finished | 0 Failed | 0 In Progress | 16 Total - schedule_type: ONCE -``` - -
- -Each collection job can contain one or more tasks, with each task corresponding to the collection of a column. Users can use the following command to view the completion status of statistics collection for each column. - -Syntax: - -```sql -SHOW ANALYZE TASK STATUS [job_id] -``` - -Here's an example: - -``` -mysql> show analyze task status 20038 ; -+---------+----------+---------+----------------------+----------+ -| task_id | col_name | message | last_exec_time_in_ms | state | -+---------+----------+---------+----------------------+----------+ -| 20039 | col4 | | 2023-06-01 17:22:15 | FINISHED | -| 20040 | col2 | | 2023-06-01 17:22:15 | FINISHED | -| 20041 | col3 | | 2023-06-01 17:22:15 | FINISHED | -| 20042 | col1 | | 2023-06-01 17:22:15 | FINISHED | -+---------+----------+---------+----------------------+----------+ -``` - -### Keywords - -SHOW, ANALYZE diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-BACKENDS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-BACKENDS.md deleted file mode 100644 index 2b018784c5acb..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-BACKENDS.md +++ /dev/null @@ -1,65 +0,0 @@ ---- -{ - "title": "SHOW-BACKENDS", - "language": "en" -} ---- - - - -## SHOW-BACKENDS - -### Name - -SHOW BACKENDS - -### Description - -This statement is used to view the BE nodes in the cluster - -```sql - SHOW BACKENDS; -``` - -illustrate: - - 1. LastStartTime indicates the last BE start time. - 2. LastHeartbeat indicates the last heartbeat. - 3. Alive indicates whether the node is alive or not. - 4. If SystemDecommissioned is true, it means that the node is being safely decommissioned. - 5. If ClusterDecommissioned is true, it means that the node is going offline in the current cluster. - 6. TabletNum represents the number of shards on the node. - 7. DataUsedCapacity Indicates the space occupied by the actual user data. - 8. AvailCapacity Indicates the available space on the disk. - 9. TotalCapacity represents the total disk space. TotalCapacity = AvailCapacity + DataUsedCapacity + other non-user data files occupy space. - 10. UsedPct Indicates the percentage of disk used. - 11. ErrMsg is used to display the error message when the heartbeat fails. - 12. Status is used to display some status information of BE in JSON format, including the time information of the last time BE reported its tablet. - 13. HeartbeatFailureCounter: The current number of heartbeats that have failed consecutively. If the number exceeds the `max_backend_heartbeat_failure_tolerance_count` configuration, the isAlive will be set to false. - 14. NodeRole is used to display the role of Backend node. Now there are two roles: mix and computation. Mix node represent the origin Backend node and computation Node represent the compute only node. - -### Example - -### Keywords - - SHOW, BACKENDS - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-BACKUP.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-BACKUP.md deleted file mode 100644 index da0cd0532a08e..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-BACKUP.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -{ - "title": "SHOW-BACKUP", - "language": "en" -} ---- - - - -## SHOW-BACKUP - -### Name - -SHOW BACKUP - -### Description - -This statement is used to view BACKUP tasks - -grammar: - -```sql - SHOW BACKUP [FROM db_name] - [WHERE SnapshotName ( LIKE | = ) 'snapshot name'] -``` - -illustrate: - - 1. Only the most recent BACKUP task is saved in Doris. - 2. The meaning of each column is as follows: - - `JobId`: Unique job id - - `SnapshotName`: The name of the backup - - `DbName`: belongs to the database - - `State`: current stage - - `PENDING`: The initial state after submitting the job - - `SNAPSHOTING`: Executing snapshot - - `UPLOAD_SNAPSHOT`: Snapshot completed, ready to upload - - `UPLOADING`: Snapshot uploading - - `SAVE_META`: Save job meta information to a local file - - `UPLOAD_INFO`: Upload job meta information - - `FINISHED`: The job was successful - - `CANCELLED`: Job failed - - `BackupObjs`: Backed up tables and partitions - - `CreateTime`: task submission time - - `SnapshotFinishedTime`: Snapshot completion time - - `UploadFinishedTime`: Snapshot upload completion time - - `FinishedTime`: Job finish time - - `UnfinishedTasks`: Displays unfinished subtask ids during SNAPSHOTING and UPLOADING stages - - `Status`: If the job fails, display the failure message - - `Timeout`: Job timeout, in seconds - -### Example - -1. View the last BACKUP task under example_db. - - ```sql - SHOW BACKUP FROM example_db; - ``` - -### Keywords - - SHOW, BACKUP - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-BROKER.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-BROKER.md deleted file mode 100644 index 7ed2c9e85ff95..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-BROKER.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -{ - "title": "SHOW-BROKER", - "language": "en" -} ---- - - - -## SHOW-BROKER - -### Name - -SHOW BROKER - -### Description - -This statement is used to view the currently existing broker - -grammar: - -```sql -SHOW BROKER; -``` - -illustrate: - -1. LastStartTime indicates the last BE start time. -2. LastHeartbeat indicates the last heartbeat. -3. Alive indicates whether the node is alive or not. -4. ErrMsg is used to display the error message when the heartbeat fails. - -### Example - -### Keywords - - SHOW, BROKER - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CACHE-HOTSPOT.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-CACHE-HOTSPOT.md deleted file mode 100644 index 00f829a2b2925..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CACHE-HOTSPOT.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -{ - "title": "SHOW-CACHE-HOTSPOT", - "language": "en" -} ---- - - - -## Description - -This statement is used to display the hotspot information of file cache. - -## Syntax - -```sql - SHOW CACHE HOTSPOT '/[compute_group_name/table_name]'; -``` - -## Parameters - -1. compute_group_name : Name of compute group. -2. table_name : Name of table. - -## Example - -1. View the table creation statement of a table - - ```sql - SHOW CACHE HOTSPOT '/'; - ``` - -## Related Commands - - - [WARMUP CACHE](../Database-Administration-Statements/WARM-UP-COMPUTE-GROUP.md) - -## References - - - [MANAGING FILE CACHE](../../../compute-storage-decoupled/file-cache.md) - -## Keywords - - SHOW, CACHE, HOTSPOT - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CATALOG-RECYCLE-BIN.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-CATALOG-RECYCLE-BIN.md deleted file mode 100644 index 558443fd05c3c..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CATALOG-RECYCLE-BIN.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -{ - "title": "SHOW-CATALOG-RECYCLE-BIN", - "language": "en" -} ---- - - - -## SHOW-CATALOG-RECYCLE-BIN - -### Name - -SHOW CATALOG RECYCLE BIN - -### Description - -This statement is used to display the dropped meta informations that can be recovered - -grammar: - -```sql -SHOW CATALOG RECYCLE BIN [ WHERE NAME [ = "name" | LIKE "name_matcher"] ] -``` - -grammar: - -``` -The meaning of each column is as follows: - Type: type of meta information:Database、Table、Partition - Name: name of meta information - DbId: id of database - TableId: id of table - PartitionId: id of partition - DropTime: drop time of meta information - DataSize: the amount of data. If the type is database, this value includes the data size of the recycled tables and partitions in the database - RemoteDataSize: the amount of data on remote storage(hdfs or object storage). If the type is database, this value includes the remote data size of the recycled tables and partitions in the database -``` - -### Example - - 1. Display all meta informations that can be recovered - - ```sql - SHOW CATALOG RECYCLE BIN; - ``` - - 2. Display meta informations with name 'test' - - ```sql - SHOW CATALOG RECYCLE BIN WHERE NAME = 'test'; - ``` - -### Keywords - - SHOW, CATALOG RECYCLE BIN - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CATALOGS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-CATALOGS.md deleted file mode 100644 index e9648748e256a..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CATALOGS.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -{ - "title": "SHOW-CATALOGS", - "language": "en" -} ---- - - - -## SHOW-CATALOGS - -### Name - -SHOW CATALOGS - -### Description - -This statement is used for view created catalogs - -Syntax: - -```sql -SHOW CATALOGS [LIKE] -``` - -illustrate: - -1. LIKE: Fuzzy query can be performed according to the catalog name - - -Return result: - -* CatalogId: Unique ID of the catalog -* CatalogName: Catalog name. where "internal" is the default built-in catalog, which cannot be modified. -* Type: Catalog type. -* IsCurrent: Show yes on the line of current using catalog. - -### Example - -1. View the data catalogs that have been created currently - - ```sql - SHOW CATALOGS; - +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ - | CatalogId | CatalogName | Type | IsCurrent | CreateTime | LastUpdateTime | Comment | - +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ - | 130100 | hive | hms | | 2023-12-25 16:11:41.687 | 2023-12-25 20:43:18 | NULL | - | 0 | internal | internal | yes | UNRECORDED | NULL | Doris internal catalog | - +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ - ``` - -2. Fuzzy query by catalog name - - ```sql - SHOW CATALOGS LIKE 'hi%'; - +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ - | CatalogId | CatalogName | Type | IsCurrent | CreateTime | LastUpdateTime | Comment | - +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ - | 130100 | hive | hms | | 2023-12-25 16:11:41.687 | 2023-12-25 20:43:18 | NULL | - +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ - ``` - -### Keywords - -SHOW, CATALOG, CATALOGS - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CHARSET.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-CHARSET.md deleted file mode 100644 index e1c9d0ef760f6..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CHARSET.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -{ - "title": "SHOW-CHARSET", - "language": "en" -} ---- - - - -## SHOW-CHARSET - -### Description - -The "SHOW CHARACTER" command is used to display the available character sets in the current database management system, -along with some associated properties for each character set. These properties may include the name of the character set, -the default collation, and the maximum byte length, among others. By running the "SHOW CHARACTER" command, you can view the list of supported character sets in the system along with their detailed information. - -The "SHOW CHARACTER" command returns the following fields: - -Charset: Character set -Description: Description -Default Collation: Default collation name -Maxlen: Maximum byte length. - - -### Example - -```sql -mysql> show charset; - -| Charset | Description | Default collation | Maxlen | -|-----------|-----------------|-------------------|--------| -| utf8mb4 | UTF-8 Unicode | utf8mb4_0900_bin | 4 | - -``` - -### Keywords - - SHOW, CHARSET - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-COLLATION.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-COLLATION.md deleted file mode 100644 index 51eb5e29d47f4..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-COLLATION.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -{ - "title": "SHOW-COLLATION", - "language": "en" -} ---- - - - -## Description - -In Doris, the `SHOW COLLATION` command is used to display the character set collations available in the database. A collation is a set of rules that determine how data is sorted and compared. These rules affect the storage and retrieval of character data. Doris currently mainly supports the proofreading method utf8mb4_0900_bin. - -## Syntax - -``` -SHOW COLLATION -``` - -## Result Fields - -The `SHOW COLLATION` command returns the following fields: - -* Collation: The collation name -* Charset: The character set -* Id: The collation's ID -* Default: Whether this is the default collation for the character set -* Compiled: Whether the collation is compiled -* Sortlen: Sort length - -### Example - -```sql -show collation; -``` - -``` -+------------------+---------+------+---------+----------+---------+ -| Collation | Charset | Id | Default | Compiled | Sortlen | -+------------------+---------+------+---------+----------+---------+ -| utf8mb4_0900_bin | utf8mb4 | 33 | Yes | Yes | 1 | -+------------------+---------+------+---------+----------+---------+ -``` - -### Notice - -In Doris, although it is compatible with MySQL's commands for setting the collation, the setting actually does not take effect. When executed, Doris will always use utf8mb4_0900_bin as the comparison rule. diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-COLUMN-STATS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-COLUMN-STATS.md deleted file mode 100644 index b64c5ad6f71e5..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-COLUMN-STATS.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -{ - "title": "SHOW-COLUMN-STATS", - "language": "en" -} ---- - - - -## SHOW-COLUMN-STATS - -### Name - -SHOW COLUMN STATS - -### Description - -Use `SHOW COLUMN STATS` to view various statistics data for columns. - -Syntax: - -```SQL -SHOW COLUMN [cached] STATS table_name [ (column_name [, ...]) ]; -``` - -Where: - -- cached: Show statistics information in the current FE memory cache. -- table_name: The target table for collecting statistics. It can be in the format `db_name.table_name`. -- column_name: Specifies the target column, which must be an existing column in `table_name`. You can specify multiple column names separated by commas. - -Here's an example: - -```sql -mysql> show column stats lineitem(l_tax)\G; -*************************** 1. row *************************** - column_name: l_tax - count: 6001215.0 - ndv: 9.0 - num_null: 0.0 - data_size: 4.800972E7 -avg_size_byte: 8.0 - min: 0.00 - max: 0.08 - method: FULL - type: FUNDAMENTALS - trigger: MANUAL - query_times: 0 - updated_time: 2023-11-07 11:00:46 -``` - -### Keywords - -SHOW, TABLE, STATS diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-COLUMNS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-COLUMNS.md deleted file mode 100644 index 53a3cf8b9dc5d..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-COLUMNS.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "SHOW-COLUMNS", - "language": "en" -} ---- - - - -## SHOW-COLUMNS - -### Name - -SHOW FULL COLUMNS - -### Description - -This statement is used to specify the column information of the table - -grammar: - -```sql -SHOW [FULL] COLUMNS FROM tbl; -``` - -### Example - -1. View the column information of the specified table - - ```sql - SHOW FULL COLUMNS FROM tbl; - ``` - -### Keywords - - SHOW, COLUMNS - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-COMPUTE-GROUPS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-COMPUTE-GROUPS.md deleted file mode 100644 index 50950cae01642..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-COMPUTE-GROUPS.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -{ - "title": "SHOW COMPUTE GROUPS", - "language": "en" -} ---- - - - -## Description - -The SHOW COMPUTE GROUPS command is used to display information about all configured compute groups in the system. Compute groups are logical units used to manage and organize computational resources, helping users allocate and utilize system resources more effectively. - -This command assists administrators and users in quickly understanding the existing compute group configurations in the system, including the name, attributes, and other relevant information for each compute group. This is particularly useful for resource management, performance optimization, and system monitoring. - -## Syntax - -```sql - SHOW COMPUTE GROUPS -``` - -## Return Values - -This command returns a result set containing the following columns: - -- `Name`: The name of the compute group. -- `IsCurrent`: Indicates whether it is the current working compute group. -- `Users`: Displays the list of users who have permission to use this compute group. -- `BackendNum`: Shows the number of backends (compute nodes) currently allocated to this compute group. - -## Related Commands - -- [ALTER SYSTEM ADD BACKEND](../Administration-Statements/ALTER-SYSTEM-ADD-BACKEND.md) -- [GRANT](../Account-Management-Statements/GRANT.md) -- [REVOKE](../Account-Management-Statements/REVOKE.md) -- [SET DEFAULT COMPUTE GROUP](../Administration-Statements/SET-DEFAULT-COMPUTE-GROUP.md) - -## Keywords - - SHOW, COMPUTE GROUPS \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CONVERT-LIGHT-SCHEMA-CHANGE-PROCESS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-CONVERT-LIGHT-SCHEMA-CHANGE-PROCESS.md deleted file mode 100644 index 1acb61deaf847..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CONVERT-LIGHT-SCHEMA-CHANGE-PROCESS.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -{ - "title": "SHOW-CONVERT-LIGHT-SCHEMA-CHANGE-PROCESS", - "language": "en" -} ---- - - - -## SHOW-CONVERT-LIGHT-SCHEMA-CHANGE-PROCESS - -### Name - -SHOW CONVERT LIGHT SCHEMA CHANGE PROCESS - -### Description - -This statement is used to show the process of converting light schema change process. should enable config `enable_convert_light_weight_schema_change`. - -grammar: - -```sql -SHOW CONVERT_LIGHT_SCHEMA_CHANGE_PROCESS [FROM db] -``` - -### Example - -1. View the converting process in db named test - - ```sql - SHOW CONVERT_LIGHT_SCHEMA_CHANGE_PROCESS FROM test; - ``` - -2. View the converting process globally - - ```sql - SHOW CONVERT_LIGHT_SCHEMA_CHANGE_PROCESS; - ``` - - -### Keywords - - SHOW, CONVERT_LIGHT_SCHEMA_CHANGE_PROCESS - -### Best Practice \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-ASYNC-MATERIALIZED-VIEW.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-ASYNC-MATERIALIZED-VIEW.md deleted file mode 100644 index 5371e85fd493c..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-ASYNC-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -{ - "title": "SHOW-CREATE-ASYNC-MATERIALIZED-VIEW", - "language": "en" -} ---- - - - -## SHOW-CREATE-ASYNC-MATERIALIZED-VIEW - -### Name - -SHOW CREATE ASYNC MATERIALIZED VIEW - -### Description - -This statement is used to display the creation statement of asynchronous materialized views. - -grammar: - -```sql -SHOW CREATE MATERIALIZED VIEW [DBNAME.]MV_NAME -``` - -illustrate: - -1. `DBNAMNE` : 数据库名称 -2. `MV_NAME` : 异步物化视图的名称 - -### Example - -1. View the creation statement of mv1 - - ```sql - SHOW CREATE MATERIALIZED VIEW mv1; - ``` - -### Keywords - - SHOW, CREATE, MATERIALIZED, VIEW, ASYNC - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-CATALOG.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-CATALOG.md deleted file mode 100644 index 2cbdd8f480e90..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-CATALOG.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -{ - "title": "SHOW-CREATE-CATALOG", - "language": "en" -} ---- - - - -## SHOW-CREATE-CATALOG - -### Name - -SHOW CREATE CATALOG - -### Description - -This statement shows the creating statement of a doris catalog. - -grammar: - -```sql -SHOW CREATE CATALOG catalog_name; -``` - -illustrate: -- `catalog_name`: The name of the catalog which exist in doris. - -### Example - -1. View the creating statement of the hive catalog in doris - - ```sql - SHOW CREATE CATALOG hive; - ``` - -### Keywords - - SHOW, CREATE, CATALOG - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-DATABASE.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-DATABASE.md deleted file mode 100644 index 1431a8ecfbae0..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-DATABASE.md +++ /dev/null @@ -1,78 +0,0 @@ ---- -{ - "title": "SHOW-CREATE-DATABASE", - "language": "en" -} ---- - - - -## SHOW-CREATE-DATABASE - -### Name - -SHOW CREATE DATABASE - -### Description - -This statement checks the creation of the doris database, support database from both internal catalog and hms catalog - -grammar: - -```sql -SHOW CREATE DATABASE db_name; -``` - -illustrate: - -- `db_name`: The name of the database -- if specific a database from hms catalog, will return same with this stmt in hive - -### Example - -1. View the creation of the test database in doris internal catalog - - ```sql - mysql> SHOW CREATE DATABASE test; - +----------+----------------------------+ - | Database | Create Database | - +----------+----------------------------+ - | test | CREATE DATABASE `test` | - +----------+----------------------------+ - 1 row in set (0.00 sec) - ``` - -2. view a database named `hdfs_text` from a hms catalog - - ```sql - mysql> show create database hdfs_text; - +-----------+------------------------------------------------------------------------------------+ - | Database | Create Database | - +-----------+------------------------------------------------------------------------------------+ - | hdfs_text | CREATE DATABASE `hdfs_text` LOCATION 'hdfs://HDFS1009138/hive/warehouse/hdfs_text' | - +-----------+------------------------------------------------------------------------------------+ - 1 row in set (0.01 sec) - ``` - -### Keywords - - SHOW, CREATE, DATABASE - -### Best Practice \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-FUNCTION.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-FUNCTION.md deleted file mode 100644 index 73198c3f2e558..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-FUNCTION.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -{ - "title": "SHOW-CREATE-FUNCTION", - "language": "en" -} ---- - - - -## SHOW-CREATE-FUNCTION - -### Name - -SHOW CREATE FUNCTION - -### Description - -This statement is used to display the creation statement of the user-defined function - -grammar: - -```sql -SHOW CREATE [GLOBAL] FUNCTION function_name(arg_type [, ...]) [FROM db_name]]; -``` - -illustrate: -1. `global`: The show function is global -2. `function_name`: The name of the function to display -3. `arg_type`: The parameter list of the function to display -4. If db_name is not specified, the current default db is used - -**Note: the "global" keyword is only available after v2.0** - -### Example - -1. Show the creation statement of the specified function under the default db - - ```sql - SHOW CREATE FUNCTION my_add(INT, INT) - ``` -2. Show the creation statement of the specified global function - - ```sql - SHOW CREATE GLOBAL FUNCTION my_add(INT, INT) - ``` - -### Keywords - - SHOW, CREATE, FUNCTION - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-LOAD.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-LOAD.md deleted file mode 100644 index aefc858aaabf0..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-LOAD.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -{ - "title": "SHOW-CREATE-LOAD", - "language": "en" -} ---- - - - -## SHOW-CREATE-LOAD - -### Name - -SHOW CREATE LOAD - -### Description - -This statement is used to demonstrate the creation statement of a import job. - -grammar: - -```sql -SHOW CREATE LOAD for load_name; -``` - -illustrate: - -- `load_name`: import job name - -### Example - -1. Show the creation statement of the specified import job under the default db - - ```sql - SHOW CREATE LOAD for test_load - ``` - -### Keywords - - SHOW, CREATE, LOAD - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-MATERIALIZED-VIEW.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-MATERIALIZED-VIEW.md deleted file mode 100644 index 0dacbc8e29b38..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -{ - "title": "SHOW-CREATE-MATERIALIZED-VIEW", - "language": "en" -} ---- - - - -## SHOW-CREATE-MATERIALIZED-VIEW - -### Name - -SHOW CREATE MATERIALIZED VIEW - -### Description - -This statement is used to query statements that create materialized views. - -grammar: - -```sql -SHOW CREATE MATERIALIZED VIEW mv_name ON table_name -``` - -1. mv_name: - Materialized view name. required. - -2. table_name: - The table name of materialized view. required. - -### Example - -Create materialized view - -```sql -create materialized view id_col1 as select id,col1 from table3; -``` - -Return after query - -```sql -mysql> show create materialized view id_col1 on table3; -+-----------+----------+----------------------------------------------------------------+ -| TableName | ViewName | CreateStmt | -+-----------+----------+----------------------------------------------------------------+ -| table3 | id_col1 | create materialized view id_col1 as select id,col1 from table3 | -+-----------+----------+----------------------------------------------------------------+ -1 row in set (0.00 sec) -``` - -### Keywords - - SHOW, MATERIALIZED, VIEW - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-REPOSITORY.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-REPOSITORY.md deleted file mode 100644 index 7b58676d54628..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-REPOSITORY.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -{ - "title": "SHOW-CREATE-REPOSITORY", - "language": "en" -} ---- - - - -## SHOW-CREATE-REPOSITORY - -### Name - -SHOW CREATE REPOSITORY - -### Description - -This statement is used to demonstrate the creation statement of a repository. - -grammar: - -```sql -SHOW CREATE REPOSITORY for repository_name; -``` - -illustrate: -- `repository_name`: repository name - -### Example - -1. Show the creation statement of the specified repository - - ```sql - SHOW CREATE REPOSITORY for test_repository - ``` - -### Keywords - - SHOW, CREATE, REPOSITORY - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-ROUTINE-LOAD.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-ROUTINE-LOAD.md deleted file mode 100644 index b4fadc2fe8ad5..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-ROUTINE-LOAD.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -{ - "title": "SHOW-CREATE-ROUTINE-LOAD", - "language": "en" -} ---- - - - -## SHOW-CREATE-ROUTINE-LOAD - -### Name - -SHOW CREATE ROUTINE LOAD - -### Description - -This statement is used to demonstrate the creation statement of a routine import job. - -The kafka partition and offset in the result show the currently consumed partition and the corresponding offset to be consumed. - -grammar: - -```sql -SHOW [ALL] CREATE ROUTINE LOAD for load_name; -``` - -illustrate: - -1. `ALL`: optional parameter, which means to get all jobs, including historical jobs -2. `load_name`: routine import job name - -### Example - -1. Show the creation statement of the specified routine import job under the default db - - ```sql - SHOW CREATE ROUTINE LOAD for test_load - ``` - -### Keywords - - SHOW, CREATE, ROUTINE, LOAD - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-TABLE.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-TABLE.md deleted file mode 100644 index 0d80bac831abd..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-TABLE.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -{ - "title": "SHOW-CREATE-TABLE", - "language": "en" -} ---- - - - -## SHOW-CREATE-TABLE - -### Name - -SHOW CREATE TABLE - -### Description - -This statement is used to display the creation statement of the data table. - -grammar: - -```sql -SHOW [BRIEF] CREATE TABLE [DBNAME.]TABLE_NAME -``` - -illustrate: - -1. `BRIEF` : will not show partitions info - -2. `DBNAMNE` : database name -3. `TABLE_NAME` : table name - -### Example - -1. View the table creation statement of a table - - ```sql - SHOW CREATE TABLE demo.tb1 - ``` - -### Keywords - - SHOW, CREATE, TABLE - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-DATA-SKEW.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-DATA-SKEW.md deleted file mode 100644 index c54587eb72837..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-DATA-SKEW.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ -"title": "SHOW DATA SKEW", -"language": "en" -} ---- - - - -## SHOW-DATA-SKEW - -### Name - -SHOW DATA SKEW - -### Description - - This statement is used to view the data skew of a table or a partition. - - grammar: - - SHOW DATA SKEW FROM [db_name.]tbl_name [PARTITION (p1)]; - - Description: - - 1. Only one partition must be specified. For non-partitioned tables, the partition name is the same as the table name. - 2. The result will show row count and data volume of each bucket under the specified partition, and the proportion of the data volume of each bucket in the total data volume. - -### Example - - 1. View the data skew of the table - - SHOW DATA SKEW FROM db1.test PARTITION(p1); - -### Keywords - - SHOW, DATA, SKEW - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-DATA-TYPES.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-DATA-TYPES.md deleted file mode 100644 index 39631f483bf65..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-DATA-TYPES.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -{ - "title": "SHOW-DATA-TYPES", - "language": "en" -} ---- - - - -## SHOW-DATA-TYPES - -### Name - -SHOW DATA TYPES - -### Description - - This statement is used to view all supported data types. - - grammar: - ```sql - SHOW DATA TYPES; - ``` - -### Example - - 1. Display all supported data types - - SHOW DATA TYPES; - -### Keywords - - SHOW,DATA,TYPES - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-DATA.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-DATA.md deleted file mode 100644 index b5f0d91b02fe0..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-DATA.md +++ /dev/null @@ -1,141 +0,0 @@ ---- -{ - "title": "SHOW-DATA", - "language": "en" -} ---- - - - -## SHOW-DATA - -### Name - -SHOW DATA - -### Description - -This statement is used to display the amount of data, the number of replicas, and the number of statistical rows. - -grammar: - -```sql -SHOW DATA [FROM [db_name.]table_name] [ORDER BY ...]; -``` - -illustrate: - -1. If the FROM clause is not specified, the data volume and number of replicas subdivided into each table under the current db will be displayed. The data volume is the total data volume of all replicas. The number of replicas is the number of replicas for all partitions of the table and all materialized views. - -2. If the FROM clause is specified, the data volume, number of copies and number of statistical rows subdivided into each materialized view under the table will be displayed. The data volume is the total data volume of all replicas. The number of replicas is the number of replicas for all partitions of the corresponding materialized view. The number of statistical rows is the number of statistical rows for all partitions of the corresponding materialized view. - -3. When counting the number of rows, the one with the largest number of rows among the multiple copies shall prevail. - -4. The `Total` row in the result set represents the total row. The `Quota` line represents the quota set by the current database. The `Left` line indicates the remaining quota. - -5. If you want to see the size of each Partition, see `help show partitions`. - -6. You can use ORDER BY to sort on any combination of columns. - -### Example - -1. Display the data size and RecycleBin size of each database by default. - - ``` - SHOW DATA; - ``` - - ``` - +-------+-----------------------------------+--------+------------+-------------+-------------------+ - | DbId | DbName | Size | RemoteSize | RecycleSize | RecycleRemoteSize | - +-------+-----------------------------------+--------+------------+-------------+-------------------+ - | 21009 | db1 | 0 | 0 | 0 | 0 | - | 22011 | regression_test_inverted_index_p0 | 72764 | 0 | 0 | 0 | - | 0 | information_schema | 0 | 0 | 0 | 0 | - | 22010 | regression_test | 0 | 0 | 0 | 0 | - | 1 | mysql | 0 | 0 | 0 | 0 | - | 22017 | regression_test_show_p0 | 0 | 0 | 0 | 0 | - | 10002 | __internal_schema | 46182 | 0 | 0 | 0 | - | Total | NULL | 118946 | 0 | 0 | 0 | - +-------+-----------------------------------+--------+------------+-------------+-------------------+ - ``` - -2. Display the data volume, replica number, aggregate data volume and aggregate replica number of each table in a database. - - ```sql - USE db1; - SHOW DATA; - ``` - - ``` - +-----------+-------------+--------------+ - | TableName | Size | ReplicaCount | - +-----------+-------------+--------------+ - | tbl1 | 900.000 B | 6 | - | tbl2 | 500.000 B | 3 | - | Total | 1.400 KB | 9 | - | Quota | 1024.000 GB | 1073741824 | - | Left | 1021.921 GB | 1073741815 | - +-----------+-------------+--------------+ - ``` - -3. Display the subdivided data volume, the number of replicas and the number of statistical rows of the specified table under the specified db - - ```sql - SHOW DATA FROM example_db.test; - ``` - - ``` - +-----------+-----------+-----------+--------------+----------+ - | TableName | IndexName | Size | ReplicaCount | RowCount | - +-----------+-----------+-----------+--------------+----------+ - | test | r1 | 10.000MB | 30 | 10000 | - | | r2 | 20.000MB | 30 | 20000 | - | | test2 | 50.000MB | 30 | 50000 | - | | Total | 80.000 | 90 | | - +-----------+-----------+-----------+--------------+----------+ - ``` - -4. It can be combined and sorted according to the amount of data, the number of copies, the number of statistical rows, etc. - - ```sql - SHOW DATA ORDER BY ReplicaCount desc,Size asc; - ``` - - ``` - +-----------+-------------+--------------+ - | TableName | Size | ReplicaCount | - +-----------+-------------+--------------+ - | table_c | 3.102 KB | 40 | - | table_d | .000 | 20 | - | table_b | 324.000 B | 20 | - | table_a | 1.266 KB | 10 | - | Total | 4.684 KB | 90 | - | Quota | 1024.000 GB | 1073741824 | - | Left | 1024.000 GB | 1073741734 | - +-----------+-------------+--------------+ - ``` - -### Keywords - - SHOW, DATA - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-DATABASE-ID.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-DATABASE-ID.md deleted file mode 100644 index db5e7581c2769..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-DATABASE-ID.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "SHOW-DATABASE-ID", - "language": "en" -} ---- - - - -## SHOW-DATABASE-ID - -### Name - -SHOW DATABASE ID - -### Description - -This statement is used to find the corresponding database name according to the database id (only for administrators) - -grammar: - -```sql -SHOW DATABASE [database_id] -``` - -### Example - -1. Find the corresponding database name according to the database id - - ```sql - SHOW DATABASE 1001; - ``` - -### Keywords - - SHOW, DATABASE, ID - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-DATABASES.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-DATABASES.md deleted file mode 100644 index da3281060020d..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-DATABASES.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -{ - "title": "SHOW-DATABASES", - "language": "en" -} ---- - - - -## SHOW-DATABASES - -### Name - -SHOW DATABASES - -### Description - -This statement is used to display the currently visible db - -grammar: - -```sql -SHOW DATABASES [FROM catalog] [filter expr]; -``` - -illustrate: -1. `SHOW DATABASES` will get all database names from current catalog. -2. `SHOW DATABASES FROM catalog` will all database names from the catalog named 'catalog'. -3. `SHOW DATABASES filter_expr` will get filtered database names from current catalog. -4. `SHOW DATABASES FROM catalog filter_expr` is not support yet. - -### Example -1. Display all the database names from current catalog. - - ```sql - SHOW DATABASES; - ``` - - ``` - +--------------------+ - | Database | - +--------------------+ - | test | - | information_schema | - +--------------------+ - ``` - -2. Display all database names from the catalog named 'hms_catalog'. - - ```sql - SHOW DATABASES from hms_catalog; - ``` - - ``` - +---------------+ - | Database | - +---------------+ - | default | - | tpch | - +---------------+ - ``` - -3. Display the filtered database names from current catalog with the expr 'like'. - - ```sql - SHOW DATABASES like 'infor%'; - ``` - - ``` - +--------------------+ - | Database | - +--------------------+ - | information_schema | - +--------------------+ - ``` - -### Keywords - - SHOW, DATABASES - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-DELETE.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-DELETE.md deleted file mode 100644 index 38dc3a0278c31..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-DELETE.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "SHOW-DELETE", - "language": "en" -} ---- - - - -## SHOW-DELETE - -### Name - -SHOW DELETE - -### Description - -This statement is used to display the historical delete tasks that have been successfully executed - -grammar: - -```sql -SHOW DELETE [FROM db_name] -``` - -### Example - - 1. Display all historical delete tasks of database database - - ```sql - SHOW DELETE FROM database; - ``` - -### Keywords - - SHOW, DELETE - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-DYNAMIC-PARTITION.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-DYNAMIC-PARTITION.md deleted file mode 100644 index d59ddee769f99..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-DYNAMIC-PARTITION.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "SHOW-DYNAMIC-PARTITION", - "language": "en" -} ---- - - - -## SHOW-DYNAMIC-PARTITION - -### Name - -SHOW DYNAMIC - -### Description - -This statement is used to display the status of all dynamic partition tables under the current db - -grammar: - -```sql -SHOW DYNAMIC PARTITION TABLES [FROM db_name]; -``` - -### Example - - 1. Display all dynamic partition table status of database database - - ```sql - SHOW DYNAMIC PARTITION TABLES FROM database; - ``` - -### Keywords - - SHOW, DYNAMIC, PARTITION - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-ENCRYPT-KEY.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-ENCRYPT-KEY.md deleted file mode 100644 index be8cef64823ec..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-ENCRYPT-KEY.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -{ - "title": "SHOW-ENCRYPT-KEY", - "language": "en" -} ---- - - - -## SHOW-ENCRYPT-KEY - -### Name - -SHOW ENCRYPTKEYS - -### Description - -View all custom keys under the database. If the user specifies a database, check the corresponding database, otherwise directly query the database where the current session is located. - -Requires `ADMIN` privilege on this database - -grammar: - -```sql -SHOW ENCRYPTKEYS [IN|FROM db] [LIKE 'key_pattern'] -``` - -parameter - ->`db`: database name to query ->`key_pattern`: parameter used to filter key names - -### Example - - ```sql - mysql> SHOW ENCRYPTKEYS; - +-------------------+-------------------+ - | EncryptKey Name | EncryptKey String | - +-------------------+-------------------+ - | example_db.my_key | ABCD123456789 | - +-------------------+-------------------+ - 1 row in set (0.00 sec) - - mysql> SHOW ENCRYPTKEYS FROM example_db LIKE "%my%"; - +-------------------+-------------------+ - | EncryptKey Name | EncryptKey String | - +-------------------+-------------------+ - | example_db.my_key | ABCD123456789 | - +-------------------+-------------------+ - 1 row in set (0.00 sec) - ``` - -### Keywords - - SHOW, ENCRYPT, KEY - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-ENGINES.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-ENGINES.md deleted file mode 100644 index e40839909c48d..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-ENGINES.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -{ - "title": "SHOW-ENGINES", - "language": "en" -} ---- - - - -## SHOW-ENGINES - -### Description - -### Example - -### Keywords - - SHOW, ENGINES - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-EVENTS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-EVENTS.md deleted file mode 100644 index 0a30dbfc95727..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-EVENTS.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -{ - "title": "SHOW-EVENTS", - "language": "en" -} ---- - - - -## SHOW-EVENTS - -### Description - -### Example - -### Keywords - - SHOW, EVENTS - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-EXPORT.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-EXPORT.md deleted file mode 100644 index ce7c917ca8d11..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-EXPORT.md +++ /dev/null @@ -1,124 +0,0 @@ ---- -{ - "title": "SHOW-EXPORT", - "language": "en" -} ---- - - - -## SHOW-EXPORT - -### Name - -SHOW EXPORT - -### Description - -This statement is used to display the execution of the specified export task - -grammar: - -```sql -SHOW EXPORT -[FROM db_name] - [ - WHERE - [ID=your_job_id] - [STATE = ["PENDING"|"EXPORTING"|"FINISHED"|"CANCELLED"]] - [LABEL=your_label] - ] -[ORDER BY...] -[LIMIT limit]; -``` - -illustrate: - 1. If db_name is not specified, the current default db is used - 2. If STATE is specified, matches EXPORT state - 3. You can use ORDER BY to sort any combination of columns - 4. If LIMIT is specified, limit matching records are displayed. Otherwise show all - -The meaning of each column in the result returned by the `show export` command is as follows: - -- JobId: The unique ID of the job -- Label: The label of the export job. If not specified in the export, the system will generate one by default. -- State: Job status: - - PENDING: Job pending scheduling - - EXPORTING: Data export in progress - - FINISHED: Job successful - - CANCELLED: Job failed -- Progress: Job progress. This progress is based on query plans. For example, if there are a total of 10 threads and 3 have been completed, the progress is 30%. -- TaskInfo: Job information displayed in JSON format: - - db: Database name - - tbl: Table name - - partitions: Specified partitions for export. An empty list indicates all partitions. - - column\_separator: Column separator for the export file. - - line\_delimiter: Line delimiter for the export file. - - tablet num: Total number of tablets involved. - - broker: Name of the broker used. - - coord num: Number of query plans. - - max\_file\_size: Maximum size of an export file. - - delete\_existing\_files: Whether to delete existing files and directories in the export directory. - - columns: Specified column names to export, empty value represents exporting all columns. - - format: File format for export -- Path: Export path on the remote storage. -- `CreateTime/StartTime/FinishTime`: Job creation time, scheduling start time, and end time. -- Timeout: Job timeout time in seconds. This time is calculated from CreateTime. -- ErrorMsg: If there is an error in the job, the error reason will be displayed here. -- OutfileInfo: If the job is successfully exported, specific `SELECT INTO OUTFILE` result information will be displayed here. - -### Example - -1. Show all export tasks of default db - - ```sql - SHOW EXPORT; - ``` - -2. Display the export tasks of the specified db, sorted by StartTime in descending order - - ```sql - SHOW EXPORT FROM example_db ORDER BY StartTime DESC; - ``` - -3. Display the export tasks of the specified db, the state is "exporting", and sort by StartTime in descending order - - ```sql - SHOW EXPORT FROM example_db WHERE STATE = "exporting" ORDER BY StartTime DESC; - ``` - -4. Display the export task of the specified db and specified job_id - - ```sql - SHOW EXPORT FROM example_db WHERE ID = job_id; - ``` - -5. Display the specified db and specify the export task of the label - - ```sql - SHOW EXPORT FROM example_db WHERE LABEL = "mylabel"; - ``` - -### Keywords - - SHOW, EXPORT - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-FILE.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-FILE.md deleted file mode 100644 index f1dc047e9a5b3..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-FILE.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -{ - "title": "SHOW-FILE", - "language": "en" -} ---- - - - -## SHOW-FILE - -### Name - -SHOW FILE - -### Description - -This statement is used to display a file created in a database - -grammar: - -```sql -SHOW FILE [FROM database]; -``` - -illustrate: - -```text -FileId: file ID, globally unique -DbName: the name of the database to which it belongs -Catalog: Custom Category -FileName: file name -FileSize: file size, in bytes -MD5: MD5 of the file -``` - -### Example - -1. View the uploaded files in the database my_database - - ```sql - SHOW FILE FROM my_database; - ``` - -### Keywords - - SHOW, FILE - -### Best Practice \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-FRONTENDS-DISKS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-FRONTENDS-DISKS.md deleted file mode 100644 index 17f196e68436a..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-FRONTENDS-DISKS.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -{ - "title": "SHOW-FRONTENDS-DISKS", - "language": "en" -} ---- - - - -## SHOW-FRONTENDS-DISKS - -### Name - -SHOW FRONTENDS DISKS - -### Description - -This statement is used to view FE nodes's important paths' disk information, such as meta, log, audit-log and temp dir. - - grammar: - -```sql -SHOW FRONTENDS DISKS; -``` - -illustrate: - -1. Name indicates the name of the FE node in bdbje. -2. Host indicates the ip of the FE node. -3. DirType indicates the type of dir type, such as meta, log, audit-log temp and deploy dir. -4. Dir indicates the dir path of FE node dir in which type. -5. FileSystem indicates the dir path in which file system on the linux operation system. -6. Capacity indicates total capacity of the filesystem. -7. Used indicates the size of the filesystem already used. -8. Available indicates the size of the filesystem remained. -9. UseRate indicates File system usage capacity ratio. -10. MountOn indicates the mount dir of the filesystem. - -### Example -` -mysql> show frontends disks; -+-----------------------------------------+-------------+-----------+---------------------------------+------------+----------+------+-----------+---------+------------+ -| Name | Host | DirType | Dir | Filesystem | Capacity | Used | Available | UseRate | MountOn | -+-----------------------------------------+-------------+-----------+---------------------------------+------------+----------+------+-----------+---------+------------+ -| fe_a1daac68_5ec0_477c_b5e8_f90a33cdc1bb | 10.xx.xx.90 | meta | /home/disk/output/fe/doris-meta | /dev/sdf1 | 7T | 2T | 4T | 36% | /home/disk | -| fe_a1daac68_5ec0_477c_b5e8_f90a33cdc1bb | 10.xx.xx.90 | log | /home/disk/output/fe/log | /dev/sdf1 | 7T | 2T | 4T | 36% | /home/disk | -| fe_a1daac68_5ec0_477c_b5e8_f90a33cdc1bb | 10.xx.xx.90 | audit-log | /home/disk/output/fe/log | /dev/sdf1 | 7T | 2T | 4T | 36% | /home/disk | -| fe_a1daac68_5ec0_477c_b5e8_f90a33cdc1bb | 10.xx.xx.90 | temp | /home/disk/output/fe/temp_dir | /dev/sdf1 | 7T | 2T | 4T | 36% | /home/disk | -| fe_a1daac68_5ec0_477c_b5e8_f90a33cdc1bb | 10.xx.xx.90 | deploy | /home/disk/output/fe | /dev/sdf1 | 7T | 2T | 4T | 36% | /home/disk | -+-----------------------------------------+-------------+-----------+---------------------------------+------------+----------+------+-----------+---------+------------+ -5 rows in set (0.00 sec) -` - -### Keywords - - SHOW, FRONTENDS - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-FRONTENDS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-FRONTENDS.md deleted file mode 100644 index 51bfa26af91b6..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-FRONTENDS.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -{ - "title": "SHOW-FRONTENDS", - "language": "en" -} ---- - - - -## SHOW-FRONTENDS - -### Name - -SHOW FRONTENDS - -### Description - -This statement is used to view FE nodes - - grammar: - -```sql -SHOW FRONTENDS; -``` - -illustrate: - -1. name indicates the name of the FE node in bdbje. -2. If Join is true, it means that the node has joined the cluster before. But it does not mean that it is still in the cluster (may have lost contact) -3. Alive indicates whether the node is alive or not. -4. ReplayedJournalId indicates the maximum metadata journal id that has been replayed by the node. -5. LastHeartbeat is the last heartbeat. -6. IsHelper indicates whether the node is a helper node in bdbje. -7. ErrMsg is used to display the error message when the heartbeat fails. -8. CurrentConnected indicates whether the FE node is currently connected - -### Example - -### Keywords - - SHOW, FRONTENDS - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-FUNCTIONS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-FUNCTIONS.md deleted file mode 100644 index ce4cbd6ff7d4a..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-FUNCTIONS.md +++ /dev/null @@ -1,132 +0,0 @@ ---- -{ - "title": "SHOW-FUNCTIONS", - "language": "en" -} ---- - - - -## SHOW-FUNCTIONS - -### Name - -SHOW FUNCTIONS - -### Description - -View all custom (system-provided) functions under the database. If the user specifies a database, then view the corresponding database, otherwise directly query the database where the current session is located - -Requires `SHOW` permission on this database - -grammar - -```sql -SHOW [FULL] [BUILTIN] FUNCTIONS [IN|FROM db] [LIKE 'function_pattern'] -``` - -Parameters - ->`full`: Indicates the detailed information of the display function ->`builtin`: Indicates the functions provided by the display system ->`db`: database name to query ->`function_pattern`: parameter used to filter function names - -grammar - -```sql -SHOW GLOBAL [FULL] FUNCTIONS [LIKE 'function_pattern'] -``` - -Parameters - ->`global`: Indicates it means that the show function is a global function ->`full`: Indicates the detailed information of the display function ->`function_pattern`: parameter used to filter function names - -**Note: the "global" keyword is only available after v2.0** - -### Example - -```sql -mysql> show full functions in testDb\G -**************************** 1. row ******************** ****** - Signature: my_add(INT,INT) - Return Type: INT - Function Type: Scalar -Intermediate Type: NULL - Properties: {"symbol":"_ZN9doris_udf6AddUdfEPNS_15FunctionContextERKNS_6IntValES4_","object_file":"http://host:port/libudfsample.so","md5":"cfe7a362d10f3aaf6c49974ee0f1f878"} -**************************** 2. row ******************** ****** - Signature: my_count(BIGINT) - Return Type: BIGINT - Function Type: Aggregate -Intermediate Type: NULL - Properties: { "object_file": "http: // host: port / libudasample.so", "finalize_fn": "_ZN9doris_udf13CountFinalizeEPNS_15FunctionContextERKNS_9BigIntValE", "init_fn": "_ZN9doris_udf9CountInitEPNS_15FunctionContextEPNS_9BigIntValE", "merge_fn": "_ZN9doris_udf10CountMergeEPNS_15FunctionContextERKNS_9BigIntValEPS2_", "md5": " 37d185f80f95569e2676da3d5b5b9d2f","update_fn":"_ZN9doris_udf11CountUpdateEPNS_15FunctionContextERKNS_6IntValEPNS_9BigIntValE"} -**************************** 3. row ******************** ****** - Signature: id_masking(BIGINT) - Return Type: VARCHAR - Function Type: Alias -Intermediate Type: NULL - Properties: {"parameter":"id","origin_function":"concat(left(`id`, 3), `****`, right(`id`, 4))"} - -3 rows in set (0.00 sec) -mysql> show builtin functions in testDb like 'year%'; -+---------------+ -| Function Name | -+---------------+ -| year | -| years_add | -| years_diff | -| years_sub | -+---------------+ -2 rows in set (0.00 sec) - -mysql> show global full functions\G; -*************************** 1. row *************************** - Signature: decimal(ALL, INT, INT) - Return Type: VARCHAR - Function Type: Alias -Intermediate Type: NULL - Properties: {"parameter":"col, precision, scale","origin_function":"CAST(`col` AS decimal(`precision`, `scale`))"} -*************************** 2. row *************************** - Signature: id_masking(BIGINT) - Return Type: VARCHAR - Function Type: Alias -Intermediate Type: NULL - Properties: {"parameter":"id","origin_function":"concat(left(`id`, 3), `****`, right(`id`, 4))"} -2 rows in set (0.00 sec) - -mysql> show global functions ; -+---------------+ -| Function Name | -+---------------+ -| decimal | -| id_masking | -+---------------+ -2 rows in set (0.00 sec) - -``` - -### Keywords - - SHOW, FUNCTIONS - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-GRANTS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-GRANTS.md deleted file mode 100644 index c88ad56f9f961..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-GRANTS.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -{ - "title": "SHOW-GRANTS", - "language": "en" -} ---- - - - -## SHOW-GRANTS - -### Name - -SHOW GRANTS - -### Description - - This statement is used to view user permissions. - -grammar: - -```sql -SHOW [ALL] GRANTS [FOR user_identity]; -``` - -illustrate: - -1. SHOW ALL GRANTS can view the permissions of all users. -2. If user_identity is specified, view the permissions of the specified user. And the user_identity must be created by the CREATE USER command. -3. If user_identity is not specified, view the permissions of the current user. - -### Example - -1. View all user permission information - - ```sql - SHOW ALL GRANTS; - ``` - -2. View the permissions of the specified user - - ```sql - SHOW GRANTS FOR jack@'%'; - ``` - -3. View the permissions of the current user - - ```sql - SHOW GRANTS; - ``` - -### Keywords - - SHOW, GRANTS - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-INDEX.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-INDEX.md deleted file mode 100644 index f8af9ce054178..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-INDEX.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -{ - "title": "SHOW-INDEX", - "language": "en" -} ---- - - - -## SHOW-INDEX - -### Name - -SHOW INDEX - -### Description - - This statement is used to display information about indexes in a table. - -grammar: - -```SQL -SHOW INDEX[ES] FROM [db_name.]table_name [FROM database]; -or -SHOW KEY[S] FROM [db_name.]table_name [FROM database]; -``` - -### Example - - 1. Display the lower index of the specified table_name - - ```SQL - SHOW INDEX FROM example_db.table_name; - ``` - -### Keywords - - SHOW, INDEX - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-LAST-INSERT.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-LAST-INSERT.md deleted file mode 100644 index d34be9be00324..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-LAST-INSERT.md +++ /dev/null @@ -1,78 +0,0 @@ ---- -{ - "title": "SHOW-LAST-INSERT", - "language": "en" -} - ---- - - - -## SHOW-LAST-INSERT - -### Name - -SHOW LAST INSERT - -### Description - -This syntax is used to view the result of the latest insert operation in the current session connection - -grammar: - -```sql -SHOW LAST INSERT -``` - -Example of returned result: - -``` - TransactionId: 64067 - Label: insert_ba8f33aea9544866-8ed77e2844d0cc9b - Database: default_cluster:db1 - Table: t1 -TransactionStatus: VISIBLE - LoadedRows: 2 - FilteredRows: 0 -``` - -illustrate: - -* TransactionId: transaction id -* Label: the label corresponding to the insert task -* Database: the database corresponding to insert -* Table: the table corresponding to insert -* TransactionStatus: transaction status - * PREPARE: preparation stage - * PRECOMMITTED: Pre-commit stage - * COMMITTED: The transaction succeeded, but the data was not visible - * VISIBLE: The transaction succeeded and the data is visible - * ABORTED: Transaction failed -* LoadedRows: Number of imported rows -* FilteredRows: The number of rows being filtered - -### Example - -### Keywords - - SHOW, LASR ,INSERT - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-LOAD-PROFILE.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-LOAD-PROFILE.md deleted file mode 100644 index dad7e79c634d1..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-LOAD-PROFILE.md +++ /dev/null @@ -1,235 +0,0 @@ ---- -{ - "title": "SHOW-LOAD-PROFILE", - "language": "en" -} ---- - - - -## SHOW-LOAD-PROFILE - -### Name - -SHOW LOAD PROFILE - -:::caution -Since 2.1.1, this syntax is deprecated. -::: - -### Description - -This statement is used to view the Profile information of the import operation. This function requires the user to open the Profile settings. The versions before 0.15 perform the following settings: - -```sql -SET is_report_success=true; -``` - -Versions 0.15 and later perform the following settings: - -```sql -SET [GLOBAL] enable_profile=true; -``` - -grammar: - -```sql -show load profile "/"; - -show load profile "/[queryId]" - -show load profile "/[queryId]/[TaskId]" - -show load profile "/[queryId]/[TaskId]/[FragmentId]/" - -show load profile "/[queryId]/[TaskId]/[FragmentId]/[InstanceId]" -``` - -This command will list all currently saved import profiles. Each line corresponds to one import. where the QueryId column is the ID of the import job. This ID can also be viewed through the SHOW LOAD statement. We can select the QueryId corresponding to the Profile we want to see to see the specific situation - -### Example - -1. List all Load Profiles - - ```sql - mysql> show load profile "/"\G -*************************** 1. row *************************** - JobId: 20010 - QueryId: 980014623046410a-af5d36f23381017f - User: root - DefaultDb: default_cluster:test - SQL: LOAD LABEL xxx - QueryType: Load - StartTime: 2023-03-07 19:48:24 - EndTime: 2023-03-07 19:50:45 - TotalTime: 2m21s - QueryState: N/A - TraceId: - AnalysisTime: NULL - PlanTime: NULL - ScheduleTime: NULL - FetchResultTime: NULL - WriteResultTime: NULL -WaitAndFetchResultTime: NULL -*************************** 2. row *************************** - JobId: N/A - QueryId: 7cc2d0282a7a4391-8dd75030185134d8 - User: root - DefaultDb: default_cluster:test - SQL: insert into xxx - QueryType: Load - StartTime: 2023-03-07 19:49:15 - EndTime: 2023-03-07 19:49:15 - TotalTime: 102ms - QueryState: OK - TraceId: - AnalysisTime: 825.277us - PlanTime: 4.126ms - ScheduleTime: N/A - FetchResultTime: 0ns - WriteResultTime: 0ns -WaitAndFetchResultTime: N/A - ``` - -2. View an overview of the subtasks with imported jobs: - - ```sql - mysql> show load profile "/980014623046410a-af5d36f23381017f"; - +-----------------------------------+------------+ - | TaskId | ActiveTime | - +-----------------------------------+------------+ - | 980014623046410a-af5d36f23381017f | 3m14s | - +-----------------------------------+------------+ - ``` - -3. View the plan tree of the specified subtask - - ```sql - show load profile "/980014623046410a-af5d36f23381017f/980014623046410a-af5d36f23381017f"; - - ┌───────────────────────┐ - │[-1: OlapTableSink] │ - │Fragment: 0 │ - │MaxActiveTime: 86.541ms│ - └───────────────────────┘ - │ - │ - ┌───────────────────┐ - │[1: VEXCHANGE_NODE]│ - │Fragment: 0 │ - └───────────────────┘ - ┌─────────────────────────┴───────┐ - │ │ - ┌─────────────┐ ┌───────────────────────┐ - │[MemoryUsage]│ │[1: VDataStreamSender] │ - │Fragment: 0 │ │Fragment: 1 │ - └─────────────┘ │MaxActiveTime: 34.882ms│ - └───────────────────────┘ - │ - │ - ┌───────────────────────────┐ - │[0: VNewOlapScanNode(tbl1)]│ - │Fragment: 1 │ - └───────────────────────────┘ - ┌─────────────────┴───────┐ - │ │ - ┌─────────────┐ ┌───────────┐ - │[MemoryUsage]│ │[VScanner] │ - │Fragment: 1 │ │Fragment: 1│ - └─────────────┘ └───────────┘ - ┌───────┴─────────┐ - │ │ - ┌─────────────────┐ ┌─────────────┐ - │[SegmentIterator]│ │[MemoryUsage]│ - │Fragment: 1 │ │Fragment: 1 │ - └─────────────────┘ └─────────────┘ - - ```sql - - This will show the plan tree and fragment id on it - -4. View the Instance overview of the specified subtask - - ```sql - mysql> show load profile "/980014623046410a-af5d36f23381017f/980014623046410a-af5d36f23381017f/1"\G - +-----------------------------------+------------------+------------+ - | Instances | Host | ActiveTime | - +-----------------------------------+------------------+------------+ - | 980014623046410a-88e260f0c43031f2 | 10.81.85.89:9067 | 3m7s | - | 980014623046410a-88e260f0c43031f3 | 10.81.85.89:9067 | 3m6s | - | 980014623046410a-88e260f0c43031f4 | 10.81.85.89:9067 | 3m10s | - | 980014623046410a-88e260f0c43031f5 | 10.81.85.89:9067 | 3m14s | - +-----------------------------------+------------------+------------+ - ``` - -4. Continue to view the detailed Profile of each operator on a specific Instance - - ```sql - mysql> show load profile "/980014623046410a-af5d36f23381017f/980014623046410a-af5d36f23381017f/1/980014623046410a-88e260f0c43031f5"\G - - *************************** 1. row *************************** - - Instance: - - ┌-----------------------------------------┐ - │[-1: OlapTableSink] │ - │(Active: 2m17s, non-child: 70.91) │ - │ - Counters: │ - │ - CloseWaitTime: 1m53s │ - │ - ConvertBatchTime: 0ns │ - │ - MaxAddBatchExecTime: 1m46s │ - │ - NonBlockingSendTime: 3m11s │ - │ - NumberBatchAdded: 782 │ - │ - NumberNodeChannels: 1 │ - │ - OpenTime: 743.822us │ - │ - RowsFiltered: 0 │ - │ - RowsRead: 1.599729M (1599729) │ - │ - RowsReturned: 1.599729M (1599729)│ - │ - SendDataTime: 11s761ms │ - │ - TotalAddBatchExecTime: 1m46s │ - │ - ValidateDataTime: 9s802ms │ - └-----------------------------------------┘ - │ - ┌-----------------------------------------------------┐ - │[0: BROKER_SCAN_NODE] │ - │(Active: 56s537ms, non-child: 29.06) │ - │ - Counters: │ - │ - BytesDecompressed: 0.00 │ - │ - BytesRead: 5.77 GB │ - │ - DecompressTime: 0ns │ - │ - FileReadTime: 34s263ms │ - │ - MaterializeTupleTime(*): 45s54ms │ - │ - NumDiskAccess: 0 │ - │ - PeakMemoryUsage: 33.03 MB │ - │ - RowsRead: 1.599729M (1599729) │ - │ - RowsReturned: 1.599729M (1599729) │ - │ - RowsReturnedRate: 28.295K sec │ - │ - TotalRawReadTime(*): 1m20s │ - │ - TotalReadThroughput: 30.39858627319336 MB/sec│ - │ - WaitScannerTime: 56s528ms │ - └-----------------------------------------------------┘ - ``` - -### Keywords - - SHOW, LOAD, PROFILE - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-LOAD-WARNINGS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-LOAD-WARNINGS.md deleted file mode 100644 index f460e29f9e682..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-LOAD-WARNINGS.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -{ - "title": "SHOW-LOAD-WARNINGS", - "language": "en" -} ---- - - - -## SHOW-LOAD-WARNINGS - -### Name - -SHOW LOAD WARNINGS - -### Description - -If the import task fails and the error message is `ETL_QUALITY_UNSATISFIED`, it means that there is an import quality problem. If you want to see these import tasks with quality problems, change the statement to complete this operation. - -grammar: - -```sql -SHOW LOAD WARNINGS -[FROM db_name] -[ - WHERE - [LABEL[="your_label"]] - [LOAD_JOB_ID = ["job id"]] -] -``` - -1) If db_name is not specified, the current default db is used -1) If LABEL = is used, it matches the specified label exactly -1) If LOAD_JOB_ID is specified, match the specified JOB ID exactly - -### Example - -1. Display the data with quality problems in the import task of the specified db, and specify the label as "load_demo_20210112" - - ```sql - SHOW LOAD WARNINGS FROM demo WHERE LABEL = "load_demo_20210112" - ``` - -### Keywords - - SHOW, LOAD, WARNINGS - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-LOAD.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-LOAD.md deleted file mode 100644 index 90c964d80e64c..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-LOAD.md +++ /dev/null @@ -1,117 +0,0 @@ ---- -{ - "title": "SHOW-LOAD", - "language": "en" -} ---- - - - -## SHOW-LOAD - -### Name - -SHOW LOAD - -### Description - -This statement is used to display the execution of the specified import task - -grammar: - -```sql -SHOW LOAD -[FROM db_name] -[ - WHERE - [LABEL [ = "your_label" | LIKE "label_matcher"]] - [STATE = ["PENDING"|"ETL"|"LOADING"|"FINISHED"|"CANCELLED"|]] -] -[ORDER BY...] -[LIMIT limit][OFFSET offset]; -``` - -illustrate: - -1. If db_name is not specified, the current default db is used - -2. If LABEL LIKE is used, it will match import tasks whose label contains label_matcher - -3. If LABEL = is used, it will match the specified label exactly - -4. If STATE is specified, matches the LOAD state - -5. You can use ORDER BY to sort on any combination of columns - -6. If LIMIT is specified, limit matching records are displayed. Otherwise show all - -7. If OFFSET is specified, the query results are displayed starting at offset offset. By default the offset is 0. - -8. If you are using broker/mini load, the connections in the URL column can be viewed using the following command: - - ```sql - SHOW LOAD WARNINGS ON 'url' - ``` - -### Example - -1. Show all import tasks for default db - - ```sql - SHOW LOAD; - ``` - -2. Display the import tasks of the specified db, the label contains the string "2014_01_02", and display the oldest 10 - - ```sql - SHOW LOAD FROM example_db WHERE LABEL LIKE "2014_01_02" LIMIT 10; - ``` - -3. Display the import tasks of the specified db, specify the label as "load_example_db_20140102" and sort by LoadStartTime in descending order - - ```sql - SHOW LOAD FROM example_db WHERE LABEL = "load_example_db_20140102" ORDER BY LoadStartTime DESC; - ``` - -4. Display the import task of the specified db, specify the label as "load_example_db_20140102", the state as "loading", and sort by LoadStartTime in descending order - - ```sql - SHOW LOAD FROM example_db WHERE LABEL = "load_example_db_20140102" AND STATE = "loading" ORDER BY LoadStartTime DESC; - ``` - -5. Display the import tasks of the specified db and sort them in descending order by LoadStartTime, and display 10 query results starting from offset 5 - - ```sql - SHOW LOAD FROM example_db ORDER BY LoadStartTime DESC limit 5,10; - SHOW LOAD FROM example_db ORDER BY LoadStartTime DESC limit 10 offset 5; - ``` - -6. Small batch import is a command to check the import status - - ``` - curl --location-trusted -u {user}:{passwd} http://{hostname}:{port}/api/{database}/_load_info?label={labelname} - ``` - -### Keywords - - SHOW, LOAD - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-OPEN-TABLES.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-OPEN-TABLES.md deleted file mode 100644 index 1ea1ed74e3411..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-OPEN-TABLES.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -{ - "title": "SHOW-OPEN-TABLES", - "language": "en" -} ---- - - - -## SHOW-OPEN-TABLES - -### Description - -### Example - -### Keywords - - SHOW, OPEN, TABLES - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-PARTITIONS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-PARTITIONS.md deleted file mode 100644 index fc04e3297ae0d..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-PARTITIONS.md +++ /dev/null @@ -1,84 +0,0 @@ ---- -{ - "title": "SHOW-PARTITIONS", - "language": "en" -} ---- - - - -## SHOW-PARTITIONS - -### Name - -SHOW PARTITIONS - -### Description - - This statement is used to display partition information for tables in Internal catalog or Hive Catalog - -grammar: - -```SQL - SHOW [TEMPORARY] PARTITIONS FROM [db_name.]table_name [WHERE] [ORDER BY] [LIMIT]; -``` - -illustrate: - -When used in Internal catalog: -1. Support the filtering of PartitionId, PartitionName, State, Buckets, ReplicationNum, LastConsistencyCheckTime and other columns -2. TEMPORARY specifies to list temporary partitions - -when used in Hive Catalog: -Will return all partitions' name. Support multilevel partition table - - -### Example - -1. Display all non-temporary partition information of the specified table under the specified db - -```SQL - SHOW PARTITIONS FROM example_db.table_name; -``` - -2. Display all temporary partition information of the specified table under the specified db - - ```SQL - SHOW TEMPORARY PARTITIONS FROM example_db.table_name; - ``` - -3. Display the information of the specified non-temporary partition of the specified table under the specified db - - ```SQL - SHOW PARTITIONS FROM example_db.table_name WHERE PartitionName = "p1"; - ``` - -4. Display the latest non-temporary partition information of the specified table under the specified db - - ```SQL - SHOW PARTITIONS FROM example_db.table_name ORDER BY PartitionId DESC LIMIT 1; - ``` - -### Keywords - - SHOW, PARTITIONS - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-PLUGINS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-PLUGINS.md deleted file mode 100644 index a23e1f272d3ab..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-PLUGINS.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -{ - "title": "SHOW-PLUGINS", - "language": "en" -} ---- - - - -## SHOW-PLUGINS - -### Name - -SHOW PLUGINS - -### Description - -This statement is used to display installed plugins - -grammar: - -```SQL -SHOW PLUGINS -``` - -This command will display all user-installed and system built-in plugins - -### Example - -1. Show installed plugins: - - ```SQL - SHOW PLUGINS; - ``` - -### Keywords - - SHOW, PLUGINS - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-POLICY.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-POLICY.md deleted file mode 100644 index 9c55953be2c3a..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-POLICY.md +++ /dev/null @@ -1,111 +0,0 @@ ---- -{ - "title": "SHOW-POLICY", - "language": "en" -} ---- - - - -## SHOW-POLICY - -### Name - -SHOW ROW POLICY - -### Description - -View the row security policy under the current DB - -```sql -SHOW ROW POLICY [FOR user| ROLE role] -``` - -### Example - -1. view all security policies. - - ```sql - mysql> SHOW ROW POLICY; - +-------------------+----------------------+-----------+------+-------------+-------------------+------+-------------------------------------------------------------------------------------------------------------------------------------------+ - | PolicyName | DbName | TableName | Type | FilterType | WherePredicate | User | OriginStmt | - +-------------------+----------------------+-----------+------+-------------+-------------------+------+-------------------------------------------------------------------------------------------------------------------------------------------+ - | test_row_policy_1 | default_cluster:test | table1 | ROW | RESTRICTIVE | `id` IN (1, 2) | root | /* ApplicationName=DataGrip 2021.3.4 */ CREATE ROW POLICY test_row_policy_1 ON test.table1 AS RESTRICTIVE TO root USING (id in (1, 2)); - | - | test_row_policy_2 | default_cluster:test | table1 | ROW | RESTRICTIVE | `col1` = 'col1_1' | root | /* ApplicationName=DataGrip 2021.3.4 */ CREATE ROW POLICY test_row_policy_2 ON test.table1 AS RESTRICTIVE TO root USING (col1='col1_1'); - | - +-------------------+----------------------+-----------+------+-------------+-------------------+------+-------------------------------------------------------------------------------------------------------------------------------------------+ - 2 rows in set (0.00 sec) - ``` - -2. specify user name query - - ```sql - mysql> SHOW ROW POLICY FOR test; - +-------------------+----------------------+-----------+------+------------+-------------------+----------------------+------------------------------------------------------------------------------------------------------------------------------------------+ - | PolicyName | DbName | TableName | Type | FilterType | WherePredicate | User | OriginStmt | - +-------------------+----------------------+-----------+------+------------+-------------------+----------------------+------------------------------------------------------------------------------------------------------------------------------------------+ - | test_row_policy_3 | default_cluster:test | table1 | ROW | PERMISSIVE | `col1` = 'col1_2' | default_cluster:test | /* ApplicationName=DataGrip 2021.3.4 */ CREATE ROW POLICY test_row_policy_3 ON test.table1 AS PERMISSIVE TO test USING (col1='col1_2'); - | - +-------------------+----------------------+-----------+------+------------+-------------------+----------------------+------------------------------------------------------------------------------------------------------------------------------------------+ - 1 row in set (0.01 sec) - ``` - -3. specify role name query - - ```sql - mysql> SHOW ROW POLICY for role role1; - +------------+--------+-----------+------+-------------+----------------+------+-------+----------------------------------------------------------------------------------+ - | PolicyName | DbName | TableName | Type | FilterType | WherePredicate | User | Role | OriginStmt | - +------------+--------+-----------+------+-------------+----------------+------+-------+----------------------------------------------------------------------------------+ - | zdtest1 | zd | user | ROW | RESTRICTIVE | `user_id` = 1 | NULL | role1 | create row policy zdtest1 on user as restrictive to role role1 using (user_id=1) | - +------------+--------+-----------+------+-------------+----------------+------+-------+----------------------------------------------------------------------------------+ - 1 row in set (0.01 sec) - ``` - -4. demonstrate data migration strategies - ```sql - mysql> SHOW STORAGE POLICY; - +---------------------+---------+-----------------------+---------------------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | PolicyName | Type | StorageResource | CooldownDatetime | CooldownTtl | properties | - +---------------------+---------+-----------------------+---------------------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | showPolicy_1_policy | STORAGE | showPolicy_1_resource | 2022-06-08 00:00:00 | -1 | { - "type": "s3", - "s3.endpoint": "bj.s3.comaaaa", - "s3.region": "bj", - "s3.access_key": "bbba", - "s3.secret_key": "******", - "s3.root.path": "path/to/rootaaaa", - "s3.bucket": "test-bucket", - "s3.connection.request.timeout": "3000" - "3.connection.maximum": "50", - "s3.connection.timeout": "1000", - } | - +---------------------+---------+-----------------------+---------------------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - 1 row in set (0.00 sec) - ``` - - -### Keywords - - SHOW, POLICY - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-PRIVILEGES.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-PRIVILEGES.md deleted file mode 100644 index 237b45f09f224..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-PRIVILEGES.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "Show Privileges", - "language": "en" -} ---- - - - -## SHOW-PRIVILEGES - -### Name - -SHOW PRIVILEGES - -### Description - -This statement is used to display all permission items. - -grammar: - -```SQL -SHOW PRIVILEGES -``` - -### Example - -1. display all permission items - - ```SQL - SHOW PRIVILEGES - ``` - -### Keywords - - SHOW, PRIVILEGES - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-PROC.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-PROC.md deleted file mode 100644 index e896eb1650723..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-PROC.md +++ /dev/null @@ -1,278 +0,0 @@ ---- -{ - "title": "SHOW-PROC", - "language": "en" -} ---- - - - -## SHOW-PROC - -### Name - -SHOW PROC - -### Description - -The Proc system is a unique feature of Doris. Students who have used Linux may understand this concept better. In Linux systems, proc is a virtual file system, usually mounted in the /proc directory. Users can view the internal data structure of the system through this file system. For example, you can view the details of the specified pid process through /proc/pid. - -Similar to the proc system in Linux, the proc system in Doris is also organized into a directory-like structure to view different system information according to the "directory path (proc path)" specified by the user. - -The proc system is designed mainly for system administrators, so that it is convenient for them to view some running states inside the system. Such as the tablet status of the table, the cluster balance status, the status of various jobs, and so on. is a very useful function - -There are two ways to view the proc system in Doris. - -1. View through the WEB UI interface provided by Doris, visit the address: `http://FE_IP:FE_HTTP_PORT` -2. Another way is by command - -All commands supported by Doris PROC can be seen through ` SHOW PROC "/";` - -After connecting to Doris through the MySQL client, you can execute the SHOW PROC statement to view the information of the specified proc directory. The proc directory is an absolute path starting with "/". - -The results of the show proc statement are presented in a two-dimensional table. And usually the first column of the result table is the next subdirectory of proc. - -```none -mysql> show proc "/"; -+---------------------------+ -| name | -+---------------------------+ -| auth | -| backends | -| bdbje | -| brokers | -| catalogs | -| cluster_balance | -| cluster_health | -| colocation_group | -| current_backend_instances | -| current_queries | -| current_query_stmts | -| dbs | -| diagnose | -| frontends | -| jobs | -| load_error_hub | -| monitor | -| resources | -| routine_loads | -| statistic | -| stream_loads | -| tasks | -| transactions | -| trash | -+---------------------------+ -23 rows in set (0.00 sec) -``` - -illustrate: - -1. auth: User name and corresponding permission information -2. backends: Displays the node list of BE in the cluster, equivalent to [SHOW BACKENDS](./SHOW-BACKENDS.md) -3. bdbje: To view the bdbje database list, you need to modify the `fe.conf` file to add `enable_bdbje_debug_mode=true`, and then start `FE` through `sh start_fe.sh --daemon` to enter the `debug` mode. After entering `debug` mode, only `http server` and `MySQLServer` will be started and the `BDBJE` instance will be opened, but no metadata loading and subsequent startup processes will be entered. -4. brokers : View cluster broker node information, equivalent to [SHOW BROKER](./SHOW-BROKER.md) -5. catalogs : View the data catalogs that have been created currently, equivalent to [SHOW CATALOGS](./SHOW-CATALOGS.md) -6. cluster_balance : To check the balance of the cluster, please refer to [Data Copy Management](../../../admin-manual/maint-monitor/tablet-repair-and-balance.md) -7. cluster_health: Run SHOW PROC '/cluster_health/tablet_health'; statement to view the replica status of the entire cluster. -8. colocation_group : This command can view the existing Group information in the cluster. For details, please refer to the [Colocation Join](../../../query-acceleration/join-optimization/colocation-join.md) chapter -9. current_backend_instances : Displays a list of be nodes that are currently executing jobs -10. current_queries : View the list of queries being executed, the SQL statement currently running. -11. current_query_stmts: Returns the currently executing query. -12. dbs: Mainly used to view the metadata information of each database and the tables in the Doris cluster. This information includes table structure, partitions, materialized views, data shards and replicas, and more. Through this directory and its subdirectories, you can clearly display the table metadata in the cluster, and locate some problems such as data skew, replica failure, etc. -13. diagnose: Report and diagnose common management and control issues in the cluster, including replica balance and migration, transaction exceptions, etc. -14. frontends: Display all FE node information in the cluster, including IP address, role, status, whether it is a master, etc., equivalent to [SHOW FRONTENDS](./SHOW-FRONTENDS.md) -15. jobs: show statistics of all kind of jobs. If a specific `dbId` is given, will return statistics data of the database. If `dbId` is -1, will return total statistics data of all databases -16. load_error_hub: Doris supports centralized storage of error information generated by load jobs in an error hub. Then view the error message directly through the SHOW LOAD WARNINGS; statement. Shown here is the configuration information of the error hub. -17. monitor : shows the resource usage of FE JVM -18. resources : View system resources, ordinary accounts can only see resources that they have USAGE_PRIV permission to use. Only the root and admin accounts can see all resources. Equivalent to [SHOW RESOURCES](./SHOW-RESOURCES.md) -19. routine_loads: Display all routine load job information, including job name, status, etc. -20. statistics: It is mainly used to summarize and view the number of databases, tables, partitions, shards, and replicas in the Doris cluster. and the number of unhealthy copies. This information helps us to control the size of the cluster meta-information in general. It helps us view the cluster sharding situation from an overall perspective, and can quickly check the health of the cluster sharding. This further locates problematic data shards. -21. stream_loads: Returns the stream load task being executed. -22. tasks : Displays the total number of tasks of various jobs and the number of failures. -23. transactions : used to view the transaction details of the specified transaction id, equivalent to [SHOW TRANSACTION](./SHOW-TRANSACTION.md) -24. trash: This statement is used to view the space occupied by garbage data in the backend. Equivalent to [SHOW TRASH](./SHOW-TRASH.md) - -### Example - -1. For example, "/dbs" displays all databases, and "/dbs/10002" displays all tables under the database with id 10002 - - ```sql - mysql> show proc "/dbs/10002"; - +---------+----------------------+----------+---------------------+--------------+--------+------+--------------------------+--------------+ - | TableId | TableName | IndexNum | PartitionColumnName | PartitionNum | State | Type | LastConsistencyCheckTime | ReplicaCount | - +---------+----------------------+----------+---------------------+--------------+--------+------+--------------------------+--------------+ - | 10065 | dwd_product_live | 1 | dt | 9 | NORMAL | OLAP | NULL | 18 | - | 10109 | ODS_MR_BILL_COSTS_DO | 1 | NULL | 1 | NORMAL | OLAP | NULL | 1 | - | 10119 | test | 1 | NULL | 1 | NORMAL | OLAP | NULL | 1 | - | 10124 | test_parquet_import | 1 | NULL | 1 | NORMAL | OLAP | NULL | 1 | - +---------+----------------------+----------+---------------------+--------------+--------+------+--------------------------+--------------+ - 4 rows in set (0.00 sec) - ``` - -2. Display information about the number of all database tables in the cluster. - - ```sql - mysql> show proc '/statistic'; - +-------+----------------------+----------+--------------+----------+-----------+------------+ - | DbId | DbName | TableNum | PartitionNum | IndexNum | TabletNum | ReplicaNum | - +-------+----------------------+----------+--------------+----------+-----------+------------+ - | 10002 | default_cluster:test | 4 | 12 | 12 | 21 | 21 | - | Total | 1 | 4 | 12 | 12 | 21 | 21 | - +-------+----------------------+----------+--------------+----------+-----------+------------+ - 2 rows in set (0.00 sec) - ``` - -3. The following command can view the existing Group information in the cluster. - - ``` - SHOW PROC '/colocation_group'; - - +-------------+--------------+--------------+------------+----------------+----------+----------+ - | GroupId | GroupName | TableIds | BucketsNum | ReplicationNum | DistCols | IsStable | - +-------------+--------------+--------------+------------+----------------+----------+----------+ - | 10005.10008 | 10005_group1 | 10007, 10040 | 10 | 3 | int(11) | true | - +-------------+--------------+--------------+------------+----------------+----------+----------+ - ``` - - - GroupId: The cluster-wide unique identifier of a group, the first half is the db id, and the second half is the group id. - - GroupName: The full name of the Group. - - TabletIds: The id list of Tables contained in this Group. - - BucketsNum: The number of buckets. - - ReplicationNum: The number of replicas. - - DistCols: Distribution columns, that is, the bucket column type. - - IsStable: Whether the Group is stable (for the definition of stability, see the `Colocation replica balance and repair` section). - -4. Use the following commands to further view the data distribution of a Group: - - ```sql - SHOW PROC '/colocation_group/10005.10008'; - - +-------------+---------------------+ - | BucketIndex | BackendIds | - +-------------+---------------------+ - | 0 | 10004, 10002, 10001 | - | 1 | 10003, 10002, 10004 | - | 2 | 10002, 10004, 10001 | - | 3 | 10003, 10002, 10004 | - | 4 | 10002, 10004, 10003 | - | 5 | 10003, 10002, 10001 | - | 6 | 10003, 10004, 10001 | - | 7 | 10003, 10004, 10002 | - +-------------+---------------------+ - ``` - - - BucketIndex: The index of the bucket sequence. - - BackendIds: The list of BE node IDs where the data shards in the bucket are located. - -5. Display the total number of tasks of various jobs and the number of failures. - - ```sql - mysql> show proc '/tasks'; - +-------------------------+-----------+----------+ - | TaskType | FailedNum | TotalNum | - +-------------------------+-----------+----------+ - | CREATE | 0 | 0 | - | DROP | 0 | 0 | - | PUSH | 0 | 0 | - | CLONE | 0 | 0 | - | STORAGE_MEDIUM_MIGRATE | 0 | 0 | - | ROLLUP | 0 | 0 | - | SCHEMA_CHANGE | 0 | 0 | - | CANCEL_DELETE | 0 | 0 | - | MAKE_SNAPSHOT | 0 | 0 | - | RELEASE_SNAPSHOT | 0 | 0 | - | CHECK_CONSISTENCY | 0 | 0 | - | UPLOAD | 0 | 0 | - | DOWNLOAD | 0 | 0 | - | CLEAR_REMOTE_FILE | 0 | 0 | - | MOVE | 0 | 0 | - | REALTIME_PUSH | 0 | 0 | - | PUBLISH_VERSION | 0 | 0 | - | CLEAR_ALTER_TASK | 0 | 0 | - | CLEAR_TRANSACTION_TASK | 0 | 0 | - | RECOVER_TABLET | 0 | 0 | - | STREAM_LOAD | 0 | 0 | - | UPDATE_TABLET_META_INFO | 0 | 0 | - | ALTER | 0 | 0 | - | INSTALL_PLUGIN | 0 | 0 | - | UNINSTALL_PLUGIN | 0 | 0 | - | Total | 0 | 0 | - +-------------------------+-----------+----------+ - 26 rows in set (0.01 sec) - ``` - -5. Display the replica status of the entire cluster. - ```sql - mysql> show proc '/cluster_health/tablet_health'; - +----------+---------------------------+-----------+------------+-------------------+----------------------+----------------------+--------------+----------------------------+-------------------------+-------------------+---------------------+----------------------+----------------------+------------------+-----------------------------+-----------------+-------------+------------+ - | DbId | DbName | TabletNum | HealthyNum | ReplicaMissingNum | VersionIncompleteNum | ReplicaRelocatingNum | RedundantNum | ReplicaMissingInClusterNum | ReplicaMissingForTagNum | ForceRedundantNum | ColocateMismatchNum | ColocateRedundantNum | NeedFurtherRepairNum | UnrecoverableNum | ReplicaCompactionTooSlowNum | InconsistentNum | OversizeNum | CloningNum | - +----------+---------------------------+-----------+------------+-------------------+----------------------+----------------------+--------------+----------------------------+-------------------------+-------------------+---------------------+----------------------+----------------------+------------------+-----------------------------+-----------------+-------------+------------+ - | 25852112 | default_cluster:bowen | 1920 | 1920 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | - | 25342914 | default_cluster:bw | 128 | 128 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | - | 2575532 | default_cluster:cps | 1440 | 1440 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 16 | 0 | - | 26150325 | default_cluster:db | 38374 | 38374 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 453 | 0 | - +----------+---------------------------+-----------+------------+-------------------+----------------------+----------------------+--------------+----------------------------+-------------------------+-------------------+---------------------+----------------------+----------------------+------------------+-----------------------------+-----------------+-------------+------------+ - 4 rows in set (0.01 sec) - ``` - - View the replica status under a database, such as a database with a DbId of 25852112. - - ```sql - mysql> show proc '/cluster_health/tablet_health/25852112'; - ``` - -7. Report and diagnose cluster management issues - - ``` - MySQL > show proc "/diagnose"; - +-----------------+----------+------------+ - | Item | ErrorNum | WarningNum | - +-----------------+----------+------------+ - | cluster_balance | 2 | 0 | - | Total | 2 | 0 | - +-----------------+----------+------------+ - - 2 rows in set - ``` - - - View replica balance migration issues - - ```sql - MySQL > show proc "/diagnose/cluster_balance"; - +-----------------------+--------+-------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+------------+ - | Item | Status | Content | Detail Cmd | Suggestion | - +-----------------------+--------+-------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+------------+ - | Tablet Health | ERROR | healthy tablet num 691 < total tablet num 1014 | show proc "/cluster_health/tablet_health"; | | - | BeLoad Balance | ERROR | backend load not balance for tag {"location" : "default"}, low load backends [], high load backends [10009] | show proc "/cluster_balance/cluster_load_stat/location_default/HDD" | | - | Disk Balance | OK | | | | - | Colocate Group Stable | OK | | | | - | History Tablet Sched | OK | | | | - +-----------------------+--------+-------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+------------+ - - 5 rows in set - ``` - -### Keywords - - SHOW, PROC - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-PROCEDURE.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-PROCEDURE.md deleted file mode 100644 index 71e0e066f1a4a..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-PROCEDURE.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -{ - "title": "SHOW-PROCEDURE", - "language": "en" -} ---- - - - -## SHOW-PROCEDURE - -### Description - -### Example - -### Keywords - - SHOW, PROCEDURE - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-PROCESSLIST.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-PROCESSLIST.md deleted file mode 100644 index c7a7dbd8e319d..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-PROCESSLIST.md +++ /dev/null @@ -1,92 +0,0 @@ ---- -{ - "title": "SHOW-PROCESSLIST", - "language": "en" -} ---- - - - -## SHOW-PROCESSLIST - -### Name - -SHOW PROCESSLIST - -### Description - -Display the running threads of the user. It should be noted that except the root user who can see all running threads, other users can only see their own running threads, and cannot see the running threads of other users. - -Only display current connected FE's connection list by default, you can set session variable ```set show_all_fe_connection = true``` to show all FE's connection. - -grammar: - -```sql -SHOW [FULL] PROCESSLIST -``` - -illustrate: - -- CurrentConnected: Indicates whether the connection is currently connected -- Id: It is the unique identifier of this thread. When we find that there is a problem with this thread, we can use the kill command to add this Id value to kill this thread. -- User: refers to the user who started this thread. -- Host: Records the IP and port number of the client sending the request. Through this information, when troubleshooting the problem, we can locate which client and which process sent the request. -- LoginTime: Timestamp when the connection is make. -- Catalog: Catalog name. -- Db: which database the currently executed command is on. If no database is specified, the value is NULL . -- Command: refers to the command that the thread is executing at the moment. -- Time: Indicates the time the thread is in the current state. -- State: The state of the thread, corresponding to Command. -- QueryId: The ID of the current query statement. -- Info: Generally recorded is the statement executed by the thread. By default, only the first 100 characters are displayed, that is, the statement you see may be truncated. To see all the information, you need to use show full processlist. - -Common Command types are as follows: - -- Query: The thread is executing a statement -- Sleep: is waiting for a client to send it an execute statement -- Quit: the thread is exiting -- Kill : The kill statement is being executed to kill the specified thread - -Other types can refer to [MySQL official website for explanation](https://dev.mysql.com/doc/refman/5.6/en/thread-commands.html) - -### Example - -1. View the threads running by the current user - - ```SQL - SHOW PROCESSLIST - ``` - return - ``` - MySQL [test]> show full processlist; - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - | CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - | Yes | 0 | root | 127.0.0.1:34650 | 2023-09-06 12:01:02 | internal | test | Query | 0 | OK | c84e397193a54fe7-bbe9bc219318b75e | select 1 | - | | 1 | root | 127.0.0.1:34776 | 2023-09-06 12:01:07 | internal | | Sleep | 29 | EOF | 886ffe2894314f50-8dd73a6ca06699e4 | show full processlist | - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - ``` - -### Keywords - - SHOW, PROCESSLIST - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-PROPERTY.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-PROPERTY.md deleted file mode 100644 index 9068a575b5cc8..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-PROPERTY.md +++ /dev/null @@ -1,114 +0,0 @@ ---- -{ - "title": "SHOW-PROPERTY", - "language": "en" -} ---- - - - -## SHOW-PROPERTY - -### Description - -This statement is used to view the attributes of the user - -``` -SHOW PROPERTY [FOR user] [LIKE key] -SHOW ALL PROPERTIES [LIKE key] -``` - -* `user` - - View the attributes of the specified user. If not specified, check the current user's. - -* `LIKE` - - Fuzzy matching can be done by attribute name. - -* `ALL` - - View the properties of all users (supported since version 2.0.3) - -Return result description: - -```sql -mysql> show property like'%connection%'; -+----------------------+-------+ -| Key | Value | -+----------------------+-------+ -| max_user_connections | 100 | -+----------------------+-------+ -1 row in set (0.01 sec) -``` - -* `Key` - - Property name. - -* `Value` - - Attribute value. - - -```sql -mysql> show all properties like "%connection%"; -+-------------------+--------------------------------------+ -| User | Properties | -+-------------------+--------------------------------------+ -| root | {"max_user_connections": "100"} | -| admin | {"max_user_connections": "100"} | -| default_cluster:a | {"max_user_connections": "1000"} | -+-------------------+--------------------------------------+ -``` - -* `User` - - username. - -* `Properties` - - Key: value corresponding to each property of the user. - -### Example - -1. View the attributes of the jack user - - ```sql - SHOW PROPERTY FOR'jack'; - ``` - -2. View the attribute of jack user connection limit - - ```sql - SHOW PROPERTY FOR'jack' LIKE'%connection%'; - ``` - -3. View all users importing cluster related properties - - ```sql - SHOW ALL PROPERTIES LIKE '%load_cluster%' - ``` - -### Keywords - - SHOW, PROPERTY, ALL - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-QUERY-PROFILE.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-QUERY-PROFILE.md deleted file mode 100644 index befa745924ef4..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-QUERY-PROFILE.md +++ /dev/null @@ -1,226 +0,0 @@ ---- -{ - "title": "SHOW-QUERY-PROFILE", - "language": "en" -} ---- - - - -## SHOW-QUERY-PROFILE - -### Name - -SHOW QUERY PROFILE - -:::caution -Since 2.1.1, this syntax is deprecated. You can still download profile from http://:/QueryProfile -::: - -### Description - -This statement is used to view the tree profile information of the query operation,this function requires the user to open profile settings. -Before versions 0.15, perform the following settings: - -```sql -SET is_report_success=true; -``` - -For versions 0.15 and later, perform the following settings: - -```sql -SET [GLOBAL] enable_profile=true; -``` - -grammar: - -```sql -show query profile "/"; -``` -This command will list the profiles of all currently saved query operations. - -```sql -show query profile "/queryId"\G -show query profile "/queryId/fragment_id/instance_id"\G -``` -Get the tree profile information of the specified query ID,Return to profile simple tree.Specify fragment_ ID and instance_ ID returns the corresponding detailed profile tree. - - -### Example - -1. List all query Profile - - ```sql - mysql> show query profile "/"; - +-----------------------------------+------+-------------------------+--------------------+-----------+---------------------+---------------------+-----------+------------+ - | QueryId | User | DefaultDb | SQL | QueryType | StartTime | EndTime | TotalTime | QueryState | - +-----------------------------------+------+-------------------------+--------------------+-----------+---------------------+---------------------+-----------+------------+ - | 327167e0db4749a9-adce3b3d770b2bb1 | root | default_cluster:test_db | select * from test | Query | 2022-08-09 10:50:09 | 2022-08-09 10:50:09 | 19ms | EOF | - +-----------------------------------+------+-------------------------+--------------------+-----------+---------------------+---------------------+-----------+------------+ - 1 row in set (0.00 sec) - ``` - -2. List the query profile of the specified queryid - - ```sql - mysql> show query profile "/327167e0db4749a9-adce3b3d770b2bb1"\G - *************************** 1. row *************************** - Fragments: ┌────────────────────────┐ - │[-1: VDataBufferSender] │ - │Fragment: 0 │ - │MaxActiveTime: 783.263us│ - └────────────────────────┘ - ┌┘ - │ - ┌───────────────────┐ - │[1: VEXCHANGE_NODE]│ - │Fragment: 0 │ - └───────────────────┘ - └┐ - │ - ┌────────────────────────┐ - │[1: VDataStreamSender] │ - │Fragment: 1 │ - │MaxActiveTime: 847.612us│ - └────────────────────────┘ - │ - │ - ┌────────────────────┐ - │[0: VOLAP_SCAN_NODE]│ - │Fragment: 1 │ - └────────────────────┘ - ┌┘ - │ - ┌─────────────┐ - │[OlapScanner]│ - │Fragment: 1 │ - └─────────────┘ - │ - │ - ┌─────────────────┐ - │[SegmentIterator]│ - │Fragment: 1 │ - └─────────────────┘ - 1 row in set (0.00 sec) - ``` -3. Lists the instance profile of the specified fragment: - - ```sql - mysql> show query profile "/327167e0db4749a9-adce3b3d770b2bb1/1/"\G - *************************** 1. row *************************** - Instances: 327167e0db4749a9-adce3b3d770b2bb2 - Host: 172.26.0.1:9111 - ActiveTime: 847.612us - 1 row in set (0.01 sec) - ``` - -4. Continue to view the detailed profile of each operator on a specific instance: - - ```sql - mysql> show query profile "/327167e0db4749a9-adce3b3d770b2bb1/1/327167e0db4749a9-adce3b3d770b2bb2"\G - *************************** 1. row *************************** - Instance: ┌───────────────────────────────────────┐ - │[1: VDataStreamSender] │ - │(Active: 36.944us, non-child: 0.20) │ - │ - Counters: │ - │ - BytesSent: 0.00 │ - │ - IgnoreRows: 0 │ - │ - LocalBytesSent: 20.00 B │ - │ - OverallThroughput: 0.0 /sec │ - │ - PeakMemoryUsage: 0.00 │ - │ - SerializeBatchTime: 0ns │ - │ - UncompressedRowBatchSize: 0.00 │ - └───────────────────────────────────────┘ - │ - │ - ┌───────────────────────────────────────┐ - │[0: VOLAP_SCAN_NODE] │ - │(Active: 563.241us, non-child: 3.00) │ - │ - Counters: │ - │ - BatchQueueWaitTime: 444.714us │ - │ - BytesRead: 37.00 B │ - │ - NumDiskAccess: 1 │ - │ - NumScanners: 2 │ - │ - PeakMemoryUsage: 320.00 KB │ - │ - RowsRead: 4 │ - │ - RowsReturned: 4 │ - │ - RowsReturnedRate: 7.101K /sec │ - │ - ScannerBatchWaitTime: 206.40us │ - │ - ScannerSchedCount : 2 │ - │ - ScannerWorkerWaitTime: 34.640us│ - │ - TabletCount : 2 │ - │ - TotalReadThroughput: 0.0 /sec │ - └───────────────────────────────────────┘ - │ - │ - ┌─────────────────────────────────┐ - │[OlapScanner] │ - │(Active: 0ns, non-child: 0.00) │ - │ - Counters: │ - │ - BlockConvertTime: 0ns │ - │ - BlockFetchTime: 183.741us│ - │ - ReaderInitTime: 180.741us│ - │ - RowsDelFiltered: 0 │ - │ - RowsPushedCondFiltered: 0│ - │ - ScanCpuTime: 388.576us │ - │ - ScanTime: 0ns │ - │ - ShowHintsTime_V1: 0ns │ - └─────────────────────────────────┘ - │ - │ - ┌─────────────────────────────────────┐ - │[SegmentIterator] │ - │(Active: 0ns, non-child: 0.00) │ - │ - Counters: │ - │ - BitmapIndexFilterTimer: 124ns│ - │ - BlockLoadTime: 179.202us │ - │ - BlockSeekCount: 5 │ - │ - BlockSeekTime: 18.792us │ - │ - BlocksLoad: 4 │ - │ - CachedPagesNum: 2 │ - │ - CompressedBytesRead: 0.00 │ - │ - DecompressorTimer: 0ns │ - │ - IOTimer: 0ns │ - │ - IndexLoadTime_V1: 0ns │ - │ - NumSegmentFiltered: 0 │ - │ - NumSegmentTotal: 2 │ - │ - RawRowsRead: 4 │ - │ - RowsBitmapIndexFiltered: 0 │ - │ - RowsBloomFilterFiltered: 0 │ - │ - RowsConditionsFiltered: 0 │ - │ - RowsKeyRangeFiltered: 0 │ - │ - RowsStatsFiltered: 0 │ - │ - RowsVectorPredFiltered: 0 │ - │ - TotalPagesNum: 2 │ - │ - UncompressedBytesRead: 0.00 │ - │ - VectorPredEvalTime: 0ns │ - └─────────────────────────────────────┘ - - 1 row in set (0.01 sec) - ``` - - -### Keywords - - SHOW, QUERY, PROFILE - -### Best Practice - - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-QUERY-STATS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-QUERY-STATS.md deleted file mode 100644 index 503f51465bc49..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-QUERY-STATS.md +++ /dev/null @@ -1,194 +0,0 @@ ---- -{ - "title": "SHOW-QUERY-STATS", - "language": "en" -} ---- - - - -## SHOW-QUERY-STATS - -### Name - -SHOW QUERY STATS - -### Description - -This statement is used to show the query hit statistics of the database and table - -grammar: - -```sql -SHOW QUERY STATS [[FOR db_name]|[FROM table_name]] [ALL] [VERBOSE]]; -``` - -Remarks: - -1. Support query database and table history query hit statistics, restart fe after data will be reset, each fe separately statistics -2. Use FOR DATABASE and FROM TABLE to specify the query database or table hit statistics, respectively followed by the database name or table name -3. ALL can specify whether to display all index query hit statistics, VERBOSE can display more detailed hit statistics, these two parameters can be used separately, but must be placed at the end and can only be used on table queries -4. If no database is used, execute `SHOW QUERY STATS` directly to display the hit statistics of all databases -5. The result may have two columns: - QueryCount: The number of times the column was queried - FilterCount: The number of times the column was queried as a where condition -### Example - -1. Show the query hit statistics for `baseall` - - ```sql - MySQL [test_query_db]> show query stats from baseall; - +-------+------------+-------------+ - | Field | QueryCount | FilterCount | - +-------+------------+-------------+ - | k0 | 0 | 0 | - | k1 | 0 | 0 | - | k2 | 0 | 0 | - | k3 | 0 | 0 | - | k4 | 0 | 0 | - | k5 | 0 | 0 | - | k6 | 0 | 0 | - | k10 | 0 | 0 | - | k11 | 0 | 0 | - | k7 | 0 | 0 | - | k8 | 0 | 0 | - | k9 | 0 | 0 | - | k12 | 0 | 0 | - | k13 | 0 | 0 | - +-------+------------+-------------+ - 14 rows in set (0.002 sec) - - MySQL [test_query_db]> select k0, k1,k2, sum(k3) from baseall where k9 > 1 group by k0,k1,k2; - +------+------+--------+-------------+ - | k0 | k1 | k2 | sum(`k3`) | - +------+------+--------+-------------+ - | 0 | 6 | 32767 | 3021 | - | 1 | 12 | 32767 | -2147483647 | - | 0 | 3 | 1989 | 1002 | - | 0 | 7 | -32767 | 1002 | - | 1 | 8 | 255 | 2147483647 | - | 1 | 9 | 1991 | -2147483647 | - | 1 | 11 | 1989 | 25699 | - | 1 | 13 | -32767 | 2147483647 | - | 1 | 14 | 255 | 103 | - | 0 | 1 | 1989 | 1001 | - | 0 | 2 | 1986 | 1001 | - | 1 | 15 | 1992 | 3021 | - +------+------+--------+-------------+ - 12 rows in set (0.050 sec) - - MySQL [test_query_db]> show query stats from baseall; - +-------+------------+-------------+ - | Field | QueryCount | FilterCount | - +-------+------------+-------------+ - | k0 | 1 | 0 | - | k1 | 1 | 0 | - | k2 | 1 | 0 | - | k3 | 1 | 0 | - | k4 | 0 | 0 | - | k5 | 0 | 0 | - | k6 | 0 | 0 | - | k10 | 0 | 0 | - | k11 | 0 | 0 | - | k7 | 0 | 0 | - | k8 | 0 | 0 | - | k9 | 1 | 1 | - | k12 | 0 | 0 | - | k13 | 0 | 0 | - +-------+------------+-------------+ - 14 rows in set (0.001 sec) - ``` - -2. Show the query hit statistics summary for all the mv in a table - - ```sql - MySQL [test_query_db]> show query stats from baseall all; - +-----------+------------+ - | IndexName | QueryCount | - +-----------+------------+ - | baseall | 1 | - +-----------+------------+ - 1 row in set (0.005 sec) - ``` - -3. Show the query hit statistics detail info for all the mv in a table - - ```sql - MySQL [test_query_db]> show query stats from baseall all verbose; - +-----------+-------+------------+-------------+ - | IndexName | Field | QueryCount | FilterCount | - +-----------+-------+------------+-------------+ - | baseall | k0 | 1 | 0 | - | | k1 | 1 | 0 | - | | k2 | 1 | 0 | - | | k3 | 1 | 0 | - | | k4 | 0 | 0 | - | | k5 | 0 | 0 | - | | k6 | 0 | 0 | - | | k10 | 0 | 0 | - | | k11 | 0 | 0 | - | | k7 | 0 | 0 | - | | k8 | 0 | 0 | - | | k9 | 1 | 1 | - | | k12 | 0 | 0 | - | | k13 | 0 | 0 | - +-----------+-------+------------+-------------+ - 14 rows in set (0.017 sec) - ``` - -4. Show the query hit for a database - - ```sql - MySQL [test_query_db]> show query stats for test_query_db; - +----------------------------+------------+ - | TableName | QueryCount | - +----------------------------+------------+ - | compaction_tbl | 0 | - | bigtable | 0 | - | empty | 0 | - | tempbaseall | 0 | - | test | 0 | - | test_data_type | 0 | - | test_string_function_field | 0 | - | baseall | 1 | - | nullable | 0 | - +----------------------------+------------+ - 9 rows in set (0.005 sec) - ``` - -5. Show query hit statistics for all the databases - - ```sql - MySQL [(none)]> show query stats; - +-----------------+------------+ - | Database | QueryCount | - +-----------------+------------+ - | test_query_db | 1 | - +-----------------+------------+ - 1 rows in set (0.005 sec) - ``` - SHOW QUERY STATS; - ``` - -### Keywords - - SHOW, QUERY, STATS; - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-REPOSITORIES.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-REPOSITORIES.md deleted file mode 100644 index 0a09bf49c5330..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-REPOSITORIES.md +++ /dev/null @@ -1,67 +0,0 @@ ---- -{ - "title": "SHOW-REPOSITORIES", - "language": "en" -} ---- - - - -## SHOW-REPOSITORIES - -### Name - -SHOW REPOSITORIES - -### Description - -This statement is used to view the currently created warehouse - -grammar: - -```sql -SHOW REPOSITORIES; -``` - -illustrate: - -1. The meanings of the columns are as follows: - RepoId: Unique repository ID - RepoName: repository name - CreateTime: The time when the repository was first created - IsReadOnly: Whether it is a read-only repository - Location: The root directory in the warehouse for backing up data - Broker: Dependent Broker - ErrMsg: Doris will regularly check the connectivity of the warehouse, if there is a problem, an error message will be displayed here - -### Example - -1. View the created repository: - -```sql - SHOW REPOSITORIES; -``` - -### Keywords - - SHOW, REPOSITORIES - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-RESOURCES.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-RESOURCES.md deleted file mode 100644 index 9e755895dcb48..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-RESOURCES.md +++ /dev/null @@ -1,91 +0,0 @@ ---- -{ - "title": "SHOW-RESOURCES", - "language": "en" -} ---- - - - -## SHOW-RESOURCES - -### Name - -SHOW RESOURCES - -### Description - -This statement is used to display resources that the user has permission to use. Ordinary users can only display resources with permission, and root or admin users will display all resources. - -grammar: - -```sql -SHOW RESOURCES -[ - WHERE - [NAME [ = "your_resource_name" | LIKE "name_matcher"]] - [RESOURCETYPE = ["SPARK"]] -] | [LIKE "pattern"] -[ORDER BY...] -[LIMIT limit][OFFSET offset]; -``` - -illustrate: - -1. If NAME LIKE is used, it will match Resource whose Name contains name_matcher in RESOURCES -2. If NAME = is used, it will match the specified Name exactly -3. If RESOURCETYPE is specified, match the corresponding Resrouce type -4. You can use ORDER BY to sort on any combination of columns -5. If LIMIT is specified, limit matching records are displayed. Otherwise show all -6. If OFFSET is specified, the query results are displayed starting at offset offset. By default the offset is 0. -7. If using LIKE, the WHERE clause will be ignored. - -### Example - -1. Display all resources that the current user has permissions to - - ```sql - SHOW RESOURCES; - ``` - -2. Display the specified Resource, the name contains the string "20140102", and display 10 attributes - - ```sql - SHOW RESOURCES WHERE NAME LIKE "2014_01_02" LIMIT 10; - ``` - -3. Display the specified Resource, specify the name as "20140102" and sort by KEY in descending order - - ```sql - SHOW RESOURCES WHERE NAME = "20140102" ORDER BY `KEY` DESC; - ``` - -3. Using LIKE to match the resource - - ```sql - SHOW RESOURCES LIKE "jdbc%"; - ``` - -### Keywords - - SHOW, RESOURCES - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-RESTORE.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-RESTORE.md deleted file mode 100644 index 0b0ea484df8e0..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-RESTORE.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -{ - "title": "SHOW-RESTORE", - "language": "en" -} ---- - - - -## SHOW-RESTORE - -### Name - -SHOW RESTORE - -### Description - -This statement is used to view RESTORE tasks - -grammar: - -```SQL -SHOW [BRIEF] RESTORE [FROM DB_NAME] -``` - -illustrate: - 1. Only the most recent RESTORE task is saved in Doris. - 2. The meaning of each column is as follows: - JobId: Unique job id - Label: The name of the backup to restore - Timestamp: The time version of the backup to restore - DbName: belongs to the database - State: current stage - PENDING: The initial state after submitting the job - SNAPSHOTING: Executing snapshot - DOWNLOAD: The snapshot is complete, ready to download the snapshot in the repository - DOWNLOADING: Snapshot downloading - COMMIT: Snapshot download is complete, ready to take effect - COMMITING: in effect - FINISHED: The job was successful - CANCELLED: Job failed - AllowLoad: Whether to allow import when restoring (currently not supported) - ReplicationNum: Specifies the number of replicas to restore - RestoreJobs: Tables and partitions to restore - CreateTime: task submission time - MetaPreparedTime: Metadata preparation completion time - SnapshotFinishedTime: Snapshot completion time - DownloadFinishedTime: Snapshot download completion time - FinishedTime: Job finish time - UnfinishedTasks: Displays unfinished subtask ids during SNAPSHOTING, DOWNLOADING and COMMITING stages - Status: If the job fails, display the failure message - Timeout: Job timeout, in seconds - - 2. brief: only show key information of RESTORE tasks, columns RestoreObjs, Progress, TaskErrMsg will not show - -### Example - -1. View the latest RESTORE task under example_db. - - ```sql - SHOW RESTORE FROM example_db; - ``` - -### Keywords - - SHOW, RESTORE - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-ROLES.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-ROLES.md deleted file mode 100644 index b4c30af5ea7b5..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-ROLES.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "SHOW-ROLES", - "language": "en" -} ---- - - - -## SHOW-ROLES - -### Name - -SHOW ROLES - -### Description - -This statement is used to display all created role information, including role name, included users and permissions. - -grammar: - -```SQL -SHOW ROLES -``` - -### Example - -1. View created roles - - ```SQL - SHOW ROLES - ``` - -### Keywords - - SHOW, ROLES - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-ROUTINE-LOAD-TASK.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-ROUTINE-LOAD-TASK.md deleted file mode 100644 index 85b5e7478f7d7..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-ROUTINE-LOAD-TASK.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -{ - "title": "SHOW-ROUTINE-LOAD-TASK", - "language": "en" -} ---- - - - -## SHOW-ROUTINE-LOAD-TASK - -### Name - -SHOW ROUTINE LOAD TASK - -### Description - -View the currently running subtasks of a specified Routine Load job. - - - -```sql -SHOW ROUTINE LOAD TASK -WHERE JobName = "job_name"; -``` - -The returned results are as follows: - -```text - TaskId: d67ce537f1be4b86-abf47530b79ab8e6 - TxnId: 4 - TxnStatus: UNKNOWN - JobId: 10280 - CreateTime: 2020-12-12 20:29:48 - ExecuteStartTime: 2020-12-12 20:29:48 - Timeout: 20 - BeId: 10002 -DataSourceProperties: {"0":19} -``` - -- `TaskId`: The unique ID of the subtask. -- `TxnId`: The import transaction ID corresponding to the subtask. -- `TxnStatus`: The import transaction status corresponding to the subtask. When TxnStatus is null, it means that the subtask has not yet started scheduling. -- `JobId`: The job ID corresponding to the subtask. -- `CreateTime`: The creation time of the subtask. -- `ExecuteStartTime`: The time when the subtask is scheduled to be executed, usually later than the creation time. -- `Timeout`: Subtask timeout, usually twice the `max_batch_interval` set by the job. -- `BeId`: The ID of the BE node executing this subtask. -- `DataSourceProperties`: The starting offset of the Kafka Partition that the subtask is ready to consume. is a Json format string. Key is Partition Id. Value is the starting offset of consumption. - -### Example - -1. Display the subtask information of the routine import task named test1. - - ```sql - SHOW ROUTINE LOAD TASK WHERE JobName = "test1"; - ``` - -### Keywords - - SHOW, ROUTINE, LOAD, TASK - -### Best Practice - -With this command, you can view how many subtasks are currently running in a Routine Load job, and which BE node is running on. - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-ROUTINE-LOAD.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-ROUTINE-LOAD.md deleted file mode 100644 index 111d160150fa1..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-ROUTINE-LOAD.md +++ /dev/null @@ -1,130 +0,0 @@ ---- -{ - "title": "SHOW-ROUTINE-LOAD", - "language": "en" -} ---- - - - -## SHOW-ROUTINE-LOAD - -### Name - -SHOW ROUTINE LOAD - -### Description - -This statement is used to display the running status of the Routine Load job - -grammar: - -```sql -SHOW [ALL] ROUTINE LOAD [FOR jobName]; -``` - -Result description: - -``` - Id: job ID - Name: job name - CreateTime: job creation time - PauseTime: The last job pause time - EndTime: Job end time - DbName: corresponding database name - TableName: The name of the corresponding table (In the case of multiple tables, since it is a dynamic table, the specific table name is not displayed, and we uniformly display it as "multi-table"). - IsMultiTbl: Indicates whether it is a multi-table - State: job running state - DataSourceType: Data source type: KAFKA - CurrentTaskNum: The current number of subtasks - JobProperties: Job configuration details -DataSourceProperties: Data source configuration details - CustomProperties: custom configuration - Statistic: Job running status statistics - Progress: job running progress - Lag: job delay status -ReasonOfStateChanged: The reason for the job state change - ErrorLogUrls: The viewing address of the filtered unqualified data - OtherMsg: other error messages -``` - -* State - - There are the following 5 states: - * NEED_SCHEDULE: The job is waiting to be scheduled - * RUNNING: The job is running - * PAUSED: The job is paused - * STOPPED: The job has ended - * CANCELLED: The job was canceled - -* Progress - - For Kafka data sources, displays the currently consumed offset for each partition. For example, {"0":"2"} indicates that the consumption progress of Kafka partition 0 is 2. - -*Lag - - For Kafka data sources, shows the consumption latency of each partition. For example, {"0":10} means that the consumption delay of Kafka partition 0 is 10. - -### Example - -1. Show all routine import jobs named test1 (including stopped or canceled jobs). The result is one or more lines. - - ```sql - SHOW ALL ROUTINE LOAD FOR test1; - ``` - -2. Show the currently running routine import job named test1 - - ```sql - SHOW ROUTINE LOAD FOR test1; - ``` - -3. Display all routine import jobs (including stopped or canceled jobs) under example_db. The result is one or more lines. - - ```sql - use example_db; - SHOW ALL ROUTINE LOAD; - ``` - -4. Display all running routine import jobs under example_db - - ```sql - use example_db; - SHOW ROUTINE LOAD; - ``` - -5. Display the currently running routine import job named test1 under example_db - - ```sql - SHOW ROUTINE LOAD FOR example_db.test1; - ``` - -6. Displays all routine import jobs named test1 under example_db (including stopped or canceled jobs). The result is one or more lines. - - ```sql - SHOW ALL ROUTINE LOAD FOR example_db.test1; - ``` - -### Keywords - - SHOW, ROUTINE, LOAD - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-SMALL-FILES.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-SMALL-FILES.md deleted file mode 100644 index be6701f083bc9..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-SMALL-FILES.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -{ - "title": "SHOW-SMALL-FILES", - "language": "en" -} ---- - - - -## SHOW-SMALL-FILES - -### Name - -SHOW FILE - -### Description - -This statement is used to display files created by the CREATE FILE command within a database. - -```sql -SHOW FILE [FROM database]; -``` - -Return result description: - -- FileId: file ID, globally unique -- DbName: the name of the database to which it belongs -- Catalog: Custom Category -- FileName: file name -- FileSize: file size in bytes -- MD5: MD5 of the file - -### Example - -1. View the uploaded files in the database my_database - - ```sql - SHOW FILE FROM my_database; - ``` - -### Keywords - - SHOW, SMALL, FILES - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-SNAPSHOT.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-SNAPSHOT.md deleted file mode 100644 index d53fd916d5971..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-SNAPSHOT.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -{ - "title": "SHOW-SNAPSHOT", - "language": "en" -} ---- - - - -## SHOW-SNAPSHOT - -### Name - -SHOW SNAPSHOT - -### Description - -This statement is used to view backups that already exist in the repository. - -grammar: - -```sql -SHOW SNAPSHOT ON `repo_name` -[WHERE SNAPSHOT = "snapshot" [AND TIMESTAMP = "backup_timestamp"]]; -``` - -illustrate: - -1. The meanings of the columns are as follows: - Snapshot: The name of the backup - Timestamp: corresponds to the time version of the backup - Status: If the backup is normal, it will display OK, otherwise it will display an error message -2. If TIMESTAMP is specified, the following additional information is displayed: - Database: The name of the database to which the backup data originally belonged - Details: In the form of Json, the data directory and file structure of the entire backup are displayed - -### Example - -1. View the existing backups in the repository example_repo - - ```sql - SHOW SNAPSHOT ON example_repo; - ``` - -2. View only the backup named backup1 in the repository example_repo: - - ```sql - SHOW SNAPSHOT ON example_repo WHERE SNAPSHOT = "backup1"; - ``` - -3. View the details of the backup named backup1 in the warehouse example_repo with the time version "2018-05-05-15-34-26": - - ```sql - SHOW SNAPSHOT ON example_repo - WHERE SNAPSHOT = "backup1" AND TIMESTAMP = "2018-05-05-15-34-26"; - ``` - -### Keywords - - SHOW, SNAPSHOT - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-SQL-BLOCK-RULE.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-SQL-BLOCK-RULE.md deleted file mode 100644 index c1e04bde617f7..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-SQL-BLOCK-RULE.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -{ - "title": "SHOW-SQL-BLOCK-RULE", - "language": "en" -} ---- - - - -## SQL-BLOCK-RULE - -### Name - -SHOW SQL BLOCK RULE - -### Description - -View the configured SQL blocking rules. If you do not specify a rule name, you will view all rules. - -grammar: - -```sql -SHOW SQL_BLOCK_RULE [FOR RULE_NAME]; -``` - -### Example - -1. View all rules. - - ```sql - mysql> SHOW SQL_BLOCK_RULE; - +------------+----------------------------+---------+- -------------+------------+-------------+--------+- -------+ - | Name | Sql | SqlHash | PartitionNum | TabletNum | Cardinality | Global | Enable | - +------------+----------------------------+---------+- -------------+------------+-------------+--------+- -------+ - | test_rule | select * from order_analysis | NULL | 0 | 0 | 0 | true | true | - | test_rule2 | NULL | NULL | 30 | 0 | 10000000000 | false | true | - +------------+----------------------------+---------+- -------------+------------+-------------+--------+- -------+ - 2 rows in set (0.01 sec) - ``` - -2. Make a rule name query - - ```sql - mysql> SHOW SQL_BLOCK_RULE FOR test_rule2; - +------------+------+---------+---------------+---- -------+-------------+--------+--------+ - | Name | Sql | SqlHash | PartitionNum | TabletNum | Cardinality | Global | Enable | - +------------+------+---------+---------------+---- -------+-------------+--------+--------+ - | test_rule2 | NULL | NULL | 30 | 0 | 10000000000 | false | true | - +------------+------+---------+---------------+---- -------+-------------+--------+--------+ - 1 row in set (0.00 sec) - - ``` - - -### Keywords - - SHOW, SQL_BLOCK_RULE - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-STATUS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-STATUS.md deleted file mode 100644 index bf9ca3d4d1799..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-STATUS.md +++ /dev/null @@ -1,114 +0,0 @@ ---- -{ - "title": "SHOW-STATUS", - "language": "en" -} ---- - - - -## SHOW-STATUS - -### Name - -SHOW STATUS - -### Description - -This command is used to view the execution of the Create Materialized View job submitted through the [CREATE-MATERIALIZED-VIEW](../Data-Definition-Statements/Create/CREATE-MATERIALIZED-VIEW.md) statement. - -> This statement is equivalent to `SHOW ALTER TABLE ROLLUP`; - -```sql -SHOW ALTER TABLE MATERIALIZED VIEW -[FROM database] -[WHERE] -[ORDER BY] -[LIMIT OFFSET] -``` - -- database: View jobs under the specified database. If not specified, the current database is used. -- WHERE: You can filter the result column, currently only the following columns are supported: - - TableName: Only equal value filtering is supported. - - State: Only supports equivalent filtering. - - Createtime/FinishTime: Support =, >=, <=, >, <, != -- ORDER BY: The result set can be sorted by any column. -- LIMIT: Use ORDER BY to perform page-turning query. - -Return result description: - -```sql -mysql> show alter table materialized view\G -**************************** 1. row ******************** ****** - JobId: 11001 - TableName: tbl1 - CreateTime: 2020-12-23 10:41:00 - FinishTime: NULL - BaseIndexName: tbl1 -RollupIndexName: r1 - RollupId: 11002 - TransactionId: 5070 - State: WAITING_TXN - Msg: - Progress: NULL - Timeout: 86400 -1 row in set (0.00 sec) -``` - -- `JobId`: Job unique ID. - -- `TableName`: base table name - -- `CreateTime/FinishTime`: Job creation time and end time. - -- `BaseIndexName/RollupIndexName`: Base table name and materialized view name. - -- `RollupId`: The unique ID of the materialized view. - -- `TransactionId`: See the description of the State field. - -- `State`: job status. - - - PENDING: The job is in preparation. - - - WAITING_TXN: - - Before officially starting to generate materialized view data, it will wait for the current running import transaction on this table to complete. And the `TransactionId` field is the current waiting transaction ID. When all previous imports for this ID are complete, the job will actually start. - - - RUNNING: The job is running. - - - FINISHED: The job ran successfully. - - - CANCELLED: The job failed to run. - -- `Msg`: error message - -- `Progress`: job progress. The progress here means `completed tablets/total tablets`. Materialized views are created at tablet granularity. - -- `Timeout`: Job timeout, in seconds. - -### Example - -### Keywords - - SHOW, STATUS - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-STORAGE-POLICY-USING.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-STORAGE-POLICY-USING.md deleted file mode 100644 index 803c94cbc8159..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-STORAGE-POLICY-USING.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -{ - "title": "SHOW-STORAGE-POLICY-USING", - "language": "en" -} ---- - - - -## SHOW-STORAGE-POLICY-USING - -### Name - -SHOW STORAGE POLICY USING - -### Description - -This command is used to show tables and partitions which is using storage policy - -```sql -SHOW STORAGE POLICY USING [FOR some_policy] -``` - -### Example - -1. get all objects which are using storage policy - - ```sql - mysql> show storage policy using; - +-----------------------+-----------------------------------------+----------------------------------------+------------+ - | PolicyName | Database | Table | Partitions | - +-----------------------+-----------------------------------------+----------------------------------------+------------+ - | test_storage_policy | regression_test_cold_heat_separation_p2 | table_with_storage_policy_1 | ALL | - | test_storage_policy | regression_test_cold_heat_separation_p2 | partition_with_multiple_storage_policy | p201701 | - | test_storage_policy_2 | regression_test_cold_heat_separation_p2 | partition_with_multiple_storage_policy | p201702 | - | test_storage_policy_2 | regression_test_cold_heat_separation_p2 | table_with_storage_policy_2 | ALL | - | test_policy | db2 | db2_test_1 | ALL | - +-----------------------+-----------------------------------------+----------------------------------------+------------+ - ``` - -2. get objects which are using the storage policy named test_storage_policy - - ```sql - mysql> show storage policy using for test_storage_policy; - +---------------------+-----------+---------------------------------+------------+ - | PolicyName | Database | Table | Partitions | - +---------------------+-----------+---------------------------------+------------+ - | test_storage_policy | db_1 | partition_with_storage_policy_1 | p201701 | - | test_storage_policy | db_1 | table_with_storage_policy_1 | ALL | - +---------------------+-----------+---------------------------------+------------+ - ``` - -### Keywords - - SHOW, STORAGE, POLICY, USING - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-STORAGE-VAULTS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-STORAGE-VAULTS.md deleted file mode 100644 index 7676d8f4e62a6..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-STORAGE-VAULTS.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -{ - "title": "SHOW STORAGE VAULTS", - "language": "en" -} ---- - - - -## Description - -The SHOW STORAGE VAULTS command is used to display information about all storage vaults configured in the system. Storage vaults are used to manage external storage locations for data. - -## Syntax - -```sql - SHOW STORAGE VAULTS -``` - -## Return Values - -This command returns a result set with the following columns: - -- `StorageVaultName`: The name of the storage vault. -- `StorageVaultId`: The id of the storage vault. -- `Properties`: A JSON string containing the configuration properties of the vault. -- `IsDefault`: Indicates whether this vault is set as the default (TRUE or FALSE). - -## Related Commands - -- [CREATE STORAGE VAULT](../Data-Definition-Statements/CREATE-STORAGE-VAULT.md) -- [GRANT](../Account-Management-Statements/GRANT.md) -- [REVOKE](../Account-Management-Statements/REVOKE.md) -- [SET DEFAULT STORAGE VAULT](../Data-Definition-Statements/SET-DEFAULT-STORAGE-VAULT.md) - -## Keywords - - SHOW, STORAGE VAULTS diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-STREAM-LOAD.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-STREAM-LOAD.md deleted file mode 100644 index 65a3da983f0c9..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-STREAM-LOAD.md +++ /dev/null @@ -1,100 +0,0 @@ ---- -{ - "title": "SHOW-STREAM-LOAD", - "language": "en" -} ---- - - - -## SHOW-STREAM-LOAD - -### Name - -SHOW STREAM LOAD - -### Description - -This statement is used to display the execution of the specified Stream Load task - -grammar: - -```sql -SHOW STREAM LOAD -[FROM db_name] -[ - WHERE - [LABEL [ = "your_label" | LIKE "label_matcher"]] - [STATUS = ["SUCCESS"|"FAIL"]] -] -[ORDER BY...] -[LIMIT limit][OFFSET offset]; -``` - -illustrate: - -1. By default, BE does not record Stream Load records. If you want to view records that need to be enabled on BE, the configuration parameter is: `enable_stream_load_record=true`. For details, please refer to [BE Configuration Items](../../../admin-manual/config/be-config.md) -2. If db_name is not specified, the current default db is used -3. If LABEL LIKE is used, it will match the tasks whose label of the Stream Load task contains label_matcher -4. If LABEL = is used, it will match the specified label exactly -5. If STATUS is specified, matches STREAM LOAD status -6. You can use ORDER BY to sort on any combination of columns -7. If LIMIT is specified, limit matching records are displayed. Otherwise show all -8. If OFFSET is specified, the query results are displayed starting at offset offset. By default the offset is 0. - -### Example - -1. Show all Stream Load tasks of the default db - - ```sql - SHOW STREAM LOAD; - ``` - -2. Display the Stream Load task of the specified db, the label contains the string "2014_01_02", and display the oldest 10 - - ```sql - SHOW STREAM LOAD FROM example_db WHERE LABEL LIKE "2014_01_02" LIMIT 10; - ``` - -3. Display the Stream Load task of the specified db and specify the label as "load_example_db_20140102" - - ```sql - SHOW STREAM LOAD FROM example_db WHERE LABEL = "load_example_db_20140102"; - ``` - -4. Display the Stream Load task of the specified db, specify the status as "success", and sort by StartTime in descending order - - ```sql - SHOW STREAM LOAD FROM example_db WHERE STATUS = "success" ORDER BY StartTime DESC; - ``` - -5. Display the import tasks of the specified db and sort them in descending order of StartTime, and display 10 query results starting from offset 5 - - ```sql - SHOW STREAM LOAD FROM example_db ORDER BY StartTime DESC limit 5,10; - SHOW STREAM LOAD FROM example_db ORDER BY StartTime DESC limit 10 offset 5; - ``` - -### Keywords - - SHOW, STREAM, LOAD - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-SYNC-JOB.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-SYNC-JOB.md deleted file mode 100644 index df79ae0a3ad84..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-SYNC-JOB.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -{ - "title": "SHOW-SYNC-JOB", - "language": "en" -} - - ---- - - - -## SHOW-SYNC-JOB - -### Name - -SHOW SYNC JOB - -### Description - -This command is used to currently display the status of resident data synchronization jobs in all databases. - -grammar: - -```sql -SHOW SYNC JOB [FROM db_name] -``` - -### Example - -1. Display the status of all data synchronization jobs in the current database. - - ```sql - SHOW SYNC JOB; - ``` - -2. Display the status of all data synchronization jobs under the database `test_db`. - - ```sql - SHOW SYNC JOB FROM `test_db`; - ``` - -### Keywords - - SHOW, SYNC, JOB - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLE-ID.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLE-ID.md deleted file mode 100644 index e88c30e649f75..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLE-ID.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "SHOW-TABLE-ID", - "language": "en" -} ---- - - - -## SHOW-TABLE-ID - -### Name - -SHOW TABLE ID - -### Description - -This statement is used to find the corresponding database name, table name according to the table id (only for administrators) - -grammar: - -```sql -SHOW TABLE [table_id] -``` - -### Example - - 1. Find the corresponding database name, table name according to the table id - - ```sql - SHOW TABLE 10001; - ``` - -### Keywords - - SHOW, TABLE, ID - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLE-STATS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLE-STATS.md deleted file mode 100644 index 06f59b27ea500..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLE-STATS.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -{ - "title": "SHOW-TABLE-STATS", - "language": "en" -} ---- - - - -## SHOW-TABLE-STATS - -### Name - -SHOW TABLE STATS - -### Description - -Use `SHOW TABLE STATS` to view an overview of statistics collection for a table. - -Syntax: - -```SQL -SHOW TABLE STATS table_name; -``` - -Where: - -- table_name: The target table name. It can be in the format `db_name.table_name`. - -Output: - -| Column Name | Description | -| :--------------------- | :--------------- | -| `updated_rows` | Updated rows since the last ANALYZE | -| `query_times` | Reserved column for recording the number of times the table was queried in future versions | -| `row_count` | Number of rows (does not reflect the exact number of rows at the time of command execution) | -| `updated_time` | Last update time | -| `columns` | Columns for which statistics information has been collected | - -Here's an example: - -```sql -mysql> show table stats lineitem \G; -*************************** 1. row *************************** -updated_rows: 0 - query_times: 0 - row_count: 6001215 -updated_time: 2023-11-07 - columns: [l_returnflag, l_receiptdate, l_tax, l_shipmode, l_suppkey, l_shipdate, l_commitdate, l_partkey, l_orderkey, l_quantity, l_linestatus, l_comment, l_extendedprice, l_linenumber, l_discount, l_shipinstruct] - trigger: MANUAL -``` - -
- -### Keywords - -SHOW, TABLE, STATS diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLE-STATUS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLE-STATUS.md deleted file mode 100644 index 74d3b4b4936d4..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLE-STATUS.md +++ /dev/null @@ -1,67 +0,0 @@ ---- -{ - "title": "SHOW-TABLE-STATUS", - "language": "en" -} ---- - - - -## SHOW-TABLE-STATUS - -### Name - -SHOW TABLE STATUS - -### Description - -This statement is used to view some information about the Table. - -grammar: - -```sql -SHOW TABLE STATUS -[FROM db] [LIKE "pattern"] -``` - -illustrate: - -1. This statement is mainly used to be compatible with MySQL syntax, currently only a small amount of information such as Comment is displayed - -### Example - - 1. View the information of all tables under the current database - - ```sql - SHOW TABLE STATUS; - ``` - - 2. View the information of the table whose name contains example under the specified database - - ```sql - SHOW TABLE STATUS FROM db LIKE "%example%"; - ``` - -### Keywords - - SHOW, TABLE, STATUS - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLES.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLES.md deleted file mode 100644 index e855ea9681b02..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLES.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -{ - "title": "SHOW-TABLES", - "language": "en" -} ---- - - - -## SHOW-TABLES - -### Name - -SHOW TABLES - -### Description - -This statement is used to display all tables under the current db - -grammar: - -```sql -SHOW [FULL] TABLES [LIKE] -``` - -illustrate: - -1. LIKE: Fuzzy query can be performed according to the table name - -### Example - - 1. View all tables under DB - - ```sql - mysql> show tables; - +---------------------------------+ - | Tables_in_demo | - +---------------------------------+ - | ads_client_biz_aggr_di_20220419 | - | cmy1 | - | cmy2 | - | intern_theme | - | left_table | - +---------------------------------+ - 5 rows in set (0.00 sec) - ``` - -2. Fuzzy query by table name - - ```sql - mysql> show tables like '%cm%'; - +----------------+ - | Tables_in_demo | - +----------------+ - | cmy1 | - | cmy2 | - +----------------+ - 2 rows in set (0.00 sec) - ``` - -### Keywords - - SHOW, TABLES - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLET.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLET.md deleted file mode 100644 index e9e060d489033..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLET.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "SHOW-TABLET", - "language": "en" -} ---- - - - -## SHOW-TABLET - -### Name - -SHOW TABLET - -### Description - -This statement is used to display the specified tablet id information (only for administrators) - -grammar: - -```sql -SHOW TABLET tablet_id -``` - -### Example - -1. Display the parent-level id information of the tablet with the specified tablet id of 10000 - - ```sql - SHOW TABLET 10000; - ``` - -### Keywords - - SHOW, TABLET - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLETS-BELONG.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLETS-BELONG.md deleted file mode 100644 index baff2c42bd803..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLETS-BELONG.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -{ - "title": "SHOW-TABLETS-BELONG", - "language": "en" -} ---- - - - -## SHOW-TABLETS-BELONG - -### Name - -SHOW TABLETS BELONG - -### Description - -Used to show tablets and information of their belonging table - -grammar: - -```sql -SHOW TABLETS BELONG tablet-ids; -``` - -illustrate: - -1. tablet-ids: one or more tablet-ids, with comma separated -2. Columns of result keep same with result of `SHOW-DATA` for the same table - -### Example - -1. show information of four tablet-ids (actually, three tablet-ids. Result will be deduplicated) - - ```sql - SHOW TABLETS BELONG 27028,78880,78382,27028; - ``` - - ``` -+---------------------+-----------+-----------+--------------+-----------+--------------+----------------+ -| DbName | TableName | TableSize | PartitionNum | BucketNum | ReplicaCount | TabletIds | -+---------------------+-----------+-----------+--------------+-----------+--------------+----------------+ -| default_cluster:db1 | kec | 613.000 B | 379 | 604 | 604 | [78880, 78382] | -| default_cluster:db1 | test | 1.874 KB | 1 | 1 | 1 | [27028] | -+---------------------+-----------+-----------+--------------+-----------+--------------+----------------+ - ``` - -### Keywords - - SHOW, TABLETS, BELONG - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLETS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLETS.md deleted file mode 100644 index 4623b60af50da..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TABLETS.md +++ /dev/null @@ -1,83 +0,0 @@ - ---- -{ - "title": "SHOW-TABLETS", - "language": "en" -} ---- - - - -## SHOW-TABLETS - -### Name - -SHOW TABLETS - -### Description - -This statement is used to list tablets of the specified table (only for administrators) - -grammar: - -```sql -SHOW TABLETS FROM [database.]table [PARTITIONS(p1,p2)] -[WHERE where_condition] -[ORDER BY col_name] -[LIMIT [offset,] row_count] -``` - -1. **Syntax Description:** - -where_condition could be one of: -``` -Version = version -state = "NORMAL|ROLLUP|CLONE|DECOMMISSION" -BackendId = backend_id -IndexName = rollup_name -``` -or compound them with operator `AND`. - -### Example - -1. list all tablets of the specified table - - ```sql - SHOW TABLETS FROM example_db.table_name; - ``` - -2. list all tablets of the specified partitions - - ```sql - SHOW TABLETS FROM example_db.table_name PARTITIONS(p1, p2); - ``` - -3. list all DECOMMISSION tablets on the specified backend - - ```sql - SHOW TABLETS FROM example_db.table_name WHERE state="DECOMMISSION" AND BackendId=11003; - ``` - -### Keywords - - SHOW, TABLETS - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TRANSACTION.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-TRANSACTION.md deleted file mode 100644 index a939df67eb376..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TRANSACTION.md +++ /dev/null @@ -1,106 +0,0 @@ ---- -{ - "title": "SHOW-TRANSACTION", - "language": "en" -} ---- - - - -## SHOW-TRANSACTION - -### Name - -SHOW TRANSACTION - -### Description - -This syntax is used to view transaction details for the specified transaction id or label. - -grammar: - -```sql -SHOW TRANSACTION -[FROM db_name] -WHERE -[id=transaction_id] -[label = label_name]; -``` - -Example of returned result: - -``` - TransactionId: 4005 - Label: insert_8d807d5d-bcdd-46eb-be6d-3fa87aa4952d - Coordinator: FE: 10.74.167.16 - TransactionStatus: VISIBLE - LoadJobSourceType: INSERT_STREAMING - PrepareTime: 2020-01-09 14:59:07 - CommitTime: 2020-01-09 14:59:09 - FinishTime: 2020-01-09 14:59:09 - Reason: -ErrorReplicasCount: 0 - ListenerId: -1 - TimeoutMs: 300000 -``` - -* TransactionId: transaction id -* Label: the label corresponding to the import task -* Coordinator: The node responsible for transaction coordination -* TransactionStatus: transaction status - * PREPARE: preparation stage - * COMMITTED: The transaction succeeded, but the data was not visible - * VISIBLE: The transaction succeeded and the data is visible - * ABORTED: Transaction failed -* LoadJobSourceType: Type of import job. -* PrepareTime: transaction start time -* CommitTime: The time when the transaction was successfully committed -* FinishTime: The time when the data is visible -* Reason: error message -* ErrorReplicasCount: The number of replicas with errors -* ListenerId: The id of the related import job -* TimeoutMs: Transaction timeout, in milliseconds - -### Example - -1. View the transaction with id 4005: - - ```sql - SHOW TRANSACTION WHERE ID=4005; - ``` - -2. In the specified db, view the transaction with id 4005: - - ```sql - SHOW TRANSACTION FROM db WHERE ID=4005; - ``` - -3. View the transaction whose label is label_name: - - ```sql - SHOW TRANSACTION WHERE LABEL = 'label_name'; - ``` - -### Keywords - - SHOW, TRANSACTION - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TRASH.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-TRASH.md deleted file mode 100644 index 4604a7a54920f..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TRASH.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -{ - "title": "SHOW-TRASH", - "language": "en" -} ---- - - - -## SHOW-TRASH - -### Name - -SHOW TRASH - -### Description - -This statement is used to view the garbage data footprint within the backend. - -grammar: - -```sql -SHOW TRASH [ON BackendHost:BackendHeartBeatPort]; -``` - -illustrate: - -1. The Backend format is the node's BackendHost:BackendHeartBeatPort -2. TrashUsedCapacity indicates the space occupied by the garbage data of the node. - -### Example - -1. View the space occupied by garbage data of all be nodes. - - ```sql - SHOW TRASH; - ``` - -2. View the space occupied by garbage data of '192.168.0.1:9050' (specific disk information will be displayed). - - ```sql - SHOW TRASH ON "192.168.0.1:9050"; - ``` - -### Keywords - - SHOW, TRASH - -### Best Practice \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TRIGGERS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-TRIGGERS.md deleted file mode 100644 index b8d9850a75e56..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TRIGGERS.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -{ - "title": "SHOW-TRIGGERS", - "language": "en" -} ---- - - - -## SHOW-TRIGGERS - -### Description - -### Example - -### Keywords - - SHOW, TRIGGERS - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TYPECAST.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-TYPECAST.md deleted file mode 100644 index 881f3b27ae7c1..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-TYPECAST.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -{ - "title": "SHOW-TYPECAST", - "language": "en" -} ---- - - - -## SHOW-TYPECAST - -### Name - -SHOW TYPECAST - -### Description - -View all type cast under the database. If the user specifies a database, then view the corresponding database, otherwise directly query the database where the current session is located - -Requires `SHOW` permission on this database - -grammar - -```sql -SHOW TYPE_CAST [IN|FROM db] -``` - - Parameters - ->`db`: database name to query - -### Example - -```sql -mysql> show type_cast in testDb\G -**************************** 1. row ******************** ****** -Origin Type: TIMEV2 - Cast Type: TIMEV2 -**************************** 2. row ******************** ****** -Origin Type: TIMEV2 - Cast Type: TIMEV2 -**************************** 3. row ******************** ****** -Origin Type: TIMEV2 - Cast Type: TIMEV2 - -3 rows in set (0.00 sec) -``` - -### Keywords - - SHOW, TYPECAST - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-VARIABLES.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-VARIABLES.md deleted file mode 100644 index eba61870d1181..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-VARIABLES.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -{ - "title": "SHOW-VARIABLES", - "language": "en" -} ---- - - - -## SHOW-VARIABLES - -### Name - -SHOW VARIABLES - -### Description - -This statement is used to display Doris system variables, which can be queried by conditions - -grammar: - -```sql -SHOW [GLOBAL | SESSION] VARIABLES - [LIKE 'pattern' | WHERE expr] -``` - -illustrate: - -- show variables is mainly used to view the values of system variables. -- Executing the SHOW VARIABLES command does not require any privileges, it only requires being able to connect to the server. -- Use the like statement to match with variable_name. -- The % percent wildcard can be used anywhere in the matching pattern - -### Example - -1. The default here is to match the Variable_name, here is the exact match - - ```sql - show variables like 'max_connections'; - ``` - -2. Matching through the percent sign (%) wildcard can match multiple items - - ```sql - show variables like '%connec%'; - ``` - -3. Use the Where clause for matching queries - - ```sql - show variables where variable_name = 'version'; - ``` - -### Keywords - - SHOW, VARIABLES - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-VIEW.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-VIEW.md deleted file mode 100644 index 4df6b336a3bc4..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-VIEW.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "SHOW-VIEW", - "language": "en" -} ---- - - - -## SHOW-VIEW - -### Name - -SHOW VIEW - -### Description - -This statement is used to display all views based on the given table - -grammar: - -```sql - SHOW VIEW { FROM | IN } table [ FROM db ] -``` - -### Example - -1. Show all views created based on table testTbl - - ```sql - SHOW VIEW FROM testTbl; - ``` - -### Keywords - - SHOW, VIEW - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-WARM-UP-JOB.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-WARM-UP-JOB.md deleted file mode 100644 index 1cdb5be51eb5a..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-WARM-UP-JOB.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -{ - "title": "SHOW-WARM-UP-JOB", - "language": "en" -} ---- - - - -## Description - -The commands are used to display warm-up jobs in Doris. - -## Syntax - -```sql - SHOW WARM UP JOB [ WHERE id = 'id' ] ; -``` - -## Parameters - -* id : id of the warm-up job. - -## Example - -1. View all warmup job - - ```sql - SHOW WARM UP JOB; - ``` - -2. View one warmup job with id = 13418 - -```sql - SHOW WARM UP JOB WHERE id = 13418; -``` - -## Related Commands - - - [WARMUP COMPUTE GROUP](../Database-Administration-Statements/WARM-UP-COMPUTE-GROUP.md) - -## References - - - [MANAGING FILE CACHE](../../../compute-storage-decoupled/file-cache.md) - -## Keywords - - SHOW, CACHE, HOTSPOT, COMPUTE GROUP - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-WARNING.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-WARNING.md deleted file mode 100644 index 46e4afc9606eb..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-WARNING.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -{ - "title": "SHOW-WARNING", - "language": "en" -} ---- - - - -## SHOW-WARNING - -### Description - -### Example - -### Keywords - - SHOW, WARNING - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-WHITE-LIST.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-WHITE-LIST.md deleted file mode 100644 index 9083f08f28d11..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-WHITE-LIST.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -{ - "title": "SHOW-WHITE-LIST", - "language": "en" -} ---- - - - -## SHOW-WHITE-LIST - -### Description - -### Example - -### Keywords - - SHOW, WHITE, LIST - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-WORKLOAD-GROUPS.md b/docs/sql-manual/sql-statements/Show-Statements/SHOW-WORKLOAD-GROUPS.md deleted file mode 100644 index a6bc02ea81cd2..0000000000000 --- a/docs/sql-manual/sql-statements/Show-Statements/SHOW-WORKLOAD-GROUPS.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -{ - "title": "SHOW-workload-GROUPS", - "language": "en" -} ---- - - - -## SHOW-workload-GROUPS - -### Name - -SHOW workload GROUPS - -### Description - -This statement is used to display the resource groups for which the current user has usage_priv privileges. - -grammar: - -```sql -SHOW WORKLOAD GROUPS [LIKE "pattern"]; -``` - -Description: - -This statement only does a simple display of workload groups, for a more complex display refer to tvf workload_groups(). - -### Example - -1. Show all workload groups: - - ```sql - mysql> show workload groups; - +----------+--------+--------------------------+---------+ - | Id | Name | Item | Value | - +----------+--------+--------------------------+---------+ - | 10343386 | normal | cpu_share | 10 | - | 10343386 | normal | memory_limit | 30% | - | 10343386 | normal | enable_memory_overcommit | true | - | 10352416 | g1 | memory_limit | 20% | - | 10352416 | g1 | cpu_share | 10 | - +----------+--------+--------------------------+---------+ - ``` - -2. Show workload groups using pattern - - ```sql - mysql> show workload groups like "normal%"; - +----------+--------+--------------------------+---------+ - | Id | Name | Item | Value | - +----------+--------+--------------------------+---------+ - | 10343386 | normal | cpu_share | 10 | - | 10343386 | normal | memory_limit | 30% | - | 10343386 | normal | enable_memory_overcommit | true | - +----------+--------+--------------------------+---------+ - ``` - -### Keywords - - SHOW, WORKLOAD, GROUPS, GROUP - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Utility-Statements/CANCEL-MATERIALIZED-VIEW-TASK.md b/docs/sql-manual/sql-statements/Utility-Statements/CANCEL-MATERIALIZED-VIEW-TASK.md deleted file mode 100644 index 9b779fe9271bb..0000000000000 --- a/docs/sql-manual/sql-statements/Utility-Statements/CANCEL-MATERIALIZED-VIEW-TASK.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "CANCEL-MATERIALIZED-VIEW-TASK", - "language": "en" -} ---- - - - -## CANCEL-MATERIALIZED-VIEW-TASK - -### Name - -CANCEL MATERIALIZED VIEW TASK - -### Description - -This statement is used to cancel the task of materialized views - -syntax: - -```sql -CANCEL MATERIALIZED VIEW TASK taskId=INTEGER_VALUE ON mvName=multipartIdentifier -``` - -### Example - -1. Cancel the task with id 1 in materialized view mv1 - - ```sql - CANCEL MATERIALIZED VIEW TASK 1 on mv1; - ``` - -### Keywords - - CANCEL, MATERIALIZED, VIEW, TASK - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Utility-Statements/CLEAN-QUERY-STATS.md b/docs/sql-manual/sql-statements/Utility-Statements/CLEAN-QUERY-STATS.md deleted file mode 100644 index c8d18aed96797..0000000000000 --- a/docs/sql-manual/sql-statements/Utility-Statements/CLEAN-QUERY-STATS.md +++ /dev/null @@ -1,73 +0,0 @@ ---- -{ - "title": "CLEAN-QUERY-STATS", - "language": "en" -} ---- - - - -## CLEAN-QUERY-STATS - -### Name - -CLEAN QUERY STATS - -### Description - -This statement is used to clear query statistics - -grammar: - -```sql -CLEAN [ALL| DATABASE | TABLE] QUERY STATS [[FOR db_name]|[FROM|IN] table_name]]; -``` - -Remarks: - -1. If ALL is specified, all query statistics are cleared, including database and table, admin privilege is needed -2. If DATABASE is specified, the query statistics of the specified database are cleared, alter privilege for this database is needed -3. If TABLE is specified, the query statistics of the specified table are cleared, alter privilege for this table is needed - -### Example - -1. Clear all statistics -2. - ```sql - clean all query stats; - ``` - -2. Clear the specified database statistics - - ```sql - clean database query stats for test_query_db; - ``` -3. Clear the specified table statistics - - ```sql - clean table query stats from test_query_db.baseall; - ``` - -### Keywords - - CLEAN, QUERY, STATS - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Utility-Statements/DESCRIBE.md b/docs/sql-manual/sql-statements/Utility-Statements/DESCRIBE.md deleted file mode 100644 index 4eb2997b3340f..0000000000000 --- a/docs/sql-manual/sql-statements/Utility-Statements/DESCRIBE.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -{ - "title": "DESCRIBE", - "language": "en" -} ---- - - - -## DESCRIBE - -### Name - -DESCRIBE - -### Description - -This statement is used to display the schema information of the specified table - -grammar: - -```sql -DESC[RIBE] [db_name.]table_name [ALL]; -``` - -illustrate: - -1. If ALL is specified, the schemas of all indexes (rollup) of the table will be displayed - -### Example - -1. Display the Base table schema - - ```sql - DESC table_name; - ``` - -2. Display the schema of all indexes of the table - - ```sql - DESC db1.table_name ALL; - ``` - -### Keywords - - DESCRIBE - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Utility-Statements/HELP.md b/docs/sql-manual/sql-statements/Utility-Statements/HELP.md deleted file mode 100644 index 68e4a3e0e711d..0000000000000 --- a/docs/sql-manual/sql-statements/Utility-Statements/HELP.md +++ /dev/null @@ -1,114 +0,0 @@ ---- -{ - "title": "HELP", - "language": "en" -} ---- - - - -## HELP - -### Name - -HELP - -### Description - -The directory of help can be queried by changing the command - -grammar: - -``` sql -HELP -``` - -All Doris commands can be listed with `help` - -```sql -List of all MySQL commands: -Note that all text commands must be first on line and end with ';' -? (\?) Synonym for `help'. -clear (\c) Clear the current input statement. -connect (\r) Reconnect to the server. Optional arguments are db and host. -delimiter (\d) Set statement delimiter. -edit (\e) Edit command with $EDITOR. -ego (\G) Send command to mysql server, display result vertically. -exit (\q) Exit mysql. Same as quit. -go (\g) Send command to mysql server. -help (\h) Display this help. -nopager (\n) Disable pager, print to stdout. -note (\t) Don't write into outfile. -pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. -print (\p) Print current command. -prompt (\R) Change your mysql prompt. -quit (\q) Quit mysql. -rehash (\#) Rebuild completion hash. -source (\.) Execute an SQL script file. Takes a file name as an argument. -status (\s) Get status information from the server. -system (\!) Execute a system shell command. -tee (\T) Set outfile [to_outfile]. Append everything into given outfile. -use (\u) Use another database. Takes database name as argument. -charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. -warnings (\W) Show warnings after every statement. -nowarning (\w) Don't show warnings after every statement. -resetconnection(\x) Clean session context. - -For server side help, type 'help contents' -``` - -Get the Doris SQL help contents via `help contents` - -```sql -Many help items for your request exist. -To make a more specific request, please type 'help ', -where is one of the following -categories: - sql-functions - sql-statements -``` - -### Example - -1. List all SQL help contents of Doris - - ```sql - help contents - ``` - -2. The command to list all function directories of the Doris cluster - - ```sql - help sql-functions - ``` - -3. List all functions under the date function - - ```sql - help date-time-functions - ``` - - -### Keywords - - HELP - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Utility-Statements/PAUSE-MATERIALIZED-VIEW.md b/docs/sql-manual/sql-statements/Utility-Statements/PAUSE-MATERIALIZED-VIEW.md deleted file mode 100644 index 2ed352ffb2270..0000000000000 --- a/docs/sql-manual/sql-statements/Utility-Statements/PAUSE-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "PAUSE-MATERIALIZED-VIEW", - "language": "en" -} ---- - - - -## PAUSE-MATERIALIZED-VIEW - -### Name - -PAUSE MATERIALIZED VIEW - -### Description - -This statement is used to pause the scheduled scheduling of materialized views - -syntax: - -```sql -PAUSE MATERIALIZED VIEW JOB ON mvName=multipartIdentifier -``` - -### Example - -1. Pause scheduled scheduling of materialized view mv1 - - ```sql - PAUSE MATERIALIZED VIEW JOB ON mv1; - ``` - -### Keywords - - PAUSE, MATERIALIZED, VIEW - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Utility-Statements/REFRESH-LDAP.md b/docs/sql-manual/sql-statements/Utility-Statements/REFRESH-LDAP.md deleted file mode 100644 index 6189be64fea3b..0000000000000 --- a/docs/sql-manual/sql-statements/Utility-Statements/REFRESH-LDAP.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -{ - "title": "REFRESH-LDAP", - "language": "en" -} ---- - - - -## REFRESH-LDAP - -### Name - -REFRESH-LDAP - -### Description - -This statement is used to refresh the cached information of LDAP in Doris. The default timeout for LDAP information cache in Doris is 12 hours, which can be viewed by `SHOW FRONTEND CONFIG LIKE 'ldap_ user_cache_timeout_s';`. - -syntax: - -```sql -REFRESH LDAP ALL; -REFRESH LDAP [for user_name]; -``` - -### Example - -1. refresh all LDAP user cache information - - ```sql - REFRESH LDAP ALL; - ``` - -2. refresh the cache information for the current LDAP user - - ```sql - REFRESH LDAP; - ``` - -3. refresh the cache information of the specified LDAP user user1 - - ```sql - REFRESH LDAP for user1; - ``` - - -### Keywords - -REFRESH, LDAP - -### Best Practice diff --git a/docs/sql-manual/sql-statements/Utility-Statements/REFRESH-MATERIALIZED-VIEW.md b/docs/sql-manual/sql-statements/Utility-Statements/REFRESH-MATERIALIZED-VIEW.md deleted file mode 100644 index f9c5bf29f7364..0000000000000 --- a/docs/sql-manual/sql-statements/Utility-Statements/REFRESH-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -{ - "title": "REFRESH-MATERIALIZED-VIEW", - "language": "en" -} ---- - - - -## REFRESH-MATERIALIZED-VIEW - -### Name - -REFRESH MATERIALIZED VIEW - -### Description - -This statement is used to manually refresh the specified asynchronous materialized view - -syntax: - -```sql -REFRESH MATERIALIZED VIEW mvName=multipartIdentifier (partitionSpec | COMPLETE | AUTO) -``` - -Explanation: - -Asynchronous refresh of data for a materialized view - -- AUTO: The calculation will determine which partitions of the materialized view are not synchronized with the base table. (Currently, if the base table is an external table, it is considered to be always synchronized with the materialized view. Therefore, if the base table is an external table, it is necessary to specify `COMPLETE` or designate the partitions to be refreshed), and then proceed to refresh the corresponding partitions accordingly. -- COMPLETE: It will forcibly refresh all partitions of the materialized view without checking whether the partitions are synchronized with the base table. -- partitionSpec: It will forcibly refresh the specified partitions without checking whether the partitions are synchronized with the base table. - -### Example - -1. Refresh materialized view mv1 (automatically calculate the partition to be refreshed) - - ```sql - REFRESH MATERIALIZED VIEW mv1 AUTO; - ``` - -2. Refresh partition named p_19950801_19950901和p_19950901_19951001 - - ```sql - REFRESH MATERIALIZED VIEW mv1 partitions(p_19950801_19950901,p_19950901_19951001); - ``` - -3. Force refresh of all materialized view data - - ```sql - REFRESH MATERIALIZED VIEW mv1 complete; - ``` - -### Keywords - - REFRESH, MATERIALIZED, VIEW - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Utility-Statements/REFRESH.md b/docs/sql-manual/sql-statements/Utility-Statements/REFRESH.md deleted file mode 100644 index 6d688f62de2d0..0000000000000 --- a/docs/sql-manual/sql-statements/Utility-Statements/REFRESH.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -{ - "title": "REFRESH", - "language": "en" -} ---- - - - -## REFRESH - -### Name - -REFRESH - -### Description - -This statement refreshes the metadata of the specified Catalog/Database/Table. - -syntax: - -```sql -REFRESH CATALOG catalog_name; -REFRESH DATABASE [catalog_name.]database_name; -REFRESH TABLE [catalog_name.][database_name.]table_name; -``` - -When the Catalog is refreshed, the object-related Cache is forced to be invalidated. - -Including Partition Cache, Schema Cache, File Cache, etc. - -### Example - -1. Refresh hive catalog - - ```sql - REFRESH CATALOG hive; - ``` - -2. Refresh database1 - - ```sql - REFRESH DATABASE ctl.database1; - REFRESH DATABASE database1; - ``` - -3. Refresh table1 - - ```sql - REFRESH TABLE ctl.db.table1; - REFRESH TABLE db.table1; - REFRESH TABLE table1; - ``` - -### Keywords - -REFRESH, CATALOG, DATABASE, TABLE - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Utility-Statements/RESUME-MATERIALIZED-VIEW.md b/docs/sql-manual/sql-statements/Utility-Statements/RESUME-MATERIALIZED-VIEW.md deleted file mode 100644 index 816b59b02be99..0000000000000 --- a/docs/sql-manual/sql-statements/Utility-Statements/RESUME-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "RESUME-MATERIALIZED-VIEW", - "language": "en" -} ---- - - - -## RESUME-MATERIALIZED-VIEW - -### Name - -RESUME MATERIALIZED VIEW - -### Description - -This statement is used to temporarily restore the scheduled scheduling of materialized views - -syntax: - -```sql -RESUME MATERIALIZED VIEW JOB ON mvName=multipartIdentifier -``` - -### Example - -1. Timed scheduling for restoring materialized view mv1 - - ```sql - RESUME MATERIALIZED VIEW JOB ON mv1; - ``` - -### Keywords - - RESUME, MATERIALIZED, VIEW - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Utility-Statements/SWITCH.md b/docs/sql-manual/sql-statements/Utility-Statements/SWITCH.md deleted file mode 100644 index 312a334b22dab..0000000000000 --- a/docs/sql-manual/sql-statements/Utility-Statements/SWITCH.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "SWITCH", - "language": "en" -} ---- - - - -## SWITCH - -### Name - -SWITCH - -### Description - -This statement is used to switch catalog. - -Syntax: - -```sql -SWITCH catalog_name -``` - -### Example - -1. Switch to hive - - ```sql - SWITCH hive; - ``` - -### Keywords - -SWITCH, CATALOG - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Utility-Statements/SYNC.md b/docs/sql-manual/sql-statements/Utility-Statements/SYNC.md deleted file mode 100644 index 276a7b49eb142..0000000000000 --- a/docs/sql-manual/sql-statements/Utility-Statements/SYNC.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "SYNC", - "language": "en" -} ---- - - - -## SYNC - -### Name - -SYNC - -### Description - -Used to synchronize metadata for fe non-master nodes. doris only master node can write fe metadata, other fe nodes write metadata operations will be forwarded to master. After master finishes metadata writing operation, there will be a short delay for non-master nodes to replay metadata, you can use this statement to synchronize metadata. - -grammar: - -```sql -SYNC; -``` - -### Example - -1. Synchronized metadata: - - ```sql - SYNC; - ``` - -### Keywords - - SYNC - -### Best Practice - diff --git a/docs/sql-manual/sql-statements/Utility-Statements/USE.md b/docs/sql-manual/sql-statements/Utility-Statements/USE.md deleted file mode 100644 index 391a042cab44d..0000000000000 --- a/docs/sql-manual/sql-statements/Utility-Statements/USE.md +++ /dev/null @@ -1,72 +0,0 @@ ---- -{ - "title": "USE", - "language": "en" -} ---- - - - -## Description - -The USE command allows us to switch to a specific database or compute group in your SQL environment. - -## Syntax - -```SQL -USE { [catalog_name.]database_name[@compute_group_name] | @compute_group_name } -``` - -## Example - -1. If the demo database exists in current catalog, try accessing it: - - ```sql - mysql> use demo; - Database changed - ``` -2. If the demo database exists in catalog hms_catalog, try switching the catalog and accessing it: - - ```sql - mysql> use hms_catalog.demo; - Database changed - ``` - -3. If the demo database exists in current catalog and you want to use the compute group named 'cg1', try accessing it: - - ```sql - mysql> use demo@cg1; - Database changed - ``` - -4. If you want to use only the compute group named 'cg1', try accessing it: - - ```sql - mysql> use @cg1; - Database changed - ``` - -## Relate Commands - -## Keywords - - USE, DATABASE, USER, COMPUTE GROUP - - diff --git a/docs/sql-manual/sql-statements/account-management/ALTER-ROLE.md b/docs/sql-manual/sql-statements/account-management/ALTER-ROLE.md new file mode 100644 index 0000000000000..9b2020e2a0c7f --- /dev/null +++ b/docs/sql-manual/sql-statements/account-management/ALTER-ROLE.md @@ -0,0 +1,50 @@ +--- +{ + "title": "ALTER ROLE", + "language": "en" +} +--- + + + + + +## Description + +Statement used to modify a role + +```sql + ALTER ROLE role_name comment; +``` + +## Example + +1. Modify the role's comment + + ```sql + ALTER ROLE role1 COMMENT "this is my first role"; + ``` + +## Keywords + +ALTER, ROLE + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/account-management/ALTER-USER.md b/docs/sql-manual/sql-statements/account-management/ALTER-USER.md new file mode 100644 index 0000000000000..47515ec73fdbf --- /dev/null +++ b/docs/sql-manual/sql-statements/account-management/ALTER-USER.md @@ -0,0 +1,101 @@ +--- +{ + "title": "ALTER USER", + "language": "en" +} +--- + + + + +## Description + +The ALTER USER command is used to modify a user's account attributes, including passwords, and password policies, etc. + +>Note that. +> +>This command give over supports modifying user roles from versions 2.0. Please use [GRANT](./GRANT.md) and [REVOKE](./REVOKE.md) for related operations + +```sql +ALTER USER [IF EXISTS] user_identity [IDENTIFIED BY 'password'] +[password_policy] +[comment] + +user_identity: + 'user_name'@'host' + +password_policy: + + 1. PASSWORD_HISTORY [n|DEFAULT] + 2. PASSWORD_EXPIRE [DEFAULT|NEVER|INTERVAL n DAY/HOUR/SECOND] + 3. FAILED_LOGIN_ATTEMPTS n + 4. PASSWORD_LOCK_TIME [n DAY/HOUR/SECOND|UNBOUNDED] + 5. ACCOUNT_UNLOCK +``` + +About `user_identity` and `password_policy`, Please refer to `CREATE USER`. + +`ACCOUNT_UNLOCK` is used to unlock a locked user. + +In an ALTER USER command, only one of the following account attributes can be modified at the same time: + +1. Change password +2. Modify `PASSWORD_HISTORY` +3. Modify `PASSWORD_EXPIRE` +4. Modify `FAILED_LOGIN_ATTEMPTS` and `PASSWORD_LOCK_TIME` +5. Unlock users + +## Example + +1. Change the user's password + + ```sql + ALTER USER jack@'%' IDENTIFIED BY "12345"; + ``` + +2. Modify the user's password policy + + ```sql + ALTER USER jack@'%' FAILED_LOGIN_ATTEMPTS 3 PASSWORD_LOCK_TIME 1 DAY; + ``` + +3. Unlock a user + + ```sql + ALTER USER jack@'%' ACCOUNT_UNLOCK + ``` + +4. Modify the user's comment + + ```sql + ALTER USER jack@'%' COMMENT "this is my first user" + ``` + +## Keywords + +ALTER, USER + +## Best Practice + +1. Modify the password policy + + 1. Modify `PASSWORD_EXPIRE` will reset the timing of password expiration time. + + 2. Modify `FAILED_LOGIN_ATTEMPTS` or `PASSWORD_LOCK_TIME` will unlock the user. \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/account-management/CREATE-ROLE.md b/docs/sql-manual/sql-statements/account-management/CREATE-ROLE.md new file mode 100644 index 0000000000000..810c3c7083e4e --- /dev/null +++ b/docs/sql-manual/sql-statements/account-management/CREATE-ROLE.md @@ -0,0 +1,57 @@ +--- +{ + "title": "CREATE ROLE", + "language": "en" +} +--- + + + + + +## Description + +The statement user creates a role + +```sql + CREATE ROLE role_name [comment]; +``` + +This statement creates an unprivileged role, which can be subsequently granted with the GRANT command. + +## Example + +1. Create a role + + ```sql + CREATE ROLE role1; + ``` + +2. Create a role with comment + + ```sql + CREATE ROLE role2 COMMENT "this is my first role"; + ``` + +## Keywords + +CREATE, ROLE + +## Best Practice diff --git a/docs/sql-manual/sql-statements/account-management/CREATE-USER.md b/docs/sql-manual/sql-statements/account-management/CREATE-USER.md new file mode 100644 index 0000000000000..96336d548f86c --- /dev/null +++ b/docs/sql-manual/sql-statements/account-management/CREATE-USER.md @@ -0,0 +1,135 @@ +--- +{ + "title": "CREATE USER", + "language": "en" +} +--- + + + + + +## Description + +The CREATE USER command is used to create a Doris user. + +```sql +CREATE USER [IF EXISTS] user_identity [IDENTIFIED BY 'password'] +[DEFAULT ROLE 'role_name'] +[password_policy] +[comment] + +user_identity: + 'user_name'@'host' + +password_policy: + + 1. PASSWORD_HISTORY [n|DEFAULT] + 2. PASSWORD_EXPIRE [DEFAULT|NEVER|INTERVAL n DAY/HOUR/SECOND] + 3. FAILED_LOGIN_ATTEMPTS n + 4. PASSWORD_LOCK_TIME [n DAY/HOUR/SECOND|UNBOUNDED] +``` + +In Doris, a user_identity uniquely identifies a user. user_identity consists of two parts, user_name and host, where username is the username. host Identifies the host address where the client connects. The host part can use % for fuzzy matching. If no host is specified, it defaults to '%', which means the user can connect to Doris from any host. + +The host part can also be specified as a domain, the syntax is: 'user_name'@['domain'], even if it is surrounded by square brackets, Doris will think this is a domain and try to resolve its ip address. . + +If a role (ROLE) is specified, the newly created user will be automatically granted the permissions of the role. If not specified, the user has no permissions by default. The specified ROLE must already exist. + +`password_policy` is a clause used to specify policies related to password authentication login. Currently, the following policies are supported: + +1. `PASSWORD_HISTORY` + + Whether to allow the current user to use historical passwords when resetting their passwords. For example, `PASSWORD_HISTORY 10` means that it is forbidden to use the password set in the past 10 times as a new password. If set to `PASSWORD_HISTORY DEFAULT`, the value in the global variable `password_history` will be used. `0` means do not enable this feature. Default is 0. + +2. `PASSWORD_EXPIRE` + + Set the expiration time of the current user's password. For example `PASSWORD_EXPIRE INTERVAL 10 DAY` means the password will expire in 10 days. `PASSWORD_EXPIRE NEVER` means that the password does not expire. If set to `PASSWORD_EXPIRE DEFAULT`, the value in the global variable `default_password_lifetime` is used. Defaults to NEVER (or 0), which means it will not expire. + +3. `FAILED_LOGIN_ATTEMPTS` and `PASSWORD_LOCK_TIME` + + When the current user logs in, if the user logs in with the wrong password for n times, the account will be locked, and the lock time is set. For example, `FAILED_LOGIN_ATTEMPTS 3 PASSWORD_LOCK_TIME 1 DAY` means that if you log in wrongly for 3 times, the account will be locked for one day. + + A locked account can be actively unlocked through the `ALTER USER` statement. + +## Example + +1. Create a passwordless user (if host is not specified, it is equivalent to jack@'%') + + ```sql + CREATE USER 'jack'; + ``` + +2. Create a user with a password to allow login from '172.10.1.10' + + ```sql + CREATE USER jack@'172.10.1.10' IDENTIFIED BY '123456'; + ``` + +3. In order to avoid passing plaintext, use case 2 can also be created in the following way + + ```sql + CREATE USER jack@'172.10.1.10' IDENTIFIED BY PASSWORD '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9'; + The encrypted content can be obtained through PASSWORD(), for example: + SELECT PASSWORD('123456'); + ``` + +4. Create a user that is allowed to log in from the '192.168' subnet, and specify its role as example_role + + ```sql + CREATE USER 'jack'@'192.168.%' DEFAULT ROLE 'example_role'; + ``` + +5. Create a user that is allowed to log in from the domain 'example_domain' + + ```sql + CREATE USER 'jack'@['example_domain'] IDENTIFIED BY '12345'; + ``` + +6. Create a user and assign a role + + ```sql + CREATE USER 'jack'@'%' IDENTIFIED BY '12345' DEFAULT ROLE 'my_role'; + ``` + +7. Create a user, set the password to expire after 10 days, and set the account to be locked for one day if you log in failed for 3 times. + + ```sql + CREATE USER 'jack' IDENTIFIED BY '12345' PASSWORD_EXPIRE INTERVAL 10 DAY FAILED_LOGIN_ATTEMPTS 3 PASSWORD_LOCK_TIME 1 DAY; + ``` + +8. Create a user and restrict non-resetable passwords to the last 8 passwords used. + + ```sql + CREATE USER 'jack' IDENTIFIED BY '12345' PASSWORD_HISTORY 8; + ``` + +9. Create a user with comment + + ```sql + CREATE USER 'jack' COMMENT "this is my first user"; + ``` + +## Keywords + +CREATE, USER + + + diff --git a/docs/sql-manual/sql-statements/account-management/DROP-ROLE.md b/docs/sql-manual/sql-statements/account-management/DROP-ROLE.md new file mode 100644 index 0000000000000..d7689a0286fc0 --- /dev/null +++ b/docs/sql-manual/sql-statements/account-management/DROP-ROLE.md @@ -0,0 +1,52 @@ +--- +{ + "title": "DROP ROLE", + "language": "en" +} +--- + + + + + +## Description + +The statement user removes a role + +```sql +DROP ROLE [IF EXISTS] role1; +``` + +Deleting a role does not affect the permissions of users who previously belonged to the role. It is only equivalent to decoupling the role from the user. The permissions that the user has obtained from the role will not change + +## Example + +1. Drop a role1 + + ```sql + DROP ROLE role1; + ``` + +## Keywords + +DROP, ROLE + + + diff --git a/docs/sql-manual/sql-statements/account-management/DROP-USER.md b/docs/sql-manual/sql-statements/account-management/DROP-USER.md new file mode 100644 index 0000000000000..d32f031770608 --- /dev/null +++ b/docs/sql-manual/sql-statements/account-management/DROP-USER.md @@ -0,0 +1,61 @@ +--- +{ + "title": "DROP USER", + "language": "en" +} +--- + + + +## DROP-USER + +### Name + +DROP USER + +## Description + +Delete a user + +```sql + DROP USER 'user_identity' + + `user_identity`: + + user@'host' + user@['domain'] +``` + + Delete the specified user identitiy. + +## Example + +1. Delete user jack@'192.%' + + ```sql + DROP USER 'jack'@'192.%' + ``` + +## Keywords + +DROP, USER + + + diff --git a/docs/sql-manual/sql-statements/account-management/GRANT-TO.md b/docs/sql-manual/sql-statements/account-management/GRANT-TO.md new file mode 100644 index 0000000000000..f024ca70735a0 --- /dev/null +++ b/docs/sql-manual/sql-statements/account-management/GRANT-TO.md @@ -0,0 +1,189 @@ +--- +{ + "title": "GRANT TO", + "language": "en" +} + +--- + + + + +## Description + +The GRANT command is used to: + +1. Grant specified privileges to a user or role. +2. Grant specified roles to a user. + +## Syntax + +GRANT privilege_list ON priv_level TO user_identity [ROLE role_name] + +GRANT privilege_list ON RESOURCE resource_name TO user_identity [ROLE role_name] + +GRANT privilege_list ON WORKLOAD GROUP workload_group_name TO user_identity [ROLE role_name] + +GRANT privilege_list ON COMPUTE GROUP compute_group_name TO user_identity [ROLE role_name] + +GRANT privilege_list ON STORAGE VAULT storage_vault_name TO user_identity [ROLE role_name] + +GRANT role_list TO user_identity + +## Parameters + +### privilege_list + +A comma-separated list of privileges to be granted. Currently supported privileges include: + +- NODE_PRIV: Cluster node operation permissions, including node online and offline operations. +- ADMIN_PRIV: All privileges except NODE_PRIV. +- GRANT_PRIV: Privilege for operation privileges, including creating and deleting users, roles, authorization and revocation, setting passwords, etc. +- SELECT_PRIV: Read permission on the specified database or table. +- LOAD_PRIV: Import privileges on the specified database or table. +- ALTER_PRIV: Schema change permission for the specified database or table. +- CREATE_PRIV: Create permission on the specified database or table. +- DROP_PRIV: Drop privilege on the specified database or table. +- USAGE_PRIV: Access to the specified resource and Workload Group permissions. +- SHOW_VIEW_PRIV: Permission to view `view` creation statements. + +Legacy privilege conversion: +- ALL and READ_WRITE will be converted to: SELECT_PRIV, LOAD_PRIV, ALTER_PRIV, CREATE_PRIV, DROP_PRIV. +- READ_ONLY is converted to SELECT_PRIV. + +### priv_level + +Supports the following four forms: + +- *.*.*: Privileges can be applied to all catalogs and all databases and tables within them. +- catalog_name.*.*: Privileges can be applied to all databases and tables in the specified catalog. +- catalog_name.db.*: Privileges can be applied to all tables under the specified database. +- catalog_name.db.tbl: Privileges can be applied to the specified table under the specified database. + +### resource_name + +Specifies the resource name, supporting `%` and `*` to match all resources, but does not support wildcards, such as res*. + +### workload_group_name + +Specifies the workload group name, supporting `%` and `*` to match all workload groups, but does not support wildcards. + +### compute_group_name + +Specifies the compute group name, supporting `%` and `*` to match all compute groups, but does not support wildcards. + +### storage_vault_name + +Specifies the storage vault name, supporting `%` and `*` to match all storage vaults, but does not support wildcards. + +### user_identity + +Specifies the user to receive the privileges. Must be a user_identity created with CREATE USER. The host in user_identity can be a domain name. If it is a domain name, the effective time of the authority may be delayed by about 1 minute. + +### role_name + +Specifies the role to receive the privileges. If the specified role does not exist, it will be created automatically. + +### role_list + +A comma-separated list of roles to be assigned. The specified roles must exist. + +## Examples + +1. Grant permissions to all catalogs and databases and tables to the user: + + GRANT SELECT_PRIV ON *.*.* TO 'jack'@'%'; + +2. Grant permissions to the specified database table to the user: + + GRANT SELECT_PRIV,ALTER_PRIV,LOAD_PRIV ON ctl1.db1.tbl1 TO 'jack'@'192.8.%'; + +3. Grant permissions to the specified database table to the role: + + GRANT LOAD_PRIV ON ctl1.db1.* TO ROLE 'my_role'; + +4. Grant access to all resources to users: + + GRANT USAGE_PRIV ON RESOURCE * TO 'jack'@'%'; + +5. Grant the user permission to use the specified resource: + + GRANT USAGE_PRIV ON RESOURCE 'spark_resource' TO 'jack'@'%'; + +6. Grant access to specified resources to roles: + + GRANT USAGE_PRIV ON RESOURCE 'spark_resource' TO ROLE 'my_role'; + +7. Grant the specified role to a user: + + GRANT 'role1','role2' TO 'jack'@'%'; + +8. Grant the specified workload group 'g1' to user jack: + + GRANT USAGE_PRIV ON WORKLOAD GROUP 'g1' TO 'jack'@'%'; + +9. Match all workload groups granted to user jack: + + GRANT USAGE_PRIV ON WORKLOAD GROUP '%' TO 'jack'@'%'; + +10. Grant the workload group 'g1' to the role my_role: + + GRANT USAGE_PRIV ON WORKLOAD GROUP 'g1' TO ROLE 'my_role'; + +11. Allow jack to view the creation statement of view1 under db1: + + GRANT SHOW_VIEW_PRIV ON db1.view1 TO 'jack'@'%'; + +12. Grant user permission to use the specified compute group: + + GRANT USAGE_PRIV ON COMPUTE GROUP 'group1' TO 'jack'@'%'; + +13. Grant role permission to use the specified compute group: + + GRANT USAGE_PRIV ON COMPUTE GROUP 'group1' TO ROLE 'my_role'; + +14. Grant user permission to use all compute groups: + + GRANT USAGE_PRIV ON COMPUTE GROUP '*' TO 'jack'@'%'; + +15. Grant user permission to use the specified storage vault: + + GRANT USAGE_PRIV ON STORAGE VAULT 'vault1' TO 'jack'@'%'; + +16. Grant role permission to use the specified storage vault: + + GRANT USAGE_PRIV ON STORAGE VAULT 'vault1' TO ROLE 'my_role'; + +17. Grant user permission to use all storage vaults: + + GRANT USAGE_PRIV ON STORAGE VAULT '*' TO 'jack'@'%'; + +## Related Commands + +- [REVOKE](./REVOKE.md) +- [SHOW GRANTS](../../../sql-manual/sql-statements/account-management/SHOW-GRANTS.md) +- [CREATE ROLE](./CREATE-ROLE.md) +- [CREATE WORKLOAD GROUP](../Administration-Statements/CREATE-WORKLOAD-GROUP.md) +- [CREATE RESOURCE](../Administration-Statements/CREATE-RESOURCE.md) +- [CREATE STORAGE VAULT](../Administration-Statements/CREATE-STORAGE-VAULT.md) + +## Keywords + +GRANT, WORKLOAD GROUP, COMPUTE GROUP, RESOURCE diff --git a/docs/sql-manual/sql-statements/account-management/REFRESH-LDAP.md b/docs/sql-manual/sql-statements/account-management/REFRESH-LDAP.md new file mode 100644 index 0000000000000..38a0ddaa5f91b --- /dev/null +++ b/docs/sql-manual/sql-statements/account-management/REFRESH-LDAP.md @@ -0,0 +1,64 @@ +--- +{ + "title": "REFRESH LDAP", + "language": "en" +} +--- + + + + +## Description + +This statement is used to refresh the cached information of LDAP in Doris. The default timeout for LDAP information cache in Doris is 12 hours, which can be viewed by `SHOW FRONTEND CONFIG LIKE 'ldap_ user_cache_timeout_s';`. + +syntax: + +```sql +REFRESH LDAP ALL; +REFRESH LDAP [for user_name]; +``` + +## Example + +1. refresh all LDAP user cache information + + ```sql + REFRESH LDAP ALL; + ``` + +2. refresh the cache information for the current LDAP user + + ```sql + REFRESH LDAP; + ``` + +3. refresh the cache information of the specified LDAP user user1 + + ```sql + REFRESH LDAP for user1; + ``` + + +## Keywords + +REFRESH, LDAP + +## Best Practice diff --git a/docs/sql-manual/sql-statements/account-management/REVOKE-FROM.md b/docs/sql-manual/sql-statements/account-management/REVOKE-FROM.md new file mode 100644 index 0000000000000..8f31972b1bbce --- /dev/null +++ b/docs/sql-manual/sql-statements/account-management/REVOKE-FROM.md @@ -0,0 +1,97 @@ +--- +{ + "title": "REVOKE FROM", + "language": "en" +} +--- + + + + +## Description + +The REVOKE command has the following functions: + +1. Revoke the specified permission of a user or a role. +2. Revoke the specified role previously granted to a user. + +>Note that. +> +>"Revoke the specified roles previously granted to a user" is supported in versions 2.0 and later + +```sql +REVOKE privilege_list ON db_name[.tbl_name] FROM user_identity [ROLE role_name] + +REVOKE privilege_list ON RESOURCE resource_name FROM user_identity [ROLE role_name] + +REVOKE role_list FROM user_identity +``` + +user_identity: + +The user_identity syntax here is the same as CREATE USER. And must be a user_identity created with CREATE USER. The host in user_identity can be a domain name. If it is a domain name, the revocation time of permissions may be delayed by about 1 minute. + +It is also possible to revoke the permissions of the specified ROLE, the executed ROLE must exist. + +role_list is the list of roles to be revoked, separated by commas. The specified roles must exist. + +## Example + +1. Revoke the permission of user jack database testDb + + ```sql + REVOKE SELECT_PRIV ON db1.* FROM 'jack'@'192.%'; + ``` + +2. Revoke user jack resource spark_resource permission + + ```sql + REVOKE USAGE_PRIV ON RESOURCE 'spark_resource' FROM 'jack'@'192.%'; + ``` +3. Revoke the roles role1 and role2 previously granted to jack + + ```sql + REVOKE 'role1','role2' FROM 'jack'@'192.%'; + ``` + +4. Revoke user jack usage privilege on 'g1'; + + ```sql + REVOKE USAGE_PRIV ON WORKLOAD GROUP 'g1' FROM 'jack'@'%'; + ``` + +5. Revoke user jack usage privilege on all Workload Group; + + ```sql + REVOKE USAGE_PRIV ON WORKLOAD GROUP '%' FROM 'jack'@'%'; + ``` + +6. Revoke role test_role usage privilege on Workload Group 'g1'; + + ```sql + REVOKE USAGE_PRIV ON WORKLOAD GROUP 'g1' FROM 'test_role'; + ``` + +## Keywords + +REVOKE + + + diff --git a/docs/sql-manual/sql-statements/account-management/SET-LDAP_ADMIN_PASSWORD.md b/docs/sql-manual/sql-statements/account-management/SET-LDAP_ADMIN_PASSWORD.md new file mode 100644 index 0000000000000..8b7c548024c97 --- /dev/null +++ b/docs/sql-manual/sql-statements/account-management/SET-LDAP_ADMIN_PASSWORD.md @@ -0,0 +1,50 @@ +--- +{ + "title": "SET LDAP_ADMIN_PASSWORD", + "language": "en" +} +--- + + + + +## Description + +SET LDAP_ADMIN_PASSWORD + +```sql + SET LDAP_ADMIN_PASSWORD = PASSWORD('plain password') +``` + +The SET LDAP_ADMIN_PASSWORD command is used to set the LDAP administrator password. When using LDAP authentication, doris needs to use the administrator account and password to query the LDAP service for login user information. + +## Example + +1. Set the LDAP administrator password + + ```sql + SET LDAP_ADMIN_PASSWORD = PASSWORD('123456') + ``` + +## Keywords + +LDAP, PASSWORD, LDAP_ADMIN_PASSWORD + +## Best Practice diff --git a/docs/sql-manual/sql-statements/account-management/SET-PASSWORD.md b/docs/sql-manual/sql-statements/account-management/SET-PASSWORD.md new file mode 100644 index 0000000000000..7c06aebf3a3f5 --- /dev/null +++ b/docs/sql-manual/sql-statements/account-management/SET-PASSWORD.md @@ -0,0 +1,62 @@ +--- +{ + "title": "SET PASSWORD", + "language": "en" +} +--- + + + +## Description + +The SET PASSWORD command can be used to modify a user's login password. If the [FOR user_identity] field does not exist, then change the current user's password + +```sql +SET PASSWORD [FOR user_identity] = + [PASSWORD('plain password')]|['hashed password'] +``` + +Note that the user_identity here must exactly match the user_identity specified when creating a user with CREATE USER, otherwise an error will be reported that the user does not exist. If user_identity is not specified, the current user is 'username'@'ip', which may not match any user_identity. Current users can be viewed through SHOW GRANTS. + +The plaintext password is input in the PASSWORD() method; when using a string directly, the encrypted password needs to be passed. +To modify the passwords of other users, administrator privileges are required. + +## Example + +1. Modify the current user's password + + ```sql + SET PASSWORD = PASSWORD('123456') + SET PASSWORD = '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' + ``` + +2. Modify the specified user password + + ```sql + SET PASSWORD FOR 'jack'@'192.%' = PASSWORD('123456') + SET PASSWORD FOR 'jack'@['domain'] = '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' + ``` + +## Keywords + +SET, PASSWORD + + + diff --git a/docs/sql-manual/sql-statements/account-management/SET-PROPERTY.md b/docs/sql-manual/sql-statements/account-management/SET-PROPERTY.md new file mode 100644 index 0000000000000..6123e748a4796 --- /dev/null +++ b/docs/sql-manual/sql-statements/account-management/SET-PROPERTY.md @@ -0,0 +1,110 @@ +--- +{ + "title": "SET PROPERTY", + "language": "en" +} + +--- + + + + + + +## Description + +Set user attributes, including resources assigned to users, importing clusters, etc. + +```sql +SET PROPERTY [FOR 'user'] 'key' = 'value' [, 'key' = 'value'] +``` + +The user attribute set here is for user, not user_identity. That is, if two users 'jack'@'%' and 'jack'@'192.%' are created through the CREATE USER statement, the SET PROPERTY statement can only be used for the user jack, not 'jack'@'% ' or 'jack'@'192.%' + +key: + +Super user privileges: + + max_user_connections: The maximum number of connections. + + max_query_instances: The number of instances that a user can use to execute a query at the same time. + + sql_block_rules: Set sql block rules. Once set, queries sent by this user will be rejected if they match the rules. + + cpu_resource_limit: Limit the cpu resources for queries. See the introduction to the session variable `cpu_resource_limit` for details. -1 means not set. + + exec_mem_limit: Limit the memory usage of the query. See the introduction to the session variable `exec_mem_limit` for details. -1 means not set. + + resource_tags: Specifies the user's resource tag permissions. + + query_timeout: Specifies the user's query timeout permissions. + + Note: If the attributes `cpu_resource_limit`, `exec_mem_limit` are not set, the value in the session variable will be used by default. + +## Example + +1. Modify the maximum number of user jack connections to 1000 + + ```sql + SET PROPERTY FOR 'jack' 'max_user_connections' = '1000'; + ``` + +2. Modify the number of available instances for user jack's query to 3000 + + ```sql + SET PROPERTY FOR 'jack' 'max_query_instances' = '3000'; + ``` + +3. Modify the sql block rule of user jack + + ```sql + SET PROPERTY FOR 'jack' 'sql_block_rules' = 'rule1, rule2'; + ``` + +4. Modify the cpu usage limit of user jack + + ```sql + SET PROPERTY FOR 'jack' 'cpu_resource_limit' = '2'; + ``` + +5. Modify the user's resource tag permissions + + ```sql + SET PROPERTY FOR 'jack' 'resource_tags.location' = 'group_a, group_b'; + ``` + +6. Modify the user's query memory usage limit, in bytes + + ```sql + SET PROPERTY FOR 'jack' 'exec_mem_limit' = '2147483648'; + ``` + +7. Modify the user's query timeout limit, in second + + ```sql + SET PROPERTY FOR 'jack' 'query_timeout' = '500'; + ``` + +## Keywords + + SET, PROPERTY + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/account-management/SHOW-GRANTS.md b/docs/sql-manual/sql-statements/account-management/SHOW-GRANTS.md new file mode 100644 index 0000000000000..5ca77a5bca1c1 --- /dev/null +++ b/docs/sql-manual/sql-statements/account-management/SHOW-GRANTS.md @@ -0,0 +1,69 @@ +--- +{ + "title": "SHOW GRANTS", + "language": "en" +} +--- + + + + +## Description + + This statement is used to view user permissions. + +grammar: + +```sql +SHOW [ALL] GRANTS [FOR user_identity]; +``` + +illustrate: + +1. SHOW ALL GRANTS can view the permissions of all users. +2. If user_identity is specified, view the permissions of the specified user. And the user_identity must be created by the CREATE USER command. +3. If user_identity is not specified, view the permissions of the current user. + +## Example + +1. View all user permission information + + ```sql + SHOW ALL GRANTS; + ``` + +2. View the permissions of the specified user + + ```sql + SHOW GRANTS FOR jack@'%'; + ``` + +3. View the permissions of the current user + + ```sql + SHOW GRANTS; + ``` + +## Keywords + + SHOW, GRANTS + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/account-management/SHOW-PRIVILEGES.md b/docs/sql-manual/sql-statements/account-management/SHOW-PRIVILEGES.md new file mode 100644 index 0000000000000..c435f84b246de --- /dev/null +++ b/docs/sql-manual/sql-statements/account-management/SHOW-PRIVILEGES.md @@ -0,0 +1,52 @@ +--- +{ + "title": "SHOW PRIVILEGES", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to display all permission items. + +grammar: + +```SQL +SHOW PRIVILEGES +``` + +## Example + +1. display all permission items + + ```SQL + SHOW PRIVILEGES + ``` + +## Keywords + + SHOW, PRIVILEGES + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/account-management/SHOW-PROPERTY.md b/docs/sql-manual/sql-statements/account-management/SHOW-PROPERTY.md new file mode 100644 index 0000000000000..11fc76c582d64 --- /dev/null +++ b/docs/sql-manual/sql-statements/account-management/SHOW-PROPERTY.md @@ -0,0 +1,114 @@ +--- +{ + "title": "SHOW PROPERTY", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to view the attributes of the user + +``` +SHOW PROPERTY [FOR user] [LIKE key] +SHOW ALL PROPERTIES [LIKE key] +``` + +* `user` + + View the attributes of the specified user. If not specified, check the current user's. + +* `LIKE` + + Fuzzy matching can be done by attribute name. + +* `ALL` + + View the properties of all users (supported since version 2.0.3) + +Return result description: + +```sql +mysql> show property like'%connection%'; ++----------------------+-------+ +| Key | Value | ++----------------------+-------+ +| max_user_connections | 100 | ++----------------------+-------+ +1 row in set (0.01 sec) +``` + +* `Key` + + Property name. + +* `Value` + + Attribute value. + + +```sql +mysql> show all properties like "%connection%"; ++-------------------+--------------------------------------+ +| User | Properties | ++-------------------+--------------------------------------+ +| root | {"max_user_connections": "100"} | +| admin | {"max_user_connections": "100"} | +| default_cluster:a | {"max_user_connections": "1000"} | ++-------------------+--------------------------------------+ +``` + +* `User` + + username. + +* `Properties` + + Key: value corresponding to each property of the user. + +## Example + +1. View the attributes of the jack user + + ```sql + SHOW PROPERTY FOR'jack'; + ``` + +2. View the attribute of jack user connection limit + + ```sql + SHOW PROPERTY FOR'jack' LIKE'%connection%'; + ``` + +3. View all users importing cluster related properties + + ```sql + SHOW ALL PROPERTIES LIKE '%load_cluster%' + ``` + +## Keywords + + SHOW, PROPERTY, ALL + +## Best Practice diff --git a/docs/sql-manual/sql-statements/account-management/SHOW-ROLES.md b/docs/sql-manual/sql-statements/account-management/SHOW-ROLES.md new file mode 100644 index 0000000000000..9512de3e616cb --- /dev/null +++ b/docs/sql-manual/sql-statements/account-management/SHOW-ROLES.md @@ -0,0 +1,52 @@ +--- +{ + "title": "SHOW ROLES", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to display all created role information, including role name, included users and permissions. + +grammar: + +```sql +SHOW ROLES +``` + +## Example + +1. View created roles + + ```sql + SHOW ROLES + ``` + +## Keywords + + SHOW, ROLES + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/catalog/ALTER-CATALOG.md b/docs/sql-manual/sql-statements/catalog/ALTER-CATALOG.md new file mode 100644 index 0000000000000..e6435151dba29 --- /dev/null +++ b/docs/sql-manual/sql-statements/catalog/ALTER-CATALOG.md @@ -0,0 +1,96 @@ +--- +{ + "title": "ALTER CATALOG", + "language": "en" +} + +--- + + + + + + + +## Description + +This statement is used to set properties of the specified catalog. (administrator only) + +1) Rename the catalog + +```sql +ALTER CATALOG catalog_name RENAME new_catalog_name; +``` + +illustrate: + +- The builtin catalog `internal` cannot be renamed +- Only the one who has at least Alter privilege can rename a catalog +- After renaming the catalog, use the REVOKE and GRANT commands to modify the appropriate user permissions + +2) Modify / add properties for the catalog + +```sql +ALTER CATALOG catalog_name SET PROPERTIES ('key1' = 'value1' [, 'key' = 'value2']); +``` + +Update values of specified keys. If a key does not exist in the catalog properties, it will be added. + +illustrate: + +- property `type` cannot be modified. +- properties of builtin catalog `internal` cannot be modified. + +3) Modify comment for the catalog + +```sql +ALTER CATALOG catalog_name MODIFY COMMENT "new catalog comment"; +``` + +illustrate: + +- The builtin catalog `internal` cannot be modified + +## Example + +1. rename catalog ctlg_hive to hive + + ```sql + ALTER CATALOG ctlg_hive RENAME hive; + ``` + +3. modify property `hive.metastore.uris` of catalog hive + + ```sql + ALTER CATALOG hive SET PROPERTIES ('hive.metastore.uris'='thrift://172.21.0.1:9083'); + ``` + +4. modify comment of catalog hive + + ```sql + ALTER CATALOG hive MODIFY COMMENT "new catalog comment"; + ``` + +## Keywords + +ALTER,CATALOG,RENAME,PROPERTY + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/catalog/CREATE-CATALOG.md b/docs/sql-manual/sql-statements/catalog/CREATE-CATALOG.md new file mode 100644 index 0000000000000..7167606ecb70d --- /dev/null +++ b/docs/sql-manual/sql-statements/catalog/CREATE-CATALOG.md @@ -0,0 +1,170 @@ +--- +{ + "title": "CREATE CATALOG", + "language": "en" +} +--- + + + + +## Description + +This statement is used to create an external catalog + +Syntax: + +```sql +CREATE CATALOG [IF NOT EXISTS] catalog_name [comment] + PROPERTIES ("key"="value", ...); +``` + +## Example + +1. Create catalog hive + + ```sql + CREATE CATALOG hive comment 'hive catalog' PROPERTIES ( + 'type'='hms', + 'hive.metastore.uris' = 'thrift://127.0.0.1:7004', + 'dfs.nameservices'='HANN', + 'dfs.ha.namenodes.HANN'='nn1,nn2', + 'dfs.namenode.rpc-address.HANN.nn1'='nn1_host:rpc_port', + 'dfs.namenode.rpc-address.HANN.nn2'='nn2_host:rpc_port', + 'dfs.client.failover.proxy.provider.HANN'='org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider' + ); + ``` + +2. Create catalog es + + ```sql + CREATE CATALOG es PROPERTIES ( + "type"="es", + "hosts"="http://127.0.0.1:9200" + ); + ``` + +3. Create catalog jdbc + + **mysql** + + ```sql + CREATE CATALOG jdbc PROPERTIES ( + "type"="jdbc", + "user"="root", + "password"="123456", + "jdbc_url" = "jdbc:mysql://127.0.0.1:3316/doris_test?useSSL=false", + "driver_url" = "https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/jdbc_driver/mysql-connector-java-8.0.25.jar", + "driver_class" = "com.mysql.cj.jdbc.Driver" + ); + ``` + + **postgresql** + + ```sql + CREATE CATALOG jdbc PROPERTIES ( + "type"="jdbc", + "user"="postgres", + "password"="123456", + "jdbc_url" = "jdbc:postgresql://127.0.0.1:5432/demo", + "driver_url" = "file:///path/to/postgresql-42.5.1.jar", + "driver_class" = "org.postgresql.Driver" + ); + ``` + + **clickhouse** + + ```sql + CREATE CATALOG jdbc PROPERTIES ( + "type"="jdbc", + "user"="default", + "password"="123456", + "jdbc_url" = "jdbc:clickhouse://127.0.0.1:8123/demo", + "driver_url" = "file:///path/to/clickhouse-jdbc-0.3.2-patch11-all.jar", + "driver_class" = "com.clickhouse.jdbc.ClickHouseDriver" + ) + ``` + + **oracle** + ```sql + CREATE CATALOG jdbc PROPERTIES ( + "type"="jdbc", + "user"="doris", + "password"="123456", + "jdbc_url" = "jdbc:oracle:thin:@127.0.0.1:1521:helowin", + "driver_url" = "file:///path/to/ojdbc8.jar", + "driver_class" = "oracle.jdbc.driver.OracleDriver" + ); + ``` + + **SQLServer** + ```sql + CREATE CATALOG sqlserver_catalog PROPERTIES ( + "type"="jdbc", + "user"="SA", + "password"="Doris123456", + "jdbc_url" = "jdbc:sqlserver://localhost:1433;DataBaseName=doris_test", + "driver_url" = "file:///path/to/mssql-jdbc-11.2.3.jre8.jar", + "driver_class" = "com.microsoft.sqlserver.jdbc.SQLServerDriver" + ); + ``` + + **SAP HANA** + ```sql + CREATE CATALOG saphana_catalog PROPERTIES ( + "type"="jdbc", + "user"="SYSTEM", + "password"="SAPHANA", + "jdbc_url" = "jdbc:sap://localhost:31515/TEST", + "driver_url" = "file:///path/to/ngdbc.jar", + "driver_class" = "com.sap.db.jdbc.Driver" + ); + ``` + + **Trino** + ```sql + CREATE CATALOG trino_catalog PROPERTIES ( + "type"="jdbc", + "user"="hadoop", + "password"="", + "jdbc_url" = "jdbc:trino://localhost:8080/hive", + "driver_url" = "file:///path/to/trino-jdbc-389.jar", + "driver_class" = "io.trino.jdbc.TrinoDriver" + ); + ``` + + **OceanBase** + ```sql + CREATE CATALOG oceanbase_catalog PROPERTIES ( + "type"="jdbc", + "user"="root", + "password"="", + "jdbc_url" = "jdbc:oceanbase://localhost:2881/demo", + "driver_url" = "file:///path/to/oceanbase-client-2.4.2.jar", + "driver_class" = "com.oceanbase.jdbc.Driver" + ); + ``` + +## Keywords + +CREATE, CATALOG + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/catalog/DROP-CATALOG.md b/docs/sql-manual/sql-statements/catalog/DROP-CATALOG.md new file mode 100644 index 0000000000000..b9145354b889b --- /dev/null +++ b/docs/sql-manual/sql-statements/catalog/DROP-CATALOG.md @@ -0,0 +1,52 @@ +--- +{ + "title": "DROP CATALOG", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to delete the external catalog. + +Syntax: + +```sql +DROP CATALOG [I EXISTS] catalog_name; +``` + +## Example + +1. Drop catalog hive + + ```sql + DROP CATALOG hive; + ``` + +## Keywords + +DROP, CATALOG + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/catalog/REFRESH.md b/docs/sql-manual/sql-statements/catalog/REFRESH.md new file mode 100644 index 0000000000000..79e3e9d26c037 --- /dev/null +++ b/docs/sql-manual/sql-statements/catalog/REFRESH.md @@ -0,0 +1,73 @@ +--- +{ + "title": "REFRESH", + "language": "en" +} +--- + + + + + +## Description + +This statement refreshes the metadata of the specified Catalog/Database/Table. + +syntax: + +```sql +REFRESH CATALOG catalog_name; +REFRESH DATABASE [catalog_name.]database_name; +REFRESH TABLE [catalog_name.][database_name.]table_name; +``` + +When the Catalog is refreshed, the object-related Cache is forced to be invalidated. + +Including Partition Cache, Schema Cache, File Cache, etc. + +## Example + +1. Refresh hive catalog + + ```sql + REFRESH CATALOG hive; + ``` + +2. Refresh database1 + + ```sql + REFRESH DATABASE ctl.database1; + REFRESH DATABASE database1; + ``` + +3. Refresh table1 + + ```sql + REFRESH TABLE ctl.db.table1; + REFRESH TABLE db.table1; + REFRESH TABLE table1; + ``` + +## Keywords + +REFRESH, CATALOG, DATABASE, TABLE + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/catalog/SHOW-CATALOG.md b/docs/sql-manual/sql-statements/catalog/SHOW-CATALOG.md new file mode 100644 index 0000000000000..b252c074ef398 --- /dev/null +++ b/docs/sql-manual/sql-statements/catalog/SHOW-CATALOG.md @@ -0,0 +1,81 @@ +--- +{ + "title": "SHOW CATALOGS", + "language": "en" +} +--- + + + + + +## Description + +This statement is used for view created catalogs + +Syntax: + +```sql +SHOW CATALOGS [LIKE] +``` + +illustrate: + +1. LIKE: Fuzzy query can be performed according to the catalog name + + +Return result: + +* CatalogId: Unique ID of the catalog +* CatalogName: Catalog name. where "internal" is the default built-in catalog, which cannot be modified. +* Type: Catalog type. +* IsCurrent: Show yes on the line of current using catalog. + +## Example + +1. View the data catalogs that have been created currently + + ```sql + SHOW CATALOGS; + +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ + | CatalogId | CatalogName | Type | IsCurrent | CreateTime | LastUpdateTime | Comment | + +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ + | 130100 | hive | hms | | 2023-12-25 16:11:41.687 | 2023-12-25 20:43:18 | NULL | + | 0 | internal | internal | yes | UNRECORDED | NULL | Doris internal catalog | + +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ + ``` + +2. Fuzzy query by catalog name + + ```sql + SHOW CATALOGS LIKE 'hi%'; + +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ + | CatalogId | CatalogName | Type | IsCurrent | CreateTime | LastUpdateTime | Comment | + +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ + | 130100 | hive | hms | | 2023-12-25 16:11:41.687 | 2023-12-25 20:43:18 | NULL | + +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ + ``` + +## Keywords + +SHOW, CATALOG, CATALOGS + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/catalog/SHOW-CREATE-CATALOG.md b/docs/sql-manual/sql-statements/catalog/SHOW-CREATE-CATALOG.md new file mode 100644 index 0000000000000..8da2b8f6e7457 --- /dev/null +++ b/docs/sql-manual/sql-statements/catalog/SHOW-CREATE-CATALOG.md @@ -0,0 +1,58 @@ +--- +{ + "title": "SHOW CREATE CATALOG", + "language": "en" +} + +--- + + + + + + +## Description + +This statement shows the creating statement of a doris catalog. + +grammar: + +```sql +SHOW CREATE CATALOG catalog_name; +``` + +illustrate: + +- `catalog_name`: The name of the catalog which exist in doris. + +## Example + +1. View the creating statement of the hive catalog in doris + + ```sql + SHOW CREATE CATALOG hive; + ``` + +## Keywords + +SHOW, CREATE, CATALOG + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/character-set/SHOW-CHARSET.md b/docs/sql-manual/sql-statements/character-set/SHOW-CHARSET.md new file mode 100644 index 0000000000000..8268c0b8d3a5f --- /dev/null +++ b/docs/sql-manual/sql-statements/character-set/SHOW-CHARSET.md @@ -0,0 +1,59 @@ +--- +{ + "title": "SHOW CHARSET", + "language": "en" +} +--- + + + + + +## Description + +The "SHOW CHARACTER" command is used to display the available character sets in the current database management system, +along with some associated properties for each character set. These properties may include the name of the character set, +the default collation, and the maximum byte length, among others. By running the "SHOW CHARACTER" command, you can view the list of supported character sets in the system along with their detailed information. + +The "SHOW CHARACTER" command returns the following fields: + +Charset: Character set +Description: Description +Default Collation: Default collation name +Maxlen: Maximum byte length. + + +## Example + +```sql +mysql> show charset; + +| Charset | Description | Default collation | Maxlen | +|-----------|-----------------|-------------------|--------| +| utf8mb4 | UTF-8 Unicode | utf8mb4_0900_bin | 4 | + +``` + +## Keywords + +SHOW, CHARSET + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/character-set/SHOW-COLLATION.md b/docs/sql-manual/sql-statements/character-set/SHOW-COLLATION.md new file mode 100644 index 0000000000000..326950d2d5037 --- /dev/null +++ b/docs/sql-manual/sql-statements/character-set/SHOW-COLLATION.md @@ -0,0 +1,59 @@ +--- +{ + "title": "SHOW COLLATION", + "language": "en" +} +--- + + + + + +## Description + +In Doris, the `SHOW COLLATION` command is used to display the character set collations available in the database. A collation is a set of rules that determine how data is sorted and compared. These rules affect the storage and retrieval of character data. Doris currently mainly supports the proofreading method utf8_general_ci. + +The `SHOW COLLATION` command returns the following fields: + +* Collation: The collation name +* Charset: The character set +* Id: The collation's ID +* Default: Whether this is the default collation for the character set +* Compiled: Whether the collation is compiled +* Sortlen: Sort length + +## Example + +```sql +mysql> show collation; ++-----------------+---------+------+---------+----------+---------+ +| Collation | Charset | Id | Default | Compiled | Sortlen | ++-----------------+---------+------+---------+----------+---------+ +| utf8mb4_0900_bin | utf8mb4 | 33 | Yes | Yes | 1 | ++-----------------+---------+------+---------+----------+---------+ +``` + +## Keywords + +SHOW, COLLATION + +## Best Practice + +Use the `SHOW COLLATION` command to give you an idea of the collations available in the database and their properties. This information can help ensure that your character data is sorted and compared as expected. If you have problems comparing or sorting characters, it can be helpful to check your collation settings to make sure they are what you expect. diff --git a/docs/sql-manual/sql-statements/cluster-management/compute-management/ALTER-RESOURCE.md b/docs/sql-manual/sql-statements/cluster-management/compute-management/ALTER-RESOURCE.md new file mode 100644 index 0000000000000..5e8883e7116f8 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/compute-management/ALTER-RESOURCE.md @@ -0,0 +1,84 @@ +--- +{ +"title": "ALTER RESOURCE", +"language": "en" +} + +--- + + + + + + + + +## Description + +This statement is used to modify an existing resource. Only the root or admin user can modify resources. +Syntax: + +```sql +ALTER RESOURCE 'resource_name' +PROPERTIES ("key"="value", ...); +``` + +Note: The resource type does not support modification. + +## Example + +1. Modify the working directory of the Spark resource named spark0: + +```sql +ALTER RESOURCE 'spark0' PROPERTIES ("working_dir" = "hdfs://127.0.0.1:10000/tmp/doris_new"); +``` + +2. Modify the maximum number of connections to the S3 resource named remote_s3: + +```sql +ALTER RESOURCE 'remote_s3' PROPERTIES ("s3.connection.maximum" = "100"); +``` + +3. Modify information related to cold and hot separation S3 resources + +- Support + - `s3.access_key` s3 ak + - `s3.secret_key` s3 sk + - `s3.session_token` s3 token + - `s3.connection.maximum` default 50 + - `s3.connection.timeout` default 1000ms + - `s3.connection.request.timeout` default 3000ms +- Not Support + - `s3.region` + - `s3.bucket"` + - `s3.root.path` + - `s3.endpoint` + +```sql + ALTER RESOURCE "showPolicy_1_resource" PROPERTIES("s3.connection.maximum" = "1111"); +``` + +## Keywords + +```text +ALTER, RESOURCE +``` + +## Best Practice \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/cluster-management/compute-management/ALTER-WORKLOAD-GROUP.md b/docs/sql-manual/sql-statements/cluster-management/compute-management/ALTER-WORKLOAD-GROUP.md new file mode 100644 index 0000000000000..187eeef240ca4 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/compute-management/ALTER-WORKLOAD-GROUP.md @@ -0,0 +1,65 @@ +--- +{ +"title": "ALTER WORKLOAD GROUP", +"language": "en" +} +--- + + + + + +## Description + +This statement is used to modify the workload group. + +Syntax: + +```sql +ALTER WORKLOAD GROUP "rg_name" +PROPERTIES ( + property_list +); +``` + +NOTE: + +* Modify the memory_limit property in such a way that the sum of all memory_limit values does not exceed 100%; +* Support modifying some properties, for example, if only cpu_share is modified, just fill in cpu_share in properties. + +## Example + +1. Modify the workload group named g1: + + ```sql + alter workload group g1 + properties ( + "cpu_share"="30", + "memory_limit"="30%" + ); + ``` + +## Keywords + +```sql +ALTER, WORKLOAD, GROUP +``` + +## Best Practice diff --git a/docs/sql-manual/sql-statements/cluster-management/compute-management/ALTER-WORKLOAD-POLICY.md b/docs/sql-manual/sql-statements/cluster-management/compute-management/ALTER-WORKLOAD-POLICY.md new file mode 100644 index 0000000000000..d8947abdf7a00 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/compute-management/ALTER-WORKLOAD-POLICY.md @@ -0,0 +1,63 @@ +--- +{ +"title": "ALTER WORKLOAD POLICY", +"language": "en" +} +--- + + + + + +## Description + +Modify the properties of a Workload Group. Currently, only property modifications are supported; modifications to actions and conditions are not supported. + + +## Syntax + +```sql +ALTER WORKLOAD POLICY PROPERTIES( ) +``` + +## Required Parameters + +`` + +Workload Policy's Name + + +`` + +1. enabled: Can be true or false, with a default value of true, indicating that the current policy is enabled. false indicates that the current policy is disabled. +2. priority: A positive integer ranging from 0 to 100, with a default value of 0. This represents the priority of the policy. The higher the value, the higher the priority. The main role of this property is to select the policy with the highest priority when multiple policies match. +3. workload_group: Currently, a policy can be bound to one workload group, which means that this policy is only effective for a specific workload group. The default is empty, which means it is effective for all queries. + +## Access Control Requirements + +You must have at least ADMIN_PRIV permissions. + +## Examples + +1. Disable a Workload Policy + + ```Java + alter workload policy cancel_big_query properties('enabled'='false') + ``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/cluster-management/compute-management/CREATE-RESOURCE.md b/docs/sql-manual/sql-statements/cluster-management/compute-management/CREATE-RESOURCE.md new file mode 100644 index 0000000000000..a5de9bbc69268 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/compute-management/CREATE-RESOURCE.md @@ -0,0 +1,246 @@ +--- +{ + "title": "CREATE RESOURCE", + "language": "en" +} +--- + + + + + + + +## Description + +This statement is used to create a resource. Only the root or admin user can create resources. Currently supports Spark, ODBC, S3 external resources. +In the future, other external resources may be added to Doris for use, such as Spark/GPU for query, HDFS/S3 for external storage, MapReduce for ETL, etc. + +grammar: + +```sql +CREATE [EXTERNAL] RESOURCE "resource_name" +PROPERTIES ("key"="value", ...); +``` + +illustrate: + +- The type of resource needs to be specified in PROPERTIES "type" = "[spark|odbc_catalog|s3]", currently supports spark, odbc_catalog, s3. +- PROPERTIES differs depending on the resource type, see the example for details. + +## Example + +1. Create a Spark resource named spark0 in yarn cluster mode. + + ```sql + CREATE EXTERNAL RESOURCE "spark0" + PROPERTIES + ( + "type" = "spark", + "spark.master" = "yarn", + "spark.submit.deployMode" = "cluster", + "spark.jars" = "xxx.jar,yyy.jar", + "spark.files" = "/tmp/aaa,/tmp/bbb", + "spark.executor.memory" = "1g", + "spark.yarn.queue" = "queue0", + "spark.hadoop.yarn.resourcemanager.address" = "127.0.0.1:9999", + "spark.hadoop.fs.defaultFS" = "hdfs://127.0.0.1:10000", + "working_dir" = "hdfs://127.0.0.1:10000/tmp/doris", + "broker" = "broker0", + "broker.username" = "user0", + "broker.password" = "password0" + ); + ``` + + Spark related parameters are as follows: + - spark.master: Required, currently supports yarn, spark://host:port. + - spark.submit.deployMode: The deployment mode of the Spark program, required, supports both cluster and client. + - spark.hadoop.yarn.resourcemanager.address: Required when master is yarn. + - spark.hadoop.fs.defaultFS: Required when master is yarn. + - Other parameters are optional, refer to [here](http://spark.apache.org/docs/latest/configuration.html) + + + + Working_dir and broker need to be specified when Spark is used for ETL. described as follows: + + - working_dir: The directory used by the ETL. Required when spark is used as an ETL resource. For example: hdfs://host:port/tmp/doris. + - broker: broker name. Required when spark is used as an ETL resource. Configuration needs to be done in advance using the `ALTER SYSTEM ADD BROKER` command. + - broker.property_key: The authentication information that the broker needs to specify when reading the intermediate file generated by ETL. + +2. Create an ODBC resource + + ```sql + CREATE EXTERNAL RESOURCE `oracle_odbc` + PROPERTIES ( + "type" = "odbc_catalog", + "host" = "192.168.0.1", + "port" = "8086", + "user" = "test", + "password" = "test", + "database" = "test", + "odbc_type" = "oracle", + "driver" = "Oracle 19 ODBC driver" + ); + ``` + + The relevant parameters of ODBC are as follows: + - hosts: IP address of the external database + - driver: The driver name of the ODBC appearance, which must be the same as the Driver name in be/conf/odbcinst.ini. + - odbc_type: the type of the external database, currently supports oracle, mysql, postgresql + - user: username of the foreign database + - password: the password information of the corresponding user + - charset: connection charset + - There is also support for implementing custom parameters per ODBC Driver, see the description of the corresponding ODBC Driver + +3. Create S3 resource + + ```sql + CREATE RESOURCE "remote_s3" + PROPERTIES + ( + "type" = "s3", + "s3.endpoint" = "bj.s3.com", + "s3.region" = "bj", + "s3.access_key" = "bbb", + "s3.secret_key" = "aaaa", + -- the followings are optional + "s3.connection.maximum" = "50", + "s3.connection.request.timeout" = "3000", + "s3.connection.timeout" = "1000" + ); + ``` + + If S3 resource is used for [cold hot separation](../../../../../docs/advanced/cold_hot_separation.md), we should add more required fields. + ```sql + CREATE RESOURCE "remote_s3" + PROPERTIES + ( + "type" = "s3", + "s3.endpoint" = "bj.s3.com", + "s3.region" = "bj", + "s3.access_key" = "bbb", + "s3.secret_key" = "aaaa", + -- required by cooldown + "s3.root.path" = "/path/to/root", + "s3.bucket" = "test-bucket" + ); + ``` + + S3 related parameters are as follows: + - Required parameters + - `s3.endpoint`: s3 endpoint + - `s3.region`:s3 region + - `s3.root.path`: s3 root directory + - `s3.access_key`: s3 access key + - `s3.secret_key`: s3 secret key + - `s3.bucket`:s3 bucket + - optional parameter + - `s3.connection.maximum`: the maximum number of s3 connections, the default is 50 + - `s3.connection.request.timeout`: s3 request timeout, in milliseconds, the default is 3000 + - `s3.connection.timeout`: s3 connection timeout, in milliseconds, the default is 1000 + +4. Create JDBC resource + + ```sql + CREATE RESOURCE mysql_resource PROPERTIES ( + "type"="jdbc", + "user"="root", + "password"="123456", + "jdbc_url" = "jdbc:mysql://127.0.0.1:3316/doris_test?useSSL=false", + "driver_url" = "https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/jdbc_driver/mysql-connector-java-8.0.25.jar", + "driver_class" = "com.mysql.cj.jdbc.Driver" + ); + ``` + + JDBC related parameters are as follows: + - user:The username used to connect to the database + - password:The password used to connect to the database + - jdbc_url: The identifier used to connect to the specified database + - driver_url: The url of JDBC driver package + - driver_class: The class of JDBC driver + +5. Create HDFS resource + + ```sql + CREATE RESOURCE hdfs_resource PROPERTIES ( + "type"="hdfs", + "hadoop.username"="user", + "dfs.nameservices" = "my_ha", + "dfs.ha.namenodes.my_ha" = "my_namenode1, my_namenode2", + "dfs.namenode.rpc-address.my_ha.my_namenode1" = "nn1_host:rpc_port", + "dfs.namenode.rpc-address.my_ha.my_namenode2" = "nn2_host:rpc_port", + "dfs.client.failover.proxy.provider.my_ha" = "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider" + ); + ``` + + HDFS related parameters are as follows: + - fs.defaultFS: namenode address and port + - hadoop.username: hdfs username + - dfs.nameservices: if hadoop enable HA, please set fs nameservice. See hdfs-site.xml + - dfs.ha.namenodes.[nameservice ID]:unique identifiers for each NameNode in the nameservice. See hdfs-site.xml + - dfs.namenode.rpc-address.[nameservice ID].[name node ID]`:the fully-qualified RPC address for each NameNode to listen on. See hdfs-site.xml + - dfs.client.failover.proxy.provider.[nameservice ID]:the Java class that HDFS clients use to contact the Active NameNode, usually it is org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider + +6. Create HMS resource + + HMS resource is used to create [hms catalog](../../../../lakehouse/multi-catalog/multi-catalog.md) + ```sql + CREATE RESOURCE hms_resource PROPERTIES ( + 'type'='hms', + 'hive.metastore.uris' = 'thrift://127.0.0.1:7004', + 'dfs.nameservices'='HANN', + 'dfs.ha.namenodes.HANN'='nn1,nn2', + 'dfs.namenode.rpc-address.HANN.nn1'='nn1_host:rpc_port', + 'dfs.namenode.rpc-address.HANN.nn2'='nn2_host:rpc_port', + 'dfs.client.failover.proxy.provider.HANN'='org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider' + ); + ``` + + HMS related parameters are as follows: + - hive.metastore.uris: hive metastore server address + Optional: + - dfs.*: If hive data is on hdfs, HDFS resource parameters should be added, or copy hive-site.xml into fe/conf. + - s3.*: If hive data is on s3, S3 resource parameters should be added. If using [Aliyun Data Lake Formation](https://www.aliyun.com/product/bigdata/dlf), copy hive-site.xml into fe/conf. + +7. Create ES resource + + ```sql + CREATE RESOURCE es_resource PROPERTIES ( + "type"="es", + "hosts"="http://127.0.0.1:29200", + "nodes_discovery"="false", + "enable_keyword_sniff"="true" + ); + ``` + + ES related parameters are as follows: + - hosts: ES Connection Address, maybe one or more node, load-balance is also accepted + - user: username for ES + - password: password for the user + - enable_docvalue_scan: whether to enable ES/Lucene column storage to get the value of the query field, the default is true + - enable_keyword_sniff: Whether to probe the string segmentation type text.fields in ES, query by keyword (the default is true, false matches the content after the segmentation) + - nodes_discovery: Whether or not to enable ES node discovery, the default is true. In network isolation, set this parameter to false. Only the specified node is connected + - http_ssl_enabled: Whether ES cluster enables https access mode, the current FE/BE implementation is to trust all + +## Keywords + + CREATE, RESOURCE + +## Best Practice diff --git a/docs/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-GROUP.md b/docs/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-GROUP.md new file mode 100644 index 0000000000000..1e42f36873425 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-GROUP.md @@ -0,0 +1,73 @@ +--- +{ + "title": "CREATE WORKLOAD GROUP", + "language": "en" +} +--- + + + + + + + + +## Description + +This statement is used to create a workload group. Workload groups enable the isolation of cpu resources and memory resources on a single be. + +grammar: + +```sql +CREATE WORKLOAD GROUP [IF NOT EXISTS] "rg_name" +PROPERTIES ( + property_list +); +``` + +illustrate: + +Properties supported by property_list: + +* cpu_share: Required, used to set how much cpu time the workload group can acquire, which can achieve soft isolation of cpu resources. cpu_share is a relative value indicating the weight of cpu resources available to the running workload group. For example, if a user creates 3 workload groups rg-a, rg-b and rg-c with cpu_share of 10, 30 and 40 respectively, and at a certain moment rg-a and rg-b are running tasks while rg-c has no tasks, then rg-a can get (10 / (10 + 30)) = 25% of the cpu resources while workload group rg-b can get 75% of the cpu resources. If the system has only one workload group running, it gets all the cpu resources regardless of the value of its cpu_share. + +* memory_limit: Required, set the percentage of be memory that can be used by the workload group. The absolute value of the workload group memory limit is: `physical_memory * mem_limit * memory_limit`, where mem_limit is a be configuration item. The total memory_limit of all workload groups in the system must not exceed 100%. Workload groups are guaranteed to use the memory_limit for the tasks in the group in most cases. When the workload group memory usage exceeds this limit, tasks in the group with larger memory usage may be canceled to release the excess memory, refer to enable_memory_overcommit. + +* enable_memory_overcommit: Optional, enable soft memory isolation for the workload group, default is false. if set to false, the workload group is hard memory isolated and the tasks with the largest memory usage will be canceled immediately after the workload group memory usage exceeds the limit to release the excess memory. if set to true, the workload group is hard memory isolated and the tasks with the largest memory usage will be canceled immediately after the workload group memory usage exceeds the limit to release the excess memory. if set to true, the workload group is softly isolated, if the system has free memory resources, the workload group can continue to use system memory after exceeding the memory_limit limit, and when the total system memory is tight, it will cancel several tasks in the group with the largest memory occupation, releasing part of the excess memory to relieve the system memory pressure. It is recommended that when this configuration is enabled for a workload group, the total memory_limit of all workload groups should be less than 100%, and the remaining portion should be used for workload group memory overcommit. + +## Example + +1. Create a workload group named g1: + + ```sql + create workload group if not exists g1 + properties ( + "cpu_share"="10", + "memory_limit"="30%", + "enable_memory_overcommit"="true" + ); + ``` + +## Keywords + + CREATE, WORKLOAD, GROUP + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md b/docs/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md new file mode 100644 index 0000000000000..f0081bbd3ca03 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md @@ -0,0 +1,69 @@ +--- +{ +"title": "CREATE WORKLOAD GROUP", +"language": "en" +} +--- + + + + +## Description + +This statement is used to create a workload group. Workload groups enable the isolation of cpu resources and memory resources on a single be. + +grammar: + +```sql +CREATE WORKLOAD GROUP [IF NOT EXISTS] "rg_name" +PROPERTIES ( + property_list +); +``` + +illustrate: + +Properties supported by property_list: + +* cpu_share: Required, used to set how much cpu time the workload group can acquire, which can achieve soft isolation of cpu resources. cpu_share is a relative value indicating the weight of cpu resources available to the running workload group. For example, if a user creates 3 workload groups rg-a, rg-b and rg-c with cpu_share of 10, 30 and 40 respectively, and at a certain moment rg-a and rg-b are running tasks while rg-c has no tasks, then rg-a can get (10 / (10 + 30)) = 25% of the cpu resources while workload group rg-b can get 75% of the cpu resources. If the system has only one workload group running, it gets all the cpu resources regardless of the value of its cpu_share. + +* memory_limit: Required, set the percentage of be memory that can be used by the workload group. The absolute value of the workload group memory limit is: `physical_memory * mem_limit * memory_limit`, where mem_limit is a be configuration item. The total memory_limit of all workload groups in the system must not exceed 100%. Workload groups are guaranteed to use the memory_limit for the tasks in the group in most cases. When the workload group memory usage exceeds this limit, tasks in the group with larger memory usage may be canceled to release the excess memory, refer to enable_memory_overcommit. + +* enable_memory_overcommit: Optional, enable soft memory isolation for the workload group, default is false. if set to false, the workload group is hard memory isolated and the tasks with the largest memory usage will be canceled immediately after the workload group memory usage exceeds the limit to release the excess memory. if set to true, the workload group is hard memory isolated and the tasks with the largest memory usage will be canceled immediately after the workload group memory usage exceeds the limit to release the excess memory. if set to true, the workload group is softly isolated, if the system has free memory resources, the workload group can continue to use system memory after exceeding the memory_limit limit, and when the total system memory is tight, it will cancel several tasks in the group with the largest memory occupation, releasing part of the excess memory to relieve the system memory pressure. It is recommended that when this configuration is enabled for a workload group, the total memory_limit of all workload groups should be less than 100%, and the remaining portion should be used for workload group memory overcommit. + +## Example + +1. Create a workload group named g1: + + ```sql + create workload group if not exists g1 + properties ( + "cpu_share"="10", + "memory_limit"="30%", + "enable_memory_overcommit"="true" + ); + ``` + +## Keywords + +CREATE, WORKLOAD, GROUP + + + diff --git a/docs/sql-manual/sql-statements/cluster-management/compute-management/DROP-RESOURCE.md b/docs/sql-manual/sql-statements/cluster-management/compute-management/DROP-RESOURCE.md new file mode 100644 index 0000000000000..93ff11b272179 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/compute-management/DROP-RESOURCE.md @@ -0,0 +1,51 @@ +--- +{ + "title": "DROP RESOURCE", + "language": "en" +} +--- + + + + +## Description + +This statement is used to delete an existing resource. Only the root or admin user can delete resources. +grammar: + +```sql +DROP RESOURCE 'resource_name' +``` + +Note: ODBC/S3 resources in use cannot be deleted. + +## Example + +1. Delete the Spark resource named spark0: + + ```sql + DROP RESOURCE 'spark0'; + ``` + +## Keywords + + DROP, RESOURCE + +## Best Practice diff --git a/docs/sql-manual/sql-statements/cluster-management/compute-management/DROP-WORKLOAD-GROUP.md b/docs/sql-manual/sql-statements/cluster-management/compute-management/DROP-WORKLOAD-GROUP.md new file mode 100644 index 0000000000000..c94e872a1b10a --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/compute-management/DROP-WORKLOAD-GROUP.md @@ -0,0 +1,51 @@ +--- +{ + "title": "DROP WORKLOAD GROUP", + "language": "en" +} +--- + + + + + + +## Description + +This statement is used to delete a workload group. + +```sql +DROP WORKLOAD GROUP [IF EXISTS] 'rg_name' +``` + +## Example + +1. Delete the workload group named g1: + + ```sql + drop workload group if exists g1; + ``` + +## Keywords + + DROP, WORKLOAD, GROUP + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/cluster-management/compute-management/DROP-WORKLOAD-POLICY.md b/docs/sql-manual/sql-statements/cluster-management/compute-management/DROP-WORKLOAD-POLICY.md new file mode 100644 index 0000000000000..262f775449e06 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/compute-management/DROP-WORKLOAD-POLICY.md @@ -0,0 +1,54 @@ +--- +{ +"title": "DROP WORKLOAD POLICY", +"language": "en" +} +--- + + + + + +## Description + +Delete a Workload Policy + +## Syntax + +```sql +DROP WORKLOAD POLICY [ IF EXISTS ] +``` +## Required Parameters + +**** + +The name of the Workload Policy + +## Access Control Requirements + +Must have at least `ADMIN_PRIV` permissions + +## Examples + +1. Delete a Workload Policy named cancel_big_query + + ```sql + drop workload policy if exists cancel_big_query + ``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/cluster-management/compute-management/SHOW-COMPUTE-GROUPS.md b/docs/sql-manual/sql-statements/cluster-management/compute-management/SHOW-COMPUTE-GROUPS.md new file mode 100644 index 0000000000000..b5a3c6bc2be28 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/compute-management/SHOW-COMPUTE-GROUPS.md @@ -0,0 +1,58 @@ +--- +{ + "title": "SHOW COMPUTE GROUPS", + "language": "en" +} +--- + + + +## Description + +The SHOW COMPUTE GROUPS command is used to display information about all configured compute groups in the system. Compute groups are logical units used to manage and organize computational resources, helping users allocate and utilize system resources more effectively. + +This command assists administrators and users in quickly understanding the existing compute group configurations in the system, including the name, attributes, and other relevant information for each compute group. This is particularly useful for resource management, performance optimization, and system monitoring. + +## Syntax + +```sql +SHOW COMPUTE GROUPS +``` + + +## Return Values + +This command returns a result set containing the following columns: + +- `Name`: The name of the compute group. +- `IsCurrent`: Indicates whether it is the current working compute group. +- `Users`: Displays the list of users who have permission to use this compute group. +- `BackendNum`: Shows the number of backends (compute nodes) currently allocated to this compute group. + +## Related Commands + +- [ALTER SYSTEM ADD BACKEND](../Administration-Statements/ALTER-SYSTEM-ADD-BACKEND.md) +- [GRANT](../account-management/GRANT-TO.md) +- [REVOKE](../account-management/REVOKE-FROM.md) +- [SET DEFAULT COMPUTE GROUP](../Administration-Statements/SET-DEFAULT-COMPUTE-GROUP.md) + +## Keywords + +SHOW, COMPUTE GROUPS diff --git a/docs/sql-manual/sql-statements/cluster-management/compute-management/SHOW-RESOURCES.md b/docs/sql-manual/sql-statements/cluster-management/compute-management/SHOW-RESOURCES.md new file mode 100644 index 0000000000000..4684c8ecd165f --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/compute-management/SHOW-RESOURCES.md @@ -0,0 +1,89 @@ +--- +{ + "title": "SHOW RESOURCES", + "language": "en" +} +--- + + + + + + + +## Description + +This statement is used to display resources that the user has permission to use. Ordinary users can only display resources with permission, and root or admin users will display all resources. + +grammar: + +```sql +SHOW RESOURCES +[ + WHERE + [NAME [ = "your_resource_name" | LIKE "name_matcher"]] + [RESOURCETYPE = ["SPARK"]] +] | [LIKE "pattern"] +[ORDER BY...] +[LIMIT limit][OFFSET offset]; +``` + +illustrate: + +1. If NAME LIKE is used, it will match Resource whose Name contains name_matcher in RESOURCES +2. If NAME = is used, it will match the specified Name exactly +3. If RESOURCETYPE is specified, match the corresponding Resrouce type +4. You can use ORDER BY to sort on any combination of columns +5. If LIMIT is specified, limit matching records are displayed. Otherwise show all +6. If OFFSET is specified, the query results are displayed starting at offset offset. By default the offset is 0. +7. If using LIKE, the WHERE clause will be ignored. + +## Example + +1. Display all resources that the current user has permissions to + + ```sql + SHOW RESOURCES; + ``` + +2. Display the specified Resource, the name contains the string "20140102", and display 10 attributes + + ```sql + SHOW RESOURCES WHERE NAME LIKE "2014_01_02" LIMIT 10; + ``` + +3. Display the specified Resource, specify the name as "20140102" and sort by KEY in descending order + + ```sql + SHOW RESOURCES WHERE NAME = "20140102" ORDER BY `KEY` DESC; + ``` + +3. Using LIKE to match the resource + + ```sql + SHOW RESOURCES LIKE "jdbc%"; + ``` + +## Keywords + + SHOW, RESOURCES + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/cluster-management/compute-management/SHOW-WORKLOAD-GROUPS.md b/docs/sql-manual/sql-statements/cluster-management/compute-management/SHOW-WORKLOAD-GROUPS.md new file mode 100644 index 0000000000000..864987ac3bb76 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/compute-management/SHOW-WORKLOAD-GROUPS.md @@ -0,0 +1,78 @@ +--- +{ + "title": "SHOW WORKLOAD GROUPS", + "language": "en" +} +--- + + + + + + +## Description + +This statement is used to display the resource groups for which the current user has usage_priv privileges. + +grammar: + +```sql +SHOW WORKLOAD GROUPS [LIKE "pattern"]; +``` + +Description: + +This statement only does a simple display of workload groups, for a more complex display refer to tvf workload_groups(). + +## Example + +1. Show all workload groups: + + ```sql + mysql> show workload groups; + +----------+--------+--------------------------+---------+ + | Id | Name | Item | Value | + +----------+--------+--------------------------+---------+ + | 10343386 | normal | cpu_share | 10 | + | 10343386 | normal | memory_limit | 30% | + | 10343386 | normal | enable_memory_overcommit | true | + | 10352416 | g1 | memory_limit | 20% | + | 10352416 | g1 | cpu_share | 10 | + +----------+--------+--------------------------+---------+ + ``` + +2. Show workload groups using pattern + + ```sql + mysql> show workload groups like "normal%"; + +----------+--------+--------------------------+---------+ + | Id | Name | Item | Value | + +----------+--------+--------------------------+---------+ + | 10343386 | normal | cpu_share | 10 | + | 10343386 | normal | memory_limit | 30% | + | 10343386 | normal | enable_memory_overcommit | true | + +----------+--------+--------------------------+---------+ + ``` + +## Keywords + + SHOW, WORKLOAD, GROUPS, GROUP + +## Best Practice diff --git a/docs/sql-manual/sql-statements/cluster-management/instance-management/ADD-BACKEND.md b/docs/sql-manual/sql-statements/cluster-management/instance-management/ADD-BACKEND.md new file mode 100644 index 0000000000000..2e1817099b790 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/instance-management/ADD-BACKEND.md @@ -0,0 +1,72 @@ +--- +{ + "title": "ADD BACKEND", + "language": "en" +} +--- + + + +## Description + +The ADD BACKEND command is used to add one or more backend nodes to a Doris OLAP database cluster. This command allows administrators to specify the host and port of the new backend nodes, along with optional properties that configure their behavior. + +grammar: + +```sql +-- Add nodes (add this method if you do not use the multi-tenancy function) + ALTER SYSTEM ADD BACKEND "host:heartbeat_port"[,"host:heartbeat_port"...] [PROPERTIES ("key"="value", ...)]; +``` + +### Parameters + +* `host` can be a hostname or an ip address of the backend node while `heartbeat_port` is the heartbeat port of the node +* `PROPERTIES ("key"="value", ...)`: (Optional) A set of key-value pairs that define additional properties for the backend nodes. These properties can be used to customize the configuration of the backends being added. Available properties include: + + * tag.location: Specifies the resource group where the backend node belongs. For example, PROPERTIES ("tag.location" = "groupb"). + +## Example + + 1. Adding Backends Without Additional Properties + + ```sql + ALTER SYSTEM ADD BACKEND "host1:9020,host2:9020"; + ```` + + This command adds two backend nodes to the cluster: + + * host1 with port 9020 + * host2 with port 9020 + + No additional properties are specified, so the default settings will apply to these backends. + +2. Adding Backends With Resource Group + + ```sql + ALTER SYSTEM ADD BACKEND "host3:9020" PROPERTIES ("tag.location" = "groupb"); + ``` + + This command adds a single backend node (host3 with port 9020) to the cluster in resource group `groupb`: + +## Keywords + +ALTER, SYSTEM, ADD, BACKEND, PROPERTIES + +## Best Practice \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/cluster-management/instance-management/ADD-BROKER.md b/docs/sql-manual/sql-statements/cluster-management/instance-management/ADD-BROKER.md new file mode 100644 index 0000000000000..89fb1703e9323 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/instance-management/ADD-BROKER.md @@ -0,0 +1,60 @@ +--- +{ + "title": "ADD BROKER", + "language": "en" +} + +--- + + + + + + + +## Description + +This statement is used to add a BROKER node. (Administrator only!) + +grammar: + +```sql +ALTER SYSTEM ADD BROKER broker_name "broker_host1:broker_ipc_port1","broker_host2:broker_ipc_port2",...; +``` + +## Example + +1. Add two brokers + + ```sql + ALTER SYSTEM ADD BROKER "host1:port", "host2:port"; + ``` +2. When fe enable fqdn([fqdn](../../../admin-manual/cluster-management/fqdn.md)),add one Broker + + ```sql + ALTER SYSTEM ADD BROKER "broker_fqdn1:port"; + ``` + +## Keywords + + ALTER, SYSTEM, ADD, FOLLOWER, ALTER SYSTEM + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/cluster-management/instance-management/ADD-FOLLOWER.md b/docs/sql-manual/sql-statements/cluster-management/instance-management/ADD-FOLLOWER.md new file mode 100644 index 0000000000000..2a010cdb9229b --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/instance-management/ADD-FOLLOWER.md @@ -0,0 +1,59 @@ +--- +{ + "title": "ADD FOLLOWER", + "language": "en" +} +--- + + + + + + + +## Description + +This statement is to increase the node of the FOLLOWER role of FRONTEND, (only for administrators!) + +grammar: + +```sql +ALTER SYSTEM ADD FOLLOWER "follower_host:edit_log_port" +``` + +illustrate: + +1. host can be a hostname or an ip address +2. edit_log_port : edit_log_port in its configuration file fe.conf + +## Example + +1. Add a FOLLOWER node + + ```sql + ALTER SYSTEM ADD FOLLOWER "host_ip:9010" + ``` + +## Keywords + + ALTER, SYSTEM, ADD, FOLLOWER, ALTER SYSTEM + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/cluster-management/instance-management/ADD-OBSERVER.md b/docs/sql-manual/sql-statements/cluster-management/instance-management/ADD-OBSERVER.md new file mode 100644 index 0000000000000..dac588cdcc223 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/instance-management/ADD-OBSERVER.md @@ -0,0 +1,59 @@ +--- +{ + "title": "ADD OBSERVER", + "language": "en" +} +--- + + + + + + + +## Description + +This statement is to increase the node of the OBSERVER role of FRONTEND, (only for administrators!) + +grammar: + +```sql +ALTER SYSTEM ADD OBSERVER "follower_host:edit_log_port" +``` + +illustrate: + +1. host can be a hostname or an ip address +2. edit_log_port : edit_log_port in its configuration file fe.conf + +## Example + +1. Add an OBSERVER node + + ```sql + ALTER SYSTEM ADD OBSERVER "host_ip:9010" + ``` + +## Keywords + + ALTER, SYSTEM, ADD, OBSERVER, ALTER SYSTEM + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/cluster-management/instance-management/CANCEL-DECOMMISSION-BACKEND.md b/docs/sql-manual/sql-statements/cluster-management/instance-management/CANCEL-DECOMMISSION-BACKEND.md new file mode 100644 index 0000000000000..1119d733e69ce --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/instance-management/CANCEL-DECOMMISSION-BACKEND.md @@ -0,0 +1,68 @@ +--- +{ + "title": "CANCEL DECOMMISSION BACKEND", + "language": "en" +} +--- + + + + + + + +## Description + +This statement is used to undo a node offline operation. (Administrator only!) + +grammar: + +- Find backend through host and port + +```sql +CANCEL DECOMMISSION BACKEND "host:heartbeat_port"[,"host:heartbeat_port"...]; +``` + +- Find backend through backend_id + +```sql +CANCEL DECOMMISSION BACKEND "id1","id2","id3..."; +``` + +## Example + + 1. Cancel the offline operation of both nodes: + + ```sql + CANCEL DECOMMISSION BACKEND "host1:port", "host2:port"; + ``` + + 2. Cancel the offline operation of the node with backend_id 1: + + ```sql + CANCEL DECOMMISSION BACKEND "1","2"; + ``` + +## Keywords + + CANCEL, DECOMMISSION, CANCEL ALTER + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/cluster-management/instance-management/DECOMMISSION-BACKEND.md b/docs/sql-manual/sql-statements/cluster-management/instance-management/DECOMMISSION-BACKEND.md new file mode 100644 index 0000000000000..e10faca2552fb --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/instance-management/DECOMMISSION-BACKEND.md @@ -0,0 +1,73 @@ +--- +{ + "title": "DECOMMISSION BACKEND", + "language": "en" +} +--- + + + + + + + +## Description + +The node offline operation is used to safely log off the node. The operation is asynchronous. If successful, the node is eventually removed from the metadata. If it fails, the logout will not be done (only for admins!) + +grammar: + +- Find backend through host and port + +```sql +ALTER SYSTEM DECOMMISSION BACKEND "host:heartbeat_port"[,"host:heartbeat_port"...]; +``` + +- Find backend through backend_id + +```sql +ALTER SYSTEM DECOMMISSION BACKEND "id1","id2"...; +``` + + illustrate: + +1. host can be a hostname or an ip address +2. heartbeat_port is the heartbeat port of the node +3. The node offline operation is used to safely log off the node. The operation is asynchronous. If successful, the node is eventually removed from the metadata. If it fails, the logout will not be completed. +4. You can manually cancel the node offline operation. See CANCEL DECOMMISSION + +## Example + +1. Offline two nodes + + ```sql + ALTER SYSTEM DECOMMISSION BACKEND "host1:port", "host2:port"; + ``` + + ```sql + ALTER SYSTEM DECOMMISSION BACKEND "id1", "id2"; + ``` + +## Keywords + + ALTER, SYSTEM, DECOMMISSION, BACKEND, ALTER SYSTEM + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/cluster-management/instance-management/DROP-BACKEND.md b/docs/sql-manual/sql-statements/cluster-management/instance-management/DROP-BACKEND.md new file mode 100644 index 0000000000000..f85add2c4b273 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/instance-management/DROP-BACKEND.md @@ -0,0 +1,70 @@ +--- +{ + "title": "DROP BACKEND", + "language": "en" +} +--- + + + + + + +## Description + +This statement is used to delete the BACKEND node (administrator only!) + +grammar: + +- Find backend through host and port + +```sql +ALTER SYSTEM DROP BACKEND "host:heartbeat_port"[,"host:heartbeat_port"...] +``` +- Find backend through backend_id + +```sql +ALTER SYSTEM DROP BACKEND "id1","id2"...; +``` + +illustrate: + +1. host can be a hostname or an ip address +2. heartbeat_port is the heartbeat port of the node +3. Adding and deleting nodes is a synchronous operation. These two operations do not consider the existing data on the node, and the node is directly deleted from the metadata, please use it with caution. + +## Example + +1. Delete two nodes + + ```sql + ALTER SYSTEM DROP BACKEND "host1:port", "host2:port"; + ``` + + ```sql + ALTER SYSTEM DROP BACKEND "ids1", "ids2"; + ``` + +## Keywords + + ALTER, SYSTEM, DROP, BACKEND, ALTER SYSTEM + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/cluster-management/instance-management/DROP-BROKER.md b/docs/sql-manual/sql-statements/cluster-management/instance-management/DROP-BROKER.md new file mode 100644 index 0000000000000..a331ac571d7e4 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/instance-management/DROP-BROKER.md @@ -0,0 +1,63 @@ +--- +{ + "title": "DROP BROKER", + "language": "en" +} + +--- + + + + + + +## Description + +This statement is to delete the BROKER node, (administrator only) + +grammar: + +```sql +-- Delete all brokers +ALTER SYSTEM DROP ALL BROKER broker_name +-- Delete a Broker node +ALTER SYSTEM DROP BROKER broker_name "host:port"[,"host:port"...]; +``` + +## Example + +1. Delete all brokers + + ```sql + ALTER SYSTEM DROP ALL BROKER broker_name + ``` + +2. Delete a Broker node + + ```sql + ALTER SYSTEM DROP BROKER broker_name "host:port"[,"host:port"...]; + ``` + +## Keywords + + ALTER, SYSTEM, DROP, FOLLOWER, ALTER SYSTEM + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/cluster-management/instance-management/DROP-FOLLOWER.md b/docs/sql-manual/sql-statements/cluster-management/instance-management/DROP-FOLLOWER.md new file mode 100644 index 0000000000000..70a3a362cbec8 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/instance-management/DROP-FOLLOWER.md @@ -0,0 +1,57 @@ +--- +{ + "title": "DROP FOLLOWER", + "language": "en" +} +--- + + + + + +## Description + +This statement is to delete the node of the FOLLOWER role of FRONTEND, (only for administrators!) + +Grammar: + +```sql +ALTER SYSTEM DROP FOLLOWER "follower_host:edit_log_port" +``` + +Illustration: + +1. host can be a hostname or an ip address + +2. edit_log_port : edit_log_port in its configuration file fe.conf + +## Example + +1. Delete a FOLLOWER node + + ```sql + ALTER SYSTEM DROP FOLLOWER "host_ip:9010" + ``` + +## Keywords + +ALTER, SYSTEM, DROP, FOLLOWER, ALTER SYSTEM + + diff --git a/docs/sql-manual/sql-statements/cluster-management/instance-management/DROP-OBSERVER.md b/docs/sql-manual/sql-statements/cluster-management/instance-management/DROP-OBSERVER.md new file mode 100644 index 0000000000000..cc6f6c4c218cc --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/instance-management/DROP-OBSERVER.md @@ -0,0 +1,59 @@ +--- +{ + "title": "DROP OBSERVER", + "language": "en" +} +--- + + + + + + + +## Description + +This statement is to delete the node of the OBSERVER role of FRONTEND, (only for administrators!) + +grammar: + +```sql +ALTER SYSTEM DROP OBSERVER "follower_host:edit_log_port" +``` + +illustrate: + +1. host can be a hostname or an ip address +2. edit_log_port : edit_log_port in its configuration file fe.conf + +## Example + +1. Add a FOLLOWER node + + ```sql + ALTER SYSTEM DROP OBSERVER "host_ip:9010" + ``` + +## Keywords + + ALTER, SYSTEM, DROP, OBSERVER, ALTER SYSTEM + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/cluster-management/instance-management/MODIFY-BACKEND.md b/docs/sql-manual/sql-statements/cluster-management/instance-management/MODIFY-BACKEND.md new file mode 100644 index 0000000000000..5eefadabaaa97 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/instance-management/MODIFY-BACKEND.md @@ -0,0 +1,102 @@ +--- +{ + "title": "MODIFY BACKEND", + "language": "en" +} + +--- + + + + + + + +## Description + +Modify BE node properties (administrator only!) + +grammar: + +- Find backend through host and port + +```sql +ALTER SYSTEM MODIFY BACKEND "host:heartbeat_port" SET ("key" = "value"[, ...]); +``` + +- Find backend through backend_id + +```sql +ALTER SYSTEM MODIFY BACKEND "id1" SET ("key" = "value"[, ...]); +``` + + illustrate: + +1. host can be a hostname or an ip address +2. heartbeat_port is the heartbeat port of the node +3. Modify BE node properties The following properties are currently supported: + +- tag.xxxx: resource tag +- disable_query: query disable attribute +- disable_load: import disable attribute + +Note: +1. A backend can be set multi resource tags. But must contain "tag.location" type. + +## Example + +1. Modify the resource tag of BE + + ```sql + ALTER SYSTEM MODIFY BACKEND "host1:heartbeat_port" SET ("tag.location" = "group_a"); + ALTER SYSTEM MODIFY BACKEND "host1:heartbeat_port" SET ("tag.location" = "group_a", "tag.compute" = "c1"); + ``` + + ```sql + ALTER SYSTEM MODIFY BACKEND "id1" SET ("tag.location" = "group_a"); + ALTER SYSTEM MODIFY BACKEND "id1" SET ("tag.location" = "group_a", "tag.compute" = "c1"); + ``` + +2. Modify the query disable property of BE + + ```sql + ALTER SYSTEM MODIFY BACKEND "host1:heartbeat_port" SET ("disable_query" = "true"); + ``` + + ```sql + ALTER SYSTEM MODIFY BACKEND "id1" SET ("disable_query" = "true"); + ``` + +3. Modify the import disable property of BE + + ```sql + ALTER SYSTEM MODIFY BACKEND "host1:heartbeat_port" SET ("disable_load" = "true"); + ``` + + ```sql + ALTER SYSTEM MODIFY BACKEND "id1" SET ("disable_load" = "true"); + ``` + +## Keywords + + ALTER, SYSTEM, ADD, BACKEND, ALTER SYSTEM + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/cluster-management/instance-management/MODIFY-FRONTEND-HOSTNAME.md b/docs/sql-manual/sql-statements/cluster-management/instance-management/MODIFY-FRONTEND-HOSTNAME.md new file mode 100644 index 0000000000000..520f7d0d44daa --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/instance-management/MODIFY-FRONTEND-HOSTNAME.md @@ -0,0 +1,61 @@ +--- +{ + "title": "MODIFY FRONTEND HOSTNAME", + "language": "en" +} + +--- + + + +## Description + +Modify the properties of the FRONTEND (hereinafter referred to as FE). Currently, this command can only modify the HOSTNAME of the FE. When the hostname of the host where a certain FE instance in the cluster is running needs to be changed, this command can be used to change the hostname registered by this FE in the cluster so that it can continue to operate normally. + +This command is only used to convert the DORIS cluster to FQDN deployment. For details on FQDN deployment, please refer to the "FQDN" chapter. + +## Syntax + +```sql +ALTER SYSTEM MODIFY FRONTEND "" HOSTNAME "" +``` +## Required Parameters + +**** + +> The hostname and edit log port registered by the FE whose hostname needs to be changed. You can view information about all FEs in the cluster by using the SHOW FRONTENDS command. For detailed usage, please refer to the "SHOW FRONTENDS" chapter. + +**** + +> The new hostname of the FE. + +## Access Control Requirements + +The user executing this SQL command must have at least NOD_PRIV permissions. + +## Examples + +Change the hostname of an FE instance in the cluster from 10.10.10.1 to 172.22.0.1: + +```sql +ALTER SYSTEM +MODIFY FRONTEND "10.10.10.1:9010" +HOSTNAME "172.22.0.1" +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/cluster-management/instance-management/SET-FRONTEND-CONFIG.md b/docs/sql-manual/sql-statements/cluster-management/instance-management/SET-FRONTEND-CONFIG.md new file mode 100644 index 0000000000000..210860e5e0be0 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/instance-management/SET-FRONTEND-CONFIG.md @@ -0,0 +1,62 @@ +--- +{ + "title": "SET FRONTEND CONFIG", + "language": "en" +} +--- + + + + + + + +## Description + +This statement is used to set the configuration items of the cluster (currently only supports setting FE configuration items). + +The configurable items can be viewed using the `SHOW FRONTEND CONFIG;` command. + +Syntax: + +```sql +ADMIN SET FRONTEND CONFIG ("key" = "value") [ALL]; +-- or +ADMIN SET ALL FRONTENDS CONFIG ("key" = "value"); +``` + +:::tip Explanation + +- Starting from versions 2.0.11 and 2.1.5, the `ALL` keyword is supported. When using the `ALL` keyword, the configuration parameters will be applied to all FEs (except for the `master_only` parameter). +- This syntax does not persistently modify the configuration. After an FE restarts, the modified configuration becomes invalid. To persist the changes, the configuration items need to be synchronously added in fe.conf. +::: + +## Example + +1. Set `disable_balance` to true + + `ADMIN SET FRONTEND CONFIG ("disable_balance" = "true");` + +## Keywords + +ADMIN, SET, CONFIG + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/cluster-management/instance-management/SHOW-BACKEND-CONFIG.md b/docs/sql-manual/sql-statements/cluster-management/instance-management/SHOW-BACKEND-CONFIG.md new file mode 100644 index 0000000000000..fd7435fc96f23 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/instance-management/SHOW-BACKEND-CONFIG.md @@ -0,0 +1,114 @@ +--- +{ + "title": "SHOW BACKEND CONFIG", + "language": "en" +} +--- + + + + +## Description + +Display the configuration items and their current values for BACKEND (i.e., BE). + +## Syntax + +```sql +[ ADMIN ] SHOW BACKEND CONFIG [ LIKE ] [ FROM ] +``` + +## Optional Parameters + +**** + +> Provides a wildcard pattern to match BE configuration items. The matching rules are the same as those for LIKE expressions. For writing rules, please refer to the "Matching Expressions" section. + +**** + +> The ID of the BE. Used to view the configuration of the BE with the specified ID. The ID of the BE can be obtained through the SHOW BACKENDS command. Please refer to the "SHOW BACKENDS" command for details. + +## Return Value + +- BackendId: The ID of the BE +- Host: The host address of the BE +- Key: The name of the configuration item +- Value: The corresponding value of the configuration item +- Type: The type of the configuration value + +## Access Control Requirements + +Users executing this SQL command must have at least ADMIN_PRIV permissions. + +## Examples + +### Query All Configuration Items + +```sql +SHOW BACKEND CONFIG +``` +Result: + +```sql ++-----------+--------------+--------------------------------+-------+--------------------------+-----------+ +| BackendId | Host | Key | Value | Type | IsMutable | ++-----------+--------------+--------------------------------+-------+--------------------------+-----------+ +| 12793 | 172.16.123.1 | LZ4_HC_compression_level | 9 | int64_t | true | +| 12793 | 172.16.123.1 | agent_task_trace_threshold_sec | 2 | int32_t | true | +... +| 12794 | 172.16.123.2 | zone_map_row_num_threshold | 20 | int32_t | true | ++-----------+--------------+--------------------------------+-------+--------------------------+-----------+ +``` + +### Query Configuration Items for a Specified BE ID + +```sql +SHOW BACKEND CONFIG FROM 12793 +``` + +Result: + +```sql ++-----------+--------------+--------------------------------+-------+--------------------------+-----------+ +| BackendId | Host | Key | Value | Type | IsMutable | ++-----------+--------------+--------------------------------+-------+--------------------------+-----------+ +| 12793 | 172.16.123.1 | LZ4_HC_compression_level | 9 | int64_t | true | +| 12793 | 172.16.123.1 | agent_task_trace_threshold_sec | 2 | int32_t | true | +... +| 12793 | 172.16.123.1 | zone_map_row_num_threshold | 20 | int32_t | true | ++-----------+--------------+--------------------------------+-------+--------------------------+-----------+ +``` + +### Query Configuration Items Matching a Specified Pattern + +```sql +SHOW BACKEND CONFIG LIKE '%compression_level%' +``` + +Result: + +```sql ++-----------+--------------+--------------------------+-------+---------+-----------+ +| BackendId | Host | Key | Value | Type | IsMutable | ++-----------+--------------+--------------------------+-------+---------+-----------+ +| 12793 | 172.16.123.1 | LZ4_HC_compression_level | 9 | int64_t | true | +| 12794 | 172.16.123.2 | LZ4_HC_compression_level | 9 | int64_t | true | ++-----------+--------------+--------------------------+-------+---------+-----------+ +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/cluster-management/instance-management/SHOW-BACKENDS.md b/docs/sql-manual/sql-statements/cluster-management/instance-management/SHOW-BACKENDS.md new file mode 100644 index 0000000000000..82c07c46008c1 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/instance-management/SHOW-BACKENDS.md @@ -0,0 +1,62 @@ +--- +{ + "title": "SHOW BACKENDS", + "language": "en" +} +--- + + + + + + +## Description + +This statement is used to view the BE nodes in the cluster + +```sql + SHOW BACKENDS; +``` + +illustrate: + +1. LastStartTime indicates the last BE start time. +2. LastHeartbeat indicates the last heartbeat. +3. Alive indicates whether the node is alive or not. +4. If SystemDecommissioned is true, it means that the node is being safely decommissioned. +5. If ClusterDecommissioned is true, it means that the node is going offline in the current cluster. +6. TabletNum represents the number of shards on the node. +7. DataUsedCapacity Indicates the space occupied by the actual user data. +8. AvailCapacity Indicates the available space on the disk. +9. TotalCapacity represents the total disk space. TotalCapacity = AvailCapacity + DataUsedCapacity + other non-user data files occupy space. +10. UsedPct Indicates the percentage of disk used. +11. ErrMsg is used to display the error message when the heartbeat fails. +12. Status is used to display some status information of BE in JSON format, including the time information of the last time BE reported its tablet. +13. HeartbeatFailureCounter: The current number of heartbeats that have failed consecutively. If the number exceeds the `max_backend_heartbeat_failure_tolerance_count` configuration, the isAlive will be set to false. +14. NodeRole is used to display the role of Backend node. Now there are two roles: mix and computation. Mix node represent the origin Backend node and computation Node represent the compute only node. + + + +## Keywords + +SHOW, BACKENDS + + + diff --git a/docs/sql-manual/sql-statements/cluster-management/instance-management/SHOW-BROKER.md b/docs/sql-manual/sql-statements/cluster-management/instance-management/SHOW-BROKER.md new file mode 100644 index 0000000000000..6eb4f4324765b --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/instance-management/SHOW-BROKER.md @@ -0,0 +1,54 @@ +--- +{ + "title": "SHOW BROKER", + "language": "en" +} +--- + + + + + + +## Description + +This statement is used to view the currently existing broker + +grammar: + +```sql +SHOW BROKER; +``` + +illustrate: + +1. LastStartTime indicates the last BE start time. +2. LastHeartbeat indicates the last heartbeat. +3. Alive indicates whether the node is alive or not. +4. ErrMsg is used to display the error message when the heartbeat fails. + +## Example + +## Keywords + +SHOW, BROKER + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/cluster-management/instance-management/SHOW-FRONTEND-CONFIG.md b/docs/sql-manual/sql-statements/cluster-management/instance-management/SHOW-FRONTEND-CONFIG.md new file mode 100644 index 0000000000000..2756d52123716 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/instance-management/SHOW-FRONTEND-CONFIG.md @@ -0,0 +1,74 @@ +--- +{ + "title": "SHOW FRONTEND CONFIG", + "language": "en" +} +--- + + + + + + +## Description + +This statement is used to display the configuration of the current cluster (currently only the configuration items of FE are supported) + +grammar: + +```sql +SHOW FRONTEND CONFIG [LIKE "pattern"]; +``` + +The columns in the results have the following meanings: + +1. Key: Configuration item name +2. Value: Configuration item value +3. Type: Configuration item type +4. IsMutable: Whether it can be set by ADMIN SET CONFIG command +5. MasterOnly: Is it only applicable to Master FE +6. Comment: Configuration item description + +## Example + +1. View the configuration of the current FE node + + ```sql + SHOW FRONTEND CONFIG; + ``` + +2. Use the like predicate to search the configuration of the current Fe node + + ```sql + mysql> SHOW FRONTEND CONFIG LIKE '%check_java_version%'; + +--------------------+-------+---------+---------- -+------------+---------+ + | Key | Value | Type | IsMutable | MasterOnly | Comment | + +--------------------+-------+---------+---------- -+------------+---------+ + | check_java_version | true | boolean | false | false | | + +--------------------+-------+---------+---------- -+------------+---------+ + 1 row in set (0.01 sec) + ``` + +## Keywords + +SHOW, CONFIG + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/cluster-management/instance-management/SHOW-FRONTENDS-DISKS.md b/docs/sql-manual/sql-statements/cluster-management/instance-management/SHOW-FRONTENDS-DISKS.md new file mode 100644 index 0000000000000..3dc6ac4f3ce64 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/instance-management/SHOW-FRONTENDS-DISKS.md @@ -0,0 +1,70 @@ +--- +{ + "title": "SHOW FRONTENDS DISKS", + "language": "en" +} +--- + + + + +## Description + +This statement is used to view FE nodes's important paths' disk information, such as meta, log, audit-log and temp dir. + +## Syntax + +```sql +SHOW FRONTENDS DISKS; +``` + +illustrate: + +1. Name indicates the name of the FE node in bdbje. +2. Host indicates the ip of the FE node. +3. DirType indicates the type of dir type, such as meta, log, audit-log temp and deploy dir. +4. Dir indicates the dir path of FE node dir in which type. +5. FileSystem indicates the dir path in which file system on the linux operation system. +6. Capacity indicates total capacity of the filesystem. +7. Used indicates the size of the filesystem already used. +8. Available indicates the size of the filesystem remained. +9. UseRate indicates File system usage capacity ratio. +10. MountOn indicates the mount dir of the filesystem. + +## Example +` +mysql> show frontends disks; ++-----------------------------------------+-------------+-----------+---------------------------------+------------+----------+------+-----------+---------+------------+ +| Name | Host | DirType | Dir | Filesystem | Capacity | Used | Available | UseRate | MountOn | ++-----------------------------------------+-------------+-----------+---------------------------------+------------+----------+------+-----------+---------+------------+ +| fe_a1daac68_5ec0_477c_b5e8_f90a33cdc1bb | 10.xx.xx.90 | meta | /home/disk/output/fe/doris-meta | /dev/sdf1 | 7T | 2T | 4T | 36% | /home/disk | +| fe_a1daac68_5ec0_477c_b5e8_f90a33cdc1bb | 10.xx.xx.90 | log | /home/disk/output/fe/log | /dev/sdf1 | 7T | 2T | 4T | 36% | /home/disk | +| fe_a1daac68_5ec0_477c_b5e8_f90a33cdc1bb | 10.xx.xx.90 | audit-log | /home/disk/output/fe/log | /dev/sdf1 | 7T | 2T | 4T | 36% | /home/disk | +| fe_a1daac68_5ec0_477c_b5e8_f90a33cdc1bb | 10.xx.xx.90 | temp | /home/disk/output/fe/temp_dir | /dev/sdf1 | 7T | 2T | 4T | 36% | /home/disk | +| fe_a1daac68_5ec0_477c_b5e8_f90a33cdc1bb | 10.xx.xx.90 | deploy | /home/disk/output/fe | /dev/sdf1 | 7T | 2T | 4T | 36% | /home/disk | ++-----------------------------------------+-------------+-----------+---------------------------------+------------+----------+------+-----------+---------+------------+ +5 rows in set (0.00 sec) +` + +## Keywords + +SHOW, FRONTENDS + + diff --git a/docs/sql-manual/sql-statements/cluster-management/instance-management/SHOW-FRONTENDS.md b/docs/sql-manual/sql-statements/cluster-management/instance-management/SHOW-FRONTENDS.md new file mode 100644 index 0000000000000..ba4b3dafcdcd6 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/instance-management/SHOW-FRONTENDS.md @@ -0,0 +1,59 @@ +--- +{ + "title": "SHOW FRONTENDS", + "language": "en" +} +--- + + + + + + + +## Description + +This statement is used to view FE nodes + +grammar: + +```sql +SHOW FRONTENDS; +``` + +illustrate: + +1. name indicates the name of the FE node in bdbje. +2. If Join is true, it means that the node has joined the cluster before. But it does not mean that it is still in the cluster (may have lost contact) +3. Alive indicates whether the node is alive or not. +4. ReplayedJournalId indicates the maximum metadata journal id that has been replayed by the node. +5. LastHeartbeat is the last heartbeat. +6. IsHelper indicates whether the node is a helper node in bdbje. +7. ErrMsg is used to display the error message when the heartbeat fails. +8. CurrentConnected indicates whether the FE node is currently connected + + + +## Keywords + +SHOW, FRONTENDS + + + diff --git a/docs/sql-manual/sql-statements/cluster-management/storage-management/ALTER-STORAGE-POLICY.md b/docs/sql-manual/sql-statements/cluster-management/storage-management/ALTER-STORAGE-POLICY.md new file mode 100644 index 0000000000000..b960ac4f0e86f --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/storage-management/ALTER-STORAGE-POLICY.md @@ -0,0 +1,54 @@ +--- +{ +"title": "ALTER STORAGE POLICY", +"language": "en" +} +--- + + + +## Description + +This statement is used to modify an existing cold and hot separation migration strategy. Only root or admin users can modify resources. + +```sql +ALTER STORAGE POLICY 'policy_name' +PROPERTIES ("key"="value", ...); +``` + +## Example + +1. Modify the name to coolown_datetime Cold and hot separation data migration time point: +```sql +ALTER STORAGE POLICY has_test_policy_to_alter PROPERTIES("cooldown_datetime" = "2023-06-08 00:00:00"); +``` +2. Modify the name to coolown_countdown of hot and cold separation data migration of ttl +```sql +ALTER STORAGE POLICY has_test_policy_to_alter PROPERTIES ("cooldown_ttl" = "10000"); +ALTER STORAGE POLICY has_test_policy_to_alter PROPERTIES ("cooldown_ttl" = "1h"); +ALTER STORAGE POLICY has_test_policy_to_alter PROPERTIES ("cooldown_ttl" = "3d"); +``` +## Keywords + +```sql +ALTER, STORAGE, POLICY +``` + +## Best Practice diff --git a/docs/sql-manual/sql-statements/cluster-management/storage-management/ALTER-STORAGE-VAULT.md b/docs/sql-manual/sql-statements/cluster-management/storage-management/ALTER-STORAGE-VAULT.md new file mode 100644 index 0000000000000..1d73273ee76ad --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/storage-management/ALTER-STORAGE-VAULT.md @@ -0,0 +1,82 @@ +--- +{ +"title": "ALTER STORAGE VAULT", +"language": "en" +} +--- + + + +## Description + +Modify the mutable properties of a Storage Vault. + +## Syntax + +```sql +ALTER STORAGE VAULT +PROPERTIES () +``` + +## Required Parameters + +**** + +> - type: Optional values are s3, hdfs + +>When type is s3, the allowed property fields are as follows: +> +>- s3.access_key: ak for s3 vault +>- s3.secret_key: sk for s3 vault +>- vault_name: The name of the vault. +>- use_path_style: Whether to allow path style url, optional values are true, false. The default value is false. + +>When type is hdfs, the following fields are prohibited: +> +>- path_prefix: Storage path prefix +>- fs.defaultFS: hdfs name + +## Permission Control + +The user executing this SQL command must have at least ADMIN_PRIV permissions. + +## Examples + +Modify s3 storage vault ak + +```sql +ALTER STORAGE VAULT old_vault_name +PROPERTIES ( + "type"="S3", + "VAULT_NAME" = "new_vault_name", + "s3.access_key" = "new_ak" +); +``` + +Modify hdfs storage vault + +```sql +ALTER STORAGE VAULT old_vault_name +PROPERTIES ( + "type"="hdfs", + "VAULT_NAME" = "new_vault_name", + "hadoop.username" = "hdfs" +); +``` diff --git a/docs/sql-manual/sql-statements/cluster-management/storage-management/CANCEL-WARM-UP.md b/docs/sql-manual/sql-statements/cluster-management/storage-management/CANCEL-WARM-UP.md new file mode 100644 index 0000000000000..a2cd0a2a73760 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/storage-management/CANCEL-WARM-UP.md @@ -0,0 +1,82 @@ +--- +{ +"title": "CANCEL WARM UP", +"language": "en" +} +--- + + + +## Description + +For terminating a specified warm-up job in Doris. + +## Syntax + +```sql +CANCEL WARM UP JOB WHERE id = ; +``` +## Required Parameters + +> The id of the warm-up job you want to terminate, which can be queried through the command `SHOW WARM UP JOB`. + +## Permission Control + +The user executing this SQL command must have at least ADMIN_PRIV permissions. + +## Example + +Query the warm-up jobs currently running in the system through `SHOW WARM UP JOB`: + +```sql +SHOW WARM UP JOB +``` + +Its result is: + +```C++ ++----------------+---------------+---------+-------+-------------------------+-------------+----------+------------+--------+ +| JobId | ClusterName | Status | Type | CreateTime | FinishBatch | AllBatch | FinishTime | ErrMsg | ++----------------+---------------+---------+-------+-------------------------+-------------+----------+------------+--------+ +| 90290165739458 | CloudCluster1 | RUNNING | TABLE | 2024-11-11 11:11:42.700 | 1 | 3 | NULL | | ++----------------+---------------+---------+-------+-------------------------+-------------+----------+------------+--------+ +``` + +Then terminate it through `CANCEL WARM UP`: + +```C++ +CANCEL WARM UP WHERE id = 90290165739458; +``` + +If the following content is returned, it indicates that the warm-up job corresponding to the specified id does not exist: + +```C++ +ERROR 1105 (HY000): errCode = 2, detailMessage = job id: 110 does not exist. +``` + +After a successful return, `SHOW WARM UP JOB` can be used again to see that the job status has changed from RUNNING to CANCELLED: + +```C++ ++----------------+---------------+-----------+-------+-------------------------+-------------+----------+-------------------------+-------------+ +| JobId | ClusterName | Status | Type | CreateTime | FinishBatch | AllBatch | FinishTime | ErrMsg | ++----------------+---------------+-----------+-------+-------------------------+-------------+----------+-------------------------+-------------+ +| 90290165739458 | CloudCluster1 | CANCELLED | TABLE | 2024-11-11 11:11:42.700 | 1 | 3 | 2024-11-11 11:11:43.700 | user cancel | ++----------------+---------------+-----------+-------+-------------------------+-------------+----------+-------------------------+-------------+ +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-POLICY.md b/docs/sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-POLICY.md new file mode 100644 index 0000000000000..b0ef59cf99922 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-POLICY.md @@ -0,0 +1,81 @@ +--- +{ + "title": "CREATE STORAGE POLICY", + "language": "en", +} +--- + + + + +## Description + +To create a storage policy, you must first create a storage resource, and then associate the created storage resource name when creating the migration policy. For details, refer to the RESOURCE section. + +## Syntax + +```sql +CREATE STORAGE POLICY +PROPERTIES( + "storage_resource" = "" + [{, "cooldown_datetime" = "" + | , "cooldown_ttl" = ""}] +); +``` + +## Required Parameters + +1. ``: The name of the storage policy to be created +2. ``: The name of the associated storage resource. For details on how to create it, refer to the RESOURCE section + +## Optional Parameters + +1. ``: Specifies the cooldown time for creating the data migration policy +2. ``: Specifies the duration of hot data for creating the data migration policy + +## Access Control Requirements + +The prerequisite for successfully executing this SQL command is to have ADMIN_PRIV privileges. Refer to the privilege document. + +| Privilege | Object | Notes | +| :--------- | :----------------------------------- | :------------------------------ | +| ADMIN_PRIV | Entire cluster management privileges | All privileges except NODE_PRIV | + +## Examples + +1. Create a data migration policy with a specified data cooldown time. + + ```sql + CREATE STORAGE POLICY testPolicy + PROPERTIES( + "storage_resource" = "s3", + "cooldown_datetime" = "2022-06-08 00:00:00" + ); + ``` + +2. Create a data migration policy with a specified duration of hot data + + ```sql + CREATE STORAGE POLICY testPolicy + PROPERTIES( + "storage_resource" = "s3", + "cooldown_ttl" = "1d" + ); + ``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT.md b/docs/sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT.md new file mode 100644 index 0000000000000..e0da5f83fbd4d --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT.md @@ -0,0 +1,214 @@ +--- +{ + "title": "CREATE-STORAGE-VAULT", + "language": "en", + "toc_min_heading_level": 2, + "toc_max_heading_level": 4 +} +--- + + + +## CREATE-STORAGE-VAULT + +### Description + +This command is used to create a storage vault. The subject of this document describes the syntax for creating Doris self-maintained storage vault. + +```sql +CREATE STORAGE VAULT [IF NOT EXISTS] vault +[properties] +``` + + +#### properties + +| param | is required | desc | +|:-------|:------------|:-------------------------------------------------------| +| `type` | required | Only two types of vaults are allowed: `S3` and `HDFS`. | + +##### S3 Vault + +| param | is required | desc | +|:----------------|:------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `s3.endpoint` | required | The endpoint used for object storage.
**Notice**, please don't provide the endpoint with any `http://` or `https://`. And for Azure Blob Storage, the endpoint should be `blob.core.windows.net`. | +| `s3.region` | required | The region of your bucket.(Not required when you'r using GCP or AZURE). | +| `s3.root.path` | required | The path where the data would be stored. | +| `s3.bucket` | required | The bucket of your object storage account. (StorageAccount if you're using Azure). | +| `s3.access_key` | required | The access key of your object storage account. (AccountName if you're using Azure). | +| `s3.secret_key` | required | The secret key of your object storage account. (AccountKey if you're using Azure). | +| `provider` | required | The cloud vendor which provides the object storage service. The supported values include `COS`, `OSS`, `S3`, `OBS`, `BOS`, `AZURE`, `GCP` | +| `use_path_style` | optional | Indicate using `path-style URL`(private environment recommended) or `virtual-hosted-style URL`(public cloud recommended), default `true` (`path-style`) | + +##### HDFS Vault + +| param | is required | desc | +|:---------------------------------|:------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `fs.defaultFS` | required | Hadoop configuration property that specifies the default file system to use. | +| `path_prefix` | optional | The path prefix to where the data would be stored. It would be the root_path of your Hadoop user if you don't provide any prefix. | +| `hadoop.username` | optional | Hadoop configuration property that specifies the user accessing the file system. It would be the user starting Hadoop process if you don't provide any user. | +| `hadoop.security.authentication` | optional | The authentication way used for hadoop. If you'd like to use kerberos you can provide with `kerboros`. | +| `hadoop.kerberos.principal` | optional | The path to your kerberos principal. | +| `hadoop.kerberos.keytab` | optional | The path to your kerberos keytab. | + +### Example + +1. create a HDFS storage vault. + ```sql + CREATE STORAGE VAULT IF NOT EXISTS hdfs_vault_demo + PROPERTIES ( + "type" = "hdfs", -- required + "fs.defaultFS" = "hdfs://127.0.0.1:8020", -- required + "path_prefix" = "big/data", -- optional + "hadoop.username" = "user" -- optional + "hadoop.security.authentication" = "kerberos" -- optional + "hadoop.kerberos.principal" = "hadoop/127.0.0.1@XXX" -- optional + "hadoop.kerberos.keytab" = "/etc/emr.keytab" -- optional + ); + ``` + +2. create a S3 storage vault using OSS. + ```sql + CREATE STORAGE VAULT IF NOT EXISTS oss_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "oss-cn-beijing.aliyuncs.com", -- required + "s3.access_key" = "xxxxxx", -- required, Your OSS access key + "s3.secret_key" = "xxxxxx", -- required, Your OSS secret key + "s3.region" = "cn-beijing", -- required + "s3.root.path" = "oss_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your OSS bucket name + "provider" = "OSS", -- required + "use_path_style" = "false" -- optional, OSS suggest setting `false` + ); + ``` + +3. create a S3 storage vault using COS. + ```sql + CREATE STORAGE VAULT IF NOT EXISTS cos_demo_vault + PROPERTIES ( + "type" = "S3", + "s3.endpoint" = "cos.ap-guangzhou.myqcloud.com", -- required + "s3.access_key" = "xxxxxx", -- required, Your COS access key + "s3.secret_key" = "xxxxxx", -- required, Your COS secret key + "s3.region" = "ap-guangzhou", -- required + "s3.root.path" = "cos_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your COS bucket name + "provider" = "COS", -- required + "use_path_style" = "false" -- optional, COS suggest setting `false` + ); + ``` + +4. create a S3 storage vault using OBS. + ```sql + CREATE STORAGE VAULT IF NOT EXISTS obs_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "obs.cn-north-4.myhuaweicloud.com", -- required + "s3.access_key" = "xxxxxx", -- required, Your OBS access key + "s3.secret_key" = "xxxxxx", -- required, Your OBS secret key + "s3.region" = "cn-north-4", -- required + "s3.root.path" = "obs_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your COS bucket name + "provider" = "OBS", -- required + "use_path_style" = "false" -- optional, OBS suggest setting `false` + ); + ``` + +5. create a S3 storage vault using BOS. + ```sql + CREATE STORAGE VAULT IF NOT EXISTS obs_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "s3.bj.bcebos.com", -- required + "s3.access_key" = "xxxxxx", -- required, Your BOS access key + "s3.secret_key" = "xxxxxx", -- required, Your BOS secret key + "s3.region" = "bj", -- required + "s3.root.path" = "bos_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your BOS bucket name + "provider" = "BOS", -- required + "use_path_style" = "false" -- optional, BOS suggest setting `false` + ); + ``` + +6. create a S3 storage vault using AWS. + ```sql + CREATE STORAGE VAULT IF NOT EXISTS s3_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "s3.us-east-1.amazonaws.com", -- required + "s3.access_key" = "xxxxxx", -- required, Your S3 access key + "s3.secret_key" = "xxxxxx", -- required, Your OBS secret key + "s3.region" = "us-east-1", -- required + "s3.root.path" = "s3_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your s3 bucket name + "provider" = "S3", -- required + "use_path_style" = "false" -- optional, S3 suggest setting `false` + ); + ``` +7. create a S3 storage vault using MinIO. + ```sql + CREATE STORAGE VAULT IF NOT EXISTS minio_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "127.0.0.1:9000", -- required + "s3.access_key" = "xxxxxx", -- required, Your minio access key + "s3.secret_key" = "xxxxxx", -- required, Your minio secret key + "s3.region" = "us-east-1", -- required + "s3.root.path" = "minio_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your minio bucket name + "provider" = "S3", -- required + "use_path_style" = "true" -- required, minio suggest setting `true` + ); + ``` + +8. create a S3 storage vault using AZURE. + ```sql + CREATE STORAGE VAULT IF NOT EXISTS azure_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "blob.core.windows.net", -- required + "s3.access_key" = "xxxxxx", -- required, Your Azure AccountName + "s3.secret_key" = "xxxxxx", -- required, Your Azure AccountKey + "s3.region" = "us-east-1", -- required + "s3.root.path" = "azure_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your Azure StorageAccount + "provider" = "AZURE" -- required + ); + ``` + +9. create a S3 storage vault using GCP. + ```sql + CREATE STORAGE VAULT IF NOT EXISTS gcp_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "storage.googleapis.com", -- required + "s3.access_key" = "xxxxxx", -- required + "s3.secret_key" = "xxxxxx", -- required + "s3.region" = "us-east-1", -- required + "s3.root.path" = "gcp_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required + "provider" = "GCP" -- required + ); + ``` + +### Keywords + + CREATE, STORAGE VAULT diff --git a/docs/sql-manual/sql-statements/cluster-management/storage-management/DROP-STORAGE-POLICY.md b/docs/sql-manual/sql-statements/cluster-management/storage-management/DROP-STORAGE-POLICY.md new file mode 100644 index 0000000000000..090bf3837cdba --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/storage-management/DROP-STORAGE-POLICY.md @@ -0,0 +1,55 @@ +--- +{ + "title": "DROP STORAGE POLICY", + "language": "en", +} +--- + + +## Description + +Delete a storage policy. For detailed descriptions of storage policies, please refer to the "Storage Policy" chapter. + +## Syntax + +```sql +DROP STORAGE POLICY +``` +## Required Parameters + +**** + +> The name of the storage policy + +## Permission Control + +The user executing this SQL command must have at least the following permissions: + +| Privilege | Object | Notes | +| :--------- | :----- | :---- | +| ADMIN_PRIV | Global | | + +## Example + +1. Delete a storage policy named policy1 + + ```sql + DROP STORAGE POLICY policy1 + ``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/cluster-management/storage-management/SET-DEFAULT-STORAGE-VAULT.md b/docs/sql-manual/sql-statements/cluster-management/storage-management/SET-DEFAULT-STORAGE-VAULT.md new file mode 100644 index 0000000000000..4a087444771d3 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/storage-management/SET-DEFAULT-STORAGE-VAULT.md @@ -0,0 +1,53 @@ +--- +{ + "title": "SET DEFAULT STORAGE VAULT", + "language": "en" +} +--- + + + +## Description + +This statement is used to set the default storage vault in Doris. The default storage vault is used to store data for internal or system tables. If the default storage vault is not set, Doris will not function properly. Once the default storage vault is set, it cannot be removed. + +## Syntax + +```sql +SET vault_name DEFAULT STORAGE VAULT +``` + +> Note: +> +> 1. Only ADMIN users can set the default storage vault. + +## Example + +1. Set the storage vault named 's3_vault' as the default storage vault. + + ```sql + SET s3_vault AS DEFAULT STORAGE VAULT; + ``` + +## Related Commands + +## Keywords + + SET, DEFAULT, STORAGE, VAULT \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/cluster-management/storage-management/SHOW-CACHE-HOTSPOT.md b/docs/sql-manual/sql-statements/cluster-management/storage-management/SHOW-CACHE-HOTSPOT.md new file mode 100644 index 0000000000000..4f793a042fba9 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/storage-management/SHOW-CACHE-HOTSPOT.md @@ -0,0 +1,61 @@ +--- +{ + "title": "SHOW CACHE HOTSPOT", + "language": "en" +} +--- + + + +## Description + +This statement is used to display the hotspot information of file cache. + +## Syntax + +```sql + SHOW CACHE HOTSPOT '/[compute_group_name/table_name]'; +``` + +## Parameters + +1. compute_group_name : Name of compute group. +2. table_name : Name of table. + +## Example + +1. View the table creation statement of a table + + ```sql + SHOW CACHE HOTSPOT '/'; + ``` + +## Related Commands + + - [WARMUP CACHE](../Database-Administration-Statements/WARM-UP-COMPUTE-GROUP.md) + +## References + + - [MANAGING FILE CACHE](../../../compute-storage-decoupled/file-cache.md) + +## Keywords + + SHOW, CACHE, HOTSPOT + diff --git a/docs/sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-POLICY-USING.md b/docs/sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-POLICY-USING.md new file mode 100644 index 0000000000000..eccebb8ca56e4 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-POLICY-USING.md @@ -0,0 +1,68 @@ +--- +{ + "title": "SHOW STORAGE POLICY USING", + "language": "en" +} +--- + + + +## Description + +This command is used to show tables and partitions which is using storage policy + +```sql +SHOW STORAGE POLICY USING [FOR some_policy] +``` + +## Example + +1. get all objects which are using storage policy + + ```sql + mysql> show storage policy using; + +-----------------------+-----------------------------------------+----------------------------------------+------------+ + | PolicyName | Database | Table | Partitions | + +-----------------------+-----------------------------------------+----------------------------------------+------------+ + | test_storage_policy | regression_test_cold_heat_separation_p2 | table_with_storage_policy_1 | ALL | + | test_storage_policy | regression_test_cold_heat_separation_p2 | partition_with_multiple_storage_policy | p201701 | + | test_storage_policy_2 | regression_test_cold_heat_separation_p2 | partition_with_multiple_storage_policy | p201702 | + | test_storage_policy_2 | regression_test_cold_heat_separation_p2 | table_with_storage_policy_2 | ALL | + | test_policy | db2 | db2_test_1 | ALL | + +-----------------------+-----------------------------------------+----------------------------------------+------------+ + ``` + +2. get objects which are using the storage policy named test_storage_policy + + ```sql + mysql> show storage policy using for test_storage_policy; + +---------------------+-----------+---------------------------------+------------+ + | PolicyName | Database | Table | Partitions | + +---------------------+-----------+---------------------------------+------------+ + | test_storage_policy | db_1 | partition_with_storage_policy_1 | p201701 | + | test_storage_policy | db_1 | table_with_storage_policy_1 | ALL | + +---------------------+-----------+---------------------------------+------------+ + ``` + +## Keywords + + SHOW, STORAGE, POLICY, USING + +## Best Practice diff --git a/docs/sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-POLICY.md b/docs/sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-POLICY.md new file mode 100644 index 0000000000000..1eebeca109aab --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-POLICY.md @@ -0,0 +1,76 @@ +--- +{ + "title": "SHOW STORAGE POLICY", + "language": "en" +} +--- + + + +## Description + +View tables and partitions associated with all/specified storage policies. + +## Syntax + +```sql +SHOW STORAGE POLICY USING [FOR ] +``` + +## Required Parameters + + + +> The name of the storage policy to view. + +The prerequisite for successfully executing this SQL command is to have ADMIN_PRIV privileges. Please refer to the privilege document. + +| Privilege (Privilege) | Object (Object) | Notes (Notes) | +| --------------------- | ------------------------------------ | ------------------------------- | +| ADMIN_PRIV | Entire cluster management privileges | All privileges except NODE_PRIV | + +## Example + +1. View all objects with enabled storage policies. + + ```sql + mysql> show storage policy using; + +-----------------------+-----------------------------------------+----------------------------------------+------------+ + | PolicyName | Database | Table | Partitions | + +-----------------------+-----------------------------------------+----------------------------------------+------------+ + | test_storage_policy | regression_test_cold_heat_separation_p2 | table_with_storage_policy_1 | ALL | + | test_storage_policy | regression_test_cold_heat_separation_p2 | partition_with_multiple_storage_policy | p201701 | + | test_storage_policy_2 | regression_test_cold_heat_separation_p2 | partition_with_multiple_storage_policy | p201702 | + | test_storage_policy_2 | regression_test_cold_heat_separation_p2 | table_with_storage_policy_2 | ALL | + | test_policy | db2 | db2_test_1 | ALL | + +-----------------------+-----------------------------------------+----------------------------------------+------------+ + ``` + +1. View objects using the storage policy test_storage_policy. + + ```sql + mysql> show storage policy using for test_storage_policy; + +---------------------+-----------+---------------------------------+------------+ + | PolicyName | Database | Table | Partitions | + +---------------------+-----------+---------------------------------+------------+ + | test_storage_policy | db_1 | partition_with_storage_policy_1 | p201701 | + | test_storage_policy | db_1 | table_with_storage_policy_1 | ALL | + +---------------------+-----------+---------------------------------+------------+ + ``` diff --git a/docs/sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-VAULTS.md b/docs/sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-VAULTS.md new file mode 100644 index 0000000000000..7344e306a75ff --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-VAULTS.md @@ -0,0 +1,55 @@ +--- +{ + "title": "SHOW STORAGE VAULTS", + "language": "en" +} +--- + + + +## Description + +The SHOW STORAGE VAULTS command is used to display information about all storage vaults configured in the system. Storage vaults are used to manage external storage locations for data. + +## Syntax + +```sql + SHOW STORAGE VAULTS +``` + +## Return Values + +This command returns a result set with the following columns: + +- `StorageVaultName`: The name of the storage vault. +- `StorageVaultId`: The id of the storage vault. +- `Properties`: A JSON string containing the configuration properties of the vault. +- `IsDefault`: Indicates whether this vault is set as the default (TRUE or FALSE). + +## Related Commands + +- [CREATE STORAGE VAULT](../Data-Definition-Statements/CREATE-STORAGE-VAULT.md) +- [GRANT](../account-management/GRANT-TO.md) +- [REVOKE](../account-management/REVOKE-FROM.md) +- [SET DEFAULT STORAGE VAULT](../Data-Definition-Statements/SET-DEFAULT-STORAGE-VAULT.md) + +## Keywords + + SHOW, STORAGE VAULTS diff --git a/docs/sql-manual/sql-statements/cluster-management/storage-management/SHOW-WARM-UP-JOB.md b/docs/sql-manual/sql-statements/cluster-management/storage-management/SHOW-WARM-UP-JOB.md new file mode 100644 index 0000000000000..dadc674a4fbb1 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/storage-management/SHOW-WARM-UP-JOB.md @@ -0,0 +1,66 @@ +--- +{ + "title": "SHOW WARM UP JOB", + "language": "en" +} +--- + + + +## Description + +The commands are used to display warm-up jobs in Doris. + +## Syntax + +```sql + SHOW WARM UP JOB [ WHERE id = 'id' ] ; +``` + +## Parameters + +* id : id of the warm-up job. + +## Example + +1. View all warmup job + + ```sql + SHOW WARM UP JOB; + ``` + +2. View one warmup job with id = 13418 + +```sql + SHOW WARM UP JOB WHERE id = 13418; +``` + +## Related Commands + + - [WARMUP COMPUTE GROUP](../Database-Administration-Statements/WARM-UP-COMPUTE-GROUP.md) + +## References + + - [MANAGING FILE CACHE](../../../compute-storage-decoupled/file-cache.md) + +## Keywords + + SHOW, CACHE, HOTSPOT, COMPUTE GROUP + diff --git a/docs/sql-manual/sql-statements/cluster-management/storage-management/UNSET-DEFAULT-STORAGE-VAULT.md b/docs/sql-manual/sql-statements/cluster-management/storage-management/UNSET-DEFAULT-STORAGE-VAULT.md new file mode 100644 index 0000000000000..890d78cddffbb --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/storage-management/UNSET-DEFAULT-STORAGE-VAULT.md @@ -0,0 +1,46 @@ +--- +{ + "title": "UNSET DEFAULT STORAGE VAULT", + "language": "en" +} +--- + + + +## Description +Cancel the Specified Default Storage Vault + +## Syntax + +```sql +UNSET DEFAULT STORAGE VAULT +``` + +## Permission Control + +| Privilege | Object | Notes | +| :--------- | :------------ | :--------------------------------------------------------- | +| ADMIN_PRIV | Storage Vault | Only admin users have permission to execute this statement | + +## Example + +```sql +UNSET DEFAULT STORAGE VAULT +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/cluster-management/storage-management/WARM-UP.md b/docs/sql-manual/sql-statements/cluster-management/storage-management/WARM-UP.md new file mode 100644 index 0000000000000..e5b504540b357 --- /dev/null +++ b/docs/sql-manual/sql-statements/cluster-management/storage-management/WARM-UP.md @@ -0,0 +1,81 @@ +--- +{ + "title": "WARM UP", + "language": "en" +} +--- + + + +## Description + +The WARM UP COMPUTE GROUP statement is used to warm up data in a compute group to improve query performance. The warming operation can either retrieve resources from another compute group or specify particular tables and partitions for warming. The warming operation returns a job ID that can be used to track the status of the warming job. + +## Syntax + +```sql +WARM UP COMPUTE GROUP WITH COMPUTE GROUP ; + +WARM UP COMPUTE GROUP WITH ; + +warm_up_list ::= warm_up_item [AND warm_up_item...]; + +warm_up_item ::= TABLE [PARTITION ]; + +``` + +## Parameters + +* destination_compute_group_name: The name of the destination compute group that is to be warmed up. + +* source_compute_group_name(Optional) The name of the source cluster from which resources will be warmed up. + +* warm_up_list: (Optional) A list of specific items to warm up, which can include tables and partitions. + +* table_name: The name of the table is used to warmup. + +* partition_name: The name of the partition is used to warmup. + +## Return Values + +* JobId: the id of warm-up job. + +## Example + +1. Warm up a compute group named destination_group_name with a compute group named source_group_name. + +```sql + WARM UP COMPUTE GROUP destination_group_name WITH COMPUTE GROUP source_group_name; + +``` + +2. Warm up a compute group named destination_group with table sales_data and customer_info and partition q1_2024 of table orders . + +``` + WARM UP COMPUTE GROUP destination_group WITH + TABLE sales_data + AND TABLE customer_info + AND TABLE orders PARTITION q1_2024; + +``` + +## Keywords + + WARM UP, COMPUTE GROUP, CACHE diff --git a/docs/sql-manual/sql-statements/data-governance/ALTER-SQL_BLOCK_RULE.md b/docs/sql-manual/sql-statements/data-governance/ALTER-SQL_BLOCK_RULE.md new file mode 100644 index 0000000000000..32cccdd3a9795 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-governance/ALTER-SQL_BLOCK_RULE.md @@ -0,0 +1,65 @@ +--- +{ + "title": "ALTER SQL_BLOCK_RULE", + "language": "en" +} +--- + + + + + +## Description + +Modify SQL blocking rules to allow modification of each item such as sql/sqlHash/partition_num/tablet_num/cardinality/global/enable. + +grammar: + +```sql +ALTER SQL_BLOCK_RULE rule_name +[PROPERTIES ("key"="value", ...)]; +``` + +illustrate: + +- sql and sqlHash cannot be set at the same time. This means that if a rule sets sql or sqlHash, the other attribute cannot be modified; +- sql/sqlHash and partition_num/tablet_num/cardinality cannot be set at the same time. For example, if a rule sets partition_num, then sql or sqlHash cannot be modified; + +## Example + +1. Modify according to SQL properties + +```sql +ALTER SQL_BLOCK_RULE test_rule PROPERTIES("sql"="select \\* from test_table","enable"="true") +``` + +2. If a rule sets partition_num, then sql or sqlHash cannot be modified + +```sql +ALTER SQL_BLOCK_RULE test_rule2 PROPERTIES("partition_num" = "10","tablet_num"="300","enable"="true") +``` + +## Keywords + +```text +ALTER,SQL_BLOCK_RULE +``` + +## Best Practice diff --git a/docs/sql-manual/sql-statements/data-governance/CREATE-ROW-POLICY.md b/docs/sql-manual/sql-statements/data-governance/CREATE-ROW-POLICY.md new file mode 100644 index 0000000000000..3db7f6e7ea680 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-governance/CREATE-ROW-POLICY.md @@ -0,0 +1,98 @@ +--- +{ + "title": "CREATE ROW POLICY", + "language": "en" +} +--- + + + + + + +## Description + +Explain can view the rewritten execution plan. + +## Syntax + +```sql +CREATE ROW POLICY [ IF NOT EXISTS ] +ON +AS { RESTRICTIVE | PERMISSIVE } +TO { | ROLE } +USING (); +``` +## Required Parameters + +**** + +> Row security policy name + +**** + +> Table name + +**** + +> RESTRICTIVE combines a set of policies with AND, PERMISSIVE combines a set of policies with OR + + + +> Equivalent to the filter condition of a query statement, for example: id=1 + +## Optional Parameters + +**** + +> User name, cannot be created for root and admin users + +**** + +> Role name + +## Access Control Requirements + +The user executing this SQL command must have at least the following privileges: + +| Privilege | Object | Notes | +| ------------------------ | ------ | ----- | +| ADMIN_PRIV or GRANT_PRIV | Global | | + +## Examples + +1. Create a set of row security policies + + ```sql + CREATE ROW POLICY test_row_policy_1 ON test.table1 + AS RESTRICTIVE TO test USING (c1 = 'a'); + CREATE ROW POLICY test_row_policy_2 ON test.table1 + AS RESTRICTIVE TO test USING (c2 = 'b'); + CREATE ROW POLICY test_row_policy_3 ON test.table1 + AS PERMISSIVE TO test USING (c3 = 'c'); + CREATE ROW POLICY test_row_policy_3 ON test.table1 + AS PERMISSIVE TO test USING (c4 = 'd'); + ``` + + When we execute a query on table1, the rewritten SQL is: + + ```sql + SELECT * FROM (SELECT * FROM table1 WHERE c1 = 'a' AND c2 = 'b' OR c3 = 'c' OR c4 = 'd') + ``` diff --git a/docs/sql-manual/sql-statements/data-governance/CREATE-SQL_BLOCK_RULE.md b/docs/sql-manual/sql-statements/data-governance/CREATE-SQL_BLOCK_RULE.md new file mode 100644 index 0000000000000..c3fd0691ea599 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-governance/CREATE-SQL_BLOCK_RULE.md @@ -0,0 +1,153 @@ +--- +{ + "title": "CREATE SQL_BLOCK_RULE", + "language": "en" +} +--- + + + + +## Description + +This statement creates a SQL blocking rule. it can restrict any kind of sql statements(no matter DDL or DML statement). + +Supports configuring SQL blacklists by user: + +- Refuse to specify SQL by regular matching +- Check if a sql reaches one of these limits by setting partition_num, tablet_num, cardinality + - partition_num, tablet_num, cardinality can be set together, once a query reaches one of these limits, the query will be intercepted + +grammar: + +```sql +CREATE SQL_BLOCK_RULE rule_name +[PROPERTIES ("key"="value", ...)]; +``` + +Parameter Description: + +- sql: matching rule (based on regular matching, special characters need to be translated,for example`select *`use`select \\*`), optional, the default value is "NULL" +- sqlHash: sql hash value, used for exact matching, we will print this value in `fe.audit.log`, optional, this parameter and sql can only be selected one, the default value is "NULL" +- partition_num: the maximum number of partitions a scan node will scan, the default value is 0L +- tablet_num: The maximum number of tablets that a scanning node will scan, the default value is 0L +- cardinality: the rough scan line number of a scan node, the default value is 0L +- global: Whether to take effect globally (all users), the default is false +- enable: whether to enable blocking rules, the default is true + +## Example + +1. Create a block rule named test_rule + + ```sql + CREATE SQL_BLOCK_RULE test_rule + PROPERTIES( + "sql"="select \\* from order_analysis", + "global"="false", + "enable"="true" + ); + ``` + + >Notes: + > + >That the sql statement here does not end with a semicolon + + When we execute the sql we just defined in the rule, an exception error will be returned. The example is as follows: + + ```sql + select * from order_analysis; + ERROR 1064 (HY000): errCode = 2, detailMessage = sql match regex sql block rule: order_analysis_rule + ``` + + +2. Create test_rule2, limit the maximum number of scanned partitions to 30, and limit the maximum scan base to 10 billion rows. The example is as follows: + + ```sql + CREATE SQL_BLOCK_RULE test_rule2 + PROPERTIES ( + "partition_num" = "30", + "cardinality" = "10000000000", + "global" = "false", + "enable" = "true" + ); + ``` +3. Create SQL BLOCK RULE with special chars + + ```sql + CREATE SQL_BLOCK_RULE test_rule3 + PROPERTIES + ( + "sql" = "select count\\(1\\) from db1.tbl1" + ); + CREATE SQL_BLOCK_RULE test_rule4 + PROPERTIES + ( + "sql" = "select \\* from db1.tbl1" + ); + ``` +4. In SQL_BLOCK_RULE, SQL matching is based on regular expressions. If want to match more patterns of SQL, need to write the corresponding regex. For example, to ignore spaces in SQL and not query tables that start with 'order_', as shown below: + + ```sql + CREATE SQL_BLOCK_RULE test_rule4 + PROPERTIES( + "sql"="\\s*select\\s*\\*\\s*from order_\\w*\\s*", + "global"="false", + "enable"="true" + ); + ``` + +### APPENDIX +Here are some commonly used regular expressions: +> . :Matches any single character except for a newline character \n. +> +> * :Matches the preceding element zero or more times. For example, a matches zero or more 'a'. +> +> + :Matches the preceding element one or more times. For example, a+ matches one or more 'a'. +> +> ? :Matches the preceding element zero or one time. For example, a? matches zero or one 'a'. +> +> [] :Used to define a character set. For example, [aeiou] matches any one vowel letter. +> +> [^] :In a character set, use ^ to indicate negation, matching characters that are not in the set. For example, [^0-9] matches any non-digit character. +> +> () :Used for grouping expressions and applying quantifiers. For example, (ab)+ matches consecutive 'ab'. +> +> | :Represents logical OR. For example, a|b matches 'a' or 'b'. +> +> ^ :Matches the beginning of a string. For example, ^abc matches a string that starts with 'abc'. +> +> $ :Matches the end of a string. For example, xyz$ matches a string that ends with 'xyz'. +> +> \ :Used to escape special characters to treat them as ordinary characters. For example, \\. matches the period character '.'. +> +> \s :Matches any whitespace character, including spaces, tabs, newline characters, etc. +> +> \d :Matches any digit character, equivalent to [0-9]. +> +> \w :Matches any word character, including letters, digits, and underscores, equivalent to [a-zA-Z0-9_]. + +## Keywords + +```text +CREATE, SQL_BLCOK_RULE +``` + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-governance/DROP-ROW-POLICY.md b/docs/sql-manual/sql-statements/data-governance/DROP-ROW-POLICY.md new file mode 100644 index 0000000000000..4daf26daff37f --- /dev/null +++ b/docs/sql-manual/sql-statements/data-governance/DROP-ROW-POLICY.md @@ -0,0 +1,86 @@ +--- +{ + "title": "DROP ROW POLICY", + "language": "en" +} +--- + + + + + +## Description + +Delete row security policy. For details about row security policies, please refer to the "Security Policies" chapter + + +## Syntax + +```sql +DROP ROW POLICY on + [ FOR { | ROLE } ]; +``` + +## Required Parameters +**** + +> Row security policy name + +**** + +> Table name + +# Optional Parameters (Optional Parameters) + +**** + +> User name + +**** + +> Role name + +# Access Control Requirements (Access Control Requirements) + +The user executing this SQL command must have at least the following privileges: + +| Privilege | Object | Notes | +| :------------------------- | :----- | :---- | +| ADMIN_PRIV or *GRANT_PRIV* | Global | | + +# Examples (Examples) + +1. Delete the *policy1 row security policy* for *db1.table1* + + ```sql + DROP ROW POLICY policy1 ON db1.table1 + ``` + +1. Delete the policy1 row security policy for db1.table1 that applies to user1 + + ```sql + DROP ROW POLICY policy1 ON db1.table1 FOR user1 + ``` + +1. Delete the policy1 row security policy for db1.table1 that applies to role1 + + ```sql + DROP ROW POLICY policy1 ON db1.table1 FOR role role1 + ``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/data-governance/DROP-SQL_BLOCK_RULE.md b/docs/sql-manual/sql-statements/data-governance/DROP-SQL_BLOCK_RULE.md new file mode 100644 index 0000000000000..f91f60c132491 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-governance/DROP-SQL_BLOCK_RULE.md @@ -0,0 +1,52 @@ +--- +{ + "title": "DROP SQL_BLOCK_RULE", + "language": "en" +} +--- + + + +## Description + +Delete SQL blocking rules, support multiple rules, separated by , + +grammar: + +```sql +DROP SQL_BLOCK_RULE test_rule1,... +``` + +## Example + +1. Delete the test_rule1 and test_rule2 blocking rules + + ```sql + mysql> DROP SQL_BLOCK_RULE test_rule1,test_rule2; + Query OK, 0 rows affected (0.00 sec) + ``` + +## Keywords + +```text +DROP, SQL_BLOCK_RULE +``` + +## Best Practice diff --git a/docs/sql-manual/sql-statements/data-governance/SHOW-ROW-POLICY.md b/docs/sql-manual/sql-statements/data-governance/SHOW-ROW-POLICY.md new file mode 100644 index 0000000000000..1b98ab478df86 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-governance/SHOW-ROW-POLICY.md @@ -0,0 +1,76 @@ +--- +{ + "title": "SHOW ROW POLICY", + "language": "en" +} +--- + + + + + + +## Description + +View row security policies. For details on row security policies, refer to the "Security Policies" chapter + +## Syntax + +```sql +SHOW ROW POLICY [ FOR { | ROLE } ]; +``` +## Optional Parameters + +**** + +> User name + +**** + +> Role name + +## Access Control Requirements + +The user executing this SQL command must have at least the following privileges: + +| Privilege | Object | Notes | +| :--------- | :----- | :---- | +| ADMIN_PRIV | Global | | + +## Examples + +1. View all security policies + + + ```sql + SHOW ROW POLICY; + ``` + +1. Query by specifying a user name + + ```sql + SHOW ROW POLICY FOR user1; + ``` + +1. Query by specifying a role name + + ```sql + SHOW ROW POLICY for role role1; + ``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/data-governance/SHOW-SQL_BLOCK_RULE.md b/docs/sql-manual/sql-statements/data-governance/SHOW-SQL_BLOCK_RULE.md new file mode 100644 index 0000000000000..1263f2a06ee2d --- /dev/null +++ b/docs/sql-manual/sql-statements/data-governance/SHOW-SQL_BLOCK_RULE.md @@ -0,0 +1,71 @@ +--- +{ + "title": "SHOW SQL_BLOCK_RULE", + "language": "en" +} +--- + + + + +## Description + +View the configured SQL blocking rules. If you do not specify a rule name, you will view all rules. + +grammar: + +```sql +SHOW SQL_BLOCK_RULE [FOR RULE_NAME]; +``` + +## Example + +1. View all rules. + + ```sql + mysql> SHOW SQL_BLOCK_RULE; + +------------+----------------------------+---------+- -------------+------------+-------------+--------+- -------+ + | Name | Sql | SqlHash | PartitionNum | TabletNum | Cardinality | Global | Enable | + +------------+----------------------------+---------+- -------------+------------+-------------+--------+- -------+ + | test_rule | select * from order_analysis | NULL | 0 | 0 | 0 | true | true | + | test_rule2 | NULL | NULL | 30 | 0 | 10000000000 | false | true | + +------------+----------------------------+---------+- -------------+------------+-------------+--------+- -------+ + 2 rows in set (0.01 sec) + ``` + +2. Make a rule name query + + ```sql + mysql> SHOW SQL_BLOCK_RULE FOR test_rule2; + +------------+------+---------+---------------+---- -------+-------------+--------+--------+ + | Name | Sql | SqlHash | PartitionNum | TabletNum | Cardinality | Global | Enable | + +------------+------+---------+---------------+---- -------+-------------+--------+--------+ + | test_rule2 | NULL | NULL | 30 | 0 | 10000000000 | false | true | + +------------+------+---------+---------------+---- -------+-------------+--------+--------+ + 1 row in set (0.00 sec) + + ``` + + +## Keywords + + SHOW, SQL_BLOCK_RULE + +## Best Practice diff --git a/docs/sql-manual/sql-statements/data-modification/DML/DELETE.md b/docs/sql-manual/sql-statements/data-modification/DML/DELETE.md new file mode 100644 index 0000000000000..dfa89978495ea --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/DML/DELETE.md @@ -0,0 +1,207 @@ +--- +{ + "title": "DELETE", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to conditionally delete data in the specified table (base index) partition. + +This operation will also delete the data of the rollup index related to this base index. + +#### Syntax + +Syntax 1: This syntax can only specify filter predicates + +```SQL +DELETE FROM table_name [PARTITION partition_name | PARTITIONS (partition_name [, partition_name])] +WHERE +column_name op { value | value_list } [ AND column_name op { value | value_list } ...]; +``` + +Syntax 2: This syntax can only used on UNIQUE KEY model + +```sql +[cte] +DELETE FROM table_name + [PARTITION partition_name | PARTITIONS (partition_name [, partition_name])] + [USING additional_tables] + WHERE condition +``` + +#### Required Parameters + ++ table_name: Specifies the table from which rows are removed. ++ column_name: column belong to table_name ++ op: Logical comparison operator, The optional types of op include: =, >, <, >=, <=, !=, in, not in ++ value | value_list: value or value list used for logial comparison ++ WHERE condition: Specifies a condition to use to select rows for removal + +#### Optional Parameters + ++ cte: Common Table Expression, e.g. 'WITH a AS SELECT * FROM tbl'. ++ PARTITION partition_name | PARTITIONS (partition_name [, partition_name]): Specifies the partition or partitions to select rows for removal ++ table_alias: alias of table ++ USING additional_tables: If you need to refer to additional tables in the WHERE clause to help identify the rows to be removed, then specify those table names in the USING clause. You can also use the USING clause to specify subqueries that identify the rows to be removed. + +#### Note + +1. Only conditions on the key column can be specified when using AGGREGATE (UNIQUE) model. +2. When the selected key column does not exist in a rollup, delete cannot be performed. +3. Wheny you use syntax 1, conditions can only have an "and" relationship. If you want to achieve an "or" relationship, you need to write the conditions in two DELETE statements. +4. In syntax 1, if it is a partitioned table, you can specify a partition. If not specified, Doris will infer partition from the given conditions. In two cases, Doris cannot infer the partition from conditions: 1) the conditions do not contain partition columns; 2) The operator of the partition column is not in. When a partition table does not specify the partition, or the partition cannot be inferred from the conditions, the session variable delete_without_partition needs to be true to make delete statement be applied to all partitions. + +:::tip Tips +This feature is supported since the Apache Doris 1.2 version +::: + +5. This statement may reduce query efficiency for a period of time after execution. The degree of impact depends on the number of delete conditions specified in the statement. The more conditions you specify, the greater the impact. + +## Example + +1. Delete the data row whose k1 column value is 3 in my_table partition p1 + + ```sql + DELETE FROM my_table PARTITION p1 + WHERE k1 = 3; + ``` + +2. Delete the data rows where the value of column k1 is greater than or equal to 3 and the value of column k2 is "abc" in my_table partition p1 + + ```sql + DELETE FROM my_table PARTITION p1 + WHERE k1 >= 3 AND k2 = "abc"; + ``` + +3. Delete the data rows where the value of column k1 is greater than or equal to 3 and the value of column k2 is "abc" in my_table partition p1, p2 + + ```sql + DELETE FROM my_table PARTITIONS (p1, p2) + WHERE k1 >= 3 AND k2 = "abc"; + ``` + +4. use the result of `t2` join `t3` to romve rows from `t1`,delete table only support unique key model + + ```sql + -- create t1, t2, t3 tables + CREATE TABLE t1 + (id INT, c1 BIGINT, c2 STRING, c3 DOUBLE, c4 DATE) + UNIQUE KEY (id) + DISTRIBUTED BY HASH (id) + PROPERTIES('replication_num'='1', "function_column.sequence_col" = "c4"); + + CREATE TABLE t2 + (id INT, c1 BIGINT, c2 STRING, c3 DOUBLE, c4 DATE) + DISTRIBUTED BY HASH (id) + PROPERTIES('replication_num'='1'); + + CREATE TABLE t3 + (id INT) + DISTRIBUTED BY HASH (id) + PROPERTIES('replication_num'='1'); + + -- insert data + INSERT INTO t1 VALUES + (1, 1, '1', 1.0, '2000-01-01'), + (2, 2, '2', 2.0, '2000-01-02'), + (3, 3, '3', 3.0, '2000-01-03'); + + INSERT INTO t2 VALUES + (1, 10, '10', 10.0, '2000-01-10'), + (2, 20, '20', 20.0, '2000-01-20'), + (3, 30, '30', 30.0, '2000-01-30'), + (4, 4, '4', 4.0, '2000-01-04'), + (5, 5, '5', 5.0, '2000-01-05'); + + INSERT INTO t3 VALUES + (1), + (4), + (5); + + -- remove rows from t1 + DELETE FROM t1 + USING t2 INNER JOIN t3 ON t2.id = t3.id + WHERE t1.id = t2.id; + ``` + + the expect result is only remove the row where id = 1 in table t1 + + ``` + +----+----+----+--------+------------+ + | id | c1 | c2 | c3 | c4 | + +----+----+----+--------+------------+ + | 2 | 2 | 2 | 2.0 | 2000-01-02 | + | 3 | 3 | 3 | 3.0 | 2000-01-03 | + +----+----+----+--------+------------+ + ``` + +5. using cte + + ```sql + create table orders( + o_orderkey bigint, + o_totalprice decimal(15, 2) + ) unique key(o_orderkey) + distributed by hash(o_orderkey) buckets 1 + properties ( + "replication_num" = "1" + ); + + insert into orders values + (1, 34.1), + (2, 432.8); + + create table lineitem( + l_linenumber int, + o_orderkey bigint, + l_discount decimal(15, 2) + ) unique key(l_linenumber) + distributed by hash(l_linenumber) buckets 1 + properties ( + "replication_num" = "1" + ); + + insert into lineitem values + (1, 1, 1.23), + (2, 1, 3.21), + (3, 2, 18.08), + (4, 2, 23.48); + + with discount_orders as ( + select * from orders + where o_totalprice > 100 + ) + delete from lineitem + using discount_orders + where lineitem.o_orderkey = discount_orders.o_orderkey; + ``` + +## Keywords + + DELETE + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/DML/INSERT-OVERWRITE.md b/docs/sql-manual/sql-statements/data-modification/DML/INSERT-OVERWRITE.md new file mode 100644 index 0000000000000..7746aefe37154 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/DML/INSERT-OVERWRITE.md @@ -0,0 +1,300 @@ +--- +{ + "title": "INSERT OVERWRITE", + "language": "en" +} + + +--- + + + + + + +## Description + +The function of this statement is to overwrite a table or some partitions of a table + +```sql +INSERT OVERWRITE table table_name + [ PARTITION (p1, ... | *) ] + [ WITH LABEL label] + [ (column [, ...]) ] + [ [ hint [, ...] ] ] + { VALUES ( { expression | DEFAULT } [, ...] ) [, ...] | query } +``` + + Parameters + +> table_name: the destination table to overwrite. This table must exist. It can be of the form `db_name.table_name` +> +> partitions: the table partitions that needs to be overwritten. The following two formats are supported +> +> > 1. partition names. must be one of the existing partitions in `table_name` separated by a comma +> > 2. asterisk(*)。Enable [auto-detect-partition](#overwrite-auto-detect-partition). The write operation will automatically detect the partitions involved in the data and overwrite those partitions. This format is supported since Apache Doris 2.1.3 version. +> +> label: specify a label for the Insert task +> +> column_name: the specified destination column must be one of the existing columns in `table_name` +> +> expression: the corresponding expression that needs to be assigned to a column +> +> DEFAULT: let the column use the default value +> +> query: a common query, the result of the query will overwrite the target. +> +> hint: some indicator used to indicate the execution behavior of `INSERT`. You can choose one of this values: `/*+ STREAMING */`, `/*+ SHUFFLE */` or `/*+ NOSHUFFLE */. +> +> 1. STREAMING: At present, it has no practical effect and is only reserved for compatibility with previous versions. (In the previous version, adding this hint would return a label, but now it defaults to returning a label) +> 2. SHUFFLE: When the target table is a partition table, enabling this hint will do repartiiton. +> 3. NOSHUFFLE: Even if the target table is a partition table, repartiiton will not be performed, but some other operations will be performed to ensure that the data is correctly dropped into each partition. + +Notice: + +1. In the current version, the session variable `enable_insert_strict` is set to `true` by default. If some data that does not conform to the format of the target table is filtered out during the execution of the `INSERT OVERWRITE` statement, such as when overwriting a partition and not all partition conditions are satisfied, overwriting the target table will fail. +2. The `INSERT OVERWRITE` statement first creates a new table, inserts the data to be overwritten into the new table, and then atomically replaces the old table with the new table and modifies its name. Therefore, during the process of overwriting the table, the data in the old table can still be accessed normally until the overwriting is completed. + +#### For Auto Partition Table + +If the target table of the INSERT OVERWRITE is an autopartitioned table, the behaviour is controlled by the [Session Variable](../#variable) `enable_auto_create_when_overwrite` controls the behaviour as follows: + +1. If PARTITION is not specified (overwrite the whole table), when `enable_auto_create_when_overwrite` is `true`, the table is overwritten and partitions are created according to the table's auto-partitioning rules for data that does not have a corresponding partition, and those datas is admit. If `enable_auto_create_when_overwrite` is `false`, data for which no partition is found will accumulate error rows until it fails. +2. If an overwrite PARTITION is specified, the AUTO PARTITION table behaves as a normal partitioned table during this process, and data that does not satisfy the conditions of an existing partition is filtered instead of creating a new partition. +3. If you specify PARTITION as `partition(*)` (auto detect partition and overwrite), when `enable_auto_create_when_overwrite` is `true`, for the data that have corresponding partitions in the table, overwrite their corresponding partitions, and leave the other existing partitions unchanged. At the same time, for data without corresponding partitions, create partitions according to the table's auto-partitioning rules, and accommodate the data without corresponding partitions. If `enable_auto_create_when_overwrite` is `false`, data for which no partition is found will accumulate error rows until it fails. + +`enable_auto_create_when_overwrite` was introduced since 2.1.6. In versions without `enable_auto_create_when_overwrite`, the behaviour is as if the variable had a value of `false`. + +Examples are shown below: + +```sql +mysql> create table auto_list( + -> k0 varchar null + -> ) + -> auto partition by list (k0) + -> ( + -> PARTITION p1 values in (("Beijing"), ("BEIJING")), + -> PARTITION p2 values in (("Shanghai"), ("SHANGHAI")), + -> PARTITION p3 values in (("xxx"), ("XXX")), + -> PARTITION p4 values in (("list"), ("LIST")), + -> PARTITION p5 values in (("1234567"), ("7654321")) + -> ) + -> DISTRIBUTED BY HASH(`k0`) BUCKETS 1 + -> properties("replication_num" = "1"); +Query OK, 0 rows affected (0.14 sec) + +mysql> insert into auto_list values ("Beijing"),("Shanghai"),("xxx"),("list"),("1234567"); +Query OK, 5 rows affected (0.22 sec) + +mysql> insert overwrite table auto_list partition(*) values ("BEIJING"), ("new1"); +Query OK, 2 rows affected (0.28 sec) + +mysql> select * from auto_list; ++----------+ --- p1 is overwritten, new1 gets the new partition, and the other partitions remain unchanged. +| k0 | ++----------+ +| 1234567 | +| BEIJING | +| list | +| xxx | +| new1 | +| Shanghai | ++----------+ +6 rows in set (0.48 sec) + +mysql> insert overwrite table auto_list values ("SHANGHAI"), ("new2"); +Query OK, 2 rows affected (0.17 sec) + +mysql> select * from auto_list; ++----------+ --- The whole table is overwritten, and new2 gets the new partition. +| k0 | ++----------+ +| new2 | +| SHANGHAI | ++----------+ +2 rows in set (0.15 sec) +``` + +## Example + +Assuming there is a table named `test`. The table contains two columns `c1` and `c2`, and two partitions `p1` and `p2` + +```sql +CREATE TABLE IF NOT EXISTS test ( + `c1` int NOT NULL DEFAULT "1", + `c2` int NOT NULL DEFAULT "4" +) ENGINE=OLAP +UNIQUE KEY(`c1`) +PARTITION BY LIST (`c1`) +( +PARTITION p1 VALUES IN ("1","2","3"), +PARTITION p2 VALUES IN ("4","5","6") +) +DISTRIBUTED BY HASH(`c1`) BUCKETS 3 +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1", + "in_memory" = "false", + "storage_format" = "V2" +); +``` + +#### Overwrite Table + +1. Overwrite the `test` table using the form of `VALUES`. + + ```sql + // Single-row overwrite. + INSERT OVERWRITE table test VALUES (1, 2); + INSERT OVERWRITE table test (c1, c2) VALUES (1, 2); + INSERT OVERWRITE table test (c1, c2) VALUES (1, DEFAULT); + INSERT OVERWRITE table test (c1) VALUES (1); + // Multi-row overwrite. + INSERT OVERWRITE table test VALUES (1, 2), (3, 2 + 2); + INSERT OVERWRITE table test (c1, c2) VALUES (1, 2), (3, 2 * 2); + INSERT OVERWRITE table test (c1, c2) VALUES (1, DEFAULT), (3, DEFAULT); + INSERT OVERWRITE table test (c1) VALUES (1), (3); + ``` + +- The first and second statements have the same effect. If the target column is not specified during overwriting, the column order in the table will be used as the default target column. After the overwrite is successful, there is only one row of data in the `test` table. +- The third and fourth statements have the same effect. The unspecified column `c2` will be overwritten with the default value 4. After the overwrite is successful, there is only one row of data in the `test` table. +- The fifth and sixth statements have the same effect. Expressions (such as `2+2`, `2*2`) can be used in the statement. The result of the expression will be computed during the execution of the statement and then overwritten into the `test` table. After the overwrite is successful, there are two rows of data in the `test` table. +- The seventh and eighth statements have the same effect. The unspecified column `c2` will be overwritten with the default value 4. After the overwrite is successful, there are two rows of data in the `test` table. + +2. Overwrite the `test` table in the form of a query statement. The data format of the `test2` table and the `test` table must be consistent. If they are not consistent, implicit data type conversion will be triggered. + + ```sql + INSERT OVERWRITE table test SELECT * FROM test2; + INSERT OVERWRITE table test (c1, c2) SELECT * from test2; + ``` + +- The first and second statements have the same effect. The purpose of these statements is to take data from the `test2` table and overwrite the `test` table with the taken data. After the overwrite is successful, the data in the `test` table will be consistent with the data in the `test2` table. + +3. Overwrite the `test` table and specify a label. + + ```sql + INSERT OVERWRITE table test WITH LABEL `label1` SELECT * FROM test2; + INSERT OVERWRITE table test WITH LABEL `label2` (c1, c2) SELECT * from test2; + ``` + +- Users can use the `SHOW LOAD;` command to check the status of the job imported by this `label`. It should be noted that the label is unique. + + +#### Overwrite Table Partition + +When using INSERT OVERWRITE to rewrite partitions, we actually encapsulate the following three steps into a single transaction and execute it. If it fails halfway through, the operations that have been performed will be rolled back: + +1. Assuming that partition `p1` is specified to be rewritten, first create an empty temporary partition `pTMP` with the same structure as the target partition to be rewritten. +2. Write data to `pTMP`. +3. replace `p1` with the `pTMP` atom + +The following is examples: + +1. Overwrite partitions `P1` and `P2` of the `test` table using the form of `VALUES`. + + ```sql + // Single-row overwrite. + INSERT OVERWRITE table test PARTITION(p1,p2) VALUES (1, 2); + INSERT OVERWRITE table test PARTITION(p1,p2) (c1, c2) VALUES (1, 2); + INSERT OVERWRITE table test PARTITION(p1,p2) (c1, c2) VALUES (1, DEFAULT); + INSERT OVERWRITE table test PARTITION(p1,p2) (c1) VALUES (1); + // Multi-row overwrite. + INSERT OVERWRITE table test PARTITION(p1,p2) VALUES (1, 2), (4, 2 + 2); + INSERT OVERWRITE table test PARTITION(p1,p2) (c1, c2) VALUES (1, 2), (4, 2 * 2); + INSERT OVERWRITE table test PARTITION(p1,p2) (c1, c2) VALUES (1, DEFAULT), (4, DEFAULT); + INSERT OVERWRITE table test PARTITION(p1,p2) (c1) VALUES (1), (4); + ``` + + Unlike overwriting an entire table, the above statements are overwriting partitions in the table. Partitions can be overwritten one at a time or multiple partitions can be overwritten at once. It should be noted that only data that satisfies the corresponding partition filtering condition can be overwritten successfully. If there is data in the overwritten data that does not satisfy any of the partitions, the overwrite will fail. An example of a failure is shown below. + + ```sql + INSERT OVERWRITE table test PARTITION(p1,p2) VALUES (7, 2); + ``` + + The data overwritten by the above statements (`c1=7`) does not satisfy the conditions of partitions `P1` and `P2`, so the overwrite will fail. + +2. Overwrite partitions `P1` and `P2` of the `test` table in the form of a query statement. The data format of the `test2` table and the `test` table must be consistent. If they are not consistent, implicit data type conversion will be triggered. + + ```sql + INSERT OVERWRITE table test PARTITION(p1,p2) SELECT * FROM test2; + INSERT OVERWRITE table test PARTITION(p1,p2) (c1, c2) SELECT * from test2; + ``` + +3. Overwrite partitions `P1` and `P2` of the `test` table and specify a label. + + ```sql + INSERT OVERWRITE table test PARTITION(p1,p2) WITH LABEL `label3` SELECT * FROM test2; + INSERT OVERWRITE table test PARTITION(p1,p2) WITH LABEL `label4` (c1, c2) SELECT * from test2; + ``` + + +#### Overwrite Auto Detect Partition + +> This feature is available since version 2.1.3. + +When the PARTITION clause specified by the INSERT OVERWRITE command is `PARTITION(*)`, this overwrite will automatically detect the partition where the data is located. Example: + +```sql +mysql> create table test( + -> k0 int null + -> ) + -> partition by range (k0) + -> ( + -> PARTITION p10 values less than (10), + -> PARTITION p100 values less than (100), + -> PARTITION pMAX values less than (maxvalue) + -> ) + -> DISTRIBUTED BY HASH(`k0`) BUCKETS 1 + -> properties("replication_num" = "1"); +Query OK, 0 rows affected (0.11 sec) + +mysql> insert into test values (1), (2), (15), (100), (200); +Query OK, 5 rows affected (0.29 sec) + +mysql> select * from test order by k0; ++------+ +| k0 | ++------+ +| 1 | +| 2 | +| 15 | +| 100 | +| 200 | ++------+ +5 rows in set (0.23 sec) + +mysql> insert overwrite table test partition(*) values (3), (1234); +Query OK, 2 rows affected (0.24 sec) + +mysql> select * from test order by k0; ++------+ +| k0 | ++------+ +| 3 | +| 15 | +| 1234 | ++------+ +3 rows in set (0.20 sec) +``` + +As you can see, all data in partitions `p10` and `pMAX`, where data 3 and 1234 are located, are overwritten, while partition `p100` remains unchanged. This operation can be interpreted as syntactic sugar for specifying a specific partition to be overwritten by the PARTITION clause during an INSERT OVERWRITE operation, which is implemented in the same way as [specify a partition to overwrite](#overwrite-table-partition). The `PARTITION(*)` syntax eliminates the need to manually fill in all the partition names when overwriting a large number of partitions. + +## Keywords + + INSERT OVERWRITE, OVERWRITE, AUTO DETECT \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/data-modification/DML/INSERT.md b/docs/sql-manual/sql-statements/data-modification/DML/INSERT.md new file mode 100644 index 0000000000000..5e8398dc70fec --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/DML/INSERT.md @@ -0,0 +1,232 @@ +--- +{ + "title": "INSERT", + "language": "en" +} +--- + + + + + + +## Description + +The change statement is to complete the data insertion operation. + +```sql +INSERT INTO table_name + [ PARTITION (p1, ...) ] + [ WITH LABEL label] + [ (column [, ...]) ] + [ [ hint [, ...] ] ] + { VALUES ( { expression | DEFAULT } [, ...] ) [, ...] | query } +``` + + Parameters + +> tablet_name: The destination table for importing data. Can be of the form `db_name.table_name` +> +> partitions: Specify the partitions to be imported, which must be partitions that exist in `table_name`. Multiple partition names are separated by commas +> +> label: specify a label for the Insert task +> +> column_name: The specified destination column, must be a column that exists in `table_name` +> +> expression: the corresponding expression that needs to be assigned to a column +> +> DEFAULT: let the corresponding column use the default value +> +> query: a common query, the result of the query will be written to the target +> +> hint: some indicator used to indicate the execution behavior of `INSERT`. You can choose one of this values: `/*+ STREAMING */`, `/*+ SHUFFLE */` or `/*+ NOSHUFFLE */. +> 1. STREAMING: At present, it has no practical effect and is only reserved for compatibility with previous versions. (In the previous version, adding this hint would return a label, but now it defaults to returning a label) +> 2. SHUFFLE: When the target table is a partition table, enabling this hint will do repartiiton. +> 3. NOSHUFFLE: Even if the target table is a partition table, repartiiton will not be performed, but some other operations will be performed to ensure that the data is correctly dropped into each partition. + +For a Unique table with merge-on-write enabled, you can also perform partial columns updates using the insert statement. To perform partial column updates with the insert statement, you need to set the session variable enable_unique_key_partial_update to true (the default value for this variable is false, meaning partial columns updates with the insert statement are not allowed by default). When performing partial columns updates, the columns being inserted must contain at least all the Key columns and specify the columns you want to update. If the Key column values for the inserted row already exist in the original table, the data in the row with the same key column values will be updated. If the Key column values for the inserted row do not exist in the original table, a new row will be inserted into the table. In this case, columns not specified in the insert statement must either have default values or be nullable. These missing columns will first attempt to be populated with default values, and if a column has no default value, it will be filled with null. If a column cannot be null, the insert operation will fail. + +Please note that the default value of the session variable `enable_insert_strict`, which controls whether the insert statement operates in strict mode, is true. In other words, the insert statement is in strict mode by default, and in this mode, updating non-existing keys in partial column updates is not allowed. Therefore, when using the insert statement for partial columns update and wishing to insert non-existing keys, you need to set `enable_unique_key_partial_update` to true and simultaneously set `enable_insert_strict` to false. + +Notice: + +When executing the `INSERT` statement, the default behavior is to filter the data that does not conform to the target table format, such as the string is too long. However, for business scenarios that require data not to be filtered, you can set the session variable `enable_insert_strict` to `true` to ensure that `INSERT` will not be executed successfully when data is filtered out. + +## Example + +The `test` table contains two columns `c1`, `c2`. + +1. Import a row of data into the `test` table + +```sql +INSERT INTO test VALUES (1, 2); +INSERT INTO test (c1, c2) VALUES (1, 2); +INSERT INTO test (c1, c2) VALUES (1, DEFAULT); +INSERT INTO test (c1) VALUES (1); +``` + +The first and second statements have the same effect. When no target column is specified, the column order in the table is used as the default target column. +The third and fourth statements express the same meaning, use the default value of the `c2` column to complete the data import. + +2. Import multiple rows of data into the `test` table at one time + +```sql +INSERT INTO test VALUES (1, 2), (3, 2 + 2); +INSERT INTO test (c1, c2) VALUES (1, 2), (3, 2 * 2); +INSERT INTO test (c1) VALUES (1), (3); +INSERT INTO test (c1, c2) VALUES (1, DEFAULT), (3, DEFAULT); +``` + +The first and second statements have the same effect, import two pieces of data into the `test` table at one time +The effect of the third and fourth statements is known, and the default value of the `c2` column is used to import two pieces of data into the `test` table + +3. Import a query result into the `test` table + +```sql +INSERT INTO test SELECT * FROM test2; +INSERT INTO test (c1, c2) SELECT * from test2; +``` + +4. Import a query result into the `test` table, specifying the partition and label + +```sql +INSERT INTO test PARTITION(p1, p2) WITH LABEL `label1` SELECT * FROM test2; +INSERT INTO test WITH LABEL `label1` (c1, c2) SELECT * from test2; +``` + + +## Keywords + + INSERT + +## Best Practice + +1. View the returned results + + The INSERT operation is a synchronous operation, and the return of the result indicates the end of the operation. Users need to perform corresponding processing according to the different returned results. + + 1. The execution is successful, the result set is empty + + If the result set of the insert corresponding to the select statement is empty, it will return as follows: + + ```sql + mysql> insert into tbl1 select * from empty_tbl; + Query OK, 0 rows affected (0.02 sec) + ``` + + `Query OK` indicates successful execution. `0 rows affected` means that no data was imported. + + 2. The execution is successful, the result set is not empty + + In the case where the result set is not empty. The returned results are divided into the following situations: + + 1. Insert executes successfully and is visible: + + ```sql + mysql> insert into tbl1 select * from tbl2; + Query OK, 4 rows affected (0.38 sec) + {'label':'insert_8510c568-9eda-4173-9e36-6adc7d35291c', 'status':'visible', 'txnId':'4005'} + + mysql> insert into tbl1 with label my_label1 select * from tbl2; + Query OK, 4 rows affected (0.38 sec) + {'label':'my_label1', 'status':'visible', 'txnId':'4005'} + + mysql> insert into tbl1 select * from tbl2; + Query OK, 2 rows affected, 2 warnings (0.31 sec) + {'label':'insert_f0747f0e-7a35-46e2-affa-13a235f4020d', 'status':'visible', 'txnId':'4005'} + + mysql> insert into tbl1 select * from tbl2; + Query OK, 2 rows affected, 2 warnings (0.31 sec) + {'label':'insert_f0747f0e-7a35-46e2-affa-13a235f4020d', 'status':'committed', 'txnId':'4005'} + ``` + + `Query OK` indicates successful execution. `4 rows affected` means that a total of 4 rows of data were imported. `2 warnings` indicates the number of lines to be filtered. + + Also returns a json string: + + ```json + {'label':'my_label1', 'status':'visible', 'txnId':'4005'} + {'label':'insert_f0747f0e-7a35-46e2-affa-13a235f4020d', 'status':'committed', 'txnId':'4005'} + {'label':'my_label1', 'status':'visible', 'txnId':'4005', 'err':'some other error'} + ``` + + `label` is a user-specified label or an automatically generated label. Label is the ID of this Insert Into import job. Each import job has a unique Label within a single database. + + `status` indicates whether the imported data is visible. Show `visible` if visible, `committed` if not visible. + + `txnId` is the id of the import transaction corresponding to this insert. + + The `err` field shows some other unexpected errors. + + When you need to view the filtered rows, the user can pass the following statement + + ```sql + show load where label="xxx"; + ``` + + The URL in the returned result can be used to query the wrong data. For details, see the summary of **Viewing Error Lines** later. + + **Invisibility of data is a temporary state, this batch of data will eventually be visible** + + You can view the visible status of this batch of data with the following statement: + + ```sql + show transaction where id=4005; + ``` + + If the `TransactionStatus` column in the returned result is `visible`, the representation data is visible. + + 3. Execution failed + + Execution failure indicates that no data was successfully imported, and the following is returned: + + ```sql + mysql> insert into tbl1 select * from tbl2 where k1 = "a"; + ERROR 1064 (HY000): all partitions have no load data. url: http://10.74.167.16:8042/api/_load_error_log?file=__shard_2/error_log_insert_stmt_ba8bb9e158e4879-ae8de8507c0bf8a2_ba8bb9e158e4879_ae8de8507c0 + ``` + + Where `ERROR 1064 (HY000): all partitions have no load data` shows the reason for the failure. The following url can be used to query the wrong data: + + ```sql + show load warnings on "url"; + ``` + + You can view the specific error line. + +2. Timeout time + + + The timeout for INSERT operations is controlled by [session variable](../../../../advanced/variables.md) `insert_timeout`. The default is 4 hours. If it times out, the job will be canceled. + +3. Label and atomicity + + The INSERT operation also guarantees the atomicity of imports, see the [Import Transactions and Atomicity](../../../../data-operate/import/import-scenes/load-atomicity.md) documentation. + + When using `CTE(Common Table Expressions)` as the query part in an insert operation, the `WITH LABEL` and `column` parts must be specified. + +4. Filter Threshold + + Unlike other import methods, INSERT operations cannot specify a filter threshold (`max_filter_ratio`). The default filter threshold is 1, which means that rows with errors can be ignored. + + For business scenarios that require data not to be filtered, you can set [session variable](../../../../advanced/variables.md) `enable_insert_strict` to `true` to ensure that when there is data When filtered out, `INSERT` will not be executed successfully. + +5. Performance issues + + There is no single row insertion using the `VALUES` method. If you must use it this way, combine multiple rows of data into one INSERT statement for bulk commit. diff --git a/docs/sql-manual/sql-statements/data-modification/DML/SHOW-DELETE.md b/docs/sql-manual/sql-statements/data-modification/DML/SHOW-DELETE.md new file mode 100644 index 0000000000000..fddd3b2f91351 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/DML/SHOW-DELETE.md @@ -0,0 +1,52 @@ +--- +{ + "title": "SHOW DELETE", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to display the historical delete tasks that have been successfully executed + +grammar: + +```sql +SHOW DELETE [FROM db_name] +``` + +## Example + + 1. Display all historical delete tasks of database database + + ```sql + SHOW DELETE FROM database; + ``` + +## Keywords + + SHOW, DELETE + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/DML/SHOW-LAST-INSERT.md b/docs/sql-manual/sql-statements/data-modification/DML/SHOW-LAST-INSERT.md new file mode 100644 index 0000000000000..ed282896b2367 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/DML/SHOW-LAST-INSERT.md @@ -0,0 +1,73 @@ +--- +{ + "title": "SHOW LAST INSERT", + "language": "en" +} + +--- + + + + +## Description + +This syntax is used to view the result of the latest insert operation in the current session connection + +grammar: + +```sql +SHOW LAST INSERT +``` + +Example of returned result: + +``` + TransactionId: 64067 + Label: insert_ba8f33aea9544866-8ed77e2844d0cc9b + Database: default_cluster:db1 + Table: t1 +TransactionStatus: VISIBLE + LoadedRows: 2 + FilteredRows: 0 +``` + +illustrate: + +* TransactionId: transaction id +* Label: the label corresponding to the insert task +* Database: the database corresponding to insert +* Table: the table corresponding to insert +* TransactionStatus: transaction status + * PREPARE: preparation stage + * PRECOMMITTED: Pre-commit stage + * COMMITTED: The transaction succeeded, but the data was not visible + * VISIBLE: The transaction succeeded and the data is visible + * ABORTED: Transaction failed +* LoadedRows: Number of imported rows +* FilteredRows: The number of rows being filtered + +## Example + +## Keywords + + SHOW, LASR ,INSERT + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/DML/UPDATE.md b/docs/sql-manual/sql-statements/data-modification/DML/UPDATE.md new file mode 100644 index 0000000000000..59c868e8dd003 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/DML/UPDATE.md @@ -0,0 +1,178 @@ +--- +{ + "title": "UPDATE", + "language": "en" +} +--- + + + + +## Description + +This statement is used to update the data. The UPDATE statement currently only supports the UNIQUE KEY model. + +The UPDATE operation currently only supports updating the Value column. The update of the Key column can refer to [Using FlinkCDC to update Key column](../../../../ecosystem/flink-doris-connector.md#use-flinkcdc-to-update-key-column). +#### Syntax + +```sql +[cte] +UPDATE target_table [table_alias] + SET assignment_list + [ FROM additional_tables] + WHERE condition +``` + +#### Required Parameters + ++ target_table: The target table of the data to be updated. Can be of the form 'db_name.table_name' ++ assignment_list: The target column to be updated, in the format 'col_name = value, col_name = value' ++ where condition: the condition that is expected to be updated, an expression that returns true or false can be + +#### Optional Parameters + ++ cte: Common Table Expression, eg 'WITH a AS SELECT * FROM tbl' ++ table_alias: alias of table ++ FROM additional_tables: Specifies one or more tables to use for selecting rows to update or for setting new values. Note that if you want use target table here, you should give it a alias explicitly. + +#### Note + +The current UPDATE statement only supports row updates on the UNIQUE KEY model. + +## Example + +The `test` table is a unique model table, which contains four columns: k1, k2, v1, v2. Where k1, k2 are keys, v1, v2 are values, and the aggregation method is Replace. + +1. Update the v1 column in the 'test' table that satisfies the conditions k1 =1 , k2 =2 to 1 + +```sql +UPDATE test SET v1 = 1 WHERE k1=1 and k2=2; +``` + +2. Increment the v1 column of the k1=1 column in the 'test' table by 1 + +```sql +UPDATE test SET v1 = v1+1 WHERE k1=1; +``` + +3. use the result of `t2` join `t3` to update `t1` + +```sql +-- create t1, t2, t3 tables +CREATE TABLE t1 + (id INT, c1 BIGINT, c2 STRING, c3 DOUBLE, c4 DATE) +UNIQUE KEY (id) +DISTRIBUTED BY HASH (id) +PROPERTIES('replication_num'='1', "function_column.sequence_col" = "c4"); + +CREATE TABLE t2 + (id INT, c1 BIGINT, c2 STRING, c3 DOUBLE, c4 DATE) +DISTRIBUTED BY HASH (id) +PROPERTIES('replication_num'='1'); + +CREATE TABLE t3 + (id INT) +DISTRIBUTED BY HASH (id) +PROPERTIES('replication_num'='1'); + +-- insert data +INSERT INTO t1 VALUES + (1, 1, '1', 1.0, '2000-01-01'), + (2, 2, '2', 2.0, '2000-01-02'), + (3, 3, '3', 3.0, '2000-01-03'); + +INSERT INTO t2 VALUES + (1, 10, '10', 10.0, '2000-01-10'), + (2, 20, '20', 20.0, '2000-01-20'), + (3, 30, '30', 30.0, '2000-01-30'), + (4, 4, '4', 4.0, '2000-01-04'), + (5, 5, '5', 5.0, '2000-01-05'); + +INSERT INTO t3 VALUES + (1), + (4), + (5); + +-- update t1 +UPDATE t1 + SET t1.c1 = t2.c1, t1.c3 = t2.c3 * 100 + FROM t2 INNER JOIN t3 ON t2.id = t3.id + WHERE t1.id = t2.id; +``` + +the expect result is only update the row where id = 1 in table t1 + +``` ++----+----+----+--------+------------+ +| id | c1 | c2 | c3 | c4 | ++----+----+----+--------+------------+ +| 1 | 10 | 1 | 1000.0 | 2000-01-01 | +| 2 | 2 | 2 | 2.0 | 2000-01-02 | +| 3 | 3 | 3 | 3.0 | 2000-01-03 | ++----+----+----+--------+------------+ +``` + +4. using cte + +```sql +create table orders( + o_orderkey bigint, + o_totalprice decimal(15, 2) +) unique key(o_orderkey) +distributed by hash(o_orderkey) buckets 1 +properties ( + "replication_num" = "1" +); + +insert into orders values +(1, 34.1), +(2, 432.8); + +create table lineitem( + l_linenumber int, + o_orderkey bigint, + l_discount decimal(15, 2) +) unique key(l_linenumber) +distributed by hash(l_linenumber) buckets 1 +properties ( + "replication_num" = "1" +); + +insert into lineitem values +(1, 1, 1.23), +(2, 1, 3.21), +(3, 2, 18.08), +(4, 2, 23.48); + +with discount_orders as ( + select * from orders + where o_totalprice > 100 +) +update lineitem set l_discount = l_discount*0.9 +from discount_orders +where lineitem.o_orderkey = discount_orders.o_orderkey; +``` + +## Keywords + + UPDATE + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/backup-and-restore/ALTER-REPOSITORY.md b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/ALTER-REPOSITORY.md new file mode 100644 index 0000000000000..8e886db2b20cc --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/ALTER-REPOSITORY.md @@ -0,0 +1,25 @@ +--- +{ + "title": "ALTER REPOSITORY", + "language": "en" +} +--- + + diff --git a/docs/sql-manual/sql-statements/data-modification/backup-and-restore/BACKUP.md b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/BACKUP.md new file mode 100644 index 0000000000000..b69832657bee5 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/BACKUP.md @@ -0,0 +1,108 @@ +--- +{ + "title": "BACKUP", + "language": "en" +} + +--- + + + + +## Description + +This statement is used to back up the data under the specified database. This command is an asynchronous operation. After the submission is successful, you need to check the progress through the SHOW BACKUP command. Only backing up tables of type OLAP is supported. + + Only root or superuser users can create repositories. + +grammar: + +```sql +BACKUP SNAPSHOT [db_name].{snapshot_name} +TO `repository_name` +[ON|EXCLUDE] ( + `table_name` [PARTITION (`p1`, ...)], + ... +) +PROPERTIES ("key"="value", ...); +``` + +illustrate: + +- There can only be one executing BACKUP or RESTORE task under the same database. +- The ON clause identifies the tables and partitions that need to be backed up. If no partition is specified, all partitions of the table are backed up by default +- Tables and partitions that do not require backup are identified in the EXCLUDE clause. Back up all partition data for all tables in this database except the specified table or partition. +- PROPERTIES currently supports the following properties: + - "type" = "full": indicates that this is a full update (default) + - "timeout" = "3600": The task timeout period, the default is one day. in seconds. + +## Example + +1. Fully backup the table example_tbl under example_db to the warehouse example_repo: + +```sql +BACKUP SNAPSHOT example_db.snapshot_label1 +TO example_repo +ON (example_tbl) +PROPERTIES ("type" = "full"); +``` + +2. Under the full backup example_db, the p1, p2 partitions of the table example_tbl, and the table example_tbl2 to the warehouse example_repo: + +```sql +BACKUP SNAPSHOT example_db.snapshot_label2 +TO example_repo +ON +( + example_tbl PARTITION (p1,p2), + example_tbl2 +); +``` + +3. Full backup of all tables except table example_tbl under example_db to warehouse example_repo: + +```sql +BACKUP SNAPSHOT example_db.snapshot_label3 +TO example_repo +EXCLUDE (example_tbl); +``` + +4. Fully back up tables under example_db to the repository example_repo: + +```sql +BACKUP SNAPSHOT example_db.snapshot_label3 +TO example_repo; +``` + +## Keywords + +BACKUP + +## Best Practice + +1. Only one backup operation can be performed under the same database. + +2. The backup operation will back up the underlying table and [Synchronous materialized view](../../../../query/view-materialized-view/materialized-view.md) of the specified table or partition, and only one replica will be backed up. [Asynchronous materialized view](../../../../query/view-materialized-view/async-materialized-view.md) is not supported. + +3. Efficiency of backup operations + + The efficiency of backup operations depends on the amount of data, the number of Compute Nodes, and the number of files. Each Compute Node where the backup data shard is located will participate in the upload phase of the backup operation. The greater the number of nodes, the higher the upload efficiency. + + The amount of file data refers only to the number of shards, and the number of files in each shard. If there are many shards, or there are many small files in the shards, the backup operation time may be increased. \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/data-modification/backup-and-restore/CANCEL-BACKUP.md b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/CANCEL-BACKUP.md new file mode 100644 index 0000000000000..87773d114327a --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/CANCEL-BACKUP.md @@ -0,0 +1,51 @@ +--- +{ + "title": "CANCEL BACKUP", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to cancel an ongoing BACKUP task. + +grammar: + +```sql +CANCEL BACKUP FROM db_name; +``` + +## Example + +1. Cancel the BACKUP task under example_db. + +```sql +CANCEL BACKUP FROM example_db; +``` + +## Keywords + + CANCEL, BACKUP + +## Best Practice diff --git a/docs/sql-manual/sql-statements/data-modification/backup-and-restore/CANCEL-RESTORE.md b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/CANCEL-RESTORE.md new file mode 100644 index 0000000000000..9e54736fc71f7 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/CANCEL-RESTORE.md @@ -0,0 +1,55 @@ +--- +{ + "title": "CANCEL RESTORE", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to cancel an ongoing RESTORE task. + +grammar: + +```sql +CANCEL RESTORE FROM db_name; +``` + +Notice: + +- When cancellation is around a COMMIT or later stage of recovery, the table being recovered may be rendered inaccessible. At this time, data recovery can only be performed by executing the recovery job again. + +## Example + +1. Cancel the RESTORE task under example_db. + +```sql +CANCEL RESTORE FROM example_db; +``` + +## Keywords + + CANCEL, RESTORE + +## Best Practice diff --git a/docs/sql-manual/sql-statements/data-modification/backup-and-restore/CREATE-REPOSITORY.md b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/CREATE-REPOSITORY.md new file mode 100644 index 0000000000000..8b065ed49fbbd --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/CREATE-REPOSITORY.md @@ -0,0 +1,140 @@ +--- +{ + "title": "CREATE REPOSITORY", + "language": "en" +} + +--- + + + + + +## Description + +This statement is used to create a repository. Repositories are used for backup or restore. Only root or superuser users can create repositories. + +grammar: + +```sql +CREATE [READ ONLY] REPOSITORY `repo_name` +WITH [S3|hdfs] +ON LOCATION `repo_location` +PROPERTIES ("key"="value", ...); +``` + +illustrate: + +- Creation of repositories, accessing cloud storage directly through AWS s3 protocol, or accessing HDFS directly. +- If it is a read-only repository, restores can only be done on the repository. If not, backup and restore operations are available. +- PROPERTIES are different according to different types of S3 or hdfs, see the example for details. +- ON LOCATION : if it is S3 , here followed by the Bucket Name. + +## Example + +1. Create a repository named s3_repo. + +```sql +CREATE REPOSITORY `s3_repo` +WITH S3 +ON LOCATION "s3://s3-repo" +PROPERTIES +( + "s3.endpoint" = "http://s3-REGION.amazonaws.com", + "s3.region" = "s3-REGION", + "s3.access_key" = "AWS_ACCESS_KEY", + "s3.secret_key"="AWS_SECRET_KEY", + "s3.region" = "REGION" +); +``` + +2. Create a repository named hdfs_repo. + +```sql +CREATE REPOSITORY `hdfs_repo` +WITH hdfs +ON LOCATION "hdfs://hadoop-name-node:54310/path/to/repo/" +PROPERTIES +( + "fs.defaultFS"="hdfs://hadoop-name-node:54310", + "hadoop.username"="user" +); + +## Keywords + +``` + +6. Create a repository named minio_repo to link minio storage directly through the s3 protocol. + +```sql +CREATE REPOSITORY `minio_repo` +WITH S3 +ON LOCATION "s3://minio_repo" +PROPERTIES +( + "s3.endpoint" = "http://minio.com", + "s3.access_key" = "MINIO_USER", + "s3.secret_key"="MINIO_PASSWORD", + "s3.region" = "REGION", + "use_path_style" = "true" +); +``` + + +7. Create a repository named minio_repo via temporary security credentials. + +```sql +CREATE REPOSITORY `minio_repo` +WITH S3 +ON LOCATION "s3://minio_repo" +PROPERTIES +( + "s3.endpoint" = "AWS_ENDPOINT", + "s3.access_key" = "AWS_TEMP_ACCESS_KEY", + "s3.secret_key" = "AWS_TEMP_SECRET_KEY", + "s3.session_token" = "AWS_TEMP_TOKEN", + "s3.region" = "AWS_REGION" +) +``` + +8. Create repository using Tencent COS + +```sql +CREATE REPOSITORY `cos_repo` +WITH S3 +ON LOCATION "s3://backet1/" +PROPERTIES +( + "s3.access_key" = "ak", + "s3.secret_key" = "sk", + "s3.endpoint" = "http://cos.ap-beijing.myqcloud.com", + "s3.region" = "ap-beijing" +); +``` + +## Keywords + +CREATE, REPOSITORY + +## Best Practice + +1. A cluster can create multiple warehouses. Only users with ADMIN privileges can create repositories. +2. Any user can view the created repositories through the [SHOW REPOSITORIES](../../../../sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-REPOSITORIES) command. +3. When performing data migration operations, it is necessary to create the exact same warehouse in the source cluster and the destination cluster, so that the destination cluster can view the data snapshots backed up by the source cluster through this warehouse. \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/data-modification/backup-and-restore/DROP-REPOSITORY.md b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/DROP-REPOSITORY.md new file mode 100644 index 0000000000000..166bb223c8866 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/DROP-REPOSITORY.md @@ -0,0 +1,56 @@ +--- +{ + "title": "DROP REPOSITORY", + "language": "en" +} + +--- + + + + + +## Description + +This statement is used to delete a created repository. Only root or superuser users can delete repositories. + +grammar: + +```sql +DROP REPOSITORY `repo_name`; +``` + +illustrate: + +- Deleting a warehouse just deletes the warehouse's mapping in Doris, not the actual warehouse data. Once deleted, it can be mapped to the repository again by specifying the same LOCATION. + +## Example + +1. Delete the repository named example_repo: + +```sql +DROP REPOSITORY `example_repo`; +``` + +## Keywords + + DROP, REPOSITORY + +## Best Practice \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/data-modification/backup-and-restore/RESTORE.md b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/RESTORE.md new file mode 100644 index 0000000000000..eb04b4a3b0cf1 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/RESTORE.md @@ -0,0 +1,126 @@ +--- +{ + "title": "RESTORE", + "language": "en" +} + +--- + + + + + + +## Description + +This statement is used to restore the data backed up by the BACKUP command to the specified database. This command is an asynchronous operation. After the submission is successful, you need to check the progress through the SHOW RESTORE command. Restoring tables of type OLAP is only supported. + +grammar: + +```sql +RESTORE SNAPSHOT [db_name].{snapshot_name} +FROM `repository_name` +[ON|EXCLUDE] ( + `table_name` [PARTITION (`p1`, ...)] [AS `tbl_alias`], + ... +) +PROPERTIES ("key"="value", ...); +``` + +illustrate: + +- There can only be one executing BACKUP or RESTORE task under the same database. +- The tables and partitions that need to be restored are identified in the ON clause. If no partition is specified, all partitions of the table are restored by default. The specified table and partition must already exist in the warehouse backup. +- Tables and partitions that do not require recovery are identified in the EXCLUDE clause. All partitions of all other tables in the warehouse except the specified table or partition will be restored. +- The table name backed up in the warehouse can be restored to a new table through the AS statement. But the new table name cannot already exist in the database. The partition name cannot be modified. +- You can restore the backed up tables in the warehouse to replace the existing tables of the same name in the database, but you must ensure that the table structures of the two tables are exactly the same. The table structure includes: table name, column, partition, Rollup, etc. +- You can specify some partitions of the recovery table, and the system will check whether the partition Range or List can match. +- PROPERTIES currently supports the following properties: + - "backup_timestamp" = "2018-05-04-16-45-08": Specifies which time version of the corresponding backup to restore, required. This information can be obtained with the `SHOW SNAPSHOT ON repo;` statement. + - "replication_num" = "3": Specifies the number of replicas for the restored table or partition. Default is 3. If restoring an existing table or partition, the number of replicas must be the same as the number of replicas of the existing table or partition. At the same time, there must be enough hosts to accommodate multiple replicas. + - "reserve_replica" = "true": Default is false. When this property is true, the replication_num property is ignored and the restored table or partition will have the same number of replication as before the backup. Supports multiple tables or multiple partitions within a table with different replication number. + - "reserve_dynamic_partition_enable" = "true": Default is false. When this property is true, the restored table will have the same value of 'dynamic_partition_enable' as before the backup. if this property is not true, the restored table will set 'dynamic_partition_enable=false'. + - "timeout" = "3600": The task timeout period, the default is one day. in seconds. + - "meta_version" = 40: Use the specified meta_version to read the previously backed up metadata. Note that this parameter is used as a temporary solution and is only used to restore the data backed up by the old version of Doris. The latest version of the backup data already contains the meta version, no need to specify it. + - "clean_tables" : Indicates whether to clean up tables that do not belong to the restore target. For example, if the target db before the restore has tables that are not present in the snapshot, specifying `clean_tables` can drop these extra tables and move them into the recycle bin during the restore. + - This feature is supported since the Apache Doris 1.2.6 version + - "clean_partitions": Indicates whether to clean up partitions that do not belong to the restore target. For example, if the target table before the restore has partitions that are not present in the snapshot, specifying `clean_partitions` can drop these extra partitions and move them into the recycle bin during the restore. + - This feature is supported since the Apache Doris 1.2.6 version + +## Example + +1. Restore the table backup_tbl in backup snapshot_1 from example_repo to database example_db1, the time version is "2018-05-04-16-45-08". Revert to 1 copy: + +```sql +RESTORE SNAPSHOT example_db1.`snapshot_1` +FROM `example_repo` +ON ( `backup_tbl` ) +PROPERTIES +( + "backup_timestamp"="2018-05-04-16-45-08", + "replication_num" = "1" +); +``` + +2. Restore partitions p1, p2 of table backup_tbl in backup snapshot_2 from example_repo, and table backup_tbl2 to database example_db1, rename it to new_tbl, and the time version is "2018-05-04-17-11-01". The default reverts to 3 replicas: + +```sql +RESTORE SNAPSHOT example_db1.`snapshot_2` +FROM `example_repo` +ON +( + `backup_tbl` PARTITION (`p1`, `p2`), + `backup_tbl2` AS `new_tbl` +) +PROPERTIES +( + "backup_timestamp"="2018-05-04-17-11-01" +); +``` + +3. Restore all tables except for table backup_tbl in backup snapshot_3 from example_repo to database example_db1, the time version is "2018-05-04-18-12-18". + +```sql +RESTORE SNAPSHOT example_db1.`snapshot_3` +FROM `example_repo` +EXCLUDE ( `backup_tbl` ) +PROPERTIES +( + "backup_timestamp"="2018-05-04-18-12-18" +); +``` + +## Keywords + +``` +RESTORE +``` + +## Best Practice + +1. There can only be one ongoing recovery operation under the same database. + +2. The table backed up in the warehouse can be restored and replaced with the existing table of the same name in the database, but the table structure of the two tables must be completely consistent. The table structure includes: table name, columns, partitions, materialized views, and so on. + +3. When specifying a partial partition of the recovery table, the system will check whether the partition range can match. + +4. Efficiency of recovery operations: + + In the case of the same cluster size, the time-consuming of the restore operation is basically the same as the time-consuming of the backup operation. If you want to speed up the recovery operation, you can first restore only one copy by setting the `replication_num` parameter, and then adjust the number of copies by [ALTER TABLE PROPERTY](../../../../sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-PROPERTY), complete the copy. \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-BACKUP.md b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-BACKUP.md new file mode 100644 index 0000000000000..3aff3b81352c3 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-BACKUP.md @@ -0,0 +1,77 @@ +--- +{ + "title": "SHOW BACKUP", + "language": "en" +} +--- + + + + +## Description + +This statement is used to view BACKUP tasks + +grammar: + +```sql + SHOW BACKUP [FROM db_name] + [WHERE SnapshotName ( LIKE | = ) 'snapshot name'] +``` + +illustrate: + + 1. Only the most recent BACKUP task is saved in Doris. + 2. The meaning of each column is as follows: + - `JobId`: Unique job id + - `SnapshotName`: The name of the backup + - `DbName`: belongs to the database + - `State`: current stage + - `PENDING`: The initial state after submitting the job + - `SNAPSHOTING`: Executing snapshot + - `UPLOAD_SNAPSHOT`: Snapshot completed, ready to upload + - `UPLOADING`: Snapshot uploading + - `SAVE_META`: Save job meta information to a local file + - `UPLOAD_INFO`: Upload job meta information + - `FINISHED`: The job was successful + - `CANCELLED`: Job failed + - `BackupObjs`: Backed up tables and partitions + - `CreateTime`: task submission time + - `SnapshotFinishedTime`: Snapshot completion time + - `UploadFinishedTime`: Snapshot upload completion time + - `FinishedTime`: Job finish time + - `UnfinishedTasks`: Displays unfinished subtask ids during SNAPSHOTING and UPLOADING stages + - `Status`: If the job fails, display the failure message + - `Timeout`: Job timeout, in seconds + +## Example + +1. View the last BACKUP task under example_db. + + ```sql + SHOW BACKUP FROM example_db; + ``` + +## Keywords + + SHOW, BACKUP + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-CREATE-REPOSITORY.md b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-CREATE-REPOSITORY.md new file mode 100644 index 0000000000000..1c50389cb3b7f --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-CREATE-REPOSITORY.md @@ -0,0 +1,54 @@ +--- +{ + "title": "SHOW CREATE REPOSITORY", + "language": "en" +} +--- + + + + +## Description + +This statement is used to demonstrate the creation statement of a repository. + +grammar: + +```sql +SHOW CREATE REPOSITORY for repository_name; +``` + +illustrate: +- `repository_name`: repository name + +## Example + +1. Show the creation statement of the specified repository + + ```sql + SHOW CREATE REPOSITORY for test_repository + ``` + +## Keywords + + SHOW, CREATE, REPOSITORY + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-REPOSITORIES.md b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-REPOSITORIES.md new file mode 100644 index 0000000000000..8d4b527563aa4 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-REPOSITORIES.md @@ -0,0 +1,64 @@ +--- +{ + "title": "SHOW REPOSITORIES", + "language": "en" +} +--- + + + + + + +## Description + +This statement is used to view the currently created warehouse + +grammar: + +```sql +SHOW REPOSITORIES; +``` + +illustrate: + +1. The meanings of the columns are as follows: + RepoId: Unique repository ID + RepoName: repository name + CreateTime: The time when the repository was first created + IsReadOnly: Whether it is a read-only repository + Location: The root directory in the warehouse for backing up data + Broker: Dependent Broker + ErrMsg: Doris will regularly check the connectivity of the warehouse, if there is a problem, an error message will be displayed here + +## Example + +1. View the created repository: + +```sql + SHOW REPOSITORIES; +``` + +## Keywords + + SHOW, REPOSITORIES + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-RESTORE.md b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-RESTORE.md new file mode 100644 index 0000000000000..0c6a42cc06b97 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-RESTORE.md @@ -0,0 +1,85 @@ +--- +{ + "title": "SHOW RESTORE", + "language": "en" +} +--- + + + + +## Description + +This statement is used to view RESTORE tasks + +grammar: + +```SQL +SHOW [BRIEF] RESTORE [FROM DB_NAME] +``` + +illustrate: + 1. Only the most recent RESTORE task is saved in Doris. + 2. The meaning of each column is as follows: + JobId: Unique job id + Label: The name of the backup to restore + Timestamp: The time version of the backup to restore + DbName: belongs to the database + State: current stage + PENDING: The initial state after submitting the job + SNAPSHOTING: Executing snapshot + DOWNLOAD: The snapshot is complete, ready to download the snapshot in the repository + DOWNLOADING: Snapshot downloading + COMMIT: Snapshot download is complete, ready to take effect + COMMITING: in effect + FINISHED: The job was successful + CANCELLED: Job failed + AllowLoad: Whether to allow import when restoring (currently not supported) + ReplicationNum: Specifies the number of replicas to restore + RestoreJobs: Tables and partitions to restore + CreateTime: task submission time + MetaPreparedTime: Metadata preparation completion time + SnapshotFinishedTime: Snapshot completion time + DownloadFinishedTime: Snapshot download completion time + FinishedTime: Job finish time + UnfinishedTasks: Displays unfinished subtask ids during SNAPSHOTING, DOWNLOADING and COMMITING stages + Status: If the job fails, display the failure message + Timeout: Job timeout, in seconds + + + + 2. brief: only show key information of RESTORE tasks, columns RestoreObjs, Progress, TaskErrMsg will not show + + + +## Example + +1. View the latest RESTORE task under example_db. + + ```sql + SHOW RESTORE FROM example_db; + ``` + +## Keywords + + SHOW, RESTORE + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-SNAPSHOT.md b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-SNAPSHOT.md new file mode 100644 index 0000000000000..d9f2605b2bfe3 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-SNAPSHOT.md @@ -0,0 +1,75 @@ +--- +{ + "title": "SHOW SNAPSHOT", + "language": "en" +} +--- + + + + +## Description + +This statement is used to view backups that already exist in the repository. + +grammar: + +```sql +SHOW SNAPSHOT ON `repo_name` +[WHERE SNAPSHOT = "snapshot" [AND TIMESTAMP = "backup_timestamp"]]; +``` + +illustrate: + +1. The meanings of the columns are as follows: + Snapshot: The name of the backup + Timestamp: corresponds to the time version of the backup + Status: If the backup is normal, it will display OK, otherwise it will display an error message +2. If TIMESTAMP is specified, the following additional information is displayed: + Database: The name of the database to which the backup data originally belonged + Details: In the form of Json, the data directory and file structure of the entire backup are displayed + +## Example + +1. View the existing backups in the repository example_repo + + ```sql + SHOW SNAPSHOT ON example_repo; + ``` + +2. View only the backup named backup1 in the repository example_repo: + + ```sql + SHOW SNAPSHOT ON example_repo WHERE SNAPSHOT = "backup1"; + ``` + +3. View the details of the backup named backup1 in the warehouse example_repo with the time version "2018-05-05-15-34-26": + + ```sql + SHOW SNAPSHOT ON example_repo + WHERE SNAPSHOT = "backup1" AND TIMESTAMP = "2018-05-05-15-34-26"; + ``` + +## Keywords + + SHOW, SNAPSHOT + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/ALTER-ROUTINE-LOAD.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/ALTER-ROUTINE-LOAD.md new file mode 100644 index 0000000000000..4c6631ae77ab1 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/ALTER-ROUTINE-LOAD.md @@ -0,0 +1,124 @@ +--- +{ + "title": "ALTER ROUTINE LOAD", + "language": "en" +} +--- + + + + +## Description + +This syntax is used to modify an already created routine import job. + +Only jobs in the PAUSED state can be modified. + +grammar: + +```sql +ALTER ROUTINE LOAD FOR [db.]job_name +[job_properties] +FROM data_source +[data_source_properties] +``` + +1. `[db.]job_name` + + Specifies the job name to modify. + +2. `tbl_name` + + Specifies the name of the table to be imported. + +3. `job_properties` + + Specifies the job parameters that need to be modified. Currently, only the modification of the following parameters is supported: + + 1. `desired_concurrent_number` + 2. `max_error_number` + 3. `max_batch_interval` + 4. `max_batch_rows` + 5. `max_batch_size` + 6. `jsonpaths` + 7. `json_root` + 8. `strip_outer_array` + 9. `strict_mode` + 10. `timezone` + 11. `num_as_string` + 12. `fuzzy_parse` + 13. `partial_columns` + 14. `max_filter_ratio` + + +4. `data_source` + + The type of data source. Currently supports: + + KAFKA + +5. `data_source_properties` + + Relevant properties of the data source. Currently only supports: + + 1. `kafka_partitions` + 2. `kafka_offsets` + 3. `kafka_broker_list` + 4. `kafka_topic` + 5. Custom properties, such as `property.group.id` + + Note: + + 1. `kafka_partitions` and `kafka_offsets` are used to modify the offset of the kafka partition to be consumed, only the currently consumed partition can be modified. Cannot add partition. + +## Example + +1. Change `desired_concurrent_number` to 1 + + ```sql + ALTER ROUTINE LOAD FOR db1.label1 + PROPERTIES + ( + "desired_concurrent_number" = "1" + ); + ``` + +2. Modify `desired_concurrent_number` to 10, modify the offset of the partition, and modify the group id. + + ```sql + ALTER ROUTINE LOAD FOR db1.label1 + PROPERTIES + ( + "desired_concurrent_number" = "10" + ) + FROM kafka + ( + "kafka_partitions" = "0, 1, 2", + "kafka_offsets" = "100, 200, 100", + "property.group.id" = "new_group" + ); + ``` + +## Keywords + + ALTER, ROUTINE, LOAD + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/BROKER-LOAD.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/BROKER-LOAD.md new file mode 100644 index 0000000000000..ee0e41a05f953 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/BROKER-LOAD.md @@ -0,0 +1,570 @@ +--- +{ + "title": "BROKER LOAD", + "language": "en" +} + +--- + + +## Description + +This command is mainly used to import data on remote storage (such as S3, HDFS) through the Broker service process. + +```sql +LOAD LABEL load_label +( +data_desc1[, data_desc2, ...] +) +WITH BROKER broker_name +[broker_properties] +[load_properties] +[COMMENT "comment"]; +``` + +- `load_label` + + Each import needs to specify a unique Label. You can use this label to view the progress of the job later. + + `[database.]label_name` + +- `data_desc1` + + Used to describe a set of files that need to be imported. + + ```sql + [MERGE|APPEND|DELETE] + DATA INFILE + ( + "file_path1"[, file_path2, ...] + ) + [NEGATIVE] + INTO TABLE `table_name` + [PARTITION (p1, p2, ...)] + [COLUMNS TERMINATED BY "column_separator"] + [LINES TERMINATED BY "line_delimiter"] + [FORMAT AS "file_type"] + [COMPRESS_TYPE AS "compress_type"] + [(column_list)] + [COLUMNS FROM PATH AS (c1, c2, ...)] + [SET (column_mapping)] + [PRECEDING FILTER predicate] + [WHERE predicate] + [DELETE ON expr] + [ORDER BY source_sequence] + [PROPERTIES ("key1"="value1", ...)] + ``` + + - `[MERGE|APPEND|DELETE]` + + Data merge type. The default is APPEND, indicating that this import is a normal append write operation. The MERGE and DELETE types are only available for Unique Key model tables. The MERGE type needs to be used with the `[DELETE ON]` statement to mark the Delete Flag column. The DELETE type indicates that all data imported this time are deleted data. + + - `DATA INFILE` + + Specify the file path to be imported. Can be multiple. Wildcards can be used. The path must eventually match to a file, if it only matches a directory the import will fail. + + - `NEGATIVE` + + This keyword is used to indicate that this import is a batch of "negative" imports. This method is only for aggregate data tables with integer SUM aggregate type. This method will reverse the integer value corresponding to the SUM aggregate column in the imported data. Mainly used to offset previously imported wrong data. + + - `PARTITION(p1, p2, ...)` + + You can specify to import only certain partitions of the table. Data that is no longer in the partition range will be ignored. + + - `COLUMNS TERMINATED BY` + + Specifies the column separator. Only valid in CSV format. Only single-byte delimiters can be specified. + + - `LINES TERMINATED BY` + + Specifies the line delimiter. Only valid in CSV format. Only single-byte delimiters can be specified. + + - `FORMAT AS` + + Specifies the file type, CSV, PARQUET and ORC formats are supported. Default is CSV. + + - `COMPRESS_TYPE AS` + Specifies the file compress type, GZ/LZO/BZ2/LZ4FRAME/DEFLATE/LZOP + + - `column list` + + Used to specify the column order in the original file. For a detailed introduction to this part, please refer to the [Column Mapping, Conversion and Filtering](../../../../data-operate/import/import-scenes/load-data-convert.md) document. + + `(k1, k2, tmpk1)` + + - `COLUMNS FROM PATH AS` + + Specifies the columns to extract from the import file path. + + - `SET (column_mapping)` + + Specifies the conversion function for the column. + + - `PRECEDING FILTER predicate` + + Pre-filter conditions. The data is first concatenated into raw data rows in order according to `column list` and `COLUMNS FROM PATH AS`. Then filter according to the pre-filter conditions. For a detailed introduction to this part, please refer to the [Column Mapping, Conversion and Filtering](../../../../data-operate/import/import-scenes/load-data-convert.md) document. + + - `WHERE predicate` + + Filter imported data based on conditions. For a detailed introduction to this part, please refer to the [Column Mapping, Conversion and Filtering](../../../../data-operate/import/import-scenes/load-data-convert.md) document. + + - `DELETE ON expr` + + It needs to be used with the MEREGE import mode, only for the table of the Unique Key model. Used to specify the columns and calculated relationships in the imported data that represent the Delete Flag. + + - `ORDER BY` + + Tables only for the Unique Key model. Used to specify the column in the imported data that represents the Sequence Col. Mainly used to ensure data order when importing. + + - `PROPERTIES ("key1"="value1", ...)` + + Specify some parameters of the imported format. For example, if the imported file is in `json` format, you can specify parameters such as `json_root`, `jsonpaths`, `fuzzy parse`, etc. + + - enclose + + When the csv data field contains row delimiters or column delimiters, to prevent accidental truncation, single-byte characters can be specified as brackets for protection. For example, the column separator is ",", the bracket is "'", and the data is "a,'b,c'", then "b,c" will be parsed as a field. Note: when the bracket is `"`, trim\_double\_quotes must be set to true. + + - escape + + Used to escape characters that appear in a csv field identical to the enclosing characters. For example, if the data is "a,'b,'c'", enclose is "'", and you want "b,'c to be parsed as a field, you need to specify a single-byte escape character, such as "\", and then modify the data to "a,' b,\'c'". + +- `WITH BROKER broker_name` + + Specify the Broker service name to be used. In the public cloud Doris. Broker service name is `bos` + +- `broker_properties` + + Specifies the information required by the broker. This information is usually used by the broker to be able to access remote storage systems. Such as BOS or HDFS. See the [Broker](../../../../advanced/broker.md) documentation for specific information. + + ```text + ( + "key1" = "val1", + "key2" = "val2", + ... + ) + ``` + +- `load_properties` + + Specifies import-related parameters. The following parameters are currently supported: + + - `timeout` + + Import timeout. The default is 4 hours. in seconds. + + - `max_filter_ratio` + + The maximum tolerable proportion of data that can be filtered (for reasons such as data irregularity). Zero tolerance by default. The value range is 0 to 1. + + - `exec_mem_limit` + + Load memory limit. Default is 2GB. The unit is bytes. + + - `strict_mode` + + Whether to impose strict restrictions on data. Defaults to false. + + - `partial_columns` + + Boolean type, True means that use partial column update, the default value is false, this parameter is only allowed to be set when the table model is Unique and Merge on Write is used. + + - `timezone` + + Specify the time zone for some functions that are affected by time zones, such as `strftime/alignment_timestamp/from_unixtime`, etc. Please refer to the [timezone](../../../../advanced/time-zone.md) documentation for details. If not specified, the "Asia/Shanghai" timezone is used + + - `load_parallelism` + + It allows the user to set the parallelism of the load execution plan + on a single node when the broker load is submitted, default value is 1. + + - `send_batch_parallelism` + + Used to set the default parallelism for sending batch, if the value for parallelism exceed `max_send_batch_parallelism_per_job` in BE config, then the coordinator BE will use the value of `max_send_batch_parallelism_per_job`. + + - `load_to_single_tablet` + + Boolean type, True means that one task can only load data to one tablet in the corresponding partition at a time. The default value is false. The number of tasks for the job depends on the overall concurrency. This parameter can only be set when loading data into the OLAP table with random bucketing. + + - priority + + Set the priority of the load job, there are three options: `HIGH/NORMAL/LOW`, use `NORMAL` priority as default. The pending broker load jobs which have higher priority will be chosen to execute earlier. + +- comment + + Specify the comment for the import job. The comment can be viewed in the `show load` statement. + +:::tip Tips +This feature is supported since the Apache Doris 1.2.3 version +::: + +## Example + +1. Import a batch of data from HDFS + + ```sql + LOAD LABEL example_db.label1 + ( + DATA INFILE("hdfs://hdfs_host:hdfs_port/input/file.txt") + INTO TABLE `my_table` + COLUMNS TERMINATED BY "," + ) + WITH BROKER hdfs + ( + "username"="hdfs_user", + "password"="hdfs_password" + ); + ``` + + Import the file `file.txt`, separated by commas, into the table `my_table`. + +2. Import data from HDFS, using wildcards to match two batches of files in two batches. into two tables separately. + + ```sql + LOAD LABEL example_db.label2 + ( + DATA INFILE("hdfs://hdfs_host:hdfs_port/input/file-10*") + INTO TABLE `my_table1` + PARTITION (p1) + COLUMNS TERMINATED BY "," + (k1, tmp_k2, tmp_k3) + SET ( + k2 = tmp_k2 + 1, + k3 = tmp_k3 + 1 + ) + DATA INFILE("hdfs://hdfs_host:hdfs_port/input/file-20*") + INTO TABLE `my_table2` + COLUMNS TERMINATED BY "," + (k1, k2, k3) + ) + WITH BROKER hdfs + ( + "username"="hdfs_user", + "password"="hdfs_password" + ); + ``` + + Import two batches of files `file-10*` and `file-20*` using wildcard matching. Imported into two tables `my_table1` and `my_table2` respectively. Where `my_table1` specifies to import into partition `p1`, and will import the values of the second and third columns in the source file +1. + +3. Import a batch of data from HDFS. + + ```sql + LOAD LABEL example_db.label3 + ( + DATA INFILE("hdfs://hdfs_host:hdfs_port/user/doris/data/*/*") + INTO TABLE `my_table` + COLUMNS TERMINATED BY "\\x01" + ) + WITH BROKER my_hdfs_broker + ( + "username" = "", + "password" = "", + "fs.defaultFS" = "hdfs://my_ha", + "dfs.nameservices" = "my_ha", + "dfs.ha.namenodes.my_ha" = "my_namenode1, my_namenode2", + "dfs.namenode.rpc-address.my_ha.my_namenode1" = "nn1_host:rpc_port", + "dfs.namenode.rpc-address.my_ha.my_namenode2" = "nn2_host:rpc_port", + "dfs.client.failover.proxy.provider.my_ha" = "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider" + ); + ``` + + Specify the delimiter as Hive's default delimiter `\\x01`, and use the wildcard * to specify all files in all directories under the `data` directory. Use simple authentication while configuring namenode HA. + +4. Import data in Parquet format and specify FORMAT as parquet. The default is to judge by the file suffix + + ```sql + LOAD LABEL example_db.label4 + ( + DATA INFILE("hdfs://hdfs_host:hdfs_port/input/file") + INTO TABLE `my_table` + FORMAT AS "parquet" + (k1, k2, k3) + ) + WITH BROKER hdfs + ( + "username"="hdfs_user", + "password"="hdfs_password" + ); + ``` + +5. Import the data and extract the partition field in the file path + + ```sql + LOAD LABEL example_db.label10 + ( + DATA INFILE("hdfs://hdfs_host:hdfs_port/input/city=beijing/*/*") + INTO TABLE `my_table` + FORMAT AS "csv" + (k1, k2, k3) + COLUMNS FROM PATH AS (city, utc_date) + ) + WITH BROKER hdfs + ( + "username"="hdfs_user", + "password"="hdfs_password" + ); + ``` + + The columns in the `my_table` table are `k1, k2, k3, city, utc_date`. + + The `hdfs://hdfs_host:hdfs_port/user/doris/data/input/dir/city=beijing` directory includes the following files: + + ```text + hdfs://hdfs_host:hdfs_port/input/city=beijing/utc_date=2020-10-01/0000.csv + hdfs://hdfs_host:hdfs_port/input/city=beijing/utc_date=2020-10-02/0000.csv + hdfs://hdfs_host:hdfs_port/input/city=tianji/utc_date=2020-10-03/0000.csv + hdfs://hdfs_host:hdfs_port/input/city=tianji/utc_date=2020-10-04/0000.csv + ``` + + The file only contains three columns of `k1, k2, k3`, and the two columns of `city, utc_date` will be extracted from the file path. + +6. Filter the data to be imported. + + ```sql + LOAD LABEL example_db.label6 + ( + DATA INFILE("hdfs://host:port/input/file") + INTO TABLE `my_table` + (k1, k2, k3) + SET ( + k2 = k2 + 1 + ) + PRECEDING FILTER k1 = 1 + WHERE k1 > k2 + ) + WITH BROKER hdfs + ( + "username"="user", + "password"="pass" + ); + ``` + + Only in the original data, k1 = 1, and after transformation, rows with k1 > k2 will be imported. + +7. Import data, extract the time partition field in the file path, and the time contains %3A (in the hdfs path, ':' is not allowed, all ':' will be replaced by %3A) + + ```sql + LOAD LABEL example_db.label7 + ( + DATA INFILE("hdfs://host:port/user/data/*/test.txt") + INTO TABLE `tbl12` + COLUMNS TERMINATED BY "," + (k2,k3) + COLUMNS FROM PATH AS (data_time) + SET ( + data_time=str_to_date(data_time, '%Y-%m-%d %H%%3A%i%%3A%s') + ) + ) + WITH BROKER hdfs + ( + "username"="user", + "password"="pass" + ); + ``` + + There are the following files in the path: + + ```text + /user/data/data_time=2020-02-17 00%3A00%3A00/test.txt + /user/data/data_time=2020-02-18 00%3A00%3A00/test.txt + ``` + + The table structure is: + + ```text + data_time DATETIME, + k2 INT, + k3 INT + ``` + +8. Import a batch of data from HDFS, specify the timeout and filter ratio. Broker with clear text my_hdfs_broker. Simple authentication. And delete the columns in the original data that match the columns with v2 greater than 100 in the imported data, and other columns are imported normally + + ```sql + LOAD LABEL example_db.label8 + ( + MERGE DATA INFILE("HDFS://test:802/input/file") + INTO TABLE `my_table` + (k1, k2, k3, v2, v1) + DELETE ON v2 > 100 + ) + WITH HDFS + ( + "hadoop.username"="user", + "password"="pass" + ) + PROPERTIES + ( + "timeout" = "3600", + "max_filter_ratio" = "0.1" + ); + ``` + + Import using the MERGE method. `my_table` must be a table with Unique Key. When the value of the v2 column in the imported data is greater than 100, the row is considered a delete row. + + The import task timeout is 3600 seconds, and the error rate is allowed to be within 10%. + +9. Specify the source_sequence column when importing to ensure the replacement order in the UNIQUE_KEYS table: + + ```sql + LOAD LABEL example_db.label9 + ( + DATA INFILE("HDFS://test:802/input/file") + INTO TABLE `my_table` + COLUMNS TERMINATED BY "," + (k1,k2,source_sequence,v1,v2) + ORDER BY source_sequence + ) + WITH HDFS + ( + "hadoop.username"="user", + "password"="pass" + ) + ``` + + `my_table` must be an Unique Key model table with Sequence Col specified. The data will be ordered according to the value of the `source_sequence` column in the source data. + +10. Import a batch of data from HDFS, specify the file format as `json`, and specify parameters of `json_root` and `jsonpaths`. + + ```sql + LOAD LABEL example_db.label10 + ( + DATA INFILE("HDFS://test:port/input/file.json") + INTO TABLE `my_table` + FORMAT AS "json" + PROPERTIES( + "json_root" = "$.item", + "jsonpaths" = "[$.id, $.city, $.code]" + ) + ) + with HDFS ( + "hadoop.username" = "user" + "password" = "" + ) + PROPERTIES + ( + "timeout"="1200", + "max_filter_ratio"="0.1" + ); + ``` + + `jsonpaths` can be use with `column list` and `SET(column_mapping)`: + + ```sql + LOAD LABEL example_db.label10 + ( + DATA INFILE("HDFS://test:port/input/file.json") + INTO TABLE `my_table` + FORMAT AS "json" + (id, code, city) + SET (id = id * 10) + PROPERTIES( + "json_root" = "$.item", + "jsonpaths" = "[$.id, $.code, $.city]" + ) + ) + with HDFS ( + "hadoop.username" = "user" + "password" = "" + ) + PROPERTIES + ( + "timeout"="1200", + "max_filter_ratio"="0.1" + ); + ``` + +11. Load data in csv format from cos(Tencent Cloud Object Storage). + + ```SQL + LOAD LABEL example_db.label10 + ( + DATA INFILE("cosn://my_bucket/input/file.csv") + INTO TABLE `my_table` + (k1, k2, k3) + ) + WITH BROKER "broker_name" + ( + "fs.cosn.userinfo.secretId" = "xxx", + "fs.cosn.userinfo.secretKey" = "xxxx", + "fs.cosn.bucket.endpoint_suffix" = "cos.xxxxxxxxx.myqcloud.com" + ) + ``` + +12. Load CSV date and trim double quotes and skip first 5 lines + + ```SQL + LOAD LABEL example_db.label12 + ( + DATA INFILE("cosn://my_bucket/input/file.csv") + INTO TABLE `my_table` + (k1, k2, k3) + PROPERTIES("trim_double_quotes" = "true", "skip_lines" = "5") + ) + WITH BROKER "broker_name" + ( + "fs.cosn.userinfo.secretId" = "xxx", + "fs.cosn.userinfo.secretKey" = "xxxx", + "fs.cosn.bucket.endpoint_suffix" = "cos.xxxxxxxxx.myqcloud.com" + ) + ``` + +## Keywords + + BROKER, LOAD + +## Best Practice + +1. Check the import task status + + Broker Load is an asynchronous import process. The successful execution of the statement only means that the import task is submitted successfully, and does not mean that the data import is successful. The import status needs to be viewed through the [SHOW LOAD](../../../../sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD) command. + +2. Cancel the import task + + Import tasks that have been submitted but not yet completed can be canceled by the [CANCEL LOAD](./CANCEL-LOAD.md) command. After cancellation, the written data will also be rolled back and will not take effect. + +3. Label, import transaction, multi-table atomicity + + All import tasks in Doris are atomic. And the import of multiple tables in the same import task can also guarantee atomicity. At the same time, Doris can also use the Label mechanism to ensure that the data imported is not lost or heavy. For details, see the [Import Transactions and Atomicity](../../../../data-operate/import/import-scenes/load-atomicity.md) documentation. + +4. Column mapping, derived columns and filtering + + Doris can support very rich column transformation and filtering operations in import statements. Most built-in functions and UDFs are supported. For how to use this function correctly, please refer to the [Column Mapping, Conversion and Filtering](../../../../data-operate/import/import-scenes/load-data-convert.md) document. + +5. Error data filtering + + Doris' import tasks can tolerate a portion of malformed data. Tolerated via `max_filter_ratio` setting. The default is 0, which means that the entire import task will fail when there is an error data. If the user wants to ignore some problematic data rows, the secondary parameter can be set to a value between 0 and 1, and Doris will automatically skip the rows with incorrect data format. + + For some calculation methods of the tolerance rate, please refer to the [Column Mapping, Conversion and Filtering](../../../../data-operate/import/import-scenes/load-data-convert.md) document. + +6. Strict Mode + + The `strict_mode` attribute is used to set whether the import task runs in strict mode. The format affects the results of column mapping, transformation, and filtering. For a detailed description of strict mode, see the [strict mode](../../../../data-operate/import/import-scenes/load-strict-mode.md) documentation. + +7. Timeout + + The default timeout for Broker Load is 4 hours. from the time the task is submitted. If it does not complete within the timeout period, the task fails. + +8. Limits on data volume and number of tasks + + Broker Load is suitable for importing data within 100GB in one import task. Although theoretically there is no upper limit on the amount of data imported in one import task. But committing an import that is too large results in a longer run time, and the cost of retrying after a failure increases. + + At the same time, limited by the size of the cluster, we limit the maximum amount of imported data to the number of ComputeNode nodes * 3GB. In order to ensure the rational use of system resources. If there is a large amount of data to be imported, it is recommended to divide it into multiple import tasks. + + Doris also limits the number of import tasks running simultaneously in the cluster, usually ranging from 3 to 10. Import jobs submitted after that are queued. The maximum queue length is 100. Subsequent submissions will be rejected outright. Note that the queue time is also calculated into the total job time. If it times out, the job is canceled. Therefore, it is recommended to reasonably control the frequency of job submission by monitoring the running status of the job. + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/CANCEL-EXPORT.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/CANCEL-EXPORT.md new file mode 100644 index 0000000000000..08218c6e80899 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/CANCEL-EXPORT.md @@ -0,0 +1,74 @@ +--- +{ + "title": "CANCEL EXPORT", + "language": "en" +} + +--- + + + + + +## Description + +This statement is used to undo an export job for the specified label. Or batch undo export jobs via fuzzy matching + +```sql +CANCEL EXPORT +[FROM db_name] +WHERE [LABEL = "export_label" | LABEL like "label_pattern" | STATE = "PENDING/IN_QUEUE/EXPORTING"] +``` + +## Example + +1. Cancel the export job whose label is `example_db_test_export_label` on the database example_db + + ```sql + CANCEL EXPORT + FROM example_db + WHERE LABEL = "example_db_test_export_label" and STATE = "EXPORTING"; + ``` + +2. Cancel all export jobs containing example* on the database example*db. + + ```sql + CANCEL EXPORT + FROM example_db + WHERE LABEL like "%example%"; + ``` + +3. Cancel all export jobs which state are "PENDING" + + ```sql + CANCEL EXPORT + FROM example_db + WHERE STATE = "PENDING"; + ``` + +## Keywords + + CANCEL, EXPORT + +## Best Practice + +1. Only pending export jobs in PENDING, IN_QUEUE,EXPORTING state can be canceled. +2. When performing batch undo, Doris does not guarantee the atomic undo of all corresponding export jobs. That is, it is possible that only some of the export jobs were successfully undone. The user can view the job status through the SHOW EXPORT statement and try to execute the CANCEL EXPORT statement repeatedly. +3. When the job of the `EXPORTING` state is revoked, part of the data may have been exported to the storage system, and the user needs to process (delete) this section to export data. \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/CANCEL-LOAD.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/CANCEL-LOAD.md new file mode 100644 index 0000000000000..92c0470cf1003 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/CANCEL-LOAD.md @@ -0,0 +1,82 @@ +--- +{ + "title": "CANCEL LOAD", + "language": "en" +} + +--- + + + + +## Description + +This statement is used to undo an import job for the specified label. Or batch undo import jobs via fuzzy matching + +```sql +CANCEL LOAD +[FROM db_name] +WHERE [LABEL = "load_label" | LABEL like "label_pattern" | STATE = "PENDING/ETL/LOADING"] +``` + +Notice: Cancel by State is supported since 1.2.0. + +## Example + +1. Cancel the import job whose label is `example_db_test_load_label` on the database example_db + + ```sql + CANCEL LOAD + FROM example_db + WHERE LABEL = "example_db_test_load_label"; + ``` + +2. Cancel all import jobs containing example* on the database example*db. + + ```sql + CANCEL LOAD + FROM example_db + WHERE LABEL like "example_"; + ``` + + + +3. Cancel all import jobs which state are "LOADING" + + ```sql + CANCEL LOAD + FROM example_db + WHERE STATE = "loading"; + ``` + +:::tip Tips +This feature is supported since the Apache Doris 1.2 version +::: + + +## Keywords + + CANCEL, LOAD + +## Best Practice + +1. Only pending import jobs in PENDING, ETL, LOADING state can be canceled. +2. When performing batch undo, Doris does not guarantee the atomic undo of all corresponding import jobs. That is, it is possible that only some of the import jobs were successfully undone. The user can view the job status through the SHOW LOAD statement and try to execute the CANCEL LOAD statement repeatedly. + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/CLEAN-LABEL.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/CLEAN-LABEL.md new file mode 100644 index 0000000000000..5d352bf4d0efe --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/CLEAN-LABEL.md @@ -0,0 +1,56 @@ +--- +{ + "title": "CLEAN LABEL", + "language": "en" +} +--- + + + +## Description + +For manual cleanup of historical load jobs. After cleaning, the Label can be reused. + +Syntax: + +```sql +CLEAN LABEL [label] FROM db; +``` + +## Example + +1. Clean label label1 from database db1 + + ```sql + CLEAN LABEL label1 FROM db1; + ``` + +2. Clean all labels from database db1 + + ```sql + CLEAN LABEL FROM db1; + ``` + +## Keywords + + CLEAN, LABEL + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/CREATE-ROUTINE-LOAD.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/CREATE-ROUTINE-LOAD.md new file mode 100644 index 0000000000000..1d9d0e7a2481a --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/CREATE-ROUTINE-LOAD.md @@ -0,0 +1,632 @@ +--- +{ + "title": "CREATE ROUTINE LOAD", + "language": "en" +} +--- + + + + +## Description + +The Routine Load function allows users to submit a resident import task, and import data into Doris by continuously reading data from a specified data source. + +Currently, only data in CSV or Json format can be imported from Kakfa through unauthenticated or SSL authentication. [Example of importing data in Json format](../../../../data-operate/import/import-way/routine-load-manual.md#Example_of_importing_data_in_Json_format) + +grammar: + +```sql +CREATE ROUTINE LOAD [db.]job_name [ON tbl_name] +[merge_type] +[load_properties] +[job_properties] +FROM data_source [data_source_properties] +[COMMENT "comment"] +``` + +- `[db.]job_name` + + The name of the import job. Within the same database, only one job with the same name can be running. + +- `tbl_name` + + Specifies the name of the table to be imported.Optional parameter, If not specified, the dynamic table method will + be used, which requires the data in Kafka to contain table name information. Currently, only the table name can be + obtained from the Kafka value, and it needs to conform to the format of "table_name|{"col1": "val1", "col2": "val2"}" + for JSON data. The "tbl_name" represents the table name, and "|" is used as the delimiter between the table name and + the table data. The same format applies to CSV data, such as "table_name|val1,val2,val3". It is important to note that + the "table_name" must be consistent with the table name in Doris, otherwise it may cause import failures. + + Tips: The `columns_mapping` parameter is not supported for dynamic tables. If your table structure is consistent with + the table structure in Doris and there is a large amount of table information to be imported, this method will be the + best choice. + +- `merge_type` + + Data merge type. The default is APPEND, which means that the imported data are ordinary append write operations. The MERGE and DELETE types are only available for Unique Key model tables. The MERGE type needs to be used with the [DELETE ON] statement to mark the Delete Flag column. The DELETE type means that all imported data are deleted data. + + Tips: When using dynamic multiple tables, please note that this parameter should be consistent with the type of each dynamic table, otherwise it will result in import failure. + +- load_properties + + Used to describe imported data. The composition is as follows: + + ```SQL + [column_separator], + [columns_mapping], + [preceding_filter], + [where_predicates], + [partitions], + [DELETE ON], + [ORDER BY] + ``` + + - `column_separator` + + Specifies the column separator, defaults to `\t` + + `COLUMNS TERMINATED BY ","` + + - `columns_mapping` + + It is used to specify the mapping relationship between file columns and columns in the table, as well as various column transformations. For a detailed introduction to this part, you can refer to the [Column Mapping, Transformation and Filtering] document. + + `(k1, k2, tmpk1, k3 = tmpk1 + 1)` + + Tips: Dynamic multiple tables are not supported. + + - `preceding_filter` + + Filter raw data. For a detailed introduction to this part, you can refer to the [Column Mapping, Transformation and Filtering] document. + + Tips: Dynamic multiple tables are not supported. + + - `where_predicates` + + Filter imported data based on conditions. For a detailed introduction to this part, you can refer to the [Column Mapping, Transformation and Filtering] document. + + `WHERE k1 > 100 and k2 = 1000` + + Tips: When using dynamic multiple tables, please note that this parameter should be consistent with the type of each dynamic table, otherwise it will result in import failure. + + - `partitions` + + Specify in which partitions of the import destination table. If not specified, it will be automatically imported into the corresponding partition. + + `PARTITION(p1, p2, p3)` + + Tips: When using dynamic multiple tables, please note that this parameter should conform to each dynamic table, otherwise it may cause import failure. + + - `DELETE ON` + + It needs to be used with the MEREGE import mode, only for the table of the Unique Key model. Used to specify the columns and calculated relationships in the imported data that represent the Delete Flag. + + `DELETE ON v3 >100` + + Tips: When using dynamic multiple tables, please note that this parameter should conform to each dynamic table, otherwise it may cause import failure. + + - `ORDER BY` + + Tables only for the Unique Key model. Used to specify the column in the imported data that represents the Sequence Col. Mainly used to ensure data order when importing. + + Tips: When using dynamic multiple tables, please note that this parameter should conform to each dynamic table, otherwise it may cause import failure. + +- `job_properties` + + Common parameters for specifying routine import jobs. + + ```text + PROPERTIES ( + "key1" = "val1", + "key2" = "val2" + ) + ``` + + Currently we support the following parameters: + + 1. `desired_concurrent_number` + + Desired concurrency. A routine import job will be divided into multiple subtasks for execution. This parameter specifies the maximum number of tasks a job can execute concurrently. Must be greater than 0. Default is 5. + + This degree of concurrency is not the actual degree of concurrency. The actual degree of concurrency will be comprehensively considered by the number of nodes in the cluster, the load situation, and the situation of the data source. + + `"desired_concurrent_number" = "3"` + + 2. `max_batch_interval/max_batch_rows/max_batch_size` + + These three parameters represent: + + 1. The maximum execution time of each subtask, in seconds. Must be greater than or equal to 1. The default is 10. + 2. The maximum number of lines read by each subtask. Must be greater than or equal to 200000. The default is 200000. + 3. The maximum number of bytes read by each subtask. The unit is bytes and the range is 100MB to 10GB. The default is 100MB. + + These three parameters are used to control the execution time and processing volume of a subtask. When either one reaches the threshold, the task ends. + + ```text + "max_batch_interval" = "20", + "max_batch_rows" = "300000", + "max_batch_size" = "209715200" + ``` + + 3. `max_error_number` + + The maximum number of error lines allowed within the sampling window. Must be greater than or equal to 0. The default is 0, which means no error lines are allowed. + + The sampling window is `max_batch_rows * 10`. That is, if the number of error lines is greater than `max_error_number` within the sampling window, the routine operation will be suspended, requiring manual intervention to check data quality problems. + + Rows that are filtered out by where conditions are not considered error rows. + + 4. `strict_mode` + + Whether to enable strict mode, the default is off. If enabled, the column type conversion of non-null raw data will be filtered if the result is NULL. Specify as: + + `"strict_mode" = "true"` + + The strict mode mode means strict filtering of column type conversions during the load process. The strict filtering strategy is as follows: + + 1. For column type conversion, if strict mode is true, the wrong data will be filtered. The error data here refers to the fact that the original data is not null, and the result is a null value after participating in the column type conversion. + 2. When a loaded column is generated by a function transformation, strict mode has no effect on it. + 3. For a column type loaded with a range limit, if the original data can pass the type conversion normally, but cannot pass the range limit, strict mode will not affect it. For example, if the type is decimal(1,0) and the original data is 10, it is eligible for type conversion but not for column declarations. This data strict has no effect on it. + + **strict mode and load relationship of source data** + + Here is an example of a column type of TinyInt. + + > Note: When a column in a table allows a null value to be loaded + + | source data | source data example | string to int | strict_mode | result | + | ----------- | ------------------- | ------------- | ------------- | ---------------------- | + | null | `\N` | N/A | true or false | NULL | + | not null | aaa or 2000 | NULL | true | invalid data(filtered) | + | not null | aaa | NULL | false | NULL | + | not null | 1 | 1 | true or false | correct data | + + Here the column type is Decimal(1,0) + + > Note: When a column in a table allows a null value to be loaded + + | source data | source data example | string to int | strict_mode | result | + | ----------- | ------------------- | ------------- | ------------- | ---------------------- | + | null | `\N` | N/A | true or false | NULL | + | not null | aaa | NULL | true | invalid data(filtered) | + | not null | aaa | NULL | false | NULL | + | not null | 1 or 10 | 1 | true or false | correct data | + + > Note: 10 Although it is a value that is out of range, because its type meets the requirements of decimal, strict mode has no effect on it. 10 will eventually be filtered in other ETL processing flows. But it will not be filtered by strict mode. + + 5. `timezone` + + Specifies the time zone used by the import job. The default is to use the Session's timezone parameter. This parameter affects the results of all time zone-related functions involved in the import. + + 6. `format` + + Specify the import data format, the default is csv, and the json format is supported. + + 7. `jsonpaths` + + When the imported data format is json, the fields in the Json data can be extracted by specifying jsonpaths. + + `-H "jsonpaths: [\"$.k2\", \"$.k1\"]"` + + 8. `strip_outer_array` + + When the imported data format is json, strip_outer_array is true, indicating that the Json data is displayed in the form of an array, and each element in the data will be regarded as a row of data. The default value is false. + + `-H "strip_outer_array: true"` + + 9. `json_root` + + When the import data format is json, you can specify the root node of the Json data through json_root. Doris will extract the elements of the root node through json_root for parsing. Default is empty. + + `-H "json_root: $.RECORDS"` + 10. `send_batch_parallelism` + + Integer, Used to set the default parallelism for sending batch, if the value for parallelism exceed `max_send_batch_parallelism_per_job` in BE config, then the coordinator BE will use the value of `max_send_batch_parallelism_per_job`. + + 11. `load_to_single_tablet` + Boolean type, True means that one task can only load data to one tablet in the corresponding partition at a time. The default value is false. This parameter can only be set when loading data into the OLAP table with random bucketing. + + 12. `partial_columns` + Boolean type, True means that use partial column update, the default value is false, this parameter is only allowed to be set when the table model is Unique and Merge on Write is used. Multi-table does not support this parameter. + + 13. `max_filter_ratio` + The maximum allowed filtering rate within the sampling window. Must be between 0 and 1. The default value is 0. + + The sampling window is `max_batch_rows * 10`. That is, if the number of error lines / total lines is greater than `max_filter_ratio` within the sampling window, the routine operation will be suspended, requiring manual intervention to check data quality problems. + + Rows that are filtered out by where conditions are not considered error rows. + + 14. `enclose` + When the csv data field contains row delimiters or column delimiters, to prevent accidental truncation, single-byte characters can be specified as brackets for protection. For example, the column separator is ",", the bracket is "'", and the data is "a,'b,c'", then "b,c" will be parsed as a field. + Note: when the bracket is `"`, `trim\_double\_quotes` must be set to true. + + 15. `escape` + Used to escape characters that appear in a csv field identical to the enclosing characters. For example, if the data is "a,'b,'c'", enclose is "'", and you want "b,'c to be parsed as a field, you need to specify a single-byte escape character, such as `\`, and then modify the data to `a,' b,\'c'`. + +- `FROM data_source [data_source_properties]` + + The type of data source. Currently supports: + + ```text + FROM KAFKA + ( + "key1" = "val1", + "key2" = "val2" + ) + ``` + + `data_source_properties` supports the following data source properties: + + 1. `kafka_broker_list` + + Kafka's broker connection information. The format is ip:host. Separate multiple brokers with commas. + + `"kafka_broker_list" = "broker1:9092,broker2:9092"` + + 2. `kafka_topic` + + Specifies the Kafka topic to subscribe to. + + `"kafka_topic" = "my_topic"` + + 3. `kafka_partitions/kafka_offsets` + + Specify the kafka partition to be subscribed to, and the corresponding starting offset of each partition. If a time is specified, consumption will start at the nearest offset greater than or equal to the time. + + offset can specify a specific offset from 0 or greater, or: + + - `OFFSET_BEGINNING`: Start subscription from where there is data. + - `OFFSET_END`: subscribe from the end. + - Time format, such as: "2021-05-22 11:00:00" + + If not specified, all partitions under topic will be subscribed from `OFFSET_END` by default. + + ```text + "kafka_partitions" = "0,1,2,3", + "kafka_offsets" = "101,0,OFFSET_BEGINNING,OFFSET_END" + ``` + + ```text + "kafka_partitions" = "0,1,2,3", + "kafka_offsets" = "2021-05-22 11:00:00,2021-05-22 11:00:00,2021-05-22 11:00:00" + ``` + + Note that the time format cannot be mixed with the OFFSET format. + + 4. `property` + + Specify custom kafka parameters. The function is equivalent to the "--property" parameter in the kafka shell. + + When the value of the parameter is a file, you need to add the keyword: "FILE:" before the value. + + For how to create a file, please refer to the [CREATE FILE](../../../Data-Definition-Statements/Create/CREATE-FILE) command documentation. + + For more supported custom parameters, please refer to the configuration items on the client side in the official CONFIGURATION document of librdkafka. Such as: + + ```text + "property.client.id" = "12345", + "property.ssl.ca.location" = "FILE:ca.pem" + ``` + + 1. When connecting to Kafka using SSL, you need to specify the following parameters: + + ```text + "property.security.protocol" = "ssl", + "property.ssl.ca.location" = "FILE:ca.pem", + "property.ssl.certificate.location" = "FILE:client.pem", + "property.ssl.key.location" = "FILE:client.key", + "property.ssl.key.password" = "abcdefg" + ``` + + in: + + `property.security.protocol` and `property.ssl.ca.location` are required to indicate the connection method is SSL and the location of the CA certificate. + + If client authentication is enabled on the Kafka server side, thenAlso set: + + ```text + "property.ssl.certificate.location" + "property.ssl.key.location" + "property.ssl.key.password" + ``` + + They are used to specify the client's public key, private key, and password for the private key, respectively. + + 2. Specify the default starting offset of the kafka partition + + If `kafka_partitions/kafka_offsets` is not specified, all partitions are consumed by default. + + At this point, you can specify `kafka_default_offsets` to specify the starting offset. Defaults to `OFFSET_END`, i.e. subscribes from the end. + + Example: + + ```text + "property.kafka_default_offsets" = "OFFSET_BEGINNING" + ``` +- comment + + Comment for the routine load job. + +:::tip Tips +This feature is supported since the Apache Doris 1.2.3 version +::: + +<<<<<<<< HEAD:versioned_docs/version-3.0/sql-manual/sql-statements/data-modification/load-and-export/CREATE-ROUTINE-LOAD.md +## Example +======== +## Examples +>>>>>>>> ac43c88d43b68f907eafd82a2629cea01b097093:versioned_docs/version-2.1/sql-manual/sql-statements/data-modification/load-and-export/CREATE-ROUTINE-LOAD.md + +1. Create a Kafka routine import task named test1 for example_tbl of example_db. Specify the column separator and group.id and client.id, and automatically consume all partitions by default, and start subscribing from the location where there is data (OFFSET_BEGINNING) + + + + ```sql + CREATE ROUTINE LOAD example_db.test1 ON example_tbl + COLUMNS TERMINATED BY ",", + COLUMNS(k1, k2, k3, v1, v2, v3 = k1 * 100) + PROPERTIES + ( + "desired_concurrent_number"="3", + "max_batch_interval" = "20", + "max_batch_rows" = "300000", + "max_batch_size" = "209715200", + "strict_mode" = "false" + ) + FROM KAFKA + ( + "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", + "kafka_topic" = "my_topic", + "property.group.id" = "xxx", + "property.client.id" = "xxx", + "property.kafka_default_offsets" = "OFFSET_BEGINNING" + ); + ``` + +2. Create a Kafka routine dynamic multiple tables import task named "test1" for the "example_db". Specify the column delimiter, group.id, and client.id, and automatically consume all partitions, subscribing from the position with data (OFFSET_BEGINNING). + +Assuming that we need to import data from Kafka into tables "test1" and "test2" in the "example_db", we create a routine import task named "test1". At the same time, we write the data in "test1" and "test2" to a Kafka topic named "my_topic" so that data from Kafka can be imported into both tables through a routine import task. + + ```sql + CREATE ROUTINE LOAD example_db.test1 + PROPERTIES + ( + "desired_concurrent_number"="3", + "max_batch_interval" = "20", + "max_batch_rows" = "300000", + "max_batch_size" = "209715200", + "strict_mode" = "false" + ) + FROM KAFKA + ( + "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", + "kafka_topic" = "my_topic", + "property.group.id" = "xxx", + "property.client.id" = "xxx", + "property.kafka_default_offsets" = "OFFSET_BEGINNING" + ); + ``` + +3. Create a Kafka routine import task named test1 for example_tbl of example_db. Import tasks are in strict mode. + + + + ```sql + CREATE ROUTINE LOAD example_db.test1 ON example_tbl + COLUMNS(k1, k2, k3, v1, v2, v3 = k1 * 100), + PRECEDING FILTER k1 = 1, + WHERE k1 > 100 and k2 like "%doris%" + PROPERTIES + ( + "desired_concurrent_number"="3", + "max_batch_interval" = "20", + "max_batch_rows" = "300000", + "max_batch_size" = "209715200", + "strict_mode" = "true" + ) + FROM KAFKA + ( + "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", + "kafka_topic" = "my_topic", + "kafka_partitions" = "0,1,2,3", + "kafka_offsets" = "101,0,0,200" + ); + ``` + +4. Import data from the Kafka cluster through SSL authentication. Also set the client.id parameter. The import task is in non-strict mode and the time zone is Africa/Abidjan + + + + ```sql + CREATE ROUTINE LOAD example_db.test1 ON example_tbl + COLUMNS(k1, k2, k3, v1, v2, v3 = k1 * 100), + WHERE k1 > 100 and k2 like "%doris%" + PROPERTIES + ( + "desired_concurrent_number"="3", + "max_batch_interval" = "20", + "max_batch_rows" = "300000", + "max_batch_size" = "209715200", + "strict_mode" = "false", + "timezone" = "Africa/Abidjan" + ) + FROM KAFKA + ( + "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", + "kafka_topic" = "my_topic", + "property.security.protocol" = "ssl", + "property.ssl.ca.location" = "FILE:ca.pem", + "property.ssl.certificate.location" = "FILE:client.pem", + "property.ssl.key.location" = "FILE:client.key", + "property.ssl.key.password" = "abcdefg", + "property.client.id" = "my_client_id" + ); + ``` + +5. Import data in Json format. By default, the field name in Json is used as the column name mapping. Specify to import three partitions 0, 1, and 2, and the starting offsets are all 0 + + + + ```sql + CREATE ROUTINE LOAD example_db.test_json_label_1 ON table1 + COLUMNS(category,price,author) + PROPERTIES + ( + "desired_concurrent_number"="3", + "max_batch_interval" = "20", + "max_batch_rows" = "300000", + "max_batch_size" = "209715200", + "strict_mode" = "false", + "format" = "json" + ) + FROM KAFKA + ( + "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", + "kafka_topic" = "my_topic", + "kafka_partitions" = "0,1,2", + "kafka_offsets" = "0,0,0" + ); + ``` + +6. Import Json data, extract fields through Jsonpaths, and specify the root node of the Json document + + + + ```sql + CREATE ROUTINE LOAD example_db.test1 ON example_tbl + COLUMNS(category, author, price, timestamp, dt=from_unixtime(timestamp, '%Y%m%d')) + PROPERTIES + ( + "desired_concurrent_number"="3", + "max_batch_interval" = "20", + "max_batch_rows" = "300000", + "max_batch_size" = "209715200", + "strict_mode" = "false", + "format" = "json", + "jsonpaths" = "[\"$.category\",\"$.author\",\"$.price\",\"$.timestamp\"]", + "json_root" = "$.RECORDS" + "strip_outer_array" = "true" + ) + FROM KAFKA + ( + "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", + "kafka_topic" = "my_topic", + "kafka_partitions" = "0,1,2", + "kafka_offsets" = "0,0,0" + ); + ``` + +7. Create a Kafka routine import task named test1 for example_tbl of example_db. And use conditional filtering. + + + + ```sql + CREATE ROUTINE LOAD example_db.test1 ON example_tbl + WITH MERGE + COLUMNS(k1, k2, k3, v1, v2, v3), + WHERE k1 > 100 and k2 like "%doris%", + DELETE ON v3 >100 + PROPERTIES + ( + "desired_concurrent_number"="3", + "max_batch_interval" = "20", + "max_batch_rows" = "300000", + "max_batch_size" = "209715200", + "strict_mode" = "false" + ) + FROM KAFKA + ( + "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", + "kafka_topic" = "my_topic", + "kafka_partitions" = "0,1,2,3", + "kafka_offsets" = "101,0,0,200" + ); + ``` + +8. Import data to Unique with sequence column Key model table + + + + ```sql + CREATE ROUTINE LOAD example_db.test_job ON example_tbl + COLUMNS TERMINATED BY ",", + COLUMNS(k1,k2,source_sequence,v1,v2), + ORDER BY source_sequence + PROPERTIES + ( + "desired_concurrent_number"="3", + "max_batch_interval" = "30", + "max_batch_rows" = "300000", + "max_batch_size" = "209715200" + ) FROM KAFKA + ( + "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", + "kafka_topic" = "my_topic", + "kafka_partitions" = "0,1,2,3", + "kafka_offsets" = "101,0,0,200" + ); + ``` + +9. Consume from a specified point in time + + + + ```sql + CREATE ROUTINE LOAD example_db.test_job ON example_tbl + PROPERTIES + ( + "desired_concurrent_number"="3", + "max_batch_interval" = "30", + "max_batch_rows" = "300000", + "max_batch_size" = "209715200" + ) FROM KAFKA + ( + "kafka_broker_list" = "broker1:9092,broker2:9092", + "kafka_topic" = "my_topic", + "kafka_default_offsets" = "2021-05-21 10:00:00" + ); + ``` + +## Keywords + + CREATE, ROUTINE, LOAD, CREATE LOAD + +## Best Practice + +Partition and Offset for specified consumption + +Doris supports the specified Partition and Offset to start consumption, and also supports the function of consumption at a specified time point. The configuration relationship of the corresponding parameters is described here. + +There are three relevant parameters: + +- `kafka_partitions`: Specify a list of partitions to be consumed, such as "0, 1, 2, 3". +- `kafka_offsets`: Specify the starting offset of each partition, which must correspond to the number of `kafka_partitions` list. For example: "1000, 1000, 2000, 2000" +- `property.kafka_default_offsets`: Specifies the default starting offset of the partition. + +When creating an import job, these three parameters can have the following combinations: + +| Composition | `kafka_partitions` | `kafka_offsets` | `property.kafka_default_offsets` | Behavior | +| ----------- | ------------------ | --------------- | ------------------------------- | ------------------------------------------------------------ | +| 1 | No | No | No | The system will automatically find all partitions corresponding to the topic and start consumption from OFFSET_END | +| 2 | No | No | Yes | The system will automatically find all partitions corresponding to the topic and start consumption from the location specified by default offset | +| 3 | Yes | No | No | The system will start consumption from OFFSET_END of the specified partition | +| 4 | Yes | Yes | No | The system will start consumption from the specified offset of the specified partition | +| 5 | Yes | No | Yes | The system will start consumption from the specified partition, the location specified by default offset | diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/CREATE-SYNC-JOB.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/CREATE-SYNC-JOB.md new file mode 100644 index 0000000000000..73c1a9426adc2 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/CREATE-SYNC-JOB.md @@ -0,0 +1,157 @@ +--- +{ + "title": "CREATE SYNC JOB", + "language": "en" +} +--- + + + + + +## Description + +The data synchronization (Sync Job) function supports users to submit a resident data synchronization job, and incrementally synchronizes the CDC (Change Data Capture) of the user's data update operation in the Mysql database by reading the Binlog log from the specified remote address. Features. + +Currently, the data synchronization job only supports connecting to Canal, obtaining the parsed Binlog data from the Canal Server and importing it into Doris. + +Users can view the data synchronization job status through [SHOW SYNC JOB](../../../../sql-manual/sql-statements/data-modification/load-and-export/SHOW-SYNC-JOB). + +grammar: + +```sql +CREATE SYNC [db.]job_name + ( + channel_desc, + channel_desc + ... + ) +binlog_desc +``` + +1. `job_name` + + The synchronization job name is the unique identifier of the job in the current database. Only one job with the same `job_name` can be running. + +2. `channel_desc` + + The data channel under the job is used to describe the mapping relationship between the mysql source table and the doris target table. + + grammar: + + ```sql + FROM mysql_db.src_tbl INTO des_tbl + [columns_mapping] + ``` + + 1. `mysql_db.src_tbl` + + Specify the database and source table on the mysql side. + + 2. `des_tbl` + + Specify the target table on the doris side. Only unique tables are supported, and the batch delete function of the table needs to be enabled (see the 'batch delete function' of help alter table for how to enable it). + + 4. `column_mapping` + + Specifies the mapping relationship between the columns of the mysql source table and the doris target table. If not specified, FE will default the columns of the source table and the target table to one-to-one correspondence in order. + + The form col_name = expr is not supported for columns. + + Example: + + ``` + Suppose the target table column is (k1, k2, v1), + + Change the order of columns k1 and k2 + (k2, k1, v1) + + Ignore the fourth column of the source data + (k2, k1, v1, dummy_column) + ``` + +3. `binlog_desc` + + Used to describe the remote data source, currently only one canal is supported. + + grammar: + + ```sql + FROM BINLOG + ( + "key1" = "value1", + "key2" = "value2" + ) + ``` + + 1. The properties corresponding to the Canal data source, prefixed with `canal.` + + 1. canal.server.ip: address of canal server + 2. canal.server.port: the port of the canal server + 3. canal.destination: the identity of the instance + 4. canal.batchSize: The maximum batch size obtained, the default is 8192 + 5. canal.username: username of instance + 6. canal.password: the password of the instance + 7. canal.debug: optional, when set to true, the batch and details of each row of data will be printed out + +## Example + +1. Simply create a data synchronization job named `job1` for `test_tbl` of `test_db`, connect to the local Canal server, corresponding to the Mysql source table `mysql_db1.tbl1`. + + ```SQL + CREATE SYNC `test_db`.`job1` + ( + FROM `mysql_db1`.`tbl1` INTO `test_tbl` + ) + FROM BINLOG + ( + "type" = "canal", + "canal.server.ip" = "127.0.0.1", + "canal.server.port" = "11111", + "canal.destination" = "example", + "canal.username" = "", + "canal.password" = "" + ); + ``` + +2. Create a data synchronization job named `job1` for multiple tables of `test_db`, corresponding to multiple Mysql source tables one-to-one, and explicitly specify the column mapping. + + ```SQL + CREATE SYNC `test_db`.`job1` + ( + FROM `mysql_db`.`t1` INTO `test1` (k1, k2, v1) , + FROM `mysql_db`.`t2` INTO `test2` (k3, k4, v2) + ) + FROM BINLOG + ( + "type" = "canal", + "canal.server.ip" = "xx.xxx.xxx.xx", + "canal.server.port" = "12111", + "canal.destination" = "example", + "canal.username" = "username", + "canal.password" = "password" + ); + ``` + +## Keywords + + CREATE, SYNC, JOB + +## Best Practice diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/EXPORT.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/EXPORT.md new file mode 100644 index 0000000000000..921dea2ab4d73 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/EXPORT.md @@ -0,0 +1,377 @@ +--- +{ + "title": "EXPORT", + "language": "en" +} +--- + + + +## Description + +The `EXPORT` command is used to export the data of a specified table to a designated location as a file. Currently, it supports exporting to remote storage such as HDFS, S3, BOS, and COS (Tencent Cloud) through Broker process, S3 protocol, or HDFS protocol. + +`EXPORT` is an asynchronous operation, and the command submits an `EXPORT JOB` to Doris. The task will be successfully submitted and returns immediately. After execution, you can use the [SHOW EXPORT](../../../../sql-manual/sql-statements/data-modification/load-and-export/SHOW-EXPORT) to view the progress. + +**grammar** + + ```sql + EXPORT TABLE table_name + [PARTITION (p1[,p2])] + [WHERE] + TO export_path + [opt_properties] + WITH BROKER/S3/HDFS + [broker_properties]; + ``` + +**principle** + +The bottom layer of the `Export` statement actually executes the `select...outfile..` statement. The `Export` task will be decomposed into multiple `select...outfile..` statements to execute concurrently according to the value of the `parallelism` parameter. Each `select...outfile..` is responsible for exporting some tablets of table. + +**illustrate:** + +- `table_name` + + The table name of the table currently being exported. Only the export of Doris local table / View / External Table data is supported. + +- `partition` + + It is possible to export only some specified partitions of the specified table + +- `export_path` + + The exported file path can be a directory or a file directory with a file prefix, for example: `hdfs://path/to/my_file_` + +- `opt_properties` + + Used to specify some export parameters. + + ```sql + [PROPERTIES ("key"="value", ...)] + ``` + + The following parameters can be specified: + + - `label`: This parameter is optional, specifies the label of the export task. If this parameter is not specified, the system randomly assigns a label to the export task. + + - `column_separator`: Specifies the exported column separator, default is `\t`, mulit-bytes is supported. This parameter is only used for `CSV` file format. + + - `line_delimiter`: Specifies the line delimiter for export, the default is `\n`, mulit-bytes is supported. This parameter is only used for `CSV` file format. + + - `timeout`: The timeout period of the export job, the default is 2 hours, the unit is seconds. + + - `columns`: Specifies certain columns of the export job table + + - `format`: Specifies the file format, support: parquet, orc, csv, csv_with_names, csv_with_names_and_types.The default is csv format. + + - `parallelism`: The concurrency degree of the `export` job, the default is `1`. The export job will be divided into `select..outfile..` statements of the number of `parallelism` to execute concurrently. (If the value of `parallelism` is greater than the number of tablets in the table, the system will automatically set `parallelism` to the number of tablets, that is, each `select..outfile..` statement is responsible for one tablet) + + - `delete_existing_files`: default `false`. If it is specified as true, you will first delete all files specified in the directory specified by the file_path, and then export the data to the directory.For example: "file_path" = "/user/tmp", then delete all files and directory under "/user/"; "file_path" = "/user/tmp/", then delete all files and directory under "/user/tmp/" + + - `max_file_size`: it is the limit for the size of a single file in the export job. If the result file exceeds this value, it will be split into multiple files. The valid range for `max_file_size` is [5MB, 2GB], with a default value of 1GB. (When exporting to the ORC file format, the actual size of the split files will be multiples of 64MB, for example, if max_file_size is specified as 5MB, the actual split size will be 64MB; if max_file_size is specified as 65MB, the actual split size will be 128MB.) + + - `with_bom`: The default is false. If it is set to true, the exported file is encoded in UTF8 with BOM (valid only for CSV-related file format). + + - `timeout`: This is the timeout parameter of the export job, the default timeout is 2 hours, and the unit is seconds. + + - `compress_type`: (since 2.1.5) When specifying the export file format as Parquet or ORC, you can choose the compression method for the Parquet or ORC files. For Parquet file format, you can specify the compression method as SNAPPY, GZIP, BROTLI, ZSTD, LZ4, or PLAIN, with the default being SNAPPY. For ORC file format, you can specify the compression method as PLAIN, SNAPPY, ZLIB, or ZSTD, with the default being ZLIB. This parameter is supported starting from version 2.1.5. (PLAIN means no compression is used.) + + > Note that to use the `delete_existing_files` parameter, you also need to add the configuration `enable_delete_existing_files = true` to the fe.conf file and restart the FE. Only then will the `delete_existing_files` parameter take effect. Setting `delete_existing_files = true` is a dangerous operation and it is recommended to only use it in a testing environment. + +- `WITH BROKER` + + The export function needs to write data to the remote storage through the Broker process. Here you need to define the relevant connection information for the broker to use. + + ```sql + WITH BROKER "broker_name" + ("key"="value"[,...]) + + Broker related properties: + username: user name + password: password + hadoop.security.authentication: specify the authentication method as kerberos + kerberos_principal: specifies the principal of kerberos + kerberos_keytab: specifies the path to the keytab file of kerberos. The file must be the absolute path to the file on the server where the broker process is located. and can be accessed by the Broker process + ``` + +- `WITH HDFS` + + You can directly write data to the remote HDFS. + + + ```sql + WITH HDFS ("key"="value"[,...]) + + HDFS related properties: + fs.defaultFS: namenode address and port + hadoop.username: hdfs username + dfs.nameservices: if hadoop enable HA, please set fs nameservice. See hdfs-site.xml + dfs.ha.namenodes.[nameservice ID]:unique identifiers for each NameNode in the nameservice. See hdfs-site.xml + dfs.namenode.rpc-address.[nameservice ID].[name node ID]: the fully-qualified RPC address for each NameNode to listen on. See hdfs-site.xml + dfs.client.failover.proxy.provider.[nameservice ID]:the Java class that HDFS clients use to contact the Active NameNode, usually it is org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider + + For a kerberos-authentication enabled Hadoop cluster, additional properties need to be set: + dfs.namenode.kerberos.principal: HDFS namenode service principal + hadoop.security.authentication: kerberos + hadoop.kerberos.principal: the Kerberos pincipal that Doris will use when connectiong to HDFS. + hadoop.kerberos.keytab: HDFS client keytab location. + ``` + +- `WITH S3` + + You can directly write data to a remote S3 object store + + ```sql + WITH S3 ("key"="value"[,...]) + + S3 related properties: + AWS_ENDPOINT + AWS_ACCESS_KEY + AWS_SECRET_KEY + AWS_REGION + use_path_style: (optional) default false . The S3 SDK uses the virtual-hosted style by default. However, some object storage systems may not be enabled or support virtual-hosted style access. At this time, we can add the use_path_style parameter to force the use of path style access method. + ``` + +## Example + +#### export to local + +> Export data to the local file system needs to add `enable_outfile_to_local = true` to the fe.conf and restart the Fe. + +1. You can export the `test` table to a local store. Export csv format file by default. + +```sql +EXPORT TABLE test TO "file:///home/user/tmp/"; +``` + +2. You can export the k1 and k2 columns in `test` table to a local store, and set export label. Export csv format file by default. + +```sql +EXPORT TABLE test TO "file:///home/user/tmp/" +PROPERTIES ( + "label" = "label1", + "columns" = "k1,k2" +); +``` + +3. You can export the rows where `k1 < 50` in `test` table to a local store, and set column_separator to `,`. Export csv format file by default. + +```sql +EXPORT TABLE test WHERE k1 < 50 TO "file:///home/user/tmp/" +PROPERTIES ( + "columns" = "k1,k2", + "column_separator"="," +); +``` + +4. Export partitions p1 and p2 from the test table to local storage, with the default exported file format being csv. + +```sql +EXPORT TABLE test PARTITION (p1,p2) TO "file:///home/user/tmp/" +PROPERTIES ("columns" = "k1,k2"); + ``` + +5. Export all data in the test table to local storage with a non-default file format. + +```sql +// parquet file format +EXPORT TABLE test TO "file:///home/user/tmp/" +PROPERTIES ( + "columns" = "k1,k2", + "format" = "parquet" +); + +// orc file format +EXPORT TABLE test TO "file:///home/user/tmp/" +PROPERTIES ( + "columns" = "k1,k2", + "format" = "orc" +); + +// csv_with_names file format. Using 'AA' as the column delimiter and 'zz' as the line delimiter. +EXPORT TABLE test TO "file:///home/user/tmp/" +PROPERTIES ( + "format" = "csv_with_names", + "column_separator"="AA", + "line_delimiter" = "zz" +); + +// csv_with_names_and_types file format +EXPORT TABLE test TO "file:///home/user/tmp/" +PROPERTIES ( + "format" = "csv_with_names_and_types" +); + +``` + +6. set max_file_sizes + +```sql +EXPORT TABLE test TO "file:///home/user/tmp/" +PROPERTIES ( + "format" = "parquet", + "max_file_size" = "5MB" +); +``` + +When the exported file size is larger than 5MB, the data will be split into multiple files, with each file containing a maximum of 5MB. + +7. set parallelism +```sql +EXPORT TABLE test TO "file:///home/user/tmp/" +PROPERTIES ( + "format" = "parquet", + "max_file_size" = "5MB", + "parallelism" = "5" +); +``` + +8. set delete_existing_files + +```sql +EXPORT TABLE test TO "file:///home/user/tmp" +PROPERTIES ( + "format" = "parquet", + "max_file_size" = "5MB", + "delete_existing_files" = "true" +) +``` + +Before exporting data, all files and directories in the `/home/user/` directory will be deleted, and then the data will be exported to that directory. + +#### export with S3 + +1. Export all data from the `testTbl` table to S3 using invisible character '\x07' as a delimiter for columns and rows.If you want to export data to minio, you also need to specify use_path_style=true. + + ```sql + EXPORT TABLE testTbl TO "s3://bucket/a/b/c" + PROPERTIES ( + "column_separator"="\\x07", + "line_delimiter" = "\\x07" + ) WITH s3 ( + "s3.endpoint" = "xxxxx", + "s3.region" = "xxxxx", + "s3.secret_key"="xxxx", + "s3.access_key" = "xxxxx" + ) + ``` + +2. Export all data in the test table to HDFS in the format of parquet, limit the size of a single file to 1024MB, and reserve all files in the specified directory. + +#### export with HDFS +1. Export all data from the `test` table to HDFS in `Parquet` format, with a limit of 512MB for the size of a single file in the export job, and retain all files under the specified directory. + + ```sql + EXPORT TABLE test TO "hdfs://hdfs_host:port/a/b/c/" + PROPERTIES( + "format" = "parquet", + "max_file_size" = "512MB", + "delete_existing_files" = "false" + ) + with HDFS ( + "fs.defaultFS"="hdfs://hdfs_host:port", + "hadoop.username" = "hadoop" + ); + ``` + +#### export with Broker +You need to first start the broker process and add it to the FE before proceeding. +1. Export the `test` table to hdfs + + ```sql + EXPORT TABLE test TO "hdfs://hdfs_host:port/a/b/c" + WITH BROKER "broker_name" + ( + "username"="xxx", + "password"="yyy" + ); + ``` + +2. Export partitions 'p1' and 'p2' from the 'testTbl' table to HDFS using ',' as the column delimiter and specifying a label. + + ```sql + EXPORT TABLE testTbl PARTITION (p1,p2) TO "hdfs://hdfs_host:port/a/b/c" + PROPERTIES ( + "label" = "mylabel", + "column_separator"="," + ) + WITH BROKER "broker_name" + ( + "username"="xxx", + "password"="yyy" + ); + ``` + +3. Export all data from the 'testTbl' table to HDFS using the non-visible character '\x07' as the column and row delimiter. + +```sql +EXPORT TABLE testTbl TO "hdfs://hdfs_host:port/a/b/c" +PROPERTIES ( + "column_separator"="\\x07", + "line_delimiter" = "\\x07" +) +WITH BROKER "broker_name" +( + "username"="xxx", + "password"="yyy" +) +``` + +## Keywords + + EXPORT + +## Best Practice + + #### Concurrent Export + + An Export job can be configured with the `parallelism` parameter to concurrently export data. The `parallelism` parameter specifies the number of threads to execute the `EXPORT Job`. Each thread is responsible for exporting a subset of the total tablets. + + The underlying execution logic of an `Export Job `is actually the `SELECT INTO OUTFILE` statement. Each thread specified by the `parallelism` parameter executes independent `SELECT INTO OUTFILE` statements. + + The specific logic for splitting an `Export Job` into multiple `SELECT INTO OUTFILE` is, to evenly distribute all the tablets of the table among all parallel threads. For example: + + - If num(tablets) = 40 and parallelism = 3, then the three threads will be responsible for 14, 13, and 13 tablets, respectively. + - If num(tablets) = 2 and parallelism = 3, then Doris automatically sets the parallelism to 2, and each thread is responsible for one tablet. + + When the number of tablets responsible for a thread exceeds the `maximum_tablets_of_outfile_in_export` value (default is 10, and can be modified by adding the `maximum_tablets_of_outfile_in_export` parameter in fe.conf), the thread will split the tablets which are responsibled for this thread into multiple `SELECT INTO OUTFILE` statements. For example: + + - If a thread is responsible for 14 tablets and `maximum_tablets_of_outfile_in_export = 10`, then the thread will be responsible for two `SELECT INTO OUTFILE` statements. The first `SELECT INTO OUTFILE` statement exports 10 tablets, and the second `SELECT INTO OUTFILE` statement exports 4 tablets. The two `SELECT INTO OUTFILE` statements are executed serially by this thread. + + #### memory limit + + The query plan for an `Export Job` typically involves only `scanning and exporting`, and does not involve compute logic that requires a lot of memory. Therefore, the default memory limit of 2GB is usually sufficient to meet the requirements. + + However, in certain scenarios, such as a query plan that requires scanning too many tablets on the same BE, or when there are too many data versions of tablets, it may result in insufficient memory. In these cases, you can adjust the session variable `exec_mem_limit` to increase the memory usage limit. + + #### Precautions + + - Exporting a large amount of data at one time is not recommended. The maximum recommended export data volume for an Export job is several tens of GB. An overly large export results in more junk files and higher retry costs. If the amount of table data is too large, it is recommended to export by partition. + + - If the Export job fails, the generated files will not be deleted, and the user needs to delete it manually. + + - The Export job only exports the data of the Base table / View / External table, not the data of the materialized view. + + - The export job scans data and occupies IO resources, which may affect the query latency of the system. + + - Currently, The `Export Job` is simply check whether the `Tablets version` is the same, it is recommended not to import data during the execution of the `Export Job`. + + - The maximum number of partitions that an `Export job` allows is 2000. You can add a parameter to the fe.conf `maximum_number_of_export_partitions` and restart FE to modify the setting. diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/MYSQL-LOAD.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/MYSQL-LOAD.md new file mode 100644 index 0000000000000..af75794772327 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/MYSQL-LOAD.md @@ -0,0 +1,169 @@ +--- +{ + "title": "MYSQL LOAD", + "language": "en" +} +--- + + + + + +## Description + +mysql-load: Import local data using the MySql client + +``` +LOAD DATA +[LOCAL] +INFILE 'file_name' +INTO TABLE tbl_name +[PARTITION (partition_name [, partition_name] ...)] +[COLUMNS TERMINATED BY 'string'] +[LINES TERMINATED BY 'string'] +[IGNORE number {LINES | ROWS}] +[(col_name_or_user_var [, col_name_or_user_var] ...)] +[SET (col_name={expr | DEFAULT} [, col_name={expr | DEFAULT}] ...)] +[PROPERTIES (key1 = value1 [, key2=value2]) ] +``` + +This statement is used to import data to the specified table. Unlike normal Load, this import method is a synchronous import. + +This import method can still guarantee the atomicity of a batch of import tasks, either all data imports are successful or all fail. + +1. MySQL Load starts with the syntax `LOAD DATA`, without specifying `LABEL` +2. Specify `LOCAL` to read client side files. Not specified to read FE server side local files. Server side load was disabled by default. It can be enabled by setting a secure path in FE configuration `mysql_load_server_secure_path` +3. The local fill path will be filled after `INFILE`, which can be a relative path or an absolute path. Currently only a single file is supported, and multiple files are not supported +4. The table name after `INTO TABLE` can specify the database name, as shown in the case. It can also be omitted, and the database where the current user is located will be used. +5. `PARTITION` syntax supports specified partition to import +6. `COLUMNS TERMINATED BY` specifies the column separator +7. `LINES TERMINATED BY` specifies the line separator +8. `IGNORE num LINES` The user skips the header of the CSV and can skip any number of lines. This syntax can also be replaced by'IGNORE num ROWS ' +9. Column mapping syntax, please refer to the column mapping chapter of [Imported Data Transformation](../../../../data-operate/import/import-way/mysql-load-manual.md) +10. `PROPERTIES` parameter configuration, see below for details + +### PROPERTIES + +1. max_filter_ratio: The maximum tolerable data ratio that can be filtered (for reasons such as data irregularity). Zero tolerance by default. Data irregularities do not include rows filtered out by where conditions. + +2. timeout: Specify the import timeout. in seconds. The default is 600 seconds. The setting range is from 1 second to 259200 seconds. + +3. strict_mode: The user specifies whether to enable strict mode for this import. The default is off. + +4. timezone: Specify the time zone used for this import. The default is Dongba District. This parameter affects the results of all time zone-related functions involved in the import. + +5. exec_mem_limit: Load memory limit. Default is 2GB. The unit is bytes. + +6. trim_double_quotes: Boolean type, The default value is false. True means that the outermost double quotes of each field in the load file are trimmed. + +7. enclose: When the csv data field contains row delimiters or column delimiters, to prevent accidental truncation, single-byte characters can be specified as brackets for protection. For example, the column separator is ",", the bracket is "'", and the data is "a,'b,c'", then "b,c" will be parsed as a field. Note: when the bracket is `"`, trim\_double\_quotes must be set to true. + +8. escape: Used to escape characters that appear in a csv field identical to the enclosing characters. For example, if the data is "a,'b,'c'", enclose is "'", and you want "b,'c to be parsed as a field, you need to specify a single-byte escape character, such as "\", and then modify the data to "a,' b,\'c'". + +## Example + +1. Import the data from the client side local file `testData` into the table `testTbl` in the database `testDb`. Specify a timeout of 100 seconds + + ```sql + LOAD DATA LOCAL + INFILE 'testData' + INTO TABLE testDb.testTbl + PROPERTIES ("timeout"="100") + ``` + +2. Import the data from the server side local file `/root/testData` (set FE config `mysql_load_server_secure_path` to be `root` already) into the table `testTbl` in the database `testDb`. Specify a timeout of 100 seconds + + ```sql + LOAD DATA + INFILE '/root/testData' + INTO TABLE testDb.testTbl + PROPERTIES ("timeout"="100") + ``` + +3. Import data from client side local file `testData` into table `testTbl` in database `testDb`, allowing 20% error rate + + ```sql + LOAD DATA LOCAL + INFILE 'testData' + INTO TABLE testDb.testTbl + PROPERTIES ("max_filter_ratio"="0.2") + ``` + +4. Import the data from the client side local file `testData` into the table `testTbl` in the database `testDb`, allowing a 20% error rate and specifying the column names of the file + + ```sql + LOAD DATA LOCAL + INFILE 'testData' + INTO TABLE testDb.testTbl + (k2, k1, v1) + PROPERTIES ("max_filter_ratio"="0.2") + ``` + +5. Import the data in the local file `testData` into the p1, p2 partitions in the table of `testTbl` in the database `testDb`, allowing a 20% error rate. + + ```sql + LOAD DATA LOCAL + INFILE 'testData' + INTO TABLE testDb.testTbl + PARTITION (p1, p2) + PROPERTIES ("max_filter_ratio"="0.2") + ``` + +6. Import the data in the CSV file `testData` with a local row delimiter of `0102` and a column delimiter of `0304` into the table `testTbl` in the database `testDb`. + + ```sql + LOAD DATA LOCAL + INFILE 'testData' + INTO TABLE testDb.testTbl + COLUMNS TERMINATED BY '0304' + LINES TERMINATED BY '0102' + ``` + +7. Import the data from the local file `testData` into the p1, p2 partitions in the table of `testTbl` in the database `testDb` and skip the first 3 lines. + + ```sql + LOAD DATA LOCAL + INFILE 'testData' + INTO TABLE testDb.testTbl + PARTITION (p1, p2) + IGNORE 1 LINES + ``` + +8. Import data for strict schema filtering and set the time zone to Africa/Abidjan + + ```sql + LOAD DATA LOCAL + INFILE 'testData' + INTO TABLE testDb.testTbl + PROPERTIES ("strict_mode"="true", "timezone"="Africa/Abidjan") + ``` + +9. Import data is limited to 10GB of load memory and timed out in 10 minutes + + ```sql + LOAD DATA LOCAL + INFILE 'testData' + INTO TABLE testDb.testTbl + PROPERTIES ("exec_mem_limit"="10737418240", "timeout"="600") + ``` + +## Keywords + + MYSQL, LOAD diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/OUTFILE.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/OUTFILE.md new file mode 100644 index 0000000000000..c0476b43a8cfd --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/OUTFILE.md @@ -0,0 +1,416 @@ +--- +{ + "title": "OUTFILE", + "language": "en" +} + +--- + + + + +## Description + +This statement is used to export query results to a file using the `SELECT INTO OUTFILE` command. Currently, it supports exporting to remote storage, such as HDFS, S3, BOS, COS (Tencent Cloud), through the Broker process, S3 protocol, or HDFS protocol. + + +#### grammar: + +```sql +query_stmt +INTO OUTFILE "file_path" +[format_as] +[properties] +``` + +#### illustrate: + +1. file_path + + file_path points to the path where the file is stored and the file prefix. Such as `hdfs://path/to/my_file_`. + + ``` + The final filename will consist of `my_file_`, the file number and the file format suffix. The file serial number starts from 0, and the number is the number of files to be divided. Such as: + + my_file_abcdefg_0.csv + my_file_abcdefg_1.csv + my_file_abcdegf_2.csv + ``` + + You can also omit the file prefix and specify only the file directory, such as: `hdfs://path/to/` + +2. format_as + + ``` + FORMAT AS CSV + ``` + + Specifies the export format. Supported formats include CSV, PARQUET, CSV_WITH_NAMES, CSV_WITH_NAMES_AND_TYPES and ORC. Default is CSV. + + > Note: PARQUET, CSV_WITH_NAMES, CSV_WITH_NAMES_AND_TYPES, and ORC are supported starting in version 1.2 . + +3. properties + + Specify related properties. Currently exporting via the Broker process, S3 protocol, or HDFS protocol is supported. + + ``` + grammar: + [PROPERTIES ("key"="value", ...)] + The following properties are supported: + + File related properties + column_separator: column separator,is only for CSV format. mulit-bytes is supported starting in version 1.2, such as: "\\x01", "abc". + line_delimiter: line delimiter,is only for CSV format. mulit-bytes supported starting in version 1.2, such as: "\\x01", "abc". + max_file_size: the size limit of a single file, if the result exceeds this value, it will be cut into multiple files, the value range of max_file_size is [5MB, 2GB] and the default is 1GB. (When specified that the file format is ORC, the size of the actual division file will be a multiples of 64MB, such as: specify max_file_size = 5MB, and actually use 64MB as the division; specify max_file_size = 65MB, and will actually use 128MB as cut division points.) + delete_existing_files: default `false`. If it is specified as true, you will first delete all files specified in the directory specified by the file_path, and then export the data to the directory.For example: "file_path" = "/user/tmp", then delete all files and directory under "/user/"; "file_path" = "/user/tmp/", then delete all files and directory under "/user/tmp/" + file_suffix: Specify the suffix of the export file. If this parameter is not specified, the default suffix for the file format will be used. + + Broker related properties need to be prefixed with `broker.`: + broker.name: broker name + broker.hadoop.security.authentication: specify the authentication method as kerberos + broker.kerberos_principal: specifies the principal of kerberos + broker.kerberos_keytab: specifies the path to the keytab file of kerberos. The file must be the absolute path to the file on the server where the broker process is located. and can be accessed by the Broker process + + HDFS related properties: + fs.defaultFS: namenode address and port + hadoop.username: hdfs username + dfs.nameservices: if hadoop enable HA, please set fs nameservice. See hdfs-site.xml + dfs.ha.namenodes.[nameservice ID]:unique identifiers for each NameNode in the nameservice. See hdfs-site.xml + dfs.namenode.rpc-address.[nameservice ID].[name node ID]: the fully-qualified RPC address for each NameNode to listen on. See hdfs-site.xml + dfs.client.failover.proxy.provider.[nameservice ID]:the Java class that HDFS clients use to contact the Active NameNode, usually it is org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider + + For a kerberos-authentication enabled Hadoop cluster, additional properties need to be set: + dfs.namenode.kerberos.principal: HDFS namenode service principal + hadoop.security.authentication: kerberos + hadoop.kerberos.principal: the Kerberos pincipal that Doris will use when connectiong to HDFS. + hadoop.kerberos.keytab: HDFS client keytab location. + + For the S3 protocol, you can directly execute the S3 protocol configuration: + s3.endpoint + s3.access_key + s3.secret_key + s3.region + use_path_style: (optional) default false . The S3 SDK uses the virtual-hosted style by default. However, some object storage systems may not be enabled or support virtual-hosted style access. At this time, we can add the use_path_style parameter to force the use of path style access method. + ``` + + > Note that to use the `delete_existing_files` parameter, you also need to add the configuration `enable_delete_existing_files = true` to the fe.conf file and restart the FE. Only then will the `delete_existing_files` parameter take effect. Setting `delete_existing_files = true` is a dangerous operation and it is recommended to only use it in a testing environment. + +4. Data Types for Export + + All file formats support the export of basic data types, while only csv/orc/csv_with_names/csv_with_names_and_types currently support the export of complex data types (ARRAY/MAP/STRUCT). Nested complex data types are not supported. + +5. Concurrent Export + + Setting the session variable `set enable_parallel_outfile = true;` enables concurrent export using outfile. For detailed usage, see [Export Query Result](../../../data-operate/export/outfile.md). + +6. Export to Local + + To export to a local file, you need configure `enable_outfile_to_local=true` in fe.conf. + + ```sql + select * from tbl1 limit 10 + INTO OUTFILE "file:///home/work/path/result_"; + ``` + +#### Explanation of the returned results: + +- **FileNumber**: The number of generated files. +- **TotalRows**: The number of rows in the result set. +- **FileSize**: The total size of the exported files in bytes. +- **URL**: The prefix of the exported file paths. Multiple files will be numbered sequentially with suffixes `_0`, `_1`, etc. + +#### DataType Mapping + +Parquet and ORC file formats have their own data types. The export function of Doris can automatically export the Doris data types to the corresponding data types of the Parquet/ORC file format. The following are the data type mapping relationship of the Doris data types and the Parquet/ORC file format data types: + +1. The mapping relationship between the Doris data types to the ORC data types is: + + | Doris Type | Orc Type | + | ----------------------- | --------- | + | boolean | boolean | + | tinyint | tinyint | + | smallint | smallint | + | int | int | + | bigint | bigint | + | largeInt | string | + | date | string | + | datev2 | string | + | datetime | string | + | datetimev2 | timestamp | + | float | float | + | double | double | + | char / varchar / string | string | + | decimal | decimal | + | struct | struct | + | map | map | + | array | array | + +2. When Doris exports data to the Parquet file format, the Doris memory data will be converted to Arrow memory data format first, and then the paraquet file format is written by Arrow. The mapping relationship between the Doris data types to the ARROW data types is: + + | Doris Type | Arrow Type | + | ----------------------- | ---------- | + | boolean | boolean | + | tinyint | int8 | + | smallint | int16 | + | int | int32 | + | bigint | int64 | + | largeInt | utf8 | + | date | utf8 | + | datev2 | utf8 | + | datetime | utf8 | + | datetimev2 | utf8 | + | float | float32 | + | double | float64 | + | char / varchar / string | utf8 | + | decimal | decimal128 | + | struct | struct | + | map | map | + | array | list | + + + + +## Example + +1. Use the broker method to export, and export the simple query results to the file `hdfs://path/to/result.txt`. Specifies that the export format is CSV. Use `my_broker` and set kerberos authentication information. Specify the column separator as `,` and the row separator as `\n`. + + ```sql + SELECT * FROM tbl + INTO OUTFILE "hdfs://path/to/result_" + FORMAT AS CSV + PROPERTIES + ( + "broker.name" = "my_broker", + "broker.hadoop.security.authentication" = "kerberos", + "broker.kerberos_principal" = "doris@YOUR.COM", + "broker.kerberos_keytab" = "/home/doris/my.keytab", + "column_separator" = ",", + "line_delimiter" = "\n", + "max_file_size" = "100MB" + ); + ``` + + If the final generated file is not larger than 100MB, it will be: `result_0.csv`. + If larger than 100MB, it may be `result_0.csv, result_1.csv, ...`. + +2. Export the simple query results to the file `hdfs://path/to/result.parquet`. Specify the export format as PARQUET. Use `my_broker` and set kerberos authentication information. + + ```sql + SELECT c1, c2, c3 FROM tbl + INTO OUTFILE "hdfs://path/to/result_" + FORMAT AS PARQUET + PROPERTIES + ( + "broker.name" = "my_broker", + "broker.hadoop.security.authentication" = "kerberos", + "broker.kerberos_principal" = "doris@YOUR.COM", + "broker.kerberos_keytab" = "/home/doris/my.keytab" + ); + ``` + +3. Export the query result of the CTE statement to the file `hdfs://path/to/result.txt`. The default export format is CSV. Use `my_broker` and set hdfs high availability information. Use the default row and column separators. + + ```sql + WITH + x1 AS + (SELECT k1, k2 FROM tbl1), + x2 AS + (SELECT k3 FROM tbl2) + SELEC k1 FROM x1 UNION SELECT k3 FROM x2 + INTO OUTFILE "hdfs://path/to/result_" + PROPERTIES + ( + "broker.name" = "my_broker", + "broker.username"="user", + "broker.password"="passwd", + "broker.dfs.nameservices" = "my_ha", + "broker.dfs.ha.namenodes.my_ha" = "my_namenode1, my_namenode2", + "broker.dfs.namenode.rpc-address.my_ha.my_namenode1" = "nn1_host:rpc_port", + "broker.dfs.namenode.rpc-address.my_ha.my_namenode2" = "nn2_host:rpc_port", + "broker.dfs.client.failover.proxy.provider.my_ha" = "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider" + ); + ``` + + If the final generated file is not larger than 1GB, it will be: `result_0.csv`. + If larger than 1GB, it may be `result_0.csv, result_1.csv, ...`. + +4. Export the query result of the UNION statement to the file `bos://bucket/result.txt`. Specify the export format as PARQUET. Use `my_broker` and set hdfs high availability information. The PARQUET format does not require a column delimiter to be specified. + After the export is complete, an identity file is generated. + + ```sql + SELECT k1 FROM tbl1 UNION SELECT k2 FROM tbl1 + INTO OUTFILE "bos://bucket/result_" + FORMAT AS PARQUET + PROPERTIES + ( + "broker.name" = "my_broker", + "broker.bos_endpoint" = "http://bj.bcebos.com", + "broker.bos_accesskey" = "xxxxxxxxxxxxxxxxxxxxxxxxxxx", + "broker.bos_secret_accesskey" = "yyyyyyyyyyyyyyyyyyyyyyyyy" + ); + ``` + +5. Export the query result of the select statement to the file `s3a://${bucket_name}/path/result.txt`. Specify the export format as csv. + After the export is complete, an identity file is generated. + + ```sql + select k1,k2,v1 from tbl1 limit 100000 + into outfile "s3a://my_bucket/export/my_file_" + FORMAT AS CSV + PROPERTIES + ( + "broker.name" = "hdfs_broker", + "broker.fs.s3a.access.key" = "xxx", + "broker.fs.s3a.secret.key" = "xxxx", + "broker.fs.s3a.endpoint" = "https://cos.xxxxxx.myqcloud.com/", + "column_separator" = ",", + "line_delimiter" = "\n", + "max_file_size" = "1024MB", + "success_file_name" = "SUCCESS" + ) + ``` + + If the final generated file is not larger than 1GB, it will be: `my_file_0.csv`. + If larger than 1GB, it may be `my_file_0.csv, result_1.csv, ...`. + Verify on cos + + 1. A path that does not exist will be automatically created + 2. Access.key/secret.key/endpoint needs to be confirmed with students of cos. Especially the value of endpoint does not need to fill in bucket_name. + +6. Use the s3 protocol to export to bos, and enable concurrent export. + + ```sql + set enable_parallel_outfile = true; + select k1 from tb1 limit 1000 + into outfile "s3://my_bucket/export/my_file_" + format as csv + properties + ( + "s3.endpoint" = "http://s3.bd.bcebos.com", + "s3.access_key" = "xxxx", + "s3.secret_key" = "xxx", + "s3.region" = "bd" + ) + ``` + + The resulting file is prefixed with `my_file_{fragment_instance_id}_`. + +7. Use the s3 protocol to export to bos, and enable concurrent export of session variables. + Note: However, since the query statement has a top-level sorting node, even if the concurrently exported session variable is enabled for this query, it cannot be exported concurrently. + + ```sql + set enable_parallel_outfile = true; + select k1 from tb1 order by k1 limit 1000 + into outfile "s3://my_bucket/export/my_file_" + format as csv + properties + ( + "s3.endpoint" = "http://s3.bd.bcebos.com", + "s3.access_key" = "xxxx", + "s3.secret_key" = "xxx", + "s3.region" = "bd" + ) + ``` + +8. Use hdfs export to export simple query results to the file `hdfs://${host}:${fileSystem_port}/path/to/result.txt`. Specify the export format as CSV and the user name as work. Specify the column separator as `,` and the row separator as `\n`. + + ```sql + -- the default port of fileSystem_port is 9000 + SELECT * FROM tbl + INTO OUTFILE "hdfs://${host}:${fileSystem_port}/path/to/result_" + FORMAT AS CSV + PROPERTIES + ( + "fs.defaultFS" = "hdfs://ip:port", + "hadoop.username" = "work" + ); + ``` + + If the Hadoop cluster is highly available and Kerberos authentication is enabled, you can refer to the following SQL statement: + + ```sql + SELECT * FROM tbl + INTO OUTFILE "hdfs://path/to/result_" + FORMAT AS CSV + PROPERTIES + ( + 'fs.defaultFS'='hdfs://hacluster/', + 'dfs.nameservices'='hacluster', + 'dfs.ha.namenodes.hacluster'='n1,n2', + 'dfs.namenode.rpc-address.hacluster.n1'='192.168.0.1:8020', + 'dfs.namenode.rpc-address.hacluster.n2'='192.168.0.2:8020', + 'dfs.client.failover.proxy.provider.hacluster'='org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider', + 'dfs.namenode.kerberos.principal'='hadoop/_HOST@REALM.COM' + 'hadoop.security.authentication'='kerberos', + 'hadoop.kerberos.principal'='doris_test@REALM.COM', + 'hadoop.kerberos.keytab'='/path/to/doris_test.keytab' + ); + + If the final generated file is not larger than 100MB, it will be: `result_0.csv`. + If larger than 100MB, it may be `result_0.csv, result_1.csv, ...`. + ``` + +9. Export the query result of the select statement to the file `cosn://${bucket_name}/path/result.txt` on Tencent Cloud Object Storage (COS). Specify the export format as csv. + After the export is complete, an identity file is generated. + + ```sql + select k1,k2,v1 from tbl1 limit 100000 + into outfile "cosn://my_bucket/export/my_file_" + FORMAT AS CSV + PROPERTIES + ( + "broker.name" = "broker_name", + "broker.fs.cosn.userinfo.secretId" = "xxx", + "broker.fs.cosn.userinfo.secretKey" = "xxxx", + "broker.fs.cosn.bucket.endpoint_suffix" = "cos.xxxxxx.myqcloud.com", + "column_separator" = ",", + "line_delimiter" = "\n", + "max_file_size" = "1024MB", + "success_file_name" = "SUCCESS" + ) + ``` + +## Keywords + +OUTFILE + +## Best Practice + +1. Export data volume and export efficiency + + This function essentially executes an SQL query command. The final result is a single-threaded output. Therefore, the time-consuming of the entire export includes the time-consuming of the query itself and the time-consuming of writing the final result set. If the query is large, you need to set the session variable `query_timeout` to appropriately extend the query timeout. + +2. Management of export files + + Doris does not manage exported files. Including the successful export, or the remaining files after the export fails, all need to be handled by the user. + +3. Export to local file + + The ability to export to a local file is not available for public cloud users, only for private deployments. And the default user has full control over the cluster nodes. Doris will not check the validity of the export path filled in by the user. If the process user of Doris does not have write permission to the path, or the path does not exist, an error will be reported. At the same time, for security reasons, if a file with the same name already exists in this path, the export will also fail. + + Doris does not manage files exported locally, nor does it check disk space, etc. These files need to be managed by the user, such as cleaning and so on. + +4. Results Integrity Guarantee + + This command is a synchronous command, so it is possible that the task connection is disconnected during the execution process, so that it is impossible to live the exported data whether it ends normally, or whether it is complete. At this point, you can use the `success_file_name` parameter to request that a successful file identifier be generated in the directory after the task is successful. Users can use this file to determine whether the export ends normally. + +5. Other Points to Note + + See [Export Query Result](../../../data-operate/export/outfile.md) \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/PAUSE-ROUTINE-LOAD.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/PAUSE-ROUTINE-LOAD.md new file mode 100644 index 0000000000000..5b93ad79b926c --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/PAUSE-ROUTINE-LOAD.md @@ -0,0 +1,55 @@ +--- +{ + "title": "PAUSE ROUTINE LOAD", + "language": "en" +} +--- + + + + +## Description + +Used to pause a Routine Load job. A suspended job can be rerun with the RESUME command. + +```sql +PAUSE [ALL] ROUTINE LOAD FOR job_name +``` + +## Example + +1. Pause the routine import job named test1. + + ```sql + PAUSE ROUTINE LOAD FOR test1; + ``` + +2. Pause all routine import jobs. + + ```sql + PAUSE ALL ROUTINE LOAD; + ``` + +## Keywords + + PAUSE, ROUTINE, LOAD + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/PAUSE-SYNC-JOB.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/PAUSE-SYNC-JOB.md new file mode 100644 index 0000000000000..e37c6300b801d --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/PAUSE-SYNC-JOB.md @@ -0,0 +1,52 @@ +--- +{ + "title": "PAUSE SYNC JOB", + "language": "en" +} +--- + + + + + +## Description + +Pause a running resident data synchronization job in a database via `job_name`. The suspended job will stop synchronizing data and keep the latest position of consumption until it is resumed by the user. + +grammar: + +```sql +PAUSE SYNC JOB [db.]job_name +``` + +## Example + +1. Pause the data sync job named `job_name`. + + ```sql + PAUSE SYNC JOB `job_name`; + ``` + +## Keywords + + PAUSE, SYNC, JOB + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/RESUME-ROUTINE-LOAD.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/RESUME-ROUTINE-LOAD.md new file mode 100644 index 0000000000000..da72700bdcb82 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/RESUME-ROUTINE-LOAD.md @@ -0,0 +1,56 @@ +--- +{ + "title": "RESUME ROUTINE LOAD", + "language": "en" +} +--- + + + + + +## Description + +Used to restart a suspended Routine Load job. The restarted job will continue to consume from the previously consumed offset. + +```sql +RESUME [ALL] ROUTINE LOAD FOR job_name +``` + +## Example + +1. Restart the routine import job named test1. + + ```sql + RESUME ROUTINE LOAD FOR test1; + ``` + +2. Restart all routine import jobs. + + ```sql + RESUME ALL ROUTINE LOAD; + ``` + +## Keywords + + RESUME, ROUTINE, LOAD + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/RESUME-SYNC-JOB.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/RESUME-SYNC-JOB.md new file mode 100644 index 0000000000000..5bac52a32549b --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/RESUME-SYNC-JOB.md @@ -0,0 +1,52 @@ +--- +{ + "title": "RESUME SYNC JOB", + "language": "en" +} +--- + + + + + +## Description + +Resume a resident data synchronization job whose current database has been suspended by `job_name`, and the job will continue to synchronize data from the latest position before the last suspension. + +grammar: + +```sql +RESUME SYNC JOB [db.]job_name +``` + +## Example + +1. Resume the data synchronization job named `job_name` + + ```sql + RESUME SYNC JOB `job_name`; + ``` + +## Keywords + + RESUME, SYNC, LOAD + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-CREATE-LOAD.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-CREATE-LOAD.md new file mode 100644 index 0000000000000..1ec4bcf7249a1 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-CREATE-LOAD.md @@ -0,0 +1,57 @@ +--- +{ + "title": "SHOW CREATE LOAD", + "language": "en" +} +--- + + + + + + +## Description + +This statement is used to demonstrate the creation statement of a import job. + +grammar: + +```sql +SHOW CREATE LOAD for load_name; +``` + +illustrate: + +- `load_name`: import job name + +## Example + +1. Show the creation statement of the specified import job under the default db + + ```sql + SHOW CREATE LOAD for test_load + ``` + +## Keywords + + SHOW, CREATE, LOAD + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-CREATE-ROUTINE-LOAD.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-CREATE-ROUTINE-LOAD.md new file mode 100644 index 0000000000000..8880986f281b5 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-CREATE-ROUTINE-LOAD.md @@ -0,0 +1,60 @@ +--- +{ + "title": "SHOW CREATE ROUTINE LOAD", + "language": "en" +} +--- + + + + + + +## Description + +This statement is used to demonstrate the creation statement of a routine import job. + +The kafka partition and offset in the result show the currently consumed partition and the corresponding offset to be consumed. + +grammar: + +```sql +SHOW [ALL] CREATE ROUTINE LOAD for load_name; +``` + +illustrate: + +1. `ALL`: optional parameter, which means to get all jobs, including historical jobs +2. `load_name`: routine import job name + +## Example + +1. Show the creation statement of the specified routine import job under the default db + + ```sql + SHOW CREATE ROUTINE LOAD for test_load + ``` + +## Keywords + + SHOW, CREATE, ROUTINE, LOAD + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-EXPORT.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-EXPORT.md new file mode 100644 index 0000000000000..fb264e966f75b --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-EXPORT.md @@ -0,0 +1,120 @@ +--- +{ + "title": "SHOW EXPORT", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to display the execution of the specified export task + +grammar: + +```sql +SHOW EXPORT +[FROM db_name] + [ + WHERE + [ID=your_job_id] + [STATE = ["PENDING"|"EXPORTING"|"FINISHED"|"CANCELLED"]] + [LABEL=your_label] + ] +[ORDER BY...] +[LIMIT limit]; +``` + +illustrate: + 1. If db_name is not specified, the current default db is used + 2. If STATE is specified, matches EXPORT state + 3. You can use ORDER BY to sort any combination of columns + 4. If LIMIT is specified, limit matching records are displayed. Otherwise show all + +The meaning of each column in the result returned by the `show export` command is as follows: + +- JobId: The unique ID of the job +- Label: The label of the export job. If not specified in the export, the system will generate one by default. +- State: Job status: + - PENDING: Job pending scheduling + - EXPORTING: Data export in progress + - FINISHED: Job successful + - CANCELLED: Job failed +- Progress: Job progress. This progress is based on query plans. For example, if there are a total of 10 threads and 3 have been completed, the progress is 30%. +- TaskInfo: Job information displayed in JSON format: + - db: Database name + - tbl: Table name + - partitions: Specified partitions for export. An empty list indicates all partitions. + - column\_separator: Column separator for the export file. + - line\_delimiter: Line delimiter for the export file. + - tablet num: Total number of tablets involved. + - broker: Name of the broker used. + - coord num: Number of query plans. + - max\_file\_size: Maximum size of an export file. + - delete\_existing\_files: Whether to delete existing files and directories in the export directory. + - columns: Specified column names to export, empty value represents exporting all columns. + - format: File format for export +- Path: Export path on the remote storage. +- `CreateTime/StartTime/FinishTime`: Job creation time, scheduling start time, and end time. +- Timeout: Job timeout time in seconds. This time is calculated from CreateTime. +- ErrorMsg: If there is an error in the job, the error reason will be displayed here. +- OutfileInfo: If the job is successfully exported, specific `SELECT INTO OUTFILE` result information will be displayed here. + +## Example + +1. Show all export tasks of default db + + ```sql + SHOW EXPORT; + ``` + +2. Display the export tasks of the specified db, sorted by StartTime in descending order + + ```sql + SHOW EXPORT FROM example_db ORDER BY StartTime DESC; + ``` + +3. Display the export tasks of the specified db, the state is "exporting", and sort by StartTime in descending order + + ```sql + SHOW EXPORT FROM example_db WHERE STATE = "exporting" ORDER BY StartTime DESC; + ``` + +4. Display the export task of the specified db and specified job_id + + ```sql + SHOW EXPORT FROM example_db WHERE ID = job_id; + ``` + +5. Display the specified db and specify the export task of the label + + ```sql + SHOW EXPORT FROM example_db WHERE LABEL = "mylabel"; + ``` + +## Keywords + + SHOW, EXPORT + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD-PROFILE.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD-PROFILE.md new file mode 100644 index 0000000000000..a7879043e2483 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD-PROFILE.md @@ -0,0 +1,227 @@ +--- +{ + "title": "SHOW LOAD PROFILE", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to view the Profile information of the import operation. This function requires the user to open the Profile settings. The versions before 0.15 perform the following settings: + +```sql +SET is_report_success=true; +``` + +Versions 0.15 and later perform the following settings: + +```sql +SET [GLOBAL] enable_profile=true; +``` + +grammar: + +```sql +show load profile "/"; + +show load profile "/[queryId]" + +show load profile "/[queryId]/[TaskId]" + +show load profile "/[queryId]/[TaskId]/[FragmentId]/" + +show load profile "/[queryId]/[TaskId]/[FragmentId]/[InstanceId]" +``` + +This command will list all currently saved import profiles. Each line corresponds to one import. where the QueryId column is the ID of the import job. This ID can also be viewed through the SHOW LOAD statement. We can select the QueryId corresponding to the Profile we want to see to see the specific situation + +## Example + +1. List all Load Profiles + + ```sql + mysql> show load profile "/"\G +*************************** 1. row *************************** + JobId: 20010 + QueryId: 980014623046410a-af5d36f23381017f + User: root + DefaultDb: default_cluster:test + SQL: LOAD LABEL xxx + QueryType: Load + StartTime: 2023-03-07 19:48:24 + EndTime: 2023-03-07 19:50:45 + TotalTime: 2m21s + QueryState: N/A + TraceId: + AnalysisTime: NULL + PlanTime: NULL + ScheduleTime: NULL + FetchResultTime: NULL + WriteResultTime: NULL +WaitAndFetchResultTime: NULL +*************************** 2. row *************************** + JobId: N/A + QueryId: 7cc2d0282a7a4391-8dd75030185134d8 + User: root + DefaultDb: default_cluster:test + SQL: insert into xxx + QueryType: Load + StartTime: 2023-03-07 19:49:15 + EndTime: 2023-03-07 19:49:15 + TotalTime: 102ms + QueryState: OK + TraceId: + AnalysisTime: 825.277us + PlanTime: 4.126ms + ScheduleTime: N/A + FetchResultTime: 0ns + WriteResultTime: 0ns +WaitAndFetchResultTime: N/A + ``` + +2. View an overview of the subtasks with imported jobs: + + ```sql + mysql> show load profile "/980014623046410a-af5d36f23381017f"; + +-----------------------------------+------------+ + | TaskId | ActiveTime | + +-----------------------------------+------------+ + | 980014623046410a-af5d36f23381017f | 3m14s | + +-----------------------------------+------------+ + ``` + +3. View the plan tree of the specified subtask + + ```sql + show load profile "/980014623046410a-af5d36f23381017f/980014623046410a-af5d36f23381017f"; + + ┌───────────────────────┐ + │[-1: OlapTableSink] │ + │Fragment: 0 │ + │MaxActiveTime: 86.541ms│ + └───────────────────────┘ + │ + │ + ┌───────────────────┐ + │[1: VEXCHANGE_NODE]│ + │Fragment: 0 │ + └───────────────────┘ + ┌─────────────────────────┴───────┐ + │ │ + ┌─────────────┐ ┌───────────────────────┐ + │[MemoryUsage]│ │[1: VDataStreamSender] │ + │Fragment: 0 │ │Fragment: 1 │ + └─────────────┘ │MaxActiveTime: 34.882ms│ + └───────────────────────┘ + │ + │ + ┌───────────────────────────┐ + │[0: VNewOlapScanNode(tbl1)]│ + │Fragment: 1 │ + └───────────────────────────┘ + ┌─────────────────┴───────┐ + │ │ + ┌─────────────┐ ┌───────────┐ + │[MemoryUsage]│ │[VScanner] │ + │Fragment: 1 │ │Fragment: 1│ + └─────────────┘ └───────────┘ + ┌───────┴─────────┐ + │ │ + ┌─────────────────┐ ┌─────────────┐ + │[SegmentIterator]│ │[MemoryUsage]│ + │Fragment: 1 │ │Fragment: 1 │ + └─────────────────┘ └─────────────┘ + + ```sql + + This will show the plan tree and fragment id on it + +4. View the Instance overview of the specified subtask + + ```sql + mysql> show load profile "/980014623046410a-af5d36f23381017f/980014623046410a-af5d36f23381017f/1"\G + +-----------------------------------+------------------+------------+ + | Instances | Host | ActiveTime | + +-----------------------------------+------------------+------------+ + | 980014623046410a-88e260f0c43031f2 | 10.81.85.89:9067 | 3m7s | + | 980014623046410a-88e260f0c43031f3 | 10.81.85.89:9067 | 3m6s | + | 980014623046410a-88e260f0c43031f4 | 10.81.85.89:9067 | 3m10s | + | 980014623046410a-88e260f0c43031f5 | 10.81.85.89:9067 | 3m14s | + +-----------------------------------+------------------+------------+ + ``` + +4. Continue to view the detailed Profile of each operator on a specific Instance + + ```sql + mysql> show load profile "/980014623046410a-af5d36f23381017f/980014623046410a-af5d36f23381017f/1/980014623046410a-88e260f0c43031f5"\G + + *************************** 1. row *************************** + + Instance: + + ┌-----------------------------------------┐ + │[-1: OlapTableSink] │ + │(Active: 2m17s, non-child: 70.91) │ + │ - Counters: │ + │ - CloseWaitTime: 1m53s │ + │ - ConvertBatchTime: 0ns │ + │ - MaxAddBatchExecTime: 1m46s │ + │ - NonBlockingSendTime: 3m11s │ + │ - NumberBatchAdded: 782 │ + │ - NumberNodeChannels: 1 │ + │ - OpenTime: 743.822us │ + │ - RowsFiltered: 0 │ + │ - RowsRead: 1.599729M (1599729) │ + │ - RowsReturned: 1.599729M (1599729)│ + │ - SendDataTime: 11s761ms │ + │ - TotalAddBatchExecTime: 1m46s │ + │ - ValidateDataTime: 9s802ms │ + └-----------------------------------------┘ + │ + ┌-----------------------------------------------------┐ + │[0: BROKER_SCAN_NODE] │ + │(Active: 56s537ms, non-child: 29.06) │ + │ - Counters: │ + │ - BytesDecompressed: 0.00 │ + │ - BytesRead: 5.77 GB │ + │ - DecompressTime: 0ns │ + │ - FileReadTime: 34s263ms │ + │ - MaterializeTupleTime(*): 45s54ms │ + │ - NumDiskAccess: 0 │ + │ - PeakMemoryUsage: 33.03 MB │ + │ - RowsRead: 1.599729M (1599729) │ + │ - RowsReturned: 1.599729M (1599729) │ + │ - RowsReturnedRate: 28.295K sec │ + │ - TotalRawReadTime(*): 1m20s │ + │ - TotalReadThroughput: 30.39858627319336 MB/sec│ + │ - WaitScannerTime: 56s528ms │ + └-----------------------------------------------------┘ + ``` + +## Keywords + + SHOW, LOAD, PROFILE + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD-WARNINGS.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD-WARNINGS.md new file mode 100644 index 0000000000000..314d0b245ba2b --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD-WARNINGS.md @@ -0,0 +1,60 @@ +--- +{ + "title": "SHOW LOAD WARNINGS", + "language": "en" +} +--- + + + +## Description + +If the import task fails and the error message is `ETL_QUALITY_UNSATISFIED`, it means that there is an import quality problem. If you want to see these import tasks with quality problems, change the statement to complete this operation. + +grammar: + +```sql +SHOW LOAD WARNINGS +[FROM db_name] +[ + WHERE + [LABEL[="your_label"]] + [LOAD_JOB_ID = ["job id"]] +] +``` + +1) If db_name is not specified, the current default db is used +1) If LABEL = is used, it matches the specified label exactly +1) If LOAD_JOB_ID is specified, match the specified JOB ID exactly + +## Example + +1. Display the data with quality problems in the import task of the specified db, and specify the label as "load_demo_20210112" + + ```sql + SHOW LOAD WARNINGS FROM demo WHERE LABEL = "load_demo_20210112" + ``` + +## Keywords + + SHOW, LOAD, WARNINGS + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD.md new file mode 100644 index 0000000000000..50642997316bb --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD.md @@ -0,0 +1,113 @@ +--- +{ + "title": "SHOW LOAD", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to display the execution of the specified import task + +grammar: + +```sql +SHOW LOAD +[FROM db_name] +[ + WHERE + [LABEL [ = "your_label" | LIKE "label_matcher"]] + [STATE = ["PENDING"|"ETL"|"LOADING"|"FINISHED"|"CANCELLED"|]] +] +[ORDER BY...] +[LIMIT limit][OFFSET offset]; +``` + +illustrate: + +1. If db_name is not specified, the current default db is used + +2. If LABEL LIKE is used, it will match import tasks whose label contains label_matcher + +3. If LABEL = is used, it will match the specified label exactly + +4. If STATE is specified, matches the LOAD state + +5. You can use ORDER BY to sort on any combination of columns + +6. If LIMIT is specified, limit matching records are displayed. Otherwise show all + +7. If OFFSET is specified, the query results are displayed starting at offset offset. By default the offset is 0. + +8. If you are using broker/mini load, the connections in the URL column can be viewed using the following command: + + ```sql + SHOW LOAD WARNINGS ON 'url' + ``` + +## Example + +1. Show all import tasks for default db + + ```sql + SHOW LOAD; + ``` + +2. Display the import tasks of the specified db, the label contains the string "2014_01_02", and display the oldest 10 + + ```sql + SHOW LOAD FROM example_db WHERE LABEL LIKE "2014_01_02" LIMIT 10; + ``` + +3. Display the import tasks of the specified db, specify the label as "load_example_db_20140102" and sort by LoadStartTime in descending order + + ```sql + SHOW LOAD FROM example_db WHERE LABEL = "load_example_db_20140102" ORDER BY LoadStartTime DESC; + ``` + +4. Display the import task of the specified db, specify the label as "load_example_db_20140102", the state as "loading", and sort by LoadStartTime in descending order + + ```sql + SHOW LOAD FROM example_db WHERE LABEL = "load_example_db_20140102" AND STATE = "loading" ORDER BY LoadStartTime DESC; + ``` + +5. Display the import tasks of the specified db and sort them in descending order by LoadStartTime, and display 10 query results starting from offset 5 + + ```sql + SHOW LOAD FROM example_db ORDER BY LoadStartTime DESC limit 5,10; + SHOW LOAD FROM example_db ORDER BY LoadStartTime DESC limit 10 offset 5; + ``` + +6. Small batch import is a command to check the import status + + ``` + curl --location-trusted -u {user}:{passwd} http://{hostname}:{port}/api/{database}/_load_info?label={labelname} + ``` + +## Keywords + + SHOW, LOAD + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-ROUTINE-LOAD-TASK.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-ROUTINE-LOAD-TASK.md new file mode 100644 index 0000000000000..c275b9cd2ae1f --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-ROUTINE-LOAD-TASK.md @@ -0,0 +1,79 @@ +--- +{ + "title": "SHOW ROUTINE LOAD TASK", + "language": "en" +} +--- + + + + + +## Description + +View the currently running subtasks of a specified Routine Load job. + + + +```sql +SHOW ROUTINE LOAD TASK +WHERE JobName = "job_name"; +``` + +The returned results are as follows: + +```text + TaskId: d67ce537f1be4b86-abf47530b79ab8e6 + TxnId: 4 + TxnStatus: UNKNOWN + JobId: 10280 + CreateTime: 2020-12-12 20:29:48 + ExecuteStartTime: 2020-12-12 20:29:48 + Timeout: 20 + BeId: 10002 +DataSourceProperties: {"0":19} +``` + +- `TaskId`: The unique ID of the subtask. +- `TxnId`: The import transaction ID corresponding to the subtask. +- `TxnStatus`: The import transaction status corresponding to the subtask. When TxnStatus is null, it means that the subtask has not yet started scheduling. +- `JobId`: The job ID corresponding to the subtask. +- `CreateTime`: The creation time of the subtask. +- `ExecuteStartTime`: The time when the subtask is scheduled to be executed, usually later than the creation time. +- `Timeout`: Subtask timeout, usually twice the `max_batch_interval` set by the job. +- `BeId`: The ID of the BE node executing this subtask. +- `DataSourceProperties`: The starting offset of the Kafka Partition that the subtask is ready to consume. is a Json format string. Key is Partition Id. Value is the starting offset of consumption. + +## Example + +1. Display the subtask information of the routine import task named test1. + + ```sql + SHOW ROUTINE LOAD TASK WHERE JobName = "test1"; + ``` + +## Keywords + + SHOW, ROUTINE, LOAD, TASK + +## Best Practice + +With this command, you can view how many subtasks are currently running in a Routine Load job, and which BE node is running on. + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-ROUTINE-LOAD.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-ROUTINE-LOAD.md new file mode 100644 index 0000000000000..201a06b0bfe9c --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-ROUTINE-LOAD.md @@ -0,0 +1,125 @@ +--- +{ + "title": "SHOW ROUTINE LOAD", + "language": "en" +} +--- + + + + +## Description + +This statement is used to display the running status of the Routine Load job + +grammar: + +```sql +SHOW [ALL] ROUTINE LOAD [FOR jobName]; +``` + +Result description: + +``` + Id: job ID + Name: job name + CreateTime: job creation time + PauseTime: The last job pause time + EndTime: Job end time + DbName: corresponding database name + TableName: The name of the corresponding table (In the case of multiple tables, since it is a dynamic table, the specific table name is not displayed, and we uniformly display it as "multi-table"). + IsMultiTbl: Indicates whether it is a multi-table + State: job running state + DataSourceType: Data source type: KAFKA + CurrentTaskNum: The current number of subtasks + JobProperties: Job configuration details +DataSourceProperties: Data source configuration details + CustomProperties: custom configuration + Statistic: Job running status statistics + Progress: job running progress + Lag: job delay status +ReasonOfStateChanged: The reason for the job state change + ErrorLogUrls: The viewing address of the filtered unqualified data + OtherMsg: other error messages +``` + +* State + + There are the following 5 states: + * NEED_SCHEDULE: The job is waiting to be scheduled + * RUNNING: The job is running + * PAUSED: The job is paused + * STOPPED: The job has ended + * CANCELLED: The job was canceled + +* Progress + + For Kafka data sources, displays the currently consumed offset for each partition. For example, {"0":"2"} indicates that the consumption progress of Kafka partition 0 is 2. + +*Lag + + For Kafka data sources, shows the consumption latency of each partition. For example, {"0":10} means that the consumption delay of Kafka partition 0 is 10. + +## Example + +1. Show all routine import jobs named test1 (including stopped or canceled jobs). The result is one or more lines. + + ```sql + SHOW ALL ROUTINE LOAD FOR test1; + ``` + +2. Show the currently running routine import job named test1 + + ```sql + SHOW ROUTINE LOAD FOR test1; + ``` + +3. Display all routine import jobs (including stopped or canceled jobs) under example_db. The result is one or more lines. + + ```sql + use example_db; + SHOW ALL ROUTINE LOAD; + ``` + +4. Display all running routine import jobs under example_db + + ```sql + use example_db; + SHOW ROUTINE LOAD; + ``` + +5. Display the currently running routine import job named test1 under example_db + + ```sql + SHOW ROUTINE LOAD FOR example_db.test1; + ``` + +6. Displays all routine import jobs named test1 under example_db (including stopped or canceled jobs). The result is one or more lines. + + ```sql + SHOW ALL ROUTINE LOAD FOR example_db.test1; + ``` + +## Keywords + + SHOW, ROUTINE, LOAD + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-STREAM-LOAD.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-STREAM-LOAD.md new file mode 100644 index 0000000000000..4b175881ccee8 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-STREAM-LOAD.md @@ -0,0 +1,95 @@ +--- +{ + "title": "SHOW STREAM LOAD", + "language": "en" +} +--- + + + + +## Description + +This statement is used to display the execution of the specified Stream Load task + +grammar: + +```sql +SHOW STREAM LOAD +[FROM db_name] +[ + WHERE + [LABEL [ = "your_label" | LIKE "label_matcher"]] + [STATUS = ["SUCCESS"|"FAIL"]] +] +[ORDER BY...] +[LIMIT limit][OFFSET offset]; +``` + +illustrate: + +1. By default, BE does not record Stream Load records. If you want to view records that need to be enabled on BE, the configuration parameter is: `enable_stream_load_record=true`. For details, please refer to [BE Configuration Items](../../../admin-manual/config/be-config.md) +2. If db_name is not specified, the current default db is used +3. If LABEL LIKE is used, it will match the tasks whose label of the Stream Load task contains label_matcher +4. If LABEL = is used, it will match the specified label exactly +5. If STATUS is specified, matches STREAM LOAD status +6. You can use ORDER BY to sort on any combination of columns +7. If LIMIT is specified, limit matching records are displayed. Otherwise show all +8. If OFFSET is specified, the query results are displayed starting at offset offset. By default the offset is 0. + +## Example + +1. Show all Stream Load tasks of the default db + + ```sql + SHOW STREAM LOAD; + ``` + +2. Display the Stream Load task of the specified db, the label contains the string "2014_01_02", and display the oldest 10 + + ```sql + SHOW STREAM LOAD FROM example_db WHERE LABEL LIKE "2014_01_02" LIMIT 10; + ``` + +3. Display the Stream Load task of the specified db and specify the label as "load_example_db_20140102" + + ```sql + SHOW STREAM LOAD FROM example_db WHERE LABEL = "load_example_db_20140102"; + ``` + +4. Display the Stream Load task of the specified db, specify the status as "success", and sort by StartTime in descending order + + ```sql + SHOW STREAM LOAD FROM example_db WHERE STATUS = "success" ORDER BY StartTime DESC; + ``` + +5. Display the import tasks of the specified db and sort them in descending order of StartTime, and display 10 query results starting from offset 5 + + ```sql + SHOW STREAM LOAD FROM example_db ORDER BY StartTime DESC limit 5,10; + SHOW STREAM LOAD FROM example_db ORDER BY StartTime DESC limit 10 offset 5; + ``` + +## Keywords + +SHOW, STREAM, LOAD + + + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-SYNC-JOB.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-SYNC-JOB.md new file mode 100644 index 0000000000000..a575351668b93 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/SHOW-SYNC-JOB.md @@ -0,0 +1,59 @@ +--- +{ + "title": "SHOW SYNC JOB", + "language": "en" +} + + +--- + + + + +## Description + +This command is used to currently display the status of resident data synchronization jobs in all databases. + +grammar: + +```sql +SHOW SYNC JOB [FROM db_name] +``` + +## Example + +1. Display the status of all data synchronization jobs in the current database. + + ```sql + SHOW SYNC JOB; + ``` + +2. Display the status of all data synchronization jobs under the database `test_db`. + + ```sql + SHOW SYNC JOB FROM `test_db`; + ``` + +## Keywords + + SHOW, SYNC, JOB + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/STOP-ROUTINE-LOAD.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/STOP-ROUTINE-LOAD.md new file mode 100644 index 0000000000000..36fb589789c71 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/STOP-ROUTINE-LOAD.md @@ -0,0 +1,50 @@ +--- +{ + "title": "STOP ROUTINE LOAD", + "language": "en" +} +--- + + + + + +## Description + +User stops a Routine Load job. A stopped job cannot be rerun. + +```sql +STOP ROUTINE LOAD FOR job_name; +``` + +## Example + +1. Stop the routine import job named test1. + + ```sql + STOP ROUTINE LOAD FOR test1; + ``` + +## Keywords + + STOP, ROUTINE, LOAD + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/STOP-SYNC-JOB.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/STOP-SYNC-JOB.md new file mode 100644 index 0000000000000..140058b43a205 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/STOP-SYNC-JOB.md @@ -0,0 +1,51 @@ +--- +{ + "title": "STOP SYNC JOB", + "language": "en" +} +--- + + + + +## Description + +Stop a non-stop resident data synchronization job in a database by `job_name`. + +grammar: + +```sql +STOP SYNC JOB [db.]job_name +``` + +## Example + +1. Stop the data sync job named `job_name` + + ```sql + STOP SYNC JOB `job_name`; + ``` + +## Keywords + + STOP, SYNC, JOB + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/data-modification/load-and-export/SYNC.md b/docs/sql-manual/sql-statements/data-modification/load-and-export/SYNC.md new file mode 100644 index 0000000000000..53307c0626d2e --- /dev/null +++ b/docs/sql-manual/sql-statements/data-modification/load-and-export/SYNC.md @@ -0,0 +1,50 @@ +--- +{ + "title": "SYNC", + "language": "en" +} +--- + + + +## Description + +Used to synchronize metadata for fe non-master nodes. doris only master node can write fe metadata, other fe nodes write metadata operations will be forwarded to master. After master finishes metadata writing operation, there will be a short delay for non-master nodes to replay metadata, you can use this statement to synchronize metadata. + +grammar: + +```sql +SYNC; +``` + +## Example + +1. Synchronized metadata: + + ```sql + SYNC; + ``` + +## Keywords + + SYNC + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/EXPLAIN.md b/docs/sql-manual/sql-statements/data-query/EXPLAIN.md similarity index 99% rename from docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/EXPLAIN.md rename to docs/sql-manual/sql-statements/data-query/EXPLAIN.md index 24736ec7d6a91..f572c1210420f 100644 --- a/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/EXPLAIN.md +++ b/docs/sql-manual/sql-statements/data-query/EXPLAIN.md @@ -144,6 +144,7 @@ Operators are linked to their child nodes with dashed lines. When an operator ha **Sink Methods** + | Name | Description | | :----------------- | :----------------------------------------------------------- | | STREAM DATA SINK | Outputs data to the next Fragment. It includes two lines of information.
First line: The downstream EXCHANGE NODE to which data is sent.
Second line: The method of data distribution.
- UNPARTITIONED means each downstream instance receives the full data set. This typically occurs in broadcast joins or when single-instance logic is required, such as global limit or order by.
- RANDOM means each downstream instance receives a random subset of data without repetition.
- HASH_PARTITIONED uses the listed slots as keys to hash and send data shards to the same downstream instance. This is often used upstream of partition hash joins or the second stage of two-phase aggregations. | diff --git a/docs/sql-manual/sql-statements/data-query/SELECT.md b/docs/sql-manual/sql-statements/data-query/SELECT.md new file mode 100644 index 0000000000000..ed5b6bca16ec1 --- /dev/null +++ b/docs/sql-manual/sql-statements/data-query/SELECT.md @@ -0,0 +1,414 @@ +--- +{ + "title": "SELECT", + "language": "en" +} + +--- + + + + + + +## Description + +Mainly introduces the use of Select syntax + +grammar: + +```sql +SELECT + [hint_statement, ...] + [ALL | DISTINCT | DISTINCTROW | ALL EXCEPT ( col_name1 [, col_name2, col_name3, ...] )] + select_expr [, select_expr ...] + [FROM table_references + [PARTITION partition_list] + [TABLET tabletid_list] + [TABLESAMPLE sample_value [ROWS | PERCENT] + [REPEATABLE pos_seek]] + [WHERE where_condition] + [GROUP BY [GROUPING SETS | ROLLUP | CUBE] {col_name | expr | position}] + [HAVING where_condition] + [ORDER BY {col_name | expr | position} + [ASC | DESC], ...] + [LIMIT {[offset,] row_count | row_count OFFSET offset}] + [INTO OUTFILE 'file_name'] +``` + +1. **Syntax Description:** + + 1. select_expr, ... Columns retrieved and displayed in the result, when using an alias, as is optional. + + 2. select_expr, ... Retrieved target table (one or more tables (including temporary tables generated by subqueries) + + 3. where_definition retrieves the condition (expression), if there is a WHERE clause, the condition filters the row data. where_condition is an expression that evaluates to true for each row to be selected. Without the WHERE clause, the statement selects all rows. In WHERE expressions, you can use any MySQL supported functions and operators except aggregate functions + + 4. `ALL | DISTINCT ` : to refresh the result set, all is all, distinct/distinctrow will refresh the duplicate columns, the default is all + + 5. `ALL EXCEPT`: Filter on the full (all) result set, except specifies the name of one or more columns to be excluded from the full result set. All matching column names will be ignored in the output. + + This feature is supported since the Apache Doris 1.2 version + + + 6. `INTO OUTFILE 'file_name' ` : save the result to a new file (which did not exist before), the difference lies in the save format. + + 7. `Group by having`: Group the result set, and brush the result of group by when having appears. `Grouping Sets`, `Rollup`, `Cube` are extensions of group by, please refer to [GROUPING SETS DESIGN](https://doris.apache.org/community/design/grouping_sets_design) for details. + + 8. `Order by`: Sort the final result, Order by sorts the result set by comparing the size of one or more columns. + + Order by is a time-consuming and resource-intensive operation, because all data needs to be sent to 1 node before it can be sorted, and the sorting operation requires more memory than the non-sorting operation. + + If you need to return the top N sorted results, you need to use the LIMIT clause; in order to limit memory usage, if the user does not specify the LIMIT clause, the first 65535 sorted results are returned by default. + + 9. `Limit n`: limit the number of lines in the output result, `limit m,n` means output n records starting from the mth line.You should use `order by` before you use `limit m,n`, otherwise the data may be inconsistent each time it is executed. + + 10. The `Having` clause does not filter the row data in the table, but filters the results produced by the aggregate function. + + Typically `having` is used with aggregate functions (eg :`COUNT(), SUM(), AVG(), MIN(), MAX()`) and `group by` clauses. + + 11. SELECT supports explicit partition selection using PARTITION containing a list of partitions or subpartitions (or both) following the name of the table in `table_reference` + + 12. `[TABLET tids] TABLESAMPLE n [ROWS | PERCENT] [REPEATABLE seek]`: Limit the number of rows read from the table in the FROM clause, select a number of Tablets pseudo-randomly from the table according to the specified number of rows or percentages, and specify the number of seeds in REPEATABLE to return the selected samples again. In addition, you can also manually specify the TableID, Note that this can only be used for OLAP tables. + + 13. `hint_statement`: hint in front of the selectlist indicates that hints can be used to influence the behavior of the optimizer in order to obtain the desired execution plan. Details refer to [joinHint using document] (https://doris.apache.org/en/docs/query-acceleration/hint/joinHint.md) + +**Syntax constraints:** + +1. SELECT can also be used to retrieve calculated rows without referencing any table. +2. All clauses must be ordered strictly according to the above format, and a HAVING clause must be placed after the GROUP BY clause and before the ORDER BY clause. +3. The alias keyword AS is optional. Aliases can be used for group by, order by and having +4. Where clause: The WHERE statement is executed to determine which rows should be included in the GROUP BY section, and HAVING is used to determine which rows in the result set should be used. +5. The HAVING clause can refer to the total function, but the WHERE clause cannot refer to, such as count, sum, max, min, avg, at the same time, the where clause can refer to other functions except the total function. Column aliases cannot be used in the Where clause to define conditions. +6. Group by followed by with rollup can count the results one or more times. + +**Join query:** + +Doris supports JOIN syntax + +```sql +JOIN +table_references: + table_reference [, table_reference] … +table_reference: + table_factor + | join_table +table_factor: + tbl_name [[AS] alias] + [{USE|IGNORE|FORCE} INDEX (key_list)] + | ( table_references ) + | { OJ table_reference LEFT OUTER JOIN table_reference + ON conditional_expr } +join_table: + table_reference [INNER | CROSS] JOIN table_factor [join_condition] + | table_reference LEFT [OUTER] JOIN table_reference join_condition + | table_reference NATURAL [LEFT [OUTER]] JOIN table_factor + | table_reference RIGHT [OUTER] JOIN table_reference join_condition + | table_reference NATURAL [RIGHT [OUTER]] JOIN table_factor +join_condition: + ON conditional_expr +``` + +**UNION Grammar:** + +```sql +SELECT ... +UNION [ALL| DISTINCT] SELECT ...... +[UNION [ALL| DISTINCT] SELECT ...] +``` + +`UNION` is used to combine the results of multiple `SELECT` statements into a single result set. + +The column names in the first `SELECT` statement are used as the column names in the returned results. The selected columns listed in the corresponding position of each `SELECT` statement should have the same data type. (For example, the first column selected by the first statement should be of the same type as the first column selected by other statements.) + +The default behavior of `UNION` is to remove duplicate rows from the result. The optional `DISTINCT` keyword has no effect other than the default, since it also specifies duplicate row removal. With the optional `ALL` keyword, no duplicate row removal occurs, and the result includes all matching rows in all `SELECT` statements + +**WITH statement**: + +To specify common table expressions, use the `WITH` clause with one or more comma-separated clauses. Each subclause provides a subquery that generates the result set and associates the name with the subquery. The following example defines `WITH` clauses in CTEs named `cte1` and `cte2`, and refers to the `WITH` clause below their top-level `SELECT`: + +```sql +WITH + cte1 AS (SELECT a,b FROM table1), + cte2 AS (SELECT c,d FROM table2) +SELECT b,d FROM cte1 JOIN cte2 +WHERE cte1.a = cte2.c; +``` + +In a statement containing the `WITH` clause, each CTE name can be referenced to access the corresponding CTE result set. + +CTE names can be referenced in other CTEs, allowing CTEs to be defined based on other CTEs. + +Recursive CTE is currently not supported. + +## Example + +1. Query the names of students whose ages are 18, 20, 25 + + ```sql + select Name from student where age in (18,20,25); + ``` +2. ALL EXCEPT Example + ```sql + -- Query all information except the students' age + select * except(age) from student; + ``` + +3. GROUP BY Example + + ```sql + --Query the tb_book table, group by type, and find the average price of each type of book, + select type,avg(price) from tb_book group by type; + ``` + +4. DISTINCT Use + + ``` + --Query the tb_book table to remove duplicate type data + select distinct type from tb_book; + ``` + +5. ORDER BY Example + + Sort query results in ascending (default) or descending (DESC) order. Ascending NULL is first, descending NULL is last + + ```sql + --Query all records in the tb_book table, sort them in descending order by id, and display three records + select * from tb_book order by id desc limit 3; + ``` + +6. LIKE fuzzy query + + Can realize fuzzy query, it has two wildcards: `%` and `_`, `%` can match one or more characters, `_` can match one character + + ``` + --Find all books whose second character is h + select * from tb_book where name like('_h%'); + ``` + +7. LIMIT limits the number of result rows + + ```sql + --1. Display 3 records in descending order + select * from tb_book order by price desc limit 3; + + --2. Display 4 records from id=1 + select * from tb_book where id limit 1,4; + ``` + +8. CONCAT join multiple columns + + ```sql + --Combine name and price into a new string output + select id,concat(name,":",price) as info,type from tb_book; + ``` + +9. Using functions and expressions + + ```sql + --Calculate the total price of various books in the tb_book table + select sum(price) as total,type from tb_book group by type; + --20% off price + select *,(price * 0.8) as "20%" from tb_book; + ``` + +10. UNION Example + + ```sql + SELECT a FROM t1 WHERE a = 10 AND B = 1 ORDER by LIMIT 10 + UNION + SELECT a FROM t2 WHERE a = 11 AND B = 2 ORDER by LIMIT 10; + ``` + +11. WITH clause example + + ```sql + WITH cte AS + ( + SELECT 1 AS col1, 2 AS col2 + UNION ALL + SELECT 3, 4 + ) + SELECT col1, col2 FROM cte; + ``` + +12. JOIN Exampel + + ```sql + SELECT * FROM t1 LEFT JOIN (t2, t3, t4) + ON (t2.a = t1.a AND t3.b = t1.b AND t4.c = t1.c) + ``` + + Equivalent to + + ```sql + SELECT * FROM t1 LEFT JOIN (t2 CROSS JOIN t3 CROSS JOIN t4) + ON (t2.a = t1.a AND t3.b = t1.b AND t4.c = t1.c) + ``` + +13. INNER JOIN + + ```sql + SELECT t1.name, t2.salary + FROM employee AS t1 INNER JOIN info AS t2 ON t1.name = t2.name; + + SELECT t1.name, t2.salary + FROM employee t1 INNER JOIN info t2 ON t1.name = t2.name; + ``` + +14. LEFT JOIN + + ```sql + SELECT left_tbl.* + FROM left_tbl LEFT JOIN right_tbl ON left_tbl.id = right_tbl.id + WHERE right_tbl.id IS NULL; + ``` + +15. RIGHT JOIN + + ```sql + mysql> SELECT * FROM t1 RIGHT JOIN t2 ON (t1.a = t2.a); + +------+------+------+------+ + | a | b | a | c | + +------+------+------+------+ + | 2 | y | 2 | z | + | NULL | NULL | 3 | w | + +------+------+------+------+ + ``` + +16. TABLESAMPLE + + ```sql + --Pseudo-randomly sample 1000 rows in t1. Note that several Tablets are actually selected according to the statistics of the table, and the total number of selected Tablet rows may be greater than 1000, so if you want to explicitly return 1000 rows, you need to add Limit. + SELECT * FROM t1 TABLET(10001) TABLESAMPLE(1000 ROWS) REPEATABLE 2 limit 1000; + ``` + +## Keywords + + SELECT + +## Best Practice + +1. ome additional knowledge about the SELECT clause + + - An alias can be specified for select_expr using AS alias_name. Aliases are used as column names in expressions and can be used in GROUP BY, ORDER BY or HAVING clauses. The AS keyword is a good habit to use when specifying aliases for columns. + + - table_references after FROM indicates one or more tables participating in the query. If more than one table is listed, a JOIN operation is performed. And for each specified table, you can define an alias for it + + - The selected column after SELECT can be referenced in ORDER IN and GROUP BY by column name, column alias or integer (starting from 1) representing the column position + + ```sql + SELECT college, region, seed FROM tournament + ORDER BY region, seed; + + SELECT college, region AS r, seed AS s FROM tournament + ORDER BY r, s; + + SELECT college, region, seed FROM tournament + ORDER BY 2, 3; + ``` + + - If ORDER BY appears in a subquery and also applies to the outer query, the outermost ORDER BY takes precedence. + + - If GROUP BY is used, the grouped columns are automatically sorted in ascending order (as if there was an ORDER BY statement followed by the same columns). If you want to avoid the overhead of GROUP BY due to automatic sorting, adding ORDER BY NULL can solve it: + + ```sql + SELECT a, COUNT(b) FROM test_table GROUP BY a ORDER BY NULL; + ``` + + + + - When sorting columns in a SELECT using ORDER BY or GROUP BY, the server sorts values using only the initial number of bytes indicated by the max_sort_length system variable. + + - Having clauses are generally applied last, just before the result set is returned to the MySQL client, and is not optimized. (while LIMIT is applied after HAVING) + + The SQL standard requires: HAVING must refer to a column in the GROUP BY list or used by an aggregate function. However, MySQL extends this by allowing HAVING to refer to columns in the Select clause list, as well as columns from outer subqueries. + + A warning is generated if the column referenced by HAVING is ambiguous. In the following statement, col2 is ambiguous: + + ```sql + SELECT COUNT(col1) AS col2 FROM t GROUP BY col2 HAVING col2 = 2; + ``` + + - Remember not to use HAVING where WHERE should be used. HAVING is paired with GROUP BY. + + - The HAVING clause can refer to aggregate functions, while WHERE cannot. + + ```sql + SELECT user, MAX(salary) FROM users + GROUP BY user HAVING MAX(salary) > 10; + ``` + + - The LIMIT clause can be used to constrain the number of rows returned by a SELECT statement. LIMIT can have one or two arguments, both of which must be non-negative integers. + + ```sql + /*Retrieve 6~15 rows in the result set*/ + SELECT * FROM tbl LIMIT 5,10; + /*Then if you want to retrieve all rows after a certain offset is set, you can set a very large constant for the second parameter. The following query fetches all data from row 96 onwards */ + SELECT * FROM tbl LIMIT 95,18446744073709551615; + /*If LIMIT has only one parameter, the parameter specifies the number of rows that should be retrieved, and the offset defaults to 0, that is, starting from the first row*/ + ``` + + - SELECT...INTO allows query results to be written to a file + +2. Modifiers of the SELECT keyword + + - deduplication + + The ALL and DISTINCT modifiers specify whether to deduplicate rows in the result set (should not be a column). + + ALL is the default modifier, that is, all rows that meet the requirements are to be retrieved. + + DISTINCT removes duplicate rows. + +2. The main advantage of subqueries + + - Subqueries allow structured queries so that each part of a statement can be isolated. + - Some operations require complex unions and associations. Subqueries provide other ways to perform these operations + +3. Speed up queries + + - Use Doris's partition and bucket as data filtering conditions as much as possible to reduce the scope of data scanning + - Make full use of Doris's prefix index fields as data filter conditions to speed up query speed + +4. UNION + + - Using only the union keyword has the same effect as using union disitnct. Since the deduplication work is more memory-intensive, the query speed using the union all operation will be faster and the memory consumption will be less. If users want to perform order by and limit operations on the returned result set, they need to put the union operation in the subquery, then select from subquery, and finally put the subquery and order by outside the subquery. + + ```sql + select * from (select age from student_01 union all select age from student_02) as t1 + order by age limit 4; + + +-------------+ + | age | + +-------------+ + | 18 | + | 19 | + | 20 | + | 21 | + +-------------+ + 4 rows in set (0.01 sec) + ``` + +6. JOIN + + - In the inner join condition, in addition to supporting equal-valued joins, it also supports unequal-valued joins. For performance reasons, it is recommended to use equal-valued joins. + - Other joins only support equivalent joins + diff --git a/docs/sql-manual/sql-statements/database/ALTER-DATABASE.md b/docs/sql-manual/sql-statements/database/ALTER-DATABASE.md new file mode 100644 index 0000000000000..7746d3a317ef9 --- /dev/null +++ b/docs/sql-manual/sql-statements/database/ALTER-DATABASE.md @@ -0,0 +1,105 @@ +--- +{ + "title": "ALTER DATABASE", + "language": "en" +} +--- + + + + +## Description + +This statement is used to set properties of the specified database. (administrator only) + +1) Set the database data quota, the unit is B/K/KB/M/MB/G/GB/T/TB/P/PB + +```sql +ALTER DATABASE db_name SET DATA QUOTA quota; +``` + +2) Rename the database + +```sql +ALTER DATABASE db_name RENAME new_db_name; +``` + +3) Set the quota for the number of copies of the database + +```sql +ALTER DATABASE db_name SET REPLICA QUOTA quota; +``` + +illustrate: + After renaming the database, use the REVOKE and GRANT commands to modify the appropriate user permissions, if necessary. + The default data quota for the database is 1024GB, and the default replica quota is 1073741824. + +4) Modify the properties of an existing database + +```sql +ALTER DATABASE db_name SET PROPERTIES ("key"="value", ...); +``` + +## Example + +1. Set the specified database data volume quota + +```sql +ALTER DATABASE example_db SET DATA QUOTA 10995116277760; +The above unit is bytes, which is equivalent to +ALTER DATABASE example_db SET DATA QUOTA 10T; + +ALTER DATABASE example_db SET DATA QUOTA 100G; + +ALTER DATABASE example_db SET DATA QUOTA 200M; +``` + +2. Rename the database example_db to example_db2 + +```sql +ALTER DATABASE example_db RENAME example_db2; +``` + +3. Set the quota for the number of copies of the specified database + +```sql +ALTER DATABASE example_db SET REPLICA QUOTA 102400; +``` + +4. Modify the default replica distribution policy for tables in db (this operation only applies to newly created tables and will not modify existing tables in db) + +```sql +ALTER DATABASE example_db SET PROPERTIES("replication_allocation" = "tag.location.default:2"); +``` + +5. Cancel the default replica distribution policy for tables in db (this operation only applies to newly created tables and will not modify existing tables in db) + +```sql +ALTER DATABASE example_db SET PROPERTIES("replication_allocation" = ""); +``` + +## Keywords + +```text +ALTER,DATABASE,RENAME +``` + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/database/CREATE-DATABASE.md b/docs/sql-manual/sql-statements/database/CREATE-DATABASE.md new file mode 100644 index 0000000000000..0129682d23858 --- /dev/null +++ b/docs/sql-manual/sql-statements/database/CREATE-DATABASE.md @@ -0,0 +1,77 @@ +--- +{ + "title": "CREATE DATABASE", + "language": "en" +} +--- + + + + +## Description + +This statement is used to create a new database (database) + +grammar: + +```sql +CREATE DATABASE [IF NOT EXISTS] db_name + [PROPERTIES ("key"="value", ...)]; +``` + +`PROPERTIES` Additional information about the database, which can be defaulted. + +- If you want to specify the default replica distribution for tables in db, you need to specify `replication_allocation` (the `replication_allocation` attribute of table will have higher priority than db) + + ```sql + PROPERTIES ( + "replication_allocation" = "tag.location.default:3" + ) + ``` + +## Example + +1. Create a new database db_test + + ```sql + CREATE DATABASE db_test; + ``` + +2. Create a new database with default replica distribution: + + ```sql + CREATE DATABASE `iceberg_test` + PROPERTIES ( + "replication_allocation" = "tag.location.group_1:3" + ); + ``` + +:::caution +If the create table statement has attributes replication_allocation or replication_num, then the default replica distribution policy of the database will not take effect. +::: + +## Keywords + +```text +CREATE, DATABASE +``` + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/database/DROP-DATABASE.md b/docs/sql-manual/sql-statements/database/DROP-DATABASE.md new file mode 100644 index 0000000000000..74f084f6bc24c --- /dev/null +++ b/docs/sql-manual/sql-statements/database/DROP-DATABASE.md @@ -0,0 +1,54 @@ +--- +{ + "title": "DROP DATABASE", + "language": "en" +} +--- + + + + +## Description + +This statement is used to delete the database (database) +grammar: + +```sql +DROP DATABASE [IF EXISTS] db_name [FORCE]; +``` + +illustrate: + +- During the execution of DROP DATABASE, the deleted database can be recovered through the RECOVER statement. See the [RECOVER](../../Database-Administration-Statements/RECOVER.md) statement for details +- If you execute DROP DATABASE FORCE, the system will not check the database for unfinished transactions, the database will be deleted directly and cannot be recovered, this operation is generally not recommended + +## Example + +1. Delete the database db_test + + ```sql + DROP DATABASE db_test; + ``` + +## Keywords + + DROP, DATABASE + +## Best Practice diff --git a/docs/sql-manual/sql-statements/database/SHOW-CREATE-DATABASE.md b/docs/sql-manual/sql-statements/database/SHOW-CREATE-DATABASE.md new file mode 100644 index 0000000000000..abb3169a7dbe7 --- /dev/null +++ b/docs/sql-manual/sql-statements/database/SHOW-CREATE-DATABASE.md @@ -0,0 +1,73 @@ +--- +{ + "title": "SHOW CREATE DATABASE", + "language": "en" +} +--- + + + + +## Description + +This statement checks the creation of the doris database, support database from both internal catalog and hms catalog + +grammar: + +```sql +SHOW CREATE DATABASE db_name; +``` + +illustrate: + +- `db_name`: The name of the database +- if specific a database from hms catalog, will return same with this stmt in hive + +## Example + +1. View the creation of the test database in doris internal catalog + + ```sql + mysql> SHOW CREATE DATABASE test; + +----------+----------------------------+ + | Database | Create Database | + +----------+----------------------------+ + | test | CREATE DATABASE `test` | + +----------+----------------------------+ + 1 row in set (0.00 sec) + ``` + +2. view a database named `hdfs_text` from a hms catalog + + ```sql + mysql> show create database hdfs_text; + +-----------+------------------------------------------------------------------------------------+ + | Database | Create Database | + +-----------+------------------------------------------------------------------------------------+ + | hdfs_text | CREATE DATABASE `hdfs_text` LOCATION 'hdfs://HDFS1009138/hive/warehouse/hdfs_text' | + +-----------+------------------------------------------------------------------------------------+ + 1 row in set (0.01 sec) + ``` + +## Keywords + + SHOW, CREATE, DATABASE + +## Best Practice \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/database/SHOW-DATABASE-ID.md b/docs/sql-manual/sql-statements/database/SHOW-DATABASE-ID.md new file mode 100644 index 0000000000000..00b565dca75dc --- /dev/null +++ b/docs/sql-manual/sql-statements/database/SHOW-DATABASE-ID.md @@ -0,0 +1,50 @@ +--- +{ + "title": "SHOW DATABASE ID", + "language": "en" +} +--- + + + + +## Description + +This statement is used to find the corresponding database name according to the database id (only for administrators) + +grammar: + +```sql +SHOW DATABASE [database_id] +``` + +## Example + +1. Find the corresponding database name according to the database id + + ```sql + SHOW DATABASE 1001; + ``` + +## Keywords + +SHOW, DATABASE, ID + + diff --git a/docs/sql-manual/sql-statements/database/SHOW-DATABASES.md b/docs/sql-manual/sql-statements/database/SHOW-DATABASES.md new file mode 100644 index 0000000000000..16e8b88458978 --- /dev/null +++ b/docs/sql-manual/sql-statements/database/SHOW-DATABASES.md @@ -0,0 +1,94 @@ +--- +{ + "title": "SHOW DATABASES", + "language": "en" +} +--- + + + + +## Description + +This statement is used to display the currently visible db + +grammar: + +```sql +SHOW DATABASES [FROM catalog] [filter expr]; +``` + +illustrate: +1. `SHOW DATABASES` will get all database names from current catalog. +2. `SHOW DATABASES FROM catalog` will all database names from the catalog named 'catalog'. +3. `SHOW DATABASES filter_expr` will get filtered database names from current catalog. +4. `SHOW DATABASES FROM catalog filter_expr` is not support yet. + +## Example +1. Display all the database names from current catalog. + + ```sql + SHOW DATABASES; + ``` + + ``` + +--------------------+ + | Database | + +--------------------+ + | test | + | information_schema | + +--------------------+ + ``` + +2. Display all database names from the catalog named 'hms_catalog'. + + ```sql + SHOW DATABASES from hms_catalog; + ``` + + ``` + +---------------+ + | Database | + +---------------+ + | default | + | tpch | + +---------------+ + ``` + +3. Display the filtered database names from current catalog with the expr 'like'. + + ```sql + SHOW DATABASES like 'infor%'; + ``` + + ``` + +--------------------+ + | Database | + +--------------------+ + | information_schema | + +--------------------+ + ``` + +## Keywords + + SHOW, DATABASES + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/function/CREATE-FUNCTION.md b/docs/sql-manual/sql-statements/function/CREATE-FUNCTION.md new file mode 100644 index 0000000000000..a26270850ed7b --- /dev/null +++ b/docs/sql-manual/sql-statements/function/CREATE-FUNCTION.md @@ -0,0 +1,127 @@ +--- +{ + "title": "CREATE FUNCTION", + "language": "en" +} +--- + + + +## Description + +This statement creates a custom function. Executing this command requires the user to have `ADMIN` privileges. + +If `function_name` contains the database name, then the custom function will be created in the corresponding database, otherwise the function will be created in the database where the current session is located. The name and parameters of the new function cannot be the same as the existing functions in the current namespace, otherwise the creation will fail. But only with the same name and different parameters can be created successfully. + +grammar: + +```sql +CREATE [GLOBAL] [AGGREGATE] [ALIAS] FUNCTION function_name + (arg_type [, ...]) + [RETURNS ret_type] + [INTERMEDIATE inter_type] + [WITH PARAMETER(param [,...]) AS origin_function] + [PROPERTIES ("key" = "value" [, ...]) ] +``` + +Parameter Description: + +- `GLOBAL`: If there is this item, it means that the created function is a global function. + +- `AGGREGATE`: If there is this item, it means that the created function is an aggregate function. + + +- `ALIAS`: If there is this item, it means that the created function is an alias function. + + + If the above two items are absent, it means that the created function is a scalar function + +- `function_name`: The name of the function to be created, which can include the name of the database. For example: `db1.my_func`. + + +- `arg_type`: The parameter type of the function, which is the same as the type defined when creating the table. Variable-length parameters can be represented by `, ...`. If it is a variable-length type, the type of the variable-length parameter is the same as that of the last non-variable-length parameter. + + **NOTE**: `ALIAS FUNCTION` does not support variable-length arguments and must have at least one argument. + +- `ret_type`: Required for creating new functions. If you are aliasing an existing function, you do not need to fill in this parameter. + + +- `inter_type`: The data type used to represent the intermediate stage of the aggregation function. + + +- `param`: used to represent the parameter of the alias function, including at least one. + + +- `origin_function`: used to represent the original function corresponding to the alias function. + + +- `properties`: Used to set function-related properties, the properties that can be set include: + + - `file`: Indicates the jar package containing the user UDF. In a multi-machine environment, you can also use http to download the jar package. This parameter is mandatory. + + - `symbol`: Indicates the name of the class containing the UDF class. This parameter must be set + + - `type`: Indicates the UDF call type, the default is Native, and JAVA_UDF is passed when using Java UDF. + + - `always_nullable`: Indicates whether NULL values may appear in the UDF return result, is an optional parameter, and the default value is true. + + +## Example + +1. Create a custom UDF function + + ```sql + CREATE FUNCTION java_udf_add_one(int) RETURNS int PROPERTIES ( + "file"="file:///path/to/java-udf-demo-jar-with-dependencies.jar", + "symbol"="org.apache.doris.udf.AddOne", + "always_nullable"="true", + "type"="JAVA_UDF" + ); + ``` + + +2. Create a custom UDAF function + + ```sql + CREATE AGGREGATE FUNCTION simple_sum(INT) RETURNS INT PROPERTIES ( + "file"="file:///pathTo/java-udaf.jar", + "symbol"="org.apache.doris.udf.demo.SimpleDemo", + "always_nullable"="true", + "type"="JAVA_UDF" + ); + ``` + +3. Create a custom alias function + + ```sql + CREATE ALIAS FUNCTION id_masking(INT) WITH PARAMETER(id) AS CONCAT(LEFT(id, 3), '****', RIGHT(id, 4)); + ``` + +4. Create a global custom alias function + + ```sql + CREATE GLOBAL ALIAS FUNCTION id_masking(INT) WITH PARAMETER(id) AS CONCAT(LEFT(id, 3), '****', RIGHT(id, 4)); + ``` + +## Keywords + + CREATE, FUNCTION + +## Best Practice diff --git a/docs/sql-manual/sql-statements/function/DESC-FUNCTION.md b/docs/sql-manual/sql-statements/function/DESC-FUNCTION.md new file mode 100644 index 0000000000000..634ba5fc9d9ed --- /dev/null +++ b/docs/sql-manual/sql-statements/function/DESC-FUNCTION.md @@ -0,0 +1,64 @@ +--- +{ + "title": "DESC FUNCTION", + "language": "en" +} +--- + + + + +## Description + +Use the desc function table_valued_function to obtain the schema information for the corresponding table-valued function. + +## Syntax + +```sql +DESC FUNCTION +``` + +## Required Parameters + +**** + +> table_valued_function, the name of the table-valued function, such as CATALOGS. For a list of supported table-valued functions, please refer to the "[Table-Valued Functions](https://doris.apache.org/en/docs/dev/sql-manual/sql-functions/table-valued-functions/s3/)" section + +## Examples + +Query the information of the table-valued function CATALOGS: + +```sql +DESC FUNCTION catalogs(); +``` + +The result is as follows: + +```sql ++-------------+--------+------+-------+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++-------------+--------+------+-------+---------+-------+ +| CatalogId | bigint | No | false | NULL | NONE | +| CatalogName | text | No | false | NULL | NONE | +| CatalogType | text | No | false | NULL | NONE | +| Property | text | No | false | NULL | NONE | +| Value | text | No | false | NULL | NONE | ++-------------+--------+------+-------+---------+-------+ +``` diff --git a/docs/sql-manual/sql-statements/function/DROP-FUNCTION.md b/docs/sql-manual/sql-statements/function/DROP-FUNCTION.md new file mode 100644 index 0000000000000..bfe8976b8697e --- /dev/null +++ b/docs/sql-manual/sql-statements/function/DROP-FUNCTION.md @@ -0,0 +1,63 @@ +--- +{ + "title": "DROP FUNCTION", + "language": "en" +} +--- + + + + + + +## Description + +Delete a custom function. Function names and parameter types are exactly the same to be deleted. + +grammar: + +```sql +DROP [GLOBAL] FUNCTION function_name + (arg_type [, ...]) +``` + +Parameter Description: + +- `function_name`: the name of the function to delete +- `arg_type`: the argument list of the function to delete + +## Example + +1. Delete a function + + ```sql + DROP FUNCTION my_add(INT, INT) + ``` +2. Delete a global function + + ```sql + DROP GLOBAL FUNCTION my_add(INT, INT) + ``` + +## Keywords + + DROP, FUNCTION + +## Best Practice diff --git a/docs/sql-manual/sql-statements/function/SHOW-CREATE-FUNCTION.md b/docs/sql-manual/sql-statements/function/SHOW-CREATE-FUNCTION.md new file mode 100644 index 0000000000000..0751c505b007c --- /dev/null +++ b/docs/sql-manual/sql-statements/function/SHOW-CREATE-FUNCTION.md @@ -0,0 +1,66 @@ +--- +{ + "title": "SHOW CREATE FUNCTION", + "language": "en" +} +--- + + + + + + +## Description + +This statement is used to display the creation statement of the user-defined function + +grammar: + +```sql +SHOW CREATE [GLOBAL] FUNCTION function_name(arg_type [, ...]) [FROM db_name]]; +``` + +illustrate: +1. `global`: The show function is global +2. `function_name`: The name of the function to display +3. `arg_type`: The parameter list of the function to display +4. If db_name is not specified, the current default db is used + +**Note: the "global" keyword is only available after v2.0** + +## Example + +1. Show the creation statement of the specified function under the default db + + ```sql + SHOW CREATE FUNCTION my_add(INT, INT) + ``` +2. Show the creation statement of the specified global function + + ```sql + SHOW CREATE GLOBAL FUNCTION my_add(INT, INT) + ``` + +## Keywords + + SHOW, CREATE, FUNCTION + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/function/SHOW-FUNCTIONS.md b/docs/sql-manual/sql-statements/function/SHOW-FUNCTIONS.md new file mode 100644 index 0000000000000..88edd59bcc608 --- /dev/null +++ b/docs/sql-manual/sql-statements/function/SHOW-FUNCTIONS.md @@ -0,0 +1,129 @@ +--- +{ + "title": "SHOW FUNCTIONS", + "language": "en" +} +--- + + + + + + +## Description + +View all custom (system-provided) functions under the database. If the user specifies a database, then view the corresponding database, otherwise directly query the database where the current session is located + +Requires `SHOW` permission on this database + +grammar + +```sql +SHOW [FULL] [BUILTIN] FUNCTIONS [IN|FROM db] [LIKE 'function_pattern'] +``` + +Parameters + +>`full`: Indicates the detailed information of the display function +>`builtin`: Indicates the functions provided by the display system +>`db`: database name to query +>`function_pattern`: parameter used to filter function names + +grammar + +```sql +SHOW GLOBAL [FULL] FUNCTIONS [LIKE 'function_pattern'] +``` + +Parameters + +>`global`: Indicates it means that the show function is a global function +>`full`: Indicates the detailed information of the display function +>`function_pattern`: parameter used to filter function names + +**Note: the "global" keyword is only available after v2.0** + +## Example + +```sql +mysql> show full functions in testDb\G +**************************** 1. row ******************** ****** + Signature: my_add(INT,INT) + Return Type: INT + Function Type: Scalar +Intermediate Type: NULL + Properties: {"symbol":"_ZN9doris_udf6AddUdfEPNS_15FunctionContextERKNS_6IntValES4_","object_file":"http://host:port/libudfsample.so","md5":"cfe7a362d10f3aaf6c49974ee0f1f878"} +**************************** 2. row ******************** ****** + Signature: my_count(BIGINT) + Return Type: BIGINT + Function Type: Aggregate +Intermediate Type: NULL + Properties: { "object_file": "http: // host: port / libudasample.so", "finalize_fn": "_ZN9doris_udf13CountFinalizeEPNS_15FunctionContextERKNS_9BigIntValE", "init_fn": "_ZN9doris_udf9CountInitEPNS_15FunctionContextEPNS_9BigIntValE", "merge_fn": "_ZN9doris_udf10CountMergeEPNS_15FunctionContextERKNS_9BigIntValEPS2_", "md5": " 37d185f80f95569e2676da3d5b5b9d2f","update_fn":"_ZN9doris_udf11CountUpdateEPNS_15FunctionContextERKNS_6IntValEPNS_9BigIntValE"} +**************************** 3. row ******************** ****** + Signature: id_masking(BIGINT) + Return Type: VARCHAR + Function Type: Alias +Intermediate Type: NULL + Properties: {"parameter":"id","origin_function":"concat(left(`id`, 3), `****`, right(`id`, 4))"} + +3 rows in set (0.00 sec) +mysql> show builtin functions in testDb like 'year%'; ++---------------+ +| Function Name | ++---------------+ +| year | +| years_add | +| years_diff | +| years_sub | ++---------------+ +2 rows in set (0.00 sec) + +mysql> show global full functions\G; +*************************** 1. row *************************** + Signature: decimal(ALL, INT, INT) + Return Type: VARCHAR + Function Type: Alias +Intermediate Type: NULL + Properties: {"parameter":"col, precision, scale","origin_function":"CAST(`col` AS decimal(`precision`, `scale`))"} +*************************** 2. row *************************** + Signature: id_masking(BIGINT) + Return Type: VARCHAR + Function Type: Alias +Intermediate Type: NULL + Properties: {"parameter":"id","origin_function":"concat(left(`id`, 3), `****`, right(`id`, 4))"} +2 rows in set (0.00 sec) + +mysql> show global functions ; ++---------------+ +| Function Name | ++---------------+ +| decimal | +| id_masking | ++---------------+ +2 rows in set (0.00 sec) + +``` + +## Keywords + + SHOW, FUNCTIONS + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/job/CANCEL-TASK.md b/docs/sql-manual/sql-statements/job/CANCEL-TASK.md new file mode 100644 index 0000000000000..c8facca8335db --- /dev/null +++ b/docs/sql-manual/sql-statements/job/CANCEL-TASK.md @@ -0,0 +1,62 @@ +--- +{ +"title": "CANCEL TASK", +"language": "en" +} + +--- + + + +## Description + +Cancel a running task created by the CREATE JOB statement. + +- The task must be created by the CREATE JOB statement. +- It must be a running task. +- This function is supported from version 2.1.0. + +## Syntax + +```sql +CANCEL TASK WHERE jobName = '' AND taskId = ''; +``` +## Required Parameters + +**** + +> The name of the job, of type string. + +**** + +> The task ID, of integer type. It can be queried through the tasks table-valued function. For example: SELECT * FROM tasks('type'='insert'). For more information, please refer to "task table-valued function". + +## Access Control Requirements + +The user executing this SQL command must have at least ADMIN_PRIV privileges. + +## Examples + +Cancel a background task with jobName 'example' and taskId 378912. + + +```sql +CANCEL TASK WHERE jobName='example' AND taskId=378912 +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/job/CREATE-JOB.md b/docs/sql-manual/sql-statements/job/CREATE-JOB.md new file mode 100644 index 0000000000000..f8127931b2c9d --- /dev/null +++ b/docs/sql-manual/sql-statements/job/CREATE-JOB.md @@ -0,0 +1,171 @@ +--- +{ +"title": "CREATE JOB", +"language": "en" +} + +--- + + + +:::tip + +This statement is supported since 2.1 + +::: + +## Description + +Doris Job is a task that runs according to a predefined schedule, triggering predefined actions at specific times or intervals to help automate certain tasks. In terms of functionality, it is similar to scheduled tasks on operating systems (e.g., cron in Linux, scheduled tasks in Windows).↳ + +There are two types of Jobs: ONE_TIME and RECURRING. The ONE_TIME type of Job triggers at a specified time point and is mainly used for one-time tasks, while the RECURRING type of Job triggers at specified time intervals and is used for periodically recurring tasks. The RECURRING type of Job can specify a start time and an end time using STARTS\ENDS. If the start time is not specified, the first execution time is set to the current time plus one scheduling period. If the end time is specified and the task completes execution by reaching the end time (or exceeds it, or the next execution period exceeds the end time), the Job status is updated to FINISHED, and no more Tasks are generated. + +#### Job Status + +A Job has four states (RUNNING, STOPPED, PAUSED, FINISHED), with the initial state being RUNNING. A Job in the RUNNING state generates Tasks based on the specified scheduling period. When a Job completes execution and reaches the end time, the status changes to FINISHED. + +A Job in the RUNNING state can be paused, which means it will no longer generate Tasks. + +A Job in the PAUSED state can be resumed by performing the RESUME operation, changing the state to RUNNING. + +A Job in the STOPPED state is triggered by the user, which cancels the running Job and then deletes it. + +A Job in the FINISHED state remains in the system for 24 hours and is deleted after that. + +#### Task status + +A Job only describes the job information, and the execution generates Tasks. The Task status can be PENDING, RUNNING, SUCCESS, FAILED, or CANCELED. + +PENDING indicates that the trigger time has been reached but resources are awaited for running. Once resources are allocated, the status changes to RUNNING. When the execution is successful or fails, the status changes to SUCCESS or FAILED, respectively. + +CANCELED indicates the cancellation status. The final status of a Task is persisted as SUCCESS or FAILED. Other statuses can be queried while the Task is running, but they become invisible after a restart. Only the latest 100 Task records are retained. + +#### Permissions + +Currently, only users with the ADMIN role can perform this operation. + +#### Related Documentation + +- [PAUSE-JOB](../Alter/PAUSE-JOB.md) +- [RESUME-JOB](../Alter/RESUME-JOB.md) +- [DROP-JOB](../Drop/DROP-JOB.md) +- [VIEW-JOB](../../../sql-functions/table-valued-functions/jobs.md), +- [VIEW-TASKS](../../../sql-functions/table-valued-functions/tasks.md) + +### Grammar + +```sql +CREATE + job + job_name + ON SCHEDULE schedule + [COMMENT 'string'] + DO sql_body; + +schedule: { + AT timestamp + | EVERY interval + [STARTS timestamp] + [ENDS timestamp ] +} + +interval: + quantity { DAY | HOUR | MINUTE | + WEEK | SECOND } +``` + +A valid Job statement must contain the following + +- The keyword CREATE JOB plus the job name, which uniquely identifies the event within a database. The job name must be globally unique, and if a JOB with the same name already exists, an error will be reported. We reserve the inner_ prefix for internal use, so users cannot create names starting with ***inner_***. +- The ON SCHEDULE clause, which specifies the type of Job and when and how often to trigger it. +- The DO clause, which specifies the actions that need to be performed when the Job is triggered. + +Here is a minimal example: + +```sql +CREATE JOB my_job ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO db1.tbl1 SELECT * FROM db2.tbl2; +``` + +This statement means to create a job named my_job to be executed every minute, and the operation performed is to import the data in db2.tbl2 into db1.tbl1. + +The SCHEDULE statement is used to define the execution time, frequency and duration of the job, which can specify a one-time job or a periodic job. +- AT timestamp + +Format: 'YYYY-MM-DD HH:MM:SS'. Used for one-time events, it specifies that the event should only be executed once at the given date and time. Once the execution is complete, the Job status changes to FINISHED. + +- EVERY + + Indicates that the operation is repeated periodically, which specifies the execution frequency of the job. After the keyword, a time interval should be specified, which can be days, hours, minutes, seconds, and weeks. + + - interval + + Used to specify the Job execution frequency, which can be `day`, `hour`, `minute`, or `week`. For example, 1 `DAY` means the Job will run once every day, 1 `HOUR` means once every hour, 1 `MINUTE` means once every minute, and `1 The CREATE JOB statement is used to create a job in a database. A job is a task that can be scheduled to run at specific times or intervals to automate certain actions. + + - STARTS timestamp(optional) + + Format: 'YYYY-MM-DD HH:MM:SS'. It is used to specify the start time of the job. If not specified, the job starts executing from the next occurrence based on the current time. The start time must be greater than the current time. + + - ENDS timestamp(optional) + + Format: 'YYYY-MM-DD HH:MM:SS'. It is used to specify the end time of the job. If not specified, it means the job executes indefinitely. The end date must be greater than the current time. If a start time (↳STARTS) is specified, the end time must be greater than the start time. + +- DO + + It is used to specify the operation that needs to be performed when the job is triggered. Currently, all ***INSERT*** operations are supported. We will support more operations in the future. + +## Example + +Create a one-time job, which will be executed once at 2020-01-01 00:00:00, and the operation performed is to import the data in db2.tbl2 into db1.tbl1. + +```sql + +CREATE JOB my_job ON SCHEDULE AT '2020-01-01 00:00:00' DO INSERT INTO db1.tbl1 SELECT * FROM db2.tbl2; + +``` + +Create a periodic Job, which will start to execute at 2020-01-01 00:00:00, once a day, and the operation is to import the data in db2.tbl2 into db1.tbl1. + +```sql +CREATE JOB my_job ON SCHEDULE EVERY 1 DAY STARTS '2020-01-01 00:00:00' DO INSERT INTO db1.tbl1 SELECT * FROM db2.tbl2 WHERE create_time >= days_add(now(),-1); +``` + +Create a periodic Job, which will start to execute at 2020-01-01 00:00:00, and execute once a day. The operation performed is to import the data in db2.tbl2 into db1.tbl1. This Job will be executed in 2020 Ends at -01-01 00:10:00. + +```sql +CREATE JOB my_job ON SCHEDULE EVERY 1 DAY STARTS '2020-01-01 00:00:00' ENDS '2020-01-01 00:10:00' DO INSERT INTO db1.tbl1 SELECT * FROM db2.tbl2 create_time >= days_add (now(),-1); +``` + +### CONFIG + +#### fe.conf + +- job_dispatch_timer_job_thread_num: Number of threads used for dispatching scheduled tasks. Default value is 2. If there are a large number of periodically executed tasks, this parameter can be increased. +- job_dispatch_timer_job_queue_size: Size of the queue used for storing scheduled tasks when there is task accumulation. Default value is 1024. If there are a large number of tasks triggered at the same time, this parameter can be increased. Otherwise, the queue may become full and submitting tasks will be blocked, causing subsequent tasks to be unable to submit. +- finished_job_cleanup_threshold_time_hour: Time threshold, in hours, for cleaning up completed tasks. Default value is 24 hours. +- job_insert_task_consumer_thread_num: Number of threads used for executing Insert tasks. The value should be greater than 0, otherwise the default value is 5. + +## Best Practice + +- Properly manage Jobs to avoid triggering a large number of Jobs simultaneously, which can lead to task accumulation and affect the normal operation of the system. +- Set the execution interval of tasks within a reasonable range, ensuring that it is at least greater than the task execution time. + +## Keywords + + CREATE, JOB, SCHEDULE diff --git a/docs/sql-manual/sql-statements/job/DROP-JOB.md b/docs/sql-manual/sql-statements/job/DROP-JOB.md new file mode 100644 index 0000000000000..48d228b7749d1 --- /dev/null +++ b/docs/sql-manual/sql-statements/job/DROP-JOB.md @@ -0,0 +1,48 @@ +--- +{ +"title": "DROP JOB", +"language": "en" +} +--- + + + +## Description + +User stops a JOB. A stopped job cannot be resumed. + +```sql +DROP JOB WHERE jobName = 'job_name'; +``` + +## Example + +1. DROP the job named test1. + + ```sql + DROP JOB where jobName = 'test1'; + ``` + +## Keywords + + DROP, JOB + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/job/PAUSE-JOB.md b/docs/sql-manual/sql-statements/job/PAUSE-JOB.md new file mode 100644 index 0000000000000..08a4f309f62cd --- /dev/null +++ b/docs/sql-manual/sql-statements/job/PAUSE-JOB.md @@ -0,0 +1,48 @@ +--- +{ +"title": "PAUSE JOB", +"language": "en" +} +--- + + + + +## Description + +User suspends a JOB. A stopped job can be resumed with RESUME JOB. + +```sql +PAUSE JOB where jobName = 'job_name'; +``` + +## Example + +1. Pause the job named test1. + + ```sql + PAUSE JOB where jobName = 'test1'; + ``` + +## Keywords + + PAUSE, JOB + +## Best Practice diff --git a/docs/sql-manual/sql-statements/job/RESUME-JOB.md b/docs/sql-manual/sql-statements/job/RESUME-JOB.md new file mode 100644 index 0000000000000..56836cd86fe80 --- /dev/null +++ b/docs/sql-manual/sql-statements/job/RESUME-JOB.md @@ -0,0 +1,51 @@ +--- +{ +"title": "RESUME JOB", +"language": "en" +} +--- + + + + +## Description + +Used to restart a JOB in PAUSE state. The restarted job will continue to be executed periodically. A JOB in STOP state cannot be resumed. + +```sql +RESUME JOB WHERE jobName = 'job_name'; +``` + +## Example + +1. Restart the JOB named test1. + + ```sql + RESUME JOB WHERE jobName = 'test1'; + ``` + +## Keywords + + RESUME, JOB + +## Best Practice + + + diff --git a/docs/sql-manual/sql-statements/plugin/INSTALL-PLUGIN.md b/docs/sql-manual/sql-statements/plugin/INSTALL-PLUGIN.md new file mode 100644 index 0000000000000..ff48135b1acf4 --- /dev/null +++ b/docs/sql-manual/sql-statements/plugin/INSTALL-PLUGIN.md @@ -0,0 +1,79 @@ +--- +{ + "title": "INSTALL PLUGIN", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to install a plugin. + +grammar: + +```sql +INSTALL PLUGIN FROM [source] [PROPERTIES ("key"="value", ...)] +``` + +source supports three types: + +1. An absolute path to a zip file. +2. An absolute path to a plugin directory. +3. Point to a zip file download path with http or https protocol + +## Example + +1. Install a local zip file plugin: + + ```sql + INSTALL PLUGIN FROM "/home/users/doris/auditdemo.zip"; + ``` + +2. Install the plugin in a local directory: + + ```sql + INSTALL PLUGIN FROM "/home/users/doris/auditdemo/"; + ``` + +3. Download and install a plugin: + + ```sql + INSTALL PLUGIN FROM "http://mywebsite.com/plugin.zip"; + ``` + + Note than an md5 file with the same name as the `.zip` file needs to be placed, such as `http://mywebsite.com/plugin.zip.md5` . + The content is the MD5 value of the .zip file. + +4. Download and install a plugin, and set the md5sum value of the zip file at the same time: + + ```sql + INSTALL PLUGIN FROM "http://mywebsite.com/plugin.zip" PROPERTIES("md5sum" = "73877f6029216f4314d712086a146570"); + ``` + +## Keywords + + INSTALL, PLUGIN + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/plugin/SHOW-PLUGINS.md b/docs/sql-manual/sql-statements/plugin/SHOW-PLUGINS.md new file mode 100644 index 0000000000000..cc681cb3032c3 --- /dev/null +++ b/docs/sql-manual/sql-statements/plugin/SHOW-PLUGINS.md @@ -0,0 +1,53 @@ +--- +{ + "title": "SHOW PLUGINS", + "language": "en" +} +--- + + + + +## Description + +This statement is used to display installed plugins + +grammar: + +```SQL +SHOW PLUGINS +``` + +This command will display all user-installed and system built-in plugins + +## Example + +1. Show installed plugins: + + ```SQL + SHOW PLUGINS; + ``` + +## Keywords + + SHOW, PLUGINS + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/plugin/UNINSTALL-PLUGIN.md b/docs/sql-manual/sql-statements/plugin/UNINSTALL-PLUGIN.md new file mode 100644 index 0000000000000..c353f03b99516 --- /dev/null +++ b/docs/sql-manual/sql-statements/plugin/UNINSTALL-PLUGIN.md @@ -0,0 +1,55 @@ +--- +{ + "title": "UNINSTALL PLUGIN", + "language": "en" +} +--- + + + + +## Description + +This statement is used to uninstall a plugin. + +grammar: + +```sql +UNINSTALL PLUGIN plugin_name; +``` + + plugin_name can be viewed with the `SHOW PLUGINS;` command. + +Only non-builtin plugins can be uninstalled. + +## Example + +1. Uninstall a plugin: + + ```sql + UNINSTALL PLUGIN auditdemo; + ``` + +## Keywords + + UNINSTALL, PLUGIN + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/recycle/DROP-CATALOG-RECYCLE-BIN.md b/docs/sql-manual/sql-statements/recycle/DROP-CATALOG-RECYCLE-BIN.md new file mode 100644 index 0000000000000..1369e07d83c25 --- /dev/null +++ b/docs/sql-manual/sql-statements/recycle/DROP-CATALOG-RECYCLE-BIN.md @@ -0,0 +1,86 @@ +--- +{ + "title": "DROP CATALOG RECYCLE BIN", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to delete db/table/partition in catalog recycle bin instantly. + +You can get all meta informations that can be deleted by statement `SHOW CATALOG RECYCLE BIN`. + +grammar: + +1. delete database by DbId + + ```sql + DROP CATALOG RECYCLE BIN WHERE 'DbId' = db_id; + ``` + +2. delete table by TableId + + ```sql + DROP CATALOG RECYCLE BIN WHERE 'TableId' = table_id; + ``` + + 3. delete partition by PartitionId + + ```sql + DROP CATALOG RECYCLE BIN WHERE 'PartitionId' = partition_id; + ``` + +illustrate: + +- When drop db/table/partition, the catalog recycle bin will delete them after catalog_trash_expire_second(in fe.conf) seconds. This statement will delete them to free disk usage timely. +- `'DbId'`, `'TableId'` and `'PartitionId'` will be case-insensitive and not distinguish between `'` and `''`. +- When drop a database which is not in catalog recycle bin, it will also delete all tables and partitions with same DbId in catalog recycle bin. Only if nothing is deleted, it will report an error. When drop a table which is not in catalog recycle bin, the treatment is similar. + +## Example + +1. Delete the database(include tables and partitions with same DbId) with id example_db_id + + ```sql + DROP CATALOG RECYCLE BIN WHERE 'DbId' = example_db_id; + ``` + +2. Delete the table(include partitions with same TableId) with id example_tbl_id + + ```sql + DROP CATALOG RECYCLE BIN WHERE 'TableId' = example_tbl_id; + ``` + +3. Delete the partition with id p1_id + + ```sql + DROP CATALOG RECYCLE BIN WHERE 'PartitionId' = p1_id; + ``` + +## Keywords + +DROP, CATALOG, RECYCLE, BIN + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/recycle/RECOVER.md b/docs/sql-manual/sql-statements/recycle/RECOVER.md new file mode 100644 index 0000000000000..f6c5f240fe65b --- /dev/null +++ b/docs/sql-manual/sql-statements/recycle/RECOVER.md @@ -0,0 +1,158 @@ +--- +{ + "title": "RECOVER", + "language": "en" +} +--- + + + + +## Description + +This statement is used to restore a previously deleted database, table or partition. It supports recover meta information by name or id, and you can set new name for recovered meta information. + +You can get all meta informations that can be recovered by statement `SHOW CATALOG RECYCLE BIN`. + +grammar: + +1. restore database by name + + ```sql + RECOVER DATABASE db_name; + ``` + +2. restore table by name + + ```sql + RECOVER TABLE [db_name.]table_name; + ``` + + 3. restore partition by name + + ```sql + RECOVER PARTITION partition_name FROM [db_name.]table_name; + ``` + +4. restore database by name and id + + ```sql + RECOVER DATABASE db_name db_id; + ``` + +5. restore table by name and id + + ```sql + RECOVER TABLE [db_name.]table_name table_id; + ``` + +6. restore partition by name and id + + ```sql + RECOVER PARTITION partition_name partition_id FROM [db_name.]table_name; + ``` + +7. restore database by name, and set new db name + + ```sql + RECOVER DATABASE db_name AS new_db_name; + ``` + +8. restore table by name and id, and set new table name + + ```sql + RECOVER TABLE [db_name.]table_name table_id AS new_table_name; + ``` + +9. restore partition by name and id, and set new partition name + + ```sql + RECOVER PARTITION partition_name partition_id AS new_partition_name FROM [db_name.]table_name; + ``` + +illustrate: + +- This operation can only restore meta information that was deleted in the previous period. Default is 1 day. (Configurable through the `catalog_trash_expire_second` parameter in fe.conf) +- If you recover a meta information by name without id, it will recover the last dropped one which has same name. +- You can get all meta informations that can be recovered by statement `SHOW CATALOG RECYCLE BIN`. + +## Example + +1. Restore the database named example_db + +```sql +RECOVER DATABASE example_db; +``` + +2. Restore the table named example_tbl + +```sql +RECOVER TABLE example_db.example_tbl; +``` + +3. Restore the partition named p1 in table example_tbl + +```sql +RECOVER PARTITION p1 FROM example_tbl; +``` + +4. Restore the database named example_db with id example_db_id + +```sql +RECOVER DATABASE example_db example_db_id; +``` + +5. Restore the table named example_tbl with id example_tbl_id + +```sql +RECOVER TABLE example_db.example_tbl example_tbl_id; +``` + +6. Restore the partition named p1 with id p1_id in table example_tbl + +```sql +RECOVER PARTITION p1 p1_id FROM example_tbl; +``` + +7. Restore the database named example_db with id example_db_id, and set new name new_example_db + +```sql +RECOVER DATABASE example_db example_db_id AS new_example_db; +``` + +8. Restore the table named example_tbl, and set new name new_example_tbl + +```sql +RECOVER TABLE example_db.example_tbl AS new_example_tbl; +``` + +9. Restore the partition named p1 with id p1_id in table example_tbl, and new name new_p1 + +```sql +RECOVER PARTITION p1 p1_id AS new_p1 FROM example_tbl; +``` + +## Keywords + + RECOVER + +## Best Practice + + diff --git a/docs/sql-manual/sql-statements/recycle/SHOW-CATALOG-RECYCLE-BIN.md b/docs/sql-manual/sql-statements/recycle/SHOW-CATALOG-RECYCLE-BIN.md new file mode 100644 index 0000000000000..bb8e349afb346 --- /dev/null +++ b/docs/sql-manual/sql-statements/recycle/SHOW-CATALOG-RECYCLE-BIN.md @@ -0,0 +1,70 @@ +--- +{ + "title": "SHOW CATALOG RECYCLE BIN", + "language": "en" +} +--- + + + +## Description + +This statement is used to display the dropped meta informations that can be recovered + +grammar: + +```sql +SHOW CATALOG RECYCLE BIN [ WHERE NAME [ = "name" | LIKE "name_matcher"] ] +``` + +grammar: + +``` +The meaning of each column is as follows: + Type: type of meta information:Database、Table、Partition + Name: name of meta information + DbId: id of database + TableId: id of table + PartitionId: id of partition + DropTime: drop time of meta information + DataSize: the amount of data. If the type is database, this value includes the data size of the recycled tables and partitions in the database + RemoteDataSize: the amount of data on remote storage(hdfs or object storage). If the type is database, this value includes the remote data size of the recycled tables and partitions in the database +``` + +## Example + + 1. Display all meta informations that can be recovered + + ```sql + SHOW CATALOG RECYCLE BIN; + ``` + + 2. Display meta informations with name 'test' + + ```sql + SHOW CATALOG RECYCLE BIN WHERE NAME = 'test'; + ``` + +## Keywords + + SHOW, CATALOG RECYCLE BIN + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/security/CREATE-ENCRYPTKEY.md b/docs/sql-manual/sql-statements/security/CREATE-ENCRYPTKEY.md new file mode 100644 index 0000000000000..aee28f909c8d6 --- /dev/null +++ b/docs/sql-manual/sql-statements/security/CREATE-ENCRYPTKEY.md @@ -0,0 +1,80 @@ +--- +{ + "title": "CREATE ENCRYPTKEY", + "language": "en" +} +--- + + + + +## Description + +This statement creates a custom key. Executing this command requires the user to have `ADMIN` privileges. + +grammar: + +```sql +CREATE ENCRYPTKEY key_name AS "key_string" +``` + +illustrate: + +`key_name`: The name of the key to be created, may contain the name of the database. For example: `db1.my_key`. + +`key_string`: The string to create the key with. + +If `key_name` contains the database name, then the custom key will be created in the corresponding database, otherwise this function will create the database in the current session. The name of the new key cannot be the same as the existing key in the corresponding database, otherwise the creation will fail. + +## Example + +1. Create a custom key + + ```sql + CREATE ENCRYPTKEY my_key AS "ABCD123456789"; + ``` + +2. Use a custom key + + To use a custom key, you need to add the keyword `KEY`/`key` before the key, separated from the `key_name` space. + + ```sql + mysql> SELECT HEX(AES_ENCRYPT("Doris is Great", KEY my_key)); + +------------------------------------------------+ + | hex(aes_encrypt('Doris is Great', key my_key)) | + +------------------------------------------------+ + | D26DB38579D6A343350EDDC6F2AD47C6 | + +------------------------------------------------+ + 1 row in set (0.02 sec) + + mysql> SELECT AES_DECRYPT(UNHEX('D26DB38579D6A343350EDDC6F2AD47C6'), KEY my_key); + +------------------------------------------------- -------------------+ + | aes_decrypt(unhex('D26DB38579D6A343350EDDC6F2AD47C6'), key my_key) | + +------------------------------------------------- -------------------+ + | Doris is Great | + +------------------------------------------------- -------------------+ + 1 row in set (0.01 sec) + ``` + +## Keywords + + CREATE, ENCRYPTKEY + +## Best Practice diff --git a/docs/sql-manual/sql-statements/security/CREATE-FILE.md b/docs/sql-manual/sql-statements/security/CREATE-FILE.md new file mode 100644 index 0000000000000..611f7915b5723 --- /dev/null +++ b/docs/sql-manual/sql-statements/security/CREATE-FILE.md @@ -0,0 +1,95 @@ +--- +{ + "title": "CREATE FILE", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to create and upload a file to the Doris cluster. +This function is usually used to manage files that need to be used in some other commands, such as certificates, public and private keys, and so on. + +This command can only be executed by users with `admin` privileges. +A certain file belongs to a certain database. This file can be used by any user with access rights to database. + +A single file size is limited to 1MB. +A Doris cluster can upload up to 100 files. + +grammar: + +```sql +CREATE FILE "file_name" [IN database] +PROPERTIES("key"="value", ...) +``` + +illustrate: + +- file_name: custom file name. +- database: The file belongs to a certain db, if not specified, the db of the current session is used. +- properties supports the following parameters: + - url: Required. Specifies the download path for a file. Currently only unauthenticated http download paths are supported. After the command executes successfully, the file will be saved in doris and the url will no longer be needed. + - catalog: Required. The classification name of the file can be customized. However, in some commands, files in the specified catalog are looked up. For example, in the routine import, when the data source is kafka, the file under the catalog name kafka will be searched. + - md5: optional. md5 of the file. If specified, verification will be performed after the file is downloaded. + +## Example + +1. Create a file ca.pem , classified as kafka + + ```sql + CREATE FILE "ca.pem" + PROPERTIES + ( + "url" = "https://test.bj.bcebos.com/kafka-key/ca.pem", + "catalog" = "kafka" + ); + ``` + +2. Create a file client.key, classified as my_catalog + + ```sql + CREATE FILE "client.key" + IN my_database + PROPERTIES + ( + "url" = "https://test.bj.bcebos.com/kafka-key/client.key", + "catalog" = "my_catalog", + "md5" = "b5bb901bf10f99205b39a46ac3557dd9" + ); + ``` + +## Keywords + +```text +CREATE, FILE +``` + +## Best Practice + +1. This command can only be executed by users with amdin privileges. A certain file belongs to a certain database. This file can be used by any user with access rights to database. + +2. File size and quantity restrictions. + + This function is mainly used to manage some small files such as certificates. So a single file size is limited to 1MB. A Doris cluster can upload up to 100 files. + diff --git a/docs/sql-manual/sql-statements/security/DROP-ENCRYPTKEY.md b/docs/sql-manual/sql-statements/security/DROP-ENCRYPTKEY.md new file mode 100644 index 0000000000000..1aa431f5610a9 --- /dev/null +++ b/docs/sql-manual/sql-statements/security/DROP-ENCRYPTKEY.md @@ -0,0 +1,57 @@ +--- +{ + "title": "DROP ENCRYPTKEY", + "language": "en" +} +--- + + + + + +## Description + +grammar: + +```sql +DROP ENCRYPTKEY key_name +``` + +Parameter Description: + +- `key_name`: The name of the key to delete, can include the name of the database. For example: `db1.my_key`. + +Delete a custom key. The name of the key is exactly the same to be deleted. + +Executing this command requires the user to have `ADMIN` privileges. + +## Example + +1. Delete a key + + ```sql + DROP ENCRYPTKEY my_key; + ``` + +## Keywords + + DROP, ENCRYPT, KEY + +## Best Practice diff --git a/docs/sql-manual/sql-statements/security/DROP-FILE.md b/docs/sql-manual/sql-statements/security/DROP-FILE.md new file mode 100644 index 0000000000000..4ed1c142249f0 --- /dev/null +++ b/docs/sql-manual/sql-statements/security/DROP-FILE.md @@ -0,0 +1,58 @@ +--- +{ + "title": "DROP FILE", + "language": "en" +} +--- + + + + +## Description + +This statement is used to delete an uploaded file. + +grammar: + +```sql +DROP FILE "file_name" [FROM database] +[properties] +``` + +illustrate: + +- file_name: file name. +- database: a db to which the file belongs, if not specified, the db of the current session is used. +- properties supports the following parameters: + - `catalog`: Required. The category the file belongs to. + +## Example + +1. Delete the file ca.pem + + ```sql + DROP FILE "ca.pem" properties("catalog" = "kafka"); + ``` + +## Keywords + + DROP, FILE + +## Best Practice diff --git a/docs/sql-manual/sql-statements/security/SHOW-ENCRYPTKEY.md b/docs/sql-manual/sql-statements/security/SHOW-ENCRYPTKEY.md new file mode 100644 index 0000000000000..1b29f8e7b8ffa --- /dev/null +++ b/docs/sql-manual/sql-statements/security/SHOW-ENCRYPTKEY.md @@ -0,0 +1,71 @@ +--- +{ + "title": "SHOW ENCRYPTKEY", + "language": "en" +} +--- + + + + + +## Description + +View all custom keys under the database. If the user specifies a database, check the corresponding database, otherwise directly query the database where the current session is located. + +Requires `ADMIN` privilege on this database + +grammar: + +```sql +SHOW ENCRYPTKEYS [IN|FROM db] [LIKE 'key_pattern'] +``` + +parameter + +>`db`: database name to query +>`key_pattern`: parameter used to filter key names + +## Example + + ```sql + mysql> SHOW ENCRYPTKEYS; + +-------------------+-------------------+ + | EncryptKey Name | EncryptKey String | + +-------------------+-------------------+ + | example_db.my_key | ABCD123456789 | + +-------------------+-------------------+ + 1 row in set (0.00 sec) + + mysql> SHOW ENCRYPTKEYS FROM example_db LIKE "%my%"; + +-------------------+-------------------+ + | EncryptKey Name | EncryptKey String | + +-------------------+-------------------+ + | example_db.my_key | ABCD123456789 | + +-------------------+-------------------+ + 1 row in set (0.00 sec) + ``` + +## Keywords + + SHOW, ENCRYPT, KEY + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/security/SHOW-FILE.md b/docs/sql-manual/sql-statements/security/SHOW-FILE.md new file mode 100644 index 0000000000000..7abc84135fb69 --- /dev/null +++ b/docs/sql-manual/sql-statements/security/SHOW-FILE.md @@ -0,0 +1,62 @@ +--- +{ + "title": "SHOW FILE", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to display a file created in a database + +grammar: + +```sql +SHOW FILE [FROM database]; +``` + +illustrate: + +```text +FileId: file ID, globally unique +DbName: the name of the database to which it belongs +Catalog: Custom Category +FileName: file name +FileSize: file size, in bytes +MD5: MD5 of the file +``` + +## Example + +1. View the uploaded files in the database my_database + + ```sql + SHOW FILE FROM my_database; + ``` + +## Keywords + + SHOW, FILE + +## Best Practice \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/session/connection/KILL-CONNECTION.md b/docs/sql-manual/sql-statements/session/connection/KILL-CONNECTION.md new file mode 100644 index 0000000000000..c7f08d5e24a5f --- /dev/null +++ b/docs/sql-manual/sql-statements/session/connection/KILL-CONNECTION.md @@ -0,0 +1,70 @@ +--- +{ + "title": "KILL CONNECTION", + "language": "en" +} +--- + + + + +## Description + +Kill a connection with a specified connection ID. This will also kill the query associated with this connection. + +## Syntax + +```sql +KILL [ CONNECTION ] +``` + +## Required Parameters + +**** + +> The ID of the connection. It can be queried through the SHOW PROCESSLIST statement. + +## Access Control Requirements + +The user executing this SQL command must be the user who owns the connection or have at least `ADMIN_PRIV` permission. + +## Examples + +Query `connection_id`: + +```sql +show processlist; +``` + +Result: + +```sql ++------------------+----+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+------------------+--------------+--------------+ +| CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | FE | CloudCluster | ++------------------+----+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+------------------+--------------+--------------+ +| Yes | 16 | root | 127.0.0.1:63746 | 2024-11-04 20:18:07 | internal | test | Query | 0 | OK | e4d69a1cce81468d-91c9ae32b17540e9 | show processlist | 172.16.123.1 | NULL | ++------------------+----+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+------------------+--------------+--------------+ +``` + +Send KILL command: + +```sql +KILL CONNECTION 16; +``` diff --git a/docs/sql-manual/sql-statements/session/context/SWITCH-CATALOG.md b/docs/sql-manual/sql-statements/session/context/SWITCH-CATALOG.md new file mode 100644 index 0000000000000..1781d85184080 --- /dev/null +++ b/docs/sql-manual/sql-statements/session/context/SWITCH-CATALOG.md @@ -0,0 +1,52 @@ +--- +{ + "title": "SWITCH CATALOG", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to switch catalog. + +Syntax: + +```sql +SWITCH catalog_name +``` + +## Example + +1. Switch to hive + + ```sql + SWITCH hive; + ``` + +## Keywords + +SWITCH, CATALOG + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/session/context/USE-COMPUTE-GROUP.md b/docs/sql-manual/sql-statements/session/context/USE-COMPUTE-GROUP.md new file mode 100644 index 0000000000000..b66dce52d1a80 --- /dev/null +++ b/docs/sql-manual/sql-statements/session/context/USE-COMPUTE-GROUP.md @@ -0,0 +1,94 @@ +--- +{ + "title": "USE COMPUTE GROUP", + "language": "en" +} + +--- + + + +## Description + +In the storage-and-compute-separated version, specify the compute cluster to use. + +## Syntax + + +```sql +USE { [ . ][ @ ] | @ } +``` + +## Required Parameters + +``: The name of the compute cluster. + +## Return Value + +If the compute cluster switch is successful, it returns "Database changed"; if the switch fails, it returns the corresponding error message. + +## Examples + +1. Specify the compute cluster `compute_cluster` to use: + + ```sql + use @compute_cluster; + Database changed + ``` + +2. Specify both the database `mysql` and the compute cluster `compute_cluster` to use: + + ```sql + use mysql@compute_cluster + Database changed + ``` + +## Permission Control + +The prerequisite for successfully executing this SQL command is to have the USAGE_PRIV permission for the compute group, refer to the permission documentation. + +| Privilege | Object | Notes | +| :--------- | :------------ | :------------------------------------ | +| USAGE_PRIV | Compute group | Permission to use the compute cluster | + +If a user does not have the compute group permission and tries to specify a compute group, an error will be reported. For example, `test` is a regular user without compute group permission: + +```sql +mysql -utest -h175.40.1.1 -P9030 + +use @compute_cluster; +ERROR 5042 (42000): errCode = 2, detailMessage = USAGE denied to user test'@'127.0.0.1' for compute group 'compute_cluster' +``` + + +## Notes + +1. If the database name or compute group name is a reserved keyword, it needs to be enclosed in backticks, for example: + + ```sql + use @`create` + ``` + +2. If the compute group does not exist, an error message will be returned: + + ```sql + mysql> use @compute_group_not_exist; + ERROR 5098 (42000): errCode = 2, detailMessage = Compute Group compute_group_not_exist not exist + ``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/session/context/USE-DATABASE.md b/docs/sql-manual/sql-statements/session/context/USE-DATABASE.md new file mode 100644 index 0000000000000..124b360120c16 --- /dev/null +++ b/docs/sql-manual/sql-statements/session/context/USE-DATABASE.md @@ -0,0 +1,65 @@ +--- +{ + "title": "USE DATABASE", + "language": "en" +} + +--- + + + + + +## Description + +The USE command allows us to use the database + +grammar: + +```SQL +USE <[CATALOG_NAME].DATABASE_NAME> +``` + +illustrate: + +1. `USE CATALOG_NAME.DATABASE_NAME` will switch the current catalog into `CATALOG_NAME` and then change the current database into `DATABASE_NAME` + +## Example + +1. If the demo database exists in current catalog, try accessing it: + + ```sql + mysql> use demo; + Database changed + ``` + +2. If the demo database exists in catalog hms_catalog, try switching the catalog and accessing it: + + ```sql + mysql> use hms_catalog.demo; + Database changed + ``` + +## Keywords + + USE + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/session/queries/CLEAN-ALL-PROFILE.md b/docs/sql-manual/sql-statements/session/queries/CLEAN-ALL-PROFILE.md new file mode 100644 index 0000000000000..ef4e2b825d3e1 --- /dev/null +++ b/docs/sql-manual/sql-statements/session/queries/CLEAN-ALL-PROFILE.md @@ -0,0 +1,50 @@ +--- +{ + "title": "CLEAN ALL PROFILE", + "language": "en" +} +--- + + + +## Description + +For manual cleanup all of historical query or load profile. + +Syntax: + +```sql +CLEAN ALL PROFILE; +``` + +## Example + +1. Clean all profile + + ```sql + CLEAN ALL PROFILE; + ``` + +## Keywords + + CLEAN, PROFILE + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md b/docs/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md new file mode 100644 index 0000000000000..aa4d621d9b060 --- /dev/null +++ b/docs/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md @@ -0,0 +1,69 @@ +--- +{ + "title": "CLEAN ALL QUERY STATS", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to clear query statistics + +grammar: + +```sql +CLEAN [ALL| DATABASE | TABLE] QUERY STATS [[FOR db_name]|[FROM|IN] table_name]]; +``` + +Remarks: + +1. If ALL is specified, all query statistics are cleared, including database and table, admin privilege is needed +2. If DATABASE is specified, the query statistics of the specified database are cleared, alter privilege for this database is needed +3. If TABLE is specified, the query statistics of the specified table are cleared, alter privilege for this table is needed + +## Example + +1. Clear all statistics +2. + ```sql + clean all query stats; + ``` + +2. Clear the specified database statistics + + ```sql + clean database query stats for test_query_db; + ``` +3. Clear the specified table statistics + + ```sql + clean table query stats from test_query_db.baseall; + ``` + +## Keywords + + CLEAN, QUERY, STATS + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/session/queries/KILL-QUERY.md b/docs/sql-manual/sql-statements/session/queries/KILL-QUERY.md new file mode 100644 index 0000000000000..9d834229cfbff --- /dev/null +++ b/docs/sql-manual/sql-statements/session/queries/KILL-QUERY.md @@ -0,0 +1,85 @@ +--- +{ + "title": "KILL QUERY", + "language": "en" +} +--- + + + + + +In Doris, each connection runs in a separate thread. You can terminate a thread using the `KILL processlist_id`statement. + +The `processlist_id` for the thread can be found in the Id column from the SHOW PROCESSLIST output. Or you can use the `SELECT CONNECTION_ID()` command to query the current connection id. + +Syntax: + +```sql +KILL [CONNECTION] processlist_id +``` + +## Kill query + +You can also terminate the query command under execution based on the processlist_id or the query_id. + +Syntax: + +```sql +KILL QUERY processlist_id | query_id +``` + +## Example + +1. Check the current connection id. + +```sql +mysql select connection_id(); ++-----------------+ +| connection_id() | ++-----------------+ +| 48 | ++-----------------+ +1 row in set (0.00 sec) +``` + +2. Check all connection id. + +```sql +mysql SHOW PROCESSLIST; ++------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ +| CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | ++------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ +| Yes | 48 | root | 10.16.xx.xx:44834 | 2023-12-29 16:49:47 | internal | test | Query | 0 | OK | e6e4ce9567b04859-8eeab8d6b5513e38 | SHOW PROCESSLIST | +| | 50 | root | 192.168.xx.xx:52837 | 2023-12-29 16:51:34 | internal | | Sleep | 1837 | EOF | deaf13c52b3b4a3b-b25e8254b50ff8cb | SELECT @@session.transaction_isolation | +| | 51 | root | 192.168.xx.xx:52843 | 2023-12-29 16:51:35 | internal | | Sleep | 907 | EOF | 437f219addc0404f-9befe7f6acf9a700 | /* ApplicationName=DBeaver Ultimate 23.1.3 - Metadata */ SHOW STATUS | +| | 55 | root | 192.168.xx.xx:55533 | 2023-12-29 17:09:32 | internal | test | Sleep | 271 | EOF | f02603dc163a4da3-beebbb5d1ced760c | /* ApplicationName=DBeaver Ultimate 23.1.3 - SQLEditor */ SELECT DATABASE() | +| | 47 | root | 10.16.xx.xx:35678 | 2023-12-29 16:21:56 | internal | test | Sleep | 3528 | EOF | f4944c543dc34a99-b0d0f3986c8f1c98 | select * from test | ++------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ +5 rows in set (0.00 sec) +``` + +3. Kill the currently running query, which will then be displayed as canceled. + +```sql +mysql kill query 55; +Query OK, 0 rows affected (0.01 sec) +``` + diff --git a/docs/sql-manual/sql-statements/session/queries/PLAN-REPLAYER-DUMP.md b/docs/sql-manual/sql-statements/session/queries/PLAN-REPLAYER-DUMP.md new file mode 100644 index 0000000000000..0d95668626d07 --- /dev/null +++ b/docs/sql-manual/sql-statements/session/queries/PLAN-REPLAYER-DUMP.md @@ -0,0 +1,100 @@ +--- +{ + "title": "PLAN REPLAYER DUMP", + "language": "en" +} +--- + + + + + +## Description + +PLAN REPLAYER DUMP is a tool for Doris users to generate execution plan diagnostic files. It captures the state and input data of the query optimizer, facilitating debugging and analysis of query optimization issues. The output is the http address of the corresponding diagnostic file. + + +## Syntax + +```sql +PLAN REPLAYER DUMP +``` + + +## Required Parameters + +`` + + +- Refers to the query statement inside the corresponding DML. +- If it is not a query statement, a parse error will be reported. +- For more details, please refer to the [SELECT](https://doris.apache.org/en-US/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/SELECT/) syntax. + + +## Permission Control + + +Users executing this SQL command must have at least the following permissions: + + +| Privilege | Object | Notes | +| :--: | :--: | :--: | +| SELECT_PRIV | Table, View | When executing the , the SELECT_PRIV permission for the queried table, view, or materialized view is required. | + + +## Examples + + +### Basic Example + +```sql +create database test_replayer; +use database test_replayer; +create table t1 (c1 int, c11 int) distributed by hash(c1) buckets 3 properties('replication_num' = '1'); +plan replayer dump select * from t1; +``` + + +Execution result example: + +```sql ++-------------------------------------------------------------------------------+ +| Plan Replayer dump url | +| Plan Replayer dump url | ++-------------------------------------------------------------------------------+ +| http://127.0.0.1:8030/api/minidump?query_id=6e7441f741e94afd-ad3ba69429ad18ec | ++-------------------------------------------------------------------------------+ +``` + + +You can use curl or wget to obtain the corresponding file, for example: + +```sql +wget http://127.0.0.1:8030/api/minidump?query_id=6e7441f741e94afd-ad3ba69429ad18ec +``` + + +When permissions are required, you can include the username and password in: + +```sql +wget --header="Authorization: Basic $(echo -n 'root:' | base64)" http://127.0.0.1:8030/api/minidump?query_id=6e7441f741e94afd-ad3ba69429ad18ec +``` +``` + diff --git a/docs/sql-manual/sql-statements/session/queries/PLAN-REPLAYER-PLAY.md b/docs/sql-manual/sql-statements/session/queries/PLAN-REPLAYER-PLAY.md new file mode 100644 index 0000000000000..edae8fc959841 --- /dev/null +++ b/docs/sql-manual/sql-statements/session/queries/PLAN-REPLAYER-PLAY.md @@ -0,0 +1,52 @@ +--- +{ + "title": "PLAN REPLAYER PLAY", + "language": "en" +} +--- + + + + +## Description + +PLAN REPLAYER PLAY is a tool used by Doris developers to analyze optimizer issues. Based on diagnostic files generated by PLAN REPLAYER DUMP, it can load metadata and statistical information in the corresponding version of fe for developers to reproduce and debug issues. + +## Syntax + +```sql +PLAN REPLAYER PLAY ; +``` + +## Required Parameters + +`` + +- A string specifying the absolute path of the dump file. +- The identifier must be enclosed in double quotes and is the absolute path to the corresponding file. + +## Example + + +When we have a `dumpfile: /home/wangwu/dumpfile.json`, we can use the following SQL to reproduce the scenario: + +```sql +PLAN REPLAYER PLAY "/home/wangwu/dumpfile.json"; +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md b/docs/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md new file mode 100644 index 0000000000000..35b1b93092413 --- /dev/null +++ b/docs/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md @@ -0,0 +1,92 @@ +--- +{ + "title": "SHOW PROCESSLIST", + "language": "en" +} + +--- + + + + + + +## Description + +Display the running threads of the user. It should be noted that except the root user who can see all running threads, other users can only see their own running threads, and cannot see the running threads of other users. + +Only display current connected FE's connection list by default, you can set session variable ```set show_all_fe_connection = true``` to show all FE's connection. + +grammar: + +```sql +SHOW [FULL] PROCESSLIST +``` + +illustrate: + +- CurrentConnected: Indicates whether the connection is currently connected +- Id: It is the unique identifier of this thread. When we find that there is a problem with this thread, we can use the kill command to add this Id value to kill this thread. +- User: refers to the user who started this thread. +- Host: Records the IP and port number of the client sending the request. Through this information, when troubleshooting the problem, we can locate which client and which process sent the request. +- LoginTime: Timestamp when the connection is make. +- Catalog: Catalog name. +- Db: which database the currently executed command is on. If no database is specified, the value is NULL . +- Command: refers to the command that the thread is executing at the moment. +- Time: Indicates the time the thread is in the current state. +- State: The state of the thread, corresponding to Command. +- QueryId: The ID of the current query statement. +- Info: Generally recorded is the statement executed by the thread. By default, only the first 100 characters are displayed, that is, the statement you see may be truncated. To see all the information, you need to use show full processlist. + +Common Command types are as follows: + +- Query: The thread is executing a statement +- Sleep: is waiting for a client to send it an execute statement +- Quit: the thread is exiting +- Kill : The kill statement is being executed to kill the specified thread + +Other types can refer to [MySQL official website for explanation](https://dev.mysql.com/doc/refman/5.6/en/thread-commands.html) + +## Example + +1. View the threads running by the current user + + ```SQL + SHOW PROCESSLIST + ``` + + return + + ``` + MySQL [test]> show full processlist; + +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ + | CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | + +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ + | Yes | 0 | root | 127.0.0.1:34650 | 2023-09-06 12:01:02 | internal | test | Query | 0 | OK | c84e397193a54fe7-bbe9bc219318b75e | select 1 | + | | 1 | root | 127.0.0.1:34776 | 2023-09-06 12:01:07 | internal | | Sleep | 29 | EOF | 886ffe2894314f50-8dd73a6ca06699e4 | show full processlist | + +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ + ``` + +## Keywords + + SHOW, PROCESSLIST + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md b/docs/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md new file mode 100644 index 0000000000000..30939a5a45625 --- /dev/null +++ b/docs/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md @@ -0,0 +1,188 @@ +--- +{ + "title": "SHOW QUERY STATS", + "language": "en" +} +--- + + + +## Description + +This statement is used to show the query hit statistics of the database and table + +grammar: + +```sql +SHOW QUERY STATS [[FOR db_name]|[FROM table_name]] [ALL] [VERBOSE]]; +``` + +Remarks: + +1. Support query database and table history query hit statistics, restart fe after data will be reset, each fe separately statistics +2. Use FOR DATABASE and FROM TABLE to specify the query database or table hit statistics, respectively followed by the database name or table name +3. ALL can specify whether to display all index query hit statistics, VERBOSE can display more detailed hit statistics, these two parameters can be used separately, but must be placed at the end and can only be used on table queries +4. If no database is used, execute `SHOW QUERY STATS` directly to display the hit statistics of all databases +5. The result may have two columns: + QueryCount: The number of times the column was queried + FilterCount: The number of times the column was queried as a where condition +## Example + +1. Show the query hit statistics for `baseall` + + ```sql + MySQL [test_query_db]> show query stats from baseall; + +-------+------------+-------------+ + | Field | QueryCount | FilterCount | + +-------+------------+-------------+ + | k0 | 0 | 0 | + | k1 | 0 | 0 | + | k2 | 0 | 0 | + | k3 | 0 | 0 | + | k4 | 0 | 0 | + | k5 | 0 | 0 | + | k6 | 0 | 0 | + | k10 | 0 | 0 | + | k11 | 0 | 0 | + | k7 | 0 | 0 | + | k8 | 0 | 0 | + | k9 | 0 | 0 | + | k12 | 0 | 0 | + | k13 | 0 | 0 | + +-------+------------+-------------+ + 14 rows in set (0.002 sec) + + MySQL [test_query_db]> select k0, k1,k2, sum(k3) from baseall where k9 > 1 group by k0,k1,k2; + +------+------+--------+-------------+ + | k0 | k1 | k2 | sum(`k3`) | + +------+------+--------+-------------+ + | 0 | 6 | 32767 | 3021 | + | 1 | 12 | 32767 | -2147483647 | + | 0 | 3 | 1989 | 1002 | + | 0 | 7 | -32767 | 1002 | + | 1 | 8 | 255 | 2147483647 | + | 1 | 9 | 1991 | -2147483647 | + | 1 | 11 | 1989 | 25699 | + | 1 | 13 | -32767 | 2147483647 | + | 1 | 14 | 255 | 103 | + | 0 | 1 | 1989 | 1001 | + | 0 | 2 | 1986 | 1001 | + | 1 | 15 | 1992 | 3021 | + +------+------+--------+-------------+ + 12 rows in set (0.050 sec) + + MySQL [test_query_db]> show query stats from baseall; + +-------+------------+-------------+ + | Field | QueryCount | FilterCount | + +-------+------------+-------------+ + | k0 | 1 | 0 | + | k1 | 1 | 0 | + | k2 | 1 | 0 | + | k3 | 1 | 0 | + | k4 | 0 | 0 | + | k5 | 0 | 0 | + | k6 | 0 | 0 | + | k10 | 0 | 0 | + | k11 | 0 | 0 | + | k7 | 0 | 0 | + | k8 | 0 | 0 | + | k9 | 1 | 1 | + | k12 | 0 | 0 | + | k13 | 0 | 0 | + +-------+------------+-------------+ + 14 rows in set (0.001 sec) + ``` + +2. Show the query hit statistics summary for all the mv in a table + + ```sql + MySQL [test_query_db]> show query stats from baseall all; + +-----------+------------+ + | IndexName | QueryCount | + +-----------+------------+ + | baseall | 1 | + +-----------+------------+ + 1 row in set (0.005 sec) + ``` + +3. Show the query hit statistics detail info for all the mv in a table + + ```sql + MySQL [test_query_db]> show query stats from baseall all verbose; + +-----------+-------+------------+-------------+ + | IndexName | Field | QueryCount | FilterCount | + +-----------+-------+------------+-------------+ + | baseall | k0 | 1 | 0 | + | | k1 | 1 | 0 | + | | k2 | 1 | 0 | + | | k3 | 1 | 0 | + | | k4 | 0 | 0 | + | | k5 | 0 | 0 | + | | k6 | 0 | 0 | + | | k10 | 0 | 0 | + | | k11 | 0 | 0 | + | | k7 | 0 | 0 | + | | k8 | 0 | 0 | + | | k9 | 1 | 1 | + | | k12 | 0 | 0 | + | | k13 | 0 | 0 | + +-----------+-------+------------+-------------+ + 14 rows in set (0.017 sec) + ``` + +4. Show the query hit for a database + + ```sql + MySQL [test_query_db]> show query stats for test_query_db; + +----------------------------+------------+ + | TableName | QueryCount | + +----------------------------+------------+ + | compaction_tbl | 0 | + | bigtable | 0 | + | empty | 0 | + | tempbaseall | 0 | + | test | 0 | + | test_data_type | 0 | + | test_string_function_field | 0 | + | baseall | 1 | + | nullable | 0 | + +----------------------------+------------+ + 9 rows in set (0.005 sec) + ``` + +5. Show query hit statistics for all the databases + + ```sql + MySQL [(none)]> show query stats; + +-----------------+------------+ + | Database | QueryCount | + +-----------------+------------+ + | test_query_db | 1 | + +-----------------+------------+ + 1 rows in set (0.005 sec) + ``` + SHOW QUERY STATS; + ``` + +## Keywords + + SHOW, QUERY, STATS; + +## Best Practice diff --git a/docs/sql-manual/sql-statements/session/variable/SET-VARIABLE.md b/docs/sql-manual/sql-statements/session/variable/SET-VARIABLE.md new file mode 100644 index 0000000000000..042f5506bd5d7 --- /dev/null +++ b/docs/sql-manual/sql-statements/session/variable/SET-VARIABLE.md @@ -0,0 +1,66 @@ +--- +{ + "title": "SET VARIABLE", + "language": "en" +} +--- + + + + +## Description + +This statement is mainly used to modify Doris system variables. These system variables can be modified at the global and session level, and some can also be modified dynamically. You can also view these system variables with `SHOW VARIABLE`. + +grammar: + +```sql +SET variable_assignment [, variable_assignment] ... +``` + +illustrate: + +1. variable_assignment: + user_var_name = expr + | [GLOBAL | SESSION] system_var_name = expr + +> Note: +> +> 1. Only ADMIN users can set variables to take effect globally +> 2. The globally effective variable affects the current session and new sessions thereafter, but does not affect other sessions that currently exist. + +## Example + +1. Set the time zone to Dongba District + + ``` + SET time_zone = "Asia/Shanghai"; + ``` + +2. Set the global execution memory size + + ``` + SET GLOBAL exec_mem_limit = 137438953472 + ``` + +## Keywords + + SET, VARIABLE + diff --git a/docs/sql-manual/sql-statements/session/variable/SHOW-VARIABLES.md b/docs/sql-manual/sql-statements/session/variable/SHOW-VARIABLES.md new file mode 100644 index 0000000000000..b3255afd3f9cb --- /dev/null +++ b/docs/sql-manual/sql-statements/session/variable/SHOW-VARIABLES.md @@ -0,0 +1,71 @@ +--- +{ + "title": "SHOW VARIABLES", + "language": "en" +} +--- + + + + +## Description + +This statement is used to display Doris system variables, which can be queried by conditions + +grammar: + +```sql +SHOW [GLOBAL | SESSION] VARIABLES + [LIKE 'pattern' | WHERE expr] +``` + +illustrate: + +- show variables is mainly used to view the values of system variables. +- Executing the SHOW VARIABLES command does not require any privileges, it only requires being able to connect to the server. +- Use the like statement to match with variable_name. +- The % percent wildcard can be used anywhere in the matching pattern + +## Example + +1. The default here is to match the Variable_name, here is the exact match + + ```sql + show variables like 'max_connections'; + ``` + +2. Matching through the percent sign (%) wildcard can match multiple items + + ```sql + show variables like '%connec%'; + ``` + +3. Use the Where clause for matching queries + + ```sql + show variables where variable_name = 'version'; + ``` + +## Keywords + + SHOW, VARIABLES + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/session/variable/UNSET-VARIABLE.md b/docs/sql-manual/sql-statements/session/variable/UNSET-VARIABLE.md new file mode 100644 index 0000000000000..fb680d68748a3 --- /dev/null +++ b/docs/sql-manual/sql-statements/session/variable/UNSET-VARIABLE.md @@ -0,0 +1,74 @@ +--- +{ + "title": "UNSET VARIABLE", + "language": "en" +} + +--- + + + + + +## Description + +This statement is used to restore Doris system variables. These system variables can be modified at global or session level. + +grammar: + +```sql +UNSET [SESSION|GLOBAL] VARIABLE (variable_name | ALL) +``` + +illustrate: + +1. (variable_name | ALL): statement must be ended with a variable name or keyword `ALL`. + +> Note: +> +> 1. Only ADMIN users can unset variables to take effect globally +> 2. When restore a variable with `GLOBAL`, it only affect your current using session and new open sessions. It does not affect other current open sessions. + +## Example + +1. Restore value of the time zone + + ``` + UNSET VARIABLE time_zone; + ``` + +2. Restore the global execution memory size + + ``` + UNSET GLOBAL VARIABLE exec_mem_limit; + ``` + +3. Restore all variables globally + + ``` + UNSET GLOBAL VARIABLE ALL; + ``` + +## Keywords + + UNSET, VARIABLE + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/statistics/ALTER-STATS.md b/docs/sql-manual/sql-statements/statistics/ALTER-STATS.md new file mode 100644 index 0000000000000..f92626e7efb5d --- /dev/null +++ b/docs/sql-manual/sql-statements/statistics/ALTER-STATS.md @@ -0,0 +1,114 @@ +--- +{ + "title": "ALTER STATS", + "language": "en" +} +--- + + + + + + +## Description + +Manually modify the statistics of a specified column in a specified table. Please refer to the "Statistics" chapter. + +## Syntax + +```sql +ALTER TABLE + [ INDEX ] + MODIFY COLUMN + SET STATS () +``` + +Where: + +```sql +column_stats + : -- column stats value + ("key1" = "value1", "key2" = "value2" [...]) +``` +# Required Parameters + +**** + +> Specifies the identifier (i.e., name) of the table. + +**** + +> Specifies the column identifier (i.e., name). When is not specified, it is the column name of the base table. + +**** + +> The statistics value to be set, given in the form of key = value, where both key and value need to be enclosed in quotation marks, and key-value pairs are separated by commas. The statistics that can be set include: + +> row_count, total number of rows + +> ndv, cardinality of the column + +> num_nulls, number of null values in the column + +> data_size, total size of the column + +> min_value, minimum value of the column + +> max_value, maximum value of the column + +> Among them, row_count must be specified, and other attributes are optional. If not set, the corresponding statistic attribute value for that column will be empty. + +# Optional Parameters + +**** + +> Synchronized materialized view (please refer to the "Synchronized Materialized Views" chapter) identifier (i.e., name). A table can have 0 to multiple materialized views. If you need to set the statistics of a column in a materialized view, you need to use to specify the name of the materialized view. If not specified, the properties of the column in the base table are set. + +# Access Control Requirements + +The user executing this SQL command must have at least the following privileges: + +| Privilege | Object | Notes | +| :--------- | :----- | :---- | +| ALTER_PRIV | Table | | + +# Usage Notes + +After a user manually injects statistics into a table, the table will no longer participate in the automatic collection of statistics (please refer to the "Automatic Collection of Statistics" chapter) to avoid overwriting the statistics manually injected by the user. If the injected statistics are no longer used, the drop stats statement can be used to delete the already injected information, which allows the table to re-enable automatic collection. + +# Examples + +- Inject statistics into the p_partkey column of the part table (base table column, as no index_name is specified). + + ```sql + alter + table part + modify column p_partkey + set stats ('row_count'='2.0E7', 'ndv'='2.0252576E7', 'num_nulls'='0.0', 'data_size'='8.0E7', 'min_value'='1', 'max_value'='20000000'); + ``` + +- Inject statistics into the col1 column of the index1 materialized view of the part table (materialized view column, as index_name is specified). + + ```sql + alter + table part index index1 + modify column col1 + set stats ('row_count'='2.0E7', 'ndv'='2.0252576E7', 'num_nulls'='0.0', 'data_size'='8.0E7', 'min_value'='1', 'max_value'='20000000'); + ``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/statistics/ANALYZE.md b/docs/sql-manual/sql-statements/statistics/ANALYZE.md new file mode 100644 index 0000000000000..7b52084392803 --- /dev/null +++ b/docs/sql-manual/sql-statements/statistics/ANALYZE.md @@ -0,0 +1,59 @@ +--- +{ + "title": "ANALYZE", + "language": "en" +} +--- + + + + +## Description + +This statement is used to collect statistical information for various columns. + +```sql +ANALYZE < TABLE | DATABASE table_name | db_name > + [ (column_name [, ...]) ] + [ [ WITH SYNC ] [ WITH SAMPLE PERCENT | ROWS ] ]; +``` + +- `table_name`: The specified target table. It can be in the format `db_name.table_name`. +- `column_name`: The specified target column. It must be an existing column in `table_name`. You can specify multiple column names separated by commas. +- `sync`: Collect statistics synchronously. Returns after collection. If not specified, it executes asynchronously and returns a JOB ID. +- `sample percent | rows`: Collect statistics with sampling. You can specify a sampling percentage or a number of sampling rows. + +## Example + +Collect statistical data for a table with a 10% sampling rate: + +```sql +ANALYZE TABLE lineitem WITH SAMPLE PERCENT 10; +``` + +Collect statistical data for a table with a sample of 100,000 rows: + +```sql +ANALYZE TABLE lineitem WITH SAMPLE ROWS 100000; +``` + +## Keywords + +ANALYZE \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/statistics/DROP-ANALYZE-JOB.md b/docs/sql-manual/sql-statements/statistics/DROP-ANALYZE-JOB.md new file mode 100644 index 0000000000000..315f70ff0d99a --- /dev/null +++ b/docs/sql-manual/sql-statements/statistics/DROP-ANALYZE-JOB.md @@ -0,0 +1,59 @@ +--- +{ + "title": "DROP ANALYZE JOB", + "language": "en" +} +--- + + + + + +## Description + +Delete the history of the specified statistics collection job. + +## Syntax + +```sql +DROP ANALYZE JOB +``` + +# Required Parameters + +**** + +> Specifies the id of the job. You can obtain the job_id by running SHOW ANALYZE. For detailed usage, please refer to the "SHOW ANALYZE" section. + +## Access Control Requirements + +The user executing this SQL command must have at least the following privileges: + +| Privilege | Object | Notes | +| ----------- | ------ | ----- | +| SELECT_PRIV | Table | | + +## Examples + +Delete the statistics information job record with id 10036 + +```sql +DROP ANALYZE JOB 10036 +``` diff --git a/docs/sql-manual/sql-statements/statistics/DROP-STATS.md b/docs/sql-manual/sql-statements/statistics/DROP-STATS.md new file mode 100644 index 0000000000000..9825d47cad9cb --- /dev/null +++ b/docs/sql-manual/sql-statements/statistics/DROP-STATS.md @@ -0,0 +1,79 @@ +--- +{ + "title": "DROP STATS", + "language": "en" +} +--- + + + + + + +## Description + +Delete statistics information for the specified table and columns. If no column names are specified, the statistics information for all columns will be deleted. + +## Syntax + +```sql +DROP STATS [ ] +``` + +Where: + +```sql +column_names + : + (, [ ... ]) +``` + +## ## Required Parameters + +**** + +> The identifier (name) of the table. + +## Optional Parameters + +**** + +> List of column identifiers (names). + +## Access Control Requirements + +Users executing this SQL command must have at least the following privileges: + +| Privilege | Object | Notes | +| :-------- | :----- | :---- | +| DROP_PRIV | Table | | + +## Examples + +- Delete statistics information for all columns in table1 + + ```sql + DROP STATS table1 + ``` +- Delete statistics information for col1 and col2 in table1 + + ```sql + DROP STATS table1 (col1, col2) + ``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/statistics/KILL-ANALYZE-JOB.md b/docs/sql-manual/sql-statements/statistics/KILL-ANALYZE-JOB.md new file mode 100644 index 0000000000000..2698acbed242e --- /dev/null +++ b/docs/sql-manual/sql-statements/statistics/KILL-ANALYZE-JOB.md @@ -0,0 +1,67 @@ +--- +{ + "title": "KILL ANALYZE JOB", + "language": "en" +} +--- + + + + + + +## Description + +Stop the statistical information collection job that is being executed in the background. + +## Syntax + +```sql +KILL ANALYZE +``` +## Required Parameters + +**** + +> Specifies the id of the job. You can obtain the job_id of the job by using SHOW ANALYZE. For detailed usage, please refer to the "SHOW ANALYZE" chapter. + +## Optional Parameters + +None + +## Access Control Requirements + +The user executing this SQL command must have at least the following privileges: + +| Privilege (Privilege) | Object (Object) | Notes (Notes) | +| --------------------- | --------------- | ------------- | +| SELECT_PRIV | Table | | + +## Usage Notes + +Jobs that have already been executed cannot be stopped. + +## Examples + +Stop the statistical information job record with an id of 10036 + +```sql +kill analyze 10036 +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/statistics/SHOW-ANALYZE.md b/docs/sql-manual/sql-statements/statistics/SHOW-ANALYZE.md new file mode 100644 index 0000000000000..8aa6372b6cd85 --- /dev/null +++ b/docs/sql-manual/sql-statements/statistics/SHOW-ANALYZE.md @@ -0,0 +1,105 @@ +--- +{ + "title": "SHOW ANALYZE", + "language": "en" +} +--- + + + + + +## Description + +Use `SHOW ANALYZE` to view information about statistics collection jobs. + +Syntax: + +```SQL +SHOW [AUTO] ANALYZE < table_name | job_id > + [ WHERE [ STATE = [ "PENDING" | "RUNNING" | "FINISHED" | "FAILED" ] ] ]; +``` + +- AUTO: Show historical information for automatic collection jobs only. Note that, by default, the status of only the last 20,000 completed automatic collection jobs is retained. +- table_name: Table name, specify to view statistics job information for that table. It can be in the format `db_name.table_name`. When not specified, it returns information for all statistics jobs. +- job_id: Job ID for statistics collection, obtained when executing `ANALYZE`. When not specified, this command returns information for all statistics jobs. + +Output: + +| Column Name | Description | +| :--------------------- | :--------------- | +| `job_id` | Job ID | +| `catalog_name` | Catalog Name | +| `db_name` | Database Name | +| `tbl_name` | Table Name | +| `col_name` | Column Name List | +| `job_type` | Job Type | +| `analysis_type` | Analysis Type | +| `message` | Job Information | +| `last_exec_time_in_ms` | Last Execution Time | +| `state` | Job Status | +| `schedule_type` | Scheduling Method | + +Here's an example: + +```sql +mysql> show analyze 245073\G; +*************************** 1. row *************************** + job_id: 245073 + catalog_name: internal + db_name: default_cluster:tpch + tbl_name: lineitem + col_name: [l_returnflag,l_receiptdate,l_tax,l_shipmode,l_suppkey,l_shipdate,l_commitdate,l_partkey,l_orderkey,l_quantity,l_linestatus,l_comment,l_extendedprice,l_linenumber,l_discount,l_shipinstruct] + job_type: MANUAL + analysis_type: FUNDAMENTALS + message: +last_exec_time_in_ms: 2023-11-07 11:00:52 + state: FINISHED + progress: 16 Finished | 0 Failed | 0 In Progress | 16 Total + schedule_type: ONCE +``` + +
+ +Each collection job can contain one or more tasks, with each task corresponding to the collection of a column. Users can use the following command to view the completion status of statistics collection for each column. + +Syntax: + +```sql +SHOW ANALYZE TASK STATUS [job_id] +``` + +Here's an example: + +``` +mysql> show analyze task status 20038 ; ++---------+----------+---------+----------------------+----------+ +| task_id | col_name | message | last_exec_time_in_ms | state | ++---------+----------+---------+----------------------+----------+ +| 20039 | col4 | | 2023-06-01 17:22:15 | FINISHED | +| 20040 | col2 | | 2023-06-01 17:22:15 | FINISHED | +| 20041 | col3 | | 2023-06-01 17:22:15 | FINISHED | +| 20042 | col1 | | 2023-06-01 17:22:15 | FINISHED | ++---------+----------+---------+----------------------+----------+ +``` + +## Keywords + +SHOW, ANALYZE diff --git a/docs/sql-manual/sql-statements/statistics/SHOW-STATS.md b/docs/sql-manual/sql-statements/statistics/SHOW-STATS.md new file mode 100644 index 0000000000000..e387bc9cd1e07 --- /dev/null +++ b/docs/sql-manual/sql-statements/statistics/SHOW-STATS.md @@ -0,0 +1,66 @@ +--- +{ + "title": "SHOW COLUMN STATS", + "language": "en" +} +--- + + + + +## Description + +Use `SHOW COLUMN STATS` to view various statistics data for columns. + +Syntax: + +```sql +SHOW COLUMN [cached] STATS table_name [ (column_name [, ...]) ]; +``` + +Where: + +- cached: Show statistics information in the current FE memory cache. +- table_name: The target table for collecting statistics. It can be in the format `db_name.table_name`. +- column_name: Specifies the target column, which must be an existing column in `table_name`. You can specify multiple column names separated by commas. + +Here's an example: + +```sql +mysql> show column stats lineitem(l_tax)\G; +*************************** 1. row *************************** + column_name: l_tax + count: 6001215.0 + ndv: 9.0 + num_null: 0.0 + data_size: 4.800972E7 +avg_size_byte: 8.0 + min: 0.00 + max: 0.08 + method: FULL + type: FUNDAMENTALS + trigger: MANUAL + query_times: 0 + updated_time: 2023-11-07 11:00:46 +``` + +## Keywords + +SHOW, TABLE, STATS diff --git a/docs/sql-manual/sql-statements/statistics/SHOW-TABLE-STATS.md b/docs/sql-manual/sql-statements/statistics/SHOW-TABLE-STATS.md new file mode 100644 index 0000000000000..f880081efdfde --- /dev/null +++ b/docs/sql-manual/sql-statements/statistics/SHOW-TABLE-STATS.md @@ -0,0 +1,69 @@ +--- +{ + "title": "SHOW TABLE STATS", + "language": "en" +} +--- + + + + +### Description + +Use `SHOW TABLE STATS` to view an overview of statistics collection for a table. + +Syntax: + +```SQL +SHOW TABLE STATS table_name; +``` + +Where: + +- table_name: The target table name. It can be in the format `db_name.table_name`. + +Output: + +| Column Name | Description | +| :--------------------- | :--------------- | +| `updated_rows` | Updated rows since the last ANALYZE | +| `query_times` | Reserved column for recording the number of times the table was queried in future versions | +| `row_count` | Number of rows (does not reflect the exact number of rows at the time of command execution) | +| `updated_time` | Last update time | +| `columns` | Columns for which statistics information has been collected | + +Here's an example: + +```sql +mysql> show table stats lineitem \G; +*************************** 1. row *************************** +updated_rows: 0 + query_times: 0 + row_count: 6001215 +updated_time: 2023-11-07 + columns: [l_returnflag, l_receiptdate, l_tax, l_shipmode, l_suppkey, l_shipdate, l_commitdate, l_partkey, l_orderkey, l_quantity, l_linestatus, l_comment, l_extendedprice, l_linenumber, l_discount, l_shipinstruct] + trigger: MANUAL +``` + +
+ +### Keywords + +SHOW, TABLE, STATS diff --git a/docs/sql-manual/sql-statements/system-info-and-help/HELP.md b/docs/sql-manual/sql-statements/system-info-and-help/HELP.md new file mode 100644 index 0000000000000..d8eab85243f0c --- /dev/null +++ b/docs/sql-manual/sql-statements/system-info-and-help/HELP.md @@ -0,0 +1,111 @@ +--- +{ + "title": "HELP", + "language": "en" +} +--- + + + + + + +## Description + +The directory of help can be queried by changing the command + +grammar: + +``` sql +HELP +``` + +All Doris commands can be listed with `help` + +```sql +List of all MySQL commands: +Note that all text commands must be first on line and end with ';' +? (\?) Synonym for `help'. +clear (\c) Clear the current input statement. +connect (\r) Reconnect to the server. Optional arguments are db and host. +delimiter (\d) Set statement delimiter. +edit (\e) Edit command with $EDITOR. +ego (\G) Send command to mysql server, display result vertically. +exit (\q) Exit mysql. Same as quit. +go (\g) Send command to mysql server. +help (\h) Display this help. +nopager (\n) Disable pager, print to stdout. +note (\t) Don't write into outfile. +pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. +print (\p) Print current command. +prompt (\R) Change your mysql prompt. +quit (\q) Quit mysql. +rehash (\#) Rebuild completion hash. +source (\.) Execute an SQL script file. Takes a file name as an argument. +status (\s) Get status information from the server. +system (\!) Execute a system shell command. +tee (\T) Set outfile [to_outfile]. Append everything into given outfile. +use (\u) Use another database. Takes database name as argument. +charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. +warnings (\W) Show warnings after every statement. +nowarning (\w) Don't show warnings after every statement. +resetconnection(\x) Clean session context. + +For server side help, type 'help contents' +``` + +Get the Doris SQL help contents via `help contents` + +```sql +Many help items for your request exist. +To make a more specific request, please type 'help ', +where is one of the following +categories: + sql-functions + sql-statements +``` + +## Example + +1. List all SQL help contents of Doris + + ```sql + help contents + ``` + +2. The command to list all function directories of the Doris cluster + + ```sql + help sql-functions + ``` + +3. List all functions under the date function + + ```sql + help date-time-functions + ``` + + +## Keywords + + HELP + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/system-info-and-help/SHOW-PROC.md b/docs/sql-manual/sql-statements/system-info-and-help/SHOW-PROC.md new file mode 100644 index 0000000000000..a92aca5a83a60 --- /dev/null +++ b/docs/sql-manual/sql-statements/system-info-and-help/SHOW-PROC.md @@ -0,0 +1,275 @@ +--- +{ + "title": "SHOW PROC", + "language": "en" +} +--- + + + + + + +## Description + +The Proc system is a unique feature of Doris. Students who have used Linux may understand this concept better. In Linux systems, proc is a virtual file system, usually mounted in the /proc directory. Users can view the internal data structure of the system through this file system. For example, you can view the details of the specified pid process through /proc/pid. + +Similar to the proc system in Linux, the proc system in Doris is also organized into a directory-like structure to view different system information according to the "directory path (proc path)" specified by the user. + +The proc system is designed mainly for system administrators, so that it is convenient for them to view some running states inside the system. Such as the tablet status of the table, the cluster balance status, the status of various jobs, and so on. is a very useful function + +There are two ways to view the proc system in Doris. + +1. View through the WEB UI interface provided by Doris, visit the address: `http://FE_IP:FE_HTTP_PORT` +2. Another way is by command + +All commands supported by Doris PROC can be seen through ` SHOW PROC "/";` + +After connecting to Doris through the MySQL client, you can execute the SHOW PROC statement to view the information of the specified proc directory. The proc directory is an absolute path starting with "/". + +The results of the show proc statement are presented in a two-dimensional table. And usually the first column of the result table is the next subdirectory of proc. + +```none +mysql> show proc "/"; ++---------------------------+ +| name | ++---------------------------+ +| auth | +| backends | +| bdbje | +| brokers | +| catalogs | +| cluster_balance | +| cluster_health | +| colocation_group | +| current_backend_instances | +| current_queries | +| current_query_stmts | +| dbs | +| diagnose | +| frontends | +| jobs | +| load_error_hub | +| monitor | +| resources | +| routine_loads | +| statistic | +| stream_loads | +| tasks | +| transactions | +| trash | ++---------------------------+ +23 rows in set (0.00 sec) +``` + +illustrate: + +1. auth: User name and corresponding permission information +2. backends: Displays the node list of BE in the cluster, equivalent to [SHOW BACKENDS](./SHOW-BACKENDS.md) +3. bdbje: To view the bdbje database list, you need to modify the `fe.conf` file to add `enable_bdbje_debug_mode=true`, and then start `FE` through `sh start_fe.sh --daemon` to enter the `debug` mode. After entering `debug` mode, only `http server` and `MySQLServer` will be started and the `BDBJE` instance will be opened, but no metadata loading and subsequent startup processes will be entered. +4. brokers : View cluster broker node information, equivalent to [SHOW BROKER](./SHOW-BROKER.md) +5. catalogs : View the data catalogs that have been created currently, equivalent to [SHOW CATALOGS](./SHOW-CATALOGS.md) +6. cluster_balance : To check the balance of the cluster, please refer to [Data Copy Management](../../../admin-manual/maint-monitor/tablet-repair-and-balance.md) +7. cluster_health: Run SHOW PROC '/cluster_health/tablet_health'; statement to view the replica status of the entire cluster. +8. colocation_group : This command can view the existing Group information in the cluster. For details, please refer to the [Colocation Join](../../../query-acceleration/join-optimization/colocation-join.md) chapter +9. current_backend_instances : Displays a list of be nodes that are currently executing jobs +10. current_queries : View the list of queries being executed, the SQL statement currently running. +11. current_query_stmts: Returns the currently executing query. +12. dbs: Mainly used to view the metadata information of each database and the tables in the Doris cluster. This information includes table structure, partitions, materialized views, data shards and replicas, and more. Through this directory and its subdirectories, you can clearly display the table metadata in the cluster, and locate some problems such as data skew, replica failure, etc. +13. diagnose: Report and diagnose common management and control issues in the cluster, including replica balance and migration, transaction exceptions, etc. +14. frontends: Display all FE node information in the cluster, including IP address, role, status, whether it is a master, etc., equivalent to [SHOW FRONTENDS](./SHOW-FRONTENDS.md) +15. jobs: show statistics of all kind of jobs. If a specific `dbId` is given, will return statistics data of the database. If `dbId` is -1, will return total statistics data of all databases +16. load_error_hub: Doris supports centralized storage of error information generated by load jobs in an error hub. Then view the error message directly through the SHOW LOAD WARNINGS; statement. Shown here is the configuration information of the error hub. +17. monitor : shows the resource usage of FE JVM +18. resources : View system resources, ordinary accounts can only see resources that they have USAGE_PRIV permission to use. Only the root and admin accounts can see all resources. Equivalent to [SHOW RESOURCES](./SHOW-RESOURCES.md) +19. routine_loads: Display all routine load job information, including job name, status, etc. +20. statistics: It is mainly used to summarize and view the number of databases, tables, partitions, shards, and replicas in the Doris cluster. and the number of unhealthy copies. This information helps us to control the size of the cluster meta-information in general. It helps us view the cluster sharding situation from an overall perspective, and can quickly check the health of the cluster sharding. This further locates problematic data shards. +21. stream_loads: Returns the stream load task being executed. +22. tasks : Displays the total number of tasks of various jobs and the number of failures. +23. transactions : used to view the transaction details of the specified transaction id, equivalent to [SHOW TRANSACTION](./SHOW-TRANSACTION.md) +24. trash: This statement is used to view the space occupied by garbage data in the backend. Equivalent to [SHOW TRASH](./SHOW-TRASH.md) + +## Example + +1. For example, "/dbs" displays all databases, and "/dbs/10002" displays all tables under the database with id 10002 + + ```sql + mysql> show proc "/dbs/10002"; + +---------+----------------------+----------+---------------------+--------------+--------+------+--------------------------+--------------+ + | TableId | TableName | IndexNum | PartitionColumnName | PartitionNum | State | Type | LastConsistencyCheckTime | ReplicaCount | + +---------+----------------------+----------+---------------------+--------------+--------+------+--------------------------+--------------+ + | 10065 | dwd_product_live | 1 | dt | 9 | NORMAL | OLAP | NULL | 18 | + | 10109 | ODS_MR_BILL_COSTS_DO | 1 | NULL | 1 | NORMAL | OLAP | NULL | 1 | + | 10119 | test | 1 | NULL | 1 | NORMAL | OLAP | NULL | 1 | + | 10124 | test_parquet_import | 1 | NULL | 1 | NORMAL | OLAP | NULL | 1 | + +---------+----------------------+----------+---------------------+--------------+--------+------+--------------------------+--------------+ + 4 rows in set (0.00 sec) + ``` + +2. Display information about the number of all database tables in the cluster. + + ```sql + mysql> show proc '/statistic'; + +-------+----------------------+----------+--------------+----------+-----------+------------+ + | DbId | DbName | TableNum | PartitionNum | IndexNum | TabletNum | ReplicaNum | + +-------+----------------------+----------+--------------+----------+-----------+------------+ + | 10002 | default_cluster:test | 4 | 12 | 12 | 21 | 21 | + | Total | 1 | 4 | 12 | 12 | 21 | 21 | + +-------+----------------------+----------+--------------+----------+-----------+------------+ + 2 rows in set (0.00 sec) + ``` + +3. The following command can view the existing Group information in the cluster. + + ``` + SHOW PROC '/colocation_group'; + + +-------------+--------------+--------------+------------+----------------+----------+----------+ + | GroupId | GroupName | TableIds | BucketsNum | ReplicationNum | DistCols | IsStable | + +-------------+--------------+--------------+------------+----------------+----------+----------+ + | 10005.10008 | 10005_group1 | 10007, 10040 | 10 | 3 | int(11) | true | + +-------------+--------------+--------------+------------+----------------+----------+----------+ + ``` + + - GroupId: The cluster-wide unique identifier of a group, the first half is the db id, and the second half is the group id. + - GroupName: The full name of the Group. + - TabletIds: The id list of Tables contained in this Group. + - BucketsNum: The number of buckets. + - ReplicationNum: The number of replicas. + - DistCols: Distribution columns, that is, the bucket column type. + - IsStable: Whether the Group is stable (for the definition of stability, see the `Colocation replica balance and repair` section). + +4. Use the following commands to further view the data distribution of a Group: + + ```sql + SHOW PROC '/colocation_group/10005.10008'; + + +-------------+---------------------+ + | BucketIndex | BackendIds | + +-------------+---------------------+ + | 0 | 10004, 10002, 10001 | + | 1 | 10003, 10002, 10004 | + | 2 | 10002, 10004, 10001 | + | 3 | 10003, 10002, 10004 | + | 4 | 10002, 10004, 10003 | + | 5 | 10003, 10002, 10001 | + | 6 | 10003, 10004, 10001 | + | 7 | 10003, 10004, 10002 | + +-------------+---------------------+ + ``` + + - BucketIndex: The index of the bucket sequence. + - BackendIds: The list of BE node IDs where the data shards in the bucket are located. + +5. Display the total number of tasks of various jobs and the number of failures. + + ```sql + mysql> show proc '/tasks'; + +-------------------------+-----------+----------+ + | TaskType | FailedNum | TotalNum | + +-------------------------+-----------+----------+ + | CREATE | 0 | 0 | + | DROP | 0 | 0 | + | PUSH | 0 | 0 | + | CLONE | 0 | 0 | + | STORAGE_MEDIUM_MIGRATE | 0 | 0 | + | ROLLUP | 0 | 0 | + | SCHEMA_CHANGE | 0 | 0 | + | CANCEL_DELETE | 0 | 0 | + | MAKE_SNAPSHOT | 0 | 0 | + | RELEASE_SNAPSHOT | 0 | 0 | + | CHECK_CONSISTENCY | 0 | 0 | + | UPLOAD | 0 | 0 | + | DOWNLOAD | 0 | 0 | + | CLEAR_REMOTE_FILE | 0 | 0 | + | MOVE | 0 | 0 | + | REALTIME_PUSH | 0 | 0 | + | PUBLISH_VERSION | 0 | 0 | + | CLEAR_ALTER_TASK | 0 | 0 | + | CLEAR_TRANSACTION_TASK | 0 | 0 | + | RECOVER_TABLET | 0 | 0 | + | STREAM_LOAD | 0 | 0 | + | UPDATE_TABLET_META_INFO | 0 | 0 | + | ALTER | 0 | 0 | + | INSTALL_PLUGIN | 0 | 0 | + | UNINSTALL_PLUGIN | 0 | 0 | + | Total | 0 | 0 | + +-------------------------+-----------+----------+ + 26 rows in set (0.01 sec) + ``` + +5. Display the replica status of the entire cluster. + ```sql + mysql> show proc '/cluster_health/tablet_health'; + +----------+---------------------------+-----------+------------+-------------------+----------------------+----------------------+--------------+----------------------------+-------------------------+-------------------+---------------------+----------------------+----------------------+------------------+-----------------------------+-----------------+-------------+------------+ + | DbId | DbName | TabletNum | HealthyNum | ReplicaMissingNum | VersionIncompleteNum | ReplicaRelocatingNum | RedundantNum | ReplicaMissingInClusterNum | ReplicaMissingForTagNum | ForceRedundantNum | ColocateMismatchNum | ColocateRedundantNum | NeedFurtherRepairNum | UnrecoverableNum | ReplicaCompactionTooSlowNum | InconsistentNum | OversizeNum | CloningNum | + +----------+---------------------------+-----------+------------+-------------------+----------------------+----------------------+--------------+----------------------------+-------------------------+-------------------+---------------------+----------------------+----------------------+------------------+-----------------------------+-----------------+-------------+------------+ + | 25852112 | default_cluster:bowen | 1920 | 1920 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | + | 25342914 | default_cluster:bw | 128 | 128 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | + | 2575532 | default_cluster:cps | 1440 | 1440 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 16 | 0 | + | 26150325 | default_cluster:db | 38374 | 38374 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 453 | 0 | + +----------+---------------------------+-----------+------------+-------------------+----------------------+----------------------+--------------+----------------------------+-------------------------+-------------------+---------------------+----------------------+----------------------+------------------+-----------------------------+-----------------+-------------+------------+ + 4 rows in set (0.01 sec) + ``` + + View the replica status under a database, such as a database with a DbId of 25852112. + + ```sql + mysql> show proc '/cluster_health/tablet_health/25852112'; + ``` + +7. Report and diagnose cluster management issues + + ``` + MySQL > show proc "/diagnose"; + +-----------------+----------+------------+ + | Item | ErrorNum | WarningNum | + +-----------------+----------+------------+ + | cluster_balance | 2 | 0 | + | Total | 2 | 0 | + +-----------------+----------+------------+ + + 2 rows in set + ``` + + + View replica balance migration issues + + ```sql + MySQL > show proc "/diagnose/cluster_balance"; + +-----------------------+--------+-------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+------------+ + | Item | Status | Content | Detail Cmd | Suggestion | + +-----------------------+--------+-------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+------------+ + | Tablet Health | ERROR | healthy tablet num 691 < total tablet num 1014 | show proc "/cluster_health/tablet_health"; | | + | BeLoad Balance | ERROR | backend load not balance for tag {"location" : "default"}, low load backends [], high load backends [10009] | show proc "/cluster_balance/cluster_load_stat/location_default/HDD" | | + | Disk Balance | OK | | | | + | Colocate Group Stable | OK | | | | + | History Tablet Sched | OK | | | | + +-----------------------+--------+-------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+------------+ + + 5 rows in set + ``` + +## Keywords + + SHOW, PROC + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/CANCEL-REBALANCE-DISK.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/CANCEL-REBALANCE-DISK.md new file mode 100644 index 0000000000000..1305f8799f0c3 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/CANCEL-REBALANCE-DISK.md @@ -0,0 +1,56 @@ +--- +{ + "title": "CANCEL REBALANCE DISK", + "language": "en" +} + +--- + + + + +## Description + +This statement is used to cancel rebalancing disks of specified backends with high priority + +Grammar: + +ADMIN CANCEL REBALANCE DISK [ON ("BackendHost1:BackendHeartBeatPort1", "BackendHost2:BackendHeartBeatPort2", ...)]; + +Explain: + +1. This statement only indicates that the system no longer rebalance disks of specified backends with high priority. The system will still rebalance disks by default scheduling. + +## Example + +1. Cancel High Priority Disk Rebalance of all of backends of the cluster + +ADMIN CANCEL REBALANCE DISK; + +2. Cancel High Priority Disk Rebalance of specified backends + +ADMIN CANCEL REBALANCE DISK ON ("192.168.1.1:1234", "192.168.1.2:1234"); + +## Keywords + +ADMIN,CANCEL,REBALANCE DISK + +## Best Practice + + + diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/CANCEL-REPAIR-TABLE.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/CANCEL-REPAIR-TABLE.md new file mode 100644 index 0000000000000..005f3e50c949a --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/CANCEL-REPAIR-TABLE.md @@ -0,0 +1,55 @@ +--- +{ + "title": "CANCEL REPAIR", + "language": "en" +} +--- + + + + +## Description + +This statement is used to cancel the repair of the specified table or partition with high priority + +grammar: + +```sql +ADMIN CANCEL REPAIR TABLE table_name[ PARTITION (p1,...)]; +``` + +illustrate: + +1. This statement simply means that the system will no longer repair shard copies of the specified table or partition with high priority. Replicas are still repaired with the default schedule. + +## Example + + 1. Cancel high priority repair + + ```sql + ADMIN CANCEL REPAIR TABLE tbl PARTITION(p1); + ``` + +## Keywords + + ADMIN, CANCEL, REPAIR + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/CHECK-TABLET.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/CHECK-TABLET.md new file mode 100644 index 0000000000000..48c965542379a --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/CHECK-TABLET.md @@ -0,0 +1,63 @@ +--- +{ + "title": "CHECK TABLET", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to perform the specified check operation on a set of tablets. + +grammar: + +```sql +ADMIN CHECK TABLET (tablet_id1, tablet_id2, ...) +PROPERTIES("type" = "..."); +``` + +illustrate: + +1. A list of tablet ids must be specified along with the type property in PROPERTIES. +2. Type only supports: + + * consistency: Check the consistency of the replica of the tablet. This command is an asynchronous command. After sending, Doris will start to execute the consistency check job of the corresponding tablet. The final result will be reflected in the InconsistentTabletNum column in the result of `SHOW PROC "/cluster_health/tablet_health";`. + + +## Example + +1. Perform a replica data consistency check on a specified set of tablets. + + ``` + ADMIN CHECK TABLET (10000, 10001) + PROPERTIES("type" = "consistency"); + ``` + +## Keywords + + ADMIN, CHECK, TABLET + +## Best Practice + + diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/CLEAN-TRASH.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/CLEAN-TRASH.md new file mode 100644 index 0000000000000..aef8eb20b26ad --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/CLEAN-TRASH.md @@ -0,0 +1,54 @@ +--- +{ + "title": "CLEAN TRASH", + "language": "en" +} + + +--- + + + + +## Description + +This statement is used to clean up garbage data in the backend + +grammar: + +```sql +ADMIN CLEAN TRASH [ON ("BackendHost1:BackendHeartBeatPort1", "BackendHost2:BackendHeartBeatPort2", ...)]; +``` + +illustrate: + +1. Use BackendHost:BackendHeartBeatPort to indicate the backend that needs to be cleaned up, and clean up all backends without adding the on limit. + +## Example + +1. Clean up the junk data of all be nodes. + + ADMIN CLEAN TRASH; + +2. Clean up the junk data of '192.168.0.1:9050' and '192.168.0.2:9050'. + + ADMIN CLEAN TRASH ON ("192.168.0.1:9050","192.168.0.2:9050"); + +## Keywords \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/COMPACT-TABLE.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/COMPACT-TABLE.md new file mode 100644 index 0000000000000..ca7598dfbf754 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/COMPACT-TABLE.md @@ -0,0 +1,86 @@ +--- +{ + "title": "COMPACT TABLE", + "language": "en" +} + + +--- + + + + +## Description + +In the storage-computing coupled mode, this is used to trigger a compaction for all replicas under the specified table partition. + +This command is not supported in the storage-computing separation mode. + +## Syntax + +```sql +ADMIN COMPACT TABLE +PARTITION +WHERE TYPE={ BASE | CUMULATIVE } +``` + +## Required Parameters + + + +> The name of the table for which compaction is to be triggered. + + + +> The name of the partition for which compaction is to be triggered. (Note: This line should be corrected as it repeats the table name description, it should specify the partition name.) + +TYPE={ BASE | CUMULATIVE } + +> Where BASE refers to triggering a base compaction, and CUMULATIVE refers to triggering a cumulative compaction. For details, refer to the COMPACTION section. + +## Access Control Requirements + +The prerequisite for successfully executing this SQL command is to have ADMIN_PRIV permissions. Refer to the permission documentation. + +| Privilege | Object | Notes | +| :--------- | :----------------------------------- | :------------------------------ | +| ADMIN_PRIV | Entire cluster management privileges | All privileges except NODE_PRIV | + +## Example + +1. Trigger cumulative compaction for partition par01 of table tbl. + + ```sql + ADMIN COMPACT TABLE tbl PARTITION par01 WHERE TYPE='CUMULATIVE'; + ``` + +## Usage Note + +1. This command is not supported in the storage-computing separation mode. Executing it in this mode will result in an error, for example: + + ```sql + ADMIN COMPACT TABLE tbl PARTITION par01 WHERE TYPE='CUMULATIVE'; + ``` + + The error message is as follows: + + ```sql + ERROR 1105 (HY000): errCode = 2, detailMessage = Unsupported operation + ``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/COPY-TABLET.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/COPY-TABLET.md new file mode 100644 index 0000000000000..aee5761352bc8 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/COPY-TABLET.md @@ -0,0 +1,98 @@ +--- +{ + "title": "COPY TABLET", + "language": "en" +} +--- + + + + + + +## Description + +This statement is used to make a snapshot for the specified tablet, mainly used to load the tablet locally to reproduce the problem. + +syntax: + +```sql +ADMIN COPY TABLET tablet_id PROPERTIES("xxx"); +``` + +Notes: + +This command requires ROOT privileges. + +PROPERTIES supports the following properties: + +1. backend_id: Specifies the id of the BE node where the replica is located. If not specified, a replica is randomly selected. + +2. version: Specifies the version of the snapshot. The version must be less than or equal to the largest version of the replica. If not specified, the largest version is used. + +3. expiration_minutes: Snapshot retention time. The default is 1 hour. It will automatically clean up after a timeout. Unit minutes. + +The results are shown below: + +``` + TabletId: 10020 + BackendId: 10003 + Ip: 192.168.10.1 + Path: /path/to/be/storage/snapshot/20220830101353.2.3600 +ExpirationMinutes: 60 + CreateTableStmt: CREATE TABLE `tbl1` ( + `k1` int(11) NULL, + `k2` int(11) NULL +) ENGINE=OLAP +DUPLICATE KEY(`k1`, `k2`) +DISTRIBUTED BY HASH(k1) BUCKETS 1 +PROPERTIES ( +"replication_num" = "1", +"version_info" = "2" +); +``` + +* TabletId: tablet id +* BackendId: BE node id +* Ip: BE node ip +* Path: The directory where the snapshot is located +* ExpirationMinutes: snapshot expiration time +* CreateTableStmt: The table creation statement for the table corresponding to the tablet. This statement is not the original table-building statement, but a simplified table-building statement for later loading the tablet locally. + +## Example + +1. Take a snapshot of the replica on the specified BE node + + ```sql + ADMIN COPY TABLET 10010 PROPERTIES("backend_id" = "10001"); + ``` + +2. Take a snapshot of the specified version of the replica on the specified BE node + + ```sql + ADMIN COPY TABLET 10010 PROPERTIES("backend_id" = "10001", "version" = "10"); + ``` + +## Keywords + + ADMIN, COPY, TABLET + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/DIAGNOSE-TABLET.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/DIAGNOSE-TABLET.md new file mode 100644 index 0000000000000..55526330ac753 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/DIAGNOSE-TABLET.md @@ -0,0 +1,141 @@ +--- +{ + "title": "DIAGNOSE TABLET", + "language": "en" +} + +--- + + + + +## Description + +In the compute-storage coupled mode, this statement is used to diagnose a specified tablet. The result will display information about the tablet and some potential issues. + +This command is not supported in the compute-storage coupled mode. + +## Syntax + +```sql +SHOW TABLET DIAGNOSIS ; +``` + +## Required Parameters + + + +> The ID of the tablet to be diagnosed + +## Return Value (Return Value) + +Returns information about the tablet + +- TabletExist + + > Whether the tablet exists + +- TabletId + + > Tablet ID + +- Database + + > The DB and its ID that the tablet belongs to + +- Table + + > The Table and its ID that the tablet belongs to + +- Partition + + > The Partition and its ID that the tablet belongs to + +- MaterializedIndex + + > The materialized view and its ID that the tablet belongs to + +- Replicas + + > The replicas of the tablet and their corresponding BEs + +- ReplicasNum + + > Whether the number of replicas is correct + +- ReplicaBackendStatus + + > Whether the BE nodes where the replicas are located are normal + +- ReplicaVersionStatus + + > Whether the version numbers of the replicas are normal + +- ReplicaStatus + + > Whether the status of the replicas is normal + +- ReplicaCompactionStatus + + > Whether the compaction status of the replicas is normal + +## Examples + +1. Diagnose the information of the tablet with the specified tablet id 10078 + + ```sql + show tablet diagnosis 10078; + +----------------------------------+---------------------------------------------+------------+ + | Item | Info | Suggestion | + +----------------------------------+---------------------------------------------+------------+ + | TabletExist | Yes | | + | TabletId | 10078 | | + | Database | __internal_schema: 10005 | | + | Table | audit_log: 10058 | | + | Partition | p20241109: 10075 | | + | MaterializedIndex | audit_log: 10059 | | + | Replicas(ReplicaId -> BackendId) | {"10099":10003,"10116":10002,"10079":10004} | | + | ReplicasNum | OK | | + | ReplicaBackendStatus | OK | | + | ReplicaVersionStatus | OK | | + | ReplicaStatus | OK | | + | ReplicaCompactionStatus | OK | | + +----------------------------------+---------------------------------------------+------------+ + ``` + +## Access Control Requirements (Access Control Requirements) + +The prerequisite for successfully executing this SQL command is to have ADMIN_PRIV privileges. Please refer to the privilege documentation. + +| Privilege (Privilege) | Object (Object) | Notes (Notes) | +| :-------------------- | :----------------------------------- | :------------------------------ | +| ADMIN_PRIV | Entire cluster management privileges | All privileges except NODE_PRIV | + +## Usage Note (Usage Note) + +1. This command is not supported in the storage-computing separation mode. Executing it in this mode will result in an error, for example: + + ```sql + show tablet diagnosis 15177; + ``` + + The error message is as follows: + + ```sql + ERROR 1105 (HY000): errCode = 2, detailMessage = Unsupported operation + ``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/REBALANCE-DISK.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/REBALANCE-DISK.md new file mode 100644 index 0000000000000..21dea061c04b1 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/REBALANCE-DISK.md @@ -0,0 +1,67 @@ +--- +{ + "title": "REBALANCE DISK", + "language": "en" +} + +--- + + + + + + +### Name + +ADMIN REBALANCE DISK + +## Description + +This statement is used to try to rebalance disks of the specified backends first, no matter if the cluster is balanced + +Grammar: + +``` +ADMIN REBALANCE DISK [ON ("BackendHost1:BackendHeartBeatPort1", "BackendHost2:BackendHeartBeatPort2", ...)]; +``` + +Explain: + +1. This statement only means that the system attempts to rebalance disks of specified backends with high priority, no matter if the cluster is balanced. +2. The default timeout is 24 hours. Timeout means that the system will no longer rebalance disks of specified backends with high priority. The command settings need to be reused. + +## Example + +1. Attempt to rebalance disks of all backends + +``` +ADMIN REBALANCE DISK; +``` + +2. Attempt to rebalance disks oof the specified backends + +``` +ADMIN REBALANCE DISK ON ("192.168.1.1:1234", "192.168.1.2:1234"); +``` + +## Keywords + +ADMIN,REBALANCE,DISK + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/REPAIR-TABLE.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/REPAIR-TABLE.md new file mode 100644 index 0000000000000..3e37dbd7b0b5a --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/REPAIR-TABLE.md @@ -0,0 +1,58 @@ +--- +{ + "title": "REPAIR TABLE", + "language": "en" +} +--- + + + + +## Description + +statement used to attempt to preferentially repair the specified table or partition + +grammar: + +```sql +ADMIN REPAIR TABLE table_name[ PARTITION (p1,...)] +``` + +illustrate: + +1. This statement only means to let the system try to repair the shard copy of the specified table or partition with high priority, and does not guarantee that the repair can be successful. Users can view the repair status through the SHOW REPLICA STATUS command. +2. The default timeout is 14400 seconds (4 hours). A timeout means that the system will no longer repair shard copies of the specified table or partition with high priority. Need to re-use this command to set + +## Example + +1. Attempt to repair the specified table + + ADMIN REPAIR TABLE tbl1; + +2. Try to repair the specified partition + + ADMIN REPAIR TABLE tbl1 PARTITION (p1, p2); + +## Keywords + + ADMIN, REPAIR, TABLE + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-REPLICA-STATUS.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-REPLICA-STATUS.md new file mode 100644 index 0000000000000..5f5d10ef5fd08 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-REPLICA-STATUS.md @@ -0,0 +1,82 @@ +--- +{ + "title": "SET REPLICA STATUS", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to set the state of the specified replica. + +This command is currently only used to manually set the status of certain replicas to BAD, DROP or OK, allowing the system to automatically repair these replicas + +grammar: + +```sql +ADMIN SET REPLICA STATUS + PROPERTIES ("key" = "value", ...); +``` + + The following properties are currently supported: + +1. "tablet_id": Required. Specify a Tablet Id. +2. "backend_id": Required. Specify Backend Id. +3. "status": Required. Specifies the state. Currently only "bad", "drop" or "ok" are supported + +If the specified replica does not exist, or the status is already bad, it will be ignored. + +> Note: +> +> A replica set to Bad, it will not be able to read or write. In addition, sometimes the setting may not working, when be report tablet ok, fe will auto change its status to ok. This operation may delete the replica immediately, so please operate with caution. +> +> A replica set to Drop, it can still be read and written. A healthy replica will be added to other machines first, and then this replica will be deleted. Compared with setting Bad, setting Drop is safer. + +## Example + + 1. Set the replica status of tablet 10003 on BE 10001 to bad. + + ```sql + ADMIN SET REPLICA STATUS PROPERTIES("tablet_id" = "10003", "backend_id" = "10001", "status" = "bad"); + ``` + + 2. Set the replica status of tablet 10003 on BE 10001 to drop. + + ```sql + ADMIN SET REPLICA STATUS PROPERTIES("tablet_id" = "10003", "backend_id" = "10001", "status" = "drop"); + ``` + + + 3. Set the replica status of tablet 10003 on BE 10001 to ok. + + ```sql + ADMIN SET REPLICA STATUS PROPERTIES("tablet_id" = "10003", "backend_id" = "10001", "status" = "ok"); + ``` + +## Keywords + + ADMIN, SET, REPLICA, STATUS + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-REPLICA-VERSION.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-REPLICA-VERSION.md new file mode 100644 index 0000000000000..8996939ea38fb --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-REPLICA-VERSION.md @@ -0,0 +1,79 @@ +--- +{ + "title": "SET REPLICA VERSION", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to set the version, maximum success version, and maximum failure version of the specified replica. + +This command is currently only used to manually repair the replica version when the program is abnormal, so that the replica can recover from the abnormal state. + +grammar: + +```sql +ADMIN SET REPLICA VERSION + PROPERTIES ("key" = "value", ...); +``` + +The following properties are currently supported: + +1. `tablet_id`: Required. Specify a Tablet Id. +2. `backend_id`: Required. Specify Backend Id. +3. `version`: Optional. Set the replica version. +4. `last_success_version`: Optional. Set the replica max success version. +5. `last_failed_version`: Optional. Set the replica max failed version. + +If the specified replica does not exist, it will be ignored. + +> Note: +> +> Modifying these values ​​may cause subsequent data reading and writing failures, resulting in data inconsistency. Please operate with caution! +> +> Record the original value before modifying it. After the modification is completed, verify the read and write of the table. If the read and write fail, please restore the original value! But recovery may fail! +> +> It is strictly prohibited to operate the tablet that is writing data! + +## Example + + 1. Clear the replica failed version of tablet 10003 on BE 10001. + + ```sql +ADMIN SET REPLICA VERSION PROPERTIES("tablet_id" = "10003", "backend_id" = "10001", "last_failed_version" = "-1"); + ``` + +2. Set the replica status of tablet 10003 on BE 10001 to ok. + +```sql +ADMIN SET REPLICA VERSION PROPERTIES("tablet_id" = "10003", "backend_id" = "10001", "version" = "1004"); +``` + +## Keywords + + ADMIN, SET, REPLICA, VERSION + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-TABLE-PARTITION-VERSION.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-TABLE-PARTITION-VERSION.md new file mode 100644 index 0000000000000..a2242ff44591c --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-TABLE-PARTITION-VERSION.md @@ -0,0 +1,63 @@ +--- +{ + "title": "SET TABLE PARTITION VERSION", + "language": "en" +} +--- + + + +## Description + +In compute-storage coupled mode. This statement is used to manually change the visible version of the specified partition. In some special cases, the version of the partition in the metadata may be inconsistent with the version of the actual replica. + +This command can manually change the version of the partition in the metadata. This command is generally only used for emergency failure recovery. Please operate with caution. + +## Syntax + +```sql +ADMIN SET TABLE PARTITION VERSION PROPERTIES ("" = "visible_version>"); +``` + +## Required Parameters + + + +> The name of the table to be set. + + + +> Specify a Partition Id. + + + +> Specify Version. + +## Examples + +1. Set the version of the partition with partition_id 10075 to 100 in the FE metadata. + + ```sql + ADMIN SET TABLE __internal_schema.audit_log PARTITION VERSION PROPERTIES("partition_id" = "10075", "visible_version" = "100"); + ``` +## Usage Note + +1. Before setting the partition version, you need to confirm the version of the actual replica on the BE machine. This command is generally only used for emergency failure recovery. Please operate with caution. +2. This command is not supported in the storage-computing separation mode. It will not take effect if set. \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-TABLE-STATUS.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-TABLE-STATUS.md new file mode 100644 index 0000000000000..028232af4e8a6 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-TABLE-STATUS.md @@ -0,0 +1,78 @@ +--- +{ + "title": "SET TABLE STATUS", + "language": "en" +} +--- + + + + + + +## Description + +This statement is used to set the state of the specified table. Only supports OLAP tables. + +This command is currently only used to manually set the OLAP table state to the specified state, allowing some jobs that are stuck by the table state to continue running. + +grammar: + +```sql +ADMIN SET TABLE table_name STATUS + PROPERTIES ("key" = "value", ...); +``` + +The following properties are currently supported: + +1. "state":Required. Specifying a target state then the state of the OLAP table will change to this state. + +> The current target states include: +> +> 1. NORMAL +> 2. ROLLUP +> 3. SCHEMA_CHANGE +> 4. BACKUP +> 5. RESTORE +> 6. WAITING_STABLE +> +> If the current state of the table is already the specified state, it will be ignored. + +**Note: This command is generally only used for emergency fault repair, please proceed with caution.** + +## Example + +1. Set the state of table tbl1 to NORMAL. + +```sql +admin set table tbl1 status properties("state" = "NORMAL"); +``` + +2. Set the state of table tbl2 to SCHEMA_CHANGE + +```sql +admin set table test_set_table_status status properties("state" = "SCHEMA_CHANGE"); +``` + +## Keywords + + ADMIN, SET, TABLE, STATUS + +## Best Practice \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-DATA-SKEW.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-DATA-SKEW.md new file mode 100644 index 0000000000000..d2d5c794c9d19 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-DATA-SKEW.md @@ -0,0 +1,51 @@ +--- +{ +"title": "SHOW DATA SKEW", +"language": "en" +} +--- + + + + + +## Description + +This statement is used to view the data skew of a table or a partition. + +grammar: + +`SHOW DATA SKEW FROM [db_name.]tbl_name [PARTITION (p1)];` + + + +1. Only one partition must be specified. For non-partitioned tables, the partition name is the same as the table name. +2. The result will show row count and data volume of each bucket under the specified partition, and the proportion of the data volume of each bucket in the total data volume. + +## Example + +1. View the data skew of the table + + ` SHOW DATA SKEW FROM db1.test PARTITION(p1);` + +## Keywords + +SHOW, DATA, SKEW + diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-DATA.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-DATA.md new file mode 100644 index 0000000000000..5efddf21d5e69 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-DATA.md @@ -0,0 +1,137 @@ +--- +{ + "title": "SHOW DATA", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to display the amount of data, the number of replicas, and the number of statistical rows. + +grammar: + +```sql +SHOW DATA [FROM [db_name.]table_name] [ORDER BY ...]; +``` + +illustrate: + +1. If the FROM clause is not specified, the data volume and number of replicas subdivided into each table under the current db will be displayed. The data volume is the total data volume of all replicas. The number of replicas is the number of replicas for all partitions of the table and all materialized views. + +2. If the FROM clause is specified, the data volume, number of copies and number of statistical rows subdivided into each materialized view under the table will be displayed. The data volume is the total data volume of all replicas. The number of replicas is the number of replicas for all partitions of the corresponding materialized view. The number of statistical rows is the number of statistical rows for all partitions of the corresponding materialized view. + +3. When counting the number of rows, the one with the largest number of rows among the multiple copies shall prevail. + +4. The `Total` row in the result set represents the total row. The `Quota` line represents the quota set by the current database. The `Left` line indicates the remaining quota. + +5. If you want to see the size of each Partition, see `help show partitions`. + +6. You can use ORDER BY to sort on any combination of columns. + +## Example + +1. Display the data size and RecycleBin size of each database by default. + + ``` + SHOW DATA; + ``` + + ``` + +-------+-----------------------------------+--------+------------+-------------+-------------------+ + | DbId | DbName | Size | RemoteSize | RecycleSize | RecycleRemoteSize | + +-------+-----------------------------------+--------+------------+-------------+-------------------+ + | 21009 | db1 | 0 | 0 | 0 | 0 | + | 22011 | regression_test_inverted_index_p0 | 72764 | 0 | 0 | 0 | + | 0 | information_schema | 0 | 0 | 0 | 0 | + | 22010 | regression_test | 0 | 0 | 0 | 0 | + | 1 | mysql | 0 | 0 | 0 | 0 | + | 22017 | regression_test_show_p0 | 0 | 0 | 0 | 0 | + | 10002 | __internal_schema | 46182 | 0 | 0 | 0 | + | Total | NULL | 118946 | 0 | 0 | 0 | + +-------+-----------------------------------+--------+------------+-------------+-------------------+ + ``` + +2. Display the data volume, replica number, aggregate data volume and aggregate replica number of each table in a database. + + ```sql + USE db1; + SHOW DATA; + ``` + + ``` + +-----------+-------------+--------------+ + | TableName | Size | ReplicaCount | + +-----------+-------------+--------------+ + | tbl1 | 900.000 B | 6 | + | tbl2 | 500.000 B | 3 | + | Total | 1.400 KB | 9 | + | Quota | 1024.000 GB | 1073741824 | + | Left | 1021.921 GB | 1073741815 | + +-----------+-------------+--------------+ + ``` + +3. Display the subdivided data volume, the number of replicas and the number of statistical rows of the specified table under the specified db + + ```sql + SHOW DATA FROM example_db.test; + ``` + + ``` + +-----------+-----------+-----------+--------------+----------+ + | TableName | IndexName | Size | ReplicaCount | RowCount | + +-----------+-----------+-----------+--------------+----------+ + | test | r1 | 10.000MB | 30 | 10000 | + | | r2 | 20.000MB | 30 | 20000 | + | | test2 | 50.000MB | 30 | 50000 | + | | Total | 80.000 | 90 | | + +-----------+-----------+-----------+--------------+----------+ + ``` + +4. It can be combined and sorted according to the amount of data, the number of copies, the number of statistical rows, etc. + + ```sql + SHOW DATA ORDER BY ReplicaCount desc,Size asc; + ``` + + ``` + +-----------+-------------+--------------+ + | TableName | Size | ReplicaCount | + +-----------+-------------+--------------+ + | table_c | 3.102 KB | 40 | + | table_d | .000 | 20 | + | table_b | 324.000 B | 20 | + | table_a | 1.266 KB | 10 | + | Total | 4.684 KB | 90 | + | Quota | 1024.000 GB | 1073741824 | + | Left | 1024.000 GB | 1073741734 | + +-----------+-------------+--------------+ + ``` + +## Keywords + + SHOW, DATA + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-REPLICA-DISTRIBUTION.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-REPLICA-DISTRIBUTION.md new file mode 100644 index 0000000000000..2d70efdc337af --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-REPLICA-DISTRIBUTION.md @@ -0,0 +1,62 @@ +--- +{ + "title": "SHOW REPLICA DISTRIBUTION", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to display the distribution status of a table or partition replica + +grammar: + +```sql +SHOW REPLICA DISTRIBUTION FROM [db_name.]tbl_name [PARTITION (p1, ...)]; +``` + +illustrate: + +1. The Graph column in the result shows the replica distribution ratio in the form of a graph + +## Example + +1. View the replica distribution of the table + + ```sql + SHOW REPLICA DISTRIBUTION FROM tbl1; + ``` + + 2. View the replica distribution of the partitions of the table + + ```sql + SHOW REPLICA DISTRIBUTION FROM db1.tbl1 PARTITION(p1, p2); + ``` + +## Keywords + + ADMIN, SHOW, REPLICA, DISTRIBUTION + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-REPLICA-STATUS.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-REPLICA-STATUS.md new file mode 100644 index 0000000000000..ad73ac4ab70ea --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-REPLICA-STATUS.md @@ -0,0 +1,79 @@ +--- +{ + "title": "SHOW REPLICA STATUS", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to display replica status information for a table or partition. + +grammar: + +```sql +SHOW REPLICA STATUS FROM [db_name.]tbl_name [PARTITION (p1, ...)] +[where_clause]; +``` + +illustrate + +1. where_clause: + WHERE STATUS [!]= "replica_status" + +2. replica_status: + OK: replica is healthy + DEAD: The Backend where the replica is located is unavailable + VERSION_ERROR: replica data version is missing + SCHEMA_ERROR: The schema hash of the replica is incorrect + MISSING: replica does not exist + +## Example + +1. View the status of all replicas of the table + + ```sql + SHOW REPLICA STATUS FROM db1.tbl1; + ``` + +2. View a copy of a table with a partition status of VERSION_ERROR + + ```sql + SHOW REPLICA STATUS FROM tbl1 PARTITION (p1, p2) + WHERE STATUS = "VERSION_ERROR"; + ``` + +3. View all unhealthy replicas of the table + + ```sql + SHOW REPLICA STATUS FROM tbl1 + WHERE STATUS != "OK"; + ``` + +## Keywords + + SHOW, REPLICA, STATUS + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET-DIAGNOSIS.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET-DIAGNOSIS.md new file mode 100644 index 0000000000000..dcd590e0e3158 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET-DIAGNOSIS.md @@ -0,0 +1,60 @@ +--- +{ + "title": "SHOW TABLET DIAGNOSIS", + "language": "en" +} +--- + + + + +## Description + +This statement is used to diagnose the specified tablet. The results will show information about the tablet and some potential problems. + +grammar: + +SHOW TABLET DIAGNOSE TABLET tablet_id + +illustrate: + +The lines of information in the result are as follows: +1. TabletExist: Whether the Tablet exists +2. TabletId: Tablet ID +3. Database: The DB to which the Tablet belongs and its ID +4. Table: The Table to which Tablet belongs and its ID +5. Partition: The Partition to which the Tablet belongs and its ID +6. MaterializedIndex: The materialized view to which the Tablet belongs and its ID +7. Replicas(ReplicaId -> BackendId): Tablet replicas and their BE. +8. ReplicasNum: Whether the number of replicas is correct. +9. ReplicaBackendStatus: Whether the BE node where the replica is located is normal. +10. ReplicaVersionStatus: Whether the version number of the replica is normal. +11. ReplicaStatus: Whether the replica status is normal. +12. ReplicaCompactionStatus: Whether the replica Compaction status is normal. + +## Example + +1. Diagnose tablet 10001 + + ```sql + SHOW TABLET DIAGNOSE TABLET 10001; + ``` + +## Keywords + +SHOW, DIAGNOSIS, TABLET diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET-STORAGE-FORMAT.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET-STORAGE-FORMAT.md new file mode 100644 index 0000000000000..51caa8e7b8f45 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET-STORAGE-FORMAT.md @@ -0,0 +1,60 @@ +--- +{ + "title": "SHOW TABLET STORAGE FORMAT", + "language": "en" +} +--- + + + + +## Description + +This statement is used to display tablet storage foramt information (for administrators only) + +Grammar: + +`SHOW TABLET STORAGE FORMAT [VERBOSE]` + +## Example + +```sql +MySQL [(none)]> show tablet storage format; ++-----------+---------+---------+ +| BackendId | V1Count | V2Count | ++-----------+---------+---------+ +| 10002 | 0 | 2867 | ++-----------+---------+---------+ +1 row in set (0.003 sec) +MySQL [test_query_qa]> show tablet storage format verbose; ++-----------+----------+---------------+ +| BackendId | TabletId | StorageFormat | ++-----------+----------+---------------+ +| 10002 | 39227 | V2 | +| 10002 | 39221 | V2 | +| 10002 | 39215 | V2 | +| 10002 | 39199 | V2 | ++-----------+----------+---------------+ +4 rows in set (0.034 sec) +``` + +## Keywords + SHOW, TABLET, STORAGE, FORMAT + diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET.md new file mode 100644 index 0000000000000..9c384433e5ec3 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET.md @@ -0,0 +1,79 @@ +--- +{ + "title": "SHOW TABLETS", + "language": "en" +} +--- + + + + + + +## Description + +This statement is used to list tablets of the specified table (only for administrators) + +grammar: + +```sql +SHOW TABLETS FROM [database.]table [PARTITIONS(p1,p2)] +[WHERE where_condition] +[ORDER BY col_name] +[LIMIT [offset,] row_count] +``` + +1. **Syntax Description:** + +where_condition could be one of: +``` +Version = version +state = "NORMAL|ROLLUP|CLONE|DECOMMISSION" +BackendId = backend_id +IndexName = rollup_name +``` +or compound them with operator `AND`. + +## Example + +1. list all tablets of the specified table + + ```sql + SHOW TABLETS FROM example_db.table_name; + ``` + +2. list all tablets of the specified partitions + + ```sql + SHOW TABLETS FROM example_db.table_name PARTITIONS(p1, p2); + ``` + +3. list all DECOMMISSION tablets on the specified backend + + ```sql + SHOW TABLETS FROM example_db.table_name WHERE state="DECOMMISSION" AND BackendId=11003; + ``` + +## Keywords + + SHOW, TABLETS + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLETS-BELONG.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLETS-BELONG.md new file mode 100644 index 0000000000000..9b1b62c56fb80 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLETS-BELONG.md @@ -0,0 +1,65 @@ +--- +{ + "title": "SHOW TABLETS BELONG", + "language": "en" +} +--- + + + + +### Description + +Used to show tablets and information of their belonging table + +grammar: + +```sql +SHOW TABLETS BELONG tablet-ids; +``` + +illustrate: + +1. tablet-ids: one or more tablet-ids, with comma separated +2. Columns of result keep same with result of `SHOW-DATA` for the same table + +### Example + +1. show information of four tablet-ids (actually, three tablet-ids. Result will be deduplicated) + + ```sql + SHOW TABLETS BELONG 27028,78880,78382,27028; + ``` + + ``` ++---------------------+-----------+-----------+--------------+-----------+--------------+----------------+ +| DbName | TableName | TableSize | PartitionNum | BucketNum | ReplicaCount | TabletIds | ++---------------------+-----------+-----------+--------------+-----------+--------------+----------------+ +| default_cluster:db1 | kec | 613.000 B | 379 | 604 | 604 | [78880, 78382] | +| default_cluster:db1 | test | 1.874 KB | 1 | 1 | 1 | [27028] | ++---------------------+-----------+-----------+--------------+-----------+--------------+----------------+ + ``` + +### Keywords + + SHOW, TABLETS, BELONG + +### Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TRASH.md b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TRASH.md new file mode 100644 index 0000000000000..8775aff3c2585 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TRASH.md @@ -0,0 +1,62 @@ +--- +{ + "title": "SHOW TRASH", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to view the garbage data footprint within the backend. + +grammar: + +```sql +SHOW TRASH [ON BackendHost:BackendHeartBeatPort]; +``` + +illustrate: + +1. The Backend format is the node's BackendHost:BackendHeartBeatPort +2. TrashUsedCapacity indicates the space occupied by the garbage data of the node. + +## Example + +1. View the space occupied by garbage data of all be nodes. + + ```sql + SHOW TRASH; + ``` + +2. View the space occupied by garbage data of '192.168.0.1:9050' (specific disk information will be displayed). + + ```sql + SHOW TRASH ON "192.168.0.1:9050"; + ``` + +## Keywords + + SHOW, TRASH + +## Best Practice \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/table-and-view/index/BUILD-INDEX.md b/docs/sql-manual/sql-statements/table-and-view/index/BUILD-INDEX.md new file mode 100644 index 0000000000000..e3a358a4131d9 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/index/BUILD-INDEX.md @@ -0,0 +1,103 @@ +--- +{ + "title": "BUILD INDEX", + "language": "en" +} +--- + + + +## Description + +Build an index for the entire table or table partitions. You must specify the table name and index name, and optionally specify the partition list. + +## Syntax + +```sql +BUILD INDEX ON [partition_list] +``` + +Where: + +```sql +partition_list + : PARTITION ([ , parition_name2 ][ ... ]) +``` +## Required Parameters + +**** + +> Specifies the identifier (name) of the index, which must be unique within its table. +> +> The identifier must start with a letter character (or any language character if unicode name support is enabled) and cannot contain spaces or special characters unless the entire identifier string is enclosed in backticks (e.g., `My Object`). +> +> The identifier cannot use reserved keywords. +> +> For more details, see Identifier Requirements and Reserved Keywords. + +**** + +> Specifies the identifier (name) of the table, which must be unique within its database. +> +> The identifier must start with a letter character (or any language character if unicode name support is enabled) and cannot contain spaces or special characters unless the entire identifier string is enclosed in backticks (e.g., `My Object`). +> +> The identifier cannot use reserved keywords. +> +> For more details, see Identifier Requirements and Reserved Keywords. + +## Optional Parameters + +**** + +> Specifies a list of partition identifiers (names) separated by commas, which must be unique within their table. +> +> The identifier must start with a letter character (or any language character if unicode name support is enabled) and cannot contain spaces or special characters unless the entire identifier string is enclosed in backticks (e.g., `My Object`). +> +> The identifier cannot use reserved keywords. +> +> For more details, see Identifier Requirements and Reserved Keywords. + +## Access Control Requirements + +Users executing this SQL command must have at least the following privileges: + +| Privilege | Object | Notes | +| :--------- | :----- | :------------------------------------------- | +| ALTER_PRIV | Table | BUILD INDEX is an ALTER operation on a table | + +## Usage Notes + +- Currently only valid for inverted indexes, other indexes such as BloomFilter index are not valid. +- Currently only valid for compute-storage integrated mode, not valid for compute-storage separated mode. +- The progress of BUILD INDEX can be viewed through SHOW BUILD INDEX + +## Examples + +- Build index index1 on the entire table1. + + ```sql + BUILD INDEX index1 ON TABLE table1 + ``` + +- Build index index1 on partitions p1 and p2 of table1. + + ```sql + BUILD INDEX index1 ON TABLE table1 PARTITION(p1, p2) + ``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/table-and-view/index/CANCEL-BUILD-INDEX.md b/docs/sql-manual/sql-statements/table-and-view/index/CANCEL-BUILD-INDEX.md new file mode 100644 index 0000000000000..1bb29369f2a8d --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/index/CANCEL-BUILD-INDEX.md @@ -0,0 +1,90 @@ +--- +{ + "title": "CANCEL BUILD INDEX", + "language": "en" +} +--- + + + +## Description + +Cancel background tasks for index building. + +## Syntax + + +```sql +CANCEL BUILD INDEX ON [ job_list ] +``` + +其中: + +```sql +job_list + : ([ , job_id2 ][ ... ]) +``` +## Required Parameters + +**** + +> Specifies the identifier (i.e., name) of the table, which must be unique within its database (Database). +> +> The identifier must start with a letter character (or any language character if unicode name support is enabled) and cannot contain spaces or special characters unless the entire identifier string is enclosed in backticks (e.g., `My Object`). +> +> Identifiers cannot use reserved keywords. +> +> For more details, see Identifier Requirements and Reserved Keywords. + +## Optional Parameters + +**** + +> Specifies a list of identifiers for index building tasks, separated by commas and enclosed in parentheses. +> +> Identifiers must be numbers and can be viewed via SHOW BUILD INDEX. + +## Access Control Requirements + +The user executing this SQL command must have at least the following privileges: + +| Privilege | Object | Notes | +| :--------- | :----- | :----------------------------------------------------------- | +| ALTER_PRIV | Table | CANCEL BUILD INDEX is considered an ALTER operation on the table | + +## Usage Notes + +- Currently only effective for inverted indexes, not for other indexes such as bloomfilter index. +- Currently only effective for the integrated storage and computing mode, not for the separated storage and computing mode. +- The progress and index building tasks of BUILD INDEX can be viewed via SHOW BUILD INDEX. + +## Examples + +- Cancel all index building tasks on table table1 + + ```sql + CANCEL BUILD INDEX ON TABLE table1 + ``` + +- Cancel index building tasks jobid1 and jobid2 on table table1 + + ```sql + CANCEL BUILD INDEX ON TABLE table1(jobid1, jobid2) + ``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md b/docs/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md new file mode 100644 index 0000000000000..43cf9bcddbe53 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md @@ -0,0 +1,55 @@ +--- +{ + "title": "CREATE INDEX", + "language": "en" +} +--- + + + + +## Description + +This statement is used to create an index +grammar: + +```sql +CREATE INDEX [IF NOT EXISTS] index_name ON table_name (column [, ...],) [USING INVERTED] [COMMENT 'balabala']; +``` +Notice: +- INVERTED indexes are only created on a single column + +## Example + +1. Create a inverted index for siteid on table1 + + ```sql + CREATE INDEX [IF NOT EXISTS] index_name ON table1 (siteid) USING INVERTED COMMENT 'balabala'; + ``` + + +## Keywords + +```text +CREATE, INDEX +``` + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/index/DROP-INDEX.md b/docs/sql-manual/sql-statements/table-and-view/index/DROP-INDEX.md new file mode 100644 index 0000000000000..24f3770926106 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/index/DROP-INDEX.md @@ -0,0 +1,49 @@ +--- +{ + "title": "DROP INDEX", + "language": "en" +} +--- + + + + +## Description + +This statement is used to delete the index of the specified name from a table. +grammar: + +```sql +DROP INDEX [IF EXISTS] index_name ON [db_name.]table_name; +``` + +## Example + +1. Delete the index + + ```sql + DROP INDEX [IF NOT EXISTS] index_name ON table1 ; + ``` + +## Keywords + + DROP, INDEX + +## Best Practice diff --git a/docs/sql-manual/sql-statements/table-and-view/index/SHOW-BUILD-INDEX.md b/docs/sql-manual/sql-statements/table-and-view/index/SHOW-BUILD-INDEX.md new file mode 100644 index 0000000000000..ab3ab6a14cb0a --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/index/SHOW-BUILD-INDEX.md @@ -0,0 +1,123 @@ +--- +{ + "title": "SHOW BUILD INDEX", + "language": "en" +} +--- + + + + +## Description + +Check the status of index build tasks. + +## Syntax + +```sql +SHOW BUILD INDEX [ (FROM | IN) +[ where_clause ] [ sort_clause ] [ limit_clause ] ] +``` + +Where: + +```sql +where_clause + : WHERE +``` + +Where: + +```sql +sort_clause + : + ORDER BY +``` + +Where: + +```sql +limit_clause + : + LIMIT +``` +## Optional Parameters + +**``** + +> Specifies the identifier (name) of the database, which must be unique within its cluster. +> +> The identifier must start with a letter character (or any language character if unicode name support is enabled) and cannot contain spaces or special characters unless the entire identifier string is enclosed in backticks (e.g., `My Object`). +> +> Identifiers cannot use reserved keywords. +> +> For more details, see Identifier Requirements and Reserved Keywords. + + +**``** + +> Specifies the output filter condition, where output_column_name must be in the output field list. + +**``** + +> Specifies the output sort column, where output_column_name must be in the output field list. + +**`LIMIT `** + +> Specifies the limit on the number of output rows, where n must be a number. + +## Access Control Requirements + +Users executing this SQL command must have at least the following privileges: + +| Privilege | Object | Notes | +| :-------- | :------- | :---- | +| SHOW_PRIV | Database | | + +## Usage Notes + +- Currently only valid for inverted indexes, not other indexes such as bloomfilter index. +- Currently only valid for the integrated storage and computing mode, not valid for the separated storage and computing mode. + +## Examples + +- View all index build tasks + + ```sql + SHOW BUILD INDEX + ``` + +- View index build tasks for database database1 + + ```sql + SHOW BUILD INDEX FROM database1 + ``` + +- View index build tasks for table table1 + + ```sql + SHOW BUILD INDEX WHERE TableName = 'table1' + ``` + +- View index build tasks for table table1, sorted by JobId and taking the first 10 rows + + ```sql + SHOW BUILD INDEX WHERE TableName = 'table1' ORDER BY JobId LIMIT 10 + ``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/table-and-view/index/SHOW-INDEX.md b/docs/sql-manual/sql-statements/table-and-view/index/SHOW-INDEX.md new file mode 100644 index 0000000000000..849f5ed242d52 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/index/SHOW-INDEX.md @@ -0,0 +1,53 @@ +--- +{ + "title": "SHOW INDEX", + "language": "en" +} +--- + + + + +## Description + + This statement is used to display information about indexes in a table. + +grammar: + +```SQL +SHOW INDEX[ES] FROM [db_name.]table_name [FROM database]; +or +SHOW KEY[S] FROM [db_name.]table_name [FROM database]; +``` + +## Example + + 1. Display the lower index of the specified table_name + + ```SQL + SHOW INDEX FROM example_db.table_name; + ``` + +## Keywords + + SHOW, INDEX + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/materialized-view/ALTER-ASYNC-MATERIALIZED-VIEW.md b/docs/sql-manual/sql-statements/table-and-view/materialized-view/ALTER-ASYNC-MATERIALIZED-VIEW.md new file mode 100644 index 0000000000000..d3c799a4e7dcf --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/materialized-view/ALTER-ASYNC-MATERIALIZED-VIEW.md @@ -0,0 +1,92 @@ +--- +{ + "title": "ALTER ASYNC MATERIALIZED VIEW", + "language": "en" +} +--- + + + +## Description + +This statement is used to modify asynchronous materialized views. + +#### syntax + +```sql +ALTER MATERIALIZED VIEW mvName=multipartIdentifier ((RENAME newName=identifier) + | (REFRESH (refreshMethod | refreshTrigger | refreshMethod refreshTrigger)) + | REPLACE WITH MATERIALIZED VIEW newName=identifier propertyClause? + | (SET LEFT_PAREN fileProperties=propertyItemList RIGHT_PAREN)) +``` + +#### illustrate + +##### RENAME + +Used to change the name of the materialized view + +For example, changing the name of mv1 to mv2 +```sql +ALTER MATERIALIZED VIEW mv1 rename mv2; +``` + +##### refreshMethod + +Same as [creating asynchronous materialized views](../Create/CREATE-ASYNC-MATERIALIZED-VIEW.md) + +##### refreshTrigger + +Same as [creating asynchronous materialized views](../Create/CREATE-ASYNC-MATERIALIZED-VIEW.md) + +##### SET +Modify properties unique to materialized views + +For example, modifying the grace_period of mv1 to 3000ms +```sql +ALTER MATERIALIZED VIEW mv1 set("grace_period"="3000"); +``` + +##### REPLACE +```sql +ALTER MATERIALIZED VIEW [db.]mv1 REPLACE WITH MATERIALIZED VIEW mv2 +[PROPERTIES('swap' = 'true')]; +``` +Replacing atoms with two materialized views + +swap default is TRUE +- If the swap parameter is set to TRUE, it is equivalent to renaming the materialized view mv1 to mv2, and renaming mv2 to mv1 at the same time +- If the swap parameter is set to FALSE, it is equivalent to renaming mv2 to mv1 and deleting the original mv1 + +For example, if you want to swap the names of mv1 and mv2 +```sql +ALTER MATERIALIZED VIEW db1.mv1 REPLACE WITH MATERIALIZED VIEW mv2; +``` + +For example, if you want to rename mv2 to mv1 and delete the original mv1 +```sql +ALTER MATERIALIZED VIEW db1.mv1 REPLACE WITH MATERIALIZED VIEW mv2 +PROPERTIES('swap' = 'false'); +``` + +## Keywords + + ALTER, ASYNC, MATERIALIZED, VIEW + diff --git a/docs/sql-manual/sql-statements/table-and-view/materialized-view/CANCEL-MATERIALIZED-VIEW-TASK.md b/docs/sql-manual/sql-statements/table-and-view/materialized-view/CANCEL-MATERIALIZED-VIEW-TASK.md new file mode 100644 index 0000000000000..1b3979e66ca49 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/materialized-view/CANCEL-MATERIALIZED-VIEW-TASK.md @@ -0,0 +1,51 @@ +--- +{ + "title": "CANCEL MATERIALIZED VIEW TASK", + "language": "en" +} +--- + + + + +## Description + +This statement is used to cancel the task of materialized views + +syntax: + +```sql +CANCEL MATERIALIZED VIEW TASK taskId=INTEGER_VALUE ON mvName=multipartIdentifier +``` + +## Example + +1. Cancel the task with id 1 in materialized view mv1 + + ```sql + CANCEL MATERIALIZED VIEW TASK 1 on mv1; + ``` + +## Keywords + + CANCEL, MATERIALIZED, VIEW, TASK + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/materialized-view/CREATE-ASYNC-MATERIALIZED-VIEW.md b/docs/sql-manual/sql-statements/table-and-view/materialized-view/CREATE-ASYNC-MATERIALIZED-VIEW.md new file mode 100644 index 0000000000000..f48bc96aa37ad --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/materialized-view/CREATE-ASYNC-MATERIALIZED-VIEW.md @@ -0,0 +1,244 @@ +--- +{ +"title": "CREATE ASYNC MATERIALIZED VIEW", +"language": "en" +} +--- + + + +## Description + +This statement is used to create an asynchronous materialized view. + +#### syntax + +```sql +CREATE MATERIALIZED VIEW (IF NOT EXISTS)? mvName=multipartIdentifier + (LEFT_PAREN cols=simpleColumnDefs RIGHT_PAREN)? buildMode? + (REFRESH refreshMethod? refreshTrigger?)? + ((DUPLICATE)? KEY keys=identifierList)? + (COMMENT STRING_LITERAL)? + (PARTITION BY LEFT_PAREN mvPartition RIGHT_PAREN)? + (DISTRIBUTED BY (HASH hashKeys=identifierList | RANDOM) (BUCKETS (INTEGER_VALUE | AUTO))?)? + propertyClause? + AS query +``` + +#### illustrate + +##### simpleColumnDefs + +Used to define the materialized view column information, if not defined, it will be automatically derived + +```sql +simpleColumnDefs +: cols+=simpleColumnDef (COMMA cols+=simpleColumnDef)* + ; + +simpleColumnDef +: colName=identifier (COMMENT comment=STRING_LITERAL)? + ; +``` + +For example, define two columns aa and bb, where the annotation for aa is "name" +```sql +CREATE MATERIALIZED VIEW mv1 +(aa comment "name",bb) +``` + +##### buildMode + +Used to define whether the materialized view is refreshed immediately after creation, default to IMMEDIATE + +IMMEDIATE: Refresh Now + +DEFERRED: Delay refresh + +```sql +buildMode +: BUILD (IMMEDIATE | DEFERRED) +; +``` + +For example, specifying the materialized view to refresh immediately + +```sql +CREATE MATERIALIZED VIEW mv1 +BUILD IMMEDIATE +``` + +##### refreshMethod + +Used to define the refresh method for materialized views, default to AUTO + +COMPLETE: Full refresh + +AUTO: Try to refresh incrementally as much as possible. If incremental refresh is not possible, refresh in full + +The SQL definition and partition fields of the materialized view need to meet the following conditions for partition incremental updates: + +- At least one of the base tables used by the materialized view is a partitioned table. +- The base tables used by the materialized view must use list or range partitioning strategies. +- The `partition by` clause in the SQL definition of the materialized view can only have one partitioning column. +- The partitioning column specified in the `partition by` clause of the materialized view's SQL must come after the `SELECT` statement. +- If the materialized view's SQL includes a `group by` clause, the columns used for partitioning must come after the `group by` clause. +- If the materialized view's SQL includes window functions, the columns used for partitioning must come after the `partition by` clause. +- Data changes should occur on partitioned tables. If data changes occur on non-partitioned tables, the materialized view needs to be fully rebuilt. +- If a field from the null-generating side of a join is used as a partitioning column for the materialized view, it cannot be incrementally updated by partition. For example, for a LEFT OUTER JOIN, the partitioning column must be on the left side, not the right. + + +```sql +refreshMethod +: COMPLETE | AUTO +; +``` + +For example, specifying full refresh of materialized views +```sql +CREATE MATERIALIZED VIEW mv1 +REFRESH COMPLETE +``` + +##### refreshTrigger + +Trigger method for refreshing data in materialized views, default to MANUAL + +MANUAL: Manual refresh + +SCHEDULE: Timed refresh + +COMMIT: Trigger-based refresh. When the base table data changes, a task to refresh the materialized view is automatically generated. + +```sql +refreshTrigger +: ON MANUAL +| ON SCHEDULE refreshSchedule +| ON COMMIT +; + +refreshSchedule +: EVERY INTEGER_VALUE mvRefreshUnit (STARTS STRING_LITERAL)? +; + +mvRefreshUnit +: MINUTE | HOUR | DAY | WEEK +; +``` + +For example: executed every 2 hours, starting from 21:07:09 on December 13, 2023 +```sql +CREATE MATERIALIZED VIEW mv1 +REFRESH ON SCHEDULE EVERY 2 HOUR STARTS "2023-12-13 21:07:09" +``` + +##### key +The materialized view is the DUPLICATE KEY model, therefore the specified columns are arranged in sequence + +```sql +identifierList +: LEFT_PAREN identifierSeq RIGHT_PAREN + ; + +identifierSeq +: ident+=errorCapturingIdentifier (COMMA ident+=errorCapturingIdentifier)* +; +``` + +For example, specifying k1 and k2 as sorting sequences +```sql +CREATE MATERIALIZED VIEW mv1 +KEY(k1,k2) +``` + +##### partition +There are two types of partitioning methods for materialized views. If no partitioning is specified, there will be a default single partition. If a partitioning field is specified, the system will automatically deduce the source base table of that field and synchronize all partitions of the base table (currently supporting `OlapTable` and `hive`). (Limitation: If the base table is an `OlapTable`, it can only have one partition field) + +For example, if the base table is a range partition with a partition field of `create_time` and partitioning by day, and `partition by(ct) as select create_time as ct from t1` is specified when creating a materialized view, +then the materialized view will also be a range partition with a partition field of 'ct' and partitioning by day + +Materialized views can also reduce the number of partitions by using partition roll-up. Currently, the partition roll-up function supports `date_trunc`, and the roll-up units supported are `year`, `month`, and `day`. + +The selection of partition fields and the definition of materialized views must meet the conditions for partition incremental updates for the materialized view to be created successfully; otherwise, an error "Unable to find a suitable base table for partitioning" will occur. + +```sql +mvPartition + : partitionKey = identifier + | partitionExpr = functionCallExpression + ; +``` + +For example, if the base table is partitioned by day, the materialized view is also partitioned by day. +```sql +partition by (`k2`) +``` + +For example, if the base table is partitioned by day, the materialized view is partitioned by month. +```sql +partition by (date_trunc(`k2`,'month')) +``` + +#### property +The materialized view can specify both the properties of the table and the properties unique to the materialized view. + +The properties unique to materialized views include: + +`grace_period`: When performing query rewrites, there is a maximum allowed delay time (measured in seconds) for the data of the materialized view. If there is a discrepancy between the data of partition A and the base table, and the last refresh time of partition A of the materialized view was 1, while the current system time is 2, then this partition will not undergo transparent rewriting. However, if the grace_period is greater than or equal to 1, this partition will be used for transparent rewriting. + +`excluded_trigger_tables`: Table names ignored during data refresh, separated by commas. For example, ` table1, table2` + +`refresh_partition_num`: The number of partitions refreshed by a single insert statement is set to 1 by default. When refreshing a materialized view, the system first calculates the list of partitions to be refreshed and then splits it into multiple insert statements that are executed in sequence according to this configuration. If any insert statement fails, the entire task will stop executing. The materialized view ensures the transactionality of individual insert statements, meaning that failed insert statements will not affect partitions that have already been successfully refreshed. + +`workload_group`: The name of the workload_group used by the materialized view when performing refresh tasks. This is used to limit the resources used for refreshing data in the materialized view, in order to avoid affecting the operation of other business processes. For details on how to create and use workload_group, refer to [WORKLOAD-GROUP](../../../../admin-manual/workload-group.md) + +`query`: Create a query statement for the materialized view, and the result is the data in the materialized view + +`enable_nondeterministic_function`: Whether the SQL definition of the materialized view allows containing nondeterministic +functions, such as current_date(), now(), random(), etc. If true, they are allowed; otherwise, they are not allowed. +By default, they are not allowed. + +## Example + +1. Create a materialized view mv1 that refreshes immediately and then once a week, with the data source being the hive catalog + + ```sql + CREATE MATERIALIZED VIEW mv1 BUILD IMMEDIATE REFRESH COMPLETE ON SCHEDULE EVERY 1 WEEK + DISTRIBUTED BY RANDOM BUCKETS 2 + PROPERTIES ( + "replication_num" = "1" + ) + AS SELECT * FROM hive_catalog.db1.user; + ``` + +2. Create a materialized view with multiple table joins + + ```sql + CREATE MATERIALIZED VIEW mv1 BUILD IMMEDIATE REFRESH COMPLETE ON SCHEDULE EVERY 1 WEEK + DISTRIBUTED BY RANDOM BUCKETS 2 + PROPERTIES ( + "replication_num" = "1" + ) + AS select user.k1,user.k3,com.k4 from user join com on user.k1=com.k1; + ``` + +## Keywords + + CREATE, ASYNC, MATERIALIZED, VIEW + diff --git a/docs/sql-manual/sql-statements/table-and-view/materialized-view/CREATE-MATERIALIZED-VIEW.md b/docs/sql-manual/sql-statements/table-and-view/materialized-view/CREATE-MATERIALIZED-VIEW.md new file mode 100644 index 0000000000000..954cde79a2323 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/materialized-view/CREATE-MATERIALIZED-VIEW.md @@ -0,0 +1,230 @@ +--- +{ + "title": "CREATE MATERIALIZED VIEW", + "language": "en" +} +--- + + + + +## Description + +This statement is used to create a materialized view. + +This operation is an asynchronous operation. After the submission is successful, you need to view the job progress through [SHOW ALTER TABLE MATERIALIZED VIEW](./SHOW-ALTER-TABLE-MATERIALIZED-VIEW). After displaying FINISHED, you can use the `desc [table_name] all` command to view the schema of the materialized view. + +grammar: + +```sql +CREATE MATERIALIZED VIEW < MV name > as < query > +[PROPERTIES ("key" = "value")] +``` + +illustrate: + +- `MV name`: The name of the materialized view, required. Materialized view names for the same table cannot be repeated. + +- `query`: The query statement used to construct the materialized view, the result of the query statement is the data of the materialized view. Currently supported query formats are: + + ```sql + SELECT select_expr[, select_expr ...] + FROM [Base view name] + GROUP BY column_name[, column_name ...] + ORDER BY column_name[, column_name ...] + ``` + + The syntax is the same as the query syntax. + + - `select_expr`: All columns in the schema of the materialized view. + - Contains at least one single column. + - `base view name`: The original table name of the materialized view, required. + - Must be a single table and not a subquery + - `group by`: The grouping column of the materialized view, optional. + - If not filled, the data will not be grouped. + - `order by`: the sorting column of the materialized view, optional. + - The declaration order of the sort column must be the same as the column declaration order in select_expr. + - If order by is not declared, the sorting column is automatically supplemented according to the rules. If the materialized view is an aggregate type, all grouping columns are automatically supplemented as sort columns. If the materialized view is of a non-aggregate type, the first 36 bytes are automatically supplemented as the sort column. + - If the number of auto-supplemented sorts is less than 3, the first three are used as the sort sequence. If query contains a grouping column, the sorting column must be the same as the grouping column. + +- properties + + Declare some configuration of the materialized view, optional. + + ```text + PROPERTIES ("key" = "value", "key" = "value" ...) + ``` + + The following configurations can be declared here: + + ```text + short_key: The number of sorting columns. + timeout: The timeout for materialized view construction. + ``` + +## Example + +Base table structure is + +```sql +mysql> desc duplicate_table; ++-------+--------+------+------+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++-------+--------+------+------+---------+-------+ +| k1 | INT | Yes | true | N/A | | +| k2 | INT | Yes | true | N/A | | +| k3 | BIGINT | Yes | true | N/A | | +| k4 | BIGINT | Yes | true | N/A | | ++-------+--------+------+------+---------+-------+ +``` +```sql +create table duplicate_table( + k1 int null, + k2 int null, + k3 bigint null, + k4 bigint null +) +duplicate key (k1,k2,k3,k4) +distributed BY hash(k4) buckets 3 +properties("replication_num" = "1"); +``` +attention: If the materialized view contains partitioned and distributed columns of the Base table, these columns must be used as key columns in the materialized view + +1. Create a materialized view that contains only the columns of the original table (k1, k2) + + ```sql + create materialized view k2_k1 as + select k2, k1 from duplicate_table; + ``` + + The schema of the materialized view is as follows, the materialized view contains only two columns k1, k2 without any aggregation + + ```text + +-------+-------+--------+------+------+ ---------+-------+ + | IndexName | Field | Type | Null | Key | Default | Extra | + +-------+-------+--------+------+------+ ---------+-------+ + | k2_k1 | k2 | INT | Yes | true | N/A | | + | | k1 | INT | Yes | true | N/A | | + +-------+-------+--------+------+------+ ---------+-------+ + ``` + +2. Create a materialized view with k2 as the sort column + + ```sql + create materialized view k2_order as + select k2, k1 from duplicate_table order by k2; + ``` + + The schema of the materialized view is shown in the figure below. The materialized view contains only two columns k2, k1, where k2 is the sorting column without any aggregation. + + ```text + +-------+-------+--------+------+------- +---------+-------+ + | IndexName | Field | Type | Null | Key | Default | Extra | + +-------+-------+--------+------+------- +---------+-------+ + | k2_order | k2 | INT | Yes | true | N/A | | + | | k1 | INT | Yes | false | N/A | NONE | + +-------+-------+--------+------+------- +---------+-------+ + ``` + +3. Create a materialized view with k1, k2 grouping and k3 column aggregated by SUM + + ```sql + create materialized view k1_k2_sumk3 as + select k1, k2, sum(k3) from duplicate_table group by k1, k2; + ``` + + The schema of the materialized view is shown in the figure below. The materialized view contains two columns k1, k2, sum(k3) where k1, k2 are the grouping columns, and sum(k3) is the sum value of the k3 column grouped by k1, k2. + + Since the materialized view does not declare a sorting column, and the materialized view has aggregated data, the system defaults to supplement the grouping columns k1 and k2 as sorting columns. + + ```text + +-------+-------+--------+------+------- +---------+-------+ + | IndexName | Field | Type | Null | Key | Default | Extra | + +-------+-------+--------+------+------- +---------+-------+ + | k1_k2_sumk3 | k1 | INT | Yes | true | N/A | | + | | k2 | INT | Yes | true | N/A | | + | | k3 | BIGINT | Yes | false | N/A | SUM | + +-------+-------+--------+------+------- +---------+-------+ + ``` + +4. Create a materialized view that removes duplicate rows + + ```sql + create materialized view deduplicate as + select k1, k2, k3, k4 from duplicate_table group by k1, k2, k3, k4; + ``` + + The materialized view schema is as shown below. The materialized view contains columns k1, k2, k3, and k4, and there are no duplicate rows. + + ```text + +-------+-------+--------+------+------- +---------+-------+ + | IndexName | Field | Type | Null | Key | Default | Extra | + +-------+-------+--------+------+------- +---------+-------+ + | deduplicate | k1 | INT | Yes | true | N/A | | + | | k2 | INT | Yes | true | N/A | | + | | k3 | BIGINT | Yes | true | N/A | | + | | k4 | BIGINT | Yes | true | N/A | | + +-------+-------+--------+------+------- +---------+-------+ + ``` + +5. Create a non-aggregate materialized view that does not declare a sort column + + The schema of all_type_table is as follows + + ``` + +-------+--------------+------+-------+---------+- ------+ + | Field | Type | Null | Key | Default | Extra | + +-------+--------------+------+-------+---------+- ------+ + | k1 | TINYINT | Yes | true | N/A | | + | k2 | SMALLINT | Yes | true | N/A | | + | k3 | INT | Yes | true | N/A | | + | k4 | BIGINT | Yes | true | N/A | | + | k5 | DECIMAL(9,0) | Yes | true | N/A | | + | k6 | DOUBLE | Yes | false | N/A | NONE | + | k7 | VARCHAR(20) | Yes | false | N/A | NONE | + +-------+--------------+------+-------+---------+- ------+ + ``` + + The materialized view contains k3, k4, k5, k6, k7 columns, and does not declare a sort column, the creation statement is as follows: + + ```sql + create materialized view mv_1 as + select k3, k4, k5, k6, k7 from all_type_table; + ``` + + The default added sorting column of the system is k3, k4, k5 three columns. The sum of the bytes of these three column types is 4(INT) + 8(BIGINT) + 16(DECIMAL) = 28 < 36. So the addition is that these three columns are used as sorting columns. The schema of the materialized view is as follows, you can see that the key field of the k3, k4, k5 columns is true, that is, the sorting column. The key field of the k6, k7 columns is false, which is a non-sorted column. + + ```sql + +----------------+-------+--------------+------+-- -----+---------+-------+ + | IndexName | Field | Type | Null | Key | Default | Extra | + +----------------+-------+--------------+------+-- -----+---------+-------+ + | mv_1 | k3 | INT | Yes | true | N/A | | + | | k4 | BIGINT | Yes | true | N/A | | + | | k5 | DECIMAL(9,0) | Yes | true | N/A | | + | | k6 | DOUBLE | Yes | false | N/A | NONE | + | | k7 | VARCHAR(20) | Yes | false | N/A | NONE | + +----------------+-------+--------------+------+-- -----+---------+-------+ + ``` + +## Keywords + + CREATE, MATERIALIZED, VIEW + +## Best Practice diff --git a/docs/sql-manual/sql-statements/table-and-view/materialized-view/DROP-ASYNC-MATERIALIZED-VIEW.md b/docs/sql-manual/sql-statements/table-and-view/materialized-view/DROP-ASYNC-MATERIALIZED-VIEW.md new file mode 100644 index 0000000000000..906b1f52f396b --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/materialized-view/DROP-ASYNC-MATERIALIZED-VIEW.md @@ -0,0 +1,63 @@ +--- +{ + "title": "DROP ASYNC MATERIALIZED VIEW", + "language": "en" +} +--- + + + + +## Description + +This statement is used to delete asynchronous materialized views. + +syntax: + +```sql +DROP MATERIALIZED VIEW (IF EXISTS)? mvName=multipartIdentifier +``` + + +1. IF EXISTS: + If the materialized view does not exist, do not throw an error. If this keyword is not declared and the materialized view does not exist, an error will be reported. + +2. mv_name: + The name of the materialized view to be deleted. Required field. + +## Example + +1. Delete table materialized view mv1 + +```sql +DROP MATERIALIZED VIEW mv1; +``` +2.If present, delete the materialized view of the specified database + +```sql +DROP MATERIALIZED VIEW IF EXISTS db1.mv1; +``` + +## Keywords + + DROP, ASYNC, MATERIALIZED, VIEW + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/materialized-view/DROP-MATERIALIZED-VIEW.md b/docs/sql-manual/sql-statements/table-and-view/materialized-view/DROP-MATERIALIZED-VIEW.md new file mode 100644 index 0000000000000..3d1b302c4bdd7 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/materialized-view/DROP-MATERIALIZED-VIEW.md @@ -0,0 +1,113 @@ +--- +{ + "title": "DROP MATERIALIZED VIEW", + "language": "en" +} +--- + + + +## Description + +This statement is used to drop a materialized view. Synchronous syntax + +grammar: + +```sql +DROP MATERIALIZED VIEW [IF EXISTS] mv_name ON table_name; +``` + + +1. IF EXISTS: + Do not throw an error if the materialized view does not exist. If this keyword is not declared, an error will be reported if the materialized view does not exist. + +2. mv_name: + The name of the materialized view to delete. Required. + +3. table_name: + The name of the table to which the materialized view to be deleted belongs. Required. + +## Example + +The table structure is + +```sql +mysql> desc all_type_table all; ++----------------+-------+----------+------+------ -+---------+-------+ +| IndexName | Field | Type | Null | Key | Default | Extra | ++----------------+-------+----------+------+------ -+---------+-------+ +| all_type_table | k1 | TINYINT | Yes | true | N/A | | +| | k2 | SMALLINT | Yes | false | N/A | NONE | +| | k3 | INT | Yes | false | N/A | NONE | +| | k4 | BIGINT | Yes | false | N/A | NONE | +| | k5 | LARGEINT | Yes | false | N/A | NONE | +| | k6 | FLOAT | Yes | false | N/A | NONE | +| | k7 | DOUBLE | Yes | false | N/A | NONE | +| | | | | | | | | +| k1_sumk2 | k1 | TINYINT | Yes | true | N/A | | +| | k2 | SMALLINT | Yes | false | N/A | SUM | ++----------------+-------+----------+------+------ -+---------+-------+ +``` + +1. Drop the materialized view named k1_sumk2 of the table all_type_table + + ```sql + drop materialized view k1_sumk2 on all_type_table; + ``` + + The table structure after the materialized view is deleted + + ```text + +----------------+-------+----------+------+------ -+---------+-------+ + | IndexName | Field | Type | Null | Key | Default | Extra | + +----------------+-------+----------+------+------ -+---------+-------+ + | all_type_table | k1 | TINYINT | Yes | true | N/A | | + | | k2 | SMALLINT | Yes | false | N/A | NONE | + | | k3 | INT | Yes | false | N/A | NONE | + | | k4 | BIGINT | Yes | false | N/A | NONE | + | | k5 | LARGEINT | Yes | false | N/A | NONE | + | | k6 | FLOAT | Yes | false | N/A | NONE | + | | k7 | DOUBLE | Yes | false | N/A | NONE | + +----------------+-------+----------+------+------ -+---------+-------+ + ``` + +2. Drop a non-existent materialized view in the table all_type_table + + ```sql + drop materialized view k1_k2 on all_type_table; + ERROR 1064 (HY000): errCode = 2, detailMessage = Materialized view [k1_k2] does not exist in table [all_type_table] + ``` + + The delete request reports an error directly + +3. Delete the materialized view k1_k2 in the table all_type_table, if it does not exist, no error will be reported. + + ```sql + drop materialized view if exists k1_k2 on all_type_table; + Query OK, 0 rows affected (0.00 sec) + ``` + + If it exists, delete it, if it does not exist, no error is reported. + +## Keywords + + DROP, MATERIALIZED, VIEW + +## Best Practice diff --git a/docs/sql-manual/sql-statements/table-and-view/materialized-view/PAUSE-MATERIALIZED-VIEW-JOB.md b/docs/sql-manual/sql-statements/table-and-view/materialized-view/PAUSE-MATERIALIZED-VIEW-JOB.md new file mode 100644 index 0000000000000..1c119c03cebca --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/materialized-view/PAUSE-MATERIALIZED-VIEW-JOB.md @@ -0,0 +1,51 @@ +--- +{ + "title": "PAUSE MATERIALIZED VIEW JOB", + "language": "en" +} +--- + + + + +## Description + +This statement is used to pause the scheduled scheduling of materialized views + +syntax: + +```sql +PAUSE MATERIALIZED VIEW JOB ON mvName=multipartIdentifier +``` + +## Example + +1. Pause scheduled scheduling of materialized view mv1 + + ```sql + PAUSE MATERIALIZED VIEW JOB ON mv1; + ``` + +## Keywords + + PAUSE, MATERIALIZED, VIEW + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/materialized-view/REFRESH-MATERIALIZED-VIEW.md b/docs/sql-manual/sql-statements/table-and-view/materialized-view/REFRESH-MATERIALIZED-VIEW.md new file mode 100644 index 0000000000000..2bdb4e90445c8 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/materialized-view/REFRESH-MATERIALIZED-VIEW.md @@ -0,0 +1,71 @@ +--- +{ + "title": "REFRESH MATERIALIZED VIEW", + "language": "en" +} +--- + + + + +## Description + +This statement is used to manually refresh the specified asynchronous materialized view + +syntax: + +```sql +REFRESH MATERIALIZED VIEW mvName=multipartIdentifier (partitionSpec | COMPLETE | AUTO) +``` + +Explanation: + +Asynchronous refresh of data for a materialized view + +- AUTO: The calculation will determine which partitions of the materialized view are not synchronized with the base table. (Currently, if the base table is an external table, it is considered to be always synchronized with the materialized view. Therefore, if the base table is an external table, it is necessary to specify `COMPLETE` or designate the partitions to be refreshed), and then proceed to refresh the corresponding partitions accordingly. +- COMPLETE: It will forcibly refresh all partitions of the materialized view without checking whether the partitions are synchronized with the base table. +- partitionSpec: It will forcibly refresh the specified partitions without checking whether the partitions are synchronized with the base table. + +## Example + +1. Refresh materialized view mv1 (automatically calculate the partition to be refreshed) + + ```sql + REFRESH MATERIALIZED VIEW mv1 AUTO; + ``` + +2. Refresh partition named p_19950801_19950901 和 p_19950901_19951001 + + ```sql + REFRESH MATERIALIZED VIEW mv1 partitions(p_19950801_19950901,p_19950901_19951001); + ``` + +3. Force refresh of all materialized view data + + ```sql + REFRESH MATERIALIZED VIEW mv1 complete; + ``` + +## Keywords + + REFRESH, MATERIALIZED, VIEW + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/materialized-view/RESUME-MATERIALIZED-VIEW-JOB.md b/docs/sql-manual/sql-statements/table-and-view/materialized-view/RESUME-MATERIALIZED-VIEW-JOB.md new file mode 100644 index 0000000000000..bd18146158eaa --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/materialized-view/RESUME-MATERIALIZED-VIEW-JOB.md @@ -0,0 +1,50 @@ +--- +{ + "title": "RESUME MATERIALIZED VIEW", + "language": "en" +} +--- + + + +## Description + +This statement is used to temporarily restore the scheduled scheduling of materialized views + +syntax: + +```sql +RESUME MATERIALIZED VIEW JOB ON mvName=multipartIdentifier +``` + +## Example + +1. Timed scheduling for restoring materialized view mv1 + + ```sql + RESUME MATERIALIZED VIEW JOB ON mv1; + ``` + +## Keywords + + RESUME, MATERIALIZED, VIEW + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/materialized-view/SHOW-ALTER-TABLE-MATERIALIZED-VIEW.md b/docs/sql-manual/sql-statements/table-and-view/materialized-view/SHOW-ALTER-TABLE-MATERIALIZED-VIEW.md new file mode 100644 index 0000000000000..606bca984c6ca --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/materialized-view/SHOW-ALTER-TABLE-MATERIALIZED-VIEW.md @@ -0,0 +1,115 @@ +--- +{ + "title": "SHOW ALTER TABLE MATERIALIZED VIEW", + "language": "en" +} +--- + + + + +## Description + +This command is used to view the execution of the Create Materialized View job submitted through the [CREATE-MATERIALIZED-VIEW](../../table-and-view/materialized-view/CREATE-MATERIALIZED-VIEW.md) statement. + +> This statement is equivalent to `SHOW ALTER TABLE ROLLUP`; + +```sql +SHOW ALTER TABLE MATERIALIZED VIEW +[FROM database] +[WHERE] +[ORDER BY] +[LIMIT OFFSET] +``` + +- database: View jobs under the specified database. If not specified, the current database is used. +- WHERE: You can filter the result column, currently only the following columns are supported: + - TableName: Only equal value filtering is supported. + - State: Only supports equivalent filtering. + - Createtime/FinishTime: Support =, >=, <=, >, <, != +- ORDER BY: The result set can be sorted by any column. +- LIMIT: Use ORDER BY to perform page-turning query. + +Return result description: + +```sql +mysql> show alter table materialized view\G +**************************** 1. row ******************** ****** + JobId: 11001 + TableName: tbl1 + CreateTime: 2020-12-23 10:41:00 + FinishTime: NULL + BaseIndexName: tbl1 +RollupIndexName: r1 + RollupId: 11002 + TransactionId: 5070 + State: WAITING_TXN + Msg: + Progress: NULL + Timeout: 86400 +1 row in set (0.00 sec) +``` + +- `JobId`: Job unique ID. + +- `TableName`: base table name + +- `CreateTime/FinishTime`: Job creation time and end time. + +- `BaseIndexName/RollupIndexName`: Base table name and materialized view name. + +- `RollupId`: The unique ID of the materialized view. + +- `TransactionId`: See the description of the State field. + +- `State`: job status. + + - PENDING: The job is in preparation. + + - WAITING_TXN: + + Before officially starting to generate materialized view data, it will wait for the current running import transaction on this table to complete. And the `TransactionId` field is the current waiting transaction ID. When all previous imports for this ID are complete, the job will actually start. + + - RUNNING: The job is running. + + - FINISHED: The job ran successfully. + + - CANCELLED: The job failed to run. + +- `Msg`: error message + +- `Progress`: job progress. The progress here means `completed tablets/total tablets`. Materialized views are created at tablet granularity. + +- `Timeout`: Job timeout, in seconds. + +## Example + +1. View the materialized view jobs under the database example_db + + ```sql + SHOW ALTER TABLE MATERIALIZED VIEW FROM example_db; + ``` + +## Keywords + + SHOW, ALTER, TABLE, MATERIALIZED, VIEW + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/materialized-view/SHOW-CREATE-ASYNC-MATERIALIZED-VIEW.md b/docs/sql-manual/sql-statements/table-and-view/materialized-view/SHOW-CREATE-ASYNC-MATERIALIZED-VIEW.md new file mode 100644 index 0000000000000..b6f459ddfda02 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/materialized-view/SHOW-CREATE-ASYNC-MATERIALIZED-VIEW.md @@ -0,0 +1,56 @@ +--- +{ + "title": "SHOW CREATE ASYNC MATERIALIZED VIEW", + "language": "en" +} +--- + + + + +## Description + +This statement is used to display the creation statement of asynchronous materialized views. + +grammar: + +```sql +SHOW CREATE MATERIALIZED VIEW [DBNAME.]MV_NAME +``` + +illustrate: + +1. `DBNAMNE` : 数据库名称 +2. `MV_NAME` : 异步物化视图的名称 + +## Example + +1. View the creation statement of mv1 + + ```sql + SHOW CREATE MATERIALIZED VIEW mv1; + ``` + +## Keywords + + SHOW, CREATE, MATERIALIZED, VIEW, ASYNC + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/materialized-view/SHOW-CREATE-MATERIALIZED-VIEW.md b/docs/sql-manual/sql-statements/table-and-view/materialized-view/SHOW-CREATE-MATERIALIZED-VIEW.md new file mode 100644 index 0000000000000..4a8615fda2c8a --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/materialized-view/SHOW-CREATE-MATERIALIZED-VIEW.md @@ -0,0 +1,68 @@ +--- +{ + "title": "SHOW CREATE MATERIALIZED VIEW", + "language": "en" +} +--- + + + +## Description + +This statement is used to query statements that create materialized views. + +grammar: + +```sql +SHOW CREATE MATERIALIZED VIEW mv_name ON table_name +``` + +1. mv_name: + Materialized view name. required. + +2. table_name: + The table name of materialized view. required. + +## Example + +Create materialized view + +```sql +create materialized view id_col1 as select id,col1 from table3; +``` + +Return after query + +```sql +mysql> show create materialized view id_col1 on table3; ++-----------+----------+----------------------------------------------------------------+ +| TableName | ViewName | CreateStmt | ++-----------+----------+----------------------------------------------------------------+ +| table3 | id_col1 | create materialized view id_col1 as select id,col1 from table3 | ++-----------+----------+----------------------------------------------------------------+ +1 row in set (0.00 sec) +``` + +## Keywords + + SHOW, MATERIALIZED, VIEW + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/table/ALTER-COLOCATE-GROUP.md b/docs/sql-manual/sql-statements/table-and-view/table/ALTER-COLOCATE-GROUP.md new file mode 100644 index 0000000000000..7649abd28bbc9 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/ALTER-COLOCATE-GROUP.md @@ -0,0 +1,79 @@ +--- +{ +"title": "ALTER COLOCATE GROUP", +"language": "en" +} +--- + + + + + + +## Description + +This statement is used to modify the colocation group. + +Syntax: + +```sql +ALTER COLOCATE GROUP [database.]group +SET ( + property_list +); +``` + +NOTE: + +1. If the colocate group is global, that is, its name starts with `__global__`, then it does not belong to any database; + +2. property_list is a colocation group attribute, currently only supports modifying `replication_num` and `replication_allocation`. After modifying these two attributes of the colocation group, at the same time, change the attribute `default.replication_allocation`, the attribute `dynamic.replication_allocation` of the table of the group, and the `replication_allocation` of the existing partition to be the same as it. + +## Example + +1. Modify the number of copies of a global group + + ```sql + # Set "colocate_with" = "__global__foo" when creating the table + + ALTER COLOCATE GROUP __global__foo + SET ( + "replication_num"="1" + ); + ``` + +2. Modify the number of copies of a non-global group + + ```sql + # Set "colocate_with" = "bar" when creating the table, and the Database is "example_db" + + ALTER COLOCATE GROUP example_db.bar + SET ( + "replication_num"="1" + ); + ``` + +## Keywords + +```sql +ALTER, COLOCATE, GROUP +``` + +## Best Practice diff --git a/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-AND-GENERATED-COLUMN.md b/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-AND-GENERATED-COLUMN.md new file mode 100644 index 0000000000000..202020b69b8ed --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-AND-GENERATED-COLUMN.md @@ -0,0 +1,63 @@ +--- +{ + "title": "ALTER TABLE AND GENERATED COLUMN", + "language": "en" +} +--- + + + + +The ALTER TABLE ADD COLUMN is not supported for adding a generated column, and the ALTER TABLE MODIFY COLUMN is not supported for modifying generated column information. +The ALTER TABLE syntax is supported for modifying the order of generated columns, modifying the names of generated columns, and deleting generated columns. + +The following error is reported for unsupported scenarios: + +```sql +mysql> CREATE TABLE test_alter_add_column(a int, b int) properties("replication_num"="1"); +Query OK, 0 rows affected (0.14 sec) +mysql> ALTER TABLE test_alter_add_column ADD COLUMN c int AS (a+b); +ERROR 1105 (HY000): errCode = 2, detailMessage = Not supporting alter table add generated columns. +mysql> ALTER TABLE test_alter MODIFY COLUMN c int KEY AS (a+b+1); +ERROR 1105 (HY000): errCode = 2, detailMessage = Not supporting alter table modify generated columns. +``` + +### REORDER COLUMN + +```sql +ALTER TABLE products ORDER BY (product_id, total_value, price, quantity); +``` + +Note: +The modified column order still needs to meet the order restrictions when generating columns and creating tables. +### RENAME COLUMN + +```sql +ALTER TABLE products RENAME COLUMN total_value new_name; +``` + +Note: +If a column in a table (generated column or common column) is referenced by other generated columns, you need to delete the other generated columns before you can modify the name of this generated column. +### DROP COLUMN + +```sql +ALTER TABLE products DROP COLUMN total_value; +``` + +Note: +If a column in a table (generated column or ordinary column) is referenced by other generated columns, you need to delete the other generated columns first before deleting the referenced generated column or ordinary column. diff --git a/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-COLUMN.md b/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-COLUMN.md new file mode 100644 index 0000000000000..1b230a38ad909 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-COLUMN.md @@ -0,0 +1,306 @@ +--- +{ + "title": "ALTER TABLE COLUMN", + "language": "en" +} +--- + + + + +## Description + +This statement is used to perform a schema change operation on an existing table. The schema change is asynchronous, and the task is returned when the task is submitted successfully. After that, you can use the [SHOW ALTER TABLE COLUMN](../../../../sql-manual/sql-statements/table-and-view/table/SHOW-ALTER-TABLE) command to view the progress. + +Doris has the concept of materialized index after table construction. After successful table construction, it is the base table and the materialized index is the base index. rollup index can be created based on the base table. Both base index and rollup index are materialized indexes. If rollup_index_name is not specified during the schema change operation, the operation is based on the base table by default. + +:::tip +Doris 1.2.0 supports light schema change for light scale structure changes, and addition and subtraction operations for value columns can be completed more quickly and synchronously. You can manually specify "light_schema_change" = 'true' when creating a table. This parameter is enabled by default for versions 2.0.0 and later. +::: + +### Grammar: + +```sql +ALTER TABLE [database.]table alter_clause; +``` + +The alter_clause of schema change supports the following modification methods: + +**1. Add a column to the specified position at the specified index** + +**Grammar** + +```sql +ALTER TABLE [database.]table table_name ADD COLUMN column_name column_type [KEY | agg_type] [DEFAULT "default_value"] +[AFTER column_name|FIRST] +[TO rollup_index_name] +[PROPERTIES ("key"="value", ...)] +``` + +**Example** + +1. Add a key column new_col to example_db.my_table after key_1 (non-aggregated model) + + ```sql + ALTER TABLE example_db.my_table + ADD COLUMN new_col INT KEY DEFAULT "0" AFTER key_1; + ``` + +2. Add a value column new_col to example_db.my_table after value_1 (non-aggregate model) + + ```sql + ALTER TABLE example_db.my_table + ADD COLUMN new_col INT DEFAULT "0" AFTER value_1; + ``` + +3. Add a key column new_col (aggregate model) to example_db.my_table after key_1 + + ```sql + ALTER TABLE example_db.my_table + ADD COLUMN new_col INT KEY DEFAULT "0" AFTER key_1; + ``` + +4. Add a value column to example_db.my_table after value_1 new_col SUM Aggregation type (aggregation model) + + ```sql + ALTER TABLE example_db.my_table + ADD COLUMN new_col INT SUM DEFAULT "0" AFTER value_1; + ``` + +5. Add new_col to the first column position of the example_db.my_table table (non-aggregated model) + + ```sql + ALTER TABLE example_db.my_table + ADD COLUMN new_col INT KEY DEFAULT "0" FIRST; + ``` + +:::tip +- If you add a value column to the aggregation model, you need to specify agg_type +- For non-aggregated models (such as DUPLICATE KEY), if you add a key column, you need to specify the KEY keyword +- You cannot add columns that already exist in the base index to the rollup index (you can recreate a rollup index if necessary) +::: + + +**2. Add multiple columns to the specified index** + +**Grammar** + +```sql +ALTER TABLE [database.]table table_name ADD COLUMN (column_name1 column_type [KEY | agg_type] DEFAULT "default_value", ...) +[TO rollup_index_name] +[PROPERTIES ("key"="value", ...)] +``` + + +**Example** + +1. Add multiple columns to example_db.my_table, where new_col and new_col2 are SUM aggregate types (aggregate model) + + ```sql + ALTER TABLE example_db.my_table + ADD COLUMN (new_col1 INT SUM DEFAULT "0" ,new_col2 INT SUM DEFAULT "0"); + ``` + +2. Add multiple columns to example_db.my_table (non-aggregated model), where new_col1 is the KEY column and new_col2 is the value column + + ```sql + ALTER TABLE example_db.my_table + ADD COLUMN (new_col1 INT key DEFAULT "0" , new_col2 INT DEFAULT "0"); + ``` + +:::tip + - If you add a value column to the aggregation model, you need to specify agg_type + - If you add a key column to the aggregation model, you need to specify the KEY keyword + - You cannot add columns that already exist in the base index to the rollup index (you can recreate a rollup index if necessary) +::: + +**3. Delete a column from the specified index** + +**Grammar*** + + ```sql + ALTER TABLE [database.]table table_name DROP COLUMN column_name + [FROM rollup_index_name] + ``` + +**Example** + +1. Delete column col1 from example_db.my_table + + ```sql + ALTER TABLE example_db.my_table DROP COLUMN col1; + ``` + +:::tip + - Cannot drop partition column + - The aggregate model cannot delete KEY columns + - If the column is removed from the base index, it will also be removed if it is included in the rollup index +::: + +**4. Modify the column type and column position of the specified index** + +**Grammar** + +```sql +ALTER TABLE [database.]table table_name MODIFY COLUMN column_name column_type [KEY | agg_type] [NULL | NOT NULL] [DEFAULT "default_value"] +[AFTER column_name|FIRST] +[FROM rollup_index_name] +[PROPERTIES ("key"="value", ...)] +``` + +**Example** + +1. Modify the type of the key column col1 of the base index to BIGINT and move it to the back of the col2 column + + ```sql + ALTER TABLE example_db.my_table + MODIFY COLUMN col1 BIGINT KEY DEFAULT "1" AFTER col2; + ``` + + :::tip + Whether you modify the key column or the value column, you need to declare complete column information + ::: + +2. Modify the maximum length of the val1 column of base index. The original val1 is (val1 VARCHAR(32) REPLACE DEFAULT "abc") + + ```sql + ALTER TABLE example_db.my_table + MODIFY COLUMN val1 VARCHAR(64) REPLACE DEFAULT "abc"; + ``` + + :::tip + You can only modify the column's data type; other attributes of the column must remain unchanged. + ::: + +3. Modify the length of a field in the Key column of the Duplicate key table + + ```sql + ALTER TABLE example_db.my_table + MODIFY COLUMN k3 VARCHAR(50) KEY NULL COMMENT 'to 50'; + ``` + +:::tip + - If you modify the value column in the aggregation model, you need to specify agg_type + - If you modify the key column for non-aggregate types, you need to specify the KEY keyword + - Only the type of the column can be modified, and other attributes of the column remain as they are (that is, other attributes need to be explicitly written in the statement according to the original attributes, see example 8) + - Partitioning and bucketing columns cannot be modified in any way + - The following types of conversions are currently supported (loss of precision is guaranteed by the user) + - Conversion of TINYINT/SMALLINT/INT/BIGINT/LARGEINT/FLOAT/DOUBLE types to larger numeric types + - Convert TINTINT/SMALLINT/INT/BIGINT/LARGEINT/FLOAT/DOUBLE/DECIMAL to VARCHAR + - VARCHAR supports modifying the maximum length + - VARCHAR/CHAR converted to TINTINT/SMALLINT/INT/BIGINT/LARGEINT/FLOAT/DOUBLE + - Convert VARCHAR/CHAR to DATE (currently supports "%Y-%m-%d", "%y-%m-%d", "%Y%m%d", "%y%m%d", "%Y/%m/%d, "%y/%m/%d" six formats) + - Convert DATETIME to DATE (only keep year-month-day information, for example: `2019-12-09 21:47:05` <--> `2019-12-09`) + - DATE is converted to DATETIME (hours, minutes and seconds are automatically filled with zeros, for example: `2019-12-09` <--> `2019-12-09 00:00:00`) + - Convert FLOAT to DOUBLE + - INT is converted to DATE (if the INT type data is illegal, the conversion fails, and the original data remains unchanged) + - All can be converted to STRING except DATE and DATETIME, but STRING cannot be converted to any other type +::: + +**5. Reorder the column at the specified index** + +**Grammar** + + ```sql + ALTER TABLE [database.]table table_name ORDER BY (column_name1, column_name2, ...) + [FROM rollup_index_name] + [PROPERTIES ("key"="value", ...)] + ``` + +**Example** + +1. Adjust the order of the key and value columns of example_db.my_table (non-aggregate model) + + ```sql + CREATE TABLE `my_table`( + `k_1` INT NULL, + `k_2` INT NULL, + `v_1` INT NULL, + `v_2` varchar NULL, + `v_3` varchar NULL + ) ENGINE=OLAP + DUPLICATE KEY(`k_1`, `k_2`) + COMMENT 'OLAP' + DISTRIBUTED BY HASH(`k_1`) BUCKETS 5 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + ); + + ALTER TABLE example_db.my_table ORDER BY (k_2,k_1,v_3,v_2,v_1); + + mysql> desc my_table; + +-------+------------+------+-------+---------+-------+ + | Field | Type | Null | Key | Default | Extra | + +-------+------------+------+-------+---------+-------+ + | k_2 | INT | Yes | true | NULL | | + | k_1 | INT | Yes | true | NULL | | + | v_3 | VARCHAR(*) | Yes | false | NULL | NONE | + | v_2 | VARCHAR(*) | Yes | false | NULL | NONE | + | v_1 | INT | Yes | false | NULL | NONE | + +-------+------------+------+-------+---------+-------+ + ``` + +2. Do two actions simultaneously + + ```sql + CREATE TABLE `my_table` ( + `k_1` INT NULL, + `k_2` INT NULL, + `v_1` INT NULL, + `v_2` varchar NULL, + `v_3` varchar NULL + ) ENGINE=OLAP + DUPLICATE KEY(`k_1`, `k_2`) + COMMENT 'OLAP' + DISTRIBUTED BY HASH(`k_1`) BUCKETS 5 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + ); + + ALTER TABLE example_db.my_table + ADD COLUMN col INT DEFAULT "0" AFTER v_1, + ORDER BY (k_2,k_1,v_3,v_2,v_1,col); + + mysql> desc my_table; + +-------+------------+------+-------+---------+-------+ + | Field | Type | Null | Key | Default | Extra | + +-------+------------+------+-------+---------+-------+ + | k_2 | INT | Yes | true | NULL | | + | k_1 | INT | Yes | true | NULL | | + | v_3 | VARCHAR(*) | Yes | false | NULL | NONE | + | v_2 | VARCHAR(*) | Yes | false | NULL | NONE | + | v_1 | INT | Yes | false | NULL | NONE | + | col | INT | Yes | false | 0 | NONE | + +-------+------------+------+-------+---------+-------+ + ``` + +:::tip + - All columns in index are written out + - the value column comes after the key column + - You can adjust the key column only within the range of the key column. The same applies to the value column +::: + +## Keywords + +```text +ALTER, TABLE, COLUMN, ALTER TABLE +``` + +## Best Practice diff --git a/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-COMMENT.md b/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-COMMENT.md new file mode 100644 index 0000000000000..152a2a88041e4 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-COMMENT.md @@ -0,0 +1,77 @@ +--- +{ + "title": "ALTER TABLE COMMENT", + "language": "en" +} +--- + + + + + + +## Description + +This statement is used to modify the comment of an existing table. The operation is synchronous, and the command returns to indicate completion. + +grammar: + +```sql +ALTER TABLE [database.]table alter_clause; +``` + +1. Modify table comment + +grammar: + +```sql +MODIFY COMMENT "new table comment"; +``` + +2. Modify column comment + +grammar: + +```sql +MODIFY COLUMN col1 COMMENT "new column comment"; +``` + +## Example + +1. Change the table1's comment to table1_comment + +```sql +ALTER TABLE table1 MODIFY COMMENT "table1_comment"; +``` + +2. Change the table1's col1 comment to table1_comment + +```sql +ALTER TABLE table1 MODIFY COLUMN col1 COMMENT "table1_col1_comment"; +``` + +## Keywords + +```text +ALTER, TABLE, COMMENT, ALTER TABLE +``` + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-PARTITION.md b/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-PARTITION.md new file mode 100644 index 0000000000000..fb4562e4051b4 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-PARTITION.md @@ -0,0 +1,174 @@ +--- +{ + "title": "ALTER TABLE PARTITION", + "language": "en" +} + +--- + + + + + + +## Description + +This statement is used to modify a table with a partition. + +This operation is synchronous, and the return of the command indicates the completion of the execution. + +grammar: + +```sql +ALTER TABLE [database.]table alter_clause; +``` + +The alter_clause of partition supports the following modification methods + +1. Add partition + +grammar: + +```sql +ADD PARTITION [IF NOT EXISTS] partition_name +partition_desc ["key"="value"] +[DISTRIBUTED BY HASH (k1[,k2 ...]) [BUCKETS num]] +``` + +Notice: + +- partition_desc supports the following two ways of writing + - VALUES LESS THAN [MAXVALUE|("value1", ...)] + - VALUES [("value1", ...), ("value1", ...)) +- The partition is left closed and right open. If the user only specifies the right boundary, the system will automatically determine the left boundary +- If the bucketing method is not specified, the bucketing method and bucket number used for creating the table would be automatically used +- If the bucketing method is specified, only the number of buckets can be modified, not the bucketing method or the bucketing column. If the bucketing method is specified but the number of buckets not be specified, the default value `10` will be used for bucket number instead of the number specified when the table is created. If the number of buckets modified, the bucketing method needs to be specified simultaneously. +- The ["key"="value"] section can set some attributes of the partition, see [CREATE TABLE](../Create/CREATE-TABLE.md) +- If the user does not explicitly create a partition when creating a table, adding a partition by ALTER is not supported +- If the user uses list partition then they can add default partition to the table. The default partition will store all data not satisfying prior partition key's constraints. + - ALTER TABLE table_name ADD PARTITION partition_name + +2. Delete the partition + +grammar: + +```sql +DROP PARTITION [IF EXISTS] partition_name [FORCE] +``` + + Notice: + +- At least one partition must be reserved for tables using partitioning. +- After executing DROP PARTITION for a period of time, the deleted partition can be recovered through the RECOVER statement. For details, see SQL Manual - Database Management - RECOVER Statement +- If you execute DROP PARTITION FORCE, the system will not check whether there are unfinished transactions in the partition, the partition will be deleted directly and cannot be recovered, this operation is generally not recommended + +3. Modify the partition properties + + grammar: + +```sql +MODIFY PARTITION p1|(p1[, p2, ...]) SET ("key" = "value", ...) +``` + +illustrate: + +- Currently supports modifying the following properties of partitions: + - storage_medium + -storage_cooldown_time + - replication_num + - in_memory +- For single-partition tables, partition_name is the same as the table name. + +## Example + +1. Add partition, existing partition [MIN, 2013-01-01), add partition [2013-01-01, 2014-01-01), use default bucketing method + +```sql +ALTER TABLE example_db.my_table +ADD PARTITION p1 VALUES LESS THAN ("2014-01-01"); +``` + +2. Increase the partition and use the new number of buckets + +```sql +ALTER TABLE example_db.my_table +ADD PARTITION p1 VALUES LESS THAN ("2015-01-01") +DISTRIBUTED BY HASH(k1) BUCKETS 20; +``` + +3. Increase the partition and use the new number of replicas + +```sql +ALTER TABLE example_db.my_table +ADD PARTITION p1 VALUES LESS THAN ("2015-01-01") +("replication_num"="1"); +``` + +4. Modify the number of partition replicas + +```sql +ALTER TABLE example_db.my_table +MODIFY PARTITION p1 SET("replication_num"="1"); +``` + +5. Batch modify the specified partition + +```sql +ALTER TABLE example_db.my_table +MODIFY PARTITION (p1, p2, p4) SET("replication_num"="1"); +``` + +6. Batch modify all partitions + +```sql +ALTER TABLE example_db.my_table +MODIFY PARTITION (*) SET("storage_medium"="HDD"); +``` + +7. Delete partition + +```sql +ALTER TABLE example_db.my_table +DROP PARTITION p1; +``` + +8. Batch delete partition + +```sql +ALTER TABLE example_db.my_table +DROP PARTITION p1, +DROP PARTITION p2, +DROP PARTITION p3; +``` + +9. Add a partition specifying upper and lower bounds + +```sql +ALTER TABLE example_db.my_table +ADD PARTITION p1 VALUES [("2014-01-01"), ("2014-02-01")); +``` + +## Keywords + +```text +ALTER, TABLE, PARTITION, ALTER TABLE +``` + +## Best Practice \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-PROPERTY.md b/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-PROPERTY.md new file mode 100644 index 0000000000000..ef17c91b6e517 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-PROPERTY.md @@ -0,0 +1,291 @@ +--- +{ + "title": "ALTER TABLE PROPERTY", + "language": "en" +} +--- + + + + + + +:::caution +Differences between Partition Attributes and Table Attributes +- Partition attributes generally focus on the number of buckets (buckets), storage medium (storage_medium), replication num (replication_num), and hot/cold data separation policies (storage_policy). + - For existing partitions, you can use ALTER TABLE {tableName} MODIFY PARTITION ({partitionName}) SET ({key}={value}) to modify them, but the number of buckets (buckets) cannot be changed. + - For not-created dynamic partitions, you can use ALTER TABLE {tableName} SET (dynamic_partition.{key} = {value}) to modify their attributes. + - For not-created auto partitions, you can use ALTER TABLE {tableName} SET ({key} = {value}) to modify their attributes. + - If users want to modify partition attributes, they need to modify the attributes of the already created partitions, as well as the attributes of not-created partitions. +- Aside from the above attributes, all others are at the table level. +- For the specific attributes, please refer to [create table attributes](../../../../sql-manual/sql-statements/table-and-view/table/CREATE-TABLE.md#properties) +::: + +## Description + +This statement is used to modify the properties of an existing table. This operation is synchronous, and the return of the command indicates the completion of the execution. + +Modify the properties of the table, currently supports modifying the bloom filter column, the colocate_with attribute and the dynamic_partition attribute, the replication_num and default.replication_num. + +grammar: + +```sql +ALTER TABLE [database.]table alter_clause; +``` + +The alter_clause of property supports the following modification methods. + +Note: + +Can also be merged into the above schema change operation to modify, see the example below + +1. Modify the bloom filter column of the table + +```sql +ALTER TABLE example_db.my_table SET ("bloom_filter_columns"="k1,k2,k3"); +``` + +Can also be incorporated into the schema change operation above (note that the syntax for multiple clauses is slightly different) + +```sql +ALTER TABLE example_db.my_table +DROP COLUMN col2 +PROPERTIES ("bloom_filter_columns"="k1,k2,k3"); +``` + +2. Modify the Colocate property of the table + +```sql +ALTER TABLE example_db.my_table set ("colocate_with" = "t1"); +``` + +3. Change the bucketing method of the table from Hash Distribution to Random Distribution + +```sql +ALTER TABLE example_db.my_table set ("distribution_type" = "random"); +``` + +4. Modify the dynamic partition attribute of the table (support adding dynamic partition attribute to the table without dynamic partition attribute) + +```sql +ALTER TABLE example_db.my_table set ("dynamic_partition.enable" = "false"); +``` + +If you need to add dynamic partition attributes to tables without dynamic partition attributes, you need to specify all dynamic partition attributes + (Note: adding dynamic partition attributes is not supported for non-partitioned tables) + +```sql +ALTER TABLE example_db.my_table set ( + "dynamic_partition.enable" = "true", + "dynamic_partition.time_unit" = "DAY", + "dynamic_partition.end" = "3", + "dynamic_partition.prefix" = "p", + "dynamic_partition. buckets" = "32" +); +``` + +5. Modify the in_memory attribute of the table, only can set value 'false' + +```sql +ALTER TABLE example_db.my_table set ("in_memory" = "false"); +``` + +6. Enable batch delete function + +```sql +ALTER TABLE example_db.my_table ENABLE FEATURE "BATCH_DELETE"; +``` + +Note: + +- Only support unique tables +- Batch deletion is supported for old tables, while new tables are already supported when they are created + +7. Enable the function of ensuring the import order according to the value of the sequence column + +```sql +ALTER TABLE example_db.my_table ENABLE FEATURE "SEQUENCE_LOAD" WITH PROPERTIES ( + "function_column.sequence_type" = "Date" +); +``` + +Note: + +- Only support unique tables +- The sequence_type is used to specify the type of the sequence column, which can be integral and time type +- Only the orderliness of newly imported data is supported. Historical data cannot be changed + +8. Change the default number of buckets for the table to 50 + +```sql +ALTER TABLE example_db.my_table MODIFY DISTRIBUTION DISTRIBUTED BY HASH(k1) BUCKETS 50; +``` + +Note: + +- Only support non colocate table with RANGE partition and HASH distribution + +9. Modify table comments + +```sql +ALTER TABLE example_db.my_table MODIFY COMMENT "new comment"; +``` + +10. Modify column comments + +```sql +ALTER TABLE example_db.my_table MODIFY COLUMN k1 COMMENT "k1", MODIFY COLUMN k2 COMMENT "k2"; +``` + +11. Modify the engine type + +Only the MySQL type can be changed to the ODBC type. The value of driver is the name of the driver in the odbc.init configuration. + +```sql +ALTER TABLE example_db.mysql_table MODIFY ENGINE TO odbc PROPERTIES("driver" = "MySQL"); +``` + +12. Modify the number of copies + +```sql +ALTER TABLE example_db.mysql_table SET ("replication_num" = "2"); +ALTER TABLE example_db.mysql_table SET ("default.replication_num" = "2"); +ALTER TABLE example_db.mysql_table SET ("replication_allocation" = "tag.location.default: 1"); +ALTER TABLE example_db.mysql_table SET ("default.replication_allocation" = "tag.location.default: 1"); +``` + +Note: +1. The property with the default prefix indicates the default replica distribution for the modified table. This modification does not modify the current actual replica distribution of the table, but only affects the replica distribution of newly created partitions on the partitioned table. +2. For non-partitioned tables, modifying the replica distribution property without the default prefix will modify both the default replica distribution and the actual replica distribution of the table. That is, after the modification, through the `show create table` and `show partitions from tbl` statements, you can see that the replica distribution has been modified. +changed. +3. For partitioned tables, the actual replica distribution of the table is at the partition level, that is, each partition has its own replica distribution, which can be viewed through the `show partitions from tbl` statement. If you want to modify the actual replica distribution, see `ALTER TABLE PARTITION`. + +13\. **[Experimental]** turn on `light_schema_change` + + For tables that were not created with light_schema_change enabled, you can enable it by using the following statement. + +```sql +ALTER TABLE example_db.mysql_table SET ("light_schema_change" = "true"); +``` + +## Example + +1. Modify the bloom filter column of the table + +```sql +ALTER TABLE example_db.my_table SET ("bloom_filter_columns"="k1,k2,k3"); +``` + +Can also be incorporated into the schema change operation above (note that the syntax for multiple clauses is slightly different) + +```sql +ALTER TABLE example_db.my_table +DROP COLUMN col2 +PROPERTIES ("bloom_filter_columns"="k1,k2,k3"); +``` + +2. Modify the Colocate property of the table + +```sql +ALTER TABLE example_db.my_table set ("colocate_with" = "t1"); +``` + +3. Change the bucketing method of the table from Hash Distribution to Random Distribution + +```sql +ALTER TABLE example_db.my_table set ("distribution_type" = "random"); +``` + +4. Modify the dynamic partition attribute of the table (support adding dynamic partition attribute to the table without dynamic partition attribute) + +```sql +ALTER TABLE example_db.my_table set ("dynamic_partition.enable" = "false"); +``` + +If you need to add dynamic partition attributes to tables without dynamic partition attributes, you need to specify all dynamic partition attributes + (Note: adding dynamic partition attributes is not supported for non-partitioned tables) + +```sql +ALTER TABLE example_db.my_table set ("dynamic_partition.enable" = "true", "dynamic_partition.time_unit" = "DAY", "dynamic_partition.end" = "3", "dynamic_partition.prefix" = "p", "dynamic_partition. buckets" = "32"); +``` + +5. Modify the in_memory attribute of the table, only can set value 'false' + +```sql +ALTER TABLE example_db.my_table set ("in_memory" = "false"); +``` + +6. Enable batch delete function + +```sql +ALTER TABLE example_db.my_table ENABLE FEATURE "BATCH_DELETE"; +``` + +7. Enable the function of ensuring the import order according to the value of the sequence column + +```sql +ALTER TABLE example_db.my_table ENABLE FEATURE "SEQUENCE_LOAD" WITH PROPERTIES ("function_column.sequence_type" = "Date"); +``` + +8. Change the default number of buckets for the table to 50 + +```sql +ALTER TABLE example_db.my_table MODIFY DISTRIBUTION DISTRIBUTED BY HASH(k1) BUCKETS 50; +``` + +9. Modify table comments + +```sql +ALTER TABLE example_db.my_table MODIFY COMMENT "new comment"; +``` + +10. Modify column comments + +```sql +ALTER TABLE example_db.my_table MODIFY COLUMN k1 COMMENT "k1", MODIFY COLUMN k2 COMMENT "k2"; +``` + +11. Modify the engine type + +```sql +ALTER TABLE example_db.mysql_table MODIFY ENGINE TO odbc PROPERTIES("driver" = "MySQL"); +``` + +12. Add a cold and hot separation data migration strategy to the table +```sql + ALTER TABLE create_table_not_have_policy set ("storage_policy" = "created_create_table_alter_policy"); +``` +NOTE: The table can be successfully added only if it hasn't been associated with a storage policy. A table just can have one storage policy. + +13. Add a hot and cold data migration strategy to the partition of the table +```sql +ALTER TABLE create_table_partition MODIFY PARTITION (*) SET("storage_policy"="created_create_table_partition_alter_policy"); +``` +NOTE: The table's partition can be successfully added only if it hasn't been associated with a storage policy. A table just can have one storage policy. + + +## Keywords + +```text +ALTER, TABLE, PROPERTY, ALTER TABLE +``` + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-RENAME.md b/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-RENAME.md new file mode 100644 index 0000000000000..6403dc12705f4 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-RENAME.md @@ -0,0 +1,120 @@ +--- +{ + "title": "ALTER TABLE RENAME", + "language": "en" +} + +--- + + + + + +## Description + +This statement is used to rename certain names of existing table properties. This operation is synchronous, and the return of the command indicates the completion of the execution. + +grammar: + +```sql +ALTER TABLE [database.]table alter_clause; +``` + +The alter_clause of rename supports modification of the following names + +1. Modify the table name + +grammar: + +```sql +RENAME new_table_name; +``` + +2. Modify the rollup index name + + grammar: + +```sql +RENAME ROLLUP old_rollup_name new_rollup_name; +``` + +3. Modify the partition name + +grammar: + +```sql +RENAME PARTITION old_partition_name new_partition_name; +``` + +4. Modify the column name + +:::tip Tips +This feature is supported since the Apache Doris 1.2 version +::: + +Modify the column name + + + +grammar: + +```sql +RENAME COLUMN old_column_name new_column_name; +``` + +Notice: + +- When creating a table, you need to set 'light_schema_change=true' in the property. + + +## Example + +1. Modify the table named table1 to table2 + +```sql +ALTER TABLE table1 RENAME table2; +``` + +2. Modify the rollup index named rollup1 in the table example_table to rollup2 + +```sql +ALTER TABLE example_table RENAME ROLLUP rollup1 rollup2; +``` + +3. Modify the partition named p1 in the table example_table to p2 + +```sql +ALTER TABLE example_table RENAME PARTITION p1 p2; +``` + +4. Modify the column named c1 in the table example_table to c2 + +```sql +ALTER TABLE example_table RENAME COLUMN c1 c2; +``` + +## Keywords + +```text +ALTER, TABLE, RENAME, ALTER TABLE +``` + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-REPLACE.md b/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-REPLACE.md new file mode 100644 index 0000000000000..9e4eab96f7278 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-REPLACE.md @@ -0,0 +1,93 @@ +--- +{ + "title": "ALTER TABLE REPLACE", + "language": "en" +} +--- + + + + + +## Description + +Atomic substitution of two tables. This operation applies only to OLAP tables. + +```sql +ALTER TABLE [db.]tbl1 REPLACE WITH TABLE tbl2 +[PROPERTIES('swap' = 'true')]; +``` + +Replace table tbl1 with table tbl2. + +If the `swap` parameter is `true`, the data in the table named `tbl1` will be the data in the original table named `tbl2` after the replacement. The data in the table named `tbl2` is the data in the original `tbl1` table. That is, two tables of data have been swapped. + +If the `swap` parameter is `false`, the data in the `tbl1` table will be the data in the `tbl2` table after the replacement. The table named `tbl2` is deleted. + +#### Theory + +The replace table function actually turns the following set of operations into an atomic operation. + +If you want to replace table A with table B and `swap` is `true`, do the following: + +1. Rename table B as table A. +2. Rename table A as table B. + +If `swap` is `false`, do as follows: + +1. Delete table A. +2. Rename table B as table A. + +#### Notice +1. The default `swap` parameter is `true`. That is, a table replacement operation is equivalent to an exchange of data between two tables. +2. If the `swap` parameter is set to false, the replaced table (table A) will be deleted and cannot be restored. +3. The replacement operation can only occur between two OLAP tables and does not check whether the table structure of the two tables is consistent. +4. The original permission Settings are not changed. Because the permission check is based on the table name. + +## Example + +1. Atomic swap `tbl1` with `tbl2` without dropping any tables(Note: if you delete it, you actually delete tbl1 and rename tbl2 to tbl1.) + +```sql +ALTER TABLE tbl1 REPLACE WITH TABLE tbl2; +``` +or +```sql +ALTER TABLE tbl1 REPLACE WITH TABLE tbl2 PROPERTIES('swap' = 'true'); +``` + +2. Atomic swap `tbl1` with `tbl2` and deleting the `tbl2` table(Keep `tbl1` and the data of the original `tbl2`) + +```sql +ALTER TABLE tbl1 REPLACE WITH TABLE tbl2 PROPERTIES('swap' = 'false'); +``` + + + +## Keywords + +```text +ALTER, TABLE, REPLACE, ALTER TABLE +``` + +## Best Practice +1. Atomic overlay write operations + + In some cases, the user wants to be able to rewrite the data of a certain table, but if the data is deleted first and then imported, the data cannot be viewed for a period of time in between. At this time, the user can first use the `CREATE TABLE LIKE` statement to create a new table with the same structure, import the new data into the new table, and use the replacement operation to atomically replace the old table to achieve the goal. Atomic overwrite write operations at the partition level, see [temp partition documentation](../../../../advanced/partition/table-temp-partition.md). diff --git a/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-ROLLUP.md b/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-ROLLUP.md new file mode 100644 index 0000000000000..a42aa1a8b707a --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-ROLLUP.md @@ -0,0 +1,136 @@ +--- +{ + "title": "ALTER TABLE ROLLUP", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to perform a rollup modification operation on an existing table. The rollup is an asynchronous operation, and the task is returned when the task is submitted successfully. After that, you can use the [SHOW ALTER](../../../../sql-manual/sql-statements/table-and-view/table/SHOW-ALTER-TABLE) command to view the progress. + +grammar: + +```sql +ALTER TABLE [database.]table alter_clause; +``` + +The alter_clause of rollup supports the following creation methods + +1. Create a rollup index + +grammar: + +```sql +ADD ROLLUP rollup_name (column_name1, column_name2, ...) +[FROM from_index_name] +[PROPERTIES ("key"="value", ...)] +``` + +properties: Support setting timeout time, the default timeout time is 1 day. + +2. Create rollup indexes in batches + +grammar: + +```sql +ADD ROLLUP [rollup_name (column_name1, column_name2, ...) + [FROM from_index_name] + [PROPERTIES ("key"="value", ...)],...] +``` + +Notice: + +- If from_index_name is not specified, it will be created from base index by default +- Columns in rollup table must be columns already in from_index +- In properties, the storage format can be specified. For details, see [CREATE TABLE](../Create/CREATE-TABLE.md) + +3. Delete rollup index + + grammar: + +```sql +DROP ROLLUP rollup_name [PROPERTIES ("key"="value", ...)] +``` + +4. Batch delete rollup index + +grammar: + +```sql +DROP ROLLUP [rollup_name [PROPERTIES ("key"="value", ...)],...] +``` + +Notice: + +- cannot delete base index + +## Example + +1. Create index: example_rollup_index, based on base index (k1,k2,k3,v1,v2). Columnar storage. + +```sql +ALTER TABLE example_db.my_table +ADD ROLLUP example_rollup_index(k1, k3, v1, v2); +``` + +2. Create index: example_rollup_index2, based on example_rollup_index (k1,k3,v1,v2) + +```sql +ALTER TABLE example_db.my_table +ADD ROLLUP example_rollup_index2 (k1, v1) +FROM example_rollup_index; +``` + +3. Create index: example_rollup_index3, based on base index (k1,k2,k3,v1), with a custom rollup timeout of one hour. + +```sql +ALTER TABLE example_db.my_table +ADD ROLLUP example_rollup_index(k1, k3, v1) +PROPERTIES("timeout" = "3600"); +``` + +4. Delete index: example_rollup_index2 + +```sql +ALTER TABLE example_db.my_table +DROP ROLLUP example_rollup_index2; +``` + +5. Batch Delete rollup index + +```sql +ALTER TABLE example_db.my_table +DROP ROLLUP example_rollup_index2,example_rollup_index3; +``` + +### + +4. Keywords + +```text +ALTER, TABLE, ROLLUP, ALTER TABLE +``` + +## Best Practice diff --git a/docs/sql-manual/sql-statements/table-and-view/table/CANCEL-ALTER-TABLE.md b/docs/sql-manual/sql-statements/table-and-view/table/CANCEL-ALTER-TABLE.md new file mode 100644 index 0000000000000..a735bbfa049c1 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/CANCEL-ALTER-TABLE.md @@ -0,0 +1,106 @@ +--- +{ + "title": "CANCEL ALTER TABLE", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to undo an ALTER operation. + +1. Undo the ALTER TABLE COLUMN operation + +grammar: + +```sql +CANCEL ALTER TABLE COLUMN +FROM db_name.table_name +``` + +2. Undo the ALTER TABLE ROLLUP operation + +grammar: + +```sql +CANCEL ALTER TABLE ROLLUP +FROM db_name.table_name +``` + +3. Batch cancel rollup operations based on job id + +grammar: + +```sql +CANCEL ALTER TABLE ROLLUP +FROM db_name.table_name (jobid,...) +``` + +Notice: + +- This command is an asynchronous operation. You need to use `show alter table rollup` to check the task status to confirm whether the execution is successful or not. + +4. Undo the ALTER CLUSTER operation + +grammar: + +``` +(To be implemented...) +``` + +## Example + +1. Undo the ALTER COLUMN operation on my_table. + + [CANCEL ALTER TABLE COLUMN] + +```sql +CANCEL ALTER TABLE COLUMN +FROM example_db.my_table; +``` + +1. Undo the ADD ROLLUP operation under my_table. + + [CANCEL ALTER TABLE ROLLUP] + +```sql +CANCEL ALTER TABLE ROLLUP +FROM example_db.my_table; +``` + +1. Undo the ADD ROLLUP operation under my_table according to the job id. + + [CANCEL ALTER TABLE ROLLUP] + +```sql +CANCEL ALTER TABLE ROLLUP +FROM example_db.my_table(12801,12802); +``` + +## Keywords + + CANCEL, ALTER, TABLE, CANCEL ALTER + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/table/CREATE-TABLE-AS-SELECT.md b/docs/sql-manual/sql-statements/table-and-view/table/CREATE-TABLE-AS-SELECT.md new file mode 100644 index 0000000000000..e612d51b373fe --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/CREATE-TABLE-AS-SELECT.md @@ -0,0 +1,105 @@ +--- +{ + "title": "CREATE TABLE AS SELECT", + "language": "en" +} + +--- + + + + + +## Description + +This statement creates the table structure by returning the results from the Select statement and imports the data at the same time + +grammar: + +```sql +CREATE TABLE table_name [( column_name_list )] + opt_engine:engineName + opt_keys:keys + opt_comment:tableComment + opt_partition:partition + opt_distribution:distribution + opt_rollup:index + opt_properties:tblProperties + opt_ext_properties:extProperties + KW_AS query_stmt:query_def +``` + +illustrate: + +- The user needs to have`SELECT`permission for the source table and`CREATE`permission for the target database +- After a table is created, data is imported. If the import fails, the table is deleted +- You can specify the key type. The default key type is `Duplicate Key` + +:::tip Tips +This feature is supported since the Apache Doris 1.2 version +::: + +- All columns of type string (varchar/var/string) are created as type "string". +- If the created source is an external table and the first column is of type String, the first column is automatically set to VARCHAR(65533). Because of Doris internal table, String column is not allowed as first column. + + + +## Example + +1. Using the field names in the SELECT statement + + ```sql + create table `test`.`select_varchar` + PROPERTIES("replication_num" = "1") + as select * from `test`.`varchar_table` + ``` + +2. Custom field names (need to match the number of fields returned) + + ```sql + create table `test`.`select_name`(user, testname, userstatus) + PROPERTIES("replication_num" = "1") + as select vt.userId, vt.username, jt.status + from `test`.`varchar_table` vt join + `test`.`join_table` jt on vt.userId=jt.userId + ``` + +3. Specify table model, partitions, and buckets + + ```sql + CREATE TABLE t_user(dt, id, name) + ENGINE=OLAP + UNIQUE KEY(dt, id) + COMMENT "OLAP" + PARTITION BY RANGE(dt) + ( + FROM ("2020-01-01") TO ("2021-12-31") INTERVAL 1 YEAR + ) + DISTRIBUTED BY HASH(id) BUCKETS 1 + PROPERTIES("replication_num"="1") + AS SELECT cast('2020-05-20' as date) as dt, 1 as id, 'Tom' as name; + ``` + +## Keywords + + CREATE, TABLE, AS, SELECT + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/table/CREATE-TABLE-LIKE.md b/docs/sql-manual/sql-statements/table-and-view/table/CREATE-TABLE-LIKE.md new file mode 100644 index 0000000000000..fb14dff315eba --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/CREATE-TABLE-LIKE.md @@ -0,0 +1,95 @@ +--- +{ + "title": "CREATE TABLE LIKE", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to create an empty table with the exact same table structure as another table, and can optionally replicate some rollups. + +grammar: + +```sql +CREATE [EXTERNAL] TABLE [IF NOT EXISTS] [database.]table_name LIKE [database.]table_name [WITH ROLLUP (r1,r2,r3,...)] +``` + +illustrate: + +- The copied table structure includes Column Definition, Partitions, Table Properties, etc. +- The user needs to have `SELECT` permission on the copied original table +- Support for copying external tables such as MySQL +- Support the rollup of copying OLAP Table + +## Example + +1. Create an empty table with the same table structure as table1 under the test1 library, the table name is table2 + + ```sql + CREATE TABLE test1.table2 LIKE test1.table1 + ``` + +2. Create an empty table with the same table structure as test1.table1 under the test2 library, the table name is table2 + + ```sql + CREATE TABLE test2.table2 LIKE test1.table1 + ``` + +3. Create an empty table with the same table structure as table1 under the test1 library, the table name is table2, and copy the two rollups of r1 and r2 of table1 at the same time + + ```sql + CREATE TABLE test1.table2 LIKE test1.table1 WITH ROLLUP (r1,r2) + ``` + +4. Create an empty table with the same table structure as table1 under the test1 library, the table name is table2, and copy all the rollups of table1 at the same time + + ```sql + CREATE TABLE test1.table2 LIKE test1.table1 WITH ROLLUP + ``` + +5. Create an empty table with the same table structure as test1.table1 under the test2 library, the table name is table2, and copy the two rollups of r1 and r2 of table1 at the same time + + ```sql + CREATE TABLE test2.table2 LIKE test1.table1 WITH ROLLUP (r1,r2) + ``` + +6. Create an empty table with the same table structure as test1.table1 under the test2 library, the table name is table2, and copy all the rollups of table1 at the same time + + ```sql + CREATE TABLE test2.table2 LIKE test1.table1 WITH ROLLUP + ``` + +7. Create an empty table under the test1 library with the same table structure as the MySQL outer table1, the table name is table2 + + ```sql + CREATE TABLE test1.table2 LIKE test1.table1 + ``` + +## Keywords + + CREATE, TABLE, LIKE + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/table/CREATE-TABLE.md b/docs/sql-manual/sql-statements/table-and-view/table/CREATE-TABLE.md new file mode 100644 index 0000000000000..16f4c3e5a31f9 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/CREATE-TABLE.md @@ -0,0 +1,877 @@ +--- +{ + "title": "CREATE TABLE", + "language": "en", + "toc_min_heading_level": 2, + "toc_max_heading_level": 4 +} + +--- + + + + + +## Description + +This command is used to create a table. The subject of this document describes the syntax for creating Doris self-maintained tables. + +```sql +CREATE TABLE [IF NOT EXISTS] [database.]table +( + column_definition_list + [, index_definition_list] +) +[engine_type] +[keys_type] +[table_comment] +[partition_info] +distribution_desc +[rollup_list] +[properties] +[extra_properties] +``` + +#### column_definition_list + +Column definition list: + +`column_definition[, column_definition]` + +* `column_definition` + + Column definition: + + `column_name column_type [KEY] [aggr_type] [NULL] [AUTO_INCREMENT(auto_inc_start_value)] [default_value] [on update current_timestamp] [column_comment]` + + * `column_type` + + Column type, the following types are supported: + + ``` + TINYINT (1 byte) + Range: -2^7 + 1 ~ 2^7-1 + SMALLINT (2 bytes) + Range: -2^15 + 1 ~ 2^15-1 + INT (4 bytes) + Range: -2^31 + 1 ~ 2^31-1 + BIGINT (8 bytes) + Range: -2^63 + 1 ~ 2^63-1 + LARGEINT (16 bytes) + Range: -2^127 + 1 ~ 2^127-1 + FLOAT (4 bytes) + Support scientific notation + DOUBLE (12 bytes) + Support scientific notation + DECIMAL[(precision, scale)] (16 bytes) + The decimal type with guaranteed precision. The default is DECIMAL(10, 0) + precision: 1 ~ 27 + scale: 0 ~ 9 + Where the integer part is 1 ~ 18 + Does not support scientific notation + DATE (3 bytes) + Range: 0000-01-01 ~ 9999-12-31 + DATETIME (8 bytes) + Range: 0000-01-01 00:00:00 ~ 9999-12-31 23:59:59 + CHAR[(length)] + Fixed-length character string. Length range: 1 ~ 255. Default is 1 + VARCHAR[(length)] + Variable length character string. Length range: 1 ~ 65533. Default is 65533 + HLL (1~16385 bytes) + HyperLogLog column type, do not need to specify the length and default value. The length is controlled within the system according to the degree of data aggregation. + Must be used with HLL_UNION aggregation type. + BITMAP + The bitmap column type does not need to specify the length and default value. Represents a collection of integers, and the maximum number of elements supported is 2^64-1. + Must be used with BITMAP_UNION aggregation type. + ``` + + * `aggr_type` + + Aggregation type, the following aggregation types are supported: + + ``` + SUM: Sum. Applicable numeric types. + MIN: Find the minimum value. Suitable for numeric types. + MAX: Find the maximum value. Suitable for numeric types. + REPLACE: Replace. For rows with the same dimension column, the index column will be imported in the order of import, and the last imported will replace the first imported. + REPLACE_IF_NOT_NULL: non-null value replacement. The difference with REPLACE is that there is no replacement for null values. It should be noted here that the default value should be NULL, not an empty string. If it is an empty string, you should replace it with an empty string. + HLL_UNION: The aggregation method of HLL type columns, aggregated by HyperLogLog algorithm. + BITMAP_UNION: The aggregation mode of BIMTAP type columns, which performs the union aggregation of bitmaps. + ``` + + * `AUTO_INCREMENT(auto_inc_start_value)` + + To indicate if the column is a auto-increment column. Auto-increment column can be used to generate a unique identity for new row. If no values are assgined for auto-increment column when inserting, Doris will generate sequence numbers automatically. You can also assign the auto-increment column with NULL literal to indicate Doris to generate sequence numbers. It should be noted that, for performance reasons, BE will cache some values of auto-increment column in memory. Therefore, the values generated by auto-increment column can only guarantee monotonicity and uniqueness, but not strict continuity. + A table can have at most one auto-incremnt column. The auto-increment column should be BIGINT type and be NOT NULL. + Both Duplicate model table and Unique model table support auto-increment column. + You can specify the starting value for an auto-increment column by providing `auto_inc_start_value. If not specified, the default starting value is 1. + + * `default_value` + + Default value of the column. If the load data does not specify a value for this column, the system will assign a default value to this column. + + The syntax is: `default default_value`. + + Currently, the default value supports two forms: + + 1. The user specifies a fixed value, such as: + + ```SQL + k1 INT DEFAULT '1', + k2 CHAR(10) DEFAULT 'aaaa' + ``` + + 2. Keywords are provided by the system. Currently, the following keywords are supported: + + ```SQL + // This keyword is used only for DATETIME type. If the value is missing, the system assigns the current timestamp. + dt DATETIME DEFAULT CURRENT_TIMESTAMP + ``` + + * `on update current_timestamp` + + To indicate that whether the value of this column should be updated to the current timestamp (`current_timestamp`) when there is an update on the row. The feature is only available on unique table with merge-on-write enabled. Columns with this feature enabled must declare a default value, and the default value must be `current_timestamp`. If the precision of the timestamp is declared here, the timestamp precision in the default value of the column must be the same as the precision declared here." + + Example: + + ``` + k1 TINYINT, + k2 DECIMAL(10,2) DEFAULT "10.5", + k4 BIGINT NULL DEFAULT "1000" COMMENT "This is column k4", + v1 VARCHAR(10) REPLACE NOT NULL, + v2 BITMAP BITMAP_UNION, + v3 HLL HLL_UNION, + v4 INT SUM NOT NULL DEFAULT "1" COMMENT "This is column v4" + dt datetime(6) default current_timestamp(6) on update current_timestamp(6) + ``` + +#### index_definition_list + +Index list definition: + +`index_definition[, index_definition]` + +* `index_definition` + + Index definition: + + ```sql + INDEX index_name (col_name) [USING INVERTED] COMMENT'xxxxxx' + ``` + + Example: + + ```sql + INDEX idx1 (k1) USING INVERTED COMMENT "This is a inverted index1", + INDEX idx2 (k2) USING INVERTED COMMENT "This is a inverted index2", + ... + ``` + +#### engine_type + +Table engine type. All types in this document are OLAP. Example: + + `ENGINE=olap` + +#### keys_type + +Data model. + +`key_type(col1, col2, ...)` + +`key_type` supports the following models: + +* DUPLICATE KEY (default): The subsequent specified column is the sorting column. +* AGGREGATE KEY: The specified column is the dimension column. +* UNIQUE KEY: The subsequent specified column is the primary key column. + +NOTE: when set table property `"enable_duplicate_without_keys_by_default" = "true"`, will create a duplicate model without sorting columns and prefix indexes by default. + +Example: + +``` +DUPLICATE KEY(col1, col2), +AGGREGATE KEY(k1, k2, k3), +UNIQUE KEY(k1, k2) +``` + +#### table_comment + +Table notes. Example: + + ``` + COMMENT "This is my first DORIS table" + ``` + +#### partition_info + +Partition information supports three writing methods: + +1. LESS THAN: Only define the upper boundary of the partition. The lower bound is determined by the upper bound of the previous partition. + + ``` + PARTITION BY RANGE(col1[, col2, ...]) + ( + PARTITION partition_name1 VALUES LESS THAN MAXVALUE|("value1", "value2", ...), + PARTITION partition_name2 VALUES LESS THAN MAXVALUE|("value1", "value2", ...) + ) + ``` + +2. FIXED RANGE: Define the left closed and right open interval of the zone. + + ``` + PARTITION BY RANGE(col1[, col2, ...]) + ( + PARTITION partition_name1 VALUES [("k1-lower1", "k2-lower1", "k3-lower1",...), ("k1-upper1", "k2-upper1", "k3-upper1", ... )), + PARTITION partition_name2 VALUES [("k1-lower1-2", "k2-lower1-2", ...), ("k1-upper1-2", MAXVALUE, )) + ) + ``` + + + +3. MULTI RANGE: Multi build RANGE partitions,Define the left closed and right open interval of the zone, Set the time unit and step size, the time unit supports year, month, day, week and hour. + +:::tip Tips +This feature is supported since the Apache Doris 1.2 version +::: + + ``` + PARTITION BY RANGE(col) + ( + FROM ("2000-11-14") TO ("2021-11-14") INTERVAL 1 YEAR, + FROM ("2021-11-14") TO ("2022-11-14") INTERVAL 1 MONTH, + FROM ("2022-11-14") TO ("2023-01-03") INTERVAL 1 WEEK, + FROM ("2023-01-03") TO ("2023-01-14") INTERVAL 1 DAY + ) + ``` + + + + +4. MULTI RANGE: Multi build integer RANGE partitions,Define the left closed and right open interval of the zone, and step size. + + ``` + PARTITION BY RANGE(int_col) + ( + FROM (1) TO (100) INTERVAL 10 + ) + ``` + +#### distribution_desc + +Define the data bucketing method. + +1. Hash + Syntax: + `DISTRIBUTED BY HASH (k1[,k2 ...]) [BUCKETS num|auto]` + Explain: + Hash bucketing using the specified key column. + +2. Random + Syntax: + `DISTRIBUTED BY RANDOM [BUCKETS num|auto]` + Explain: + Use random numbers for bucketing. + +#### rollup_list + +Multiple materialized views (ROLLUP) can be created at the same time as the table is built. + +`ROLLUP (rollup_definition[, rollup_definition, ...])` + +* `rollup_definition` + + `rollup_name (col1[, col2, ...]) [DUPLICATE KEY(col1[, col2, ...])] [PROPERTIES("key" = "value")]` + + Example: + + ``` + ROLLUP ( + r1 (k1, k3, v1, v2), + r2 (k1, v1) + ) + ``` + +#### properties + +Set table properties. The following attributes are currently supported: + +* `replication_num` + + Number of copies. The default number of copies is 3. If the number of BE nodes is less than 3, you need to specify that the number of copies is less than or equal to the number of BE nodes. + + After version 0.15, this attribute will be automatically converted to the `replication_allocation` attribute, such as: + + `"replication_num" = "3"` will be automatically converted to `"replication_allocation" = "tag.location.default:3"` + +* `replication_allocation` + + Set the copy distribution according to Tag. This attribute can completely cover the function of the `replication_num` attribute. + +* `min_load_replica_num` + + The minimum required successful replica num for loading data. The default value is `-1`. If set less than or equal to 0, loading data requires a majority replicas to succeed. + +* `is_being_synced` + + Used to identify whether this table is copied by CCR and is being synchronized by syncer. The default is `false`. + + If set to `true`: + `colocate_with`, `storage_policy` properties will be erased + `dynamic partition`, `auto bucket` features will be disabled, that is, they will be displayed as enabled in `show create table`, but will not actually take effect. When `is_being_synced` is set to `false`, these features will resume working. + + This property is for CCR peripheral modules only and should not be manually set during CCR synchronization. + +* `storage_medium/storage_cooldown_time` + + Data storage medium. `storage_medium` is used to declare the initial storage medium of the table data, and `storage_cooldown_time` is used to set the expiration time. Example: + + ``` + "storage_medium" = "SSD", + "storage_cooldown_time" = "2020-11-20 00:00:00" + ``` + + This example indicates that the data is stored in the SSD and will be automatically migrated to the HDD storage after the expiration of 2020-11-20 00:00:00. + +* `colocate_with` + + When you need to use the Colocation Join function, use this parameter to set the Colocation Group. + + `"colocate_with" = "group1"` + +* `bloom_filter_columns` + + The user specifies the list of column names that need to be added to the Bloom Filter index. The Bloom Filter index of each column is independent, not a composite index. + + `"bloom_filter_columns" = "k1, k2, k3"` + +* `in_memory` + + Deprecated. + +* `function_column.sequence_col` + + When using the UNIQUE KEY model, you can specify a sequence column. When the KEY columns are the same, REPLACE will be performed according to the sequence column (the larger value replaces the smaller value, otherwise it cannot be replaced) + + The `function_column.sequence_col` is used to specify the mapping of the sequence column to a column in the table, which can be integral and time (DATE, DATETIME). The type of this column cannot be changed after creation. If `function_column.sequence_col` is set, `function_column.sequence_type` is ignored. + + `"function_column.sequence_col" ='column_name'` + +* `function_column.sequence_type` + + When using the UNIQUE KEY model, you can specify a sequence column. When the KEY columns are the same, REPLACE will be performed according to the sequence column (the larger value replaces the smaller value, otherwise it cannot be replaced) + + Here we only need to specify the type of sequence column, support time type or integer type. Doris will create a hidden sequence column. + + `"function_column.sequence_type" ='Date'` + +* `compression` + + The default compression method for Doris tables is LZ4. After version 1.1, it is supported to specify the compression method as ZSTD to obtain a higher compression ratio. + + `"compression"="zstd"` + +* `enable_unique_key_merge_on_write` + + Wheather the unique table use merge-on-write implementation. + + The property is disabled by default before version 2.1 and is enabled by default since version 2.1. + +* `light_schema_change` + + Whether to use the Light Schema Change optimization. + + If set to true, the addition and deletion of value columns can be done more quickly and synchronously. + + `"light_schema_change"="true"` + + This feature is enabled by default after v2.0.0. + +* `disable_auto_compaction` + + Whether to disable automatic compaction for this table. + + If this property is set to 'true', the background automatic compaction process will skip all the tables of this table. + + `"disable_auto_compaction" = "false"` + +* `enable_single_replica_compaction` + + Whether to enable single replica compaction for this table. + + If this property is set to 'true', all replicas of the tablet will only have one replica performing compaction, while the others fetch rowsets from that replica. + + `"enable_single_replica_compaction" = "false"` + +* `enable_duplicate_without_keys_by_default` + + When `true`, if Unique, Aggregate, or Duplicate is not specified when creating a table, a Duplicate model table without sorting columns and prefix indexes will be created by default. + + `"enable_duplicate_without_keys_by_default" = "false"` + +* `skip_write_index_on_load` + + Whether to enable skip inverted index on load for this table. + + If this property is set to 'true', skip writting index (only inverted index now) on first time load and delay writting + index to compaction. It can reduce CPU and IO resource usage for high throughput load. + + `"skip_write_index_on_load" = "false"` + +* `compaction_policy` + + Configure the compaction strategy in the compression phase. Only support configuring the compaction policy as "time_series" or "size_based". + + time_series: When the disk size of a rowset accumulates to a certain threshold, version merging takes place. The merged rowset is directly promoted to the base compaction stage. This approach effectively reduces the write amplification rate of compaction, especially in scenarios with continuous imports in a time series context. + + In the case of time series compaction, the execution of compaction is adjusted using parameters that have the prefix time_series_compaction. + + `"compaction_policy" = ""` + +* `group_commit_interval_ms` + + Configures the group commit batch interval for this table. The unit is milliseconds, with a default value of 10000ms (10 seconds). + + The flushing timing of group commit depends on which value is reached first: `group_commit_interval_ms` or `group_commit_data_bytes`. + + `"group_commit_interval_ms" = "10000"` + +* `group_commit_data_bytes` + + Configures the group commit batch data size for this table. The unit is bytes, with a default value of 134217728 bytes (128MB). + + The flushing timing of group commit depends on which value is reached first: `group_commit_interval_ms` or `group_commit_data_bytes`. + + `"group_commit_data_bytes" = "134217728"` + +* `time_series_compaction_goal_size_mbytes` + + Time series compaction policy will utilize this parameter to adjust the size of input files for each compaction. The output file size will be approximately equal to the input file size. + + `"time_series_compaction_goal_size_mbytes" = "1024"` + +* `time_series_compaction_file_count_threshold` + + Time series compaction policy will utilize this parameter to adjust the minimum number of input files for each compaction. + + If the number of files in a tablet exceeds the configured threshold, it will trigger a compaction process. + + `"time_series_compaction_file_count_threshold" = "2000"` + +* `time_series_compaction_time_threshold_seconds` + + When time series compaction policy is applied, a significant duration passes without a compaction being executed, a compaction will be triggered. + + `"time_series_compaction_time_threshold_seconds" = "3600"` + +* `enable_mow_light_delete` + + If modify delete predicate for the DELETE statement on the unique merge-on-write table. If enabled, it will improve the performance of the DELETE statement, but errors may occur in partial column updates after deletion. If disabled, it will reduce the performance of the DELETE statement to ensure correctness. + + The default value for this property is false. + + This propertiy can only be enabled on unique merge-on-write tables. + + `"enable_mow_light_delete" = "true"` + +* Dynamic partition related + +References related to dynamic partitioning[Data Partitioning-Dynamic partitioning](../../../../table-design/data-partition.md#Dynamic partitioning) + + +## Example + +1. Create a detailed model table + + ```sql + CREATE TABLE example_db.table_hash + ( + k1 TINYINT, + k2 DECIMAL(10, 2) DEFAULT "10.5", + k3 CHAR(10) COMMENT "string column", + k4 INT NOT NULL DEFAULT "1" COMMENT "int column" + ) + COMMENT "my first table" + DISTRIBUTED BY HASH(k1) BUCKETS 32 + ``` + +2. Create a detailed model table, partition, specify the sorting column, and set the number of copies to 1 + + ```sql + CREATE TABLE example_db.table_hash + ( + k1 DATE, + k2 DECIMAL(10, 2) DEFAULT "10.5", + k3 CHAR(10) COMMENT "string column", + k4 INT NOT NULL DEFAULT "1" COMMENT "int column" + ) + DUPLICATE KEY(k1, k2) + COMMENT "my first table" + PARTITION BY RANGE(k1) + ( + PARTITION p1 VALUES LESS THAN ("2020-02-01"), + PARTITION p2 VALUES LESS THAN ("2020-03-01"), + PARTITION p3 VALUES LESS THAN ("2020-04-01") + ) + DISTRIBUTED BY HASH(k1) BUCKETS 32 + PROPERTIES ( + "replication_num" = "1" + ); + ``` + +3. Create a table with a unique model of the primary key, set the initial storage medium and cooling time + + ```sql + CREATE TABLE example_db.table_hash + ( + k1 BIGINT, + k2 LARGEINT, + v1 VARCHAR(2048), + v2 SMALLINT DEFAULT "10" + ) + UNIQUE KEY(k1, k2) + DISTRIBUTED BY HASH (k1, k2) BUCKETS 32 + PROPERTIES( + "storage_medium" = "SSD", + "storage_cooldown_time" = "2015-06-04 00:00:00" + ); + ``` + +4. Create an aggregate model table, using a fixed range partition description + + ```sql + CREATE TABLE table_range + ( + k1 DATE, + k2 INT, + k3 SMALLINT, + v1 VARCHAR(2048) REPLACE, + v2 INT SUM DEFAULT "1" + ) + AGGREGATE KEY(k1, k2, k3) + PARTITION BY RANGE (k1, k2, k3) + ( + PARTITION p1 VALUES [("2014-01-01", "10", "200"), ("2014-01-01", "20", "300")), + PARTITION p2 VALUES [("2014-06-01", "100", "200"), ("2014-07-01", "100", "300")) + ) + DISTRIBUTED BY HASH(k2) BUCKETS 32 + ``` + +5. Create an aggregate model table with HLL and BITMAP column types + + ```sql + CREATE TABLE example_db.example_table + ( + k1 TINYINT, + k2 DECIMAL(10, 2) DEFAULT "10.5", + v1 HLL HLL_UNION, + v2 BITMAP BITMAP_UNION + ) + ENGINE=olap + AGGREGATE KEY(k1, k2) + DISTRIBUTED BY HASH(k1) BUCKETS 32 + ``` + +6. Create two self-maintained tables of the same Colocation Group. + + ```sql + CREATE TABLE t1 ( + id int(11) COMMENT "", + value varchar(8) COMMENT "" + ) + DUPLICATE KEY(id) + DISTRIBUTED BY HASH(id) BUCKETS 10 + PROPERTIES ( + "colocate_with" = "group1" + ); + + CREATE TABLE t2 ( + id int(11) COMMENT "", + value1 varchar(8) COMMENT "", + value2 varchar(8) COMMENT "" + ) + DUPLICATE KEY(`id`) + DISTRIBUTED BY HASH(`id`) BUCKETS 10 + PROPERTIES ( + "colocate_with" = "group1" + ); + ``` + +7. Create a table with inverted index and bloom filter index + + ```sql + CREATE TABLE example_db.table_hash + ( + k1 TINYINT, + k2 DECIMAL(10, 2) DEFAULT "10.5", + v1 CHAR(10) REPLACE, + v2 INT SUM, + INDEX k1_idx (k1) USING INVERTED COMMENT'my first index' + ) + AGGREGATE KEY(k1, k2) + DISTRIBUTED BY HASH(k1) BUCKETS 32 + PROPERTIES ( + "bloom_filter_columns" = "k2" + ); + ``` + +8. Create a dynamic partition table. + + The table creates partitions 3 days in advance every day, and deletes the partitions 3 days ago. For example, if today is `2020-01-08`, partitions named `p20200108`, `p20200109`, `p20200110`, `p20200111` will be created. The partition ranges are: + + ``` + [types: [DATE]; keys: [2020-01-08]; ‥types: [DATE]; keys: [2020-01-09];) + [types: [DATE]; keys: [2020-01-09]; ‥types: [DATE]; keys: [2020-01-10];) + [types: [DATE]; keys: [2020-01-10]; ‥types: [DATE]; keys: [2020-01-11];) + [types: [DATE]; keys: [2020-01-11]; ‥types: [DATE]; keys: [2020-01-12];) + ``` + + ```sql + CREATE TABLE example_db.dynamic_partition + ( + k1 DATE, + k2 INT, + k3 SMALLINT, + v1 VARCHAR(2048), + v2 DATETIME DEFAULT "2014-02-04 15:36:00" + ) + DUPLICATE KEY(k1, k2, k3) + PARTITION BY RANGE (k1) () + DISTRIBUTED BY HASH(k2) BUCKETS 32 + PROPERTIES( + "dynamic_partition.time_unit" = "DAY", + "dynamic_partition.start" = "-3", + "dynamic_partition.end" = "3", + "dynamic_partition.prefix" = "p", + "dynamic_partition.buckets" = "32" + ); + ``` + +9. Create a table with a materialized view (ROLLUP). + + ```sql + CREATE TABLE example_db.rolup_index_table + ( + event_day DATE, + siteid INT DEFAULT '10', + citycode SMALLINT, + username VARCHAR(32) DEFAULT'', + pv BIGINT SUM DEFAULT '0' + ) + AGGREGATE KEY(event_day, siteid, citycode, username) + DISTRIBUTED BY HASH(siteid) BUCKETS 10 + ROLLUP ( + r1(event_day,siteid), + r2(event_day,citycode), + r3(event_day) + ) + PROPERTIES("replication_num" = "3"); + ``` + +10. Set the replica of the table through the `replication_allocation` property. + + ```sql + CREATE TABLE example_db.table_hash + ( + k1 TINYINT, + k2 DECIMAL(10, 2) DEFAULT "10.5" + ) + DISTRIBUTED BY HASH(k1) BUCKETS 32 + PROPERTIES ( + "replication_allocation"="tag.location.group_a:1, tag.location.group_b:2" + ); + ``` + + ```sql + CREATE TABLE example_db.dynamic_partition + ( + k1 DATE, + k2 INT, + k3 SMALLINT, + v1 VARCHAR(2048), + v2 DATETIME DEFAULT "2014-02-04 15:36:00" + ) + PARTITION BY RANGE (k1) () + DISTRIBUTED BY HASH(k2) BUCKETS 32 + PROPERTIES( + "dynamic_partition.time_unit" = "DAY", + "dynamic_partition.start" = "-3", + "dynamic_partition.end" = "3", + "dynamic_partition.prefix" = "p", + "dynamic_partition.buckets" = "32", + "dynamic_partition.replication_allocation" = "tag.location.group_a:3" + ); + ``` + +11. Set the table hot and cold separation policy through the `storage_policy` property. + + ```sql + CREATE TABLE IF NOT EXISTS create_table_use_created_policy + ( + k1 BIGINT, + k2 LARGEINT, + v1 VARCHAR(2048) + ) + UNIQUE KEY(k1) + DISTRIBUTED BY HASH (k1) BUCKETS 3 + PROPERTIES( + "storage_policy" = "test_create_table_use_policy", + "replication_num" = "1" + ); + ``` + + NOTE: Need to create the s3 resource and storage policy before the table can be successfully associated with the migration policy + +12. Add a hot and cold data migration strategy for the table partition + + ```sql + CREATE TABLE create_table_partion_use_created_policy + ( + k1 DATE, + k2 INT, + V1 VARCHAR(2048) REPLACE + ) PARTITION BY RANGE (k1) ( + PARTITION p1 VALUES LESS THAN ("2022-01-01") ("storage_policy" = "test_create_table_partition_use_policy_1" ,"replication_num"="1"), + PARTITION p2 VALUES LESS THAN ("2022-02-01") ("storage_policy" = "test_create_table_partition_use_policy_2" ,"replication_num"="1") + ) DISTRIBUTED BY HASH(k2) BUCKETS 1; + ``` + + NOTE: Need to create the s3 resource and storage policy before the table can be successfully associated with the migration policy + + + +13. Multi Partition by a partition desc + +:::tip Tips +This feature is supported since the Apache Doris 1.2 version +::: + + ```sql + CREATE TABLE create_table_multi_partion_date + ( + k1 DATE, + k2 INT, + V1 VARCHAR(20) + ) PARTITION BY RANGE (k1) ( + FROM ("2000-11-14") TO ("2021-11-14") INTERVAL 1 YEAR, + FROM ("2021-11-14") TO ("2022-11-14") INTERVAL 1 MONTH, + FROM ("2022-11-14") TO ("2023-01-03") INTERVAL 1 WEEK, + FROM ("2023-01-03") TO ("2023-01-14") INTERVAL 1 DAY, + PARTITION p_20230114 VALUES [('2023-01-14'), ('2023-01-15')) + ) DISTRIBUTED BY HASH(k2) BUCKETS 1 + PROPERTIES( + "replication_num" = "1" + ); + ``` + ```sql + CREATE TABLE create_table_multi_partion_date_hour + ( + k1 DATETIME, + k2 INT, + V1 VARCHAR(20) + ) PARTITION BY RANGE (k1) ( + FROM ("2023-01-03 12") TO ("2023-01-14 22") INTERVAL 1 HOUR + ) DISTRIBUTED BY HASH(k2) BUCKETS 1 + PROPERTIES( + "replication_num" = "1" + ); + ``` + ```sql + CREATE TABLE create_table_multi_partion_integer + ( + k1 BIGINT, + k2 INT, + V1 VARCHAR(20) + ) PARTITION BY RANGE (k1) ( + FROM (1) TO (100) INTERVAL 10 + ) DISTRIBUTED BY HASH(k2) BUCKETS 1 + PROPERTIES( + "replication_num" = "1" + ); + ``` + +NOTE: Multi Partition can be mixed with conventional manual creation of partitions. When using, you need to limit the partition column to only one, The default maximum number of partitions created in multi partition is 4096, This parameter can be adjusted in fe configuration `max_multi_partition_num`. + + + +1. Add a duplicate without sorting column table + + ```sql + CREATE TABLE example_db.table_hash + ( + k1 DATE, + k2 DECIMAL(10, 2) DEFAULT "10.5", + k3 CHAR(10) COMMENT "string column", + k4 INT NOT NULL DEFAULT "1" COMMENT "int column" + ) + COMMENT "duplicate without keys" + PARTITION BY RANGE(k1) + ( + PARTITION p1 VALUES LESS THAN ("2020-02-01"), + PARTITION p2 VALUES LESS THAN ("2020-03-01"), + PARTITION p3 VALUES LESS THAN ("2020-04-01") + ) + DISTRIBUTED BY HASH(k1) BUCKETS 32 + PROPERTIES ( + "replication_num" = "1", + "enable_duplicate_without_keys_by_default" = "true" + ); + ``` + +## Keywords + + CREATE, TABLE + +## Best Practice + +#### Partitioning and bucketing + +A table must specify the bucket column, but it does not need to specify the partition. For the specific introduction of partitioning and bucketing, please refer to the [Data Division](../../../../table-design/data-partition) document. + +Tables in Doris can be divided into partitioned tables and non-partitioned tables. This attribute is determined when the table is created and cannot be changed afterwards. That is, for partitioned tables, you can add or delete partitions in the subsequent use process, and for non-partitioned tables, you can no longer perform operations such as adding partitions afterwards. + +At the same time, partitioning columns and bucketing columns cannot be changed after the table is created. You can neither change the types of partitioning and bucketing columns, nor do any additions or deletions to these columns. + +Therefore, it is recommended to confirm the usage method to build the table reasonably before building the table. + +#### Dynamic Partition + +The dynamic partition function is mainly used to help users automatically manage partitions. By setting certain rules, the Doris system regularly adds new partitions or deletes historical partitions. Please refer to [Dynamic Partition](../../../../table-design/data-partition#dynamic-partitioning) document for more help. + +#### Auto Partition + +See the [Auto Partition](../../../../table-design/data-partition#auto-partitioning) document. + +#### Materialized View + +Users can create multiple materialized views (ROLLUP) while building a table. Materialized views can also be added after the table is built. It is convenient for users to create all materialized views at one time by writing in the table creation statement. + +If the materialized view is created when the table is created, all subsequent data import operations will synchronize the data of the materialized view to be generated. The number of materialized views may affect the efficiency of data import. + +If you add a materialized view in the subsequent use process, if there is data in the table, the creation time of the materialized view depends on the current amount of data. + +For the introduction of materialized views, please refer to the [Materialized View](../../../../query/view-materialized-view/metarialized-view) document. + +#### Index + +Users can create indexes on multiple columns while building a table. Indexes can also be added after the table is built. + +If you add an index in the subsequent use process, if there is data in the table, you need to rewrite all the data, so the creation time of the index depends on the current data volume. + diff --git a/docs/sql-manual/sql-statements/table-and-view/table/DESC-TABLE.md b/docs/sql-manual/sql-statements/table-and-view/table/DESC-TABLE.md new file mode 100644 index 0000000000000..eb3f258dfa552 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/DESC-TABLE.md @@ -0,0 +1,62 @@ +--- +{ + "title": "DESC TABLE", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to display the schema information of the specified table + +grammar: + +```sql +DESC[RIBE] [db_name.]table_name [ALL]; +``` + +illustrate: + +1. If ALL is specified, the schemas of all indexes (rollup) of the table will be displayed + +## Example + +1. Display the Base table schema + + ```sql + DESC table_name; + ``` + +2. Display the schema of all indexes of the table + + ```sql + DESC db1.table_name ALL; + ``` + +## Keywords + + DESCRIBE + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/table/DROP-TABLE.md b/docs/sql-manual/sql-statements/table-and-view/table/DROP-TABLE.md new file mode 100644 index 0000000000000..8fedbba16d8ad --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/DROP-TABLE.md @@ -0,0 +1,64 @@ +--- +{ + "title": "DROP TABLE", + "language": "en" +} + +--- + + + + + +## Description + +This statement is used to drop a table. +grammar: + +```sql +DROP TABLE [IF EXISTS] [db_name.]table_name [FORCE]; +``` + + +illustrate: + +- After executing DROP TABLE for a period of time, the dropped table can be recovered through the RECOVER statement. See [RECOVER](../../../../sql-manual/sql-statements/recycle/RECOVER) statement for details + +- If you execute DROP TABLE FORCE, the system will not check whether there are unfinished transactions in the table, the table will be deleted directly and cannot be recovered, this operation is generally not recommended + +## Example + +1. Delete a table + + ```sql + DROP TABLE my_table; + ``` + +2. If it exists, delete the table of the specified database + + ```sql + DROP TABLE IF EXISTS example_db.my_table; + ``` + +## Keywords + + DROP, TABLE + +## Best Practice \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/table-and-view/table/SHOW-ALTER-TABLE.md b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-ALTER-TABLE.md new file mode 100644 index 0000000000000..712216336692b --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-ALTER-TABLE.md @@ -0,0 +1,93 @@ +--- +{ + "title": "SHOW ALTER", + "language": "en" +} + +--- + + + +## Description + +This statement is used to display the execution status of various ongoing modification tasks. + +```sql +SHOW ALTER [TABLE [COLUMN | ROLLUP] [FROM db_name]]; +``` + +Notes: + +1. TABLE COLUMN: Displays ALTER tasks for modifying columns. +2. Supported syntax: [WHERE TableName|CreateTime|FinishTime|State] [ORDER BY] [LIMIT]. +3. TABLE ROLLUP: Displays tasks for creating or deleting ROLLUP. +4. If db_name is not specified, the current default database is used. + +## Result + +*SHOW ALTER TABLE COLUMN* + +| Field Name | Description | +|-----------------------|------------------------------------------------------------------| +| JobId | Unique ID for each Schema Change job. | +| TableName | The name of the base table corresponding to the Schema Change. | +| CreateTime | Job creation time. | +| FinishedTime | Job completion time. If not completed, shows "N/A". | +| IndexName | The name of a base table/synchronized materialized view involved in this modification. | +| IndexId | ID of the new base table/synchronized materialized view. | +| OriginIndexId | ID of a base table/synchronized materialized view involved in this modification. | +| SchemaVersion | Displays in M:N format. M represents the version of the Schema Change, and N represents the corresponding hash value. Each Schema Change increments the version. | +| TransactionId | Transaction ID for converting historical data. | +| State | The phase of the job. | +| | - PENDING: The job is waiting to be scheduled in the queue. | +| | - WAITING_TXN: Waiting for import tasks before the boundary transaction ID to complete. | +| | - RUNNING: Currently performing historical data conversion. | +| | - FINISHED: The job has successfully completed. | +| | - CANCELLED: The job has failed. | +| Msg | If the job fails, displays the failure message. | +| Progress | Job progress. Only displayed in RUNNING state. Progress is shown in M/N format. N is the total number of replicas involved in the Schema Change. M is the number of replicas for which historical data conversion has been completed. | +| Timeout | Job timeout in seconds. | + + +## Examples + +1. Display the execution status of all modification column tasks for the default database. + + ```sql + SHOW ALTER TABLE COLUMN; + ``` + +2. Display the execution status of the most recent modification column task for a specific table. + + ```sql + SHOW ALTER TABLE COLUMN WHERE TableName = "table1" ORDER BY CreateTime DESC LIMIT 1; + ``` + +3. Display the execution status of creating or deleting ROLLUP tasks for a specified database. + + ```sql + SHOW ALTER TABLE ROLLUP FROM example_db; + ``` + +## Keywords + + SHOW, ALTER + +## Best Practices diff --git a/docs/sql-manual/sql-statements/table-and-view/table/SHOW-COLUMNS.md b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-COLUMNS.md new file mode 100644 index 0000000000000..22d9b2d8e8a7f --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-COLUMNS.md @@ -0,0 +1,52 @@ +--- +{ + "title": "SHOW COLUMNS", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to specify the column information of the table + +grammar: + +```sql +SHOW [FULL] COLUMNS FROM tbl; +``` + +## Example + +1. View the column information of the specified table + + ```sql + SHOW FULL COLUMNS FROM tbl; + ``` + +## Keywords + + SHOW, COLUMNS + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/table/SHOW-CONVERT-LIGHT-SCHEMA-CHANGE-PROCESS.md b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-CONVERT-LIGHT-SCHEMA-CHANGE-PROCESS.md new file mode 100644 index 0000000000000..470c502bb0a5d --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-CONVERT-LIGHT-SCHEMA-CHANGE-PROCESS.md @@ -0,0 +1,57 @@ +--- +{ + "title": "SHOW CONVERT LIGHT SCHEMA CHANGE PROCESS", + "language": "en" +} +--- + + + + +## Description + +This statement is used to show the process of converting light schema change process. should enable config `enable_convert_light_weight_schema_change`. + +grammar: + +```sql +SHOW CONVERT_LIGHT_SCHEMA_CHANGE_PROCESS [FROM db] +``` + +## Example + +1. View the converting process in db named test + + ```sql + SHOW CONVERT_LIGHT_SCHEMA_CHANGE_PROCESS FROM test; + ``` + +2. View the converting process globally + + ```sql + SHOW CONVERT_LIGHT_SCHEMA_CHANGE_PROCESS; + ``` + + +## Keywords + + SHOW, CONVERT_LIGHT_SCHEMA_CHANGE_PROCESS + +## Best Practice \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/table-and-view/table/SHOW-CREATE-TABLE.md b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-CREATE-TABLE.md new file mode 100644 index 0000000000000..55154d2b5489a --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-CREATE-TABLE.md @@ -0,0 +1,64 @@ +--- +{ + "title": "SHOW CREATE TABLE", + "language": "en" +} + +--- + + + + + +## Description + +This statement is used to display the creation statement of the data table. + +grammar: + +```sql +SHOW [BRIEF] CREATE TABLE [DBNAME.]TABLE_NAME +``` + +illustrate: + + + +1. `BRIEF` : will not show partitions info + + + +2. `DBNAMNE` : database name +3. `TABLE_NAME` : table name + +## Example + +1. View the table creation statement of a table + + ```sql + SHOW CREATE TABLE demo.tb1 + ``` + +## Keywords + + SHOW, CREATE, TABLE + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/table/SHOW-DYNAMIC-PARTITION-TABLES.md b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-DYNAMIC-PARTITION-TABLES.md new file mode 100644 index 0000000000000..ea22162f36595 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-DYNAMIC-PARTITION-TABLES.md @@ -0,0 +1,50 @@ +--- +{ + "title": "SHOW DYNAMIC PARTITION TABLES", + "language": "en" +} +--- + + + +## Description + +This statement is used to display the status of all dynamic partition tables under the current db + +grammar: + +```sql +SHOW DYNAMIC PARTITION TABLES [FROM db_name]; +``` + +## Example + + 1. Display all dynamic partition table status of database database + + ```sql + SHOW DYNAMIC PARTITION TABLES FROM database; + ``` + +## Keywords + + SHOW, DYNAMIC, PARTITION + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/Show-Statements/SHOW-PARTITION-ID.md b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-PARTITION-ID.md similarity index 100% rename from docs/sql-manual/sql-statements/Show-Statements/SHOW-PARTITION-ID.md rename to docs/sql-manual/sql-statements/table-and-view/table/SHOW-PARTITION-ID.md diff --git a/docs/sql-manual/sql-statements/table-and-view/table/SHOW-PARTITION.md b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-PARTITION.md new file mode 100644 index 0000000000000..9a0ca062c021c --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-PARTITION.md @@ -0,0 +1,65 @@ +--- +{ + "title": "SHOW PARTITION", + "language": "en" +} + +--- + + + + +## Description + +SHOW PARTITION is used to display detailed information about a specified partition. This includes the name and ID of the associated database, the name and ID of the associated table, and the partition name. + +## Syntax + +```sql +SHOW PARTITION +``` + +## Required Parameters + +**** + +> The ID of the partition. The partition ID can be obtained through methods such as SHOW PARTITIONS. For more information, please refer to the "SHOW PARTITIONS" section. + +## Access Control Requirements + +The user executing this SQL command must have at least `ADMIN_PRIV` permissions. + +## Examples + +Query partition information for partition ID 13004: + +```sql +SHOW PARTITION 13004; +``` + +Results: + +```sql ++--------+-----------+---------------+-------+---------+ +| DbName | TableName | PartitionName | DbId | TableId | ++--------+-----------+---------------+-------+---------+ +| ods | sales | sales | 13003 | 13005 | ++--------+-----------+---------------+-------+---------+ +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/table-and-view/table/SHOW-PARTITIONS.md b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-PARTITIONS.md new file mode 100644 index 0000000000000..bd123f5a3f55e --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-PARTITIONS.md @@ -0,0 +1,85 @@ +--- +{ + "title": "SHOW PARTITIONS", + "language": "en" +} + +--- + + + + + + +## Description + + This statement is used to display partition information for tables in Internal catalog or Hive Catalog + +grammar: + +```SQL + SHOW [TEMPORARY] PARTITIONS FROM [db_name.]table_name [WHERE] [ORDER BY] [LIMIT]; +``` + +illustrate: + +When used in Internal catalog: + +1. Support the filtering of PartitionId, PartitionName, State, Buckets, ReplicationNum, LastConsistencyCheckTime and other columns +2. TEMPORARY specifies to list temporary partitions + + +when used in Hive Catalog: +Will return all partitions' name. Support multilevel partition table + + + +## Example + +1. Display all non-temporary partition information of the specified table under the specified db + +```SQL + SHOW PARTITIONS FROM example_db.table_name; +``` + +2. Display all temporary partition information of the specified table under the specified db + + ```SQL + SHOW TEMPORARY PARTITIONS FROM example_db.table_name; + ``` + +3. Display the information of the specified non-temporary partition of the specified table under the specified db + + ```SQL + SHOW PARTITIONS FROM example_db.table_name WHERE PartitionName = "p1"; + ``` + +4. Display the latest non-temporary partition information of the specified table under the specified db + + ```SQL + SHOW PARTITIONS FROM example_db.table_name ORDER BY PartitionId DESC LIMIT 1; + ``` + +## Keywords + + SHOW, PARTITIONS + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/table/SHOW-TABLE-ID.md b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-TABLE-ID.md new file mode 100644 index 0000000000000..78f30f30f5d6b --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-TABLE-ID.md @@ -0,0 +1,51 @@ +--- +{ + "title": "SHOW TABLE ID", + "language": "en" +} +--- + + + + +### Description + +This statement is used to find the corresponding database name, table name according to the table id (only for administrators) + +grammar: + +```sql +SHOW TABLE [table_id] +``` + +### Example + + 1. Find the corresponding database name, table name according to the table id + + ```sql + SHOW TABLE 10001; + ``` + +### Keywords + + SHOW, TABLE, ID + +### Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/table/SHOW-TABLE-STATUS.md b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-TABLE-STATUS.md new file mode 100644 index 0000000000000..2a85c0af6a63a --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-TABLE-STATUS.md @@ -0,0 +1,62 @@ +--- +{ + "title": "SHOW TABLE STATUS", + "language": "en" +} +--- + + + + +## Description + +This statement is used to view some information about the Table. + +grammar: + +```sql +SHOW TABLE STATUS +[FROM db] [LIKE "pattern"] +``` + +illustrate: + +1. This statement is mainly used to be compatible with MySQL syntax, currently only a small amount of information such as Comment is displayed + +## Example + + 1. View the information of all tables under the current database + + ```sql + SHOW TABLE STATUS; + ``` + + 2. View the information of the table whose name contains example under the specified database + + ```sql + SHOW TABLE STATUS FROM db LIKE "%example%"; + ``` + +## Keywords + + SHOW, TABLE, STATUS + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/table/SHOW-TABLES.md b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-TABLES.md new file mode 100644 index 0000000000000..81e37065146cc --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/SHOW-TABLES.md @@ -0,0 +1,78 @@ +--- +{ + "title": "SHOW TABLES", + "language": "en" +} +--- + + + + +## Description + +This statement is used to display all tables under the current db + +grammar: + +```sql +SHOW [FULL] TABLES [LIKE] +``` + +illustrate: + +1. LIKE: Fuzzy query can be performed according to the table name + +## Example + + 1. View all tables under DB + + ```sql + mysql> show tables; + +---------------------------------+ + | Tables_in_demo | + +---------------------------------+ + | ads_client_biz_aggr_di_20220419 | + | cmy1 | + | cmy2 | + | intern_theme | + | left_table | + +---------------------------------+ + 5 rows in set (0.00 sec) + ``` + +2. Fuzzy query by table name + + ```sql + mysql> show tables like '%cm%'; + +----------------+ + | Tables_in_demo | + +----------------+ + | cmy1 | + | cmy2 | + +----------------+ + 2 rows in set (0.00 sec) + ``` + +## Keywords + + SHOW, TABLES + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/table/TRUNCATE-TABLE.md b/docs/sql-manual/sql-statements/table-and-view/table/TRUNCATE-TABLE.md new file mode 100644 index 0000000000000..97bfd9fcc039f --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/table/TRUNCATE-TABLE.md @@ -0,0 +1,64 @@ +--- +{ + "title": "TRUNCATE TABLE", + "language": "en" +} +--- + + + + +## Description + +This statement is used to clear the data of the specified table and partition +grammar: + +```sql +TRUNCATE TABLE [db.]tbl[ PARTITION(p1, p2, ...)]; +``` + +illustrate: + +- The statement clears the data, but leaves the table or partition. +- Unlike DELETE, this statement can only clear the specified table or partition as a whole, and cannot add filter conditions. +- Unlike DELETE, using this method to clear data will not affect query performance. +- The data deleted by this operation cannot be recovered. +- When using this command, the table status needs to be NORMAL, that is, operations such as SCHEMA CHANGE are not allowed. +- This command may cause the ongoing load to fail + +## Example + +1. Clear the table tbl under example_db + + ```sql + TRUNCATE TABLE example_db.tbl; + ``` + +2. Empty p1 and p2 partitions of table tbl + + ```sql + TRUNCATE TABLE tbl PARTITION(p1, p2); + ``` + +## Keywords + + TRUNCATE, TABLE + +## Best Practice diff --git a/docs/sql-manual/sql-statements/table-and-view/view/ALTER-VIEW.md b/docs/sql-manual/sql-statements/table-and-view/view/ALTER-VIEW.md new file mode 100644 index 0000000000000..33af3468fbae4 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/view/ALTER-VIEW.md @@ -0,0 +1,70 @@ +--- +{ + "title": "ALTER VIEW", + "language": "en" +} +--- + + + + + + +## Description + +This statement is used to modify the definition of a view + +grammar: + +```sql +ALTER VIEW +[db_name.]view_name +(column1[ COMMENT "col comment"][, column2, ...]) +AS query_stmt +``` + +illustrate: + +- Views are all logical, and the data in them will not be stored on physical media. When querying, the view will be used as a subquery in the statement. Therefore, modifying the definition of the view is equivalent to modifying query_stmt. +- query_stmt is any supported SQL + +## Example + +1. Modify the view example_view on example_db + +```sql +ALTER VIEW example_db.example_view +( +c1 COMMENT "column 1", +c2 COMMENT "column 2", +c3 COMMENT "column 3" +) +AS SELECT k1, k2, SUM(v1) FROM example_table +GROUP BY k1, k2 +``` + +## Keywords + +```text +ALTER, VIEW +``` + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/table-and-view/view/CREATE-VIEW.md b/docs/sql-manual/sql-statements/table-and-view/view/CREATE-VIEW.md new file mode 100644 index 0000000000000..88e45d698d4ab --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/view/CREATE-VIEW.md @@ -0,0 +1,77 @@ +--- +{ + "title": "CREATE VIEW", + "language": "en" +} +--- + + + + +## Description + +This statement is used to create a logical view +grammar: + +```sql +CREATE VIEW [IF NOT EXISTS] + [db_name.]view_name + (column1[ COMMENT "col comment"][, column2, ...]) +AS query_stmt +``` + + +illustrate: + +- Views are logical views and have no physical storage. All queries on the view are equivalent to the sub-queries corresponding to the view. +- query_stmt is any supported SQL + +## Example + +1. Create the view example_view on example_db + + ```sql + CREATE VIEW example_db.example_view (k1, k2, k3, v1) + AS + SELECT c1 as k1, k2, k3, SUM(v1) FROM example_table + WHERE k1 = 20160112 GROUP BY k1,k2,k3; + ``` + +2. Create a view with a comment + + ```sql + CREATE VIEW example_db.example_view + ( + k1 COMMENT "first key", + k2 COMMENT "second key", + k3 COMMENT "third key", + v1 COMMENT "first value" + ) + COMMENT "my first view" + AS + SELECT c1 as k1, k2, k3, SUM(v1) FROM example_table + WHERE k1 = 20160112 GROUP BY k1,k2,k3; + ``` + +## Keywords + + CREATE, VIEW + +## Best Practice diff --git a/docs/sql-manual/sql-statements/table-and-view/view/DROP-VIEW.md b/docs/sql-manual/sql-statements/table-and-view/view/DROP-VIEW.md new file mode 100644 index 0000000000000..5c17cd914eda1 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/view/DROP-VIEW.md @@ -0,0 +1,64 @@ +--- +{ + "title": "DROP VIEW", + "language": "en" +} +--- + + + + +## Description + +Delete a view in the current or specified database. + +## Syntax + +```sql +DROP VIEW [ IF EXISTS ] +``` +## Required Parameters + +The name of the view to be deleted. + +## Optional Parameters + +**[ IF EXISTS ]** + +If this parameter is specified, no error will be thrown when the view does not exist, and the deletion operation will be skipped directly. + +## Access Control Requirements + +The user executing this SQL command must have at least the following privileges: + +| Privilege | Object | Notes | +| :-------- | :----- | :---- | +| DROP_PRIV | Table | | + +## Usage Notes + +Deleted views cannot be restored and must be recreated. + +## Examples + +```sql +CREATE VIEW vtest AS SELECT 1, 'test'; +DROP VIEW IF EXISTS vtest; +``` \ No newline at end of file diff --git a/docs/sql-manual/sql-statements/table-and-view/view/SHOW-CREATE-VIEW.md b/docs/sql-manual/sql-statements/table-and-view/view/SHOW-CREATE-VIEW.md new file mode 100644 index 0000000000000..d36ae3a06d543 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/view/SHOW-CREATE-VIEW.md @@ -0,0 +1,74 @@ +--- +{ + "title": "SHOW CREATE VIEW", + "language": "en" +} +--- + + + + +## Description + +Display the CREATE VIEW statement used to create the specified view. + +## Syntax + +```sql +SHOW CREATE VIEW +``` + +## Required Parameters + +`****` The name of the view to view. + +## Result Description + +- View: The name of the queried view. +- Create View: The persisted SQL statement in the database. +- character_set_client: The value of the character_set_client system variable in the session when the view was created. +- collation_connection: The value of the collation_connection system variable in the session when the view was created. + +## Access Control Requirements + +Users executing this SQL command must have at least the following privileges: + +| Privilege | Object | Notes | +| ---------------- | ------ | ----- | +| SHOW_VIEW_PRIV | Table | | + +View information can also be queried via the INFORMATION_SCHEMA.VIEWS table. + +## Examples + +```sql +CREATE VIEW vtest AS SELECT 1, 'test'; +SHOW CREATE VIEW vtest; +``` + +Query result: + +```sql ++-------+------------------------------------------+----------------------+----------------------+ +| View | Create View | character_set_client | collation_connection | ++-------+------------------------------------------+----------------------+----------------------+ +| vtest | CREATE VIEW `vtest` AS SELECT 1, 'test'; | utf8mb4 | utf8mb4_0900_bin | ++-------+------------------------------------------+----------------------+----------------------+ +``` diff --git a/docs/sql-manual/sql-statements/table-and-view/view/SHOW-VIEW.md b/docs/sql-manual/sql-statements/table-and-view/view/SHOW-VIEW.md new file mode 100644 index 0000000000000..d9078d5819d45 --- /dev/null +++ b/docs/sql-manual/sql-statements/table-and-view/view/SHOW-VIEW.md @@ -0,0 +1,52 @@ +--- +{ + "title": "SHOW VIEW", + "language": "en" +} +--- + + + + + +## Description + +This statement is used to display all views based on the given table + +grammar: + +```sql + SHOW VIEW { FROM | IN } table [ FROM db ] +``` + +## Example + +1. Show all views created based on table testTbl + + ```sql + SHOW VIEW FROM testTbl; + ``` + +## Keywords + + SHOW, VIEW + +## Best Practice + diff --git a/docs/sql-manual/sql-statements/transaction/BEGIN.md b/docs/sql-manual/sql-statements/transaction/BEGIN.md new file mode 100644 index 0000000000000..506d70da1db30 --- /dev/null +++ b/docs/sql-manual/sql-statements/transaction/BEGIN.md @@ -0,0 +1,62 @@ +--- +{ + "title": "BEGIN", + "language": "en" +} +--- + + + + +## Description + +Users can specify a Label. If not specified, the system will generate a Label automatically. + +## Syntax + +```sql +BEGIN [ WITH LABEL

- `visible`:表示导入成功,数据可见

- `committed`:该状态也表示导入已经完成,只是数据可能会延迟可见,无需重试

- Label Already Exists:Label 重复,需要更换 label

- Fail:导入失败

| | Err | 导入错误信息 | -当需要查看被过滤的行时,用户可以通过[ SHOW LOAD ](../../../sql-manual/sql-statements/Show-Statements/SHOW-LOAD)语句 +当需要查看被过滤的行时,用户可以通过[ SHOW LOAD ](../../../sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD)语句 ```sql SHOW LOAD WHERE label="xxx"; @@ -217,7 +217,7 @@ SHOW LOAD WHERE label="xxx"; 数据不可见是一个临时状态,这批数据最终是一定可见的 -可以通过[ SHOW TRANSACTION ](../../../sql-manual/sql-statements/Show-Statements/SHOW-TRANSACTION)语句查看这批数据的可见状态: +可以通过[ SHOW TRANSACTION ](../../../sql-manual/sql-statements/transaction/SHOW-TRANSACTION)语句查看这批数据的可见状态: ```sql SHOW TRANSACTION WHERE id=4005; @@ -314,7 +314,7 @@ PROPERTIES ( ); ``` -2. 关于创建 Doris 表的详细说明,请参阅 [CREATE-TABLE](../../../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE) 语法帮助。 +2. 关于创建 Doris 表的详细说明,请参阅 [CREATE-TABLE](../../../sql-manual/sql-statements/table-and-view/table/CREATE-TABLE) 语法帮助。 3. 导入数据 (从 hive.db1.source_tbl 表导入到 target_tbl 表) @@ -398,4 +398,4 @@ FROM s3( ## 更多帮助 -关于 Insert Into 使用的更多详细语法,请参阅 [INSERT INTO](../../../sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/INSERT) 命令手册,也可以在 MySQL 客户端命令行下输入 `HELP INSERT` 获取更多帮助信息。 +关于 Insert Into 使用的更多详细语法,请参阅 [INSERT INTO](../../../sql-manual/sql-statements/data-modification/DML/INSERT) 命令手册,也可以在 MySQL 客户端命令行下输入 `HELP INSERT` 获取更多帮助信息。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/import/import-way/insert-into-values-manual.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/import/import-way/insert-into-values-manual.md index 5cea63ca6c7c5..ed3e4ccfe9ab7 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/import/import-way/insert-into-values-manual.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/import/import-way/insert-into-values-manual.md @@ -44,7 +44,7 @@ INSERT INTO VALUES 通过 MySQL 协议提交和传输。下例以 MySQL 命令 ### 前置检查 -INSERT INTO VALUES 需要对目标表的 INSERT 权限。如果没有 INSERT 权限,可以通过 [GRANT](../../../sql-manual/sql-statements/Account-Management-Statements/GRANT) 命令给用户授权。 +INSERT INTO VALUES 需要对目标表的 INSERT 权限。如果没有 INSERT 权限,可以通过 [GRANT](../../../sql-manual/sql-statements/account-management/GRANT-TO) 命令给用户授权。 ### 创建导入作业 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/import/import-way/mysql-load-manual.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/import/import-way/mysql-load-manual.md index 16d3a48fde899..f1d66cc6d0970 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/import/import-way/mysql-load-manual.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/import/import-way/mysql-load-manual.md @@ -270,4 +270,4 @@ PROPERTIES ("exec_mem_limit"="10737418240"); ## 更多帮助 -关于 MySQL Load 使用的更多详细语法及最佳实践,请参阅 [MySQL Load](../../../sql-manual/sql-statements/Data-Manipulation-Statements/Load/MYSQL-LOAD) 命令手册。 \ No newline at end of file +关于 MySQL Load 使用的更多详细语法及最佳实践,请参阅 [MySQL Load](../../../sql-manual/sql-statements/data-modification/load-and-export/MYSQL-LOAD) 命令手册。 \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/import/import-way/routine-load-manual.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/import/import-way/routine-load-manual.md index 013e6a7279951..b2c37831c7c1e 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/import/import-way/routine-load-manual.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/import/import-way/routine-load-manual.md @@ -80,7 +80,7 @@ Routine Load 的导入具体流程如下图展示: ### 创建导入作业 -在 Doris 内可以通过 CREATE ROUTINE LOAD 命令创建常驻 Routine Load 导入任务。详细语法可以参考 [CREATE ROUTINE LOAD](../../../sql-manual/sql-statements/Data-Manipulation-Statements/Load/CREATE-ROUTINE-LOAD)。Routine Load 可以消费 CSV 和 JSON 的数据。 +在 Doris 内可以通过 CREATE ROUTINE LOAD 命令创建常驻 Routine Load 导入任务。详细语法可以参考 [CREATE ROUTINE LOAD](../../../sql-manual/sql-statements/data-modification/load-and-export/CREATE-ROUTINE-LOAD)。Routine Load 可以消费 CSV 和 JSON 的数据。 **导入 CSV 数据** @@ -193,7 +193,7 @@ FROM KAFKA( **01 查看导入运行任务** -可以通过 [SHOW ROUTINE LOAD](../../../sql-manual/sql-statements/Show-Statements/SHOW-ROUTINE-LOAD) 命令查看导入作业情况。SHOW ROUTINE LOAD 描述了当前作业的基本情况,如导入目标表、导入延迟状态、导入配置信息、导入错误信息等。 +可以通过 [SHOW ROUTINE LOAD](../../../sql-manual/sql-statements/data-modification/load-and-export/SHOW-ROUTINE-LOAD) 命令查看导入作业情况。SHOW ROUTINE LOAD 描述了当前作业的基本情况,如导入目标表、导入延迟状态、导入配置信息、导入错误信息等。 如通过以下命令可以查看 testdb.example_routine_load_csv 的任务情况: @@ -227,7 +227,7 @@ ReasonOfStateChanged: **02 查看导入运行作业** -可以通过 [SHOW ROUTINE LOAD TASK](../../../sql-manual/sql-statements/Show-Statements/SHOW-ROUTINE-LOAD-TASK) 命令查看导入子任务情况。SHOW ROUTINE LOAD TASK 描述了当前作业下的子任务信息,如子任务状态,下发 BE id 等信息。 +可以通过 [SHOW ROUTINE LOAD TASK](../../../sql-manual/sql-statements/data-modification/load-and-export/SHOW-ROUTINE-LOAD-TASK) 命令查看导入子任务情况。SHOW ROUTINE LOAD TASK 描述了当前作业下的子任务信息,如子任务状态,下发 BE id 等信息。 如通过以下命令可以查看 testdb.example_routine_load_csv 的任务情况: @@ -246,7 +246,7 @@ mysql> SHOW ROUTINE LOAD TASK WHERE jobname = 'example_routine_load_csv'; ### 暂停导入作业 -可以通过 [PAUSE ROUTINE LOAD](../../../sql-manual/sql-statements/Data-Manipulation-Statements/Load/PAUSE-ROUTINE-LOAD) 命令暂停导入作业。暂停导入作业后,会进入 PAUSED 状态,但导入作业并未终止,可以通过 RESUME ROUTINE LOAD 命令重启导入作业。 +可以通过 [PAUSE ROUTINE LOAD](../../../sql-manual/sql-statements/data-modification/load-and-export/PAUSE-ROUTINE-LOAD) 命令暂停导入作业。暂停导入作业后,会进入 PAUSED 状态,但导入作业并未终止,可以通过 RESUME ROUTINE LOAD 命令重启导入作业。 如通过以下命令可以暂停 testdb.example_routine_load_csv 导入作业: @@ -266,7 +266,7 @@ RESUME ROUTINE LOAD FOR testdb.example_routine_load_csv; ### 修改导入作业 -可以通过 [ALTER ROUTINE LOAD](../../../sql-manual/sql-statements/Data-Manipulation-Statements/Load/ALTER-ROUTINE-LOAD) 命令修改已创建的导入作业。在修改导入作业前,需要使用 PAUSE ROUTINE LOAD 暂停导入作业,修改后需要使用 RESUME ROUTINE LOAD 恢复导入作业。 +可以通过 [ALTER ROUTINE LOAD](../../../sql-manual/sql-statements/data-modification/load-and-export/ALTER-ROUTINE-LOAD) 命令修改已创建的导入作业。在修改导入作业前,需要使用 PAUSE ROUTINE LOAD 暂停导入作业,修改后需要使用 RESUME ROUTINE LOAD 恢复导入作业。 如通过以下命令可以修改期望导入任务并行度参数 desired_concurrent_number,并修改 Kafka Topic 信息: @@ -399,8 +399,8 @@ job_properties 子句具体参数选项如下: | max_batch_interval | 每个子任务的最大运行时间,单位是秒,必须大于0,默认值为 60(s)。max_batch_interval/max_batch_rows/max_batch_size 共同形成子任务执行阈值。任一参数达到阈值,导入子任务结束,并生成新的导入子任务。 | | max_batch_rows | 每个子任务最多读取的行数。必须大于等于 200000。默认是 20000000。max_batch_interval/max_batch_rows/max_batch_size 共同形成子任务执行阈值。任一参数达到阈值,导入子任务结束,并生成新的导入子任务。 | | max_batch_size | 每个子任务最多读取的字节数。单位是字节,范围是 100MB 到 1GB。默认是 1G。max_batch_interval/max_batch_rows/max_batch_size 共同形成子任务执行阈值。任一参数达到阈值,导入子任务结束,并生成新的导入子任务。 | -| max_error_number | 采样窗口内,允许的最大错误行数。必须大于等于 0。默认是 0,即不允许有错误行。采样窗口为 `max_batch_rows * 10`。即如果在采样窗口内,错误行数大于 `max_error_number`,则会导致例行作业被暂停,需要人工介入检查数据质量问题,通过 [SHOW ROUTINE LOAD](../../../sql-manual/sql-statements/Show-Statements/SHOW-ROUTINE-LOAD) 命令中 `ErrorLogUrls` 检查数据的质量问题。被 where 条件过滤掉的行不算错误行。 | -| strict_mode | 是否开启严格模式,默认为关闭。严格模式表示对于导入过程中的列类型转换进行严格过滤。如果开启后,非空原始数据的列类型变换如果结果为 NULL,则会被过滤。

严格模式过滤策略如下:

- 某衍生列(由函数转换生成而来),Strict Mode 对其不产生影响

- 当列类型需要转换,错误的数据类型将被过滤掉,在 [SHOW ROUTINE LOAD](../../../sql-manual/sql-statements/Show-Statements/SHOW-ROUTINE-LOAD) 的 `ErrorLogUrls` 中查看因为数据类型错误而被过滤掉的列

- 对于导入的某列类型包含范围限制的,如果原始数据能正常通过类型转换,但无法通过范围限制的,strict mode 对其也不产生影响。例如:如果类型是 decimal(1,0), 原始数据为 10,则属于可以通过类型转换但不在列声明的范围内。这种数据 strict 对其不产生影响。详细内容参考[严格模式](../../../data-operate/import/handling-messy-data#严格模式)。

| +| max_error_number | 采样窗口内,允许的最大错误行数。必须大于等于 0。默认是 0,即不允许有错误行。采样窗口为 `max_batch_rows * 10`。即如果在采样窗口内,错误行数大于 `max_error_number`,则会导致例行作业被暂停,需要人工介入检查数据质量问题,通过 [SHOW ROUTINE LOAD](../../../sql-manual/sql-statements/data-modification/load-and-export/SHOW-ROUTINE-LOAD) 命令中 `ErrorLogUrls` 检查数据的质量问题。被 where 条件过滤掉的行不算错误行。 | +| strict_mode | 是否开启严格模式,默认为关闭。严格模式表示对于导入过程中的列类型转换进行严格过滤。如果开启后,非空原始数据的列类型变换如果结果为 NULL,则会被过滤。

严格模式过滤策略如下:

- 某衍生列(由函数转换生成而来),Strict Mode 对其不产生影响

- 当列类型需要转换,错误的数据类型将被过滤掉,在 [SHOW ROUTINE LOAD](../../../sql-manual/sql-statements/data-modification/load-and-export/SHOW-ROUTINE-LOAD) 的 `ErrorLogUrls` 中查看因为数据类型错误而被过滤掉的列

- 对于导入的某列类型包含范围限制的,如果原始数据能正常通过类型转换,但无法通过范围限制的,strict mode 对其也不产生影响。例如:如果类型是 decimal(1,0), 原始数据为 10,则属于可以通过类型转换但不在列声明的范围内。这种数据 strict 对其不产生影响。详细内容参考[严格模式](../../../data-operate/import/handling-messy-data#严格模式)。

| | timezone | 指定导入作业所使用的时区。默认为使用 Session 的 timezone 参数。该参数会影响所有导入涉及的和时区有关的函数结果。 | | format | 指定导入数据格式,默认是 CSV,支持 JSON 格式。 | | jsonpaths | 当导入数据格式为 JSON 时,可以通过 jsonpaths 指定抽取 JSON 数据中的字段。例如通过以下命令指定导入 jsonpaths:`"jsonpaths" = "[\"$.userid\",\"$.username\",\"$.age\",\"$.city\"]"` | @@ -429,7 +429,7 @@ data_source_properties 子句具体参数选项如下: | kafka_topic | 指定要订阅的 Kafka 的 topic。一个导入作业仅能消费一个 Kafka Topic。 | | kafka_partitions | 指定需要订阅的 Kafka Partition。如果不指定,则默认消费所有分区。 | | kafka_offsets | 待销费的 Kakfa Partition 中起始消费点(offset)。如果指定时间,则会从大于等于该时间的最近一个 offset 处开始消费。offset 可以指定从大于等于 0 的具体 offset,也可以使用以下格式:

- OFFSET_BEGINNING: 从有数据的位置开始订阅。

- OFFSET_END: 从末尾开始订阅。

- 时间格式,如:"2021-05-22 11:00:00"

如果没有指定,则默认从 `OFFSET_END` 开始订阅 topic 下的所有 partition。

可以指定多个其实消费点,使用逗号分隔,如:`"kafka_offsets" = "101,0,OFFSET_BEGINNING,OFFSET_END"`或者`"kafka_offsets" = "2021-05-22 11:00:00,2021-05-22 11:00:00"`

注意,时间格式不能和 OFFSET 格式混用。

| -| property | 指定自定义 kafka 参数。功能等同于 kafka shell 中 "--property" 参数。当参数的 Value 为一个文件时,需要在 Value 前加上关键词:"FILE:"。创建文件可以参考 [CREATE FILE](../../../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FILE) 命令文档。更多支持的自定义参数,可以参考 librdkafka 的官方 [CONFIGURATION](https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md) 文档中,client 端的配置项。如:`"property.client.id" = "12345"``"property.group.id" = "group_id_0"``"property.ssl.ca.location" = "FILE:ca.pem"` | +| property | 指定自定义 kafka 参数。功能等同于 kafka shell 中 "--property" 参数。当参数的 Value 为一个文件时,需要在 Value 前加上关键词:"FILE:"。创建文件可以参考 [CREATE FILE](../../../sql-manual/sql-statements/security/CREATE-FILE) 命令文档。更多支持的自定义参数,可以参考 librdkafka 的官方 [CONFIGURATION](https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md) 文档中,client 端的配置项。如:`"property.client.id" = "12345"``"property.group.id" = "group_id_0"``"property.ssl.ca.location" = "FILE:ca.pem"` | 通过配置 data_source_properties 中的 kafka property 参数,可以配置安全访问选项。目前 Doris 支持多种 Kafka 安全协议,如 plaintext(默认)、SSL、PLAIN、Kerberos 等。 @@ -1733,4 +1733,4 @@ FROM KAFKA ## 更多帮助 -参考 SQL 手册 [Routine Load](../../../sql-manual/sql-statements/Data-Manipulation-Statements/Load/CREATE-ROUTINE-LOAD)。也可以在客户端命令行下输入 `HELP ROUTINE LOAD` 获取更多帮助信息。 +参考 SQL 手册 [Routine Load](../../../sql-manual/sql-statements/data-modification/load-and-export/CREATE-ROUTINE-LOAD)。也可以在客户端命令行下输入 `HELP ROUTINE LOAD` 获取更多帮助信息。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/import/import-way/stream-load-manual.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/import/import-way/stream-load-manual.md index dbad10d0f3673..9c7dc285b5dfe 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/import/import-way/stream-load-manual.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/import/import-way/stream-load-manual.md @@ -67,7 +67,7 @@ Stream Load 通过 HTTP 协议提交和传输。下例以 curl 工具为例, ### 前置检查 -Stream Load 需要对目标表的 INSERT 权限。如果没有 INSERT 权限,可以通过 [GRANT](../../../sql-manual/sql-statements/Account-Management-Statements/GRANT) 命令给用户授权。 +Stream Load 需要对目标表的 INSERT 权限。如果没有 INSERT 权限,可以通过 [GRANT](../../../sql-manual/sql-statements/account-management/GRANT-TO) 命令给用户授权。 ### 创建导入作业 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/update/unique-update.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/update/unique-update.md index 5344327d1490a..9da3c3e6916cb 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/update/unique-update.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/data-operate/update/unique-update.md @@ -137,4 +137,4 @@ WHERE transaction_date = '2024-11-24'; ## 更多帮助 -关于数据更新使用的更多详细语法,请参阅 [UPDATE](../../sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/UPDATE) 命令手册,也可以在 MySQL 客户端命令行下输入 `HELP UPDATE` 获取更多帮助信息。 \ No newline at end of file +关于数据更新使用的更多详细语法,请参阅 [UPDATE](../../sql-manual/sql-statements/data-modification/DML/UPDATE) 命令手册,也可以在 MySQL 客户端命令行下输入 `HELP UPDATE` 获取更多帮助信息。 \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/gettingStarted/what-is-apache-doris.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/gettingStarted/what-is-apache-doris.md index c94107c812349..66b909853b760 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/gettingStarted/what-is-apache-doris.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/gettingStarted/what-is-apache-doris.md @@ -83,7 +83,7 @@ FE 与 BE 进程都是可以横向扩展的,单集群可以支持到数百台 - 存储层:存储层可以使用 S3、HDFS、OSS、COS、OBS、Minio、Ceph 等共享存储存放 Doris 的数据文件,包含包括 Segment 文件、反向索引的索引文件等。 -![存算分离整体架构和技术特点](/images/getting-started/apache-doris-technical-compute-storage-decouple-overview.png) +![存算分离整体架构和技术特点](/images/getting-started/apache-doris-technical-compute-storage-decouple-overview.jpg) ## Apache Doris 的核心特性 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/install/cluster-deployment/k8s-deploy/compute-storage-coupled/cluster-operation.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/install/cluster-deployment/k8s-deploy/compute-storage-coupled/cluster-operation.md index cde68654fee67..c0957cc2d6da7 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/install/cluster-deployment/k8s-deploy/compute-storage-coupled/cluster-operation.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/install/cluster-deployment/k8s-deploy/compute-storage-coupled/cluster-operation.md @@ -133,7 +133,7 @@ K8s 所有运维操作通过修改资源为最终状态,由 Operator 服务自 ### 节点缩容 -关于节点缩容问题,Doris-Operator 目前并不能很好的支持节点安全下线,在这里仍能够通过减少集群组件的 replicas 属性来实现减少 FE 或 BE 的目的,这里是直接 stop 节点来实现节点下线,当前版本的 Doris-Operator 并未能实现 [decommission](../../../../sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DECOMMISSION-BACKEND.md) 安全转移副本后下线。由此可能引发一些问题及其注意事项如下 +关于节点缩容问题,Doris-Operator 目前并不能很好的支持节点安全下线,在这里仍能够通过减少集群组件的 replicas 属性来实现减少 FE 或 BE 的目的,这里是直接 stop 节点来实现节点下线,当前版本的 Doris-Operator 并未能实现 [decommission](../../../../sql-manual/sql-statements/cluster-management/instance-management/DECOMMISSION-BACKEND) 安全转移副本后下线。由此可能引发一些问题及其注意事项如下 - 表存在单副本情况下贸然下线 BE 节点,一定会有数据丢失,尽可能避免此操作。 - FE Follower 节点尽量避免随意下线,可能带来元数据损坏影响服务。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/install/deploy-manually/storage-compute-decoupled-deploy-manually.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/install/deploy-manually/storage-compute-decoupled-deploy-manually.md index be350b5b62c4e..4da9b54083387 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/install/deploy-manually/storage-compute-decoupled-deploy-manually.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/install/deploy-manually/storage-compute-decoupled-deploy-manually.md @@ -243,7 +243,7 @@ ALTER SYSTEM ADD FOLLOWER "host:port"; ``` -将 `host:port` 替换为 FE 节点的实际地址和编辑日志端口。更多信息请参见 [ADD FOLLOWER](../../sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-FOLLOWER) 和 [ADD OBSERVER](../../sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-OBSERVER)。 +将 `host:port` 替换为 FE 节点的实际地址和编辑日志端口。更多信息请参见 [ADD FOLLOWER](../../sql-manual/sql-statements/cluster-management/instance-management/ADD-FOLLOWER) 和 [ADD OBSERVER](../../sql-manual/sql-statements/cluster-management/instance-management/ADD-OBSERVER)。 生产环境中,请确保在 FOLLOWER 角色中的前端 (FE) 节点总数,包括第一个 FE,保持为奇数。一般来说,三个 FOLLOWER 就足够了。观察者角色的前端节点可以是任意数量。 @@ -284,7 +284,7 @@ ALTER SYSTEM ADD FOLLOWER "host:port"; 可以通过 PROPERTIES 设置 BE 所在的 计算组。 - 更详细的用法请参考 [ADD BACKEND](../../sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-BACKEND) 和 [REMOVE BACKEND](../../sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-BACKEND)。 + 更详细的用法请参考 [ADD BACKEND](../../sql-manual/sql-statements/cluster-management/instance-management/ADD-BACKEND) 和 [REMOVE BACKEND](../../sql-manual/sql-statements/cluster-management/instance-management/DROP-BACKEND)。 5. 验证 BE 状态 @@ -335,7 +335,7 @@ Storage Vault 是 Doris 存算分离架构中的重要组件。它们代表了 ); ``` - 要在其他对象存储上创建 Storage Vault ,请参考 [创建 Storage Vault ](../../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-STORAGE-VAULT)。 + 要在其他对象存储上创建 Storage Vault ,请参考 [创建 Storage Vault ](../../sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT)。 3. 设置默认 Storage Vault diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/lakehouse/catalog-overview.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/lakehouse/catalog-overview.md index d6d76667761b2..86a9668a87913 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/lakehouse/catalog-overview.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/lakehouse/catalog-overview.md @@ -111,7 +111,7 @@ mysql> SHOW CATALOGS; +-----------+-----------------+----------+-----------+-------------------------+---------------------+------------------------+ ``` -可以通过 [SHOW CREATE CATALOG](../sql-manual/sql-statements/Show-Statements/SHOW-CREATE-CATALOG.md) 查看创建 Catalog 的语句。 +可以通过 [SHOW CREATE CATALOG](../sql-manual/sql-statements/catalog/SHOW-CREATE-CATALOG) 查看创建 Catalog 的语句。 ### 切换数据目录 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-acceleration/materialized-view/async-materialized-view/functions-and-demands.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-acceleration/materialized-view/async-materialized-view/functions-and-demands.md index 9b7f0a1c84f9d..cac8d36dd81c3 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-acceleration/materialized-view/async-materialized-view/functions-and-demands.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-acceleration/materialized-view/async-materialized-view/functions-and-demands.md @@ -143,7 +143,7 @@ SELECT * FROM lineitem; 如果基表的数据频繁变更,不太适合使用此种触发方式,因为会频繁构建物化刷新任务,消耗过多资源。 ::: -详情参考 [REFRESH MATERIALIZED VIEW](../../../sql-manual/sql-statements/Utility-Statements/REFRESH-MATERIALIZED-VIEW/) +详情参考 [REFRESH MATERIALIZED VIEW](../../../sql-manual/sql-statements/table-and-view/materialized-view/REFRESH-MATERIALIZED-VIEW) #### 示例如下 @@ -471,7 +471,7 @@ SELECT * FROM t1; 此外,如果分区字段为字符串类型,可以通过设置物化视图的 `partition_date_format` 属性来指定日期格式,例如 `'%Y-%m-%d'`。 -详情参考 [CREATE ASYNC MATERIALIZED VIEW](../../../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-ASYNC-MATERIALIZED-VIEW) +详情参考 [CREATE ASYNC MATERIALIZED VIEW](../../../sql-manual/sql-statements/table-and-view/materialized-view/CREATE-ASYNC-MATERIALIZED-VIEW) ### SQL 定义 @@ -1039,7 +1039,7 @@ SET( DROP MATERIALIZED VIEW mv_1; ``` -详情参考 [DROP ASYNC MATERIALIZED VIEW](../../../sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-ASYNC-MATERIALIZED-VIEW) +详情参考 [DROP ASYNC MATERIALIZED VIEW](../../../sql-manual/sql-statements/table-and-view/materialized-view/DROP-ASYNC-MATERIALIZED-VIEW) ### 查看物化视图创建语句 @@ -1047,20 +1047,20 @@ DROP MATERIALIZED VIEW mv_1; SHOW CREATE MATERIALIZED VIEW mv_1; ``` -详情参考 [SHOW CREATE MATERIALIZED VIEW](../../../sql-manual/sql-statements/Show-Statements/SHOW-CREATE-MATERIALIZED-VIEW/) +详情参考 [SHOW CREATE MATERIALIZED VIEW](../../../sql-manual/sql-statements/table-and-view/materialized-view/SHOW-CREATE-MATERIALIZED-VIEW) ### 暂停物化视图 -详情参考 [PAUSE MATERIALIZED VIEW](../../../sql-manual/sql-statements/Utility-Statements/PAUSE-MATERIALIZED-VIEW) +详情参考 [PAUSE MATERIALIZED VIEW](../../../sql-manual/sql-statements/table-and-view/materialized-view/PAUSE-MATERIALIZED-VIEW) ### 启用物化视图 -详情参考 [RESUME MATERIALIZED VIEW](../../../sql-manual/sql-statements/Utility-Statements/RESUME-MATERIALIZED-VIEW) +详情参考 [RESUME MATERIALIZED VIEW](../../../sql-manual/sql-statements/table-and-view/materialized-view/RESUME-MATERIALIZED-VIEW) ### 取消物化视图刷新任务 -详情参考 [CANCEL MATERIALIZED VIEW TASK](../../../sql-manual/sql-statements/Utility-Statements/CANCEL-MATERIALIZED-VIEW-TASK) +详情参考 [CANCEL MATERIALIZED VIEW TASK](../../../sql-manual/sql-statements/table-and-view/materialized-view/CANCEL-MATERIALIZED-VIEW-TASK) ### 元数据查询 @@ -1205,12 +1205,12 @@ show partitions from mv11; 主要查看 `SyncWithBaseTables` 字段是否为 true。false 表示此分区不可用于透明改写。 -详情参考 [SHOW PARTITIONS](../../../sql-manual/sql-statements/Show-Statements/SHOW-PARTITIONS) +详情参考 [SHOW PARTITIONS](../../../sql-manual/sql-statements/table-and-view/table/SHOW-PARTITIONS) #### 查看物化视图表结构 -详情参考 [DESCRIBE](../../../sql-manual/sql-statements/Utility-Statements/DESCRIBE) +详情参考 [DESCRIBE](../../../sql-manual/sql-statements/table-and-view/table/DESC-TABLE) ### 相关配置 #### Session Variables 开关 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-data/join.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-data/join.md index 9139fe4a79099..8a018314793aa 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-data/join.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-data/join.md @@ -32,7 +32,7 @@ under the License. ## Doris 支持的 JOIN 类型 -- INNER JOIN(内连接):对左表每一行和右表所有行进行 JOIN 条件比较,返回两个表中满足 JOIN 条件的匹配行。详细信息请参考 [SELECT](../sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/SELECT/) 中有关于联接查询的语法定义 +- INNER JOIN(内连接):对左表每一行和右表所有行进行 JOIN 条件比较,返回两个表中满足 JOIN 条件的匹配行。详细信息请参考 [SELECT](../sql-manual/sql-statements/data-query/SELECT) 中有关于联接查询的语法定义 - LEFT JOIN(左连接):在 INNER JOIN 的结果集基础上。如果左表的行在右表中没有匹配,则返回左表的所有行,同时右表对应的列显示为 NULL。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-data/udf/java-user-defined-function.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-data/udf/java-user-defined-function.md index 611d4367754e0..7c14f66e179e8 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-data/udf/java-user-defined-function.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-data/udf/java-user-defined-function.md @@ -105,7 +105,7 @@ insert into test_table values (6, 666.66, "d,e"); } ``` -2. 在 Doris 中注册创建 Java-UDF 函数。更多语法帮助可参阅 [CREATE FUNCTION](../../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FUNCTION.md). +2. 在 Doris 中注册创建 Java-UDF 函数。更多语法帮助可参阅 [CREATE FUNCTION](../../sql-manual/sql-statements/function/CREATE-FUNCTION). ```sql CREATE FUNCTION java_udf_add_one(int) RETURNS int PROPERTIES ( @@ -117,7 +117,7 @@ insert into test_table values (6, 666.66, "d,e"); ``` 3. 用户使用 UDF 必须拥有对应数据库的 `SELECT` 权限。 - 如果想查看注册成功的对应 UDF 函数,可以使用[SHOW FUNCTIONS](../../sql-manual/sql-statements/Show-Statements/SHOW-FUNCTIONS.md) 命令。 + 如果想查看注册成功的对应 UDF 函数,可以使用[SHOW FUNCTIONS](../../sql-manual/sql-statements/function/SHOW-FUNCTIONS) 命令。 ``` sql select id,java_udf_add_one(id) from test_table; @@ -129,7 +129,7 @@ insert into test_table values (6, 666.66, "d,e"); +------+----------------------+ ``` -4. 当不再需要 UDF 函数时,可以通过下述命令来删除一个 UDF 函数,可以参考 [DROP FUNCTION](../../sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-FUNCTION.md) +4. 当不再需要 UDF 函数时,可以通过下述命令来删除一个 UDF 函数,可以参考 [DROP FUNCTION](../../sql-manual/sql-statements/function/DROP-FUNCTION) 另外,如果定义的 UDF 中需要加载很大的资源文件,或者希望可以定义全局的 static 变量,可以参照文档下方的 static 变量加载方式。 @@ -316,7 +316,7 @@ public void destroy(State state) { -2. 在 Doris 中注册创建 Java-UADF 函数。更多语法帮助可参阅 [CREATE FUNCTION](../../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FUNCTION.md). +2. 在 Doris 中注册创建 Java-UADF 函数。更多语法帮助可参阅 [CREATE FUNCTION](../../sql-manual/sql-statements/function/CREATE-FUNCTION). ```sql CREATE AGGREGATE FUNCTION simple_demo(INT) RETURNS INT PROPERTIES ( @@ -369,7 +369,7 @@ UDTF 和 UDF 函数一样,需要用户自主实现一个 `evaluate` 方法, ``` 2. 在 Doris 中注册创建 Java-UDTF 函数。此时会注册两个 UTDF 函数,另外一个是在函数名后面加上`_outer`后缀,其中带后缀`_outer` 的是针对结果为 0 行时的特殊处理,具体可查看[OUTER 组合器](../../sql-manual/sql-functions/table-functions/explode-numbers-outer.md)。 -更多语法帮助可参阅 [CREATE FUNCTION](../../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FUNCTION.md). +更多语法帮助可参阅 [CREATE FUNCTION](../../sql-manual/sql-statements/function/CREATE-FUNCTION). ```sql CREATE TABLES FUNCTION java-utdf(string, string) RETURNS array PROPERTIES ( diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/releasenotes/v1.1/release-1.1.0.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/releasenotes/v1.1/release-1.1.0.md index ff7cca49b1302..981c270f932ce 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/releasenotes/v1.1/release-1.1.0.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/releasenotes/v1.1/release-1.1.0.md @@ -89,11 +89,11 @@ Iceberg 外部表为 Apache Doris 提供了直接访问存储在 Iceberg 数据 - 在 TPC-H 测试数据集的全部 22 个 SQL 上,1.1 版本均优于 0.15 版本,整体性能约提升了 4.5 倍,部分场景性能达到了十余倍的提升; -![](/images/release-note-1.1.0-SSB.png) +![release-note-1.1.0-SSB](/images/release-note-1.1.0-SSB.png)

SSB 测试数据集

-![](/images/release-note-1.1.0-TPC-H.png) +![release-note-1.1.0-TPC-H](/images/release-note-1.1.0-TPC-H.png)

TPC-H 测试数据集

diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/releasenotes/v2.1/release-2.1.0.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/releasenotes/v2.1/release-2.1.0.md index ce4419d0b8e37..4863d5afbb2ae 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/releasenotes/v2.1/release-2.1.0.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/releasenotes/v2.1/release-2.1.0.md @@ -858,7 +858,7 @@ JOB e_daily :::caution 注意事项 -当前 Job Scheduler 仅支持 Insert 内表,参考文档:[CREATE-JOB](../../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-JOB.md) +当前 Job Scheduler 仅支持 Insert 内表,参考文档:[CREATE-JOB](../../sql-manual/sql-statements/job/CREATE-JOB) ::: diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/releasenotes/v2.1/release-2.1.4.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/releasenotes/v2.1/release-2.1.4.md index 8464a59f25649..323446b5a29d6 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/releasenotes/v2.1/release-2.1.4.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/releasenotes/v2.1/release-2.1.4.md @@ -96,7 +96,7 @@ under the License. - 支持 `show storage policy using` 语句:支持查看所有或指定存储策略关联的表和分区。 - 关于更多信息,请参考文档:[SQL 语句 - SHOW](../../sql-manual/sql-statements/Show-Statements/SHOW-STORAGE-POLICY-USING.md) + 关于更多信息,请参考文档:[SQL 语句 - SHOW](../../sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-POLICY-USING) - **支持 BE 侧的 JVM 指标:** 通过在 `be.conf` 配置文件中设置`enable_jvm_monitor=true`,可以启用对 BE 节点 JVM 的监控和指标收集,有助于了解 BE JVM 的资源使用情况,以便进行故障排除和性能优化。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/group-concat.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/group-concat.md index 0fd25a72e2dba..ff40fa49751ff 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/group-concat.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/group-concat.md @@ -24,25 +24,37 @@ specific language governing permissions and limitations under the License. --> -## group_concat + ## 描述 + +GROUP_CONCAT 函数将结果集中的多行结果连接成一个字符串 + ## 语法 -`VARCHAR GROUP_CONCAT([DISTINCT] VARCHAR str[, VARCHAR sep] [ORDER BY { col_name | expr} [ASC | DESC]])` +```sql +GROUP_CONCAT([DISTINCT] [, ] [ORDER BY { | } [ASC | DESC]]) +``` +## 参数 -该函数是类似于 sum() 的聚合函数,group_concat 将结果集中的多行结果连接成一个字符串。第二个参数 sep 为字符串之间的连接符号,该参数可以省略。该函数通常需要和 group by 语句一起使用。 +| 参数 | 说明 | +| -- | -- | +| `` | 必选。需要连接值的表达式 | +| `` | 可选。字符串之间的连接符号 | +| `` | 可选。用于指定排序的列 | +| `` | 可选。用于指定排序的表达式 | -支持Order By进行多行结果的排序,排序和聚合列可不同。 +## 返回值 -:::caution -`group_concat`暂不支持`distinct`和`order by`一起用。 -::: +返回 VARCHAR 类型的数值。 ## 举例 +```sql +select value from test; ``` -mysql> select value from test; + +```text +-------+ | value | +-------+ @@ -51,35 +63,52 @@ mysql> select value from test; | c | | c | +-------+ +``` + +```sql +select GROUP_CONCAT(value) from test; +``` -mysql> select GROUP_CONCAT(value) from test; +```text +-----------------------+ | GROUP_CONCAT(`value`) | +-----------------------+ -| a, b, c, c | +| a, b, c, c | +-----------------------+ +``` -mysql> select GROUP_CONCAT(DISTINCT value) from test; +```sql +select GROUP_CONCAT(DISTINCT value) from test; +``` + +```text +-----------------------+ | GROUP_CONCAT(`value`) | +-----------------------+ | a, b, c | +-----------------------+ +``` + +```sql +select GROUP_CONCAT(value, " ") from test; +``` -mysql> select GROUP_CONCAT(value, " ") from test; +```text +----------------------------+ | GROUP_CONCAT(`value`, ' ') | +----------------------------+ | a b c c | +----------------------------+ +``` + +```sql +select GROUP_CONCAT(value, NULL) from test; +``` -mysql> select GROUP_CONCAT(value, NULL) from test; +```text +----------------------------+ | GROUP_CONCAT(`value`, NULL)| +----------------------------+ | NULL | +----------------------------+ ``` - -### keywords -GROUP_CONCAT,GROUP,CONCAT diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/histogram.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/histogram.md index e02ef61b695e6..6a7303152c8ee 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/histogram.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/histogram.md @@ -24,31 +24,53 @@ specific language governing permissions and limitations under the License. --> -## HISTOGRAM + ## 描述 + +HISTOGRAM(直方图)函数用于描述数据分布情况,它使用“等高”的分桶策略,并按照数据的值大小进行分桶,并用一些简单的数据来描述每个桶,比如落在桶里的值的个数。 + +## 别名 + +HIST + ## 语法 -`histogram(expr[, INT num_buckets])` +```sql +HISTOGRAM([, ]) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `expr` | 需要获取第一个值的表达式 | +| `num_buckets` | 可选。用于限制直方图桶(bucket)的数量,默认值 128 | -histogram(直方图)函数用于描述数据分布情况,它使用“等高”的分桶策略,并按照数据的值大小进行分桶,并用一些简单的数据来描述每个桶,比如落在桶里的值的个数。主要用于优化器进行区间查询的估算。 -函数结果返回空或者 Json 字符串。 +## 返回值 -参数说明: -- num_buckets:可选项。用于限制直方图桶(bucket)的数量,默认值 128。 +返回直方图估算后的 JSON 类型的值。特殊情况: +- 当参数为NULL时,返回 NULL。 -别名函数:`hist(expr[, INT num_buckets])` ## 举例 +```sql +SELECT histogram(c_float) FROM histogram_test; ``` -MySQL [test]> SELECT histogram(c_float) FROM histogram_test; + +```text +-------------------------------------------------------------------------------------------------------------------------------------+ | histogram(`c_float`) | +-------------------------------------------------------------------------------------------------------------------------------------+ | {"num_buckets":3,"buckets":[{"lower":"0.1","upper":"0.1","count":1,"pre_sum":0,"ndv":1},...]} | +-------------------------------------------------------------------------------------------------------------------------------------+ +``` + +```sql +SELECT histogram(c_string, 2) FROM histogram_test; +``` -MySQL [test]> SELECT histogram(c_string, 2) FROM histogram_test; +```text +-------------------------------------------------------------------------------------------------------------------------------------+ | histogram(`c_string`) | +-------------------------------------------------------------------------------------------------------------------------------------+ @@ -58,7 +80,7 @@ MySQL [test]> SELECT histogram(c_string, 2) FROM histogram_test; 查询结果说明: -``` +```json { "num_buckets": 3, "buckets": [ @@ -87,6 +109,7 @@ MySQL [test]> SELECT histogram(c_string, 2) FROM histogram_test; } ``` +```text 字段说明: - num_buckets:桶的数量 - buckets:直方图所包含的桶 @@ -97,7 +120,4 @@ MySQL [test]> SELECT histogram(c_string, 2) FROM histogram_test; - ndv:桶内不同值的个数 > 直方图总的元素数量 = 最后一个桶的元素数量(count)+ 前面桶的元素总量(pre_sum)。 - -### keywords - -HISTOGRAM, HIST +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/hll-raw-agg.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/hll-raw-agg.md index e877ef4916b80..edd685aef1ebe 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/hll-raw-agg.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/hll-raw-agg.md @@ -1,6 +1,6 @@ --- { - "title": "hll_raw_agg", + "title": "HLL_RAW_AGG", "language": "zh-CN" } --- @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md index 1826b413075ec..2d06c5a0f2d5b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md @@ -24,29 +24,36 @@ specific language governing permissions and limitations under the License. --> -## HLL_UNION_AGG ## 描述 -## 语法 -`HLL_UNION_AGG(hll)` +HLL_UNION_AGG 函数是一种聚合函数,主要用于将多个 HyperLogLog 数据结构合并,估算合并后基数的近似值。 + + +## 语法 +```sql +hll_union_agg() +``` -HLL是基于HyperLogLog算法的工程实现,用于保存HyperLogLog计算过程的中间结果 +## 参数 -它只能作为表的value列类型、通过聚合来不断的减少数据量,以此来实现加快查询的目的 +| 参数 | 说明 | +| -- | -- | +| `` | 需要被计算HyperLogLog类型表达式 | -基于它得到的是一个估算结果,误差大概在1%左右,hll列是通过其它列或者导入数据里面的数据生成的 +## 返回值 -导入的时候通过hll_hash函数来指定数据中哪一列用于生成hll列,它常用于替代count distinct,通过结合rollup在业务上用于快速计算uv等 +返回 BIGINT 类型的基数值。 ## 举例 +```sql +select HLL_UNION_AGG(uv_set) from test_uv; ``` -MySQL > select HLL_UNION_AGG(uv_set) from test_uv;; + +```text +-------------------------+ | HLL_UNION_AGG(`uv_set`) | +-------------------------+ | 17721 | +-------------------------+ ``` -### keywords -HLL_UNION_AGG,HLL,UNION,AGG diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/intersect-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/intersect-count.md index 5d3b8b939f532..c054e126f6dda 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/intersect-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/intersect-count.md @@ -22,35 +22,52 @@ specific language governing permissions and limitations under the License. --> -## intersect_count + ## 描述 + +INTERSECT_COUNT 函数用于计算 Bitmap 数据结构的交集元素的数量。 + ## 语法 -`BITMAP INTERSECT_COUNT(bitmap_column, column_to_filter, filter_values)` -聚合函数,求bitmap交集大小的函数, 不要求数据分布正交 -第一个参数是Bitmap列,第二个参数是用来过滤的维度列,第三个参数是变长参数,含义是过滤维度列的不同取值 +```sql +INTERSECT_COUNT(, , ) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 需要获取第一个值的表达式 | +| `` | 可选。需要进行过滤的维度列 | +| `` | 可选。过滤维度列的不同取值 | + +## 返回值 + +返回 BIGINT 类型的值。 ## 举例 +```sql +select dt,bitmap_to_string(user_id) from pv_bitmap where dt in (3,4); ``` -MySQL [test_query_qa]> select dt,bitmap_to_string(user_id) from pv_bitmap where dt in (3,4); + +```text +------+-----------------------------+ | dt | bitmap_to_string(`user_id`) | +------+-----------------------------+ -| 4 | 1,2,3 | -| 3 | 1,2,3,4,5 | +| 4 | 1,2,3 | +| 3 | 1,2,3,4,5 | +------+-----------------------------+ -2 rows in set (0.012 sec) +``` -MySQL [test_query_qa]> select intersect_count(user_id,dt,3,4) from pv_bitmap; +```sql +select intersect_count(user_id,dt,3,4) from pv_bitmap; +``` + +```text +----------------------------------------+ | intersect_count(`user_id`, `dt`, 3, 4) | +----------------------------------------+ | 3 | +----------------------------------------+ -1 row in set (0.014 sec) ``` - -### keywords - - INTERSECT_COUNT,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/kurt.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/kurt.md index ed4aad61341cd..c027c193bd5cc 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/kurt.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/kurt.md @@ -26,41 +26,65 @@ under the License. ## 描述 -kurtosis 返回 expr 表达式的[峰度值](https://en.wikipedia.org/wiki/Kurtosis)。此函数使用的公式为 第四阶中心矩 / (方差的平方) - 3,当方差为零时,kurtosis 将返回 NULL。 +KURTOSIS 函数用于计算数据的[峰度值](https://en.wikipedia.org/wiki/Kurtosis)。此函数使用的公式为 第四阶中心矩 / (方差的平方) - 3。 + +## 别名 + +KURT_POP,KURTOSIS ## 语法 -`kurtosis(expr)` +```sql +KURTOSIS() +``` ## 参数说明 -TinyInt/SmallInt/Integer/BigInt/Float/Double, Decimal 会被 cast 成浮点数参与运算。 +| 参数 | 说明 | +| -- | -- | +| `` | 需要获取值的表达式 | -## 返回值说明 +## 返回值 -`Double` +返回 DOUBLE 类型的值。特殊情况: + +- 当方差为零时,返回 NULL ## 举例 ```sql -create table statistic_test(tag int, val1 double not null, val2 double null) distributed by hash(tag) properties("replication_num"="1"); +select * from statistic_test; +``` -insert into statistic_test values (1, -10, -10),(2, -20, NULL),(3, 100, NULL),(4, 100, NULL),(5, 1000,1000); +```text ++-----+------+------+ +| tag | val1 | val2 | ++-----+------+------+ +| 1 | -10 | -10| +| 2 | -20 | NULL| +| 3 | 100 | NULL| +| 4 | 100 | NULL| +| 5 | 1000 | 1000| ++-----+------+------+ +``` -// NULL 值会被忽略 +```sql select kurt(val1), kurt(val2) from statistic_test; --------------- +``` +```text +-------------------+--------------------+ | kurt(val1) | kurt(val2) | +-------------------+--------------------+ | 0.162124583734851 | -1.3330994719286338 | +-------------------+--------------------+ -1 row in set (0.02 sec) +``` +```sql // 每组只有一行数据,结果为 NULL select kurt(val1), kurt(val2) from statistic_test group by tag; --------------- +``` +```text +------------+------------+ | kurt(val1) | kurt(val2) | +------------+------------+ @@ -70,9 +94,5 @@ select kurt(val1), kurt(val2) from statistic_test group by tag; | NULL | NULL | | NULL | NULL | +------------+------------+ -5 rows in set (0.02 sec) ``` -## 相关命令 - -[skew](./skew.md) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/linear-histogram.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/linear-histogram.md index 42c6348ababdb..ded3196246484 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/linear-histogram.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/linear-histogram.md @@ -24,29 +24,46 @@ specific language governing permissions and limitations under the License. --> -## Description -### Syntax +## 描述 -`LINEAR_HISTOGRAM(expr, DOUBLE interval[, DOUBLE offset)` +LINEAR_HISTOGRAM 函数用于描述数据分布情况,它使用“等宽”的分桶策略,并按照数据的值大小进行分桶。 -linear_histogram 函数用于描述数据分布情况,它使用“等宽”的分桶策略,并按照数据的值大小进行分桶。 +## 语法 -参数说明: +```sql +`LINEAR_HISTOGRAM(, DOUBLE [, DOUBLE )` +``` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `interval` | 必须。桶的宽度 | +| `offset` | 可选。默认为 0,范围是 `[0, interval)` | -- `interval`:必须项。桶的宽度。 -- `offset`:可选项。默认为 0,范围是 `[0, interval)`。 +## 返回值 -## Example +返回计算后的 JSON 类型的值。 +## 举例 + +```sql +select linear_histogram(a, 2) from histogram_test; ``` -mysql> select linear_histogram(a, 2) from histogram_test; + +```text +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | linear_histogram(a, cast(2 as DOUBLE)) | +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | {"num_buckets":6,"buckets":[{"lower":0.0,"upper":2.0,"count":2,"acc_count":2},{"lower":2.0,"upper":4.0,"count":4,"acc_count":6},{"lower":4.0,"upper":6.0,"count":4,"acc_count":10},{"lower":6.0,"upper":8.0,"count":4,"acc_count":14},{"lower":8.0,"upper":10.0,"count":4,"acc_count":18},{"lower":10.0,"upper":12.0,"count":2,"acc_count":20}]} | +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +``` -mysql> select linear_histogram(a, 2, 1) from histogram_test; +```sql +select linear_histogram(a, 2, 1) from histogram_test; +``` + +```text +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | linear_histogram(a, cast(2 as DOUBLE), cast(1 as DOUBLE)) | +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ @@ -54,6 +71,7 @@ mysql> select linear_histogram(a, 2, 1) from histogram_test; +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ``` +```text 字段说明: - `num_buckets`:桶的数量。 @@ -62,8 +80,4 @@ mysql> select linear_histogram(a, 2, 1) from histogram_test; - `upper`:桶的上界。(不包含在内) - `count`:桶内包含的元素数量。 - `acc_count`:前面桶与当前桶元素的累计总量。 - - -## Keywords - -LINEAR_HISTOGRAM \ No newline at end of file +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/map-agg.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/map-agg.md index 8327da387592b..a5ce0daf7d28f 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/map-agg.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/map-agg.md @@ -24,17 +24,32 @@ specific language governing permissions and limitations under the License. --> -## MAP_AGG ## 描述 + +MAP_AGG 函数用于根据多行数据中的键值对形成一个映射结构。 + ## 语法 -`MAP_AGG(expr1, expr2)` +`MAP_AGG(, )` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `` | 用于指定作为键的表达式。 | +| `` | 用于指定作为对应的值的表达式。 | -返回一个 map, 由 expr1 作为键,expr2 作为对应的值。 +## 返回值 + +返回映射后的 MAP 类型的值。 ## 举例 + +```sql +select `n_nationkey`, `n_name`, `n_regionkey` from `nation`; ``` -MySQL > select `n_nationkey`, `n_name`, `n_regionkey` from `nation`; + +```text +-------------+----------------+-------------+ | n_nationkey | n_name | n_regionkey | +-------------+----------------+-------------+ @@ -64,8 +79,13 @@ MySQL > select `n_nationkey`, `n_name`, `n_regionkey` from `nation`; | 23 | UNITED KINGDOM | 3 | | 24 | UNITED STATES | 1 | +-------------+----------------+-------------+ +``` + +```sql +select `n_regionkey`, map_agg(`n_nationkey`, `n_name`) from `nation` group by `n_regionkey`; +``` -MySQL > select `n_regionkey`, map_agg(`n_nationkey`, `n_name`) from `nation` group by `n_regionkey`; +```text +-------------+---------------------------------------------------------------------------+ | n_regionkey | map_agg(`n_nationkey`, `n_name`) | +-------------+---------------------------------------------------------------------------+ @@ -75,8 +95,13 @@ MySQL > select `n_regionkey`, map_agg(`n_nationkey`, `n_name`) from `nation` gro | 4 | {4:"EGYPT", 10:"IRAN", 11:"IRAQ", 13:"JORDAN", 20:"SAUDI ARABIA"} | | 2 | {8:"INDIA", 9:"INDONESIA", 12:"JAPAN", 18:"CHINA", 21:"VIETNAM"} | +-------------+---------------------------------------------------------------------------+ +``` + +```sql +select n_regionkey, map_agg(`n_name`, `n_nationkey` % 5) from `nation` group by `n_regionkey`; +``` -MySQL > select n_regionkey, map_agg(`n_name`, `n_nationkey` % 5) from `nation` group by `n_regionkey`; +```text +-------------+------------------------------------------------------------------------+ | n_regionkey | map_agg(`n_name`, (`n_nationkey` % 5)) | +-------------+------------------------------------------------------------------------+ @@ -87,5 +112,3 @@ MySQL > select n_regionkey, map_agg(`n_name`, `n_nationkey` % 5) from `nation` g | 4 | {"EGYPT":4, "IRAN":0, "IRAQ":1, "JORDAN":3, "SAUDI ARABIA":0} | +-------------+------------------------------------------------------------------------+ ``` -### keywords -MAP_AGG diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/max-by.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/max-by.md index 7c412ebfc0449..41bfcd7756d81 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/max-by.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/max-by.md @@ -24,18 +24,35 @@ specific language governing permissions and limitations under the License. --> -## MAX_BY + ## 描述 + +MAX_BY 函数用于根据指定列的最大值,返回对应的的关联值。 + ## 语法 -`MAX_BY(expr1, expr2)` +```sql +MAX_BY(, ) +``` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `` | 用于指定对应关联的表达式。 | +| `` | 用于指定最大值统计的表达式。 | +## 返回值 -返回与 expr2 的最大值关联的 expr1 的值。 +返回与输入表达式 相同的数据类型。 ## 举例 + +```sql +select * from tbl; ``` -MySQL > select * from tbl; + +```text +------+------+------+------+ | k1 | k2 | k3 | k4 | +------+------+------+------+ @@ -44,13 +61,16 @@ MySQL > select * from tbl; | 4 | 3 | 2 | 1 | | 3 | 4 | 2 | 1 | +------+------+------+------+ +``` + +```sql +select max_by(k1, k4) from tbl; +``` -MySQL > select max_by(k1, k4) from tbl; +```text +--------------------+ | max_by(`k1`, `k4`) | +--------------------+ | 0 | +--------------------+ ``` -### keywords -MAX_BY diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/max.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/max.md index 16bdd21bfd58b..34175045d7823 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/max.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/max.md @@ -24,23 +24,37 @@ specific language governing permissions and limitations under the License. --> -## MAX + ## 描述 + +MAX 函数返回表达式的最大值。 + ## 语法 -`MAX(expr)` +```sql +MAX() +``` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `` | 需要获取值的表达式 | +## 返回值 -返回expr表达式的最大值 +返回与输入表达式相同的数据类型。 ## 举例 + +```sql +select max(scan_rows) from log_statis group by datetime; ``` -MySQL > select max(scan_rows) from log_statis group by datetime; + +```text +------------------+ | max(`scan_rows`) | +------------------+ | 4671587 | +------------------+ ``` -### keywords -MAX diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/median.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/median.md index 1125b71ac0711..9623f9b0c136a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/median.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/median.md @@ -1,6 +1,6 @@ --- { - "title": "median", + "title": "MEDIAN", "language": "zh-CN" } --- @@ -23,3 +23,36 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## 描述 + +MEDIAN 函数返回表达式的中位数 + +## 语法 + +```sql +MEDIAN() +``` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `` | 需要获取值的表达式 | + +## 返回值 + +返回与输入表达式相同的数据类型。 + +## 举例 +```sql +select median(scan_rows) from log_statis group by datetime; +``` + +```text ++---------------------+ +| median(`scan_rows`) | ++---------------------+ +| 50 | ++---------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/min-by.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/min-by.md index eceeb6427307f..3ccfa4f885696 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/min-by.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/min-by.md @@ -24,18 +24,34 @@ specific language governing permissions and limitations under the License. --> -## MIN_BY + ## 描述 + +MIN_BY 函数用于根据指定列的最小值,返回对应的的关联值。 + ## 语法 -`MIN_BY(expr1, expr2)` +```sql +MIN_BY(, ) +``` + +## 参数说明 +| 参数 | 说明 | +| -- | -- | +| `` | 用于指定对应关联的表达式。 | +| `` | 用于指定最小值统计的表达式。 | -返回与 expr2 的最小值关联的 expr1 的值。 +## 返回值 + +返回与输入表达式 相同的数据类型。 ## 举例 +```sql +select * from tbl; ``` -MySQL > select * from tbl; + +```text +------+------+------+------+ | k1 | k2 | k3 | k4 | +------+------+------+------+ @@ -44,13 +60,16 @@ MySQL > select * from tbl; | 4 | 3 | 2 | 1 | | 3 | 4 | 2 | 1 | +------+------+------+------+ +``` + +```sql +select min_by(k1, k4) from tbl; +``` -MySQL > select min_by(k1, k4) from tbl; +```text +--------------------+ | min_by(`k1`, `k4`) | +--------------------+ | 4 | +--------------------+ ``` -### keywords -MIN_BY diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/min.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/min.md index b765ab423683b..dd261dd5c5d18 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/min.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/min.md @@ -24,23 +24,36 @@ specific language governing permissions and limitations under the License. --> -## MIN ## 描述 + +MIN 函数返回表达式的最小值。 + ## 语法 -`MIN(expr)` +```sql +MIN() +``` + +## 参数说明 +| 参数 | 说明 | +| -- | -- | +| `` | 需要获取值的表达式 | -返回expr表达式的最小值 +## 返回值 + +返回与输入表达式相同的数据类型。 ## 举例 + +```sql +select MIN(scan_rows) from log_statis group by datetime; ``` -MySQL > select min(scan_rows) from log_statis group by datetime; + +```text +------------------+ -| min(`scan_rows`) | +| MIN(`scan_rows`) | +------------------+ | 0 | +------------------+ ``` -### keywords -MIN diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md index 5d1bfb22a303c..27b5ea423724a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md @@ -1,6 +1,6 @@ --- { - "title": "orthogonal_bitmap_expr_calculate_count", + "title": "ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT", "language": "zh-CN" } --- @@ -23,3 +23,52 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## 描述 + +ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT 函数返回对 Bitmap 表达式进行交并差计算后集合中的元素数量 + +## 语法 + +```sql +ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT(, , ) +``` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `bitmap_column` | 需要获取值的 Bitmap 类型表达式 | +| `column_to_filter` | 过滤的维度列,即计算的 Key 列 | +| `input_string` | 计算表达式字符串,含义是依据 Key 列进行 Bitmap 交并差集表达式计算,表达式支持的计算符:& 代表交集计算,\| 代表并集计算,- 代表差集计算, ^ 代表异或计算,\ 代表转义字符 | + +## 返回值 + +返回 BIGINT 类型的值。 + +## 举例 +```sql +select orthogonal_bitmap_expr_calculate_count(user_id, tag, '(833736|999777)&(1308083|231207)&(1000|20000-30000)') from user_tag_bitmap where tag in (833736,999777,130808,231207,1000,20000,30000); +注:1000、20000、30000 等整形tag,代表用户不同标签 +``` + +```text ++-----------------------------------------------------------------------------------------------------------------+ +| orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(833736|999777)&(1308083|231207)&(1000|20000-30000)') | ++-----------------------------------------------------------------------------------------------------------------+ +| 1000 | ++-----------------------------------------------------------------------------------------------------------------+ +``` + +```sql +select orthogonal_bitmap_expr_calculate_count(user_id, tag, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23') from user_str_tag_bitmap where tag in ('A:a/b', 'B:2-4', 'C:1', 'D:12', 'E:23'); + 注:'A:a/b', 'B:2-4'等是字符串类型tag,代表用户不同标签, 其中'B:2-4'需要转义成'B:2\\-4' +``` + +```text ++---------------------------------------------------------------------------------------------+ +| orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23') | ++---------------------------------------------------------------------------------------------+ +| 30 | ++---------------------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md index 07f1033cb6edd..f3b457bf09e51 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md @@ -1,6 +1,6 @@ --- { - "title": "orthogonal_bitmap_expr_calculate", + "title": "ORTHOGONAL_BITMAP_EXPR_CALCULATE", "language": "zh-CN" } --- @@ -23,3 +23,52 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## 描述 + +ORTHOGONAL_BITMAP_EXPR_CALCULATE 函数返回对 Bitmap 表达式进行交并差计算后的集合 + +## 语法 + +```sql +ORTHOGONAL_BITMAP_EXPR_CALCULATE(, , ) +``` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `bitmap_column` | 需要获取值的 Bitmap 类型表达式 | +| `column_to_filter` | 过滤的维度列,即计算的 Key 列 | +| `input_string` | 计算表达式字符串,含义是依据 Key 列进行 Bitmap 交并差集表达式计算,表达式支持的计算符:& 代表交集计算,\| 代表并集计算,- 代表差集计算, ^ 代表异或计算,\ 代表转义字符 | + +## 返回值 + +返回 BITMAP 类型的集合。 + +## 举例 +```sql +select bitmap_count(orthogonal_bitmap_expr_calculate(user_id, tag, '(833736|999777)&(1308083|231207)&(1000|20000-30000)')) from user_tag_bitmap where tag in (833736,999777,130808,231207,1000,20000,30000); +注:1000、20000、30000等整形tag,代表用户不同标签 +``` + +```text ++-------------------------------------------------------------------------------------------------------------------------------+ +| bitmap_count(orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(833736|999777)&(1308083|231207)&(1000|20000-30000)')) | ++-------------------------------------------------------------------------------------------------------------------------------+ +| 1000 | ++-------------------------------------------------------------------------------------------------------------------------------+ +``` + +```sql +select bitmap_count(orthogonal_bitmap_expr_calculate(user_id, tag, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23')) from user_str_tag_bitmap where tag in ('A:a/b', 'B:2-4', 'C:1', 'D:12', 'E:23'); + 注:'A:a/b', 'B:2-4'等是字符串类型tag,代表用户不同标签, 其中'B:2-4'需要转义成'B:2\\-4' +``` + +```text ++-----------------------------------------------------------------------------------------------------------+ +| bitmap_count(orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23')) | ++-----------------------------------------------------------------------------------------------------------+ +| 30 | ++-----------------------------------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md index a0ad89d31e92c..fac7fbfeb7c9b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md @@ -1,6 +1,6 @@ --- { - "title": "orthogonal_bitmap_intersect_count", + "title": "ORTHOGONAL_BITMAP_INTERSECT_COUNT", "language": "zh-CN" } --- @@ -23,3 +23,39 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> +## 描述 + +ORTHOGONAL_BITMAP_INTERSECT_COUNT 函数返回对 Bitmap 表达式进行交集计算后集合中的元素数量 + +## 语法 + +```sql +ORTHOGONAL_BITMAP_INTERSECT_COUNT(, , ) +``` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `bitmap_column` | 需要获取值的 Bitmap 类型表达式 | +| `column_to_filter` | 可选。需要进行过滤的维度列 | +| `filter_values` | 可选。变长参数,用于过滤维度列的不同取值 | + + +## 返回值 + +返回 BIGINT 类型的值。 + +## 举例 + +```sql +select orthogonal_bitmap_intersect_count(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); +``` + +```text ++-------------------------------------------------------------------------------------+ +| orthogonal_bitmap_intersect_count(`members`, `tag_group`, 1150000, 1150001, 390006) | ++-------------------------------------------------------------------------------------+ +| 0 | ++-------------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md index f384ce2027a9a..2460c03a4a600 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md @@ -1,6 +1,6 @@ --- { - "title": "orthogonal_bitmap_intersect", + "title": "ORTHOGONAL_BITMAP_INTERSECT", "language": "zh-CN" } --- @@ -23,3 +23,39 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> +## 描述 + +ORTHOGONAL_BITMAP_INTERSECT 函数返回对 Bitmap 表达式进行交集集合 + +## 语法 + +```sql +ORTHOGONAL_BITMAP_INTERSECT(, , ) +``` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `bitmap_column` | 需要获取值的 Bitmap 类型表达式 | +| `column_to_filter` | 可选。需要进行过滤的维度列 | +| `filter_values` | 可选。变长参数,用于过滤维度列的不同取值 | + +## 返回值 + +返回 BITMAP 类型的集合。 + +## 举例 + +```sql +select orthogonal_bitmap_intersect(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); + +``` + +```text ++-------------------------------------------------------------------------------+ +| orthogonal_bitmap_intersect(`members`, `tag_group`, 1150000, 1150001, 390006) | ++-------------------------------------------------------------------------------+ +| NULL | ++-------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md index e35e4587be51a..4b1649eda9789 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md @@ -1,6 +1,6 @@ --- { - "title": "orthogonal_bitmap_union_count", + "title": "ORTHOGONAL_BITMAP_UNION_COUNT", "language": "zh-CN" } --- @@ -23,3 +23,38 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> +## 描述 + +ORTHOGONAL_BITMAP_UNION_COUNT 函数返回对 Bitmap 表达式进行并集计算后集合中的元素数量 + +## 语法 + +```sql +ORTHOGONAL_BITMAP_UNION_COUNT(, , ) +``` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `bitmap_column` | 需要获取值的 Bitmap 类型表达式 | +| `column_to_filter` | 可选。需要进行过滤的维度列 | +| `filter_values` | 可选。变长参数,用于过滤维度列的不同取值 | + +## 返回值 + +返回 BITMAP 类型的集合。 + +## 举例 + +```sql +select ORTHOGONAL_BITMAP_UNION_COUNT(members) from tag_map where tag_group in ( 1150000, 1150001, 390006); +``` + +```text ++------------------------------------------+ +| orthogonal_bitmap_union_count(`members`) | ++------------------------------------------+ +| 286957811 | ++------------------------------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/percentile-approx.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/percentile-approx.md index 573dbcf572bea..091f30c0729b4 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/percentile-approx.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/percentile-approx.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,36 +22,72 @@ specific language governing permissions and limitations under the License. --> -## PERCENTILE_APPROX ## 描述 + +`PERCENTILE_APPROX` 函数用于计算近似百分位数,主要用于大数据集的场景。与 `PERCENTILE` 函数相比,它具有以下特点: + +1. 内存效率:使用固定大小的内存,即使在处理高基数列(数据量很大)时也能保持较低的内存消耗 +2. 性能优势:适合处理大规模数据集,计算速度快 +3. 精度可调:通过 compression 参数可以在精度和性能之间做平衡 + ## 语法 -`PERCENTILE_APPROX(expr, DOUBLE p[, DOUBLE compression])` +```sql +PERCENTILE_APPROX(,

[, ]) +``` +## 参数 -返回第p个百分位点的近似值,p的值介于0到1之间 +| 参数 | 说明 | +| -- | -- | +| `` | 需要计算百分位数的列 | +| `

` | 百分位数值,取值范围 `[0.0, 1.0]`,例如 `0.99` 表示 `99` 分位数 | +| `` | 可选参数,压缩度,取值范围 `[2048, 10000]`。值越大,精度越高,但内存消耗也越大。如果不指定或超出范围,则使用 `10000`。 | -compression参数是可选项,可设置范围是[2048, 10000],值越大,精度越高,内存消耗越大,计算耗时越长。 -compression参数未指定或设置的值在[2048, 10000]范围外,以10000的默认值运行 +## 返回值 -该函数使用固定大小的内存,因此对于高基数的列可以使用更少的内存,可用于计算tp99等统计值 +返回一个 `DOUBLE` 类型的值,表示计算得到的近似百分位数。 ## 举例 + +```sql +-- 创建示例表 +CREATE TABLE response_times ( + request_id INT, + response_time DECIMAL(10, 2) +) DUPLICATE KEY(`request_id`) +DISTRIBUTED BY HASH(`request_id`) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- 插入示例数据 +INSERT INTO response_times VALUES +(1, 10.5), +(2, 15.2), +(3, 20.1), +(4, 25.8), +(5, 30.3), +(6, 35.7), +(7, 40.2), +(8, 45.9), +(9, 50.4), +(10, 100.6); + +-- 使用不同压缩度计算 99 分位数 +SELECT + percentile_approx(response_time, 0.99) as p99_default, -- 默认压缩度 + percentile_approx(response_time, 0.99, 2048) as p99_fast, -- 低压缩度,更快 + percentile_approx(response_time, 0.99, 10000) as p99_accurate -- 高压缩度,更精确 +FROM response_times; ``` -MySQL > select `table`, percentile_approx(cost_time,0.99) from log_statis group by `table`; -+---------------------+---------------------------+ -| table | percentile_approx(`cost_time`, 0.99) | -+----------+--------------------------------------+ -| test | 54.22 | -+----------+--------------------------------------+ - -MySQL > select `table`, percentile_approx(cost_time,0.99, 4096) from log_statis group by `table`; -+---------------------+---------------------------+ -| table | percentile_approx(`cost_time`, 0.99, 4096.0) | -+----------+--------------------------------------+ -| test | 54.21 | -+----------+--------------------------------------+ + +```text ++-------------------+-------------------+-------------------+ +| p99_default | p99_fast | p99_accurate | ++-------------------+-------------------+-------------------+ +| 100.5999984741211 | 100.5999984741211 | 100.5999984741211 | ++-------------------+-------------------+-------------------+ ``` -### keywords -PERCENTILE_APPROX,PERCENTILE,APPROX + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/percentile-array.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/percentile-array.md index 9f33f295d7c1c..4a141e5157457 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/percentile-array.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/percentile-array.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,29 +22,67 @@ specific language governing permissions and limitations under the License. --> -## PERCENTILE_ARRAY ## 描述 + +`PERCENTILE_ARRAY` 函数用于计算精确的百分位数数组,允许一次性计算多个百分位数值。这个函数主要适用于小数据量。 + +主要特点: +1. 精确计算:提供精确的百分位数结果,而不是近似值 +2. 批量处理:可以一次计算多个百分位数 +3. 适用范围:最适合处理数据量较小的场景 + ## 语法 -`ARRAY_DOUBLE PERCENTILE_ARRAY(expr, ARRAY_DOUBLE p)` +```sql +PERCENTILE_ARRAY(, ) +``` + +## 参数 -计算精确的百分位数,适用于小数据量。先对指定列降序排列,然后取精确的第 p 位百分数。 -返回值为依次取数组p中指定的百分数组成的结果。 -参数说明: -expr: 必填。值为整数(最大为bigint) 类型的列。 -p: 需要精确的百分位数, 由常量组成的数组, 取值为 [0.0,1.0]。 +| 参数 | 说明 | +| -- | -- | +| `` | 需要计算百分位数的列 | +| `` | 百分位数数组,数组中的每个元素必须在 `[0.0, 1.0]` 范围内,例如 `[0.5, 0.95, 0.99]` | + +## 返回值 + +返回一个 `DOUBLE` 类型的数组,包含了对应于输入百分位数数组的计算结果。 ## 举例 -``` -mysql> select percentile_array(k1,[0.3,0.5,0.9]) from baseall; -+----------------------------------------------+ -| percentile_array(`k1`, ARRAY(0.3, 0.5, 0.9)) | -+----------------------------------------------+ -| [5.2, 8, 13.6] | -+----------------------------------------------+ -1 row in set (0.02 sec) +```sql +-- 创建示例表 +CREATE TABLE sales_data ( + id INT, + amount DECIMAL(10, 2) +) DUPLICATE KEY(`id`) +DISTRIBUTED BY HASH(`id`) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- 插入示例数据 +INSERT INTO sales_data VALUES +(1, 10.5), +(2, 15.2), +(3, 20.1), +(4, 25.8), +(5, 30.3), +(6, 35.7), +(7, 40.2), +(8, 45.9), +(9, 50.4), +(10, 100.6); + +-- 计算多个百分位数 +SELECT percentile_array(amount, [0.25, 0.5, 0.75, 0.9]) as percentiles +FROM sales_data; ``` -### keywords -PERCENTILE_ARRAY +```text ++-----------------------------------------+ +| percentiles | ++-----------------------------------------+ +| [21.25, 32.5, 43.75, 54.99999999999998] | ++-----------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md index 07857cfe22ea4..25d93ff36ca8a 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,36 +22,76 @@ specific language governing permissions and limitations under the License. --> -## PERCENTILE_APPROX_WEIGHTED ## 描述 + +`PERCENTILE_APPROX_WEIGHTED` 函数用于计算带权重的近似百分位数,主要用于需要考虑数值重要性的场景。它是 `PERCENTILE_APPROX` 的加权版本,允许为每个值指定一个权重。 + +主要特点: +1. 支持权重:每个数值可以设置对应的权重,影响最终的百分位数计算 +2. 内存效率:使用固定大小的内存,适合处理大规模数据 +3. 精度可调:通过 compression 参数平衡精度和性能 + ## 语法 -`PERCENTILE_APPROX_WEIGHTED(expr, w ,DOUBLE p [, DOUBLE compression])` +```sql +PERCENTILE_APPROX_WEIGHTED(, ,

[, ]) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 需要计算百分位数的列 | +| `` | 权重列,必须是正数 | +| `

` | 百分位数值,取值范围 `[0.0, 1.0]`,例如 `0.99` 表示 `99` 分位数 | +| `` | 可选参数,压缩度,取值范围 `[2048, 10000]`。值越大,精度越高,但内存消耗也越大。如果不指定或超出范围,则使用 `10000`。 | +## 返回值 -该函数和 PERCENTILE_APPROX 类似,唯一的区别是多了一个参数 w,用来表示 expr 出现的次数。 -注意参数 W 的取值需要大于0,如果计算过程中某一行的取值小于等于0时,则会跳过当前行。 +返回一个 `DOUBLE` 类型的值,表示计算得到的加权近似百分位数。 ## 举例 + +```sql +-- 创建示例表 +CREATE TABLE weighted_scores ( + student_id INT, + score DECIMAL(10, 2), + weight INT +) DUPLICATE KEY(student_id) +DISTRIBUTED BY HASH(student_id) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- 插入示例数据 +INSERT INTO weighted_scores VALUES +(1, 85.5, 1), -- 普通作业分数,权重1 +(2, 90.0, 2), -- 重要作业分数,权重2 +(3, 75.5, 1), +(4, 95.5, 3), -- 非常重要的作业,权重3 +(5, 88.0, 2), +(6, 92.5, 2), +(7, 78.0, 1), +(8, 89.5, 2), +(9, 94.0, 3), +(10, 83.5, 1); + +-- 计算带权重的分数分布 +SELECT + -- 计算不同压缩度下的90分位数 + percentile_approx_weighted(score, weight, 0.9) as p90_default, -- 默认压缩度 + percentile_approx_weighted(score, weight, 0.9, 2048) as p90_fast, -- 低压缩度,更快 + percentile_approx_weighted(score, weight, 0.9, 10000) as p90_accurate -- 高压缩度,更精确 +FROM weighted_scores; ``` -mysql >select * from quantile_weighted_table order by k; -+------+------+ -| k | w | -+------+------+ -| 1 | 2 | -| 3 | 1 | -| 5 | 2 | -+------+------+ - - -mysql >select percentile_approx_weighted(k,w,0.55) from quantile_weighted_table; -+----------------------------------------------------------------------------------------+ -| percentile_approx_weighted(cast(k as DOUBLE), cast(w as DOUBLE), cast(0.55 as DOUBLE)) | -+----------------------------------------------------------------------------------------+ -| 3.3333332538604736 | -+----------------------------------------------------------------------------------------+ +```text ++------------------+------------------+------------------+ +| p90_default | p90_fast | p90_accurate | ++------------------+------------------+------------------+ +| 95.3499984741211 | 95.3499984741211 | 95.3499984741211 | ++------------------+------------------+------------------+ ``` -### keywords -PERCENTILE_APPROX,PERCENTILE,APPROX,PERCENTILE_APPROX_WEIGHTED + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/quantile-union.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/quantile-union.md index 6bb8e3e6d5265..4c899d578b3c1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/quantile-union.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/quantile-union.md @@ -1,6 +1,6 @@ --- { - "title": "quantile_union", + "title": "QUANTILE_UNION", "language": "zh-CN" } --- @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -23,3 +21,73 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## 描述 + +`QUANTILE_UNION` 函数用于合并多个分位数计算的中间结果。这个函数通常与 `QUANTILE_STATE` 配合使用,特别适用于需要分阶段计算分位数的场景。 + +## 语法 + +```sql +QUANTILE_UNION() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 由 `TO_QUANTILE_STATE` 函数生成的中间状态 | + +## 返回值 + +返回一个可以用于进一步分位数计算的聚合状态。此函数返回的结果仍是 `QUANTILE_STATE`。 + +## 举例 + +```sql +-- 创建示例表 +CREATE TABLE response_times ( + request_id INT, + response_time DOUBLE, + region STRING +) DUPLICATE KEY(request_id) +DISTRIBUTED BY HASH(request_id) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- 插入示例数据 +INSERT INTO response_times VALUES +(1, 10.5, 'east'), +(2, 15.2, 'east'), +(3, 20.1, 'west'), +(4, 25.8, 'east'), +(5, 30.3, 'west'), +(6, 35.7, 'east'), +(7, 40.2, 'west'), +(8, 45.9, 'east'), +(9, 50.4, 'west'), +(10, 100.6, 'east'); + +-- 按区域计算响应时间的50%分位数 +SELECT + region, + QUANTILE_PERCENT( + QUANTILE_UNION( + TO_QUANTILE_STATE(response_time, 2048) + ), + 0.5 + ) AS median_response_time +FROM response_times +GROUP BY region; + +``` + +```text ++--------+----------------------+ +| region | median_response_time | ++--------+----------------------+ +| west | 35.25 | +| east | 30.75 | ++--------+----------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/regr-intercept.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/regr-intercept.md index 4f81d8572f82e..a826864bedac0 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/regr-intercept.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/regr-intercept.md @@ -1,6 +1,6 @@ --- { - "title": "regr_intercept", + "title": "REGR_INTERCEPT", "language": "zh-CN" } --- @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -23,3 +21,62 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## 描述 + +`REGR_INTERCEPT` 函数用于计算线性回归方程中的截距(y轴截距)。它返回组内非空值对的单变量线性回归线的截距。对于非空值对,使用以下公式计算: + +`AVG(y) - REGR_SLOPE(y, x) * AVG(x)` + +其中 `x` 是自变量,`y` 是因变量。 + +## 语法 + +```sql +REGR_INTERCEPT(, ) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 因变量,必须是可以计算为数值类型的表达式。 | +| `` | 自变量,必须是可以计算为数值类型的表达式。 | + +## 返回值 + +返回 `DOUBLE` 类型的值,表示线性回归线与 `y` 轴的交点。 + +## 举例 + +```sql +-- 创建示例表 +CREATE TABLE test_regr_intercept ( + `id` int, + `x` int, + `y` int +) DUPLICATE KEY (`id`) +DISTRIBUTED BY HASH(`id`) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- 插入示例数据 +INSERT INTO test_regr_intercept VALUES +(1, 18, 13), +(2, 14, 27), +(3, 12, 2), +(4, 5, 6), +(5, 10, 20); + +-- 计算x和y的线性回归截距 +SELECT REGR_INTERCEPT(y, x) FROM test_regr_intercept; +``` + +```text ++-------------------------+ +| regr_intercept(y, x) | ++-------------------------+ +| 5.512931034482759 | ++-------------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/regr-slope.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/regr-slope.md index 93045d67a91db..3e2ae9506128a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/regr-slope.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/regr-slope.md @@ -1,6 +1,6 @@ --- { - "title": "regr_slope", + "title": "REGR_SLOPE", "language": "zh-CN" } --- @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -23,3 +21,59 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## 描述 + +`REGR_SLOPE` 函数用于计算线性回归方程中的斜率。它返回组内非空值对的单变量线性回归线的斜率。 + + +## 语法 + +```sql +REGR_SLOPE(, ) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 因变量,必须是可以计算为数值类型的表达式。 | +| `` | 自变量,必须是可以计算为数值类型的表达式。 | + +## 返回值 + +返回 DOUBLE 类型的值,表示线性回归线的斜率。 + +## 举例 + +```sql +-- 创建示例表 +CREATE TABLE test_regr_slope ( + `id` int, + `x` int, + `y` int +) DUPLICATE KEY (`id`) +DISTRIBUTED BY HASH(`id`) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- 插入示例数据 +INSERT INTO test_regr_slope VALUES +(1, 18, 13), +(2, 14, 27), +(3, 12, 2), +(4, 5, 6), +(5, 10, 20); + +-- 计算x和y的线性回归斜率 +SELECT REGR_SLOPE(y, x) FROM test_regr_slope; +``` + +```text ++----------------------+ +| regr_slope(y, x) | ++----------------------+ +| 0.6853448275862069 | ++----------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/retention.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/retention.md index d23fb985ec208..6f6be9a736e8a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/retention.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/retention.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,118 +22,73 @@ specific language governing permissions and limitations under the License. --> -## RETENTION - -RETENTION - ## 描述 -## 语法 - -`retention(event1, event2, ... , eventN);` -留存函数将一组条件作为参数,类型为1到32个`UInt8`类型的参数,用来表示事件是否满足特定条件。 任何条件都可以指定为参数. +留存函数将一组条件作为参数,类型为1到32个`UInt8`类型的参数,用来表示事件是否满足特定条件。 任何条件都可以指定为参数。 除了第一个以外,条件成对适用:如果第一个和第二个是真的,第二个结果将是真的,如果第一个和第三个是真的,第三个结果将是真的,等等。 -简单来讲,返回值数组第1位表示`event1`的真假,第二位表示`event1`真假与`event2`真假相与,第三位表示`event1`真假与`event3`真假相与,等等。如果`event1`为假,则返回全是0的数组。 +简单来讲,返回值数组第1位表示`event_1`的真假,第二位表示`event_1`真假与`event_2`真假相与,第三位表示`event_1`真假与`event_3`真假相与,等等。如果`event_1`为假,则返回全是0的数组。 + +## 语法 + +```sql +RETENTION( [, , ... , ]); +``` ## 参数 -`event` — 返回`UInt8`结果(1或0)的表达式. +| 参数 | 说明 | +| -- | -- | +| `` | 第`n`个事件条件,类型为`UInt8`,取值为1或0 | ## 返回值 由1和0组成的最大长度为32位的数组,最终输出数组的长度与输入参数长度相同。 -1 — 条件满足。 +- 1: 条件满足。 -0 — 条件不满足 +- 0: 条件不满足。 ## 举例 ```sql -DROP TABLE IF EXISTS retention_test; - +-- 创建示例表 CREATE TABLE retention_test( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( - "replication_num" = "1" -); - -INSERT into retention_test (uid, date) values (0, '2022-10-12'), - (0, '2022-10-13'), - (0, '2022-10-14'), - (1, '2022-10-12'), - (1, '2022-10-13'), - (2, '2022-10-12'); - -SELECT * from retention_test; - -+------+---------------------+ -| uid | date | -+------+---------------------+ -| 0 | 2022-10-14 00:00:00 | -| 0 | 2022-10-13 00:00:00 | -| 0 | 2022-10-12 00:00:00 | -| 1 | 2022-10-13 00:00:00 | -| 1 | 2022-10-12 00:00:00 | -| 2 | 2022-10-12 00:00:00 | -+------+---------------------+ - -SELECT - uid, - retention(date = '2022-10-12') - AS r - FROM retention_test - GROUP BY uid - ORDER BY uid ASC; - -+------+------+ -| uid | r | -+------+------+ -| 0 | [1] | -| 1 | [1] | -| 2 | [1] | -+------+------+ - + "replication_allocation" = "tag.location.default: 1" +); + +-- 插入示例数据 +INSERT into retention_test values +(0, '2022-10-12'), +(0, '2022-10-13'), +(0, '2022-10-14'), +(1, '2022-10-12'), +(1, '2022-10-13'), +(2, '2022-10-12'); + +-- 计算用户留存 SELECT uid, - retention(date = '2022-10-12', date = '2022-10-13') - AS r - FROM retention_test - GROUP BY uid - ORDER BY uid ASC; - -+------+--------+ -| uid | r | -+------+--------+ -| 0 | [1, 1] | -| 1 | [1, 1] | -| 2 | [1, 0] | -+------+--------+ - -SELECT - uid, - retention(date = '2022-10-12', date = '2022-10-13', date = '2022-10-14') - AS r - FROM retention_test - GROUP BY uid - ORDER BY uid ASC; - -+------+-----------+ -| uid | r | -+------+-----------+ -| 0 | [1, 1, 1] | -| 1 | [1, 1, 0] | -| 2 | [1, 0, 0] | -+------+-----------+ - + RETENTION(date = '2022-10-12') AS r, + RETENTION(date = '2022-10-12', date = '2022-10-13') AS r2, + RETENTION(date = '2022-10-12', date = '2022-10-13', date = '2022-10-14') AS r3 +FROM retention_test +GROUP BY uid +ORDER BY uid ASC; ``` -### keywords - -RETENTION +```text ++------+------+--------+-----------+ +| uid | r | r2 | r3 | ++------+------+--------+-----------+ +| 0 | [1] | [1, 1] | [1, 1, 1] | +| 1 | [1] | [1, 1] | [1, 1, 0] | +| 2 | [1] | [1, 0] | [1, 0, 0] | ++------+------+--------+-----------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/sequence-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/sequence-count.md index b2e312eb6f7c6..dff1be7e0b230 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/sequence-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/sequence-count.md @@ -22,11 +22,7 @@ specific language governing permissions and limitations under the License. --> -## SEQUENCE-COUNT ## 描述 -## 语法 - -`sequence_count(pattern, timestamp, cond1, cond2, ...);` 计算与模式匹配的事件链的数量。该函数搜索不重叠的事件链。当前链匹配后,它开始搜索下一个链。 @@ -34,23 +30,29 @@ under the License. 在同一秒钟发生的事件可能以未定义的顺序排列在序列中,会影响最终结果。 -## 参数 +## 语法 -`pattern` — 模式字符串. +```sql +SEQUENCE_COUNT(, , [, , ..., ]); +``` -**模式语法** +## 参数 -`(?N)` — 在位置N匹配条件参数。 条件在编号 `[1, 32]` 范围。 例如, `(?1)` 匹配传递给 `cond1` 参数。 +| 参数 | 说明 | +| -- | -- | +| `` | 模式字符串,可参考下面的**模式语法** | +| `` | 包含时间的列。典型的时间类型是: `Date` 和 `DateTime`。也可以使用任何支持的 `UInt` 数据类型。 | +| `` | 事件链的约束条件。 数据类型是: `UInt8`。 最多可以传递32个条件参数。 该函数只考虑这些条件中描述的事件。 如果序列包含未在条件中描述的数据,则函数将跳过这些数据 | -`.*` — 匹配任何事件的数字。 不需要条件参数来匹配这个模式。 +**模式语法** -`(?t operator value)` — 分开两个事件的时间。 单位为秒。 +- `(?N)` — 在位置N匹配条件参数。 条件在编号 `[1, 32]` 范围。 例如, `(?1)` 匹配传递给 `cond_1` 参数。 -`t`表示为两个时间的差值,单位为秒。 例如: `(?1)(?t>1800)(?2)` 匹配彼此发生超过1800秒的事件, `(?1)(?t>10000)(?2)`匹配彼此发生超过10000秒的事件。 这些事件之间可以存在任意数量的任何事件。 您可以使用 `>=`, `>`, `<`, `<=`, `==` 运算符。 +- `.*` — 匹配任何事件的数字。 不需要条件参数来匹配这个模式。 -`timestamp` — 包含时间的列。典型的时间类型是: `Date` 和 `DateTime`。也可以使用任何支持的 `UInt` 数据类型。 +- `(?t operator value)` — 分开两个事件的时间。 单位为秒。 -`cond1`, `cond2` — 事件链的约束条件。 数据类型是: `UInt8`。 最多可以传递32个条件参数。 该函数只考虑这些条件中描述的事件。 如果序列包含未在条件中描述的数据,则函数将跳过这些数据。 +- `t`表示为两个时间的差值,单位为秒。 例如: `(?1)(?t>1800)(?2)` 匹配彼此发生超过1800秒的事件, `(?1)(?t>10000)(?2)`匹配彼此发生超过10000秒的事件。 这些事件之间可以存在任意数量的任何事件。 您可以使用 `>=`, `>`, `<`, `<=`, `==` 运算符。 ## 返回值 @@ -61,161 +63,106 @@ under the License. **匹配例子** ```sql -DROP TABLE IF EXISTS sequence_count_test1; - +-- 创建示例表 CREATE TABLE sequence_count_test1( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_count_test1(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 13:28:02', 2), - (3, '2022-11-02 16:15:01', 1), - (4, '2022-11-02 19:05:04', 2), - (5, '2022-11-02 20:08:44', 3); - -SELECT * FROM sequence_count_test1 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 13:28:02 | 2 | -| 3 | 2022-11-02 16:15:01 | 1 | -| 4 | 2022-11-02 19:05:04 | 2 | -| 5 | 2022-11-02 20:08:44 | 3 | -+------+---------------------+--------+ - -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 3) FROM sequence_count_test1; - -+----------------------------------------------------------------+ -| sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 3) | -+----------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 2) FROM sequence_count_test1; - -+----------------------------------------------------------------+ -| sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 2 | -+----------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) FROM sequence_count_test1; +-- 插入示例数据 +INSERT INTO sequence_count_test1(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 13:28:02', 2), +(3, '2022-11-02 16:15:01', 1), +(4, '2022-11-02 19:05:04', 2), +(5, '2022-11-02 20:08:44', 3); + +-- 查询示例 +SELECT + SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 3) as c1, + SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 2) as c2, + SEQUENCE_COUNT('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) as c3 +FROM sequence_count_test1; +``` -+---------------------------------------------------------------------------+ -| sequence_count('(?1)(?t>=3600)(?2)', `date`, `number` = 1, `number` = 2) | -+---------------------------------------------------------------------------+ -| 2 | -+---------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 1 | 2 | 2 | ++------+------+------+ ``` **不匹配例子** ```sql -DROP TABLE IF EXISTS sequence_count_test2; - +-- 创建示例表 CREATE TABLE sequence_count_test2( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_count_test2(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_count_test2 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ - -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 2) FROM sequence_count_test2; - -+----------------------------------------------------------------+ -| sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 0 | -+----------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?2).*', date, number = 1, number = 2) FROM sequence_count_test2; - -+------------------------------------------------------------------+ -| sequence_count('(?1)(?2).*', `date`, `number` = 1, `number` = 2) | -+------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?t>3600)(?2)', date, number = 1, number = 7) FROM sequence_count_test2; +-- 插入示例数据 +INSERT INTO sequence_count_test2(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); + +-- 查询示例 +SELECT + SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 2) as c1, + SEQUENCE_COUNT('(?1)(?2).*', date, number = 1, number = 2) as c2, + SEQUENCE_COUNT('(?1)(?t>3600)(?2)', date, number = 1, number = 7) as c3 +FROM sequence_count_test2; +``` -+--------------------------------------------------------------------------+ -| sequence_count('(?1)(?t>3600)(?2)', `date`, `number` = 1, `number` = 7) | -+--------------------------------------------------------------------------+ -| 0 | -+--------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 0 | 0 | 0 | ++------+------+------+ ``` **特殊例子** ```sql -DROP TABLE IF EXISTS sequence_count_test3; - +-- 创建示例表 CREATE TABLE sequence_count_test3( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_count_test3(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_count_test3 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ -``` - -Perform the query: +-- 插入示例数据 +INSERT INTO sequence_count_test3(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); -```sql -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5) FROM sequence_count_test3; +-- 查询示例 +SELECT SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 5) FROM sequence_count_test3; +``` +```text +----------------------------------------------------------------+ | sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 5) | +----------------------------------------------------------------+ @@ -228,8 +175,10 @@ SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5) FROM sequence_co 现在,考虑如下执行语句: ```sql -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM sequence_count_test3; +SELECT SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM sequence_count_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 4) | +------------------------------------------------------------------------------+ @@ -240,15 +189,13 @@ SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM 您可能对这个结果有些许疑惑,在这种情况下,函数找不到与模式匹配的事件链,因为数字4的事件发生在1和5之间。 如果在相同的情况下,我们检查了数字6的条件,则序列将与模式匹配。 ```sql -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5, number = 6) FROM sequence_count_test3; +SELECT SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 5, number = 6) FROM sequence_count_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 6) | +------------------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------------------+ ``` - -### keywords - -SEQUENCE_COUNT \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/sequence-match.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/sequence-match.md index c07318fc990e1..7491cd0fcfa73 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/sequence-match.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/sequence-match.md @@ -22,11 +22,7 @@ specific language governing permissions and limitations under the License. --> -## SEQUENCE-MATCH ## 描述 -## 语法 - -`sequence_match(pattern, timestamp, cond1, cond2, ...);` 检查序列是否包含与模式匹配的事件链。 @@ -34,190 +30,135 @@ under the License. 在同一秒钟发生的事件可能以未定义的顺序排列在序列中,会影响最终结果。 +## 语法 +```sql +SEQUENCE_MATCH(, , [, , ..., ]) +``` + ## 参数 -`pattern` — 模式字符串. +| 参数 | 说明 | +| -- | -- | +| `` | 模式字符串,可参考下面的**模式语法** | +| `` | 包含时间的列。典型的时间类型是: `Date` 和 `DateTime`。也可以使用任何支持的 `UInt` 数据类型。 | +| `` | 事件链的约束条件。 数据类型是: `UInt8`。最多可以传递32个条件参数。该函数只考虑这些条件中描述的事件。如果序列包含未在条件中描述的数据,则函数将跳过这些数据。 | -**模式语法** -`(?N)` — 在位置N匹配条件参数。 条件在编号 `[1, 32]` 范围。 例如, `(?1)` 匹配传递给 `cond1` 参数。 +**模式语法** -`.*` — 匹配任何事件的数字。 不需要条件参数来匹配这个模式。 +- `(?N)` — 在位置N匹配条件参数。 条件在编号 `[1, 32]` 范围。 例如, `(?1)` 匹配传递给 `cond1` 参数。 -`(?t operator value)` — 分开两个事件的时间。 单位为秒。 +- `.*` — 匹配任何事件的数字。 不需要条件参数来匹配这个模式。 -`t`表示为两个时间的差值,单位为秒。 例如: `(?1)(?t>1800)(?2)` 匹配彼此发生超过1800秒的事件, `(?1)(?t>10000)(?2)`匹配彼此发生超过10000秒的事件。 这些事件之间可以存在任意数量的任何事件。 您可以使用 `>=`, `>`, `<`, `<=`, `==` 运算符。 +- `(?t operator value)` — 分开两个事件的时间。 单位为秒。 -`timestamp` — 包含时间的列。典型的时间类型是: `Date` 和 `DateTime`。也可以使用任何支持的 `UInt` 数据类型。 +- `t`表示为两个时间的差值,单位为秒。 例如: `(?1)(?t>1800)(?2)` 匹配彼此发生超过1800秒的事件, `(?1)(?t>10000)(?2)`匹配彼此发生超过10000秒的事件。 这些事件之间可以存在任意数量的任何事件。 您可以使用 `>=`, `>`, `<`, `<=`, `==` 运算符。 -`cond1`, `cond2` — 事件链的约束条件。 数据类型是: `UInt8`。 最多可以传递32个条件参数。 该函数只考虑这些条件中描述的事件。 如果序列包含未在条件中描述的数据,则函数将跳过这些数据。 ## 返回值 -1,如果模式匹配。 +1:模式匹配。 -0,如果模式不匹配。 +0:模式不匹配。 ## 举例 **匹配例子** ```sql -DROP TABLE IF EXISTS sequence_match_test1; - CREATE TABLE sequence_match_test1( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_match_test1(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 13:28:02', 2), - (3, '2022-11-02 16:15:01', 1), - (4, '2022-11-02 19:05:04', 2), - (5, '2022-11-02 20:08:44', 3); - -SELECT * FROM sequence_match_test1 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 13:28:02 | 2 | -| 3 | 2022-11-02 16:15:01 | 1 | -| 4 | 2022-11-02 19:05:04 | 2 | -| 5 | 2022-11-02 20:08:44 | 3 | -+------+---------------------+--------+ +INSERT INTO sequence_match_test1(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 13:28:02', 2), +(3, '2022-11-02 16:15:01', 1), +(4, '2022-11-02 19:05:04', 2), +(5, '2022-11-02 20:08:44', 3); -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 3) FROM sequence_match_test1; - -+----------------------------------------------------------------+ -| sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 3) | -+----------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 2) FROM sequence_match_test1; - -+----------------------------------------------------------------+ -| sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------+ -SELECT sequence_match('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) FROM sequence_match_test1; +SELECT +sequence_match('(?1)(?2)', date, number = 1, number = 3) as c1, +sequence_match('(?1)(?2)', date, number = 1, number = 2) as c2, +sequence_match('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) as c3 +FROM sequence_match_test1; +``` -+---------------------------------------------------------------------------+ -| sequence_match('(?1)(?t>=3600)(?2)', `date`, `number` = 1, `number` = 2) | -+---------------------------------------------------------------------------+ -| 1 | -+---------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 1 | 1 | 1 | ++------+------+------+ ``` **不匹配例子** ```sql -DROP TABLE IF EXISTS sequence_match_test2; - CREATE TABLE sequence_match_test2( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_match_test2(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_match_test2 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ - -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 2) FROM sequence_match_test2; - -+----------------------------------------------------------------+ -| sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 0 | -+----------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?2).*', date, number = 1, number = 2) FROM sequence_match_test2; - -+------------------------------------------------------------------+ -| sequence_match('(?1)(?2).*', `date`, `number` = 1, `number` = 2) | -+------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?t>3600)(?2)', date, number = 1, number = 7) FROM sequence_match_test2; +INSERT INTO sequence_match_test2(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); + +SELECT +sequence_match('(?1)(?2)', date, number = 1, number = 2) as c1, +sequence_match('(?1)(?2).*', date, number = 1, number = 2) as c2, +sequence_match('(?1)(?t>3600)(?2)', date, number = 1, number = 7) as c3 +FROM sequence_match_test2; +``` -+--------------------------------------------------------------------------+ -| sequence_match('(?1)(?t>3600)(?2)', `date`, `number` = 1, `number` = 7) | -+--------------------------------------------------------------------------+ -| 0 | -+--------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 0 | 0 | 0 | ++------+------+------+ ``` **特殊例子** ```sql -DROP TABLE IF EXISTS sequence_match_test3; - CREATE TABLE sequence_match_test3( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_match_test3(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_match_test3 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ -``` - -Perform the query: +INSERT INTO sequence_match_test3(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); -```sql -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5) FROM sequence_match_test3; +SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5) +FROM sequence_match_test3; +``` +```text +----------------------------------------------------------------+ | sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 5) | +----------------------------------------------------------------+ @@ -230,8 +171,11 @@ SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5) FROM sequence_ma 现在,考虑如下执行语句: ```sql -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM sequence_match_test3; +SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 4) +FROM sequence_match_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 4) | +------------------------------------------------------------------------------+ @@ -242,15 +186,14 @@ SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM 您可能对这个结果有些许疑惑,在这种情况下,函数找不到与模式匹配的事件链,因为数字4的事件发生在1和5之间。 如果在相同的情况下,我们检查了数字6的条件,则序列将与模式匹配。 ```sql -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 6) FROM sequence_match_test3; +SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 6) +FROM sequence_match_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 6) | +------------------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------------------+ ``` - -### keywords - -SEQUENCE_MATCH \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/skew.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/skew.md index 2328228628cd1..4f36d3ec28eb6 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/skew.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/skew.md @@ -1,7 +1,7 @@ --- { "title": "SKEW,SKEW_POP,SKEWNESS", - "language": "en" + "language": "zh-CN" } --- @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,50 +22,79 @@ specific language governing permissions and limitations under the License. --> -## skewness,skew,skew_pop -### 描述 +## 描述 返回表达式的 [斜度](https://en.wikipedia.org/wiki/Skewness)。 -用来计算斜度的公式是 `3阶中心矩 / ((方差)^{1.5})`, 当方差为零时, `skewness` 会返回 `NULL`. +用来计算斜度的公式是 `3阶中心矩 / ((方差)^{1.5})`, 当方差为零时, `SKEWNESS` 会返回 `NULL`。 -### 语法 +**相关命令** -`skewness(expr)` +[kurt](./kurt.md) -### 参数说明 +## 别名 -TinyInt/SmallInt/Integer/BigInt/Float/Double, Decimal 会被 cast 成浮点数参与运算。 +- SKEW +- SKEW_POP -### 返回值说明 +## 语法 -`Double` - -### 举例 ```sql -create table statistic_test (tag int, val1 double not null, val2 double null) - distributed by hash(tag) properties("replication_num"="1") +SKEWNESS() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 需要被计算斜度的列 | + +## 返回值 -insert into statistic_test values (1, -10, -10), - (2, -20, NULL), - (3, 100, NULL), - (4, 100, NULL), - (5, 1000,1000); +返回表达式的斜度, `Double` 类型。 -// NULL is ignored -select skew(val1), skew(val2) from statistic_test --------------- +## 举例 +```sql +CREATE TABLE statistic_test( + tag int, + val1 double not null, + val2 double null +) DISTRIBUTED BY HASH(tag) +PROPERTIES ( + "replication_num"="1" +); + +INSERT INTO statistic_test VALUES +(1, -10, -10), +(2, -20, NULL), +(3, 100, NULL), +(4, 100, NULL), +(5, 1000,1000); + +-- NULL 值会被忽略 +SELECT + skew(val1), + skew(val2) +FROM statistic_test; +``` +```text +--------------------+--------------------+ | skew(val1) | skew(val2) | +--------------------+--------------------+ | 1.4337199628825619 | 1.1543940205711711 | +--------------------+--------------------+ -1 row in set (0.01 sec) +``` -// Each group just has one row, result is NULL -select skew(val1), skew(val2) from statistic_test group by tag --------------- +```sql +-- 每组仅包含一行,结果为 NULL。 +SELECT + skew(val1), + skew(val2) +FROM statistic_test +GROUP BY tag; +``` +```text +------------+------------+ | skew(val1) | skew(val2) | +------------+------------+ @@ -77,8 +104,4 @@ select skew(val1), skew(val2) from statistic_test group by tag | NULL | NULL | | NULL | NULL | +------------+------------+ -5 rows in set (0.04 sec) -``` -### 相关命令 - -[kurt](./kurt.md) \ No newline at end of file +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/stddev-samp.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/stddev-samp.md index 104ce066a6bb3..e71d23be26f9b 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/stddev-samp.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/stddev-samp.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,23 +22,54 @@ specific language governing permissions and limitations under the License. --> -## STDDEV_SAMP ## 描述 + +返回expr表达式的样本标准差 + ## 语法 -`STDDEV_SAMP(expr)` +```sql +STDDEV_SAMP() +``` + +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 需要被计算标准差的值 | -返回expr表达式的样本标准差 +## 返回值 + +返回参数 expr 的样本标准差 ## 举例 +```sql +-- 创建示例表 +CREATE TABLE score_table ( + student_id INT, + score DOUBLE +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO score_table VALUES +(1, 85), +(2, 90), +(3, 82), +(4, 88), +(5, 95); + +-- 计算所有学生分数的样本标准差 +SELECT STDDEV_SAMP(score) as score_stddev +FROM score_table; ``` -MySQL > select stddev_samp(scan_rows) from log_statis group by datetime; -+--------------------------+ -| stddev_samp(`scan_rows`) | -+--------------------------+ -| 2.372044195280762 | -+--------------------------+ + +```text ++-------------------+ +| score_stddev | ++-------------------+ +| 4.949747468305831 | ++-------------------+ ``` -### keywords -STDDEV_SAMP,STDDEV,SAMP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/stddev.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/stddev.md index 85803054ba7a1..47778ec9dde5f 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/stddev.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/stddev.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,30 +22,58 @@ specific language governing permissions and limitations under the License. --> -## STDDEV,STDDEV_POP ## 描述 + +返回 expr 表达式的标准差 + +## 别名 + +- STDDEV_POP + ## 语法 -`STDDEV(expr)` +```sql +STDDEV() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 需要被计算标准差的值 | +## 返回值 -返回expr表达式的标准差 +返回参数 expr 的标准差 ## 举例 +```sql +-- 创建示例表 +CREATE TABLE score_table ( + student_id INT, + score DOUBLE +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO score_table VALUES +(1, 85), +(2, 90), +(3, 82), +(4, 88), +(5, 95); + +-- 计算所有学生分数的标准差 +SELECT STDDEV(score) as score_stddev +FROM score_table; ``` -MySQL > select stddev(scan_rows) from log_statis group by datetime; -+---------------------+ -| stddev(`scan_rows`) | -+---------------------+ -| 2.3736656687790934 | -+---------------------+ - -MySQL > select stddev_pop(scan_rows) from log_statis group by datetime; -+-------------------------+ -| stddev_pop(`scan_rows`) | -+-------------------------+ -| 2.3722760595994914 | -+-------------------------+ + +```text ++-------------------+ +| score_stddev | ++-------------------+ +| 4.427188724235729 | ++-------------------+ ``` -### keywords -STDDEV,STDDEV_POP,POP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/sum.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/sum.md index f97b3ae225f73..20023c95ec7f7 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/sum.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/sum.md @@ -24,23 +24,55 @@ specific language governing permissions and limitations under the License. --> -## SUM ## 描述 + +用于返回选中字段所有值的和。 + ## 语法 -`SUM(expr)` +```sql +SUM() +``` + +## 参数 +| 参数 | 说明 | +| --- | --- | +| `` | 要计算和的字段 | -用于返回选中字段所有值的和 +## 返回值 + +返回选中字段所有值的和。 ## 举例 +```sql +-- 创建示例表 +CREATE TABLE sales_table ( + product_id INT, + price DECIMAL(10,2), + quantity INT +) DISTRIBUTED BY HASH(product_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO sales_table VALUES +(1, 99.99, 2), +(2, 159.99, 1), +(3, 49.99, 5), +(4, 299.99, 1), +(5, 79.99, 3); + +-- 计算销售总金额 +SELECT SUM(price * quantity) as total_sales +FROM sales_table; ``` -MySQL > select sum(scan_rows) from log_statis group by datetime; -+------------------+ -| sum(`scan_rows`) | -+------------------+ -| 8217360135 | -+------------------+ + +```text ++-------------+ +| total_sales | ++-------------+ +| 1149.88 | ++-------------+ ``` -### keywords -SUM diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/sum0.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/sum0.md index 691d8808adb7a..51abed020e4b1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/sum0.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/sum0.md @@ -1,7 +1,6 @@ --- { - "title": "sum0 - ", + "title": "SUM0", "language": "zh-CN" } --- @@ -24,3 +23,60 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## 描述 + +用于返回选中字段所有值的和。与 SUM 函数不同的是,当输入值全为 NULL 时,SUM0 返回 0 而不是 NULL。 + +## 语法 + +```sql +SUM0() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 要计算和的字段 | + +## 返回值 + +返回选中字段所有值的和。如果所有值都为 NULL,则返回 0。 + +## 举例 + +```sql +-- 创建示例表 +CREATE TABLE sales_table ( + product_id INT, + price DECIMAL(10,2), + quantity INT, + discount DECIMAL(10,2) +) DISTRIBUTED BY HASH(product_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO sales_table VALUES +(1, 99.99, 2, NULL), +(2, 159.99, 1, NULL), +(3, 49.99, 5, NULL), +(4, 299.99, 1, NULL), +(5, 79.99, 3, NULL); + +-- 对比 SUM 和 SUM0 的区别 +SELECT + SUM(discount) as sum_discount, -- 返回 NULL + SUM0(discount) as sum0_discount -- 返回 0 +FROM sales_table; +``` + +```text ++--------------+---------------+ +| sum_discount | sum0_discount | ++--------------+---------------+ +| NULL | 0.00 | ++--------------+---------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/topn-array.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/topn-array.md index d97028c5bf6c5..88aafaa85d4ff 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/topn-array.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/topn-array.md @@ -24,37 +24,58 @@ specific language governing permissions and limitations under the License. --> -## TOPN_ARRAY ## 描述 -## 语法 -`ARRAY topn_array(expr, INT top_num[, INT space_expand_rate])` +TOPN_ARRAY 函数返回指定列中出现频率最高的 N 个值的数组。与 TOPN 函数不同,TOPN_ARRAY 返回一个数组类型,便于后续处理和分析。 -该topn_array函数使用Space-Saving算法计算expr中的top_num个频繁项,返回由前top_num个组成的数组,该结果为近似值 +## 语法 -space_expand_rate参数是可选项,该值用来设置Space-Saving算法中使用的counter个数 +```sql +TOPN_ARRAY(, [, ]) ``` -counter numbers = top_num * space_expand_rate -``` -space_expand_rate的值越大,结果越准确,默认值为50 + +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 要统计的列或表达式 | +| `` | 要返回的最高频率值的数量,必须是正整数 | +| `` | 可选项,该值用来设置 Space-Saving 算法中使用的 counter 个数`counter_numbers = top_num * space_expand_rate` space_expand_rate 的值越大,结果越准确,默认值为50 | + +## 返回值 +返回一个数组,包含出现频率最高的 N 个值。 ## 举例 +```sql +-- 创建示例表 +CREATE TABLE page_visits ( + page_id INT, + user_id INT, + visit_date DATE +) DISTRIBUTED BY HASH(page_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO page_visits VALUES +(1, 101, '2024-01-01'), +(2, 102, '2024-01-01'), +(1, 103, '2024-01-01'), +(3, 101, '2024-01-01'), +(1, 104, '2024-01-01'), +(2, 105, '2024-01-01'), +(1, 106, '2024-01-01'), +(4, 107, '2024-01-01'); + +-- 查找访问量最高的前3个页面 +SELECT TOPN_ARRAY(page_id, 3) as top_pages +FROM page_visits; ``` -mysql> select topn_array(k3,3) from baseall; -+--------------------------+ -| topn_array(`k3`, 3) | -+--------------------------+ -| [3021, 2147483647, 5014] | -+--------------------------+ -1 row in set (0.02 sec) - -mysql> select topn_array(k3,3,100) from baseall; -+--------------------------+ -| topn_array(`k3`, 3, 100) | -+--------------------------+ -| [3021, 2147483647, 5014] | -+--------------------------+ -1 row in set (0.02 sec) + +```text ++-----------+ +| top_pages | ++-----------+ +| [1, 2, 4] | ++-----------+ ``` -### keywords -TOPN, TOPN_ARRAY diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/topn-weighted.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/topn-weighted.md index abd13f58138a9..87d8bddcd25b1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/topn-weighted.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/topn-weighted.md @@ -24,37 +24,60 @@ specific language governing permissions and limitations under the License. --> -## TOPN_WEIGHTED ## 描述 -## 语法 -`ARRAY topn_weighted(expr, BigInt weight, INT top_num[, INT space_expand_rate])` +TOPN_WEIGHTED 函数返回指定列中出现频率最高的 N 个值,并且可以为每个值指定权重。与普通的 TOPN 函数不同,TOPN_WEIGHTED 允许通过权重来调整值的重要性。 -该topn_weighted函数使用Space-Saving算法计算,取expr中权重和为前top_num个数组成的结果,该结果为近似值 +## 语法 -space_expand_rate参数是可选项,该值用来设置Space-Saving算法中使用的counter个数 -``` -counter numbers = top_num * space_expand_rate +```sql +TOPN_WEIGHTED(, , [, ]) ``` -space_expand_rate的值越大,结果越准确,默认值为50 + +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 要统计的列或表达式 | +| `` | 用于调整权重的列或表达式 | +| `` | 要返回的最高频率值的数量,必须是正整数 | +| `` | 可选项,该值用来设置 Space-Saving 算法中使用的 counter 个数`counter_numbers = top_num * space_expand_rate` space_expand_rate 的值越大,结果越准确,默认值为50 | + +## 返回值 + +返回一个数组,包含值和对应的加权计数。 ## 举例 +```sql +-- 创建示例表 +CREATE TABLE product_sales ( + product_id INT, + sale_amount DECIMAL(10,2), + sale_date DATE +) DISTRIBUTED BY HASH(product_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO product_sales VALUES +(1, 100.00, '2024-01-01'), +(2, 50.00, '2024-01-01'), +(1, 150.00, '2024-01-01'), +(3, 75.00, '2024-01-01'), +(1, 200.00, '2024-01-01'), +(2, 80.00, '2024-01-01'), +(1, 120.00, '2024-01-01'), +(4, 90.00, '2024-01-01'); + +-- 查找销售额最高的前3个产品(按销售金额加权) +SELECT TOPN_WEIGHTED(product_id, sale_amount, 3) as top_products +FROM product_sales; ``` -mysql> select topn_weighted(k5,k1,3) from baseall; -+------------------------------+ -| topn_weighted(`k5`, `k1`, 3) | -+------------------------------+ -| [0, 243.325, 100.001] | -+------------------------------+ -1 row in set (0.02 sec) - -mysql> select topn_weighted(k5,k1,3,100) from baseall; -+-----------------------------------+ -| topn_weighted(`k5`, `k1`, 3, 100) | -+-----------------------------------+ -| [0, 243.325, 100.001] | -+-----------------------------------+ -1 row in set (0.02 sec) + +```text ++--------------+ +| top_products | ++--------------+ +| [1, 2, 4] | ++--------------+ ``` -### keywords -TOPN, TOPN_WEIGHTED diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/topn.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/topn.md index 649222139a656..9b75f9b83acae 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/topn.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/topn.md @@ -24,37 +24,58 @@ specific language governing permissions and limitations under the License. --> -## TOPN ## 描述 -## 语法 -`topn(expr, INT top_num[, INT space_expand_rate])` +TOPN 函数用于返回指定列中出现频率最高的 N 个值。它是一个近似计算函数,返回结果的顺序是按照计数值从大到小排序。 -该topn函数使用Space-Saving算法计算expr中的top_num个频繁项,结果为频繁项及其出现次数,该结果为近似值 +## 语法 -space_expand_rate参数是可选项,该值用来设置Space-Saving算法中使用的counter个数 -``` -counter numbers = top_num * space_expand_rate +```sql +TOPN(, [, ]) ``` -space_expand_rate的值越大,结果越准确,默认值为50 + +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 要统计的列或表达式 | +| `` | 要返回的最高频率值的数量,必须是正整数 | +| `` | 可选项,该值用来设置 Space-Saving 算法中使用的 counter 个数`counter_numbers = top_num * space_expand_rate` space_expand_rate 的值越大,结果越准确,默认值为50 | + +## 返回值 +返回一个 JSON 字符串,包含值和对应的出现次数。 ## 举例 +```sql +-- 创建示例表 +CREATE TABLE page_visits ( + page_id INT, + user_id INT, + visit_date DATE +) DISTRIBUTED BY HASH(page_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO page_visits VALUES +(1, 101, '2024-01-01'), +(2, 102, '2024-01-01'), +(1, 103, '2024-01-01'), +(3, 101, '2024-01-01'), +(1, 104, '2024-01-01'), +(2, 105, '2024-01-01'), +(1, 106, '2024-01-01'), +(4, 107, '2024-01-01'); + +-- 查找访问量最高的前3个页面 +SELECT TOPN(page_id, 3) as top_pages +FROM page_visits; ``` -MySQL [test]> select topn(keyword,10) from keyword_table where date>= '2020-06-01' and date <= '2020-06-19' ; -+------------------------------------------------------------------------------------------------------------+ -| topn(`keyword`, 10) | -+------------------------------------------------------------------------------------------------------------+ -| a:157, b:138, c:133, d:133, e:131, f:127, g:124, h:122, i:117, k:117 | -+------------------------------------------------------------------------------------------------------------+ - -MySQL [test]> select date,topn(keyword,10,100) from keyword_table where date>= '2020-06-17' and date <= '2020-06-19' group by date; -+------------+-----------------------------------------------------------------------------------------------+ -| date | topn(`keyword`, 10, 100) | -+------------+-----------------------------------------------------------------------------------------------+ -| 2020-06-19 | a:11, b:8, c:8, d:7, e:7, f:7, g:7, h:7, i:7, j:7 | -| 2020-06-18 | a:10, b:8, c:7, f:7, g:7, i:7, k:7, l:7, m:6, d:6 | -| 2020-06-17 | a:9, b:8, c:8, j:8, d:7, e:7, f:7, h:7, i:7, k:7 | -+------------+-----------------------------------------------------------------------------------------------+ -``` -### keywords -TOPN + +```text ++---------------------+ +| top_pages | ++---------------------+ +| {"1":4,"2":2,"4":1} | ++---------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/var-samp.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/var-samp.md index b563f95e59e27..06154cb8343c4 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/var-samp.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/var-samp.md @@ -24,24 +24,62 @@ specific language governing permissions and limitations under the License. --> -## VAR_SAMP,VARIANCE_SAMP ## 描述 + +VAR_SAMP 函数计算指定表达式的样本方差。与 VARIANCE(总体方差)不同,VAR_SAMP 使用 n-1 作为除数,这在统计学上被认为是对总体方差的无偏估计。 + +## 别名 + +- VARIANCE_SAMP + ## 语法 -`VAR_SAMP(expr)` +```sql +VAR_SAMP() +``` + +## 参数 +| 参数 | 描述 | +| -- | -- | +| `` | 要计算样本方差的列或表达式 | -返回expr表达式的样本方差 +## 返回值 +返回一个 DOUBLE 类型的值,表示计算得到的样本方差。 ## 举例 -``` -MySQL > select var_samp(scan_rows) from log_statis group by datetime; -+-----------------------+ -| var_samp(`scan_rows`) | -+-----------------------+ -| 5.6227132145741789 | -+-----------------------+ +```sql +-- 创建示例表 +CREATE TABLE student_scores ( + student_id INT, + score DECIMAL(4,1) +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO student_scores VALUES +(1, 85.5), +(2, 92.0), +(3, 78.5), +(4, 88.0), +(5, 95.5), +(6, 82.0), +(7, 90.0), +(8, 87.5); + +-- 计算学生成绩的样本方差 +SELECT + VAR_SAMP(score) as sample_variance, + VARIANCE(score) as population_variance +FROM student_scores; ``` -### keywords -VAR_SAMP,VARIANCE_SAMP,VAR,SAMP,VARIANCE +```text ++------------------+---------------------+ +| sample_variance | population_variance | ++------------------+---------------------+ +| 29.4107142857143 | 25.73437500000001 | ++------------------+---------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/variance.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/variance.md index 019582b0822a7..b873857e02e54 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/variance.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/variance.md @@ -24,31 +24,59 @@ specific language governing permissions and limitations under the License. --> -## VARIANCE,VAR_POP,VARIANCE_POP ## 描述 + +VARIANCE 函数计算指定表达式的统计方差。它衡量了数据值与其算术平均值之间的差异程度。 + +## 别名 + +- VAR_POP +- VARIANCE_POP + ## 语法 -`VARIANCE(expr)` +```sql +VARIANCE() +``` +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 要计算方差的列或表达式 | -返回expr表达式的方差 +## 返回值 +返回一个 DOUBLE 类型的值,表示计算得到的方差。 ## 举例 -``` -MySQL > select variance(scan_rows) from log_statis group by datetime; -+-----------------------+ -| variance(`scan_rows`) | -+-----------------------+ -| 5.6183332881176211 | -+-----------------------+ - -MySQL > select var_pop(scan_rows) from log_statis group by datetime; -+----------------------+ -| var_pop(`scan_rows`) | -+----------------------+ -| 5.6230744719006163 | -+----------------------+ +```sql +-- 创建示例表 +CREATE TABLE student_scores ( + student_id INT, + score DECIMAL(4,1) +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO student_scores VALUES +(1, 85.5), +(2, 92.0), +(3, 78.5), +(4, 88.0), +(5, 95.5), +(6, 82.0), +(7, 90.0), +(8, 87.5); +-- 计算学生成绩的方差 +SELECT VARIANCE(score) as score_variance +FROM student_scores; ``` -### keywords -VARIANCE,VAR_POP,VARIANCE_POP,VAR,POP +```text ++-------------------+ +| score_variance | ++-------------------+ +| 25.73437499999998 | ++-------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/window-funnel.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/window-funnel.md index dd00c0bada841..c25d317952a5d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/window-funnel.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/window-funnel.md @@ -1,6 +1,6 @@ --- { - "title": "WINDOW_FUNCTION_WINDOW_FUNNEL", + "title": "WINDOW_FUNNEL", "language": "zh-CN" } --- @@ -11,19 +11,9 @@ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> -## WINDOW FUNCTION WINDOW_FUNNEL ## 描述 -在滑动时间窗口中搜索事件链,并计算链中发生的最大事件数。 - -- window :滑动时间窗口大小,单位为秒。 -- mode :模式,共有四种模式 - - "default": 默认模式。 - - "deduplication": 当某个事件重复发生时,这个重复发生的事件会阻止后续的处理过程。如,指定事件链为[event1='A', event2='B', event3='C', event4='D'],原始事件链为"A-B-C-B-D"。由于B事件重复,最终的结果事件链为A-B-C,最大长度为3。 - - "fixed": 不允许事件的顺序发生交错,即事件发生的顺序必须和指定的事件链顺序一致。如,指定事件链为[event1='A', event2='B', event3='C', event4='D'],原始事件链为"A-B-D-C",则结果事件链为A-B,最大长度为2 - - "increase": 选中的事件的时间戳必须按照指定事件链严格递增。 -- timestamp_column :指定时间列,类型为DATETIME, 滑动窗口沿着此列工作。 -- eventN :表示事件的布尔表达式。 +WINDOW_FUNNEL 函数用于分析用户行为序列,它在指定的时间窗口内搜索事件链,并计算事件链中完成的最大步骤数。这个函数特别适用于转化漏斗分析,比如分析用户从访问网站到最终购买的转化过程。 漏斗分析函数按照如下算法工作: @@ -31,15 +21,36 @@ Unless required by applicable law or agreed to in writing, software distributed - 如果事件在时间窗口内按照指定的顺序发生,时间长度累计增加。如果事件没有按照指定的顺序发生,时间长度不增加。 - 如果搜索到多个事件链,漏斗分析函数返回最大的长度。 +## 语法 + ```sql -window_funnel(window, mode, timestamp_column, event1, event2, ... , eventN) +WINDOW_FUNNEL(, , , [, event_2, ... , event_n]) ``` +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 滑动时间窗口大小,单位为秒 | +| `` | 模式,共有四种模式,分别为`default`, `deduplication`, `fixed`, `increase`,详细请参见下面的**模式** | +| `` | 指定时间列,类型为DATETIME, 滑动窗口沿着此列工作 | +| `` | 表示事件的布尔表达式。 | + +**模式** + - `default`: 默认模式。 + - `deduplication`: 当某个事件重复发生时,这个重复发生的事件会阻止后续的处理过程。如,指定事件链为[event1='A', event2='B', event3='C', event4='D'],原始事件链为"A-B-C-B-D"。由于B事件重复,最终的结果事件链为A-B-C,最大长度为3。 + - `fixed`: 不允许事件的顺序发生交错,即事件发生的顺序必须和指定的事件链顺序一致。如,指定事件链为[event1='A', event2='B', event3='C', event4='D'],原始事件链为"A-B-D-C",则结果事件链为A-B,最大长度为2 + - `increase`: 选中的事件的时间戳必须按照指定事件链严格递增。 + +## 返回值 + +返回一个整数,表示在指定时间窗口内完成的最大连续步骤数。 + ## 举例 ### 举例1: default 模式 -使用默认模式,筛选出不同```user_id```对应的最大连续事件数,时间窗口为```5```分钟: +使用默认模式,筛选出不同`user_id`对应的最大连续事件数,时间窗口为`5`分钟: ```sql CREATE TABLE events( @@ -82,7 +93,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -93,11 +106,11 @@ order BY +---------+-------+ ``` -对于```uesr_id=100123```,因为```付款```事件发生的时间超出了时间窗口,所以匹配到的事件链是```登陆-访问-下单```。 +对于`uesr_id=100123`,因为`付款`事件发生的时间超出了时间窗口,所以匹配到的事件链是`登陆-访问-下单`。 ### 举例2: deduplication 模式 -使用```deduplication```模式,筛选出不同```user_id```对应的最大连续事件数,时间窗口为```1```小时: +使用`deduplication`模式,筛选出不同`user_id`对应的最大连续事件数,时间窗口为`1`小时: ```sql CREATE TABLE events( @@ -141,7 +154,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -151,11 +166,11 @@ order BY | 100127 | 2 | +---------+-------+ ``` -对于```uesr_id=100123```,匹配到```访问```事件后,```登录```事件重复出现,所以匹配到的事件链是```登陆-访问```。 +对于`uesr_id=100123`,匹配到`访问`事件后,`登录`事件重复出现,所以匹配到的事件链是`登陆-访问`。 ### 举例3: fixed 模式 -使用```fixed```模式,筛选出不同```user_id```对应的最大连续事件数,时间窗口为```1```小时: +使用`fixed`模式,筛选出不同`user_id`对应的最大连续事件数,时间窗口为`1`小时: ```sql CREATE TABLE events( @@ -199,7 +214,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -209,11 +226,11 @@ order BY | 100127 | 2 | +---------+-------+ ``` -对于```uesr_id=100123```,匹配到```下单```事件后,事件链被```登录2```事件打断,所以匹配到的事件链是```登陆-访问-下单```。 +对于`uesr_id=100123`,匹配到`下单`事件后,事件链被`登录2`事件打断,所以匹配到的事件链是`登陆-访问-下单`。 ### 举例4: increase 模式 -使用```increase```模式,筛选出不同```user_id```对应的最大连续事件数,时间窗口为```1```小时: +使用`increase`模式,筛选出不同`user_id`对应的最大连续事件数,时间窗口为`1`小时: ```sql CREATE TABLE events( @@ -256,7 +273,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -266,8 +285,5 @@ order BY | 100127 | 2 | +---------+-------+ ``` -对于```uesr_id=100123```,```付款```事件的时间戳与```下单```事件的时间戳发生在同一秒,没有递增,所以匹配到的事件链是```登陆-访问-下单```。 - -### keywords +对于`uesr_id=100123`,`付款`事件的时间戳与`下单`事件的时间戳发生在同一秒,没有递增,所以匹配到的事件链是`登陆-访问-下单`。 - WINDOW,FUNCTION,WINDOW_FUNNEL diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md index 2e658573e9936..571a0d1543161 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md @@ -24,27 +24,38 @@ specific language governing permissions and limitations under the License. --> -## hours_add + ## 描述 + +返回一个新的日期时间值,该值是在输入的日期时间上增加指定的小时数。 + ## 语法 -`DATETIME HOURS_ADD(DATETIME date, INT hours)` +```sql +HOURS_ADD(, ) +``` + +## 参数 -从日期时间或日期加上指定小时数 +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIME 或 DATE | +| `` | 要增加的小时数,类型为 INT | -参数 date 可以是 DATETIME 或者 DATE 类型,返回类型为 DATETIME。 +## 返回值 + +返回类型为 DATETIME,返回以输入日期时间为基准,增加指定小时数后的时间值。 ## 举例 -``` -mysql> select hours_add("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| hours_add('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-02-02 03:02:02 | -+-------------------------------------+ +```sql +SELECT HOURS_ADD('2020-02-02 02:02:02', 1); ``` -### keywords - - HOURS_ADD +```text ++------------------------------------------------------------+ +| hours_add(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), 1) | ++------------------------------------------------------------+ +| 2020-02-02 03:02:02 | ++------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md index 42290a06a827d..7b0150d470c65 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md @@ -24,25 +24,38 @@ specific language governing permissions and limitations under the License. --> -## hours_diff + ## 描述 + +开始时间到结束时间相差几小时。 + ## 语法 -`INT hours_diff(DATETIME enddate, DATETIME startdate)` +```sql +HOURS_DIFF(, ) +``` + +## 参数 -开始时间到结束时间相差几小时 +| 参数 | 说明 | +| ---- | ---- | +| `` | 结束时间,类型为 DATETIME 或 DATE | +| `` | 开始时间,类型为 DATETIME 或 DATE | + +## 返回值 + +返回类型为 INT,返回开始时间到结束时间相差的小时数。 ## 举例 -``` -mysql> select hours_diff('2020-12-25 22:00:00','2020-12-25 21:00:00'); -+----------------------------------------------------------+ -| hours_diff('2020-12-25 22:00:00', '2020-12-25 21:00:00') | -+----------------------------------------------------------+ -| 1 | -+----------------------------------------------------------+ +```sql +SELECT HOURS_DIFF('2020-12-25 22:00:00', '2020-12-25 21:00:00'); ``` -### keywords - - hours_diff +```text ++--------------------------------------------------------------------------------------------------------+ +| hours_diff(cast('2020-12-25 22:00:00' as DATETIMEV2(0)), cast('2020-12-25 21:00:00' as DATETIMEV2(0))) | ++--------------------------------------------------------------------------------------------------------+ +| 1 | ++--------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md index 72cdcbb4b3a6c..7d46e4a94db55 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md @@ -24,27 +24,38 @@ specific language governing permissions and limitations under the License. --> -## hours_sub + ## 描述 + +返回一个新的日期时间值,该值是从输入的日期时间中减去指定的小时数。 + ## 语法 -`DATETIME HOURS_SUB(DATETIME date, INT hours)` +```sql +HOURS_SUB(, ) +``` + +## 参数 -从日期时间或日期减去指定小时数 +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIME 或 DATE | +| `` | 要减去的小时数,类型为 INT | -参数 date 可以是 DATETIME 或者 DATE 类型,返回类型为 DATETIME。 +## 返回值 + +返回类型为 DATETIME,返回以输入日期时间为基准,减去指定小时数后的时间值。 ## 举例 -``` -mysql> select hours_sub("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| hours_sub('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-02-02 01:02:02 | -+-------------------------------------+ +```sql +SELECT HOURS_SUB('2020-02-02 02:02:02', 1); ``` -### keywords - - HOURS_SUB +```text ++------------------------------------------------------------+ +| hours_sub(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), 1) | ++------------------------------------------------------------+ +| 2020-02-02 01:02:02 | ++------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md index 02f695b712737..456daea9869af 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md @@ -22,28 +22,42 @@ specific language governing permissions and limitations under the License. --> -## last_day + ## 描述 + +返回输入日期所在月份的最后一天的日期。根据不同月份,返回日期的具体日期值为: + +- 28 日:非闰年的二月 +- 29 日:闰年的二月 +- 30 日:四月、六月、九月、十一月 +- 31 日:一月、三月、五月、七月、八月、十月、十二月 + ## 语法 -`DATE last_day(DATETIME date)` +```sql +LAST_DAY() +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIME 或 DATE | + +## 返回值 -返回输入日期中月份的最后一天;所以返回的日期中,年和月不变,日可能是如下情况: -'28'(非闰年的二月份), -'29'(闰年的二月份), -'30'(四月,六月,九月,十一月), -'31'(一月,三月,五月,七月,八月,十月,十二月) +返回类型为 DATE,返回输入日期所在月份的最后一天的日期。 ## 举例 -``` -mysql > select last_day('2000-02-03'); -+-------------------+ -| last_day('2000-02-03 00:00:00') | -+-------------------+ -| 2000-02-29 | -+-------------------+ +```sql +SELECT LAST_DAY('2000-02-03'); ``` -### keywords - LAST_DAY,DAYS +```text ++-----------------------------------------------+ +| last_day(cast('2000-02-03' as DATETIMEV2(0))) | ++-----------------------------------------------+ +| 2000-02-29 | ++-----------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md index 6ab0f9704b8ab..e2d1615ec6d47 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md @@ -24,24 +24,42 @@ specific language governing permissions and limitations under the License. --> -## makedate + ## 描述 + +根据指定的年份和一年中的天数(dayofyear)构建并返回一个日期。 + +特殊情况: +- 当 `` 小于等于 0 时,返回 NULL +- 当 `` 超过当年天数时,会自动往后顺延到下一年 + ## 语法 -`DATE MAKEDATE(INT year, INT dayofyear)` +```sql +MAKEDATE(, ) +``` + +## 参数 -返回指定年份和dayofyear构建的日期。dayofyear必须大于0,否则结果为空。 +| 参数 | 说明 | +| ---- | ---- | +| year | 指定的年份,类型为 INT | +| dayofyear | 一年中的第几天(1-366),类型为 INT | + +## 返回值 + +返回类型为 DATE,返回以指定年份和一年中的第几天构建的日期。 ## 举例 + +```sql +SELECT MAKEDATE(2021, 1), MAKEDATE(2021, 100), MAKEDATE(2021, 400); ``` -mysql> select makedate(2021,1), makedate(2021,100), makedate(2021,400); + +```text +-------------------+---------------------+---------------------+ | makedate(2021, 1) | makedate(2021, 100) | makedate(2021, 400) | +-------------------+---------------------+---------------------+ | 2021-01-01 | 2021-04-10 | 2022-02-04 | +-------------------+---------------------+---------------------+ ``` - -### keywords - - MAKEDATE diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md index 513b0314b5d80..e529b88d9d49c 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md @@ -24,26 +24,37 @@ specific language governing permissions and limitations under the License. --> -## microsecond + ## 描述 + +从日期时间值中提取微秒部分的值。返回的范围是 0 到 999999。 + ## 语法 -`INT MICROSECOND(DATETIMEV2 date)` +```sql +MICROSECOND() +``` + +## 参数 +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIMEV2,精度需要大于 0 | -获得日期中的微秒信息。 +## 返回值 -参数为 Datetime 类型 +返回类型为 INT,返回日期时间值中的微秒部分。取值范围为 0 到 999999。对于精度小于 6 的输入,不足的位数补 0。 ## 举例 +```sql +SELECT MICROSECOND(CAST('1999-01-02 10:11:12.000123' AS DATETIMEV2(6))) AS microsecond; ``` -mysql> select microsecond(cast('1999-01-02 10:11:12.000123' as datetimev2(6))) as microsecond; + +```text +-------------+ | microsecond | +-------------+ | 123 | +-------------+ ``` -### keywords - MICROSECOND diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md index 962a328dcf636..7eb111621184b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md @@ -24,25 +24,42 @@ specific language governing permissions and limitations under the License. --> -## microseconds_add + ## 描述 + +向日期时间值中添加指定的微秒数,返回一个新的日期时间值。 + ## 语法 -`DATETIMEV2 microseconds_add(DATETIMEV2 basetime, INT delta)` -- basetime: DATETIMEV2 类型起始时间 -- delta: 从 basetime 起需要相加的微秒数 -- 返回类型为 DATETIMEV2 +```sql +MICROSECONDS_ADD(, ) +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIMEV2 | +| `` | 要添加的微秒数,类型为 INT,1 秒 = 1,000,000 微秒 | + +## 返回值 + +返回类型为 DATETIMEV2,返回以输入日期时间为基准,增加指定微秒数后的时间值。返回值的精度与输入参数 basetime 的精度相同。 ## 举例 + +```sql +SELECT NOW(3) AS current_time, MICROSECONDS_ADD(NOW(3), 100000) AS after_add; ``` -mysql> select now(3), microseconds_add(now(3), 100000); -+-------------------------+----------------------------------+ -| now(3) | microseconds_add(now(3), 100000) | -+-------------------------+----------------------------------+ -| 2023-02-21 11:35:56.556 | 2023-02-21 11:35:56.656 | -+-------------------------+----------------------------------+ + +```text ++-------------------------+----------------------------+ +| current_time | after_add | ++-------------------------+----------------------------+ +| 2025-01-16 11:48:10.505 | 2025-01-16 11:48:10.605000 | ++-------------------------+----------------------------+ ``` -`now(3)` 返回精度位数 3 的 DATETIMEV2 类型当前时间,`microseconds_add(now(3), 100000)` 返回当前时间加上 100000 微秒后的 DATETIMEV2 类型时间 -### keywords - microseconds_add +注意: +- NOW(3) 返回精度为 3 位小数的当前时间 +- 添加 100000 微秒(0.1 秒)后,时间增加了 0.1 秒 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md index 2dfb6fe286610..fa70308687ee5 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md @@ -24,26 +24,41 @@ specific language governing permissions and limitations under the License. --> -## microseconds_diff + ## 描述 + +计算两个日期时间值之间的微秒差值。结果为 `` 减去 `` 的微秒数。 + ## 语法 -`INT microseconds_diff(DATETIME enddate, DATETIME startdate)` +```sql +MICROSECONDS_DIFF(, ) +``` + +## 参数 -开始时间到结束时间相差几微秒 +| 参数 | 说明 | +| ---- | ---- | +| `` | 结束时间,类型为 DATETIMEV2 | +| `` | 开始时间,类型为 DATETIMEV2 | + +## 返回值 + +返回类型为 INT,表示两个时间之间的微秒差值。 +- 如果 `` 大于 ``,返回正数 +- 如果 `` 小于 ``,返回负数 +- 1 秒 = 1,000,000 微秒 ## 举例 +```sql +SELECT MICROSECONDS_DIFF('2020-12-25 21:00:00.623000','2020-12-25 21:00:00.123000'); ``` -mysql> select microseconds_diff('2020-12-25 21:00:00.623000','2020-12-25 21:00:00.123000'); + +```text +-----------------------------------------------------------------------------------------------------------------------------+ -| microseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(6)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(6))) | +| microseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(3)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(3))) | +-----------------------------------------------------------------------------------------------------------------------------+ | 500000 | +-----------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.12 sec) ``` - -### keywords - - microseconds_diff diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md index 6882ec9daa6f0..20dc5382c3208 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md @@ -24,27 +24,43 @@ specific language governing permissions and limitations under the License. --> -## microseconds_sub + ## 描述 + +从日期时间值中减去指定的微秒数,返回一个新的日期时间值。 + ## 语法 -`DATETIMEV2 microseconds_sub(DATETIMEV2 basetime, INT delta)` -- basetime: DATETIMEV2 类型起始时间 -- delta: 从 basetime 起需要扣减的微秒数 -- 返回类型为 DATETIMEV2 +```sql +MICROSECONDS_SUB(, ) +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIMEV2 | +| `` | 要减去的微秒数,类型为 INT,1 秒 = 1,000,000 微秒 | + +## 返回值 + +返回类型为 DATETIMEV2,返回以输入日期时间为基准,减去指定微秒数后的时间值。返回值的精度与输入参数 basetime 的精度相同。 ## 举例 + +```sql +SELECT NOW(3) AS current_time, MICROSECONDS_SUB(NOW(3), 100000) AS after_sub; ``` -mysql> select now(3), microseconds_sub(now(3), 100000); -+-------------------------+----------------------------------+ -| now(3) | microseconds_sub(now(3), 100000) | -+-------------------------+----------------------------------+ -| 2023-02-25 02:03:05.174 | 2023-02-25 02:03:05.074 | -+-------------------------+----------------------------------+ -``` -`now(3)` 返回精度位数 3 的 DATETIMEV2 类型当前时间,`microseconds_add(now(3), 100000)` 返回当前时间减去 100000 微秒后的 DATETIMEV2 类型时间 -### keywords - microseconds_sub +```text ++-------------------------+----------------------------+ +| current_time | after_sub | ++-------------------------+----------------------------+ +| 2025-01-16 11:52:22.296 | 2025-01-16 11:52:22.196000 | ++-------------------------+----------------------------+ +``` - \ No newline at end of file +注意: +- `NOW(3)` 返回精度为 3 位小数的当前时间 +- 减去 100000 微秒(0.1 秒)后,时间减少了 0.1 秒 +- 函数的计算结果与输入时间的精度有关 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md index 7575f0502214c..658634d67ea9a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md @@ -24,28 +24,43 @@ specific language governing permissions and limitations under the License. --> -## milliseconds_add + ## 描述 + +向日期时间值中添加指定的毫秒数,返回一个新的日期时间值。 + ## 语法 -`DATETIMEV2 milliseconds_add(DATETIMEV2 basetime, INT delta)` -- basetime: DATETIMEV2 类型起始时间 -- delta: 从 basetime 起需要相加的毫秒数 -- 返回类型为 DATETIMEV2 +```sql +MILLISECONDS_ADD(, ) +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIMEV2 | +| `` | 要添加的毫秒数,类型为 INT,1 秒 = 1,000 毫秒 = 1,000,000 微秒 | + +## 返回值 + +返回类型为 DATETIMEV2,返回以输入日期时间为基准,增加指定毫秒数后的时间值。返回值的精度与输入参数 basetime 的精度相同。 ## 举例 + +```sql +SELECT MILLISECONDS_ADD('2023-09-08 16:02:08.435123', 1); ``` -mysql> select milliseconds_add('2023-09-08 16:02:08.435123', 1); + +```text +--------------------------------------------------------------------------+ | milliseconds_add(cast('2023-09-08 16:02:08.435123' as DATETIMEV2(6)), 1) | +--------------------------------------------------------------------------+ | 2023-09-08 16:02:08.436123 | +--------------------------------------------------------------------------+ -1 row in set (0.04 sec) ``` - -### keywords - milliseconds_add - - \ No newline at end of file +注意: +- 示例中添加 1 毫秒后,时间从 .435123 增加到 .436123 +- 1 毫秒等于 1000 微秒 +- 函数的计算结果与输入时间的精度有关,示例使用了 6 位小数精度 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md index b30e62fb8bd4c..caea0e696f08e 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md @@ -24,26 +24,46 @@ specific language governing permissions and limitations under the License. --> -## milliseconds_diff ## 描述 + +计算两个日期时间值之间的毫秒差值。结果为 `` 减去 `` 的毫秒数。 + ## 语法 -`INT milliseconds_diff(DATETIME enddate, DATETIME startdate)` +```sql +MILLISECONDS_DIFF(, ) +``` + +## 参数 -开始时间到结束时间相差几毫秒 +| 参数 | 说明 | +| ---- | ---- | +| `` | 结束时间,类型为 DATETIMEV2 | +| `` | 开始时间,类型为 DATETIMEV2 | + +## 返回值 + +返回类型为 INT,表示两个时间之间的毫秒差值。 +- 如果 `` 大于 ``,返回正数 +- 如果 `` 小于 ``,返回负数 +- 1 秒 = 1,000 毫秒 +- 1 毫秒 = 1,000 微秒 ## 举例 +```sql +SELECT MILLISECONDS_DIFF('2020-12-25 21:00:00.623000', '2020-12-25 21:00:00.123000'); ``` -mysql> select milliseconds_diff('2020-12-25 21:00:00.623000','2020-12-25 21:00:00.123000'); + +```text +-----------------------------------------------------------------------------------------------------------------------------+ -| milliseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(6)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(6))) | +| milliseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(3)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(3))) | +-----------------------------------------------------------------------------------------------------------------------------+ | 500 | +-----------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) ``` -### keywords - - milliseconds_diff +注意: +- 示例中的时间差为 0.5 秒,即 500 毫秒 +- 函数的计算结果与输入时间的精度有关,示例使用了 3 位小数精度 +- 结果只返回毫秒差值,不包含微秒部分 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md index 840a533669bab..ee0608d66eb3f 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md @@ -24,28 +24,43 @@ specific language governing permissions and limitations under the License. --> -## milliseconds_sub ## 描述 + +从日期时间值中减去指定的毫秒数,返回一个新的日期时间值。 + ## 语法 -`DATETIMEV2 milliseconds_sub(DATETIMEV2 basetime, INT delta)` -- basetime: DATETIMEV2 类型起始时间 -- delta: 从 basetime 起需要扣减的毫秒数 -- 返回类型为 DATETIMEV2 +```sql +MILLISECONDS_SUB(, ) +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIMEV2 | +| `` | 要减去的毫秒数,类型为 INT,1 秒 = 1,000 毫秒 = 1,000,000 微秒 | + +## 返回值 + +返回类型为 DATETIMEV2,返回以输入日期时间为基准,减去指定毫秒数后的时间值。返回值的精度与输入参数 basetime 的精度相同。 ## 举例 + +```sql +SELECT MILLISECONDS_SUB('2023-09-08 16:02:08.435123', 1); ``` -mysql> select milliseconds_sub('2023-09-08 16:02:08.435123', 1); + +```text +--------------------------------------------------------------------------+ | milliseconds_sub(cast('2023-09-08 16:02:08.435123' as DATETIMEV2(6)), 1) | +--------------------------------------------------------------------------+ | 2023-09-08 16:02:08.434123 | +--------------------------------------------------------------------------+ -1 row in set (0.11 sec) ``` - -### keywords - milliseconds_sub - - \ No newline at end of file +注意: +- 示例中减去 1 毫秒后,时间从 .435123 减少到 .434123 +- 1 毫秒等于 1000 微秒 +- 函数的计算结果与输入时间的精度有关,示例使用了 6 位小数精度 +- 结果保留了微秒级别的精度 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md index 54a81bf3a8668..1a5cdf24810ce 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md @@ -1,6 +1,6 @@ --- { - "title": "minute_floor", + "title": "MINUTE_FLOOR", "language": "zh-CN" } --- @@ -24,39 +24,51 @@ specific language governing permissions and limitations under the License. --> -## minute_floor ## 描述 + +将日期时间向下取整到最近的指定分钟周期。如果指定了起始时间(origin),则以该时间为基准计算周期。 + ## 语法 ```sql -DATETIME MINUTE_FLOOR(DATETIME datetime) -DATETIME MINUTE_FLOOR(DATETIME datetime, DATETIME origin) -DATETIME MINUTE_FLOOR(DATETIME datetime, INT period) -DATETIME MINUTE_FLOOR(DATETIME datetime, INT period, DATETIME origin) +MINUTE_FLOOR() +MINUTE_FLOOR(, ) +MINUTE_FLOOR(, ) +MINUTE_FLOOR(, , ) ``` -将日期转化为指定的时间间隔周期的最近下取整时刻。 +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 需要向下取整的日期时间值,类型为 DATETIME 或 DATETIMEV2 | +| `` | 分钟周期值,类型为 INT,表示每个周期包含的分钟数 | +| `` | 周期的起始时间点,类型为 DATETIME 或 DATETIMEV2,默认值为 0001-01-01 00:00:00 | + +## 返回值 -- datetime:参数是合法的日期表达式。 -- period:参数是指定每个周期有多少天组成。 -- origin:开始的时间起点,如果不填,默认是 0001-01-01T00:00:00。 +返回类型为 DATETIMEV2,表示向下取整后的日期时间值。 ## 举例 +```sql +SELECT MINUTE_FLOOR("2023-07-13 22:28:18", 5); ``` -mysql> select minute_floor("2023-07-13 22:28:18", 5); + +```text +---------------------------------------------------------------+ | minute_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +---------------------------------------------------------------+ | 2023-07-13 22:25:00 | +---------------------------------------------------------------+ -1 row in set (0.06 sec) ``` -### keywords - - MINUTE_FLOOR, MINUTE, FLOOR +注意: +- 不指定 period 时,默认以 1 分钟为周期 +- period 必须为正整数 +- 结果总是向过去时间取整 +- 与 MINUTE_CEIL 相反,MINUTE_FLOOR 总是舍去超出周期的部分 -### Best Practice +## 最佳实践 还可参阅 [date_floor](./date_floor) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md index 0803c1f016ab0..fcd872cb1c358 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md @@ -25,26 +25,41 @@ under the License. --> -## Description +## 描述 +从日期时间值中提取分钟部分的值。返回值范围为 0 到 59。 -获得日期中的分钟的信息,返回值范围从 0-59。 +## 语法 -参数为 Date 或者 Datetime,Time 类型 +```sql +MINUTE() +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型可以是 DATE、DATETIME、DATETIMEV2 或 TIME | -## Syntax +## 返回值 -`INT MINUTE(DATETIME date)` +返回类型为 INT,表示分钟值,取值范围为 0-59。 -## Example +## 举例 ```sql -mysql> select minute('2018-12-31 23:59:59'); -+-----------------------------+ -| minute('2018-12-31 23:59:59') | -+-----------------------------+ -| 59 | -+-----------------------------+ +SELECT MINUTE('2018-12-31 23:59:59'); ``` -## Keywords - MINUTE + +```text ++------------------------------------------------------+ +| minute(cast('2018-12-31 23:59:59' as DATETIMEV2(0))) | ++------------------------------------------------------+ +| 59 | ++------------------------------------------------------+ +``` + +注意: +- 输入参数可以是多种时间相关类型 +- 返回值始终是 0-59 之间的整数 +- 如果输入参数为 NULL,则返回 NULL diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minute_ceil.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minute_ceil.md index d8f9cec1ff25b..006bac979249d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minute_ceil.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minute_ceil.md @@ -1,6 +1,6 @@ --- { - "title": "minute_ceil", + "title": "MINUTE_CEIL", "language": "zh-CN" } --- @@ -24,39 +24,50 @@ specific language governing permissions and limitations under the License. --> -## minute_ceil ## 描述 + +将日期时间向上取整到最近的指定分钟周期。如果指定了起始时间(origin),则以该时间为基准计算周期。 + ## 语法 ```sql -DATETIME MINUTE_CEIL(DATETIME datetime) -DATETIME MINUTE_CEIL(DATETIME datetime, DATETIME origin) -DATETIME MINUTE_CEIL(DATETIME datetime, INT period) -DATETIME MINUTE_CEIL(DATETIME datetime, INT period, DATETIME origin) +MINUTE_CEIL() +MINUTE_CEIL(, ) +MINUTE_CEIL(, ) +MINUTE_CEIL(, , ) ``` -将日期转化为指定的时间间隔周期的最近上取整时刻。 +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 需要向上取整的日期时间值,类型为 DATETIME 或 DATETIMEV2 | +| `` | 分钟周期值,类型为 INT,表示每个周期包含的分钟数 | +| `` | 周期的起始时间点,类型为 DATETIME 或 DATETIMEV2,默认值为 0001-01-01 00:00:00 | + +## 返回值 -- datetime:参数是合法的日期表达式。 -- period:参数是指定每个周期有多少分钟组成。 -- origin:开始的时间起点,如果不填,默认是 0001-01-01T00:00:00。 +返回类型为 DATETIMEV2,返回以输入日期时间为基准,向上取整到最近的指定分钟周期后的时间值。返回值的精度与输入参数 datetime 的精度相同。 ## 举例 +```sql +SELECT MINUTE_CEIL("2023-07-13 22:28:18", 5); ``` -mysql> select minute_ceil("2023-07-13 22:28:18", 5); + +```text +--------------------------------------------------------------+ | minute_ceil(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +--------------------------------------------------------------+ | 2023-07-13 22:30:00 | +--------------------------------------------------------------+ -1 row in set (0.21 sec) ``` -### keywords - - MINUTE_CEIL, MINUTE, CEIL +注意: +- 不指定 period 时,默认以 1 分钟为周期 +- period 必须为正整数 +- 结果总是向未来时间取整 -### Best Practice +## 最佳实践 还可参阅 [date_ceil](./date_ceil) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md index 60e3e55c887b0..fe4721e2ce618 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md @@ -24,27 +24,42 @@ specific language governing permissions and limitations under the License. --> -## minutes_add ## 描述 + +向日期时间值中添加指定的分钟数,返回一个新的日期时间值。 + ## 语法 -`DATETIME MINUTES_ADD(DATETIME date, INT minutes)` +```sql +MINUTES_ADD(, ) +``` + +## 参数 -从日期时间或日期加上指定分钟数 +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型可以是 DATE、DATETIME 或 DATETIMEV2 | +| `` | 要添加的分钟数,类型为 INT,可以为正数或负数 | -参数 date 可以是 DATETIME 或者 DATE 类型,返回类型为 DATETIME。 +## 返回值 + +返回类型为 DATETIME,表示添加指定分钟数后的日期时间值。 ## 举例 -``` -mysql> select minutes_add("2020-02-02", 1); -+---------------------------------------+ -| minutes_add('2020-02-02 00:00:00', 1) | -+---------------------------------------+ -| 2020-02-02 00:01:00 | -+---------------------------------------+ +```sql +SELECT MINUTES_ADD("2020-02-02", 1); ``` -### keywords +```text ++-----------------------------------------------------+ +| minutes_add(cast('2020-02-02' as DATETIMEV2(0)), 1) | ++-----------------------------------------------------+ +| 2020-02-02 00:01:00 | ++-----------------------------------------------------+ +``` - MINUTES_ADD +注意: +- 当添加的分钟数为负数时,相当于减去对应的分钟数 +- 函数会自动处理跨小时、跨天的情况 +- 如果输入参数为 NULL,则返回 NULL diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md index 4b216c3428bdd..96e3de8cdb608 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md @@ -24,25 +24,44 @@ specific language governing permissions and limitations under the License. --> -## minutes_diff ## 描述 + +计算两个日期时间值之间的分钟差值。结果为 `` 减去 `` 的分钟数。 + ## 语法 -`INT minutes_diff(DATETIME enddate, DATETIME startdate)` +```sql +MINUTES_DIFF(, ) +``` + +## 参数 -开始时间到结束时间相差几分钟 +| 参数 | 说明 | +| ---- | ---- | +| `` | 结束时间,类型可以是 DATE、DATETIME 或 DATETIMEV2 | +| `` | 开始时间,类型可以是 DATE、DATETIME 或 DATETIMEV2 | + +## 返回值 + +返回类型为 INT,表示两个时间之间的分钟差值。 +- 如果 `` 大于 ``,返回正数 +- 如果 `` 小于 ``,返回负数 ## 举例 -``` -mysql> select minutes_diff('2020-12-25 22:00:00','2020-12-25 21:00:00'); -+------------------------------------------------------------+ -| minutes_diff('2020-12-25 22:00:00', '2020-12-25 21:00:00') | -+------------------------------------------------------------+ -| 60 | -+------------------------------------------------------------+ +```sql +SELECT MINUTES_DIFF('2020-12-25 22:00:00', '2020-12-25 21:00:00'); ``` -### keywords +```text ++----------------------------------------------------------------------------------------------------------+ +| minutes_diff(cast('2020-12-25 22:00:00' as DATETIMEV2(0)), cast('2020-12-25 21:00:00' as DATETIMEV2(0))) | ++----------------------------------------------------------------------------------------------------------+ +| 60 | ++----------------------------------------------------------------------------------------------------------+ +``` - minutes_diff +注意: +- 计算只考虑完整的分钟数,秒和毫秒部分会被忽略 +- 如果任一输入参数为 NULL,则返回 NULL +- 可以处理跨天、跨月、跨年的时间差计算 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md index 1c54f977ef150..238f3ff8159a0 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md @@ -24,27 +24,44 @@ specific language governing permissions and limitations under the License. --> -## minutes_sub + ## 描述 + +从日期时间值中减去指定的分钟数,返回一个新的日期时间值。 + ## 语法 -`DATETIME MINUTES_SUB(DATETIME date, INT minutes)` +```sql +MINUTES_SUB(, ) +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型可以是 DATE、DATETIME 或 DATETIMEV2 | +| `` | 要减去的分钟数,类型为 INT,可以为正数或负数 | -从日期时间或日期减去指定分钟数 +## 返回值 -参数 date 可以是 DATETIME 或者 DATE 类型,返回类型为 DATETIME。 +返回类型为 DATETIME,表示减去指定分钟数后的日期时间值。 ## 举例 -``` -mysql> select minutes_sub("2020-02-02 02:02:02", 1); -+---------------------------------------+ -| minutes_sub('2020-02-02 02:02:02', 1) | -+---------------------------------------+ -| 2020-02-02 02:01:02 | -+---------------------------------------+ +```sql +SELECT MINUTES_SUB("2020-02-02 02:02:02", 1); ``` -### keywords +```text ++--------------------------------------------------------------+ +| minutes_sub(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), 1) | ++--------------------------------------------------------------+ +| 2020-02-02 02:01:02 | ++--------------------------------------------------------------+ +``` - MINUTES_SUB +注意: +- 当减去的分钟数为负数时,相当于加上对应的分钟数 +- 函数会自动处理跨小时、跨天的情况 +- 如果输入参数为 NULL,则返回 NULL +- 结果会保留原始时间的秒数部分 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md index 3c56748a182d3..f26db7f8dc6bc 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md @@ -1,6 +1,6 @@ --- { - "title": "month_ceil", + "title": "MONTH_CEIL", "language": "zh-CN" } --- @@ -24,39 +24,51 @@ specific language governing permissions and limitations under the License. --> -## month_ceil ## 描述 + +将日期时间值向上取整到最近的指定月份周期。如果指定了起始时间(origin),则以该时间为基准计算周期。 + ## 语法 ```sql -DATETIME MONTH_CEIL(DATETIME datetime) -DATETIME MONTH_CEIL(DATETIME datetime, DATETIME origin) -DATETIME MONTH_CEIL(DATETIME datetime, INT period) -DATETIME MONTH_CEIL(DATETIME datetime, INT period, DATETIME origin) +MONTH_CEIL() +MONTH_CEIL(, ) +MONTH_CEIL(, ) +MONTH_CEIL(, , ) ``` -将日期转化为指定的时间间隔周期的最近上取整时刻。 +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 需要向上取整的日期时间值,类型为 DATETIME 或 DATETIMEV2 | +| `` | 月份周期值,类型为 INT,表示每个周期包含的月数 | +| `` | 周期的起始时间点,类型为 DATETIME 或 DATETIMEV2,默认值为 0001-01-01 00:00:00 | + +## 返回值 -- datetime:参数是合法的日期表达式。 -- period:参数是指定每个周期有几个月组成。 -- origin:开始的时间起点,如果不填,默认是 0001-01-01T00:00:00。 +返回类型为 DATETIME,表示向上取整后的日期时间值。结果的时间部分将被设置为 00:00:00。 ## 举例 +```sql +SELECT MONTH_CEIL("2023-07-13 22:28:18", 5); ``` -mysql> select month_ceil("2023-07-13 22:28:18", 5); + +```text +-------------------------------------------------------------+ | month_ceil(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +-------------------------------------------------------------+ | 2023-10-01 00:00:00 | +-------------------------------------------------------------+ -1 row in set (0.02 sec) ``` -### keywords - - MONTH_CEIL, MONTH, CEIL +注意: +- 不指定 period 时,默认以 1 个月为周期 +- period 必须为正整数 +- 结果总是向未来时间取整 +- 返回值的时间部分总是 00:00:00 -### Best Practice +## 最佳实践 还可参阅 [date_ceil](./date_ceil) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md index e1684fce70bfa..45610a1bfb732 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md @@ -1,6 +1,6 @@ --- { - "title": "month_floor", + "title": "MONTH_FLOOR", "language": "zh-CN" } --- @@ -24,39 +24,52 @@ specific language governing permissions and limitations under the License. --> -## month_floor ## 描述 + +将日期时间值向下取整到最近的指定月份周期。如果指定了起始时间(origin),则以该时间为基准计算周期。 + ## 语法 ```sql -DATETIME MONTH_FLOOR(DATETIME datetime) -DATETIME MONTH_FLOOR(DATETIME datetime, DATETIME origin) -DATETIME MONTH_FLOOR(DATETIME datetime, INT period) -DATETIME MONTH_FLOOR(DATETIME datetime, INT period, DATETIME origin) +MONTH_FLOOR() +MONTH_FLOOR(, ) +MONTH_FLOOR(, ) +MONTH_FLOOR(, , ) ``` -将日期转化为指定的时间间隔周期的最近下取整时刻。 +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 需要向下取整的日期时间值,类型为 DATETIME 或 DATETIMEV2 | +| `` | 月份周期值,类型为 INT,表示每个周期包含的月数 | +| `` | 周期的起始时间点,类型为 DATETIME 或 DATETIMEV2,默认值为 0001-01-01 00:00:00 | + +## 返回值 -- datetime:参数是合法的日期表达式。 -- period:参数是指定每个周期有多少天组成。 -- origin:开始的时间起点,如果不填,默认是 0001-01-01T00:00:00。 +返回类型为 DATETIME,表示向下取整后的日期时间值。结果的时间部分将被设置为 00:00:00。 ## 举例 +```sql +SELECT MONTH_FLOOR("2023-07-13 22:28:18", 5); ``` -mysql> select month_floor("2023-07-13 22:28:18", 5); + +```text +--------------------------------------------------------------+ | month_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +--------------------------------------------------------------+ | 2023-05-01 00:00:00 | +--------------------------------------------------------------+ -1 row in set (0.12 sec) ``` -### keywords - - MONTH_FLOOR, MONTH, FLOOR +注意: +- 不指定 period 时,默认以 1 个月为周期 +- period 必须为正整数 +- 结果总是向过去时间取整 +- 返回值的时间部分总是 00:00:00 +- 与 MONTH_CEIL 相反,MONTH_FLOOR 总是舍去超出周期的部分 -### Best Practice +## 最佳实践 还可参阅 [date_floor](./date_floor) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md index 1bd5109dc589f..9a8c52bd24014 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md @@ -24,28 +24,40 @@ specific language governing permissions and limitations under the License. --> -## month + ## 描述 + +从日期时间值中提取月份值。返回值范围为 1 到 12,分别代表一年中的 12 个月。 + ## 语法 -`INT MONTH(DATETIME date)` +```sql +MONTH() +``` + +## 参数 +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型可以是 DATE、DATETIME 或 DATETIMEV2 | -返回时间类型中的月份信息,范围是1, 12 +## 返回值 -参数为Date或者Datetime类型 +返回类型为 INT,表示月份值: +- 范围:1 到 12 +- 1 表示一月,12 表示十二月 +- 如果输入为 NULL,返回 NULL ## 举例 -``` -mysql> select month('1987-01-01'); -+-----------------------------+ -| month('1987-01-01 00:00:00') | -+-----------------------------+ -| 1 | -+-----------------------------+ +```sql +SELECT MONTH('1987-01-01'); ``` -### keywords - - MONTH +```text ++--------------------------------------------+ +| month(cast('1987-01-01' as DATETIMEV2(0))) | ++--------------------------------------------+ +| 1 | ++--------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md index 14475378ebc09..742c6a971f783 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md @@ -24,28 +24,40 @@ specific language governing permissions and limitations under the License. --> -## monthname + ## 描述 + +返回日期对应的英文月份名称。返回值为完整的英文月份名称(January 到 December)。 + ## 语法 -`VARCHAR MONTHNAME(DATE)` +```sql +MONTHNAME() +``` + +## 参数 +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型可以是 DATE、DATETIME 或 DATETIMEV2 | -返回日期对应的月份名字 +## 返回值 -参数为Date或者Datetime类型 +返回类型为 VARCHAR,表示月份的英文名称: +- 返回值范围:January, February, March, April, May, June, July, August, September, October, November, December +- 如果输入为 NULL,返回 NULL +- 返回值首字母大写,其余字母小写 ## 举例 -``` -mysql> select monthname('2008-02-03 00:00:00'); -+----------------------------------+ -| monthname('2008-02-03 00:00:00') | -+----------------------------------+ -| February | -+----------------------------------+ +```sql +SELECT MONTHNAME('2008-02-03 00:00:00'); ``` -### keywords - - MONTHNAME +```text ++---------------------------------------------------------+ +| monthname(cast('2008-02-03 00:00:00' as DATETIMEV2(0))) | ++---------------------------------------------------------+ +| February | ++---------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/json-functions/json-array.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/json-functions/json-array.md index 2b418ae1e17c6..a134cca9cd689 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/json-functions/json-array.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/json-functions/json-array.md @@ -24,47 +24,73 @@ specific language governing permissions and limitations under the License. --> -## json_array ## 描述 + +生成一个包含制定元素的 json 数组,未指定时返回空数组 + ## 语法 -`VARCHAR json_array(VARCHAR,...)` +```sql +JSON_ARRAY(, ...) +``` + +## 参数 +| 参数 | 描述 | +|------|------------------------------------------------------------| +| `, ...` | 要包含在 JSON 数组中的元素。可以是单个或者多个任意类型的值,包括`NULL`。如果没有指定元素,则返回一个空数组。 | -生成一个包含指定元素的json数组,未指定时返回空数组 +## 返回值 -## 举例 +返回一个包含指定元素的 JSON 数组。特殊情况: +* 如果指定的元素为`NULL`,则返回`NULL`。 +## 示例 + +```sql +select json_array(); ``` -MySQL> select json_array(); + +```text +--------------+ | json_array() | +--------------+ | [] | +--------------+ +``` -MySQL> select json_array(null); +```sql +select json_array(null); +``` + +```text +--------------------+ | json_array('NULL') | +--------------------+ | [NULL] | +--------------------+ +``` +```sql +SELECT json_array(1, "abc", NULL, TRUE, CURTIME()); +``` -MySQL> SELECT json_array(1, "abc", NULL, TRUE, CURTIME()); +```text +-----------------------------------------------+ | json_array(1, 'abc', 'NULL', TRUE, curtime()) | +-----------------------------------------------+ | [1, "abc", NULL, TRUE, "10:41:15"] | +-----------------------------------------------+ +``` +```sql +select json_array("a", null, "c"); +``` -MySQL> select json_array("a", null, "c"); +```text +------------------------------+ | json_array('a', 'NULL', 'c') | +------------------------------+ | ["a", NULL, "c"] | +------------------------------+ ``` -### keywords -json,array,json_array diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/json-functions/jsonb-extract.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/json-functions/jsonb-extract.md deleted file mode 100644 index 967d1a45b2e75..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/json-functions/jsonb-extract.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -{ - "title": "JSON_EXTRACT", - "language": "zh-CN" -} ---- - - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md index f6b0cdb832217..e1ce4ac677fae 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md @@ -26,48 +26,35 @@ under the License. ## 描述 +判断给定 `map` 中是否包含特定的键 `key` + ## 语法 -`BOOLEAN map_contains_key(Map map, K key)` +```sql +MAP_CONTAINS_KEY(, ) +``` -判断给定 `map` 中是否包含特定的键 `key` +## 参数 -## 举例 +| 参数 | 说明 | +| -- | -- | +| `` | 输入的 map 内容 | +| `` | 需要检索的key | -```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +## 返回值 -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +判断给定 `map` 中是否包含特定的键 `key`,存在返回 1 ,不存在返回 0 。 -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +## 举例 -mysql> select map_contains_key(map(null, 1, 2, null), null); -+-----------------------------------------------+ -| map_contains_key(map(NULL, 1, 2, NULL), NULL) | -+-----------------------------------------------+ -| 1 | -+-----------------------------------------------+ -1 row in set (0.14 sec) +```sql +select map_contains_key(map(null, 1, 2, null), null),map_contains_key(map(1, "100", 0.1, 2), 0.11); ``` -### Keywords - -MAP, CONTAINS, KEY, MAP_CONTAINS_KEY +```text ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_key(map(NULL, 1, 2, NULL), NULL) | map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast(0.11 as DECIMALV3(3, 2))) | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md index 8e2eb5b56a700..c255f874055f1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md @@ -26,64 +26,35 @@ under the License. ## 描述 -## 语法 - -`BOOLEAN map_contains_value(Map map, V value)` - 判断给定 `map` 中是否包含特定的值 `value` -## 举例 +## 语法 ```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +MAP_CONTAINS_VALUE(, ) +``` -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## 参数 -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +| 参数 | 说明 | +| -- | -- | +| `` | 输入的 map 内容 | +| `` | 需要检索的 value | -mysql> select map_contains_value(map(1, "100", 0.1, 2), 100.0); -+--------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(100.0 as VARCHAR(3))) | -+--------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+--------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## 返回值 -mysql> select map_contains_value(map(1, "100", 0.1, 2), 101); -+------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | -+------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.14 sec) +判断给定 `map` 中是否包含特定的值 `value`,存在返回 1 ,不存在返回 0 。 -mysql> select map_contains_value(map(null, 1, 2, null), null); -+-------------------------------------------------+ -| map_contains_value(map(NULL, 1, 2, NULL), NULL) | -+-------------------------------------------------+ -| 1 | -+-------------------------------------------------+ -1 row in set (0.15 sec) -``` +## 举例 -### Keywords +```sql +select map_contains_value(map(null, 1, 2, null), null),map_contains_value(map(1, "100", 0.1, 2), 101); +``` -MAP, CONTAINS, VALUE, MAP_CONTAINS_VALUE +```text ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_value(map(NULL, 1, 2, NULL), NULL) | map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md index 852b288f2440e..5579de67ce60b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md @@ -26,32 +26,34 @@ under the License. ## 描述 +将给定 `map` 的键提取成一个对应类型的 `ARRAY` + ## 语法 -`ARRAY map_keys(Map map)` +```sql +MAP_KEYS() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 输入的 map 内容 | + +## 返回值 将给定 `map` 的键提取成一个对应类型的 `ARRAY` ## 举例 ```sql -mysql> select map_keys(map(1, "100", 0.1, 2)); -+-------------------------------------------------------------------------------------------------+ -| map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+-------------------------------------------------------------------------------------------------+ -| [1.0, 0.1] | -+-------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) - -mysql> select map_keys(map()); -+-----------------+ -| map_keys(map()) | -+-----------------+ -| [] | -+-----------------+ -1 row in set (0.12 sec) +select map_keys(map()),map_keys(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, KEYS, MAP_KEYS +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_keys(map()) | map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| [] | [1.0, 0.1] | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md index 85424d7fecd6f..b3ca337613d91 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md @@ -1,7 +1,6 @@ --- { - "title": "MAP_SIZE - ", + "title": "MAP_SIZE", "language": "zh-CN" } --- @@ -24,3 +23,37 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## 描述 + +计算 Map 中元素的个数 + +## 语法 + +```sql +MAP_SIZE() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 输入的 map 内容 | + +## 返回值 + +返回 Map 中元素的个数 + +## 举例 + +```sql +select map_size(map()),map_size(map(1, "100", 0.1, 2)); +``` + +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_size(map()) | map_size(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| 0 | 2 | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md index b5a0b2e27d326..955db06dddae3 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md @@ -26,32 +26,34 @@ under the License. ## 描述 +将给定 `map` 的值提取成一个对应类型的 `ARRAY` + ## 语法 -`ARRAY map_values(Map map)` +```sql +MAP_VALUES() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 输入的 map 内容 | + +## 返回值 将给定 `map` 的值提取成一个对应类型的 `ARRAY` ## 举例 ```sql -mysql> select map_values(map(1, "100", 0.1, 2)); -+---------------------------------------------------------------------------------------------------+ -| map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+---------------------------------------------------------------------------------------------------+ -| ["100", "2"] | -+---------------------------------------------------------------------------------------------------+ -1 row in set (0.12 sec) - -mysql> select map_values(map()); -+-------------------+ -| map_values(map()) | -+-------------------+ -| [] | -+-------------------+ -1 row in set (0.11 sec) +select map_values(map()),map_values(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, VALUES, MAP_VALUES +```text ++-------------------+---------------------------------------------------------------------------------------------------+ +| map_values(map()) | map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-------------------+---------------------------------------------------------------------------------------------------+ +| [] | ["100", "2"] | ++-------------------+---------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map.md index 80124e9a5d8ff..95896922640e5 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/map-functions/map.md @@ -26,32 +26,35 @@ under the License. ## 描述 +使用若干组键值对构造一个特定类型的 `Map` + ## 语法 -`MAP map(K key0, V value0, K key1, V value1, ..., K keyn, V valuen)` +```sql +MAP( , [, , ... ]) +``` -使用若干组键值对构造一个特定类型的 `Map` +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 构造 map 的 key | +| `` | 构造 map 的 value | + +## 返回值 + +返回由若干组键值对构造的特定类型 `Map` ## 举例 ```sql -mysql> select map(1, "100", 0.1, 2); -+---------------------------------------------------------------------------------------+ -| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | -+---------------------------------------------------------------------------------------+ -| {1.0:"100", 0.1:"2"} | -+---------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) - -mysql> select map(1, "100", 0.1, 2)[1]; -+-------------------------------------------------------------------------------------------------------------------------------+ -| element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | -+-------------------------------------------------------------------------------------------------------------------------------+ -| 100 | -+-------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +select map(1, "100", 0.1, 2),map(1, "100", 0.1, 2)[1]; ``` -### Keywords - -MAP +```text ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| {1.0:"100", 0.1:"2"} | 100 | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md index 2220defaba4de..6bac0360a12b1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md @@ -24,38 +24,52 @@ specific language governing permissions and limitations under the License. --> -## ST_Angle_Sphere +## 描述 -### Syntax +计算地球表面两点之间的圆心角,单位为 度。传入的参数分别为 X 点的经度,X 点的纬度,Y 点的经度,Y 点的纬度。 -`DOUBLE ST_Angle_Sphere(DOUBLE x_lng, DOUBLE x_lat, DOUBLE y_lng, DOUBLE y_lat)` +## 语法 -## 描述 +```sql +ST_Angle_Sphere( , , , ) +``` -计算地球表面两点之间的圆心角,单位为 度。传入的参数分别为X点的经度,X点的纬度,Y点的经度,Y点的纬度。 +## 参数 -x_lng 和 y_lng 都是经度数据,合理的取值范围是 [-180, 180]。 +| 参数 | 说明 | +| -- | -- | +| `` | 经度数据,合理的取值范围是 [-180, 180] | +| `` | 经度数据,合理的取值范围是 [-180, 180] | +| `` | 纬度数据,合理的取值范围是 [-90, 90] | +| `` | 纬度数据,合理的取值范围是 [-90, 90] | -x_lat 和 y_lat 都是纬度数据,合理的取值范围是 [-90, 90]。 +## 返回值 + +两点之间的圆心角角度 ## 举例 +```sql +select ST_Angle_Sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); ``` -mysql> select ST_Angle_Sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); + +```text +---------------------------------------------------------------------------+ | st_angle_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219) | +---------------------------------------------------------------------------+ | 0.0659823452409903 | +---------------------------------------------------------------------------+ -1 row in set (0.06 sec) +``` + +```sql +select ST_Angle_Sphere(0, 0, 45, 0); +``` -mysql> select ST_Angle_Sphere(0, 0, 45, 0); +```text +----------------------------------------+ | st_angle_sphere(0.0, 0.0, 45.0, 0.0) | +----------------------------------------+ | 45 | +----------------------------------------+ -1 row in set (0.06 sec) ``` -### keywords -ST_ANGLE_SPHERE,ST,ANGLE,SPHERE + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md index d43d4f73410e3..5309c3fb6222a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md @@ -24,66 +24,95 @@ specific language governing permissions and limitations under the License. --> -## ST_Angle +## 描述 -### Syntax +输入三个点,它们表示两条相交的线。返回这些线之间的夹角。 -`DOUBLE ST_Angle(GEOPOINT point1, GEOPOINT point2, GEOPOINT point3)` +## 语法 -## 描述 +```sql +ST_Angle( , , ) +``` + +## 参数 + +| 参数 | 说明 | +|----------|--------------------------| +| `` | 第一条直线的第一个端点 | +| `` | 第一条直线的第二个端点且是第二条直线的第一个端点 | +| `` | 第二条直线的第二个端点 | -输入三个点,它们表示两条相交的线。返回这些线之间的夹角。点 2 和点 1 表示第一条线,点 2 和点 3 表示第二条线。这些线之间的夹角以弧度表示,范围为 [0, 2pi)。夹角按顺时针方向从第一条线开始测量,直至第二条线。 +## 返回值 + +这些线之间的夹角以弧度表示,范围为 [0, 2pi)。夹角按顺时针方向从第一条线开始测量,直至第二条线。 ST_ANGLE 存在以下边缘情况: -* 如果点 2 和点 3 相同,则返回 NULL。 -* 如果点 2 和点 1 相同,则返回 NULL。 -* 如果点 2 和点 3 是完全对映点,则返回 NULL。 -* 如果点 2 和点 1 是完全对映点,则返回 NULL。 -* 如果任何输入地理位置不是单点或为空地理位置,则会抛出错误。 +- 如果点 2 和点 3 相同,则返回 NULL。 +- 如果点 2 和点 1 相同,则返回 NULL。 +- 如果点 2 和点 3 是完全对映点,则返回 NULL。 +- 如果点 2 和点 1 是完全对映点,则返回 NULL。 +- 如果任何输入地理位置不是单点或为空地理位置,则会抛出错误。 ## 举例 +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1)); ``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1)); + +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------------------------+ | 4.71238898038469 | +----------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1)); +``` -mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1)); +```text +----------------------------------------------------------------------+ | st_angle(st_point(0.0, 0.0), st_point(1.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------------------------+ | 0.78547432161873854 | +----------------------------------------------------------------------+ -1 row in set (0.02 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0)); +``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0)); +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(1.0, 0.0)) | +----------------------------------------------------------------------+ | 0 | +----------------------------------------------------------------------+ -1 row in set (0.02 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 0)); +``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 0)); +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 0.0)) | +----------------------------------------------------------------------+ | NULL | +----------------------------------------------------------------------+ -1 row in set (0.03 sec) +``` -mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(-30, 0),ST_Point(150, 0)); +```sql +SELECT ST_Angle(ST_Point(0, 0),ST_Point(-30, 0),ST_Point(150, 0)); +``` + +```text +--------------------------------------------------------------------------+ | st_angle(st_point(0.0, 0.0), st_point(-30.0, 0.0), st_point(150.0, 0.0)) | +--------------------------------------------------------------------------+ | NULL | +--------------------------------------------------------------------------+ -1 row in set (0.02 sec) ``` -### keywords -ST_ANGLE,ST,ANGLE + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md index 7f3b0da7f28e4..ebb22dd79b48e 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md @@ -24,45 +24,63 @@ specific language governing permissions and limitations under the License. --> -## ST_AsBinary - -### Syntax - -`VARCHAR ST_AsBinary(GEOMETRY geo)` - ## 描述 将一个几何图形转化为一个标准 WKB(Well-known binary)的表示形式。 目前支持对几何图形是:Point, LineString, Polygon。 +## 语法 + +```sql +ST_AsBinary( ) +``` + +## 参数 + +| 参数 | 说明 | +| -- |----------| +| `` | 需要被转换的图形 | + +## 返回值 + +该几何图形的 WKB 表示形式: + ## 举例 +```sql +select ST_AsBinary(st_point(24.7, 56.7)); ``` -mysql> select ST_AsBinary(st_point(24.7, 56.7)); + +```text +----------------------------------------------+ | st_asbinary(st_point(24.7, 56.7)) | +----------------------------------------------+ | \x01010000003333333333b338409a99999999594c40 | +----------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> select ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); +```sql +select ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); +``` + +```text +--------------------------------------------------------------------------------------+ | st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +--------------------------------------------------------------------------------------+ | \x010200000002000000000000000000f03f000000000000f03f00000000000000400000000000000040 | +--------------------------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` -mysql> select ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")); +```sql +select ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")); +``` + +```text +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')) | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | \x01030000000100000006000000f3380ce6af865c402d05a4fd0f8c364041ef8d2100865c403049658a398c3640b9fb1c1f2d865c409d9b36e334883640de921cb0ab865c40cf876709328a36402cefaa07cc865c407b319413ed8a3640f3380ce6af865c402d05a4fd0f8c3640 | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.02 sec) - ``` -### keywords -ST_ASBINARY,ST,ASBINARY + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md index f86ba99a2846c..9346e7acf70df 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_AsText,ST_AsWKT ## 描述 + +将一个几何图形转化为 WKT(Well Known Text)的表示形式 + ## 语法 -`VARCHAR ST_AsText(GEOMETRY geo)` +```sql +ST_AsText( ) +``` + +# 参数 + +| 参数 | 说明 | +| -- |----------| +| `` | 待转换的几何图形 | +## 返回值 -将一个几何图形转化为WKT(Well Known Text)的表示形式 +该几何图形的 WKT 表示形式 ## 举例 +```sql +SELECT ST_AsText(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_AsText(ST_Point(24.7, 56.7)); + +```text +---------------------------------+ | st_astext(st_point(24.7, 56.7)) | +---------------------------------+ | POINT (24.7 56.7) | +---------------------------------+ ``` -### keywords -ST_ASTEXT,ST_ASWKT,ST,ASTEXT,ASWKT diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md index c04d57a205ae3..da2a98caa76d7 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md @@ -24,64 +24,84 @@ specific language governing permissions and limitations under the License. --> -## ST_Azimuth +## 描述 -### Syntax +输入两个点,并返回由点 1 和点 2 形成的线段的方位角。方位角是点 1 的真北方向线与点 1 和点 2 形成的线段之间的角的弧度。 -`DOUBLE ST_Azimuth(GEOPOINT point1, GEOPOINT point2)` +## 语法 -## 描述 +```sql +ST_Azimuth( , ) +``` +## 参数 -输入两个点,并返回由点 1 和点 2 形成的线段的方位角。方位角是点 1 的真北方向线与点 1 和点 2 形成的线段之间的角的弧度。 +| 参数 | 说明 | +|----------|--------------| +| `` | 用于计算方位角的第一个点 | +| `` | 用于计算方位角的第二个点 | -正角在球面上按顺时针方向测量。 例如,线段的方位角: +## 返回值 -* 指北是 0 -* 指东是 PI/2 -* 指南是 PI -* 指西是 3PI/2 +正角在球面上按顺时针方向测量。例如,线段的方位角: + +- 指北是 0 +- 指东是 PI/2 +- 指南是 PI +- 指西是 3PI/2 ST_Azimuth 存在以下边缘情况: -* 如果两个输入点相同,则返回 NULL。 -* 如果两个输入点是完全对映点,则返回 NULL。 -* 如果任一输入地理位置不是单点或为空地理位置,则会抛出错误。 +- 如果两个输入点相同,则返回 NULL。 +- 如果两个输入点是完全对映点,则返回 NULL。 +- 如果任一输入地理位置不是单点或为空地理位置,则会抛出错误。 ## 举例 +```sql +SELECT st_azimuth(ST_Point(1, 0),ST_Point(0, 0)); ``` -mysql> SELECT st_azimuth(ST_Point(1, 0),ST_Point(0, 0)); + +```text +----------------------------------------------------+ | st_azimuth(st_point(1.0, 0.0), st_point(0.0, 0.0)) | +----------------------------------------------------+ | 4.71238898038469 | +----------------------------------------------------+ -1 row in set (0.03 sec) +``` + +```sql +SELECT st_azimuth(ST_Point(0, 0),ST_Point(1, 0)); +``` -mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(1, 0)); +```text +----------------------------------------------------+ | st_azimuth(st_point(0.0, 0.0), st_point(1.0, 0.0)) | +----------------------------------------------------+ | 1.5707963267948966 | +----------------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(0, 1)); +```sql +SELECT st_azimuth(ST_Point(0, 0),ST_Point(0, 1)); +``` + +```text +----------------------------------------------------+ | st_azimuth(st_point(0.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------+ | 0 | +----------------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> SELECT st_azimuth(ST_Point(-30, 0),ST_Point(150, 0)); +```sql +SELECT st_azimuth(ST_Point(-30, 0),ST_Point(150, 0)); +``` + +```text +--------------------------------------------------------+ | st_azimuth(st_point(-30.0, 0.0), st_point(150.0, 0.0)) | +--------------------------------------------------------+ | NULL | +--------------------------------------------------------+ -1 row in set (0.02 sec) - ``` -### keywords -ST_AZIMUTH,ST,AZIMUTH + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md index 3ce013929a449..ff8ae0d148635 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md @@ -24,25 +24,40 @@ specific language governing permissions and limitations under the License. --> -## ST_Circle ## 描述 + +将一个 WKT(Well Known Text)转化为地球球面上的一个圆。 + ## 语法 -`GEOMETRY ST_Circle(DOUBLE center_lng, DOUBLE center_lat, DOUBLE radius)` +```sql +ST_Circle( , , ) +``` +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 圆心的经度 | +| `` | 圆心的纬度 | +| `` | 圆的半径 | +- radius 单位是米,最大支持 9999999 -将一个WKT(Well Known Text)转化为地球球面上的一个圆。其中`center_lng`表示的圆心的经度, -`center_lat`表示的是圆心的纬度,`radius`表示的是圆的半径,单位是米,最大支持9999999 +## 返回值 + +根据圆的基本信息得到的球面上的一个圆 ## 举例 +```sql +SELECT ST_AsText(ST_Circle(111, 64, 10000)); ``` -mysql> SELECT ST_AsText(ST_Circle(111, 64, 10000)); + +```text +--------------------------------------------+ | st_astext(st_circle(111.0, 64.0, 10000.0)) | +--------------------------------------------+ | CIRCLE ((111 64), 10000) | +--------------------------------------------+ ``` -### keywords -ST_CIRCLE,ST,CIRCLE + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md index a13d683fbb3ac..f299982b3ab6e 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md @@ -24,31 +24,51 @@ specific language governing permissions and limitations under the License. --> -## ST_Contains ## 描述 + +判断几何图形 shape1 是否完全能够包含几何图形 shape2 + ## 语法 +```sql +ST_Contains( , ) +``` + +## 参数 + +| 参数 | 说明 | +|----------|------------------------| +| `` | 传入的几何图形,用于判断是否包含 shape2 | +| `` | 传入的几何图形,用于判断是被 shape1 包含 | -`BOOL ST_Contains(GEOMETRY shape1, GEOMETRY shape2)` +## 返回值 +返回 1:shape1 图形可包含图形 shape2 + +返回 0:shape1 图形不可包含图形 shape2 -判断几何图形shape1是否完全能够包含几何图形shape2 ## 举例 +```sql +SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(5, 5)); ``` -mysql> SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(5, 5)); + +```text +----------------------------------------------------------------------------------------+ | st_contains(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'), st_point(5.0, 5.0)) | +----------------------------------------------------------------------------------------+ | 1 | +----------------------------------------------------------------------------------------+ +``` + +```sql +SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(50, 50)); +``` -mysql> SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(50, 50)); +```text +------------------------------------------------------------------------------------------+ | st_contains(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'), st_point(50.0, 50.0)) | +------------------------------------------------------------------------------------------+ | 0 | +------------------------------------------------------------------------------------------+ ``` -### keywords -ST_CONTAINS,ST,CONTAINS diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md index 98b520c066986..a2ef36dada741 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md @@ -24,27 +24,40 @@ specific language governing permissions and limitations under the License. --> -## ST_Distance_Sphere ## 描述 + +计算地球两点之间的球面距离,单位为 米。传入的参数分别为 X 点的经度,X 点的纬度,Y 点的经度,Y 点的纬度。 + ## 语法 -`DOUBLE ST_Distance_Sphere(DOUBLE x_lng, DOUBLE x_lat, DOUBLE y_lng, DOUBLE y_lat)` +```sql +ST_Distance_Sphere( , , , ) +``` + +## 参数 +| 参数 | 说明 | +|-----------| -- | +| `` | 经度数据,合理的取值范围是 [-180, 180] | +| `` | 经度数据,合理的取值范围是 [-180, 180] | +| `` | 纬度数据,合理的取值范围是 [-90, 90] | +| `` | 纬度数据,合理的取值范围是 [-90, 90] | -计算地球两点之间的球面距离,单位为 米。传入的参数分别为X点的经度,X点的纬度,Y点的经度,Y点的纬度。 +## 返回值 -x_lng 和 y_lng 都是经度数据,合理的取值范围是 [-180, 180]。 -x_lat 和 y_lat 都是纬度数据,合理的取值范围是 [-90, 90]。 +两点之间的球面距离 ## 举例 +```sql +select st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); ``` -mysql> select st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); + +```text +----------------------------------------------------------------------------+ | st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219) | +----------------------------------------------------------------------------+ | 7336.9135549995917 | +----------------------------------------------------------------------------+ ``` -### keywords -ST_DISTANCE_SPHERE,ST,DISTANCE,SPHERE + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md index 81678f1834136..5675c42211d16 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md @@ -24,24 +24,35 @@ specific language governing permissions and limitations under the License. --> -## ST_GeometryFromText,ST_GeomFromText ## 描述 + +将一个线型 WKT(Well Known Text)转化为对应的内存的几何形式 + ## 语法 -`GEOMETRY ST_GeometryFromText(VARCHAR wkt)` +```sql +ST_GeometryFromText( ) +``` +## 参数 + +| 参数 | 说明 | +| -- |---------| +| `` | 图形的内存形式 | +## 返回值 -将一个WKT(Well Known Text)转化为对应的内存的几何形式 +WKB 的对应的几何存储形式 ## 举例 +```sql +SELECT ST_AsText(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); ``` -mysql> SELECT ST_AsText(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); + +```text +---------------------------------------------------------+ | st_astext(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +---------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +---------------------------------------------------------+ -``` -### keywords -ST_GEOMETRYFROMTEXT,ST_GEOMFROMTEXT,ST,GEOMETRYFROMTEXT,GEOMFROMTEXT +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md index 5ddf12fe985bb..4769187879431 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md @@ -24,59 +24,83 @@ specific language governing permissions and limitations under the License. --> -## ST_GeometryFromWKB,ST_GeomFromWKB +## 描述 -### Syntax +将一个标准图形 WKB(Well-known binary)转化为对应的内存的几何形式 -`GEOMETRY ST_GeometryFromWKB(VARCHAR WKB)` +## 语法 -## 描述 +```sql +ST_GeometryFromWKB( ) +``` +## 参数 + +| 参数 | 说明 | +|---------|---------| +| `` | 图形的内存形式 | + +## 返回值 -将一个标准 WKB(Well-known binary)转化为对应的内存的几何形式 +WKB 的对应的几何存储形式 ## 举例 +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); ``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); + +```text +------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_point(24.7, 56.7)))) | +------------------------------------------------------------------+ | POINT (24.7 56.7) | +------------------------------------------------------------------+ -1 row in set (0.05 sec) +``` -mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); +```sql +select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); +``` + +```text +--------------------------------------------------------------+ | st_astext(st_geomfromwkb(st_asbinary(st_point(24.7, 56.7)))) | +--------------------------------------------------------------+ | POINT (24.7 56.7) | +--------------------------------------------------------------+ -1 row in set (0.03 sec) +``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")))); +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")))); +``` + +```text +------------------------------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')))) | +------------------------------------------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +------------------------------------------------------------------------------------------+ -1 row in set (0.06 sec) +``` + +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +```text +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) +``` + +```sql +select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +``` -mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +```text +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_astext(st_geomfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) | +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) | +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) - -``` -### keywords -ST_GEOMETRYFROMWKB,ST_GEOMFROMWKB,ST,GEOMETRYFROMWKB,GEOMFROMWKB,WKB +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md index 2a41e25f2641c..e4d6f3db4dc3e 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_LineFromText,ST_LineStringFromText ## 描述 + +将一个 WKT(Well Known Text)转化为一个 Line 形式的内存表现形式 + ## 语法 -`GEOMETRY ST_LineFromText(VARCHAR wkt)` +```sql +ST_LineFromText( ) +``` + +## 参数 +| 参数 | 说明 | +|---------|------------| +| `` | 由两个坐标组成的线段 | -将一个WKT(Well Known Text)转化为一个Line形式的内存表现形式 +## 返回值 + +线段的内存形式。 ## 举例 +```sql +SELECT ST_AsText(ST_LineFromText("LINESTRING (1 1, 2 2)")); ``` -mysql> SELECT ST_AsText(ST_LineFromText("LINESTRING (1 1, 2 2)")); + +```text +---------------------------------------------------------+ | st_astext(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +---------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +---------------------------------------------------------+ -``` -### keywords -ST_LINEFROMTEXT,ST_LINESTRINGFROMTEXT,ST,LINEFROMTEXT,LINESTRINGFROMTEXT +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md index c33eb4b733648..4370a57998dc9 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md @@ -24,25 +24,38 @@ specific language governing permissions and limitations under the License. --> -## ST_Point ## 描述 + +通过给定的 X 坐标值,Y 坐标值返回对应的 Point。 + +当前这个值只是在球面集合上有意义,X/Y 对应的是经度/纬度 (longitude/latitude); + ## 语法 -`POINT ST_Point(DOUBLE x, DOUBLE y)` +```sql +ST_Point( , ) +``` +## 参数 +| 参数 | 说明 | +|-----|-----| +| `` | 横坐标 | +| `` | 纵坐标 | -通过给定的X坐标值,Y坐标值返回对应的Point。 -当前这个值只是在球面集合上有意义,X/Y对应的是经度/纬度(longitude/latitude); +## 返回值 + +给定横坐标以及纵坐标对应的位置信息 ## 举例 +```sql +SELECT ST_AsText(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_AsText(ST_Point(24.7, 56.7)); + +```text +---------------------------------+ | st_astext(st_point(24.7, 56.7)) | +---------------------------------+ | POINT (24.7 56.7) | +---------------------------------+ -``` -### keywords -ST_POINT,ST,POINT +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md index bac2ef264de1e..50c9a24800fc7 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_Polygon,ST_PolyFromText,ST_PolygonFromText ## 描述 + +将一个 WKT(Well Known Text)转化为对应的多边形内存形式 + ## 语法 -`GEOMETRY ST_Polygon(VARCHAR wkt)` +```sql +ST_Polygon( ) +``` + +## 参数 +| 参数 | 说明 | +|------|--------------------| +| `` | 由 POLYGON 函数生成的一个多边形 | -将一个WKT(Well Known Text)转化为对应的多边形内存形式 +## 返回值 + +多边形的内存形式。 ## 举例 +```sql +SELECT ST_AsText(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))")); ``` -mysql> SELECT ST_AsText(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))")); + +```text +------------------------------------------------------------------+ | st_astext(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))')) | +------------------------------------------------------------------+ | POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0)) | +------------------------------------------------------------------+ -``` -### keywords -ST_POLYGON,ST_POLYFROMTEXT,ST_POLYGONFROMTEXT,ST,POLYGON,POLYFROMTEXT,POLYGONFROMTEXT +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md index de572bdb3dc12..54aed2165562f 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md @@ -24,24 +24,35 @@ specific language governing permissions and limitations under the License. --> -## ST_X ## 描述 + +当 point 是一个合法的 POINT 类型时,返回对应的 X 坐标值 + ## 语法 -`DOUBLE ST_X(POINT point)` +```sql +ST_X( ) +``` +## 参数 + +| 参数 | 说明 | +|-----------|----------| +| `` | 二维点的几何坐标 | +## 返回值 -当point是一个合法的POINT类型时,返回对应的X坐标值 +几何坐标中的 X 值 ## 举例 +```sql +SELECT ST_X(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_X(ST_Point(24.7, 56.7)); + +```text +----------------------------+ | st_x(st_point(24.7, 56.7)) | +----------------------------+ | 24.7 | +----------------------------+ -``` -### keywords -ST_X,ST,X +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md index c452a7a1464e7..6b105fe3543be 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md @@ -24,24 +24,35 @@ specific language governing permissions and limitations under the License. --> -## ST_Y ## 描述 + +当 point 是一个合法的 POINT 类型时,返回对应的 Y 坐标值 + ## 语法 -`DOUBLE ST_Y(POINT point)` +```sql +ST_Y( ) +``` +## 参数 + +| 参数 | 说明 | +|-----------|----------| +| `` | 二维点的几何坐标 | +## 返回值 -当point是一个合法的POINT类型时,返回对应的Y坐标值 +几何坐标中的 Y 值 ## 举例 +```sql +SELECT ST_Y(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_Y(ST_Point(24.7, 56.7)); + +```text +----------------------------+ -| st_y(st_point(24.7, 56.7)) | +| st_x(st_point(24.7, 56.7)) | +----------------------------+ -| 56.7 | +| 24.7 | +----------------------------+ -``` -### keywords -ST_Y,ST,Y +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/hdfs.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/hdfs.md index 70855c7709e27..ff21a3a8c08cc 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/hdfs.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/hdfs.md @@ -83,7 +83,7 @@ hdfs( 其他参数: - `path_partition_keys`:(选填)指定文件路径中携带的分区列名,例如/path/to/city=beijing/date="2023-07-09", 则填写`path_partition_keys="city,date"`,将会自动从路径中读取相应列名和列值进行导入。 -- `resource`:(选填)指定 Resource 名,HDFS TVF 可以利用已有的 HFDS Resource 来直接访问 HDFS。创建 HDFS Resource 的方法可以参照 [CREATE-RESOURCE](../../sql-statements/Data-Definition-Statements/Create/CREATE-RESOURCE.md)。该功能自 2.1.4 版本开始支持。 +- `resource`:(选填)指定 Resource 名,HDFS TVF 可以利用已有的 HFDS Resource 来直接访问 HDFS。创建 HDFS Resource 的方法可以参照 [CREATE-RESOURCE](../../sql-statements/cluster-management/compute-management/CREATE-RESOURCE)。该功能自 2.1.4 版本开始支持。 :::tip 注意 直接查询 TVF 或基于该 TVF 创建 View ,需要拥有该 Resource 的 USAGE 权限,查询基于 TVF 创建的 View ,只需要该 View 的 SELECT 权限 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/s3.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/s3.md index a6d5a6d77cf23..41596a0e28ff4 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/s3.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-valued-functions/s3.md @@ -97,7 +97,7 @@ S3 TVF 中的每一个参数都是一个 `"key"="value"` 对。 其他参数: - `path_partition_keys`:(选填)指定文件路径中携带的分区列名,例如 `/path/to/city=beijing/date="2023-07-09"`, 则填写 `path_partition_keys="city,date"`,将会自动从路径中读取相应列名和列值进行导入。 -- `resource`:(选填)指定 Resource 名,S3 TVF 可以利用已有的 S3 Resource 来直接访问 S3。创建 S3 Resource 的方法可以参照 [CREATE-RESOURCE](../../sql-statements/Data-Definition-Statements/Create/CREATE-RESOURCE.md)。该功能自 2.1.4 版本开始支持。 +- `resource`:(选填)指定 Resource 名,S3 TVF 可以利用已有的 S3 Resource 来直接访问 S3。创建 S3 Resource 的方法可以参照 [CREATE-RESOURCE](../../sql-statements/cluster-management/compute-management/CREATE-RESOURCE)。该功能自 2.1.4 版本开始支持。 :::tip 注意 直接查询 TVF 或基于该 TVF 创建 View ,需要拥有该 Resource 的 USAGE 权限,查询基于 TVF 创建的 View ,只需要该 View 的 SELECT 权限。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/ALTER-ROLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/ALTER-ROLE.md deleted file mode 100644 index 2d066d5eea9e6..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/ALTER-ROLE.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -{ - "title": "ALTER-ROLE", - "language": "zh-CN" -} ---- - - - -## ALTER ROLE - -### Name - -ALTER ROLE - -## 描述 - -该语句用于修改一个角色 - -```sql - ALTER ROLE role_name comment; -``` - -## 举例 - -1. 修改一个角色的注释 - - ```sql - ALTER ROLE role1 COMMENT "this is my first role"; - ``` - -### Keywords - - ALTER, ROLE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/ALTER-USER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/ALTER-USER.md deleted file mode 100644 index 30bb43a5f4f1c..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/ALTER-USER.md +++ /dev/null @@ -1,107 +0,0 @@ ---- -{ - "title": "ALTER-USER", - "language": "zh-CN" -} ---- - - - -## ALTER USER - -### Name - -ALTER USER - -## 描述 - -ALTER USER 命令用于修改一个用户的账户属性,包括密码、和密码策略等 - ->注意: -> ->从2.0版本开始,此命令不再支持修改用户角色,相关操作请使用[GRANT](./GRANT.md)和[REVOKE](./REVOKE.md) - -```sql -ALTER USER [IF EXISTS] user_identity [IDENTIFIED BY 'password'] -[password_policy] -[comment] - -user_identity: - 'user_name'@'host' - -password_policy: - - 1. PASSWORD_HISTORY [n|DEFAULT] - 2. PASSWORD_EXPIRE [DEFAULT|NEVER|INTERVAL n DAY/HOUR/SECOND] - 3. FAILED_LOGIN_ATTEMPTS n - 4. PASSWORD_LOCK_TIME [n DAY/HOUR/SECOND|UNBOUNDED] - 5. ACCOUNT_UNLOCK -``` - -关于 `user_identity`, 和 `password_policy` 的说明,请参阅 `CREATE USER` 命令。 - -`ACCOUNT_UNLOCK` 命令用于解锁一个被锁定的用户。 - -在一个 ALTER USER 命令中,只能同时对以下账户属性中的一项进行修改: - -1. 修改密码 -2. 修改 `PASSWORD_HISTORY` -3. 修改 `PASSWORD_EXPIRE` -4. 修改 `FAILED_LOGIN_ATTEMPTS` 和 `PASSWORD_LOCK_TIME` -5. 解锁用户 - -## 举例 - -1. 修改用户的密码 - - ``` - ALTER USER jack@'%' IDENTIFIED BY "12345"; - ``` - -2. 修改用户的密码策略 - - ``` - ALTER USER jack@'%' FAILED_LOGIN_ATTEMPTS 3 PASSWORD_LOCK_TIME 1 DAY; - ``` - -3. 解锁一个用户 - - ``` - ALTER USER jack@'%' ACCOUNT_UNLOCK - ``` - -4. 修改一个用户的注释 - - ``` - ALTER USER jack@'%' COMMENT "this is my first user" - ``` - -### Keywords - - ALTER, USER - -### Best Practice - -1. 修改密码策略 - - 1. 修改 `PASSWORD_EXPIRE` 会重置密码过期时间的计时。 - - 2. 修改 `FAILED_LOGIN_ATTEMPTS` 或 `PASSWORD_LOCK_TIME`,会解锁用户。 - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/CREATE-ROLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/CREATE-ROLE.md deleted file mode 100644 index 5a5e47986ab43..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/CREATE-ROLE.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -{ - "title": "CREATE-ROLE", - "language": "zh-CN" -} ---- - - - -## CREATE ROLE - -### Name - -CREATE ROLE - -## 描述 - -该语句用户创建一个角色 - -```sql - CREATE ROLE role_name [comment]; -``` - -该语句创建一个无权限的角色,可以后续通过 GRANT 命令赋予该角色权限。 - -## 举例 - -1. 创建一个角色 - - ```sql - CREATE ROLE role1; - ``` -2. 创建一个角色并添加注释 - - ```sql - CREATE ROLE role2 COMMENT "this is my first role"; - ``` - -### Keywords - - CREATE, ROLE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/CREATE-USER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/CREATE-USER.md deleted file mode 100644 index eccabf0971040..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/CREATE-USER.md +++ /dev/null @@ -1,139 +0,0 @@ ---- -{ - "title": "CREATE-USER", - "language": "zh-CN" -} ---- - - - -## CREATE USER - -### Name - -CREATE USER - -## 描述 - -CREATE USER 命令用于创建一个 Doris 用户。 - -```sql -CREATE USER [IF EXISTS] user_identity [IDENTIFIED BY 'password'] -[DEFAULT ROLE 'role_name'] -[password_policy] -[comment] - -user_identity: - 'user_name'@'host' - -password_policy: - - 1. PASSWORD_HISTORY [n|DEFAULT] - 2. PASSWORD_EXPIRE [DEFAULT|NEVER|INTERVAL n DAY/HOUR/SECOND] - 3. FAILED_LOGIN_ATTEMPTS n - 4. PASSWORD_LOCK_TIME [n DAY/HOUR/SECOND|UNBOUNDED] -``` - -在 Doris 中,一个 user_identity 唯一标识一个用户。user_identity 由两部分组成,user_name 和 host,其中 username 为用户名。host 标识用户端连接所在的主机地址。host 部分可以使用 % 进行模糊匹配。如果不指定 host,默认为 '%',即表示该用户可以从任意 host 连接到 Doris。 - -host 部分也可指定为 domain,语法为:'user_name'@['domain'],即使用中括号包围,则 Doris 会认为这个是一个 domain,并尝试解析其 ip 地址。 - -如果指定了角色(ROLE),则会自动将该角色所拥有的权限赋予新创建的这个用户。如果不指定,则该用户默认没有任何权限。指定的 ROLE 必须已经存在。 - -password_policy 是用于指定密码认证登录相关策略的子句,目前支持以下策略: - -1. `PASSWORD_HISTORY` - - 是否允许当前用户重置密码时使用历史密码。如 `PASSWORD_HISTORY 10` 表示禁止使用过去10次设置过的密码为新密码。如果设置为 `PASSWORD_HISTORY DEFAULT`,则会使用全局变量 `password_history` 中的值。`0` 表示不启用这个功能。默认为 0。 - -2. `PASSWORD_EXPIRE` - - 设置当前用户密码的过期时间。如 `PASSWORD_EXPIRE INTERVAL 10 DAY` 表示密码会在 10 天后过期。`PASSWORD_EXPIRE NEVER` 表示密码不过期。如果设置为 `PASSWORD_EXPIRE DEFAULT`,则会使用全局变量 `default_password_lifetime` 中的值。默认为 NEVER(或0),表示不会过期。 - -3. `FAILED_LOGIN_ATTEMPTS` 和 `PASSWORD_LOCK_TIME` - - 设置当前用户登录时,如果使用错误的密码登录n次后,账户将被锁定,并设置锁定时间。如 `FAILED_LOGIN_ATTEMPTS 3 PASSWORD_LOCK_TIME 1 DAY` 表示如果3次错误登录,则账户会被锁定一天。 - - 被锁定的账户可以通过 ALTER USER 语句主动解锁。 - -## 举例 - -1. 创建一个无密码用户(不指定 host,则等价于 jack@'%') - - ```sql - CREATE USER 'jack'; - ``` - -2. 创建一个有密码用户,允许从 '172.10.1.10' 登陆 - - ```sql - CREATE USER jack@'172.10.1.10' IDENTIFIED BY '123456'; - ``` - -3. 为了避免传递明文,用例2也可以使用下面的方式来创建 - - ```sql - CREATE USER jack@'172.10.1.10' IDENTIFIED BY PASSWORD '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9'; - 后面加密的内容可以通过PASSWORD()获得到,例如: - SELECT PASSWORD('123456'); - ``` - -4. 创建一个允许从 '192.168' 子网登陆的用户,同时指定其角色为 example_role - - ```sql - CREATE USER 'jack'@'192.168.%' DEFAULT ROLE 'example_role'; - ``` - -5. 创建一个允许从域名 'example_domain' 登陆的用户 - - ```sql - CREATE USER 'jack'@['example_domain'] IDENTIFIED BY '12345'; - ``` - -6. 创建一个用户,并指定一个角色 - - ```sql - CREATE USER 'jack'@'%' IDENTIFIED BY '12345' DEFAULT ROLE 'my_role'; - ``` - -7. 创建一个用户,设定密码10天后过期,并且设置如果3次错误登录则账户会被锁定一天。 - - ```sql - CREATE USER 'jack' IDENTIFIED BY '12345' PASSWORD_EXPIRE INTERVAL 10 DAY FAILED_LOGIN_ATTEMPTS 3 PASSWORD_LOCK_TIME 1 DAY; - ``` - -8. 创建一个用户,并限制不可重置密码为最近8次是用过的密码。 - - ```sql - CREATE USER 'jack' IDENTIFIED BY '12345' PASSWORD_HISTORY 8; - ``` - -9. 创建一个用户并添加注释 - - ```sql - CREATE USER 'jack' COMMENT "this is my first user"; - ``` - -### Keywords - - CREATE, USER - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/DROP-ROLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/DROP-ROLE.md deleted file mode 100644 index 1f1ea4e349537..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/DROP-ROLE.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "DROP-ROLE", - "language": "zh-CN" -} ---- - - - -## DROP-ROLE - -### Name - -DROP ROLE - -## 描述 - -语句用户删除角色 - -```sql - DROP ROLE [IF EXISTS] role1; -``` - -删除角色不会影响以前属于角色的用户的权限。 它仅相当于解耦来自用户的角色。 用户从角色获得的权限不会改变 - -## 举例 - -1. 删除一个角色 - -```sql -DROP ROLE role1; -``` - -### Keywords - - DROP, ROLE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/DROP-USER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/DROP-USER.md deleted file mode 100644 index 65c5a02ff75b6..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/DROP-USER.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -{ - "title": "DROP-USER", - "language": "zh-CN" -} ---- - - - -## DROP-USER - -### Name - -DROP USER - -## 描述 - -删除一个用户 - -```sql - DROP USER 'user_identity' - - `user_identity`: - - user@'host' - user@['domain'] -``` - - 删除指定的 user identity. - -## 举例 - -1. 删除用户 jack@'192.%' - - ```sql - DROP USER 'jack'@'192.%' - ``` - -### Keywords - - DROP, USER - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/GRANT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/GRANT.md deleted file mode 100644 index 5307b464a5ad1..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/GRANT.md +++ /dev/null @@ -1,187 +0,0 @@ ---- -{ - "title": "GRANT", - "language": "zh-CN" -} ---- - - - -## 描述 - -GRANT 命令用于: - -1. 将指定的权限授予某用户或角色。 -2. 将指定角色授予某用户。 - -## 语法 - -GRANT privilege_list ON priv_level TO user_identity [ROLE role_name] - -GRANT privilege_list ON RESOURCE resource_name TO user_identity [ROLE role_name] - -GRANT privilege_list ON WORKLOAD GROUP workload_group_name TO user_identity [ROLE role_name] - -GRANT privilege_list ON COMPUTE GROUP compute_group_name TO user_identity [ROLE role_name] - -GRANT privilege_list ON STORAGE VAULT storage_vault_name TO user_identity [ROLE role_name] - -GRANT role_list TO user_identity - -## 参数 - -### privilege_list - -需要赋予的权限列表,以逗号分隔。当前支持如下权限: - -- NODE_PRIV:集群节点操作权限,包括节点上下线等操作。 -- ADMIN_PRIV:除 NODE_PRIV 以外的所有权限。 -- GRANT_PRIV:操作权限的权限,包括创建删除用户、角色,授权和撤权,设置密码等。 -- SELECT_PRIV:对指定的库或表的读取权限。 -- LOAD_PRIV:对指定的库或表的导入权限。 -- ALTER_PRIV:对指定的库或表的 schema 变更权限。 -- CREATE_PRIV:对指定的库或表的创建权限。 -- DROP_PRIV:对指定的库或表的删除权限。 -- USAGE_PRIV:对指定资源、Workload Group、Compute Group 的使用权限。 -- SHOW_VIEW_PRIV:查看 view 创建语句的权限。 - -旧版权限转换: -- ALL 和 READ_WRITE 会被转换成:SELECT_PRIV, LOAD_PRIV, ALTER_PRIV, CREATE_PRIV, DROP_PRIV。 -- READ_ONLY 会被转换为 SELECT_PRIV。 - -### priv_level - -支持以下四种形式: - -- *.*.*:权限可以应用于所有 catalog 及其中的所有库表。 -- catalog_name.*.*:权限可以应用于指定 catalog 中的所有库表。 -- catalog_name.db.*:权限可以应用于指定库下的所有表。 -- catalog_name.db.tbl:权限可以应用于指定库下的指定表。 - -### resource_name - -指定 resource 名,支持 % 和 * 匹配所有资源,不支持通配符,比如 res*。 - -### workload_group_name - -指定 workload group 名,支持 % 和 * 匹配所有 workload group,不支持通配符。 - -### compute_group_name - -指定 compute group 名称,支持 % 和 * 匹配所有 compute group,不支持通配符。 - -### storage_vault_name - -指定 storage vault 名称,支持 % 和 * 匹配所有 storage vault,不支持通配符。 - -### user_identity - -指定接收权限的用户。必须为使用 CREATE USER 创建过的 user_identity。user_identity 中的 host 可以是域名,如果是域名的话,权限的生效时间可能会有 1 分钟左右的延迟。 - -### role_name - -指定接收权限的角色。如果指定的角色不存在,则会自动创建。 - -### role_list - -需要赋予的角色列表,以逗号分隔,指定的角色必须存在。 - -## 示例 - -1. 授予所有 catalog 和库表的权限给用户: - - GRANT SELECT_PRIV ON *.*.* TO 'jack'@'%'; - -2. 授予指定库表的权限给用户: - - GRANT SELECT_PRIV,ALTER_PRIV,LOAD_PRIV ON ctl1.db1.tbl1 TO 'jack'@'192.8.%'; - -3. 授予指定库表的权限给角色: - - GRANT LOAD_PRIV ON ctl1.db1.* TO ROLE 'my_role'; - -4. 授予所有 resource 的使用权限给用户: - - GRANT USAGE_PRIV ON RESOURCE * TO 'jack'@'%'; - -5. 授予指定 resource 的使用权限给用户: - - GRANT USAGE_PRIV ON RESOURCE 'spark_resource' TO 'jack'@'%'; - -6. 授予指定 resource 的使用权限给角色: - - GRANT USAGE_PRIV ON RESOURCE 'spark_resource' TO ROLE 'my_role'; - -7. 将指定 role 授予某用户: - - GRANT 'role1','role2' TO 'jack'@'%'; - -8. 将指定 workload group 授予用户: - - GRANT USAGE_PRIV ON WORKLOAD GROUP 'g1' TO 'jack'@'%'; - -9. 匹配所有 workload group 授予用户: - - GRANT USAGE_PRIV ON WORKLOAD GROUP '%' TO 'jack'@'%'; - -10. 将指定 workload group 授予角色: - - GRANT USAGE_PRIV ON WORKLOAD GROUP 'g1' TO ROLE 'my_role'; - -11. 允许用户查看指定 view 的创建语句: - - GRANT SHOW_VIEW_PRIV ON db1.view1 TO 'jack'@'%'; - -12. 授予用户对指定 compute group 的使用权限: - - GRANT USAGE_PRIV ON COMPUTE GROUP 'group1' TO 'jack'@'%'; - -13. 授予角色对指定 compute group 的使用权限: - - GRANT USAGE_PRIV ON COMPUTE GROUP 'group1' TO ROLE 'my_role'; - -14. 授予用户对所有 compute group 的使用权限: - - GRANT USAGE_PRIV ON COMPUTE GROUP '*' TO 'jack'@'%'; - -15. 授予用户对指定 storage vault 的使用权限: - - GRANT USAGE_PRIV ON STORAGE VAULT 'vault1' TO 'jack'@'%'; - -16. 授予角色对指定 storage vault 的使用权限: - - GRANT USAGE_PRIV ON STORAGE VAULT 'vault1' TO ROLE 'my_role'; - -17. 授予用户对所有 storage vault 的使用权限: - - GRANT USAGE_PRIV ON STORAGE VAULT '*' TO 'jack'@'%'; - -## 相关命令 - -- [REVOKE](./REVOKE.md) -- [SHOW GRANTS](../../../sql-manual/sql-statements/account-management/SHOW-GRANTS.md) -- [CREATE ROLE](./CREATE-ROLE.md) -- [CREATE WORKLOAD GROUP](../cluster-management/compute-management/CREATE-WORKLOAD-GROUP.md) -- [CREATE RESOURCE](../cluster-management/compute-management/CREATE-RESOURCE.md) -- [CREATE STORAGE VAULT](../cluster-management/storage-management/CREATE-STORAGE-VAULT.md) - -### Keywords - - GRANT, WORKLOAD GROUP, COMPUTE GROUP, STORAGE VAULT, RESOURCE \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/LDAP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/LDAP.md deleted file mode 100644 index e4be00d0ca44c..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/LDAP.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -{ - "title": "LDAP", - "language": "zh-CN" -} ---- - - - -## LDAP - -### Name - -LDAP - -## 描述 - -SET LDAP_ADMIN_PASSWORD - -```sql - SET LDAP_ADMIN_PASSWORD = PASSWORD('plain password') -``` - - SET LDAP_ADMIN_PASSWORD 命令用于设置LDAP管理员密码。使用LDAP认证时,doris需使用管理员账户和密码来向LDAP服务查询登录用户的信息。 - -## 举例 - -1. 设置LDAP管理员密码 -```sql -SET LDAP_ADMIN_PASSWORD = PASSWORD('123456') -``` - -### Keywords - - LDAP, PASSWORD, LDAP_ADMIN_PASSWORD - -### Best Practice diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/REVOKE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/REVOKE.md deleted file mode 100644 index c7ab012fe09e7..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/REVOKE.md +++ /dev/null @@ -1,161 +0,0 @@ ---- -{ - "title": "REVOKE", - "language": "zh-CN" -} ---- - - - -## 描述 - -REVOKE 命令用于: - -1. 撤销某用户或某角色的指定权限。 -2. 撤销先前授予某用户的指定角色。 - -## 语法 - -REVOKE privilege_list ON priv_level FROM user_identity [ROLE role_name] - -REVOKE privilege_list ON RESOURCE resource_name FROM user_identity [ROLE role_name] - -REVOKE privilege_list ON WORKLOAD GROUP workload_group_name FROM user_identity [ROLE role_name] - -REVOKE privilege_list ON COMPUTE GROUP compute_group_name FROM user_identity [ROLE role_name] - -REVOKE privilege_list ON STORAGE VAULT storage_vault_name FROM user_identity [ROLE role_name] - -REVOKE role_list FROM user_identity - -## 参数 - -### privilege_list - -需要撤销的权限列表,以逗号分隔。支持的权限包括: - -- NODE_PRIV:集群节点操作权限 -- ADMIN_PRIV:管理员权限 -- GRANT_PRIV:授权权限 -- SELECT_PRIV:查询权限 -- LOAD_PRIV:数据导入权限 -- ALTER_PRIV:修改权限 -- CREATE_PRIV:创建权限 -- DROP_PRIV:删除权限 -- USAGE_PRIV:使用权限 -- SHOW_VIEW_PRIV:查看视图定义权限 - -### priv_level - -指定权限的作用范围。支持以下格式: - -- *.*.*:所有 catalog、数据库和表 -- catalog_name.*.*:指定 catalog 中的所有数据库和表 -- catalog_name.db.*:指定数据库中的所有表 -- catalog_name.db.tbl:指定数据库中的特定表 - -### resource_name - -指定 resource 名称。支持 % (匹配任意字符串)和 _(匹配任意单个字符)通配符。 - -### workload_group_name - -指定 workload group 名称。支持 % (匹配任意字符串)和 _(匹配任意单个字符)通配符。 - -### compute_group_name - -指定 compute group 名称。支持 % (匹配任意字符串)和 _(匹配任意单个字符)通配符。 - -### storage_vault_name - -指定 storage vault 名称。支持 % (匹配任意字符串)和 _(匹配任意单个字符)通配符。 - - -### user_identity - -指定要撤销权限的用户。必须是使用 CREATE USER 创建的用户。user_identity 中的 host 可以是域名,如果是域名,权限的撤销时间可能会有 1 分钟左右的延迟。 - -### role_name - -指定要撤销权限的角色。该角色必须存在。 - -### role_list - -需要撤销的角色列表,以逗号分隔。指定的所有角色必须存在。 - -## 示例 - -1. 撤销用户在特定数据库上的 SELECT 权限: - - REVOKE SELECT_PRIV ON db1.* FROM 'jack'@'192.%'; - -2. 撤销用户对资源的使用权限: - - REVOKE USAGE_PRIV ON RESOURCE 'spark_resource' FROM 'jack'@'192.%'; - -3. 撤销用户的角色: - - REVOKE 'role1','role2' FROM 'jack'@'192.%'; - -4. 撤销用户对 workload group 的使用权限: - - REVOKE USAGE_PRIV ON WORKLOAD GROUP 'g1' FROM 'jack'@'%'; - -5. 撤销用户对所有 workload group 的使用权限: - - REVOKE USAGE_PRIV ON WORKLOAD GROUP '%' FROM 'jack'@'%'; - -6. 撤销角色对 workload group 的使用权限: - - REVOKE USAGE_PRIV ON WORKLOAD GROUP 'g1' FROM ROLE 'test_role'; - -7. 撤销用户对 compute group 的使用权限: - - REVOKE USAGE_PRIV ON COMPUTE GROUP 'group1' FROM 'jack'@'%'; - -8. 撤销角色对 compute group 的使用权限: - - REVOKE USAGE_PRIV ON COMPUTE GROUP 'group1' FROM ROLE 'my_role'; - -9. 撤销用户对 storage vault 的使用权限: - - REVOKE USAGE_PRIV ON STORAGE VAULT 'vault1' FROM 'jack'@'%'; - -10. 撤销角色对 storage vault 的使用权限: - - REVOKE USAGE_PRIV ON STORAGE VAULT 'vault1' FROM ROLE 'my_role'; - -11. 撤销用户对所有 storage vault 的使用权限: - - REVOKE USAGE_PRIV ON STORAGE VAULT '%' FROM 'jack'@'%'; - -## 相关命令 - -- [GRANT](./GRANT.md) -- [SHOW GRANTS](../Show-Statements/SHOW-GRANTS.md) -- [CREATE ROLE](./CREATE-ROLE.md) -- [CREATE WORKLOAD GROUP](../Administration-Statements/CREATE-WORKLOAD-GROUP.md) -- [CREATE COMPUTE GROUP](../Administration-Statements/CREATE-COMPUTE-GROUP.md) -- [CREATE RESOURCE](../Administration-Statements/CREATE-RESOURCE.md) -- [CREATE STORAGE VAULT](../Administration-Statements/CREATE-STORAGE-VAULT.md) - -## Keywords - - REVOKE, WORKLOAD GROUP, COMPUTE GROUP, RESOURCE \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/SET-PASSWORD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/SET-PASSWORD.md deleted file mode 100644 index 09fdf0bfcc2e8..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/SET-PASSWORD.md +++ /dev/null @@ -1,67 +0,0 @@ ---- -{ - "title": "SET-PASSWORD", - "language": "zh-CN" -} ---- - - - -## SET-PASSWORD - -### Name - -SET PASSWORD - -## 描述 - -SET PASSWORD 命令可以用于修改一个用户的登录密码。如果 [FOR user_identity] 字段不存在,那么修改当前用户的密码 - -```sql -SET PASSWORD [FOR user_identity] = - [PASSWORD('plain password')]|['hashed password'] -``` - -注意这里的 user_identity 必须完全匹配在使用 CREATE USER 创建用户时指定的 user_identity,否则会报错用户不存在。如果不指定 user_identity,则当前用户为 'username'@'ip',这个当前用户,可能无法匹配任何 user_identity。可以通过 SHOW GRANTS 查看当前用户。 - -PASSWORD() 方式输入的是明文密码; 而直接使用字符串,需要传递的是已加密的密码。 -如果修改其他用户的密码,需要具有管理员权限。 - -## 举例 -1. 修改当前用户的密码 - - ```sql - SET PASSWORD = PASSWORD('123456') - SET PASSWORD = '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' - ``` - -2. 修改指定用户密码 - - ```sql - SET PASSWORD FOR 'jack'@'192.%' = PASSWORD('123456') - SET PASSWORD FOR 'jack'@['domain'] = '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' - ``` - -### Keywords - - SET, PASSWORD - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/SET-PROPERTY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/SET-PROPERTY.md deleted file mode 100644 index dd98ba4489157..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Account-Management-Statements/SET-PROPERTY.md +++ /dev/null @@ -1,126 +0,0 @@ ---- -{ - "title": "SET-PROPERTY", - "language": "zh-CN" -} ---- - - - -## 描述 - -SET PROPERTY 语句用于设置用户属性,包括分配给用户的资源和导入集群设置。这里设置的用户属性是针对用户的,而不是针对 user_identity。例如,如果通过 CREATE USER 语句创建了两个用户 'jack'@'%' 和 'jack'@'192.%',则使用 SET PROPERTY 语句只能针对用户 'jack',而不是 'jack'@'%' 或 'jack'@'192.%'。 - -## 语法 - -```sql -SET PROPERTY [FOR 'user'] 'key' = 'value' [, 'key' = 'value'] -``` - -## 参数 - -### user - -要设置属性的用户名。如果省略,则为当前用户设置属性。 - -### key - -要设置的属性键。可用的键包括: - -- `max_user_connections`:最大连接数。 -- `max_query_instances`:用户同一时间点执行查询可以使用的 instance 个数。 -- `sql_block_rules`:设置 SQL 阻止规则。设置后,该用户发送的查询如果匹配规则,则会被拒绝。 -- `cpu_resource_limit`:限制查询的 CPU 资源。详见会话变量 `cpu_resource_limit` 的介绍。-1 表示未设置。 -- `exec_mem_limit`:限制查询的内存使用。详见会话变量 `exec_mem_limit` 的介绍。-1 表示未设置。 -- `resource_tags`:指定用户的资源标签权限。 -- `query_timeout`:指定用户的查询超时。 -- `default_workload_group`:指定用户的默认工作负载组。 -- `default_compute_group`:指定用户的默认计算组。 - -注:如果未设置 `cpu_resource_limit` 和 `exec_mem_limit`,则默认使用会话变量中的值。 - -### value - -为指定键设置的值。 - -## 示例 - -1. 设置用户 'jack' 的最大连接数为 1000: - - ```sql - SET PROPERTY FOR 'jack' 'max_user_connections' = '1000'; - ``` - -2. 设置用户 'jack' 的最大查询实例数为 3000: - - ```sql - SET PROPERTY FOR 'jack' 'max_query_instances' = '3000'; - ``` - -3. 为用户 'jack' 设置 SQL 阻止规则: - - ```sql - SET PROPERTY FOR 'jack' 'sql_block_rules' = 'rule1, rule2'; - ``` - -4. 设置用户 'jack' 的 CPU 资源限制: - - ```sql - SET PROPERTY FOR 'jack' 'cpu_resource_limit' = '2'; - ``` - -5. 设置用户 'jack' 的资源标签权限: - - ```sql - SET PROPERTY FOR 'jack' 'resource_tags.location' = 'group_a, group_b'; - ``` - -6. 设置用户 'jack' 的内存使用限制(以字节为单位): - - ```sql - SET PROPERTY FOR 'jack' 'exec_mem_limit' = '2147483648'; - ``` - -7. 设置用户 'jack' 的查询超时时间(以秒为单位): - - ```sql - SET PROPERTY FOR 'jack' 'query_timeout' = '500'; - ``` - -8. 设置用户 'jack' 的默认工作负载组: - - ```sql - SET PROPERTY FOR 'jack' 'default_workload_group' = 'group1'; - ``` - -9. 设置用户 'jack' 的默认计算组: - - ```sql - SET PROPERTY FOR 'jack' 'default_compute_group' = 'compute_group1'; - ``` - -## 相关命令 - -- [CREATE USER](./CREATE-USER.md) -- [SHOW PROPERTY](../Show-Statements/SHOW-PROPERTY.md) - -## Keywords - - SET, PROPERTY, WORKLOAD GROUP, COMPUTE GROUP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-BACKEND.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-BACKEND.md deleted file mode 100644 index d11f1e16b311e..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-BACKEND.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -{ - "title": "ALTER-SYSTEM-ADD-BACKEND", - "language": "zh-CN" -} ---- - - - -## 描述 - -ADD BACKEND 命令用于向 Doris OLAP 数据库集群添加一个或多个后端节点。此命令允许管理员指定新后端节点的主机和端口,以及可选的属性来配置它们的行为。 - -## 语法 - -```sql - ALTER SYSTEM ADD BACKEND "host:heartbeat_port"[,"host:heartbeat_port"...] [PROPERTIES ("key"="value", ...)]; -``` - -## 参数 - -* `host` 可以是后端节点的主机名或 IP 地址,而 `heartbeat_port` 是节点的心跳端口 -* `PROPERTIES ("key"="value", ...)`:(可选)一组键值对,用于定义后端节点的附加属性。这些属性可用于自定义正在添加的后端的配置。可用属性包括: - - * tag.location:指定后端节点所属的资源组。例如,PROPERTIES ("tag.location" = "groupb")。 - * tag.compute_group_name:指定后端节点所属的计算组。例如,PROPERTIES ("tag.compute_group_name" = "groupb")。 - -## 示例 - -1. 不带附加属性添加后端 - - ```sql - ALTER SYSTEM ADD BACKEND "host1:9050,host2:9050"; - ``` - - 此命令向集群添加两个后端节点: - - * host1,端口 9050 - * host2,端口 9050 - - 未指定附加属性,因此将应用默认设置。 - -2. 添加带有资源组的后端 - - ```sql - ALTER SYSTEM ADD BACKEND "host3:9050" PROPERTIES ("tag.location" = "groupb"); - ``` - - 此命令将单个后端节点(host3,端口 9050)添加到集群中的资源组 `groupb`: - -3. 添加带有计算组的后端 - - ```sql - ALTER SYSTEM ADD BACKEND "host3:9050" PROPERTIES ("tag.compute_group_name" = "groupb"); - ``` - - 此命令将单个后端节点(host3,端口 9050)添加到集群中的计算组 `groupb`: - -## 关键词 - - ALTER, SYSTEM, ADD, BACKEND, PROPERTIES - -## 最佳实践 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-BROKER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-BROKER.md deleted file mode 100644 index c81bfb94693ba..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-BROKER.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -{ - "title": "ALTER-SYSTEM-ADD-BROKER", - "language": "zh-CN" -} - ---- - - - -## ALTER-SYSTEM-ADD-BROKER - -### Name - -ALTER SYSTEM ADD BROKER - -## 描述 - -该语句用于添加一个 BROKER 节点。(仅管理员使用!) - -语法: - -```sql -ALTER SYSTEM ADD BROKER broker_name "broker_host1:broker_ipc_port1","broker_host2:broker_ipc_port2",...; -``` - -## 举例 - -1. 增加两个 Broker - - ```sql - ALTER SYSTEM ADD BROKER "host1:port", "host2:port"; - ``` -2. fe开启fqdn([fqdn](../../../admin-manual/cluster-management/fqdn.md))时添加一个Broker - - ```sql - ALTER SYSTEM ADD BROKER "broker_fqdn1:port"; - ``` - - -### Keywords - - ALTER, SYSTEM, ADD, FOLLOWER, ALTER SYSTEM - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-FOLLOWER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-FOLLOWER.md deleted file mode 100644 index bd80d5aeabcef..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-FOLLOWER.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -{ - "title": "ALTER-SYSTEM-ADD-FOLLOWER", - "language": "zh-CN" -} ---- - - - -## ALTER-SYSTEM-ADD-FOLLOWER - -### Name - -ALTER SYSTEM ADD FOLLOWER - -## 描述 - -该语句是增加 FRONTEND 的 FOLLOWER 角色的节点,(仅管理员使用!) - -语法: - -```sql -ALTER SYSTEM ADD FOLLOWER "follower_host:edit_log_port" -``` - -说明: - -1. host 可以是主机名或者ip地址 -2. edit_log_port : edit_log_port 在其配置文件 fe.conf - -## 举例 - -1. 添加一个 FOLLOWER节点 - - ```sql - ALTER SYSTEM ADD FOLLOWER "host_ip:9010" - ``` - -### Keywords - - ALTER, SYSTEM, ADD, FOLLOWER, ALTER SYSTEM - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-OBSERVER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-OBSERVER.md deleted file mode 100644 index 52fe27587079e..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-OBSERVER.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -{ - "title": "ALTER-SYSTEM-ADD-OBSERVER", - "language": "zh-CN" -} ---- - - - -## ALTER-SYSTEM-ADD-OBSERVER - -### Name - -ALTER SYSTEM ADD OBSERVER - -## 描述 - -该语句是增加 FRONTEND 的 OBSERVER 角色的节点,(仅管理员使用!) - -语法: - -```sql -ALTER SYSTEM ADD OBSERVER "follower_host:edit_log_port" -``` - -说明: - -1. host 可以是主机名或者ip地址 -2. edit_log_port : edit_log_port 在其配置文件 fe.conf - -## 举例 - -1. 添加一个 OBSERVER 节点 - - ```sql - ALTER SYSTEM ADD OBSERVER "host_ip:9010" - ``` - -### Keywords - - ALTER, SYSTEM, ADD, OBSERVER, ALTER SYSTEM - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DECOMMISSION-BACKEND.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DECOMMISSION-BACKEND.md deleted file mode 100644 index d36a195de7c32..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DECOMMISSION-BACKEND.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -{ - "title": "ALTER-SYSTEM-DECOMMISSION-BACKEND", - "language": "zh-CN" -} ---- - - - -## ALTER-SYSTEM-DECOMMISSION-BACKEND - -### Name - -ALTER SYSTEM DECOMMISSION BACKEND - -## 描述 - -节点下线操作用于安全下线节点。该操作为异步操作。如果成功,节点最终会从元数据中删除。如果失败,则不会完成下线(仅管理员使用!) - -语法: - -- 通过 host 和 port 查找 backend - -```sql -ALTER SYSTEM DECOMMISSION BACKEND "host:heartbeat_port"[,"host:heartbeat_port"...]; -``` - -- 通过 backend_id 查找 backend - -```sql -ALTER SYSTEM DECOMMISSION BACKEND "id1","id2"...; -``` - - 说明: - -1. host 可以是主机名或者ip地址 -2. heartbeat_port 为该节点的心跳端口 -3. 节点下线操作用于安全下线节点。该操作为异步操作。如果成功,节点最终会从元数据中删除。如果失败,则不会完成下线。 -4. 可以手动取消节点下线操作。详见 CANCEL DECOMMISSION - -## 举例 - -1. 下线两个节点 - - ```sql - ALTER SYSTEM DECOMMISSION BACKEND "host1:port", "host2:port"; - ``` - - ```sql - ALTER SYSTEM DECOMMISSION BACKEND "id1", "id2"; - ``` - -### Keywords - - ALTER, SYSTEM, DECOMMISSION, BACKEND, ALTER SYSTEM - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-BACKEND.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-BACKEND.md deleted file mode 100644 index 0b05e330afb7a..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-BACKEND.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -{ - "title": "ALTER-SYSTEM-DROP-BACKEND", - "language": "zh-CN" -} ---- - - - -## ALTER-SYSTEM-DROP-BACKEND - -### Name - -ALTER SYSTEM DROP BACKEND - -## 描述 - -该语句用于删除 BACKEND 节点(仅管理员使用!) - -语法: - -- 通过 host 和 port 查找 backend - -```sql -ALTER SYSTEM DROP BACKEND "host:heartbeat_port"[,"host:heartbeat_port"...] -``` - -- 通过 backend_id 查找 backend - -```sql -ALTER SYSTEM DROP BACKEND "id1","id2"...; -``` - -说明: - -1. host 可以是主机名或者ip地址 -2. heartbeat_port 为该节点的心跳端口 -3. 增加和删除节点为同步操作。这两种操作不考虑节点上已有的数据,节点直接从元数据中删除,请谨慎使用。 - -## 举例 - -1. 删除两个节点 - - ```sql - ALTER SYSTEM DROP BACKEND "host1:port", "host2:port"; - ``` - - ```sql - ALTER SYSTEM DROP BACKEND "id1", "id2"; - ``` - -### Keywords - - ALTER, SYSTEM, DROP, BACKEND, ALTER SYSTEM - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-BROKER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-BROKER.md deleted file mode 100644 index db28f3d72d5b5..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-BROKER.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -{ - "title": "ALTER-SYSTEM-DROP-BROKER", - "language": "zh-CN" -} - ---- - - - -## ALTER-SYSTEM-DROP-BROKER - -### Name - -ALTER SYSTEM DROP BROKER - -## 描述 - -该语句是删除 BROKER 节点,(仅限管理员使用) - -语法: - -```sql -删除所有 Broker -ALTER SYSTEM DROP ALL BROKER broker_name -删除某一个 Broker 节点 -ALTER SYSTEM DROP BROKER broker_name "host:port"[,"host:port"...]; -``` - -## 举例 - -1. 删除所有 Broker - - ```sql - ALTER SYSTEM DROP ALL BROKER broker_name - ``` - -2. 删除某一个 Broker 节点 - - ```sql - ALTER SYSTEM DROP BROKER broker_name "host:port"[,"host:port"...]; - ``` - -### Keywords - - ALTER, SYSTEM, DROP, FOLLOWER, ALTER SYSTEM - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-FOLLOWER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-FOLLOWER.md deleted file mode 100644 index 1682ac54ff99d..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-FOLLOWER.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -{ - "title": "ALTER-SYSTEM-DROP-FOLLOWER", - "language": "zh-CN" -} ---- - - - - -## Name - -ALTER SYSTEM DROP FOLLOWER - -## Description - -该语句是删除 FRONTEND 的 FOLLOWER 角色的节点,(仅管理员使用!) - -语法: - -```sql -ALTER SYSTEM DROP FOLLOWER "follower_host:edit_log_port" -``` - -说明: - -1. host 可以是主机名或者 ip 地址 -2. edit_log_port : edit_log_port 在其配置文件 fe.conf - -## Example - -1. 删除一个 FOLLOWER 节点 - - ```sql - ALTER SYSTEM DROP FOLLOWER "host_ip:9010" - ``` - -## Keywords - - ALTER, SYSTEM, DROP, FOLLOWER, ALTER SYSTEM - - - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-OBSERVER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-OBSERVER.md deleted file mode 100644 index 169dacc7ac409..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-OBSERVER.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -{ - "title": "ALTER-SYSTEM-DROP-OBSERVER", - "language": "zh-CN" -} ---- - - - -## ALTER-SYSTEM-DROP-OBSERVER - -### Name - -ALTER SYSTEM DROP OBSERVER - -## 描述 - -该语句是删除 FRONTEND 的 OBSERVER 角色的节点,(仅管理员使用!) - -语法: - -```sql -ALTER SYSTEM DROP OBSERVER "follower_host:edit_log_port" -``` - -说明: - -1. host 可以是主机名或者ip地址 -2. edit_log_port : edit_log_port 在其配置文件 fe.conf - -## 举例 - -1. 添加一个 FOLLOWER节点 - - ```sql - ALTER SYSTEM DROP OBSERVER "host_ip:9010" - ``` - -### Keywords - - ALTER, SYSTEM, DROP, OBSERVER, ALTER SYSTEM - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-MODIFY-BACKEND.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-MODIFY-BACKEND.md deleted file mode 100644 index 201b175f01def..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-MODIFY-BACKEND.md +++ /dev/null @@ -1,104 +0,0 @@ ---- -{ - "title": "ALTER-SYSTEM-MODIFY-BACKEND", - "language": "zh-CN" -} - ---- - - - -## ALTER-SYSTEM-MODIFY-BACKEND - -### Name - -ALTER SYSTEM MKDIFY BACKEND - -## 描述 - -修改 BE 节点属性(仅管理员使用!) - -语法: - -- 通过 host 和 port 查找 backend - -```sql -ALTER SYSTEM MODIFY BACKEND "host:heartbeat_port" SET ("key" = "value"[, ...]); -``` - -- 通过 backend_id 查找 backend - -```sql -ALTER SYSTEM MODIFY BACKEND "id1" SET ("key" = "value"[, ...]); -``` - - 说明: - -1. host 可以是主机名或者ip地址 -2. heartbeat_port 为该节点的心跳端口 -3. 修改 BE 节点属性目前支持以下属性: - -- tag.xxx:资源标签 -- disable_query: 查询禁用属性 -- disable_load: 导入禁用属性 - -注: -1. 可以给一个 Backend 设置多种资源标签。但必须包含 "tag.location"。 - -## 举例 - -1. 修改 BE 的资源标签 - - ```sql - ALTER SYSTEM MODIFY BACKEND "host1:heartbeat_port" SET ("tag.location" = "group_a"); - ALTER SYSTEM MODIFY BACKEND "host1:heartbeat_port" SET ("tag.location" = "group_a", "tag.compute" = "c1"); - ``` - - ```sql - ALTER SYSTEM MODIFY BACKEND "id1" SET ("tag.location" = "group_a"); - ALTER SYSTEM MODIFY BACKEND "id1" SET ("tag.location" = "group_a", "tag.compute" = "c1"); - ``` - -2. 修改 BE 的查询禁用属性 - - ```sql - ALTER SYSTEM MODIFY BACKEND "host1:heartbeat_port" SET ("disable_query" = "true"); - ``` - - ```sql - ALTER SYSTEM MODIFY BACKEND "id1" SET ("disable_query" = "true"); - ``` - -3. 修改 BE 的导入禁用属性 - - ```sql - ALTER SYSTEM MODIFY BACKEND "host1:heartbeat_port" SET ("disable_load" = "true"); - ``` - - ```sql - ALTER SYSTEM MODIFY BACKEND "id1" SET ("disable_load" = "true"); - ``` - -### Keywords - - ALTER, SYSTEM, ADD, BACKEND, ALTER SYSTEM - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/CANCEL-ALTER-SYSTEM.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/CANCEL-ALTER-SYSTEM.md deleted file mode 100644 index 707c45caffa3e..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Cluster-Management-Statements/CANCEL-ALTER-SYSTEM.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -{ - "title": "CANCEL-ALTER-SYSTEM", - "language": "zh-CN" -} ---- - - - -## CANCEL-ALTER-SYSTEM - -### Name - -CANCEL DECOMMISSION - -## 描述 - -该语句用于撤销一个节点下线操作。(仅管理员使用!) - -语法: - -- 通过 host 和 port 查找 backend - -```sql -CANCEL DECOMMISSION BACKEND "host:heartbeat_port"[,"host:heartbeat_port"...]; -``` - -- 通过 backend_id 查找 backend - -```sql -CANCEL DECOMMISSION BACKEND "id1","id2","id3..."; -``` - -## 举例 - - 1. 取消两个节点的下线操作: - - ```sql - CANCEL DECOMMISSION BACKEND "host1:port", "host2:port"; - ``` - - 2. 取消 backend_id 为 1 的节点的下线操作: - - ```sql - CANCEL DECOMMISSION BACKEND "1","2"; - ``` - -### Keywords - - CANCEL, DECOMMISSION, CANCEL ALTER - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-ASYNC-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-ASYNC-MATERIALIZED-VIEW.md deleted file mode 100644 index fcdb9e4dd2b3b..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-ASYNC-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,98 +0,0 @@ ---- -{ - "title": "ALTER-ASYNC-MATERIALIZED-VIEW", - "language": "zh-CN" -} ---- - - - -## ALTER-ASYNC-MATERIALIZED-VIEW - -### Name - -ALTER ASYNC MATERIALIZED VIEW - -## 描述 - -该语句用于修改异步物化视图。 - -#### 语法 - -```sql -ALTER MATERIALIZED VIEW mvName=multipartIdentifier ((RENAME newName=identifier) - | (REFRESH (refreshMethod | refreshTrigger | refreshMethod refreshTrigger)) - | REPLACE WITH MATERIALIZED VIEW newName=identifier propertyClause? - | (SET LEFT_PAREN fileProperties=propertyItemList RIGHT_PAREN)) -``` - -#### 说明 - -##### RENAME - -用来更改物化视图的名字 - -例如: 将mv1的名字改为mv2 -```sql -ALTER MATERIALIZED VIEW mv1 rename mv2; -``` - -##### refreshMethod - -同[创建异步物化视图](../Create/CREATE-ASYNC-MATERIALIZED-VIEW.md) - -##### refreshTrigger - -同[创建异步物化视图](../Create/CREATE-ASYNC-MATERIALIZED-VIEW.md) - -##### SET -修改物化视图特有的property - -例如修改mv1的grace_period为3000ms -```sql -ALTER MATERIALIZED VIEW mv1 set("grace_period"="3000"); -``` - -##### REPLACE -```sql -ALTER MATERIALIZED VIEW [db.]mv1 REPLACE WITH MATERIALIZED VIEW mv2 -[PROPERTIES('swap' = 'true')]; -``` -两个物化视图进行原子的替换操作 - -swap 默认为 TRUE -- 如果 swap 参数为 TRUE,相当于把物化视图 mv1 重命名为 mv2 , 同时把 mv2 重命名为 mv1 -- 如果 swap 参数为 FALSE,相当于把 mv2 重命名为 mv1 ,原有的 mv1 被删除 - -例如想把 mv1 和 mv2 的名字互换 -```sql -ALTER MATERIALIZED VIEW db1.mv1 REPLACE WITH MATERIALIZED VIEW mv2; -``` - -例如想把 mv2 重命名为 mv1,并删除原先的 mv1 -```sql -ALTER MATERIALIZED VIEW db1.mv1 REPLACE WITH MATERIALIZED VIEW mv2 -PROPERTIES('swap' = 'false'); -``` - -### Keywords - - ALTER, ASYNC, MATERIALIZED, VIEW - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-CATALOG.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-CATALOG.md deleted file mode 100644 index 186eb29ecf2ef..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-CATALOG.md +++ /dev/null @@ -1,92 +0,0 @@ ---- -{ - "title": "ALTER-CATALOG", - "language": "zh-CN" -} ---- - - - -## ALTER-CATALOG - -### Name - -ALTER CATALOG - -## 描述 - -该语句用于设置指定数据目录的属性。(仅管理员使用) - -1) 重命名数据目录 - -```sql -ALTER CATALOG catalog_name RENAME new_catalog_name; -``` -注意: -- `internal` 是内置数据目录,不允许重命名 -- 对 `catalog_name` 拥有 Alter 权限才允许对其重命名 -- 重命名数据目录后,如需要,请使用 REVOKE 和 GRANT 命令修改相应的用户权限。 - -2) 设置数据目录属性 - -```sql -ALTER CATALOG catalog_name SET PROPERTIES ('key1' = 'value1' [, 'key' = 'value2']); -``` - -更新指定属性的值为指定的 value。如果 SET PROPERTIES 从句中的 key 在指定 catalog 属性中不存在,则新增此 key。 - -注意: -- 不可更改数据目录类型,即 `type` 属性 -- 不可更改内置数据目录 `internal` 的属性 - -3) 修改数据目录注释 - -```sql -ALTER CATALOG catalog_name MODIFY COMMENT "new catalog comment"; -``` - -注意: -- `internal` 是内置数据目录,不允许修改注释 - -## 举例 - -1. 将数据目录 ctlg_hive 重命名为 hive - -```sql -ALTER CATALOG ctlg_hive RENAME hive; -``` - -3. 更新名为 hive 数据目录的属性 `hive.metastore.uris` - -```sql -ALTER CATALOG hive SET PROPERTIES ('hive.metastore.uris'='thrift://172.21.0.1:9083'); -``` - -4. 更改名为 hive 数据目录的注释 - -```sql -ALTER CATALOG hive MODIFY COMMENT "new catalog comment"; -``` - -### Keywords - -ALTER,CATALOG,RENAME,PROPERTY - -### Best Practice diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-COLOCATE-GROUP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-COLOCATE-GROUP.md deleted file mode 100644 index d55997c6ca02b..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-COLOCATE-GROUP.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -{ -"title": "ALTER-COLOCATE-GROUP", -"language": "zh-CN" -} ---- - - - -## ALTER-COLOCATE-GROUP - -### Name - -ALTER COLOCATE GROUP - -## 描述 - -该语句用于修改 Colocation Group 的属性。 - -语法: - -```sql -ALTER COLOCATE GROUP [database.]group -SET ( - property_list -); -``` - -注意: - -1. 如果 colocate group 是全局的,即它的名称是以 `__global__` 开头的,那它不属于任何一个 Database; - -2. property_list 是 colocation group 属性,目前只支持修改`replication_num` 和 `replication_allocation`。 - 修改 colocation group 的这两个属性修改之后,同时把该 group 的表的属性`default.replication_allocation` 、 - 属性`dynamic.replication_allocation `、以及已有分区的`replication_allocation`改成跟它一样。 - - - -## 举例 - -1. 修改一个全局 group 的副本数 - - ```sql - # 建表时设置 "colocate_with" = "__global__foo" - - ALTER COLOCATE GROUP __global__foo - SET ( - "replication_num"="1" - ); - ``` - -2. 修改一个非全局 group 的副本数 - - ```sql - # 建表时设置 "colocate_with" = "bar",且表属于 Database example_db - - ALTER COLOCATE GROUP example_db.bar - SET ( - "replication_num"="1" - ); - ``` - -### Keywords - -```sql -ALTER, COLOCATE , GROUP -``` - -### Best Practice diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-DATABASE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-DATABASE.md deleted file mode 100644 index 684e4a5544aac..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-DATABASE.md +++ /dev/null @@ -1,109 +0,0 @@ ---- -{ - "title": "ALTER-DATABASE", - "language": "zh-CN" -} ---- - - - -## ALTER-DATABASE - -### Name - -ALTER DATABASE - -## 描述 - -该语句用于设置指定数据库的属性。(仅管理员使用) - -1) 设置数据库数据量配额,单位为B/K/KB/M/MB/G/GB/T/TB/P/PB - -```sql -ALTER DATABASE db_name SET DATA QUOTA quota; -``` - -2) 重命名数据库 - -```sql -ALTER DATABASE db_name RENAME new_db_name; -``` - -3) 设置数据库的副本数量配额 - -```sql -ALTER DATABASE db_name SET REPLICA QUOTA quota; -``` - -说明: - 重命名数据库后,如需要,请使用 REVOKE 和 GRANT 命令修改相应的用户权限。 - 数据库的默认数据量配额为1024GB,默认副本数量配额为1073741824。 - -4) 对已有 database 的 property 进行修改操作 - -```sql -ALTER DATABASE db_name SET PROPERTIES ("key"="value", ...); -``` - -## 举例 - -1. 设置指定数据库数据量配额 - -```sql -ALTER DATABASE example_db SET DATA QUOTA 10995116277760; -上述单位为字节,等价于 -ALTER DATABASE example_db SET DATA QUOTA 10T; - -ALTER DATABASE example_db SET DATA QUOTA 100G; - -ALTER DATABASE example_db SET DATA QUOTA 200M; -``` - -2. 将数据库 example_db 重命名为 example_db2 - -```sql -ALTER DATABASE example_db RENAME example_db2; -``` - -3. 设定指定数据库副本数量配额 - -```sql -ALTER DATABASE example_db SET REPLICA QUOTA 102400; -``` - -4. 修改db下table的默认副本分布策略(该操作仅对新建的table生效,不会修改db下已存在的table) - -```sql -ALTER DATABASE example_db SET PROPERTIES("replication_allocation" = "tag.location.default:2"); -``` - -5. 取消db下table的默认副本分布策略(该操作仅对新建的table生效,不会修改db下已存在的table) - -```sql -ALTER DATABASE example_db SET PROPERTIES("replication_allocation" = ""); -``` - -### Keywords - -```text -ALTER,DATABASE,RENAME -``` - -### Best Practice diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-RESOURCE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-RESOURCE.md deleted file mode 100644 index 2a9545b720401..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-RESOURCE.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -{ -"title": "ALTER-RESOURCE", -"language": "zh-CN" -} ---- - - - -## ALTER-RESOURCE - -### Name - -ALTER RESOURCE - -## 描述 - -该语句用于修改一个已有的资源。仅 root 或 admin 用户可以修改资源。 -语法: -```sql -ALTER RESOURCE 'resource_name' -PROPERTIES ("key"="value", ...); -``` -注意:resource type 不支持修改。 - -## 举例 - -1. 修改名为 spark0 的 Spark 资源的工作目录: -```sql -ALTER RESOURCE 'spark0' PROPERTIES ("working_dir" = "hdfs://127.0.0.1:10000/tmp/doris_new"); -``` -2. 修改名为 remote_s3 的 S3 资源的最大连接数: -```sql -ALTER RESOURCE 'remote_s3' PROPERTIES ("s3.connection.maximum" = "100"); -``` -3. 修改冷热分层S3资源相关信息 -- 支持修改项 - - `s3.access_key` s3的ak信息 - - `s3.secret_key` s3的sk信息 - - `s3.session_token` s3的session token信息 - - `s3.connection.maximum` s3最大连接数,默认50 - - `s3.connection.timeout` s3连接超时时间,默认1000ms - - `s3.connection.request.timeout` s3请求超时时间,默认3000ms -- 禁止修改项 - - `s3.region` - - `s3.bucket"` - - `s3.root.path` - - `s3.endpoint` - -```sql - ALTER RESOURCE "showPolicy_1_resource" PROPERTIES("s3.connection.maximum" = "1111"); -``` -### Keywords - -```sql -ALTER, RESOURCE -``` - -### Best Practice diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-SQL-BLOCK-RULE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-SQL-BLOCK-RULE.md deleted file mode 100644 index 34a9c385d0e6a..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-SQL-BLOCK-RULE.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -{ - "title": "ALTER-SQL-BLOCK-RULE", - "language": "zh-CN" -} ---- - - - -## ALTER-SQL-BLOCK-RULE - -### Name - -ALTER SQL BLOCK RULE - -## 描述 - -修改SQL阻止规则,允许对sql/sqlHash/partition_num/tablet_num/cardinality/global/enable等每一项进行修改。 - -语法: - -```sql -ALTER SQL_BLOCK_RULE rule_name -[PROPERTIES ("key"="value", ...)]; -``` - -说明: - -- sql 和 sqlHash 不能同时被设置。这意味着,如果一个rule设置了sql或者sqlHash,则另一个属性将无法被修改; -- sql/sqlHash 和 partition_num/tablet_num/cardinality 不能同时被设置。举个例子,如果一个rule设置了partition_num,那么sql或者sqlHash将无法被修改; - -## 举例 - -1. 根据SQL属性进行修改 - -```sql -ALTER SQL_BLOCK_RULE test_rule PROPERTIES("sql"="select \\* from test_table","enable"="true") -``` - -2. 如果一个rule设置了partition_num,那么sql或者sqlHash将无法被修改 - -```sql -ALTER SQL_BLOCK_RULE test_rule2 PROPERTIES("partition_num" = "10","tablet_num"="300","enable"="true") -``` - -### Keywords - -```text -ALTER,SQL_BLOCK_RULE -``` - -### Best Practice diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-STORAGE-POLICY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-STORAGE-POLICY.md deleted file mode 100644 index 4b09e7923f4f2..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-STORAGE-POLICY.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -{ -"title": "ALTER-POLICY", -"language": "zh-CN" -} ---- - - - -## ALTER-POLICY - -### Name - -ALTER STORAGE POLICY - -## 描述 - -该语句用于修改一个已有的冷热分层迁移策略。仅 root 或 admin 用户可以修改资源。 -语法: -```sql -ALTER STORAGE POLICY 'policy_name' -PROPERTIES ("key"="value", ...); -``` - -## 举例 - -1. 修改名为 cooldown_datetime冷热分层数据迁移时间点: -```sql -ALTER STORAGE POLICY has_test_policy_to_alter PROPERTIES("cooldown_datetime" = "2023-06-08 00:00:00"); -``` -2. 修改名为 cooldown_ttl的冷热分层数据迁移倒计时 -```sql -ALTER STORAGE POLICY has_test_policy_to_alter PROPERTIES ("cooldown_ttl" = "10000"); -ALTER STORAGE POLICY has_test_policy_to_alter PROPERTIES ("cooldown_ttl" = "1h"); -ALTER STORAGE POLICY has_test_policy_to_alter PROPERTIES ("cooldown_ttl" = "3d"); -``` -### Keywords - -```sql -ALTER, STORAGE, POLICY -``` - -### Best Practice diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-AND-GENERATED-COLUMN.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-AND-GENERATED-COLUMN.md deleted file mode 100644 index fc8d84012d07b..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-AND-GENERATED-COLUMN.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -{ - "title": "ALTER-TABLE-AND-GENERATED-COLUMN", - "language": "zh-CN" -} ---- - - - - -## ALTER TABLE和生成列 -不支持使用ALTER TABLE ADD COLUMN增加一个生成列,不支持使用ALTER TABLE MODIFY COLUMN修改生成列信息。支持使用ALTER TABLE对生成列顺序进行修改,修改生成列名称和删除生成列。 - -不支持的场景报错如下: - -```sql -mysql> CREATE TABLE test_alter_add_column(a int, b int) properties("replication_num"="1"); -Query OK, 0 rows affected (0.14 sec) -mysql> ALTER TABLE test_alter_add_column ADD COLUMN c int AS (a+b); -ERROR 1105 (HY000): errCode = 2, detailMessage = Not supporting alter table add generated columns. -mysql> ALTER TABLE test_alter MODIFY COLUMN c int KEY AS (a+b+1); -ERROR 1105 (HY000): errCode = 2, detailMessage = Not supporting alter table modify generated columns. -``` - -### REORDER COLUMN - -```sql -ALTER TABLE products ORDER BY (product_id, total_value, price, quantity); -``` - -注意: -修改后的列顺序仍然需要满足生成列建表时的顺序限制。 -### RENAME COLUMN - -```sql -ALTER TABLE products RENAME COLUMN total_value new_name; -``` - -注意: -如果表中某列(生成列或者普通列)被其它生成列引用,需要先删除其它生成列后,才能修改此生成列的名称。 -### DROP COLUMN - -```sql -ALTER TABLE products DROP COLUMN total_value; -``` - -注意: -如果表中某列(生成列或者普通列)被其它生成列引用,需要先删除其它生成列后,才能删除此被引用的生成列或者普通列。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-COLUMN.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-COLUMN.md deleted file mode 100644 index 8a30a5f9f5273..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-COLUMN.md +++ /dev/null @@ -1,308 +0,0 @@ ---- -{ - "title": "ALTER-TABLE-COLUMN", - "language": "zh-CN" -} ---- - - - -## Name - -ALTER TABLE COLUMN - -## 描述 - -该语句用于对已有 table 进行 Schema change 操作。schema change 是异步的,任务提交成功则返回,之后可使用[SHOW ALTER TABLE COLUMN](../../Show-Statements/SHOW-ALTER.md) 命令查看进度。 - -:::tip -Doris 在建表之后有物化索引的概念,在建表成功后为 base 表,物化索引为 base index,基于 base 表可以创建 rollup index。其中 base index 和 rollup index 都是物化索引,在进行 schema change 操作时如果不指定 rollup_index_name 默认基于 base 表进行操作。 -Doris 在 1.2.0 支持了 light schema change 轻量表结构变更,对于值列的加减操作,可以更快地,同步地完成。可以在建表时手动指定 "light_schema_change" = 'true',2.0.0 及之后版本该参数默认开启。 -::: - -### 语法: - -```sql -ALTER TABLE [database.]table alter_clause; -``` - -schema change 的 alter_clause 支持如下几种修改方式: - -**1. 添加列,向指定的 index 位置进行列添加** - -**语法** - -```sql -ALTER TABLE [database.]table table_name ADD COLUMN column_name column_type [KEY | agg_type] [DEFAULT "default_value"] -[AFTER column_name|FIRST] -[TO rollup_index_name] -[PROPERTIES ("key"="value", ...)] -``` - -**Example** - -1. 向 example_db.my_table 的 key_1 后添加一个 key 列 new_col (非聚合模型) - - ```sql - ALTER TABLE example_db.my_table - ADD COLUMN new_col INT KEY DEFAULT "0" AFTER key_1; - ``` - -2. 向 example_db.my_table 的 value_1 后添加一个 value 列 new_col (非聚合模型) - - ```sql - ALTER TABLE example_db.my_table - ADD COLUMN new_col INT DEFAULT "0" AFTER value_1; - ``` - -3. 向 example_db.my_table 的 key_1 后添加一个 key 列 new_col (聚合模型) - - ```sql - ALTER TABLE example_db.my_table - ADD COLUMN new_col INT KEY DEFAULT "0" AFTER key_1; - ``` - -4. 向 example_db.my_table 的 value_1 后添加一个 value 列 new_col SUM 聚合类型 (聚合模型) - - ```sql - ALTER TABLE example_db.my_table - ADD COLUMN new_col INT SUM DEFAULT "0" AFTER value_1; - ``` - -5. 将 new_col 添加到 example_db.my_table 表的首列位置 (非聚合模型) - - ```sql - ALTER TABLE example_db.my_table - ADD COLUMN new_col INT KEY DEFAULT "0" FIRST; - ``` - -:::tip - - 聚合模型如果增加 value 列,需要指定 agg_type - - 非聚合模型(如 DUPLICATE KEY)如果增加key列,需要指定KEY关键字 - - 不能在 rollup index 中增加 base index 中已经存在的列(如有需要,可以重新创建一个 rollup index) -::: - -**2. 添加多列,向指定的 index 位置进行多列添加** - -**语法** - - ```sql - ALTER TABLE [database.]table table_name ADD COLUMN (column_name1 column_type [KEY | agg_type] DEFAULT "default_value", ...) - [TO rollup_index_name] - [PROPERTIES ("key"="value", ...)] - ``` - -**Example** - -1. 向 example_db.my_table 中添加多列,new_col 和 new_col2 都是 SUM 聚合类型(聚合模型) - - ```sql - ALTER TABLE example_db.my_table - ADD COLUMN (new_col1 INT SUM DEFAULT "0" ,new_col2 INT SUM DEFAULT "0"); - ``` - -2. 向 example_db.my_table 中添加多列(非聚合模型),其中 new_col1 为 KEY 列,new_col2 为 value 列 - - ```sql - ALTER TABLE example_db.my_table - ADD COLUMN (new_col1 INT key DEFAULT "0" , new_col2 INT DEFAULT "0"); - ``` - -:::tip - - - 聚合模型如果增加 value 列,需要指定agg_type - - 聚合模型如果增加key列,需要指定KEY关键字 - - 不能在 rollup index 中增加 base index 中已经存在的列(如有需要,可以重新创建一个 rollup index) -::: - -**3. 删除列,从指定 index 中删除一列** - -**语法** - - ```sql - ALTER TABLE [database.]table table_name DROP COLUMN column_name - [FROM rollup_index_name] - ``` - -**Example** - -1. 从 example_db.my_table 中删除 col1 列 - - ```sql - ALTER TABLE example_db.my_table DROP COLUMN col1; - ``` - -:::tip - - 不能删除分区列 - - 聚合模型不能删除KEY列 - - 如果是从 base index 中删除列,则如果 rollup index 中包含该列,也会被删除 -::: - -**4. 修改指定列类型以及列位置** - -**语法** - -```sql -ALTER TABLE [database.]table table_name MODIFY COLUMN column_name column_type [KEY | agg_type] [NULL | NOT NULL] [DEFAULT "default_value"] -[AFTER column_name|FIRST] -[FROM rollup_index_name] -[PROPERTIES ("key"="value", ...)] -``` - -**Example** - -1. 修改 example_db.my_table 的 key 列 col1 的类型为 BIGINT,并移动到 col2 列后面。 - - ```sql - ALTER TABLE example_db.my_table - MODIFY COLUMN col1 BIGINT KEY DEFAULT "1" AFTER col2; - ``` - - :::tip - 无论是修改 key 列还是 value 列都需要声明完整的 column 信息 - ::: - -2. 修改 example_db.my_table 的 val1 列最大长度。原 val1 为 (val1 VARCHAR(32) REPLACE DEFAULT "abc") - - ```sql - ALTER TABLE example_db.my_table - MODIFY COLUMN val1 VARCHAR(64) REPLACE DEFAULT "abc"; - ``` - - :::tip - 只能修改列的类型,列的其他属性维持原样 - ::: - -3. 修改 Duplicate key 表 Key 列的某个字段的长度 - - ```sql - ALTER TABLE example_db.my_table - MODIFY COLUMN k3 VARCHAR(50) KEY NULL COMMENT 'to 50'; - ``` - -:::tip - - 聚合模型如果修改 value 列,需要指定 agg_type - - 非聚合类型如果修改key列,需要指定KEY关键字 - - 只能修改列的类型,列的其他属性维持原样(即其他属性需在语句中按照原属性显式的写出,参见 example 8) - - 分区列和分桶列不能做任何修改 - - 目前支持以下类型的转换(精度损失由用户保证) - - TINYINT/SMALLINT/INT/BIGINT/LARGEINT/FLOAT/DOUBLE 类型向范围更大的数字类型转换 - - TINTINT/SMALLINT/INT/BIGINT/LARGEINT/FLOAT/DOUBLE/DECIMAL 转换成 VARCHAR - - VARCHAR 支持修改最大长度 - - VARCHAR/CHAR 转换成 TINTINT/SMALLINT/INT/BIGINT/LARGEINT/FLOAT/DOUBLE - - VARCHAR/CHAR 转换成 DATE (目前支持"%Y-%m-%d", "%y-%m-%d", "%Y%m%d", "%y%m%d", "%Y/%m/%d, "%y/%m/%d"六种格式化格式) - - DATETIME 转换成 DATE(仅保留年-月-日信息, 例如: `2019-12-09 21:47:05` <--> `2019-12-09`) - - DATE 转换成 DATETIME(时分秒自动补零, 例如: `2019-12-09` <--> `2019-12-09 00:00:00`) - - FLOAT 转换成 DOUBLE - - INT 转换成 DATE (如果INT类型数据不合法则转换失败,原始数据不变) - - 除DATE与DATETIME以外都可以转换成STRING,但是STRING不能转换任何其他类型 -::: - -**5. 对指定表的列进行重新排序** - -**语法** - - ```sql - ALTER TABLE [database.]table table_name ORDER BY (column_name1, column_name2, ...) - [FROM rollup_index_name] - [PROPERTIES ("key"="value", ...)] - ``` - -**Example** - -1. 调整 example_db.my_table 的 key 列 和 value 列的顺序(非聚合模型) - - ```sql - CREATE TABLE `my_table`( - `k_1` INT NULL, - `k_2` INT NULL, - `v_1` INT NULL, - `v_2` varchar NULL, - `v_3` varchar NULL - ) ENGINE=OLAP - DUPLICATE KEY(`k_1`, `k_2`) - COMMENT 'OLAP' - DISTRIBUTED BY HASH(`k_1`) BUCKETS 5 - PROPERTIES ( - "replication_allocation" = "tag.location.default: 1" - ); - - ALTER TABLE example_db.my_table ORDER BY (k_2,k_1,v_3,v_2,v_1); - - mysql> desc my_table; - +-------+------------+------+-------+---------+-------+ - | Field | Type | Null | Key | Default | Extra | - +-------+------------+------+-------+---------+-------+ - | k_2 | INT | Yes | true | NULL | | - | k_1 | INT | Yes | true | NULL | | - | v_3 | VARCHAR(*) | Yes | false | NULL | NONE | - | v_2 | VARCHAR(*) | Yes | false | NULL | NONE | - | v_1 | INT | Yes | false | NULL | NONE | - +-------+------------+------+-------+---------+-------+ - ``` - -2. 同时执行添加列和列排序操作 - - ```sql - CREATE TABLE `my_table` ( - `k_1` INT NULL, - `k_2` INT NULL, - `v_1` INT NULL, - `v_2` varchar NULL, - `v_3` varchar NULL - ) ENGINE=OLAP - DUPLICATE KEY(`k_1`, `k_2`) - COMMENT 'OLAP' - DISTRIBUTED BY HASH(`k_1`) BUCKETS 5 - PROPERTIES ( - "replication_allocation" = "tag.location.default: 1" - ); - - ALTER TABLE example_db.my_table - ADD COLUMN col INT DEFAULT "0" AFTER v_1, - ORDER BY (k_2,k_1,v_3,v_2,v_1,col); - - mysql> desc my_table; - +-------+------------+------+-------+---------+-------+ - | Field | Type | Null | Key | Default | Extra | - +-------+------------+------+-------+---------+-------+ - | k_2 | INT | Yes | true | NULL | | - | k_1 | INT | Yes | true | NULL | | - | v_3 | VARCHAR(*) | Yes | false | NULL | NONE | - | v_2 | VARCHAR(*) | Yes | false | NULL | NONE | - | v_1 | INT | Yes | false | NULL | NONE | - | col | INT | Yes | false | 0 | NONE | - +-------+------------+------+-------+---------+-------+ - ``` - -:::tip - - index 中的所有列都要写出来 - - value 列在 key 列之后 - - key 列只能调整 key 列的范围内进行调整,value 列同理 -::: - -### Keywords - -```text -ALTER, TABLE, COLUMN, ALTER TABLE -``` - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-COMMENT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-COMMENT.md deleted file mode 100644 index 12d866d0c9529..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-COMMENT.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -{ - "title": "ALTER-TABLE-COMMENT", - "language": "zh-CN" -} ---- - - - -## ALTER-TABLE-COMMENT - -### Name - -ALTER TABLE COMMENT - -## 描述 - -该语句用于对已有 table 的 comment 进行修改。这个操作是同步的,命令返回表示执行完毕。 - -语法: - -```sql -ALTER TABLE [database.]table alter_clause; -``` - -1. 修改表注释 - -语法: - -```sql -MODIFY COMMENT "new table comment"; -``` - -2. 修改列注释 - - 语法: - -```sql -MODIFY COLUMN col1 COMMENT "new column comment"; -``` - -## 举例 - -1. 将名为 table1 的 comment 修改为 table1_comment - -```sql -ALTER TABLE table1 MODIFY COMMENT "table1_comment"; -``` - -2. 将名为 table1 的 col1 列的 comment 修改为 table1_col1_comment - -```sql -ALTER TABLE table1 MODIFY COLUMN col1 COMMENT "table1_col1_comment"; -``` - -### Keywords - -```text -ALTER, TABLE, COMMENT, ALTER TABLE -``` - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-PARTITION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-PARTITION.md deleted file mode 100644 index ef10ff78ee3ca..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-PARTITION.md +++ /dev/null @@ -1,187 +0,0 @@ ---- -{ - "title": "ALTER-TABLE-PARTITION", - "language": "zh-CN" -} ---- - - - -## ALTER-TABLE-PARTITION - -### Name - -ALTER TABLE PARTITION - -## 描述 - -该语句用于对有 partition 的 table 进行修改操作。 - -这个操作是同步的,命令返回表示执行完毕。 - -语法: - -```sql -ALTER TABLE [database.]table alter_clause; -``` - -partition 的 alter_clause 支持如下几种修改方式 - -1. 增加分区 - -语法: - -```sql -ADD PARTITION [IF NOT EXISTS] partition_name -partition_desc ["key"="value"] -[DISTRIBUTED BY HASH (k1[,k2 ...]) [BUCKETS num]] -``` - -注意: - -- partition_desc 支持以下两种写法 - - VALUES LESS THAN [MAXVALUE|("value1", ...)] - - VALUES [("value1", ...), ("value1", ...)) -- 分区为左闭右开区间,如果用户仅指定右边界,系统会自动确定左边界 -- 如果没有指定分桶方式,则自动使用建表使用的分桶方式和分桶数。 -- 如指定分桶方式,只能修改分桶数,不可修改分桶方式或分桶列。如果指定了分桶方式,但是没有指定分桶数,则分桶数会使用默认值10,不会使用建表时指定的分桶数。如果要指定分桶数,则必须指定分桶方式。 -- ["key"="value"] 部分可以设置分区的一些属性,具体说明见 [CREATE TABLE](../Create/CREATE-TABLE.md) -- 如果建表时用户未显式创建Partition,则不支持通过ALTER的方式增加分区 -- 如果用户使用的是List Partition则可以增加default partition,default partition将会存储所有不满足其他分区键要求的数据。 - - ALTER TABLE table_name ADD PARTITION partition_name - -2. 删除分区 - -语法: - -```sql -DROP PARTITION [IF EXISTS] partition_name [FORCE] -``` - - 注意: - -- 使用分区方式的表至少要保留一个分区。 -- 执行 DROP PARTITION 一段时间内,可以通过 RECOVER 语句恢复被删除的分区。详见 SQL手册-数据库管理-RECOVER 语句 -- 如果执行 DROP PARTITION FORCE,则系统不会检查该分区是否存在未完成的事务,分区将直接被删除并且不能被恢复,一般不建议执行此操作 - -3. 修改分区属性 - - 语法: - -```sql -MODIFY PARTITION p1|(p1[, p2, ...]) SET ("key" = "value", ...) -``` - -说明: - -- 当前支持修改分区的下列属性: - - storage_medium - - storage_cooldown_time - - replication_num - - in_memory -- 对于单分区表,partition_name 同表名。 - -## 举例 - -1. 增加分区, 现有分区 [MIN, 2013-01-01),增加分区 [2013-01-01, 2014-01-01),使用默认分桶方式 - -```sql -ALTER TABLE example_db.my_table -ADD PARTITION p1 VALUES LESS THAN ("2014-01-01"); -``` - -2. 增加分区,使用新的分桶数 - -```sql -ALTER TABLE example_db.my_table -ADD PARTITION p1 VALUES LESS THAN ("2015-01-01") -DISTRIBUTED BY HASH(k1) BUCKETS 20; -``` - -3. 增加分区,使用新的副本数 - -```sql -ALTER TABLE example_db.my_table -ADD PARTITION p1 VALUES LESS THAN ("2015-01-01") -("replication_num"="1"); -``` - -4. 修改分区副本数 - -```sql -ALTER TABLE example_db.my_table -MODIFY PARTITION p1 SET("replication_num"="1"); -``` - -5. 批量修改指定分区 - -```sql -ALTER TABLE example_db.my_table -MODIFY PARTITION (p1, p2, p4) SET("replication_num"="1"); -``` - -6. 批量修改所有分区 - -```sql -ALTER TABLE example_db.my_table -MODIFY PARTITION (*) SET("storage_medium"="HDD"); -``` - -7. 删除分区 - -```sql -ALTER TABLE example_db.my_table -DROP PARTITION p1; -``` - -8. 批量删除分区 - -```sql -ALTER TABLE example_db.my_table -DROP PARTITION p1, -DROP PARTITION p2, -DROP PARTITION p3; -``` - -9. 增加一个指定上下界的分区 - -```sql -ALTER TABLE example_db.my_table -ADD PARTITION p1 VALUES [("2014-01-01"), ("2014-02-01")); -``` - -10. 批量增加数字类型和时间类型的分区 - -```sql -ALTER TABLE example_db.my_table ADD PARTITIONS FROM (1) TO (100) INTERVAL 10; -ALTER TABLE example_db.my_table ADD PARTITIONS FROM ("2023-01-01") TO ("2025-01-01") INTERVAL 1 YEAR; -ALTER TABLE example_db.my_table ADD PARTITIONS FROM ("2023-01-01") TO ("2025-01-01") INTERVAL 1 MONTH; -ALTER TABLE example_db.my_table ADD PARTITIONS FROM ("2023-01-01") TO ("2025-01-01") INTERVAL 1 WEEK; -ALTER TABLE example_db.my_table ADD PARTITIONS FROM ("2023-01-01") TO ("2025-01-01") INTERVAL 1 DAY; -``` - -### Keywords - -```text -ALTER, TABLE, PARTITION, ALTER TABLE -``` - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-PROPERTY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-PROPERTY.md deleted file mode 100644 index 9d6f169bab35a..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-PROPERTY.md +++ /dev/null @@ -1,301 +0,0 @@ ---- -{ - "title": "ALTER-TABLE-PROPERTY", - "language": "zh-CN" -} ---- - - - -## ALTER-TABLE-PROPERTY - -### Name - -ALTER TABLE PROPERTY - -:::caution -分区属性与表属性的一些区别 -- 分区属性一般主要关注分桶数(buckets)、存储介质(storage_medium)、副本数(replication)、冷热分离存储策略(storage_policy); - - 对于已经创建的分区,可以使用alter table {tableName} modify partition({partitionName}) set ({key}={value}) 来修改,但是分桶数(buckets)不能修改; - - 对于未创建的动态分区(dynamic partition),可以使用alter table {tableName} set (dynamic_partition.{key} = {value}) 来修改其属性; - - 对于未创建的自动分区(auto partition),可以使用alter table {tableName} set ({key} = {value}) 来修改其属性; - - 若用户想修改分区的属性,需要修改已经创建分区的属性,同时也要修改未创建分区的属性 -- 除了上面几个属性,其他均为表级别属性 -- 具体属性可以参考[建表属性](../../../../sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE.md#properties) -::: - -## 描述 - -该语句用于对已有 table 的 property 进行修改操作。这个操作是同步的,命令返回表示执行完毕。 - -语法: - -```sql -ALTER TABLE [database.]table alter_clause; -``` - -property 的 alter_clause 支持如下几种修改方式 - -1. 修改表的 bloom filter 列 - -```sql -ALTER TABLE example_db.my_table SET ("bloom_filter_columns"="k1,k2,k3"); -``` - -也可以合并到上面的 schema change 操作中(注意多子句的语法有少许区别) - -```sql -ALTER TABLE example_db.my_table -DROP COLUMN col2 -PROPERTIES ("bloom_filter_columns"="k1,k2,k3"); -``` - -2. 修改表的Colocate 属性 - -```sql -ALTER TABLE example_db.my_table set ("colocate_with" = "t1"); -``` - -3. 将表的分桶方式由 Hash Distribution 改为 Random Distribution - -```sql -ALTER TABLE example_db.my_table set ("distribution_type" = "random"); -``` - -4. 修改表的动态分区属性(支持未添加动态分区属性的表添加动态分区属性) - -```sql -ALTER TABLE example_db.my_table set ("dynamic_partition.enable" = "false"); -``` - -如果需要在未添加动态分区属性的表中添加动态分区属性,则需要指定所有的动态分区属性 - (注:非分区表不支持添加动态分区属性) - -```sql -ALTER TABLE example_db.my_table set ( - "dynamic_partition.enable" = "true", - "dynamic_partition.time_unit" = "DAY", - "dynamic_partition.end" = "3", - "dynamic_partition.prefix" = "p", - "dynamic_partition.buckets" = "32" -); -``` - -5. 修改表的 in_memory 属性,只支持修改为'false' - -```sql -ALTER TABLE example_db.my_table set ("in_memory" = "false"); -``` - -6. 启用 批量删除功能 - -```sql -ALTER TABLE example_db.my_table ENABLE FEATURE "BATCH_DELETE"; -``` - -注意: - -- 只能用在unique 表 -- 用于旧表支持批量删除功能,新表创建时已经支持 - -7. 启用按照sequence column的值来保证导入顺序的功能 - -```sql -ALTER TABLE example_db.my_table ENABLE FEATURE "SEQUENCE_LOAD" WITH PROPERTIES ( - "function_column.sequence_type" = "Date" -); -``` - -注意: - -- 只能用在unique 表 -- sequence_type用来指定sequence列的类型,可以为整型和时间类型 -- 只支持新导入数据的有序性,历史数据无法更改 - -8. 将表的默认分桶数改为50 - -```sql -ALTER TABLE example_db.my_table MODIFY DISTRIBUTION DISTRIBUTED BY HASH(k1) BUCKETS 50; -``` - -注意: - -- 只能用在分区类型为RANGE,采用哈希分桶的非colocate表 - -9. 修改表注释 - -```sql -ALTER TABLE example_db.my_table MODIFY COMMENT "new comment"; -``` - -10. 修改列注释 - -```sql -ALTER TABLE example_db.my_table MODIFY COLUMN k1 COMMENT "k1", MODIFY COLUMN k2 COMMENT "k2"; -``` - -11. 修改引擎类型 - - 仅支持将 MySQL 类型修改为 ODBC 类型。driver 的值为 odbc.init 配置中的 driver 名称。 - -```sql -ALTER TABLE example_db.mysql_table MODIFY ENGINE TO odbc PROPERTIES("driver" = "MySQL"); -``` - -12. 修改副本数 - -```sql -ALTER TABLE example_db.mysql_table SET ("replication_num" = "2"); -ALTER TABLE example_db.mysql_table SET ("default.replication_num" = "2"); -ALTER TABLE example_db.mysql_table SET ("replication_allocation" = "tag.location.default: 1"); -ALTER TABLE example_db.mysql_table SET ("default.replication_allocation" = "tag.location.default: 1"); -``` - -注: -1. default 前缀的属性表示修改表的默认副本分布。这种修改不会修改表的当前实际副本分布,而只影响分区表上新建分区的副本分布。 -2. 对于非分区表,修改不带 default 前缀的副本分布属性,会同时修改表的默认副本分布和实际副本分布。即修改后,通过 `show create table` 和 `show partitions from tbl` 语句可以看到副本分布数据都被修改了。 -3. 对于分区表,表的实际副本分布是分区级别的,即每个分区有自己的副本分布,可以通过 `show partitions from tbl` 语句查看。如果想修改实际副本分布,请参阅 `ALTER TABLE PARTITION`。 - -13\. **[Experimental]** 打开`light_schema_change` - - 对于建表时未开启light_schema_change的表,可以通过如下方式打开。 - -```sql -ALTER TABLE example_db.mysql_table SET ("light_schema_change" = "true"); -``` - -## 举例 - -1. 修改表的 bloom filter 列 - -```sql -ALTER TABLE example_db.my_table SET ( - "bloom_filter_columns"="k1,k2,k3" -); -``` - -也可以合并到上面的 schema change 操作中(注意多子句的语法有少许区别) - -```sql -ALTER TABLE example_db.my_table -DROP COLUMN col2 -PROPERTIES ( - "bloom_filter_columns"="k1,k2,k3" -); -``` - -2. 修改表的Colocate 属性 - -```sql -ALTER TABLE example_db.my_table set ("colocate_with" = "t1"); -``` - -3. 将表的分桶方式由 Hash Distribution 改为 Random Distribution - -```sql -ALTER TABLE example_db.my_table set ( - "distribution_type" = "random" -); -``` - -4. 修改表的动态分区属性(支持未添加动态分区属性的表添加动态分区属性) - -```sql -ALTER TABLE example_db.my_table set ( - "dynamic_partition.enable" = "false" -); -``` - -如果需要在未添加动态分区属性的表中添加动态分区属性,则需要指定所有的动态分区属性 - (注:非分区表不支持添加动态分区属性) - -```sql -ALTER TABLE example_db.my_table set ( - "dynamic_partition.enable" = "true", - "dynamic_partition.time_unit" = "DAY", - "dynamic_partition.end" = "3", - "dynamic_partition.prefix" = "p", - "dynamic_partition.buckets" = "32" -); -``` - -5. 修改表的 in_memory 属性,只支持修改为'false' - -```sql -ALTER TABLE example_db.my_table set ("in_memory" = "false"); -``` - -6. 启用 批量删除功能 - -```sql -ALTER TABLE example_db.my_table ENABLE FEATURE "BATCH_DELETE"; -``` - -7. 启用按照sequence column的值来保证导入顺序的功能 - -```sql -ALTER TABLE example_db.my_table ENABLE FEATURE "SEQUENCE_LOAD" WITH PROPERTIES ( - "function_column.sequence_type" = "Date" -); -``` - -8. 将表的默认分桶数改为50 - -```sql -ALTER TABLE example_db.my_table MODIFY DISTRIBUTION DISTRIBUTED BY HASH(k1) BUCKETS 50; -``` - -9. 修改表注释 - -```sql -ALTER TABLE example_db.my_table MODIFY COMMENT "new comment"; -``` - -10. 修改列注释 - -```sql -ALTER TABLE example_db.my_table MODIFY COLUMN k1 COMMENT "k1", MODIFY COLUMN k2 COMMENT "k2"; -``` - -11. 修改引擎类型 - -```sql -ALTER TABLE example_db.mysql_table MODIFY ENGINE TO odbc PROPERTIES("driver" = "MySQL"); -``` - -12. 给表添加冷热分层数据迁移策略 -```sql - ALTER TABLE create_table_not_have_policy set ("storage_policy" = "created_create_table_alter_policy"); -``` -注:表没有关联过storage policy,才能被添加成功,一个表只能添加一个storage policy - -13. 给表的partition添加冷热分层数据迁移策略 -```sql -ALTER TABLE create_table_partition MODIFY PARTITION (*) SET("storage_policy"="created_create_table_partition_alter_policy"); -``` -注:表的partition没有关联过storage policy,才能被添加成功,一个表只能添加一个storage policy -### Keywords - -```text -ALTER, TABLE, PROPERTY, ALTER TABLE -``` - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-RENAME.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-RENAME.md deleted file mode 100644 index eb258da26c084..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-RENAME.md +++ /dev/null @@ -1,116 +0,0 @@ ---- -{ - "title": "ALTER-TABLE-RENAME", - "language": "zh-CN" -} ---- - - - -## ALTER-TABLE-RENAME - -### Name - -ALTER TABLE RENAME - -## 描述 - -该语句用于对已有 table 属性的某些名称进行重命名操作。这个操作是同步的,命令返回表示执行完毕。 - -语法: - -```sql -ALTER TABLE [database.]table alter_clause; -``` - -rename 的 alter_clause 支持对以下名称进行修改 - -1. 修改表名 - -语法: - -```sql -RENAME new_table_name; -``` - -2. 修改 rollup index 名称 - - 语法: - -```sql -RENAME ROLLUP old_rollup_name new_rollup_name; -``` - -3. 修改 partition 名称 - -语法: - -```sql -RENAME PARTITION old_partition_name new_partition_name; -``` - -4. 修改 column 名称 - -修改 column 名称 - -语法: - -```sql -RENAME COLUMN old_column_name new_column_name; -``` - -注意: -- 建表时需要在 property 中设置 light_schema_change=true - - -## 举例 - -1. 将名为 table1 的表修改为 table2 - -```sql -ALTER TABLE table1 RENAME table2; -``` - -2. 将表 example_table 中名为 rollup1 的 rollup index 修改为 rollup2 - -```sql -ALTER TABLE example_table RENAME ROLLUP rollup1 rollup2; -``` - -3. 将表 example_table 中名为 p1 的 partition 修改为 p2 - -```sql -ALTER TABLE example_table RENAME PARTITION p1 p2; -``` - -4. 将表 example_table 中名为 c1 的 column 修改为 c2 - -```sql -ALTER TABLE example_table RENAME COLUMN c1 c2; -``` - -### Keywords - -```text -ALTER, TABLE, RENAME, ALTER TABLE -``` - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-REPLACE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-REPLACE.md deleted file mode 100644 index 97c136bceca59..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-REPLACE.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -{ - "title": "ALTER-TABLE-REPLACE", - "language": "zh-CN" -} ---- - - - -## ALTER-TABLE-REPLACE - -### Name - -ALTER TABLE REPLACE - -## 描述 - -对两个表进行原子的替换操作。 该操作仅适用于 OLAP 表。 - -```sql -ALTER TABLE [db.]tbl1 REPLACE WITH TABLE tbl2 -[PROPERTIES('swap' = 'true')]; -``` - -将表 tbl1 替换为表 tbl2。 - -如果 `swap` 参数为 `true`,则替换后,名称为 `tbl1` 表中的数据为原 `tbl2` 表中的数据。而名称为 `tbl2` 表中的数据为原 `tbl1` 表中的数据。即两张表数据发生了互换。 - -如果 `swap` 参数为 `false`,则替换后,名称为 `tbl1` 表中的数据为原 `tbl2` 表中的数据。而名称为 `tbl2` 表被删除。 - -#### 原理 - -替换表功能,实际上是将以下操作集合变成一个原子操作。 - -假设要将表 A 替换为表 B,且 `swap` 为 `true`,则操作如下: - -1. 将表 B 重名为表 A。 -2. 将表 A 重名为表 B。 - -如果 `swap` 为 `false`,则操作如下: - -1. 删除表 A。 -2. 将表 B 重名为表 A。 - -#### 注意事项 -1. `swap` 参数默认为 `true`。即替换表操作相当于将两张表数据进行交换。 -2. 如果设置 `swap` 参数为 `false`,则被替换的表(表A)将被删除,且无法恢复。 -3. 替换操作仅能发生在两张 OLAP 表之间,且不会检查两张表的表结构是否一致。 -4. 替换操作不会改变原有的权限设置。因为权限检查以表名称为准。 - -## 举例 - -1. 将 `tbl1` 与 `tbl2` 进行原子交换,不删除任何表(注:如果删除的话,实际上删除的是tbl1,只是将tbl2重命名为tbl1。) - -```sql -ALTER TABLE tbl1 REPLACE WITH TABLE tbl2; -``` -或 -```sql -ALTER TABLE tbl1 REPLACE WITH TABLE tbl2 PROPERTIES('swap' = 'true') ; -``` - -2. 将 `tbl1` 与 `tbl2` 进行交换,删除 `tbl2` 表(保留名为`tbl1`,数据为`tbl2`的表) - -```sql -ALTER TABLE tbl1 REPLACE WITH TABLE tbl2 PROPERTIES('swap' = 'false') ; -``` - -### Keywords - -```text -ALTER, TABLE, REPLACE, ALTER TABLE -``` - -### Best Practice -1. 原子的覆盖写操作 - - 某些情况下,用户希望能够重写某张表的数据,但如果采用先删除再导入的方式进行,在中间会有一段时间无法查看数据。这时,用户可以先使用 `CREATE TABLE LIKE` 语句创建一个相同结构的新表,将新的数据导入到新表后,通过替换操作,原子的替换旧表,以达到目的。分区级别的原子覆盖写操作,请参阅 [临时分区文档](../../../../advanced/partition/table-temp-partition.md)。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-ROLLUP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-ROLLUP.md deleted file mode 100644 index 2de026f773118..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-ROLLUP.md +++ /dev/null @@ -1,139 +0,0 @@ ---- -{ - "title": "ALTER-TABLE-ROLLUP", - "language": "zh-CN" -} ---- - - - -## ALTER-TABLE-ROLLUP - -### Name - -ALTER TABLE ROLLUP - -## 描述 - -该语句用于对已有 table 进行 rollup 进行修改操作。rollup 是异步操作,任务提交成功则返回,之后可使用[SHOW ALTER](../../Show-Statements/SHOW-ALTER.md) 命令查看进度。 - -语法: - -```sql -ALTER TABLE [database.]table alter_clause; -``` - -rollup 的 alter_clause 支持如下几种创建方式 - -1. 创建 rollup index - -语法: - -```sql -ADD ROLLUP rollup_name (column_name1, column_name2, ...) -[FROM from_index_name] -[PROPERTIES ("key"="value", ...)] -``` - - properties: 支持设置超时时间,默认超时时间为1天。 - -2. 批量创建 rollup index - -语法: - -```sql -ADD ROLLUP [rollup_name (column_name1, column_name2, ...) - [FROM from_index_name] - [PROPERTIES ("key"="value", ...)],...] -``` - -注意: - -- 如果没有指定 from_index_name,则默认从 base index 创建 -- rollup 表中的列必须是 from_index 中已有的列 -- 在 properties 中,可以指定存储格式。具体请参阅 [CREATE TABLE](../Create/CREATE-TABLE.md) - -3. 删除 rollup index - - 语法: - -```sql -DROP ROLLUP rollup_name [PROPERTIES ("key"="value", ...)] -``` - -4. 批量删除 rollup index - -语法: - -```sql -DROP ROLLUP [rollup_name [PROPERTIES ("key"="value", ...)],...] -``` - -注意: - -- 不能删除 base index - -## 举例 - -1. 创建 index: example_rollup_index,基于 base index(k1,k2,k3,v1,v2)。列式存储。 - -```sql -ALTER TABLE example_db.my_table -ADD ROLLUP example_rollup_index(k1, k3, v1, v2); -``` - -2. 创建 index: example_rollup_index2,基于 example_rollup_index(k1,k3,v1,v2) - -```sql -ALTER TABLE example_db.my_table -ADD ROLLUP example_rollup_index2 (k1, v1) -FROM example_rollup_index; -``` - -3. 创建 index: example_rollup_index3, 基于 base index (k1,k2,k3,v1), 自定义 rollup 超时时间一小时。 - -```sql -ALTER TABLE example_db.my_table -ADD ROLLUP example_rollup_index(k1, k3, v1) -PROPERTIES("timeout" = "3600"); -``` - -4. 删除 index: example_rollup_index2 - -```sql -ALTER TABLE example_db.my_table -DROP ROLLUP example_rollup_index2; -``` - -5. 批量删除Rollup - -```sql -ALTER TABLE example_db.my_table -DROP ROLLUP example_rollup_index2,example_rollup_index3; -``` - -### Keywords - -```text -ALTER, TABLE, ROLLUP, ALTER TABLE -``` - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-VIEW.md deleted file mode 100644 index f9f58100e3a80..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-VIEW.md +++ /dev/null @@ -1,73 +0,0 @@ ---- -{ - "title": "ALTER-VIEW", - "language": "zh-CN" -} ---- - - - -## ALTER-VIEW - -### Name - -ALTER VIEW - -## 描述 - -该语句用于修改一个view的定义 - -语法: - -```sql -ALTER VIEW -[db_name.]view_name -(column1[ COMMENT "col comment"][, column2, ...]) -AS query_stmt -``` - -说明: - -- 视图都是逻辑上的,其中的数据不会存储在物理介质上,在查询时视图将作为语句中的子查询,因此,修改视图的定义等价于修改query_stmt。 -- query_stmt 为任意支持的 SQL - -## 举例 - -1、修改example_db上的视图example_view - -```sql -ALTER VIEW example_db.example_view -( - c1 COMMENT "column 1", - c2 COMMENT "column 2", - c3 COMMENT "column 3" -) -AS SELECT k1, k2, SUM(v1) FROM example_table -GROUP BY k1, k2 -``` - -### Keywords - -```text -ALTER, VIEW -``` - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-WORKLOAD-GROUP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-WORKLOAD-GROUP.md deleted file mode 100644 index 83f6e2400f647..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-WORKLOAD-GROUP.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -{ -"title": "ALTER-WORKLOAD-GROUP", -"language": "zh-CN" -} ---- - - - -## ALTER-WORKLOAD-GROUP - -### Name - -ALTER WORKLOAD GROUP - -## 描述 - -该语句用于修改资源组。 - -语法: - -```sql -ALTER WORKLOAD GROUP "rg_name" -PROPERTIES ( - property_list -); -``` - -注意: - -* 修改 memory_limit 属性时不可使所有 memory_limit 值的总和超过 100%; -* 支持修改部分属性,例如只修改 cpu_share 的话,properties 里只填 cpu_share 即可。 - -## 举例 - -1. 修改名为 g1 的资源组: - - ```sql - alter workload group g1 - properties ( - "cpu_share"="30", - "memory_limit"="30%" - ); - ``` - -### Keywords - -```sql -ALTER, WORKLOAD , GROUP -``` - -### Best Practice diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/CANCEL-ALTER-TABLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/CANCEL-ALTER-TABLE.md deleted file mode 100644 index 158f5c3b71621..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/CANCEL-ALTER-TABLE.md +++ /dev/null @@ -1,110 +0,0 @@ ---- -{ - "title": "CANCEL-ALTER-TABLE", - "language": "zh-CN" -} ---- - - - -## CANCEL-ALTER-TABLE - -### Name - -CANCEL ALTER TABLE - -## 描述 - -该语句用于撤销一个 ALTER 操作。 - -1. 撤销 ALTER TABLE COLUMN 操作 - -语法: - -```sql -CANCEL ALTER TABLE COLUMN -FROM db_name.table_name -``` - -2. 撤销 ALTER TABLE ROLLUP 操作 - -语法: - -```sql -CANCEL ALTER TABLE ROLLUP -FROM db_name.table_name -``` - -3. 根据job id批量撤销rollup操作 - -语法: - -```sql -CANCEL ALTER TABLE ROLLUP -FROM db_name.table_name (jobid,...) -``` - -注意: - -- 该命令为异步操作,具体是否执行成功需要使用`show alter table rollup`查看任务状态确认 - -4. 撤销 ALTER CLUSTER 操作 - -语法: - -``` -(待实现...) -``` - -## 举例 - -1. 撤销针对 my_table 的 ALTER COLUMN 操作。 - - [CANCEL ALTER TABLE COLUMN] - -```sql -CANCEL ALTER TABLE COLUMN -FROM example_db.my_table; -``` - -1. 撤销 my_table 下的 ADD ROLLUP 操作。 - - [CANCEL ALTER TABLE ROLLUP] - -```sql -CANCEL ALTER TABLE ROLLUP -FROM example_db.my_table; -``` - -1. 根据job id撤销 my_table 下的 ADD ROLLUP 操作。 - - [CANCEL ALTER TABLE ROLLUP] - -```sql -CANCEL ALTER TABLE ROLLUP -FROM example_db.my_table (12801,12802); -``` - -### Keywords - - CANCEL, ALTER, TABLE, CANCEL ALTER - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/PAUSE-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/PAUSE-JOB.md deleted file mode 100644 index 46c00b0d67d92..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/PAUSE-JOB.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ -"title": "PAUSE-JOB", -"language": "zh-CN" -} ---- - - - -## PAUSE-JOB - -### Name - -PAUSE JOB - -## 描述 - -用户暂停一个正在 RUNNING 状态的 JOB ,正在运行的 TASK 会被中断,JOB 状态变更为 PAUSED。 被停止的 JOB 可以通过 RESUME 操作恢复运行。 - -使用此命令需要 ADMIN 权限。 - -```sql -PAUSE JOB WHERE jobname= 'jobname'; -``` - -## 举例 - -1. 暂停名称为 example 的 JOB。 - -```sql - PAUSE JOB where jobname='example'; -``` - -### Keywords - - PAUSE, JOB - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/RESUME-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/RESUME-JOB.md deleted file mode 100644 index 0eecf25d4e5b6..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Alter/RESUME-JOB.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -{ -"title": "RESUME-JOB", -"language": "zh-CN" -} ---- - - - -## RESUME-JOB - -### Name - -RESUME JOB - -## 描述 - -将处于 PAUSED 状态的 JOB 恢复为 RUNNING 状态。RUNNING 状态的 JOB 将会根据既定的调度周期去执行。 - -```sql -RESUME JOB where jobName = jobName; -``` - -## 举例 - -1. 恢复运行名称为 example 的 JOB。 - - ```sql - RESUME JOB where jobName= 'example'; - ``` - -### Keywords - - RESUME, JOB - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/BACKUP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/BACKUP.md deleted file mode 100644 index 3ccdec90f118f..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/BACKUP.md +++ /dev/null @@ -1,116 +0,0 @@ ---- -{ - "title": "BACKUP", - "language": "zh-CN" -} ---- - - - -## BACKUP - -### Name - -BACKUP - -## 描述 - -该语句用于备份指定数据库下的数据。该命令为异步操作。 - -仅 root 或 superuser 用户可以创建仓库。 - -提交成功后,需通过 SHOW BACKUP 命令查看进度。仅支持备份 OLAP 类型的表。 - -语法: - -```sql -BACKUP SNAPSHOT [db_name].{snapshot_name} -TO `repository_name` -[ON|EXCLUDE] ( - `table_name` [PARTITION (`p1`, ...)], - ... -) -PROPERTIES ("key"="value", ...); -``` - -说明: - -- 同一数据库下只能有一个正在执行的 BACKUP 或 RESTORE 任务。 -- ON 子句中标识需要备份的表和分区。如果不指定分区,则默认备份该表的所有分区 -- EXCLUDE 子句中标识不需要备份的表和分区。备份除了指定的表或分区之外这个数据库中所有表的所有分区数据。 -- PROPERTIES 目前支持以下属性: - - "type" = "full":表示这是一次全量更新(默认) - - "timeout" = "3600":任务超时时间,默认为一天。单位秒。 - -## 举例 - -1. 全量备份 example_db 下的表 example_tbl 到仓库 example_repo 中: - -```sql -BACKUP SNAPSHOT example_db.snapshot_label1 -TO example_repo -ON (example_tbl) -PROPERTIES ("type" = "full"); -``` - -2. 全量备份 example_db 下,表 example_tbl 的 p1, p2 分区,以及表 example_tbl2 到仓库 example_repo 中: - -```sql -BACKUP SNAPSHOT example_db.snapshot_label2 -TO example_repo -ON -( - example_tbl PARTITION (p1,p2), - example_tbl2 -); -``` - -3. 全量备份 example_db 下除了表 example_tbl 的其他所有表到仓库 example_repo 中: - -```sql -BACKUP SNAPSHOT example_db.snapshot_label3 -TO example_repo -EXCLUDE (example_tbl); -``` - -4. 全量备份 example_db 下的表到仓库 example_repo 中: - -```sql -BACKUP SNAPSHOT example_db.snapshot_label3 -TO example_repo; -``` - -### Keywords - -```text -BACKUP -``` - -### Best Practice - -1. 同一个数据库下只能进行一个备份操作。 - -2. 备份操作会备份指定表或分区的基础表及同步物化视图[物化视图](../../../../query-acceleration/materialized-view/sync-materialized-view),并且仅备份一副本,[异步物化视图](../../../../query-acceleration/materialized-view/async-materialized-view/overview) 当前未支持。 - -3. 备份操作的效率 - - 备份操作的效率取决于数据量、Compute Node 节点数量以及文件数量。备份数据分片所在的每个 Compute Node 都会参与备份操作的上传阶段。节点数量越多,上传的效率越高。 - - 文件数据量只涉及到的分片数,以及每个分片中文件的数量。如果分片非常多,或者分片内的小文件较多,都可能增加备份操作的时间。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CANCEL-BACKUP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CANCEL-BACKUP.md deleted file mode 100644 index 8e0104663368a..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CANCEL-BACKUP.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "CANCEL-BACKUP", - "language": "zh-CN" -} ---- - - - -## CANCEL-BACKUP - -### Name - -CANCEL BACKUP - -## 描述 - -该语句用于取消一个正在进行的 BACKUP 任务。 - -语法: - -```sql -CANCEL BACKUP FROM db_name; -``` - -## 举例 - -1. 取消 example_db 下的 BACKUP 任务。 - -```sql -CANCEL BACKUP FROM example_db; -``` - -### Keywords - - CANCEL, BACKUP - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CANCEL-RESTORE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CANCEL-RESTORE.md deleted file mode 100644 index 3039333f80c8a..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CANCEL-RESTORE.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -{ - "title": "CANCEL-RESTORE", - "language": "zh-CN" -} ---- - - - -## CANCEL-RESTORE - -### Name - -CANCEL RESTORE - -## 描述 - -该语句用于取消一个正在进行的 RESTORE 任务。 - -语法: - -```sql -CANCEL RESTORE FROM db_name; -``` - -注意: - -- 当取消处于 COMMIT 或之后阶段的恢复左右时,可能导致被恢复的表无法访问。此时只能通过再次执行恢复作业进行数据恢复。 - -## 举例 - -1. 取消 example_db 下的 RESTORE 任务。 - -```sql -CANCEL RESTORE FROM example_db; -``` - -### Keywords - - CANCEL, RESTORE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CREATE-REPOSITORY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CREATE-REPOSITORY.md deleted file mode 100644 index ee22270848a67..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CREATE-REPOSITORY.md +++ /dev/null @@ -1,137 +0,0 @@ ---- -{ - "title": "CREATE-REPOSITORY", - "language": "zh-CN" -} ---- - - - -## CREATE-REPOSITORY - -### Name - -CREATE REPOSITORY - -## 描述 - -该语句用于创建仓库。仓库用于属于备份或恢复。仅 root 或 superuser 用户可以创建仓库。 - -语法: - -```sql -CREATE [READ ONLY] REPOSITORY `repo_name` -WITH [S3|hdfs] -ON LOCATION `repo_location` -PROPERTIES ("key"="value", ...); -``` - -说明: - -- 如果是只读仓库,则只能在仓库上进行恢复。如果不是,则可以进行备份和恢复操作。 -- 根据 S3、HDFS 的不同类型,PROPERTIES 有所不同,具体见示例。 -- ON LOCATION ,如果是 S3 , 这里后面跟的是 Bucket Name。 - -## 举例 - -1. 创建名为 s3_repo 的仓库。 - -```sql -CREATE REPOSITORY `s3_repo` -WITH S3 -ON LOCATION "s3://s3-repo" -PROPERTIES -( - "s3.endpoint" = "http://s3-REGION.amazonaws.com", - "s3.access_key" = "AWS_ACCESS_KEY", - "s3.secret_key"="AWS_SECRET_KEY", - "s3.region" = "REGION" -); -``` - -2. 创建名为 hdfs_repo 的仓库。 - -```sql -CREATE REPOSITORY `hdfs_repo` -WITH hdfs -ON LOCATION "hdfs://hadoop-name-node:54310/path/to/repo/" -PROPERTIES -( - "fs.defaultFS"="hdfs://hadoop-name-node:54310", - "hadoop.username"="user" -); -``` - -3. 创建名为 minio_repo 的仓库。 - -```sql -CREATE REPOSITORY `minio_repo` -WITH S3 -ON LOCATION "s3://minio_repo" -PROPERTIES -( - "s3.endpoint" = "http://minio.com", - "s3.access_key" = "MINIO_USER", - "s3.secret_key"="MINIO_PASSWORD", - "s3.region" = "REGION", - "use_path_style" = "true" -); -``` - -4. 使用临时秘钥创建名为 minio_repo 的仓库 - -```sql -CREATE REPOSITORY `minio_repo` -WITH S3 -ON LOCATION "s3://minio_repo" -PROPERTIES -( - "s3.endpoint" = "AWS_ENDPOINT", - "s3.access_key" = "AWS_TEMP_ACCESS_KEY", - "s3.secret_key" = "AWS_TEMP_SECRET_KEY", - "s3.session_token" = "AWS_TEMP_TOKEN", - "s3.region" = "AWS_REGION" -) -``` - -5. 使用腾讯云 COS 创建仓库 - -```sql -CREATE REPOSITORY `cos_repo` -WITH S3 -ON LOCATION "s3://backet1/" -PROPERTIES -( - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.endpoint" = "http://cos.ap-beijing.myqcloud.com", - "s3.region" = "ap-beijing" -); -``` - -### Keywords - - CREATE, REPOSITORY - -### Best Practice - -1. 一个集群可以创建过多个仓库。只有拥有 ADMIN 权限的用户才能创建仓库。 -2. 任何用户都可以通过 [SHOW REPOSITORIES](../../Show-Statements/SHOW-REPOSITORIES.md) 命令查看已经创建的仓库。 -3. 在做数据迁移操作时,需要在源集群和目的集群创建完全相同的仓库,以便目的集群可以通过这个仓库,查看到源集群备份的数据快照。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/DROP-REPOSITORY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/DROP-REPOSITORY.md deleted file mode 100644 index 99cde13e69ec9..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/DROP-REPOSITORY.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -{ - "title": "DROP-REPOSITORY", - "language": "zh-CN" -} ---- - - - -## DROP-REPOSITORY - -### Name - -DROP REPOSITORY - -## 描述 - -该语句用于删除一个已创建的仓库。仅 root 或 superuser 用户可以删除仓库。 - -语法: - -```sql -DROP REPOSITORY `repo_name`; -``` - -说明: - -- 删除仓库,仅仅是删除该仓库在 Palo 中的映射,不会删除实际的仓库数据。删除后,可以再次通过指定相同的 LOCATION 映射到该仓库。 - -## 举例 - -1. 删除名为 bos_repo 的仓库: - -```sql -DROP REPOSITORY `bos_repo`; -``` - -### Keywords - - DROP, REPOSITORY - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/RESTORE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/RESTORE.md deleted file mode 100644 index 10ae7314efd6b..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/RESTORE.md +++ /dev/null @@ -1,123 +0,0 @@ ---- -{ - "title": "RESTORE", - "language": "zh-CN" -} ---- - - - -## RESTORE - -### Name - -RESTORE - -## 描述 - -该语句用于将之前通过 BACKUP 命令备份的数据,恢复到指定数据库下。该命令为异步操作。提交成功后,需通过 SHOW RESTORE 命令查看进度。仅支持恢复 OLAP 类型的表。 - -语法: - -```sql -RESTORE SNAPSHOT [db_name].{snapshot_name} -FROM `repository_name` -[ON|EXCLUDE] ( - `table_name` [PARTITION (`p1`, ...)] [AS `tbl_alias`], - ... -) -PROPERTIES ("key"="value", ...); -``` - -说明: -- 同一数据库下只能有一个正在执行的 BACKUP 或 RESTORE 任务。 -- ON 子句中标识需要恢复的表和分区。如果不指定分区,则默认恢复该表的所有分区。所指定的表和分区必须已存在于仓库备份中。 -- EXCLUDE 子句中标识不需要恢复的表和分区。除了所指定的表或分区之外仓库中所有其他表的所有分区将被恢复。 -- 可以通过 AS 语句将仓库中备份的表名恢复为新的表。但新表名不能已存在于数据库中。分区名称不能修改。 -- 可以将仓库中备份的表恢复替换数据库中已有的同名表,但须保证两张表的表结构完全一致。表结构包括:表名、列、分区、Rollup 等等。 -- 可以指定恢复表的部分分区,系统会检查分区 Range 或者 List 是否能够匹配。 -- PROPERTIES 目前支持以下属性: - - "backup_timestamp" = "2018-05-04-16-45-08":指定了恢复对应备份的哪个时间版本,必填。该信息可以通过 `SHOW SNAPSHOT ON repo;` 语句获得。 - - "replication_num" = "3":指定恢复的表或分区的副本数。默认为 3。若恢复已存在的表或分区,则副本数必须和已存在表或分区的副本数相同。同时,必须有足够的 host 容纳多个副本。 - - "reserve_replica" = "true":默认为 false。当该属性为 true 时,会忽略 replication_num 属性,恢复的表或分区的副本数将与备份之前一样。支持多个表或表内多个分区有不同的副本数。 - - "reserve_dynamic_partition_enable" = "true":默认为 false。当该属性为 true 时,恢复的表会保留该表备份之前的'dynamic_partition_enable'属性值。该值不为 true 时,则恢复出来的表的'dynamic_partition_enable'属性值会设置为 false。 - - "timeout" = "3600":任务超时时间,默认为一天。单位秒。 - - "meta_version" = 40:使用指定的 meta_version 来读取之前备份的元数据。注意,该参数作为临时方案,仅用于恢复老版本 Doris 备份的数据。最新版本的备份数据中已经包含 meta version,无需再指定。 - - "clean_tables": 表示是否清理不属于恢复目标的表。例如,如果恢复之前的目标数据库有备份中不存在的表,指定 `clean_tables` 就可以在恢复期间删除这些额外的表并将其移入回收站。 - - "clean_partitions":表示是否清理不属于恢复目标的分区。例如,如果恢复之前的目标表有备份中不存在的分区,指定 `clean_partitions` 就可以在恢复期间删除这些额外的分区并将其移入回收站。 - -## 举例 - -1. 从 example_repo 中恢复备份 snapshot_1 中的表 backup_tbl 到数据库 example_db1,时间版本为 "2018-05-04-16-45-08"。恢复为 1 个副本: - -```sql -RESTORE SNAPSHOT example_db1.`snapshot_1` -FROM `example_repo` -ON ( `backup_tbl` ) -PROPERTIES -( - "backup_timestamp"="2018-05-04-16-45-08", - "replication_num" = "1" -); -``` - -2. 从 example_repo 中恢复备份 snapshot_2 中的表 backup_tbl 的分区 p1,p2,以及表 backup_tbl2 到数据库 example_db1,并重命名为 new_tbl,时间版本为 "2018-05-04-17-11-01"。默认恢复为 3 个副本: - -```sql -RESTORE SNAPSHOT example_db1.`snapshot_2` -FROM `example_repo` -ON -( - `backup_tbl` PARTITION (`p1`, `p2`), - `backup_tbl2` AS `new_tbl` -) -PROPERTIES -( - "backup_timestamp"="2018-05-04-17-11-01" -); -``` - -3. 从 example_repo 中恢复备份 snapshot_3 中除了表 backup_tbl 的其他所有表到数据库 example_db1,时间版本为 "2018-05-04-18-12-18"。 - -```sql -RESTORE SNAPSHOT example_db1.`snapshot_3` -FROM `example_repo` -EXCLUDE ( `backup_tbl` ) -PROPERTIES -( - "backup_timestamp"="2018-05-04-18-12-18" -); -``` - -### Keywords - - RESTORE - -### Best Practice - -1. 同一数据库下只能有一个正在执行的恢复操作。 - -2. 可以将仓库中备份的表恢复替换数据库中已有的同名表,但须保证两张表的表结构完全一致。表结构包括:表名、列、分区、物化视图等等。 - -3. 当指定恢复表的部分分区时,系统会检查分区范围是否能够匹配。 - -4. 恢复操作的效率: - - 在集群规模相同的情况下,恢复操作的耗时基本等同于备份操作的耗时。如果想加速恢复操作,可以先通过设置 `replication_num` 参数,仅恢复一个副本,之后在通过调整副本数 [ALTER TABLE PROPERTY](../../Data-Definition-Statements/Alter/ALTER-TABLE-PROPERTY.md),将副本补齐。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-ASYNC-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-ASYNC-MATERIALIZED-VIEW.md deleted file mode 100644 index 55cd1ab30a233..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-ASYNC-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,261 +0,0 @@ ---- -{ - "title": "CREATE-ASYNC-MATERIALIZED-VIEW", - "language": "zh-CN" -} ---- - - - -## CREATE-ASYNC-MATERIALIZED-VIEW - -### 名称 - -CREATE ASYNC MATERIALIZED VIEW - -### 描述 - -该语句用于创建异步物化视图。 - -#### 语法 - -```sql -CREATE MATERIALIZED VIEW (IF NOT EXISTS)? mvName=multipartIdentifier - (LEFT_PAREN cols=simpleColumnDefs RIGHT_PAREN)? buildMode? - (REFRESH refreshMethod? refreshTrigger?)? - ((DUPLICATE)? KEY keys=identifierList)? - (COMMENT STRING_LITERAL)? - (PARTITION BY LEFT_PAREN mvPartition RIGHT_PAREN)? - (DISTRIBUTED BY (HASH hashKeys=identifierList | RANDOM) (BUCKETS (INTEGER_VALUE | AUTO))?)? - PropertyClause? - AS query -``` - -#### 说明 - -`simpleColumnDefs` - -用来定义物化视图 Column 信息,如果不定义,将自动推导。 - -```sql -simpleColumnDefs -: cols+=simpleColumnDef (COMMA cols+=simpleColumnDef)* - ; - -simpleColumnDef -: colName=identifier (COMMENT comment=STRING_LITERAL)? - ; -``` - -例如:定义两列 aa 和 bb,其中 aa 的注释为"name" -```sql -CREATE MATERIALIZED VIEW mv1 -(aa comment "name",bb) -``` - -`buildMode` - -用来定义物化视图是否创建完成立即刷新,默认 IMMEDIATE - -IMMEDIATE:立即刷新 - -DEFERRED:延迟刷新 - -```sql -buildMode -: BUILD (IMMEDIATE | DEFERRED) -; -``` - -例如:指定物化视图立即刷新 - -```sql -CREATE MATERIALIZED VIEW mv1 -BUILD IMMEDIATE -``` - -`refreshMethod` - -用来定义物化视图刷新方式,默认 AUTO - -COMPLETE:全量刷新 - -AUTO:尽量增量刷新,如果不能分区增量刷新,就全量刷新 - -物化视图的 SQL 定义和分区字段需要满足如下条件,才可以进行分区增量更新: - -- 物化视图使用的 Base Table 中至少有一个是分区表。 -- 物化视图使用的 Base Table 分区表,必须使用 List 或者 Range 分区策略。 -- 物化视图定义 SQL 中 Partition By 分区列只能有一个分区字段。 -- 物化视图的 SQL 中 Partition By 的分区列,要在 Select 后。 -- 物化视图定义 SQL,如果使用了 Group By,分区列的字段一定要在 Group By 后。 -- 物化视图定义 SQL,如果使用了 Window 函数,分区列的字段一定要在 Partition By 后。 -- 数据变更应发生在分区表上,如果发生在非分区表,物化视图需要全量构建。 -- 物化视图使用 Join 的 NULL 产生端的字段作为分区字段,不能分区增量更新,例如对于 LEFT OUTER JOIN 分区字段需要在左侧,在右侧则不行。 - - -```sql -refreshMethod -: COMPLETE | AUTO -; -``` - -例如:指定物化视图全量刷新 -```sql -CREATE MATERIALIZED VIEW mv1 -REFRESH COMPLETE -``` - -`refreshTrigger` - -物化视图刷新数据的触发方式,默认 MANUAL - -MANUAL:手动刷新 - -SCHEDULE:定时刷新 - -COMMIT:触发式刷新,基表数据变更时,自动生成刷新物化视图的任务 - -```sql -refreshTrigger -: ON MANUAL -| ON SCHEDULE refreshSchedule -| ON COMMIT -; - -refreshSchedule -: EVERY INTEGER_VALUE mvRefreshUnit (STARTS STRING_LITERAL)? -; - -mvRefreshUnit -: MINUTE | HOUR | DAY | WEEK -; -``` - -例如:每2小时执行一次,从2023-12-13 21:07:09开始 -```sql -CREATE MATERIALIZED VIEW mv1 -REFRESH ON SCHEDULE EVERY 2 HOUR STARTS "2023-12-13 21:07:09" -``` - -`key` -物化视图为 Duplicate Key 模型,因此指定的列为排序列 - -```sql -identifierList -: LEFT_PAREN identifierSeq RIGHT_PAREN - ; - -identifierSeq -: ident+=errorCapturingIdentifier (COMMA ident+=errorCapturingIdentifier)* -; -``` - -例如:指定k1,k2为排序列 -```sql -CREATE MATERIALIZED VIEW mv1 -KEY(k1,k2) -``` - -`partition` -物化视图有两种分区方式,如果不指定分区,默认只有一个分区,如果指定分区字段,会自动推导出字段来自哪个基表并同步基表(当前支持 `OlapTable` 和 `hive`)的所有分区(限制条件:基表如果是 `OlapTable`,那么只能有一个分区字段)。 - -例如:基表是 Range 分区,分区字段为 `create_time` 并按天分区,创建物化视图时指定 `partition by(ct) as select create_time as ct from t1`,那么物化视图也会是 Range 分区,分区字段为 `ct`,并且按天分区。 - -物化视图也可以通过分区上卷的方式减少物化视图的分区数量,目前分区上卷函数支持 `date_trunc`,上卷的单位支持 `year`, `month`, `day` - -分区字段的选择和物化视图的定义需要满足分区增量更新的条件,物化视图才可以创建成功,否则会报错 `Unable to find a suitable base table for partitioning` - -```sql -mvPartition - : partitionKey = identifier - | partitionExpr = functionCallExpression - ; -``` - -例如基表按天分区,物化视图同样按天分区 -```sql -partition by (`k2`) -``` - -例如基表按天分区,物化视图按月分区 -```sql -partition by (date_trunc(`k2`,'month')) -``` - -#### Property -物化视图既可以指定 Table 的 Property,也可以指定物化视图特有的 Property。 - -物化视图特有的 Property 包括: - -`grace_period`:查询改写时允许物化视图数据的最大延迟时间(单位:秒)。如果分区 A 和基表的数据不一致,物化视图的分区 A 上次刷新时间为 1,系统当前时间为 2,那么该分区不会被透明改写。但是如果 `grace_period` 大于等于1,该分区就会被用于透明改写。 - -`excluded_trigger_tables`:数据刷新时忽略的表名,逗号分割。例如`table1,table2` - -`refresh_partition_num`:单次 Insert 语句刷新的分区数量,默认为 1。物化视图刷新时会先计算要刷新的分区列表,然后根据该配置拆分成多个 Insert 语句顺序执行。遇到失败的 Insert 语句,整个任务将停止执行。物化视图保证单个 Insert 语句的事务性,失败的 Insert 语句不会影响到已经刷新成功的分区。 - -`workload_group`:物化视图执行刷新任务时使用的 `workload_group` 名称。用来限制物化视图刷新数据使用的资源,避免影响到其它业务的运行。关于 `workload_group` 的创建及使用,可参考 [Workload Group](../../../../admin-manual/workload-group.md) 文档。 - -`partition_sync_limit`:当基表的分区字段为时间时(如果是字符串类型的时间,可以设置 `partition_date_format`),可以用此属性配置同步基表的分区范围,配合 `partition_sync_time_unit` 一起使用。 -例如设置为 2,`partition_sync_time_unit` 设置为 `MONTH`,代表仅同步基表近 2 个月的分区和数据。最小值为 `1`。 -随着时间的变化物化视图每次刷新时都会自动增删分区,例如物化视图现在有 2,3 两个月的数据,下个月的时候,会自动删除 2 月的数据,增加 4 月的数据。 - -`partition_sync_time_unit`:时间单位,支持 DAY/MONTH/YEAR(默认DAY) - -`partition_date_format`:分区字段的时间格式,例如"%Y-%m-%d" - -`enable_nondeterministic_function`:物化视图定义 SQL 是否允许包含 nondeterministic 函数,比如 current_date(), now(), random()等,如果 -是 true, 允许包含,否则不允许包含, 默认不允许包含。 - -:::tips -自 2.1.7 版本起支持 use_for_rewrite -::: -`use_for_rewrite`:标识此物化视图是否参与到透明改写中,如果为 false,不参与到透明改写,默认是 true。数据建模场景中,如果物化视图只是用于直查,物化视图可以设置此属性,从而不参与透明改写,提高查询响应速度。 - -`query`:创建物化视图的查询语句,其结果即为物化视图中的数据 - - -### 示例 - -1. 创建一个立即刷新,之后每周刷新一次的物化视图 `mv1`,数据源为 Hive Catalog - - ```sql - CREATE MATERIALIZED VIEW mv1 BUILD IMMEDIATE REFRESH COMPLETE ON SCHEDULE EVERY 1 WEEK - DISTRIBUTED BY RANDOM BUCKETS 2 - PROPERTIES ( - "replication_num" = "1" - ) - AS SELECT * FROM hive_catalog.db1.user; - ``` - -2. 创建一个多表 Join 的物化视图 - - ```sql - CREATE MATERIALIZED VIEW mv1 BUILD IMMEDIATE REFRESH COMPLETE ON SCHEDULE EVERY 1 WEEK - DISTRIBUTED BY RANDOM BUCKETS 2 - PROPERTIES ( - "replication_num" = "1" - ) - AS select user.k1,user.k3,com.k4 from user join com on user.k1=com.k1; - ``` - -### 关键词 - - CREATE, ASYNC, MATERIALIZED, VIEW diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-CATALOG.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-CATALOG.md deleted file mode 100644 index 8706ecfcce770..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-CATALOG.md +++ /dev/null @@ -1,179 +0,0 @@ ---- -{ - "title": "CREATE-CATALOG", - "language": "zh-CN" -} ---- - - - -## CREATE-CATALOG - -### Name - -CREATE CATALOG - -## 描述 - -该语句用于创建外部数据目录(catalog) - -语法: - -```sql -CREATE CATALOG [IF NOT EXISTS] catalog_name [comment] - PROPERTIES ("key"="value", ...); -``` - -* hms:Hive MetaStore -* es:Elasticsearch -* jdbc:数据库访问的标准接口(JDBC), 当前支持 MySQL 和 PostgreSQL - -## 举例 - -1. 新建数据目录 hive - - ```sql - CREATE CATALOG hive comment 'hive catalog' PROPERTIES ( - 'type'='hms', - 'hive.metastore.uris' = 'thrift://127.0.0.1:7004', - 'dfs.nameservices'='HANN', - 'dfs.ha.namenodes.HANN'='nn1,nn2', - 'dfs.namenode.rpc-address.HANN.nn1'='nn1_host:rpc_port', - 'dfs.namenode.rpc-address.HANN.nn2'='nn2_host:rpc_port', - 'dfs.client.failover.proxy.provider.HANN'='org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider' - ); - ``` - -2. 新建数据目录 es - - ```sql - CREATE CATALOG es PROPERTIES ( - "type"="es", - "hosts"="http://127.0.0.1:9200" - ); - ``` - -3. 新建数据目录 jdbc - - **mysql** - - ```sql - CREATE CATALOG jdbc PROPERTIES ( - "type"="jdbc", - "user"="root", - "password"="123456", - "jdbc_url" = "jdbc:mysql://127.0.0.1:3316/doris_test?useSSL=false", - "driver_url" = "https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/jdbc_driver/mysql-connector-java-8.0.25.jar", - "driver_class" = "com.mysql.cj.jdbc.Driver" - ); - ``` - - **postgresql** - - ```sql - CREATE CATALOG jdbc PROPERTIES ( - "type"="jdbc", - "user"="postgres", - "password"="123456", - "jdbc_url" = "jdbc:postgresql://127.0.0.1:5432/demo", - "driver_url" = "file:///path/to/postgresql-42.5.1.jar", - "driver_class" = "org.postgresql.Driver" - ); - ``` - - **clickhouse** - - ```sql - CREATE CATALOG jdbc PROPERTIES ( - "type"="jdbc", - "user"="default", - "password"="123456", - "jdbc_url" = "jdbc:clickhouse://127.0.0.1:8123/demo", - "driver_url" = "file:///path/to/clickhouse-jdbc-0.3.2-patch11-all.jar", - "driver_class" = "com.clickhouse.jdbc.ClickHouseDriver" - ) - ``` - - **oracle** - ```sql - CREATE CATALOG jdbc PROPERTIES ( - "type"="jdbc", - "user"="doris", - "password"="123456", - "jdbc_url" = "jdbc:oracle:thin:@127.0.0.1:1521:helowin", - "driver_url" = "file:///path/to/ojdbc8.jar", - "driver_class" = "oracle.jdbc.driver.OracleDriver" - ); - ``` - - **SQLServer** - ```sql - CREATE CATALOG sqlserver_catalog PROPERTIES ( - "type"="jdbc", - "user"="SA", - "password"="Doris123456", - "jdbc_url" = "jdbc:sqlserver://localhost:1433;DataBaseName=doris_test", - "driver_url" = "file:///path/to/mssql-jdbc-11.2.3.jre8.jar", - "driver_class" = "com.microsoft.sqlserver.jdbc.SQLServerDriver" - ); - ``` - - **SAP HANA** - ```sql - CREATE CATALOG saphana_catalog PROPERTIES ( - "type"="jdbc", - "user"="SYSTEM", - "password"="SAPHANA", - "jdbc_url" = "jdbc:sap://localhost:31515/TEST", - "driver_url" = "file:///path/to/ngdbc.jar", - "driver_class" = "com.sap.db.jdbc.Driver" - ); - ``` - - **Trino** - ```sql - CREATE CATALOG trino_catalog PROPERTIES ( - "type"="jdbc", - "user"="hadoop", - "password"="", - "jdbc_url" = "jdbc:trino://localhost:8080/hive", - "driver_url" = "file:///path/to/trino-jdbc-389.jar", - "driver_class" = "io.trino.jdbc.TrinoDriver" - ); - ``` - - **OceanBase** - ```sql - CREATE CATALOG oceanbase_catalog PROPERTIES ( - "type"="jdbc", - "user"="root", - "password"="", - "jdbc_url" = "jdbc:oceanbase://localhost:2881/demo", - "driver_url" = "file:///path/to/oceanbase-client-2.4.2.jar", - "driver_class" = "com.oceanbase.jdbc.Driver" - ); - ``` - -### Keywords - -CREATE, CATALOG - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-DATABASE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-DATABASE.md deleted file mode 100644 index 533d139645d5e..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-DATABASE.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -{ - "title": "CREATE-DATABASE", - "language": "zh-CN" -} ---- - - - -## CREATE-DATABASE - -### Name - -CREATE DATABASE - -## 描述 - -该语句用于新建数据库(database) - -语法: - -```sql -CREATE DATABASE [IF NOT EXISTS] db_name - [PROPERTIES ("key"="value", ...)]; -``` - -`PROPERTIES` 该数据库的附加信息,可以缺省。 - -- 如果要为db下的table指定默认的副本分布策略,需要指定`replication_allocation`(table的`replication_allocation`属性优先级会高于db) - - ```sql - PROPERTIES ( - "replication_allocation" = "tag.location.default:3" - ) - ``` - -## 举例 - -1. 新建数据库 db_test - - ```sql - CREATE DATABASE db_test; - ``` - -2. 新建数据库并设置默认的副本分布: - - ```sql - CREATE DATABASE `db_test` - PROPERTIES ( - "replication_allocation" = "tag.location.group_1:3" - ); - ``` - -:::caution -若建表语句属性key带replication_allocation或replication_num,则db的默认的副本分布策略不会生效 -::: - -### Keywords - -```text -CREATE, DATABASE -``` - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-ENCRYPT-KEY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-ENCRYPT-KEY.md deleted file mode 100644 index 7b12b810050a4..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-ENCRYPT-KEY.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -{ - "title": "CREATE-ENCRYPT-KEY", - "language": "zh-CN" -} ---- - - - -## CREATE-ENCRYPTKEY - -### Name - -CREATE ENCRYPTKEY - -## 描述 - -此语句创建一个自定义密钥。执行此命令需要用户拥有 `ADMIN` 权限。 - -语法: - -```sql -CREATE ENCRYPTKEY key_name AS "key_string" -``` - -说明: - -`key_name`: 要创建密钥的名字, 可以包含数据库的名字。比如:`db1.my_key`。 - -`key_string`: 要创建密钥的字符串。 - -如果 `key_name` 中包含了数据库名字,那么这个自定义密钥会创建在对应的数据库中,否则这个函数将会创建在当前会话所在的数据库。新密钥的名字不能够与对应数据库中已存在的密钥相同,否则会创建失败。 - -## 举例 - -1. 创建一个自定义密钥 - - ```sql - CREATE ENCRYPTKEY my_key AS "ABCD123456789"; - ``` - -2. 使用自定义密钥 - - 使用自定义密钥需在密钥前添加关键字 `KEY`/`key`,与 `key_name` 空格隔开。 - - ```sql - mysql> SELECT HEX(AES_ENCRYPT("Doris is Great", KEY my_key)); - +------------------------------------------------+ - | hex(aes_encrypt('Doris is Great', key my_key)) | - +------------------------------------------------+ - | D26DB38579D6A343350EDDC6F2AD47C6 | - +------------------------------------------------+ - 1 row in set (0.02 sec) - - mysql> SELECT AES_DECRYPT(UNHEX('D26DB38579D6A343350EDDC6F2AD47C6'), KEY my_key); - +--------------------------------------------------------------------+ - | aes_decrypt(unhex('D26DB38579D6A343350EDDC6F2AD47C6'), key my_key) | - +--------------------------------------------------------------------+ - | Doris is Great | - +--------------------------------------------------------------------+ - 1 row in set (0.01 sec) - ``` - -### Keywords - - CREATE, ENCRYPTKEY - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FILE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FILE.md deleted file mode 100644 index c83d6e8e3521f..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FILE.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -{ - "title": "CREATE-FILE", - "language": "zh-CN" -} ---- - - - -## CREATE-FILE - -### Name - -CREATE FILE - -## 描述 - -该语句用于创建并上传一个文件到 Doris 集群。 -该功能通常用于管理一些其他命令中需要使用到的文件,如证书、公钥私钥等等。 - -该命令只用 `admin` 权限用户可以执行。 -某个文件都归属与某一个的 database。对 database 拥有访问权限的用户都可以使用该文件。 - -单个文件大小限制为 1MB。 -一个 Doris 集群最多上传 100 个文件。 - -语法: - -```sql -CREATE FILE "file_name" [IN database] -PROPERTIES("key"="value", ...) -``` - -说明: - -- file_name: 自定义文件名。 -- database: 文件归属于某一个 db,如果没有指定,则使用当前 session 的 db。 -- properties 支持以下参数: - - url:必须。指定一个文件的下载路径。当前仅支持无认证的 http 下载路径。命令执行成功后,文件将被保存在 doris 中,该 url 将不再需要。 - - catalog:必须。对文件的分类名,可以自定义。但在某些命令中,会查找指定 catalog 中的文件。比如例行导入中的,数据源为 kafka 时,会查找 catalog 名为 kafka 下的文件。 - - md5: 可选。文件的 md5。如果指定,会在下载文件后进行校验。 - -## 举例 - -1. 创建文件 ca.pem ,分类为 kafka - - ```sql - CREATE FILE "ca.pem" - PROPERTIES - ( - "url" = "https://test.bj.bcebos.com/kafka-key/ca.pem", - "catalog" = "kafka" - ); - ``` - -2. 创建文件 client.key,分类为 my_catalog - - ```sql - CREATE FILE "client.key" - IN my_database - PROPERTIES - ( - "url" = "https://test.bj.bcebos.com/kafka-key/client.key", - "catalog" = "my_catalog", - "md5" = "b5bb901bf10f99205b39a46ac3557dd9" - ); - ``` - -### Keywords - -```text -CREATE, FILE -``` - -### Best Practice - -1. 该命令只有 amdin 权限用户可以执行。某个文件都归属与某一个的 database。对 database 拥有访问权限的用户都可以使用该文件。 - -2. 文件大小和数量限制。 - - 这个功能主要用于管理一些证书等小文件。因此单个文件大小限制为 1MB。一个 Doris 集群最多上传 100 个文件。 - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FUNCTION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FUNCTION.md deleted file mode 100644 index f980b4a66e671..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FUNCTION.md +++ /dev/null @@ -1,133 +0,0 @@ ---- -{ - "title": "CREATE-FUNCTION", - "language": "zh-CN" -} ---- - - - -## CREATE-FUNCTION - -### Name - -CREATE FUNCTION - -## 描述 - -此语句创建一个自定义函数。执行此命令需要用户拥有 `ADMIN` 权限。 - -如果 `function_name` 中包含了数据库名字,那么这个自定义函数会创建在对应的数据库中,否则这个函数将会创建在当前会话所在的数据库。新函数的名字与参数不能够与当前命名空间中已存在的函数相同,否则会创建失败。但是只有名字相同,参数不同是能够创建成功的。 - -语法: - -```sql -CREATE [GLOBAL] [AGGREGATE] [ALIAS] FUNCTION function_name - (arg_type [, ...]) - [RETURNS ret_type] - [INTERMEDIATE inter_type] - [WITH PARAMETER(param [,...]) AS origin_function] - [PROPERTIES ("key" = "value" [, ...]) ] -``` - -参数说明: - -- `GLOBAL`: 如果有此项,表示的是创建的函数是全局范围内生效。 - -- `AGGREGATE`: 如果有此项,表示的是创建的函数是一个聚合函数。 - - -- `ALIAS`:如果有此项,表示的是创建的函数是一个别名函数。 - - - 如果没有上述两项,表示创建的函数是一个标量函数 - -- `function_name`: 要创建函数的名字, 可以包含数据库的名字。比如:`db1.my_func`。 - - -- `arg_type`: 函数的参数类型,与建表时定义的类型一致。变长参数时可以使用`, ...`来表示,如果是变长类型,那么变长部分参数的类型与最后一个非变长参数类型一致。 - - **注意**:`ALIAS FUNCTION` 不支持变长参数,且至少有一个参数。 - -- `ret_type`: 对创建新的函数来说,是必填项。如果是给已有函数取别名则可不用填写该参数。 - - -- `inter_type`: 用于表示聚合函数中间阶段的数据类型。 - - -- `param`:用于表示别名函数的参数,至少包含一个。 - - -- `origin_function`:用于表示别名函数对应的原始函数。 - -- `properties`: 用于设定函数相关属性,能够设置的属性包括: - - - `file`: 表示的包含用户UDF的jar包,当在多机环境时,也可以使用http的方式下载jar包。这个参数是必须设定的。 - - - `symbol`: 表示的是包含UDF类的类名。这个参数是必须设定的 - - - `type`: 表示的 UDF 调用类型,默认为 Native,使用 Java UDF时传 JAVA_UDF。 - - - `always_nullable`:表示的 UDF 返回结果中是否有可能出现NULL值,是可选参数,默认值为true。 - - -## 举例 - -1. 创建一个自定义UDF函数 - - ```sql - CREATE FUNCTION java_udf_add_one(int) RETURNS int PROPERTIES ( - "file"="file:///path/to/java-udf-demo-jar-with-dependencies.jar", - "symbol"="org.apache.doris.udf.AddOne", - "always_nullable"="true", - "type"="JAVA_UDF" - ); - ``` - - -2. 创建一个自定义UDAF函数 - - ```sql - CREATE AGGREGATE FUNCTION simple_sum(INT) RETURNS INT PROPERTIES ( - "file"="file:///pathTo/java-udaf.jar", - "symbol"="org.apache.doris.udf.demo.SimpleDemo", - "always_nullable"="true", - "type"="JAVA_UDF" - ); - ``` - -3. 创建一个自定义别名函数 - - ```sql - CREATE ALIAS FUNCTION id_masking(INT) WITH PARAMETER(id) AS CONCAT(LEFT(id, 3), '****', RIGHT(id, 4)); - ``` - -4. 创建一个全局自定义别名函数 - - ```sql - CREATE GLOBAL ALIAS FUNCTION id_masking(INT) WITH PARAMETER(id) AS CONCAT(LEFT(id, 3), '****', RIGHT(id, 4)); - ``` - -### Keywords - - CREATE, FUNCTION - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-INDEX.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-INDEX.md deleted file mode 100644 index 9783be2632d6f..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-INDEX.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -{ - "title": "CREATE-INDEX", - "language": "zh-CN" -} ---- - - - -## CREATE-INDEX - -### Name - -CREATE INDEX - -## 描述 - -该语句用于创建索引 -语法: - -```sql -CREATE INDEX [IF NOT EXISTS] index_name ON table_name (column [, ...],) [USING INVERTED] [COMMENT'balabala']; -``` -注意: -- 倒排索引仅在单列上创建 - -## 举例 - -1. 在table1 上为siteid 创建倒排索引 - - ```sql - CREATE INDEX [IF NOT EXISTS] index_name ON table1 (siteid) USING INVERTED COMMENT 'balabala'; - ``` - - -### Keywords - -```text -CREATE, INDEX -``` - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-JOB.md deleted file mode 100644 index 44e4ee9410485..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-JOB.md +++ /dev/null @@ -1,174 +0,0 @@ ---- -{ -"title": "CREATE-JOB", -"language": "zh-CN" -} - ---- - - - -## CREATE-JOB - -### Name - -CREATE JOB - -## 描述 - -Doris Job 是根据既定计划运行的任务,用于在特定时间或指定时间间隔触发预定义的操作,从而帮助我们自动执行一些任务。从功能上来讲,它类似于操作系统上的 -定时任务(如:Linux 中的 cron、Windows 中的计划任务)。 - -Job 有两种类型:`ONE_TIME` 和 `RECURRING`。其中 `ONE_TIME` 类型的 Job 会在指定的时间点触发,它主要用于一次性任务,而 `RECURRING` 类型的 Job 会在指定的时间间隔内循环触发, 此方式主要用于周期性执行的任务。 -`RECURRING` 类型的 Job 可指定开始时间,结束时间,即 `STARTS\ENDS`, 如果不指定开始时间,则默认首次执行时间为当前时间 + 一次调度周期。如果指定结束时间,则 task 执行完成如果达到结束时间(或超过,或下次执行周期会超过结束时间)则更新为FINISHED状态,此时不会再产生 Task。 - -JOB 共4种状态(`RUNNING`,`STOPPED`,`PAUSED`,`FINISHED`,),初始状态为RUNNING,RUNNING 状态的JOB会根据既定的调度周期去生成 TASK 执行,Job 执行完成达到结束时间则状态变更为 `FINISHED`. - -RUNNING 状态的JOB 可以被 pause,即暂停,此时不会再生成 Task。 - -PAUSE状态的 JOB 可以通过 RESUME 操作来恢复运行,更改为RUNNING状态。 - -STOP 状态的 JOB 由用户主动触发,此时会 Cancel 正在运行中的作业,然后删除 JOB。 - -Finished 状态的 JOB 会保留在系统中 24 H,24H 后会被删除。 - -JOB 只描述作业信息, 执行会生成 TASK, TASK 状态分为 PENDING,RUNNING,SUCCEESS,FAILED,CANCELED -PENDING 表示到达触发时间了但是等待资源 RUN, 分配到资源后状态变更为RUNNING ,执行成功/失败即变更为 SUCCESS/FAILED. -CANCELED 即取消状态 ,TASK持久化最终状态,即SUCCESS/FAILED,其他状态运行中可以查到,但是如果重启则不可见。TASK只保留最新的 100 条记录。 - -#### 权限 - -- 目前仅支持 ***ADMIN*** 权限执行此操作。 - -#### 相关文档 - -- [暂停-JOB](../Alter/PAUSE-JOB.md) -- [恢复-JOB](../Alter/RESUME-JOB.md) -- [删除-JOB](../Drop/DROP-JOB.md) -- [查询-JOB](../../../sql-functions/table-valued-functions/jobs.md) -- [查询-TASKS](../../../sql-functions/table-valued-functions/tasks.md) - -### 语法 - -```sql -CREATE - JOB - job_name - ON SCHEDULE schedule - [COMMENT 'string'] - DO sql_body; - -schedule: { - AT timestamp - | EVERY interval - [STARTS timestamp ] - [ENDS timestamp ] -} - -interval: - quantity { WEEK | DAY | HOUR | MINUTE } -``` - -一条有效的 Job 语句必须包含以下内容 - -- 关键字 CREATE JOB 加上作业名称,它在一个 db 中标识唯一事件。 JOB 名称必须是全局唯一的,如果已经存在同名的 JOB,则会报错。我们保留了 ***inner_*** 前缀在系统内部使用,因此用户不能创建以 ***inner_*** 开头的名称。 -- ON SCHEDULE 子句,它指定了 Job 作业的类型和触发时间以及频率。 -- DO 子句,它指定了 Job 作业触发时需要执行的操作, 即一条 SQL 语句。 - -这是一个最简单的例子: - -```sql -CREATE JOB my_job ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO db1.tbl1 SELECT * FROM db2.tbl2; -``` - -该语句表示创建一个名为 my_job 的作业,每分钟执行一次,执行的操作是将 db2.tbl2 中的数据导入到 db1.tbl1 中。 - -SCHEDULE 语句用于定义作业的执行时间,频率以及持续时间,它可以指定一次性作业或者周期性作业。 -- AT timestamp - -格式:'YYYY-MM-DD HH:MM:SS', 用于一次性事件,它指定事件仅在 给定的日期和时间执行一次 timestamp,当执行完成后,JOB 状态会变更为 FINISHED。 - -- EVERY - - 表示定期重复操作,它指定了作业的执行频率,关键字后面要指定一个时间间隔,该时间间隔可以是天、小时、分钟、秒、周。 - - - interval - - 用于指定作业执行频率,它可以是天、小时、分钟、周。例如:` 1 DAY` 表示每天执行一次,` 1 HOUR` 表示每小时执行一次,` 1 MINUTE` 表示每分钟执行一次,` 1 WEEK` 表示每周执行一次。 - - - STARTS timestamp (可选字段) - - 格式:'YYYY-MM-DD HH:MM:SS',用于指定作业的开始时间,如果没有指定,则从当前时间的下一个时间点开始执行。开始时间必须大于当前时间。 - - - ENDS timestamp (可选字段) - - 格式:'YYYY-MM-DD HH:MM:SS', 用于指定作业的结束时间,如果没有指定,则表示永久执行。该日期必须大于当前时间,如果指定了开始时间, 即 `STARTS`,则结束时间必须大于开始时间。 - -- DO - - 用于指定作业触发时需要执行的操作,目前仅支持 ***INSERT 内表*** 操作。后续我们会支持更多的操作。 - -## 举例 - -创建一个一次性的 Job,它会在 2020-01-01 00:00:00 时执行一次,执行的操作是将 db2.tbl2 中的数据导入到 db1.tbl1 中。 - -```sql - -CREATE JOB my_job ON SCHEDULE AT '2020-01-01 00:00:00' DO INSERT INTO db1.tbl1 SELECT * FROM db2.tbl2; - -``` - -创建一个周期性的 Job,它会在 2020-01-01 00:00:00 时开始执行,每天执行一次,执行的操作是将 db2.tbl2 中的数据导入到 db1.tbl1 中。 - -```sql -CREATE JOB my_job ON SCHEDULE EVERY 1 DAY STARTS '2020-01-01 00:00:00' DO INSERT INTO db1.tbl1 SELECT * FROM db2.tbl2 WHERE create_time >= days_add(now(),-1); -``` - -创建一个周期性的 Job,它会在 2020-01-01 00:00:00 时开始执行,每天执行一次,执行的操作是将 db2.tbl2 中的数据导入到 db1.tbl1 中,该 Job 在 2020-01-01 00:10:00 时结束。 - -```sql -CREATE JOB my_job ON SCHEDULE EVERY 1 DAY STARTS '2020-01-01 00:00:00' ENDS '2020-01-01 00:10:00' DO INSERT INTO db1.tbl1 SELECT * FROM db2.tbl2 create_time >= days_add(now(),-1); -``` - -### INSERT JOB - -- 目前仅支持 ***INSERT 内表*** -- 当下一个计划任务时间到期,即需要调度任务执行时,如果当前 JOB 仍有历史任务正在执行,则会跳过当前任务调度。因此控制一个合理的执行间隔非常重要。 - -### CONFIG - -fe.conf - -- job_dispatch_timer_job_thread_num, 用于分发定时任务的线程数, 默认值2,如果含有大量周期执行任务,可以调大这个参数。 - -- job_dispatch_timer_job_queue_size, 任务堆积时用于存放定时任务的队列大小,默认值 1024. 如果有大量任务同一时间触发,可以调大这个参数。否则会导致队列满,提交任务会进入阻塞状态,从而导致后续任务无法提交。 - -- finished_job_cleanup_threshold_time_hour, 用于清理已完成的任务的时间阈值,单位为小时,默认值为24小时。 - -- job_insert_task_consumer_thread_num = 10;用于执行 Insert 任务的线程数, 值应该大于0,否则默认为5. - -### Best Practice - -- 合理的进行 Job 的管理,避免大量的 Job 同时触发,导致任务堆积,从而影响系统的正常运行。 -- 任务的执行间隔应该设置在一个合理的范围,至少应该大于任务执行时间。 - -### Keywords - - CREATE, JOB diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-MATERIALIZED-VIEW.md deleted file mode 100644 index 5aeefd3792356..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,236 +0,0 @@ ---- -{ - "title": "CREATE-MATERIALIZED-VIEW", - "language": "zh-CN" -} ---- - - - -## CREATE-MATERIALIZED-VIEW - -### Name - -CREATE MATERIALIZED VIEW - -## 描述 - -该语句用于创建物化视图。 - -该操作为异步操作,提交成功后,需通过 [SHOW ALTER TABLE MATERIALIZED VIEW](../../Show-Statements/SHOW-ALTER-TABLE-MATERIALIZED-VIEW.md) 查看作业进度。在显示 FINISHED 后既可通过 `desc [table_name] all` 命令来查看物化视图的 schema 了。 - -语法: - -```sql -CREATE MATERIALIZED VIEW < MV name > as < query > -[PROPERTIES ("key" = "value")] -``` - -说明: - -- `MV name`:物化视图的名称,必填项。相同表的物化视图名称不可重复。 - -- `query`:用于构建物化视图的查询语句,查询语句的结果既物化视图的数据。目前支持的 query 格式为: - - ```sql - SELECT select_expr[, select_expr ...] - FROM [Base view name] - GROUP BY column_name[, column_name ...] - ORDER BY column_name[, column_name ...] - ``` - - 语法和查询语句语法一致。 - - - `select_expr`:物化视图的 schema 中所有的列。 - - 至少包含一个单列。 - - `base view name`:物化视图的原始表名,必填项。 - - 必须是单表,且非子查询 - - `group by`:物化视图的分组列,选填项。 - - 不填则数据不进行分组。 - - `order by`:物化视图的排序列,选填项。 - - 排序列的声明顺序必须和 select_expr 中列声明顺序一致。 - - 如果不声明 order by,则根据规则自动补充排序列。 如果物化视图是聚合类型,则所有的分组列自动补充为排序列。 如果物化视图是非聚合类型,则前 36 个字节自动补充为排序列。 - - 如果自动补充的排序个数小于3个,则前三个作为排序列。 如果 query 中包含分组列的话,则排序列必须和分组列一致。 - -- properties - - 声明物化视图的一些配置,选填项。 - - ```text - PROPERTIES ("key" = "value", "key" = "value" ...) - ``` - - 以下几个配置,均可声明在此处: - - ```text - short_key: 排序列的个数。 - timeout: 物化视图构建的超时时间。 - ``` - -## 举例 - -Base 表结构为 - -```sql -mysql> desc duplicate_table; -+-------+--------+------+------+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-------+--------+------+------+---------+-------+ -| k1 | INT | Yes | true | N/A | | -| k2 | INT | Yes | true | N/A | | -| k3 | BIGINT | Yes | true | N/A | | -| k4 | BIGINT | Yes | true | N/A | | -+-------+--------+------+------+---------+-------+ -``` -```sql -create table duplicate_table( - k1 int null, - k2 int null, - k3 bigint null, - k4 bigint null -) -duplicate key (k1,k2,k3,k4) -distributed BY hash(k4) buckets 3 -properties("replication_num" = "1"); -``` -注意:如果物化视图包含了base表的分区列和分桶列,那么这些列必须作为物化视图中的key列 - -1. 创建一个仅包含原始表 (k1, k2)列的物化视图 - - ```sql - create materialized view k1_k2 as - select k2, k1 from duplicate_table; - ``` - - 物化视图的 schema 如下图,物化视图仅包含两列 k1, k2 且不带任何聚合 - - ```text - +-----------------+-------+--------+------+------+---------+-------+ - | IndexName | Field | Type | Null | Key | Default | Extra | - +-----------------+-------+--------+------+------+---------+-------+ - | k2_k1 | k2 | INT | Yes | true | N/A | | - | | k1 | INT | Yes | true | N/A | | - +-----------------+-------+--------+------+------+---------+-------+ - ``` - -2. 创建一个以 k2 为排序列的物化视图 - - ```sql - create materialized view k2_order as - select k2, k1 from duplicate_table order by k2; - ``` - - 物化视图的 schema 如下图,物化视图仅包含两列 k2, k1,其中 k2 列为排序列,不带任何聚合。 - - ```text - +-----------------+-------+--------+------+-------+---------+-------+ - | IndexName | Field | Type | Null | Key | Default | Extra | - +-----------------+-------+--------+------+-------+---------+-------+ - | k2_order | k2 | INT | Yes | true | N/A | | - | | k1 | INT | Yes | false | N/A | NONE | - +-----------------+-------+--------+------+-------+---------+-------+ - ``` - -3. 创建一个以 k1, k2 分组,k3 列为 SUM 聚合的物化视图 - - ```sql - create materialized view k1_k2_sumk3 as - select k1, k2, sum(k3) from duplicate_table group by k1, k2; - ``` - - 物化视图的 schema 如下图,物化视图包含两列 k1, k2,sum(k3) 其中 k1, k2 为分组列,sum(k3) 为根据 k1, k2 分组后的 k3 列的求和值。 - - 由于物化视图没有声明排序列,且物化视图带聚合数据,系统默认补充分组列 k1, k2 为排序列。 - - ```text - +-----------------+-------+--------+------+-------+---------+-------+ - | IndexName | Field | Type | Null | Key | Default | Extra | - +-----------------+-------+--------+------+-------+---------+-------+ - | k1_k2_sumk3 | k1 | INT | Yes | true | N/A | | - | | k2 | INT | Yes | true | N/A | | - | | k3 | BIGINT | Yes | false | N/A | SUM | - +-----------------+-------+--------+------+-------+---------+-------+ - ``` - -4. 创建一个去除重复行的物化视图 - - ```sql - create materialized view deduplicate as - select k1, k2, k3, k4 from duplicate_table group by k1, k2, k3, k4; - ``` - - 物化视图 schema 如下图,物化视图包含 k1, k2, k3, k4列,且不存在重复行。 - - ```text - +-----------------+-------+--------+------+-------+---------+-------+ - | IndexName | Field | Type | Null | Key | Default | Extra | - +-----------------+-------+--------+------+-------+---------+-------+ - | deduplicate | k1 | INT | Yes | true | N/A | | - | | k2 | INT | Yes | true | N/A | | - | | k3 | BIGINT | Yes | true | N/A | | - | | k4 | BIGINT | Yes | true | N/A | | - +-----------------+-------+--------+------+-------+---------+-------+ - ``` - -5. 创建一个不声明排序列的非聚合型物化视图 - - all_type_table 的 schema 如下 - - ``` - +-------+--------------+------+-------+---------+-------+ - | Field | Type | Null | Key | Default | Extra | - +-------+--------------+------+-------+---------+-------+ - | k1 | TINYINT | Yes | true | N/A | | - | k2 | SMALLINT | Yes | true | N/A | | - | k3 | INT | Yes | true | N/A | | - | k4 | BIGINT | Yes | true | N/A | | - | k5 | DECIMAL(9,0) | Yes | true | N/A | | - | k6 | DOUBLE | Yes | false | N/A | NONE | - | k7 | VARCHAR(20) | Yes | false | N/A | NONE | - +-------+--------------+------+-------+---------+-------+ - ``` - - 物化视图包含 k3, k4, k5, k6, k7 列,且不声明排序列,则创建语句如下: - - ```sql - create materialized view mv_1 as - select k3, k4, k5, k6, k7 from all_type_table; - ``` - - 系统默认补充的排序列为 k3, k4, k5 三列。这三列类型的字节数之和为 4(INT) + 8(BIGINT) + 16(DECIMAL) = 28 < 36。所以补充的是这三列作为排序列。 物化视图的 schema 如下,可以看到其中 k3, k4, k5 列的 key 字段为 true,也就是排序列。k6, k7 列的 key 字段为 false,也就是非排序列。 - - ```sql - +----------------+-------+--------------+------+-------+---------+-------+ - | IndexName | Field | Type | Null | Key | Default | Extra | - +----------------+-------+--------------+------+-------+---------+-------+ - | mv_1 | k3 | INT | Yes | true | N/A | | - | | k4 | BIGINT | Yes | true | N/A | | - | | k5 | DECIMAL(9,0) | Yes | true | N/A | | - | | k6 | DOUBLE | Yes | false | N/A | NONE | - | | k7 | VARCHAR(20) | Yes | false | N/A | NONE | - +----------------+-------+--------------+------+-------+---------+-------+ - ``` - -### Keywords - - CREATE, MATERIALIZED, VIEW - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-POLICY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-POLICY.md deleted file mode 100644 index 6013a933e4794..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-POLICY.md +++ /dev/null @@ -1,125 +0,0 @@ ---- -{ - "title": "CREATE-POLICY", - "language": "zh-CN" -} ---- - - - -## CREATE-POLICY - -### Name - -CREATE POLICY - -## 描述 - -创建策略,包含以下几种: - -1. 创建安全策略 (ROW POLICY),explain 可以查看改写后的 SQL。 -2. 创建数据迁移策略 (STORAGE POLICY),用于冷热数据转换。 - -#### 语法: - -1. ROW POLICY -```sql -CREATE ROW POLICY test_row_policy_1 ON test.table1 -AS {RESTRICTIVE|PERMISSIVE} TO test USING (id in (1, 2)); -``` -参数说明: - -- filterType:RESTRICTIVE 将一组策略通过 AND 连接,PERMISSIVE 将一组策略通过 OR 连接 -- 配置多个策略首先合并 RESTRICTIVE 的策略,再添加 PERMISSIVE 的策略 -- RESTRICTIVE 和 PERMISSIVE 之间通过 AND 连接的 -- 不允许对 root 和 admin 用户创建 - -2. STORAGE POLICY -```sql -CREATE STORAGE POLICY test_storage_policy_1 -PROPERTIES ("key"="value", ...); -``` -参数说明: -- PROPERTIES 中需要指定资源的类型: - 1. storage_resource:指定策略使用的 storage resource 名称。 - 2. cooldown_datetime:热数据转为冷数据时间,不能与 cooldown_ttl 同时存在。 - 3. cooldown_ttl:热数据持续时间。从数据分片生成时开始计算,经过指定时间后转为冷数据。支持的格式: - 1d:1 天 - 1h:1 小时 - 50000: 50000 秒 - -## 举例 - -1. 创建一组行安全策略 - - ```sql - CREATE ROW POLICY test_row_policy_1 ON test.table1 - AS RESTRICTIVE TO test USING (c1 = 'a'); - ``` - ```sql - CREATE ROW POLICY test_row_policy_2 ON test.table1 - AS RESTRICTIVE TO test USING (c2 = 'b'); - ``` - ```sql - CREATE ROW POLICY test_row_policy_3 ON test.table1 - AS PERMISSIVE TO test USING (c3 = 'c'); - ``` - ```sql - CREATE ROW POLICY test_row_policy_3 ON test.table1 - AS PERMISSIVE TO test USING (c4 = 'd'); - ``` - - 当我们执行对 table1 的查询时被改写后的 sql 为 - - ```sql - select * from (select * from table1 where c1 = 'a' and c2 = 'b' or c3 = 'c' or c4 = 'd') - ``` -2. 创建数据迁移策略 - 1. 说明 - - 冷热分层创建策略,必须先创建 resource,然后创建迁移策略时候关联创建的 resource 名 - - 当前不支持删除 drop 数据迁移策略,防止数据被迁移后。策略被删除了,系统无法找回数据 - - 2. 指定数据冷却时间创建数据迁移策略 - ```sql - CREATE STORAGE POLICY testPolicy - PROPERTIES( - "storage_resource" = "s3", - "cooldown_datetime" = "2022-06-08 00:00:00" - ); - ``` - 3. 指定热数据持续时间创建数据迁移策略 - ```sql - CREATE STORAGE POLICY testPolicy - PROPERTIES( - "storage_resource" = "s3", - "cooldown_ttl" = "1d" - ); - ``` - 相关参数如下: - - `storage_resource`:创建的storage resource名称 - - `cooldown_datetime`:迁移数据的时间点 - - `cooldown_ttl`:迁移数据距离当前时间的倒计时,单位s。与cooldown_datetime二选一即可 - -### Keywords - - CREATE, POLICY - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-RESOURCE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-RESOURCE.md deleted file mode 100644 index 7f079e30c9926..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-RESOURCE.md +++ /dev/null @@ -1,248 +0,0 @@ ---- -{ - "title": "CREATE-RESOURCE", - "language": "zh-CN" -} ---- - - - -## CREATE-RESOURCE - -### Name - -CREATE RESOURCE - -## 描述 - -该语句用于创建资源。仅 root 或 admin 用户可以创建资源。目前支持 Spark, ODBC, S3, JDBC, HDFS, HMS, ES 外部资源。 -将来其他外部资源可能会加入到 Doris 中使用,如 Spark/GPU 用于查询,HDFS/S3 用于外部存储,MapReduce 用于 ETL 等。 - -语法: - -```sql -CREATE [EXTERNAL] RESOURCE "resource_name" -PROPERTIES ("key"="value", ...); -``` - -说明: - -- PROPERTIES 中需要指定资源的类型 "type" = "[spark|odbc_catalog|s3|jdbc|hdfs|hms|es]"。 -- 根据资源类型的不同 PROPERTIES 有所不同,具体见示例。 - -## 举例 - -1. 创建 yarn cluster 模式,名为 spark0 的 Spark 资源。 - - ```sql - CREATE EXTERNAL RESOURCE "spark0" - PROPERTIES - ( - "type" = "spark", - "spark.master" = "yarn", - "spark.submit.deployMode" = "cluster", - "spark.jars" = "xxx.jar,yyy.jar", - "spark.files" = "/tmp/aaa,/tmp/bbb", - "spark.executor.memory" = "1g", - "spark.yarn.queue" = "queue0", - "spark.hadoop.yarn.resourcemanager.address" = "127.0.0.1:9999", - "spark.hadoop.fs.defaultFS" = "hdfs://127.0.0.1:10000", - "working_dir" = "hdfs://127.0.0.1:10000/tmp/doris", - "broker" = "broker0", - "broker.username" = "user0", - "broker.password" = "password0" - ); - ``` - - Spark 相关参数如下: - - spark.master: 必填,目前支持 yarn,spark://host:port。 - - spark.submit.deployMode: Spark 程序的部署模式,必填,支持 cluster,client 两种。 - - spark.hadoop.yarn.resourcemanager.address: master 为 yarn 时必填。 - - spark.hadoop.fs.defaultFS: master 为 yarn 时必填。 - - 其他参数为可选,参考[这里](http://spark.apache.org/docs/latest/configuration.html) - - - -Spark 用于 ETL 时需要指定 working_dir 和 broker。说明如下: - -- working_dir: ETL 使用的目录。spark 作为 ETL 资源使用时必填。例如:hdfs://host:port/tmp/doris。 -- broker: broker 名字。spark 作为 ETL 资源使用时必填。需要使用`ALTER SYSTEM ADD BROKER` 命令提前完成配置。 -- broker.property_key: broker 读取 ETL 生成的中间文件时需要指定的认证信息等。 - -2. 创建 ODBC resource - - ```sql - CREATE EXTERNAL RESOURCE `oracle_odbc` - PROPERTIES ( - "type" = "odbc_catalog", - "host" = "192.168.0.1", - "port" = "8086", - "user" = "test", - "password" = "test", - "database" = "test", - "odbc_type" = "oracle", - "driver" = "Oracle 19 ODBC driver" - ); - ``` - - ODBC 的相关参数如下: - - hosts:外表数据库的 IP 地址 - - driver:ODBC 外表的 Driver 名,该名字需要和 be/conf/odbcinst.ini 中的 Driver 名一致。 - - odbc_type:外表数据库的类型,当前支持 oracle, mysql, postgresql - - user:外表数据库的用户名 - - password:对应用户的密码信息 - - charset: 数据库链接的编码信息 - - 另外还支持每个 ODBC Driver 实现自定义的参数,参见对应 ODBC Driver 的说明 - -3. 创建 S3 resource - - ```sql - CREATE RESOURCE "remote_s3" - PROPERTIES - ( - "type" = "s3", - "s3.endpoint" = "bj.s3.com", - "s3.region" = "bj", - "s3.access_key" = "bbb", - "s3.secret_key" = "aaaa", - -- the followings are optional - "s3.connection.maximum" = "50", - "s3.connection.request.timeout" = "3000", - "s3.connection.timeout" = "1000" - ); - ``` - - 如果 s3 reource 在[冷热分层](../../../../../docs/advanced/cold_hot_separation.md)中使用,需要添加额外的字段。 - ```sql - CREATE RESOURCE "remote_s3" - PROPERTIES - ( - "type" = "s3", - "s3.endpoint" = "bj.s3.com", - "s3.region" = "bj", - "s3.access_key" = "bbb", - "s3.secret_key" = "aaaa", - -- required by cooldown - "s3.root.path" = "/path/to/root", - "s3.bucket" = "test-bucket" - ); - ``` - - S3 相关参数如下: - - 必需参数 - - `s3.endpoint`:s3 endpoint - - `s3.region`:s3 region - - `s3.root.path`:s3 根目录 - - `s3.access_key`:s3 access key - - `s3.secret_key`:s3 secret key - - `s3.bucket`:s3 的桶名 - - 可选参数 - - `s3.connection.maximum`:s3 最大连接数量,默认为 50 - - `s3.connection.request.timeout`:s3 请求超时时间,单位毫秒,默认为 3000 - - `s3.connection.timeout`:s3 连接超时时间,单位毫秒,默认为 1000 - -4. 创建 JDBC resource - - ```sql - CREATE RESOURCE mysql_resource PROPERTIES ( - "type"="jdbc", - "user"="root", - "password"="123456", - "jdbc_url" = "jdbc:mysql://127.0.0.1:3316/doris_test?useSSL=false", - "driver_url" = "https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/jdbc_driver/mysql-connector-java-8.0.25.jar", - "driver_class" = "com.mysql.cj.jdbc.Driver" - ); - ``` - - JDBC 的相关参数如下: - - user:连接数据库使用的用户名 - - password:连接数据库使用的密码 - - jdbc_url: 连接到指定数据库的标识符 - - driver_url: jdbc 驱动包的 url - - driver_class: jdbc 驱动类 - -5. 创建 HDFS resource - - ```sql - CREATE RESOURCE hdfs_resource PROPERTIES ( - "type"="hdfs", - "hadoop.username"="user", - "dfs.nameservices" = "my_ha", - "dfs.ha.namenodes.my_ha" = "my_namenode1, my_namenode2", - "dfs.namenode.rpc-address.my_ha.my_namenode1" = "nn1_host:rpc_port", - "dfs.namenode.rpc-address.my_ha.my_namenode2" = "nn2_host:rpc_port", - "dfs.client.failover.proxy.provider.my_ha" = "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider" - ); - ``` - - HDFS 相关参数如下: - - fs.defaultFS: namenode 地址和端口 - - hadoop.username: hdfs 用户名 - - dfs.nameservices: name service 名称,与 hdfs-site.xml 保持一致 - - dfs.ha.namenodes.[nameservice ID]: namenode 的 id 列表,与 hdfs-site.xml 保持一致 - - dfs.namenode.rpc-address.[nameservice ID].[name node ID]: Name node 的 rpc 地址,数量与 namenode 数量相同,与 hdfs-site.xml 保持一致 - -6. 创建 HMS resource - - HMS resource 用于 [hms catalog](../../../../lakehouse/datalake-analytics/hive) - ```sql - CREATE RESOURCE hms_resource PROPERTIES ( - 'type'='hms', - 'hive.metastore.uris' = 'thrift://127.0.0.1:7004', - 'dfs.nameservices'='HANN', - 'dfs.ha.namenodes.HANN'='nn1,nn2', - 'dfs.namenode.rpc-address.HANN.nn1'='nn1_host:rpc_port', - 'dfs.namenode.rpc-address.HANN.nn2'='nn2_host:rpc_port', - 'dfs.client.failover.proxy.provider.HANN'='org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider' - ); - ``` - - HMS 的相关参数如下: - - hive.metastore.uris: hive metastore server 地址 - 可选参数: - - dfs.*: 如果 hive 数据存放在 hdfs,需要添加类似 HDFS resource 的参数,也可以将 hive-site.xml 拷贝到 fe/conf 目录下 - - s3.*: 如果 hive 数据存放在 s3,需要添加类似 S3 resource 的参数。如果连接 [阿里云 Data Lake Formation](https://www.aliyun.com/product/bigdata/dlf),可以将 hive-site.xml 拷贝到 fe/conf 目录下 - -7. 创建 ES resource - - ```sql - CREATE RESOURCE es_resource PROPERTIES ( - "type"="es", - "hosts"="http://127.0.0.1:29200", - "nodes_discovery"="false", - "enable_keyword_sniff"="true" - ); - ``` - - ES 的相关参数如下: - - hosts: ES 地址,可以是一个或多个,也可以是 ES 的负载均衡地址 - - user: ES 用户名 - - password: 对应用户的密码信息 - - enable_docvalue_scan: 是否开启通过 ES/Lucene 列式存储获取查询字段的值,默认为 true - - enable_keyword_sniff: 是否对 ES 中字符串分词类型 text.fields 进行探测,通过 keyword 进行查询 (默认为 true,设置为 false 会按照分词后的内容匹配) - - nodes_discovery: 是否开启 ES 节点发现,默认为 true,在网络隔离环境下设置为 false,只连接指定节点 - - http_ssl_enabled: ES 是否开启 https 访问模式,目前在 fe/be 实现方式为信任所有 - -### Keywords - - CREATE, RESOURCE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-SQL-BLOCK-RULE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-SQL-BLOCK-RULE.md deleted file mode 100644 index a314635af9452..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-SQL-BLOCK-RULE.md +++ /dev/null @@ -1,158 +0,0 @@ ---- -{ - "title": "CREATE-SQL-BLOCK-RULE", - "language": "zh-CN" -} ---- - - - -## CREATE-SQL-BLOCK-RULE - -### Name - -CREATE SQL BLOCK RULE - -## 描述 - -该语句创建 SQL 阻止规则,该功能可用于限制任何 sql 语句(包括 DDL 和 DML 语句)。 - -支持按用户配置 SQL 黑名单: - -- 通过正则匹配的方式拒绝指定 SQL -- 通过设置 partition_num, tablet_num, cardinality, 检查一个查询是否达到其中一个限制 - - partition_num, tablet_num, cardinality 可以一起设置,一旦一个查询达到其中一个限制,查询将会被拦截 - -语法: - -```sql -CREATE SQL_BLOCK_RULE rule_name -[PROPERTIES ("key"="value", ...)]; -``` - -参数说明: - -- sql:匹配规则 (基于正则匹配,特殊字符需要转译,如`select *`使用`select \\*`),可选,默认值为 "NULL", 最后不要带分号 -- sqlHash: sql hash 值,用于完全匹配,我们会在`fe.audit.log`打印这个值,可选,这个参数和 sql 只能二选一,默认值为 "NULL" -- partition_num: 一个扫描节点会扫描的最大 partition 数量,默认值为 0L -- tablet_num: 一个扫描节点会扫描的最大 tablet 数量,默认值为 0L -- cardinality: 一个扫描节点粗略的扫描行数,默认值为 0L -- global:是否全局 (所有用户) 生效,默认为 false -- enable:是否开启阻止规则,默认为 true - -## 举例 - -1. 创建一个名称为 test_rule 的阻止规则 - - ```sql - CREATE SQL_BLOCK_RULE test_rule - PROPERTIES( - "sql"="select \\* from order_analysis", - "global"="false", - "enable"="true" - ); - ``` - 当我们去执行刚才我们定义在规则里的 sql 时就会返回异常错误,示例如下: - - ```sql - mysql> select * from order_analysis; - ERROR 1064 (HY000): errCode = 2, detailMessage = sql match regex sql block rule: order_analysis_rule - ``` - -2. 创建 test_rule2,将最大扫描的分区数量限制在 30 个,最大扫描基数限制在 100 亿行,示例如下: - - ```sql - CREATE SQL_BLOCK_RULE test_rule2 - PROPERTIES - ( - "partition_num" = "30", - "cardinality" = "10000000000", - "global" = "false", - "enable" = "true" - ); - Query OK, 0 rows affected (0.01 sec) - ``` - -3. 创建包含特殊字符的 SQL BLOCK RULE,正则表达式中 ( 和 ) 符号是特殊符号,所以需要转义,示例如下: - - ```sql - CREATE SQL_BLOCK_RULE test_rule3 - PROPERTIES - ( - "sql" = "select count\\(1\\) from db1.tbl1" - ); - CREATE SQL_BLOCK_RULE test_rule4 - PROPERTIES - ( - "sql" = "select \\* from db1.tbl1" - ); - ``` - -4. SQL_BLCOK_RULE 中,SQL 的匹配是基于正则的,如果想匹配更多模式的 SQL 需要写相应的正则,比如忽略 SQL -中空格,还有 order_ 开头的表都不能查询,示例如下: - - ```sql - CREATE SQL_BLOCK_RULE test_rule4 - PROPERTIES( - "sql"="\\s*select\\s*\\*\\s*from order_\\w*\\s*", - "global"="false", - "enable"="true" - ); - ``` - -### 附录 -常用正则表达式如下: - -> . :匹配任何单个字符,除了换行符 `\n`。 -> -> * :匹配前面的元素零次或多次。例如,a* 匹配零个或多个 'a'。 -> -> + :匹配前面的元素一次或多次。例如,a+ 匹配一个或多个 'a'。 -> -> ? :匹配前面的元素零次或一次。例如,a? 匹配零个或一个 'a'。 -> -> [] :用于定义字符集合。例如,[aeiou] 匹配任何一个元音字母。 -> -> [^] :在字符集合中使用 ^ 表示否定,匹配不在集合内的字符。例如,[^0-9] 匹配任何非数字字符。 -> -> () :用于分组表达式,可以对其应用量词。例如,(ab)+ 匹配连续的 'ab'。 -> -> | :用于表示或逻辑。例如,a|b 匹配 'a' 或 'b'。 -> -> ^ :匹配字符串的开头。例如,^abc 匹配以 'abc' 开头的字符串。 -> -> $ :匹配字符串的结尾。例如,xyz$ 匹配以 'xyz' 结尾的字符串。 -> -> \ :用于转义特殊字符,使其变成普通字符。例如,\\. 匹配句点字符 '.'。 -> -> \s:匹配任何空白字符,包括空格、制表符、换行符等。 -> -> \d:匹配任何数字字符,相当于 [0-9]。 -> -> \w:匹配任何单词字符,包括字母、数字和下划线,相当于 [a-zA-Z0-9_]。 - -### Keywords - -```text -CREATE, SQL_BLCOK_RULE -``` - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-STORAGE-VAULT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-STORAGE-VAULT.md deleted file mode 100644 index da6eaaabc0e0d..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-STORAGE-VAULT.md +++ /dev/null @@ -1,176 +0,0 @@ ---- -{ - "title": "CREATE-STORAGE-VAULT", - "language": "zh-CN", - "toc_min_heading_level": 2, - "toc_max_heading_level": 4 -} ---- - - - -## CREATE-STORAGE-VAULT - -## 描述 - -该命令用于创建存储库。本文档的主题描述了创建 Doris 自管理存储库的语法。 - -```sql -CREATE STORAGE VAULT [IF NOT EXISTS] vault -[properties] -``` - -#### properties - -| 参数 | 是否必需 | 描述 | -|:-------|:-----|:-----------------------| -| `type` | 必需 | 只允许两种类型的存储库:S3 和 HDFS。 | - -##### S3 Vault - -| 参数 | 是否必需 | 描述 | -|:----------------|:-----|:--------------------------------------------------------------------------------------------------------| -| `s3.endpoint` | 必需 | 用于对象存储的端点。
注意,请不要提供带有 http:// 或 https:// 开头的链接。对于 Azure Blob 存储,链接应该像 ${ak}.blob.core.windows.net/。 | -| `s3.region` | 必需 | 您的存储桶的区域。(如果您使用 GCP 或 AZURE,则不需要)。 | -| `s3.root.path` | 必需 | 存储数据的路径。 | -| `s3.bucket` | 必需 | 您的对象存储账户的存储桶。(如果您使用 Azure,则为 StorageAccount)。 | -| `s3.access_key` | 必需 | 您的对象存储账户的访问密钥。(如果您使用 Azure,则为 AccountName)。 | -| `s3.secret_key` | 必需 | 您的对象存储账户的秘密密钥。(如果您使用 Azure,则为 AccountKey)。 | -| `provider` | 必需 | 提供对象存储服务的云供应商。支持的值有`COS`,`OSS`,`S3`,`OBS`,`BOS`,`AZURE`,`GCP` | -| `use_path_style` | 可选 | 使用 `path-style URL`(私有化部署环境)或者`virtual-hosted-style URL`(公有云环境建议), 默认值 `true` (path-style) | - -##### HDFS vault - -| 参数 | 是否必需 | 描述 | -|:---------------------------------|:-----|:------------------------------------------------------| -| `fs.defaultFS` |必需| Hadoop 配置属性,指定要使用的默认文件系统。 | -| `path_prefix` |可选| 存储数据的路径前缀。如果没有指定则会使用 user 账户下的默认路径。 | -| `hadoop.username` |可选| Hadoop 配置属性,指定访问文件系统的用户。如果没有指定则会使用启动 hadoop 进程的 user。 | -| `hadoop.security.authentication` |可选| 用于 hadoop 的认证方式。如果希望使用 kerberos 则可以填写`kerberos`。 | -| `hadoop.kerberos.principal` |可选| 您的 kerberos 主体的路径。 | -| `hadoop.kerberos.keytab` |可选| 您的 kerberos keytab 的路径。 | - -### 示例 - -1. 创建 HDFS storage vault。 - ```sql - CREATE STORAGE VAULT IF NOT EXISTS hdfs_vault - PROPERTIES ( - "type"="hdfs", - "fs.defaultFS"="hdfs://127.0.0.1:8020" - ); - ``` - -2. 创建微软 azure S3 storage vault。 - ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="ak.blob.core.windows.net/", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "AZURE" - ); - ``` - -3. 创建阿里云 OSS S3 storage vault。 - ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="oss.aliyuncs.com", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.region" = "cn-hangzhou", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "OSS", - "use_path_style" = "false" - ); - ``` - -4. 创建腾讯云 COS S3 storage vault。 - ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="cos.ap-guangzhou.myqcloud.com", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.region" = "ap-guangzhou", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "COS", - "use_path_style" = "false" - ); - ``` - -5. 创建华为云 OBS S3 storage vault。 - ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="obs.cn-north-4.myhuaweicloud.com", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.region" = "cn-north-4", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "OBS", - "use_path_style" = "false" - ); - ``` - -6. 创建亚马逊云 S3 storage vault。 - ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="s3.us-east-1.amazonaws.com", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.region" = "us-east-1", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "S3", - "use_path_style" = "false" - ); - ``` -7. 创建 MinIO S3 storage vault。 - ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="127.0.0.1:9000", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.region" = "us-east-1", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "S3", - "use_path_style" = "true" - ); - ``` - -### 关键词 - - CREATE, STORAGE VAULT diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-AND-GENERATED-COLUMN.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-AND-GENERATED-COLUMN.md deleted file mode 100644 index feb2e28968579..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-AND-GENERATED-COLUMN.md +++ /dev/null @@ -1,257 +0,0 @@ ---- -{ - "title": "CREATE-TABLE-AND-GENERATED-COLUMN", - "language": "zh-CN" -} ---- - - - -生成列是一种特殊的数据库表列,其值由其他列的值计算而来,而不是直接由用户插入或更新。该功能支持预先计算表达式的结果,并存储在数据库中,适用于需要频繁查询或进行复杂计算的场景。 - -生成列可以在数据导入或更新时自动根据预定义的表达式计算结果,并将这些结果持久化存储。这样,在后续的查询过程中,可以直接访问这些已经计算好的结果,而无需在查询时再进行复杂的计算,从而显著减少查询时的计算负担,提升查询性能。 - -下面是一个使用生成列的例子: - -```sql -CREATE TABLE products ( -product_id INT, -price DECIMAL(10,2), -quantity INT, -total_value DECIMAL(10,2) GENERATED ALWAYS AS (price * quantity) -) UNIQUE KEY(product_id) -DISTRIBUTED BY HASH(product_id) PROPERTIES ("replication_num" = "1"); - -INSERT INTO products VALUES(1, 10.00, 10, default); -INSERT INTO products(product_id, price, quantity) VALUES(1, 20.00, 10); -``` - -从表中查询数据: - -```sql -mysql> SELECT * FROM products; -+------------+-------+----------+-------------+ -| product_id | price | quantity | total_value | -+------------+-------+----------+-------------+ -| 1 | 10.00 | 10 | 100.00 | -| 1 | 20.00 | 10 | 200.00 | -+------------+-------+----------+-------------+ -``` - -在这个示例中, total_value 列是一个生成列,其值由 price 和 quantity 列的值相乘计算而来。 -生成列的值在导入或更新时计算并存储在表中。 -## 语法 - -```sql -col_name data_type [GENERATED ALWAYS] AS (expr) -[NOT NULL | NULL] [COMMENT 'string'] -``` - -## 生成列的限制 -1. 使用的函数只能是内置的标量函数和运算符,不允许使用udf,聚合函数等其它。 -2. 不允许使用变量,子查询,Lambda表达式。 -3. AUTO_INCREMENT列不能用作生成的列定义中的基列。 -4. 生成的列定义可以引用其他生成的列,但只能引用表定义中较早出现的列。 生成的列定义可以引用表中的任何基本(非生成)列,无论其定义发生得早还是晚。 -5. 聚合模型中,生成列是VALUE列时,仅允许使用REPLACE和REPLACE_IF_NOT_NULL聚合类型。 - -## 导入数据 -导入数据时,如果违反了生成列的NOT NULL限制,例如导入数据时,没有指定生成列引用的列,并且此列没有默认值,将导致导入失败。 -### INSERT -指定列时,指定的列不能包含生成列,否则将报错。 - -```sql -INSERT INTO products(product_id, price, quantity) VALUES(1, 20.00, 10); -``` - -没有指定列时,生成列需要使用DEFAULT关键字进行占位。 - -```sql -INSERT INTO products VALUES(1, 10.00, 10, default); -``` - -### Load -使用load方式进行数据导入时,需要显式指定导入列。不应当指定生成列为导入列,当指定导入生成列并在数据文件中有对应的数据时,生成列不会使用数据文件中的值,生成列的值仍然是根据表达式计算得到的结果。 -#### Stream Load -创建表: - -```sql -mysql> CREATE TABLE gen_col_stream_load(a INT,b INT,c DOUBLE GENERATED ALWAYS AS (abs(a+b)) not null) -DISTRIBUTED BY HASH(a) -PROPERTIES("replication_num" = "1"); -``` - -准备数据,并进行stream load: - -```shell -cat gen_col_data.csv -1,2 -3,5 -2,9 - -curl --location-trusted -u root: \ --H "Expect:100-continue" \ --H "column_separator:," \ --H "columns:a,b" \ --T gen_col_data.csv \ --XPUT http://127.0.0.1:8030/api/testdb/gen_col_stream_load/_stream_load -{ - "TxnId": 223227, - "Label": "d4a615c9-6e73-4d95-a8a4-e4c30d3b2262", - "Comment": "", - "TwoPhaseCommit": "false", - "Status": "Success", - "Message": "OK", - "NumberTotalRows": 3, - "NumberLoadedRows": 3, - "NumberFilteredRows": 0, - "NumberUnselectedRows": 0, - "LoadBytes": 12, - "LoadTimeMs": 152, - "BeginTxnTimeMs": 5, - "StreamLoadPutTimeMs": 39, - "ReadDataTimeMs": 0, - "WriteDataTimeMs": 66, - "CommitAndPublishTimeMs": 37 -} -``` - -查看数据导入结果: - -```sql -mysql> SELECT * FROM gen_col_stream_load; -+------+------+------+ -| a | b | c | -+------+------+------+ -| 1 | 2 | 3 | -| 2 | 9 | 11 | -| 3 | 5 | 8 | -+------+------+------+ -3 rows in set (0.07 sec) -``` - -#### HTTP Stream Load -创建表: - -```sql -mysql> CREATE TABLE gencol_refer_gencol_http_load(a INT,c DOUBLE GENERATED ALWAYS AS (abs(a+b)) NOT NULL,b INT, d INT GENERATED ALWAYS AS(c+1)) -DISTRIBUTED BY HASH(a) -PROPERTIES("replication_num" = "1"); -``` - -准备数据,并进行http stream load: - -```shell -curl --location-trusted -u root: -T gen_col_data.csv -H "Expect: 100-Continue" \ --H "sql:insert into testdb.gencol_refer_gencol_http_load(a, b) select * from http_stream(\"format\" = \"CSV\", \"column_separator\" = \",\" )" \ -http://127.0.0.1:8030/api/_http_stream -{ - "TxnId": 223244, - "Label": "label_824464cba2a1eabc_bee78e427ea55e81", - "Comment": "", - "TwoPhaseCommit": "false", - "Status": "Success", - "Message": "OK", - "NumberTotalRows": 3, - "NumberLoadedRows": 3, - "NumberFilteredRows": 0, - "NumberUnselectedRows": 0, - "LoadBytes": 12, - "LoadTimeMs": 142, - "BeginTxnTimeMs": 0, - "StreamLoadPutTimeMs": 45, - "ReadDataTimeMs": 46, - "WriteDataTimeMs": 59, - "CommitAndPublishTimeMs": 36 -} -``` - -查看数据导入结果: - -```sql -mysql> SELECT * FROM gencol_refer_gencol_http_load; +------+------+------+------+ -| a | c | b | d | -+------+------+------+------+ -| 2 | 11 | 9 | 12 | -| 1 | 3 | 2 | 4 | -| 3 | 8 | 5 | 9 | -+------+------+------+------+ -3 rows in set (0.04 sec) -``` - -#### MySQL Load -建表,加载数据和查询的过程如下: - -```sql -mysql> CREATE TABLE gen_col_mysql_load(a INT,b INT,c DOUBLE GENERATED ALWAYS AS (abs(a+b)) NOT NULL) -DISTRIBUTED BY HASH(a) -PROPERTIES("replication_num" = "1"); - -mysql> LOAD DATA LOCAL -INFILE '/path_to_data/gen_col_data.csv' -INTO TABLE gen_col_mysql_load -COLUMNS TERMINATED BY ',' -(a,b); -Query OK, 3 rows affected (0.14 sec) -Records: 3 Deleted: 0 Skipped: 0 Warnings: 0 - -mysql> SELECT * FROM gen_col_mysql_load; -+------+------+------+ -| a | b | c | -+------+------+------+ -| 2 | 9 | 11 | -| 3 | 5 | 8 | -| 1 | 2 | 3 | -+------+------+------+ -3 rows in set (0.06 sec) -``` - -#### 其它Load -BROKER LOAD, ROUTINE LOAD等方式都可以将数据导入有生成列的表,不再一一列举。 - -## 生成列与部分列更新 -在进行部分列更新时,必须在columns中指定生成列引用的所有普通列,否则会报错。 - -下面是一个示例, 建表和插入一行数据,并设置session变量: - -```sql -CREATE TABLE test_partial_column_unique_gen_col (a INT, b INT, c INT AS (a+b), d INT AS (c+1), e INT) -UNIQUE KEY(a) DISTRIBUTED BY HASH(a) PROPERTIES( - "enable_unique_key_merge_on_write" = "true", - "replication_num"="1" -); -SET enable_unique_key_partial_update=true; -SET enable_insert_strict=false; -SET enable_fallback_to_original_planner=false; -INSERT INTO test_partial_column_unique_gen_col(a,b,e) VALUES(1,2,7); -``` - -如果没有指定所有被引用的普通列会报错: - -```sql -mysql> INSERT INTO test_partial_column_unique_gen_col(a) VALUES(3); -ERROR 1105 (HY000): errCode = 2, detailMessage = Partial update should include all ordinary columns referenced by generated columns, missing: b -``` - -LOAD也是这样,-H "columns: a, b"中需要指定所有被引用的普通列,下面是使用stream load的示例: - -```shell -curl --location-trusted -u root: -H "Expect:100-continue" -H "column_separator:," \ --H "columns: a, b" -H "partial_columns:true" \ --T /Users/moailing/Documents/tmp/gen_col_data.csv \ -http://127.0.0.1:8030/api/testdb/partial_column_unique_gen_col/_stream_load -``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT.md deleted file mode 100644 index ca3b218503e2b..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -{ - "title": "CREATE-TABLE-AS-SELECT", - "language": "zh-CN" -} ---- - - - -## CREATE-TABLE-AS-SELECT - -### Name - -CREATE TABLE AS SELECT - -## 描述 - -该语句通过 Select 语句返回结果创建表结构,同时导入数据 - -语法: - -```sql -CREATE TABLE table_name [( column_name_list )] - opt_engine:engineName - opt_keys:keys - opt_comment:tableComment - opt_partition:partition - opt_distribution:distribution - opt_rollup:index - opt_properties:tblProperties - opt_ext_properties:extProperties - KW_AS query_stmt:query_def - ``` - -说明: - -- 用户需要拥有来源表的`SELECT`权限和目标库的`CREATE`权限 -- 创建表成功后,会进行数据导入,如果导入失败,将会删除表 -- 可以自行指定 key type,默认为`Duplicate Key` -- 所有字符串类型的列 (varchar/var/string) 都会被创建为 string 类型。 -- 如果创建的来源为外部表,并且第一列为 String 类型,则会自动将第一列设置为 VARCHAR(65533)。因为 Doris 内部表,不允许 String 列作为第一列。 - -## 举例 - -1. 使用 select 语句中的字段名 - - ```sql - create table `test`.`select_varchar` - PROPERTIES("replication_num" = "1") - as select * from `test`.`varchar_table` - ``` - -2. 自定义字段名 (需要与返回结果字段数量一致) - ```sql - create table `test`.`select_name`(user, testname, userstatus) - PROPERTIES("replication_num" = "1") - as select vt.userId, vt.username, jt.status - from `test`.`varchar_table` vt join - `test`.`join_table` jt on vt.userId=jt.userId - ``` - -3. 指定表模型、分区、分桶 - ```sql - CREATE TABLE t_user(dt, id, name) - ENGINE=OLAP - UNIQUE KEY(dt, id) - COMMENT "OLAP" - PARTITION BY RANGE(dt) - ( - FROM ("2020-01-01") TO ("2021-12-31") INTERVAL 1 YEAR - ) - DISTRIBUTED BY HASH(id) BUCKETS 1 - PROPERTIES("replication_num"="1") - AS SELECT cast('2020-05-20' as date) as dt, 1 as id, 'Tom' as name; - ``` - -### Keywords - - CREATE, TABLE, AS, SELECT - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-LIKE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-LIKE.md deleted file mode 100644 index cf205ebc0162e..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-LIKE.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -{ - "title": "CREATE-TABLE-LIKE", - "language": "zh-CN" -} ---- - - - -## CREATE-TABLE-LIKE - -### Name - -CREATE TABLE LIKE - -## 描述 - -该语句用于创建一个表结构和另一张表完全相同的空表,同时也能够可选复制一些rollup。 - -语法: - -```sql -CREATE [EXTERNAL] TABLE [IF NOT EXISTS] [database.]table_name LIKE [database.]table_name [WITH ROLLUP (r1,r2,r3,...)] -``` - -说明: - -- 复制的表结构包括Column Definition、Partitions、Table Properties等 -- 用户需要对复制的原表有`SELECT`权限 -- 支持复制MySQL等外表 -- 支持复制OLAP Table的rollup - -## 举例 - -1. 在test1库下创建一张表结构和table1相同的空表,表名为table2 - - ```sql - CREATE TABLE test1.table2 LIKE test1.table1 - ``` - -2. 在test2库下创建一张表结构和test1.table1相同的空表,表名为table2 - - ```sql - CREATE TABLE test2.table2 LIKE test1.table1 - ``` - -3. 在test1库下创建一张表结构和table1相同的空表,表名为table2,同时复制table1的r1,r2两个rollup - - ```sql - CREATE TABLE test1.table2 LIKE test1.table1 WITH ROLLUP (r1,r2) - ``` - -4. 在test1库下创建一张表结构和table1相同的空表,表名为table2,同时复制table1的所有rollup - - ```sql - CREATE TABLE test1.table2 LIKE test1.table1 WITH ROLLUP - ``` - -5. 在test2库下创建一张表结构和test1.table1相同的空表,表名为table2,同时复制table1的r1,r2两个rollup - - ```sql - CREATE TABLE test2.table2 LIKE test1.table1 WITH ROLLUP (r1,r2) - ``` - -6. 在test2库下创建一张表结构和test1.table1相同的空表,表名为table2,同时复制table1的所有rollup - - ```sql - CREATE TABLE test2.table2 LIKE test1.table1 WITH ROLLUP - ``` - -7. 在test1库下创建一张表结构和MySQL外表table1相同的空表,表名为table2 - - ```sql - CREATE TABLE test1.table2 LIKE test1.table1 - ``` - -### Keywords - - CREATE, TABLE, LIKE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE.md deleted file mode 100644 index 6cd55e087a62b..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE.md +++ /dev/null @@ -1,858 +0,0 @@ ---- -{ - "title": "CREATE-TABLE", - "language": "zh-CN", - "toc_min_heading_level": 2, - "toc_max_heading_level": 4 -} ---- - - - -## CREATE-TABLE - -## 描述 - -该命令用于创建一张表。本文档主要介绍创建 Doris 自维护的表的语法 - -```sql -CREATE TABLE [IF NOT EXISTS] [database.]table -( - column_definition_list - [, index_definition_list] -) -[engine_type] -[keys_type] -[table_comment] -[partition_info] -distribution_desc -[rollup_list] -[properties] -[extra_properties] -``` - -#### column_definition_list - -列定义列表: - -`column_definition[, column_definition]` -* `column_definition` - 列定义: - - `column_name column_type [KEY] [aggr_type] [NULL] [AUTO_INCREMENT(auto_inc_start_value)] [default_value] [on update current_timestamp] [column_comment]` - * `column_type` - 列类型,支持以下类型: - ``` - TINYINT(1 字节) - 范围:-2^7 + 1 ~ 2^7 - 1 - SMALLINT(2 字节) - 范围:-2^15 + 1 ~ 2^15 - 1 - INT(4 字节) - 范围:-2^31 + 1 ~ 2^31 - 1 - BIGINT(8 字节) - 范围:-2^63 + 1 ~ 2^63 - 1 - LARGEINT(16 字节) - 范围:-2^127 + 1 ~ 2^127 - 1 - FLOAT(4 字节) - 支持科学计数法 - DOUBLE(12 字节) - 支持科学计数法 - DECIMAL[(PRECISION, SCALE)] (16 字节) - 保证精度的小数类型。默认是 DECIMAL(9, 0) - PRECISION: 1 ~ 27 - SCALE: 0 ~ 9 - 其中整数部分为 1 ~ 18 - 不支持科学计数法 - DATE(3 字节) - 范围:0000-01-01 ~ 9999-12-31 - DATETIME(8 字节) - 范围:0000-01-01 00:00:00 ~ 9999-12-31 23:59:59 - CHAR[(length)] - 定长字符串。长度范围:1 ~ 255。默认为 1 - VARCHAR[(length)] - 变长字符串。长度范围:1 ~ 65533。默认为 65533 - HLL (1~16385 个字节) - HyperLogLog 列类型,不需要指定长度和默认值。长度根据数据的聚合程度系统内控制。 - 必须配合 HLL_UNION 聚合类型使用。 - BITMAP - bitmap 列类型,不需要指定长度和默认值。表示整型的集合,元素最大支持到 2^64 - 1。 - 必须配合 BITMAP_UNION 聚合类型使用。 - ``` - * `aggr_type` - 聚合类型,支持以下聚合类型: - ``` - SUM:求和。适用数值类型。 - MIN:求最小值。适合数值类型。 - MAX:求最大值。适合数值类型。 - REPLACE:替换。对于维度列相同的行,指标列会按照导入的先后顺序,后导入的替换先导入的。 - REPLACE_IF_NOT_NULL:非空值替换。和 REPLACE 的区别在于对于 NULL 值,不做替换。这里要注意的是字段默认值要给 NULL,而不能是空字符串,如果是空字符串,会给你替换成空字符串。 - HLL_UNION:HLL 类型的列的聚合方式,通过 HyperLogLog 算法聚合。 - BITMAP_UNION:BIMTAP 类型的列的聚合方式,进行位图的并集聚合。 - ``` - * `AUTO_INCREMENT(auto_inc_start_value)` - - 是否为自增列,自增列可以用来为新插入的行生成一个唯一标识。在插入表数据时如果没有指定自增列的值,则会自动生成一个合法的值。当自增列被显示地插入 NULL 时,其值也会被替换为生成的合法值。需要注意的是,处于性能考虑,BE 会在内存中缓存部分自增列的值,所以自增列自动生成的值只能保证单调性和唯一性,无法保证严格的连续性。 - 一张表中至多有一个列是自增列,自增列必须是 BIGINT 类型,且必须为 NOT NULL。 - Duplicate 模型表和 Unique 模型表均支持自增列。 - 可以通过给定`auto_inc_start_value`的方式指定自增列的起始值,如果不指定,则默认起始值为 1。 - - * `default_value` - 列默认值,当导入数据未指定该列的值时,系统将赋予该列 `default_value`。 - - 语法为`default default_value`。 - - 当前 `default_value` 支持两种形式: - 1. 用户指定固定值,如: - ```SQL - k1 INT DEFAULT '1', - k2 CHAR(10) DEFAULT 'aaaa' - ``` - 2. 系统提供的关键字,目前支持以下关键字: - - ```SQL - // 只用于 DATETIME 类型,导入数据缺失该值时系统将赋予当前时间 - dt DATETIME DEFAULT CURRENT_TIMESTAMP - // 只用于 DATE 类型,导入数据缺失该值时系统将赋予当前日期 - dt DATE DEFAULT CURRENT_DATE - ``` - * `on update current_timestamp` - - 是否在该行有列更新时将该列的值更新为当前时间 (`current_timestamp`)。该特性只能在开启了 Merge-on-Write 的 Unique 表上使用,开启了这个特性的列必须声明默认值,且默认值必须为`current_timestamp`。如果此处声明了时间戳的精度,则该列默认值中的时间戳精度必须与该处的时间戳精度相同。 - - - 示例: - - ```text - k1 TINYINT, - k2 DECIMAL(10,2) DEFAULT "10.5", - k4 BIGINT NULL DEFAULT "1000" COMMENT "This is column k4", - v1 VARCHAR(10) REPLACE NOT NULL, - v2 BITMAP BITMAP_UNION, - v3 HLL HLL_UNION, - v4 INT SUM NOT NULL DEFAULT "1" COMMENT "This is column v4" - dt datetime(6) default current_timestamp(6) on update current_timestamp(6) - ``` - -#### index_definition_list - -索引列表定义: - -`index_definition[, index_definition]` - -* `index_definition` - - 索引定义: - - ```sql - INDEX index_name (col_name) [USING INVERTED] COMMENT 'xxxxxx' - ``` - - 示例: - - ```sql - INDEX idx1 (k1) USING INVERTED COMMENT "This is a inverted index1", - INDEX idx2 (k2) USING INVERTED COMMENT "This is a inverted index2", - ... - ``` - -#### engine_type - -表引擎类型。本文档中类型皆为 OLAP。示例: - - `ENGINE=olap` - -#### keys_type - -数据模型。 - -`key_type(col1, col2, ...)` - -`key_type` 支持以下模型: - -* DUPLICATE KEY(默认):其后指定的列为排序列。 -* AGGREGATE KEY:其后指定的列为维度列。 -* UNIQUE KEY:其后指定的列为主键列。 - -:::info 备注 -注:当表属性`enable_duplicate_without_keys_by_default = true`时,默认创建没有排序列的 Duplicate 表。 -::: - -示例: - -``` -DUPLICATE KEY(col1, col2), -AGGREGATE KEY(k1, k2, k3), -UNIQUE KEY(k1, k2) -``` - -#### table_comment - -表注释。示例: - - ``` - COMMENT "This is my first DORIS table" - ``` - -#### partition_info - -分区信息,支持三种写法: - -1. LESS THAN:仅定义分区上界。下界由上一个分区的上界决定。 - - ``` - PARTITION BY RANGE(col1[, col2, ...]) - ( - PARTITION partition_name1 VALUES LESS THAN MAXVALUE|("value1", "value2", ...), - PARTITION partition_name2 VALUES LESS THAN MAXVALUE|("value1", "value2", ...) - ) - ``` - -2. FIXED RANGE:定义分区的左闭右开区间。 - - ``` - PARTITION BY RANGE(col1[, col2, ...]) - ( - PARTITION partition_name1 VALUES [("k1-lower1", "k2-lower1", "k3-lower1",...), ("k1-upper1", "k2-upper1", "k3-upper1", ...)), - PARTITION partition_name2 VALUES [("k1-lower1-2", "k2-lower1-2", ...), ("k1-upper1-2", MAXVALUE, )) - ) - ``` - -3. MULTI RANGE:批量创建 RANGE 分区,定义分区的左闭右开区间,设定时间单位和步长,时间单位支持年、月、日、周和小时。 - - ``` - PARTITION BY RANGE(col) - ( - FROM ("2000-11-14") TO ("2021-11-14") INTERVAL 1 YEAR, - FROM ("2021-11-14") TO ("2022-11-14") INTERVAL 1 MONTH, - FROM ("2022-11-14") TO ("2023-01-03") INTERVAL 1 WEEK, - FROM ("2023-01-03") TO ("2023-01-14") INTERVAL 1 DAY - ) - ``` - -4. MULTI RANGE:批量创建数字类型的 RANGE 分区,定义分区的左闭右开区间,设定步长。 - - ``` - PARTITION BY RANGE(int_col) - ( - FROM (1) TO (100) INTERVAL 10 - ) - ``` - - -#### distribution_desc - -定义数据分桶方式。 - -1. Hash 分桶 - 语法: - `DISTRIBUTED BY HASH (k1[,k2 ...]) [BUCKETS num|auto]` - 说明: - 使用指定的 Key 列进行哈希分桶。 -2. Random 分桶 - 语法: - `DISTRIBUTED BY RANDOM [BUCKETS num|auto]` - 说明: - 使用随机数进行分桶。 - -#### rollup_list - -建表的同时可以创建多个物化视图(ROLLUP)。 - -`ROLLUP (rollup_definition[, rollup_definition, ...])` - -* `rollup_definition` - - `rollup_name (col1[, col2, ...]) [DUPLICATE KEY(col1[, col2, ...])] [PROPERTIES("key" = "value")]` - - 示例: - - ``` - ROLLUP ( - r1 (k1, k3, v1, v2), - r2 (k1, v1) - ) - ``` - -#### properties - -设置表属性。目前支持以下属性: - -* `replication_num` - - 副本数。默认副本数为 3。如果 BE 节点数量小于 3,则需指定副本数小于等于 BE 节点数量。 - - 在 0.15 版本后,该属性将自动转换成 `replication_allocation` 属性,如: - - `"replication_num" = "3"` 会自动转换成 `"replication_allocation" = "tag.location.default:3"` - -* `replication_allocation` - - 根据 Tag 设置副本分布情况。该属性可以完全覆盖 `replication_num` 属性的功能。 - -* `min_load_replica_num` - - 设定数据导入成功所需的最小副本数,默认值为 -1。当该属性小于等于 0 时,表示导入数据仍需多数派副本成功。 - -* `is_being_synced` - - 用于标识此表是否是被 CCR 复制而来并且正在被 Syncer 同步,默认为 `false`。 - - 如果设置为 `true`: - `colocate_with`,`storage_policy`属性将被擦除 - `dynamic partition`,`auto bucket`功能将会失效,即在`show create table`中显示开启状态,但不会实际生效。当`is_being_synced`被设置为 `false` 时,这些功能将会恢复生效。 - - 这个属性仅供 CCR 外围模块使用,在 CCR 同步的过程中不要手动设置。 - -* `storage_medium/storage_cooldown_time` - - 数据存储介质。`storage_medium` 用于声明表数据的初始存储介质,而 `storage_cooldown_time` 用于设定到期时间。示例: - - ``` - "storage_medium" = "SSD", - "storage_cooldown_time" = "2020-11-20 00:00:00" - ``` - - 这个示例表示数据存放在 SSD 中,并且在 2020-11-20 00:00:00 到期后,会自动迁移到 HDD 存储上。 - -* `colocate_with` - - 当需要使用 Colocation Join 功能时,使用这个参数设置 Colocation Group。 - - `"colocate_with" = "group1"` - -* `bloom_filter_columns` - - 用户指定需要添加 Bloom Filter 索引的列名称列表。各个列的 Bloom Filter 索引是独立的,并不是组合索引。 - - `"bloom_filter_columns" = "k1, k2, k3"` - -* `in_memory` - - 已弃用。只支持设置为'false'。 - -* `compression` - - Doris 表的默认压缩方式是 LZ4。1.1 版本后,支持将压缩方式指定为 ZSTD 以获得更高的压缩比。 - - `"compression"="zstd"` - -* `function_column.Sequence_col` - - 当使用 Unique Key 模型时,可以指定一个 Sequence 列,当 Key 列相同时,将按照 Sequence 列进行 REPLACE(较大值替换较小值,否则无法替换) - - `function_column.sequence_col`用来指定 Sequence 列到表中某一列的映射,该列可以为整型和时间类型(DATE、DATETIME),创建后不能更改该列的类型。如果设置了`function_column.sequence_col`, `function_column.sequence_type`将被忽略。 - - `"function_column.sequence_col" = 'column_name'` - -* `function_column.sequence_type` - - 当使用 Unique Key 模型时,可以指定一个 Sequence 列,当 Key 列相同时,将按照 Sequence 列进行 REPLACE (较大值替换较小值,否则无法替换) - - 这里我们仅需指定顺序列的类型,支持时间类型或整型。Doris 会创建一个隐藏的顺序列。 - - `"function_column.sequence_type" = 'Date'` - -* `enable_unique_key_merge_on_write` - - Unique 表是否使用 Merge-on-Write 实现。 - - 该属性在 2.1 版本之前默认关闭,从 2.1 版本开始默认开启。 - -* `light_schema_change` - - 是否使用 Light Schema Change 优化。 - - 如果设置成 `true`, 对于值列的加减操作,可以更快地,同步地完成。 - - `"light_schema_change" = 'true'` - - 该功能在 2.0.0 及之后版本默认开启。 - -* `disable_auto_compaction` - - 是否对这个表禁用自动 Compaction。 - - 如果这个属性设置成 `true`, 后台的自动 Compaction 进程会跳过这个表的所有 Tablet。 - - `"disable_auto_compaction" = "false"` - -* `enable_single_replica_compaction` - - 是否对这个表开启单副本 compaction。 - - 如果这个属性设置成 `true`, 这个表的 tablet 的所有副本只有一个 do compaction,其他的从该副本拉取 rowset - - `"enable_single_replica_compaction" = "false"` - -* `enable_duplicate_without_keys_by_default` - - 当配置为`true`时,如果创建表的时候没有指定 Unique、Aggregate 或 Duplicate 模型,会默认创建一个没有排序列和前缀索引的 Duplicate 模型的表。 - - `"enable_duplicate_without_keys_by_default" = "false"` - -* `skip_write_index_on_load` - - 是否对这个表开启数据导入时不写索引。 - - 如果这个属性设置成 `true`, 数据导入的时候不写索引(目前仅对倒排索引生效),而是在 Compaction 的时候延迟写索引。这样可以避免首次写入和 Compaction - 重复写索引的 CPU 和 IO 资源消耗,提升高吞吐导入的性能。 - - `"skip_write_index_on_load" = "false"` - -* `compaction_policy` - - 配置这个表的 Compaction 的合并策略,仅支持配置为 time_series 或者 size_based - - time_series: 当 rowset 的磁盘体积积攒到一定大小时进行版本合并。合并后的 rowset 直接晋升到 base compaction 阶段。在时序场景持续导入的情况下有效降低 compact 的写入放大率 - - 此策略将使用 time_series_compaction 为前缀的参数调整 Compaction 的执行 - - `"compaction_policy" = ""` - -* `group_commit_interval_ms` - - 配置这个表的 Group Commit 攒批间隔。单位为 ms,默认值为 10000ms,即 10s。 - - Group Commit 的下刷时机取决于 `group_commit_interval_ms`以及`group_commit_data_bytes`哪个先到设置的值。 - - `"group_commit_interval_ms" = "10000"` - -* `group_commit_data_bytes` - - 配置这个表的 Group Commit 攒批数据大小。单位为 bytes,默认值为 134217728 bytes,即 128MB。 - - Group Commit 的下刷时机取决于 `group_commit_interval_ms`以及`group_commit_data_bytes` 哪个先到设置的值。 - - `"group_commit_data_bytes" = "134217728"` - -* `time_series_compaction_goal_size_mbytes` - - Compaction 的合并策略为 time_series 时,将使用此参数来调整每次 Compaction 输入的文件的大小,输出的文件大小和输入相当 - - `"time_series_compaction_goal_size_mbytes" = "1024"` - -* `time_series_compaction_file_count_threshold` - - compaction 的合并策略为 time_series 时,将使用此参数来调整每次 Compaction 输入的文件数量的最小值 - - 一个 tablet 中,文件数超过该配置,就会触发 compaction - - `"time_series_compaction_file_count_threshold" = "2000"` - -* `time_series_compaction_time_threshold_seconds` - - Compaction 的合并策略为 time_series 时,将使用此参数来调整 Compaction 的最长时间间隔,即长时间未执行过 Compaction 时,就会触发一次 Compaction,单位为秒 - - `"time_series_compaction_time_threshold_seconds" = "3600"` - -* `time_series_compaction_level_threshold` - - Compaction 的合并策略为 `time_series` 时,此参数默认为 1,当设置为 2 时用来控住对于合并过一次的段再合并一层,保证段大小达到 `time_series_compaction_goal_size_mbytes`, - - 能达到段数量减少的效果。 - - `"time_series_compaction_level_threshold" = "2"` - -* `enable_mow_light_delete` - - 是否在 Unique 表 Mow 上开启 Delete 语句写 Delete predicate。若开启,会提升 Delete 语句的性能,但 Delete 后进行部分列更新可能会出现部分数据错误的情况。若关闭,会降低 Delete 语句的性能来保证正确性。 - - 此属性的默认值为 `false`。 - - 此属性只能在 Unique Merge-on-Write 表上开启。 - - `"enable_mow_light_delete" = "true"` - -* 动态分区相关 - - 动态分区相关参考[数据划分 - 动态分区](../../../../table-design/data-partitioning/dynamic-partitioning) - -* `file_cache_ttl_seconds`: - - 存算分离模式下 TTL 类型 File Cache 的过期时间。 - -## 举例 - -1. 创建一个明细模型的表 - - ```sql - CREATE TABLE example_db.table_hash - ( - k1 TINYINT, - k2 DECIMAL(10, 2) DEFAULT "10.5", - k3 CHAR(10) COMMENT "string column", - k4 INT NOT NULL DEFAULT "1" COMMENT "int column" - ) - COMMENT "my first table" - DISTRIBUTED BY HASH(k1) BUCKETS 32 - ``` - -2. 创建一个明细模型的表,分区,指定排序列,设置副本数为 1 - - ```sql - CREATE TABLE example_db.table_hash - ( - k1 DATE, - k2 DECIMAL(10, 2) DEFAULT "10.5", - k3 CHAR(10) COMMENT "string column", - k4 INT NOT NULL DEFAULT "1" COMMENT "int column" - ) - DUPLICATE KEY(k1, k2) - COMMENT "my first table" - PARTITION BY RANGE(k1) - ( - PARTITION p1 VALUES LESS THAN ("2020-02-01"), - PARTITION p2 VALUES LESS THAN ("2020-03-01"), - PARTITION p3 VALUES LESS THAN ("2020-04-01") - ) - DISTRIBUTED BY HASH(k1) BUCKETS 32 - PROPERTIES ( - "replication_num" = "1" - ); - ``` - -3. 创建一个主键唯一模型的表,设置初始存储介质和冷却时间 - - ```sql - CREATE TABLE example_db.table_hash - ( - k1 BIGINT, - k2 LARGEINT, - v1 VARCHAR(2048), - v2 SMALLINT DEFAULT "10" - ) - UNIQUE KEY(k1, k2) - DISTRIBUTED BY HASH (k1, k2) BUCKETS 32 - PROPERTIES( - "storage_medium" = "SSD", - "storage_cooldown_time" = "2015-06-04 00:00:00" - ); - ``` - -4. 创建一个聚合模型表,使用固定范围分区描述 - - ```sql - CREATE TABLE table_range - ( - k1 DATE, - k2 INT, - k3 SMALLINT, - v1 VARCHAR(2048) REPLACE, - v2 INT SUM DEFAULT "1" - ) - AGGREGATE KEY(k1, k2, k3) - PARTITION BY RANGE (k1, k2, k3) - ( - PARTITION p1 VALUES [("2014-01-01", "10", "200"), ("2014-01-01", "20", "300")), - PARTITION p2 VALUES [("2014-06-01", "100", "200"), ("2014-07-01", "100", "300")) - ) - DISTRIBUTED BY HASH(k2) BUCKETS 32 - ``` - -5. 创建一个包含 HLL 和 BITMAP 列类型的聚合模型表 - - ```sql - CREATE TABLE example_db.example_table - ( - k1 TINYINT, - k2 DECIMAL(10, 2) DEFAULT "10.5", - v1 HLL HLL_UNION, - v2 BITMAP BITMAP_UNION - ) - ENGINE=olap - AGGREGATE KEY(k1, k2) - DISTRIBUTED BY HASH(k1) BUCKETS 32 - ``` - -6. 创建两张同一个 Colocation Group 自维护的表。 - - ```sql - CREATE TABLE t1 ( - id int(11) COMMENT "", - value varchar(8) COMMENT "" - ) - DUPLICATE KEY(id) - DISTRIBUTED BY HASH(id) BUCKETS 10 - PROPERTIES ( - "colocate_with" = "group1" - ); - - CREATE TABLE t2 ( - id int(11) COMMENT "", - value1 varchar(8) COMMENT "", - value2 varchar(8) COMMENT "" - ) - DUPLICATE KEY(`id`) - DISTRIBUTED BY HASH(`id`) BUCKETS 10 - PROPERTIES ( - "colocate_with" = "group1" - ); - ``` - -7. 创建一个带有倒排索引以及 bloom filter 索引的表 - - ```sql - CREATE TABLE example_db.table_hash - ( - k1 TINYINT, - k2 DECIMAL(10, 2) DEFAULT "10.5", - v1 CHAR(10) REPLACE, - v2 INT SUM, - INDEX k1_idx (k1) USING INVERTED COMMENT 'my first index' - ) - AGGREGATE KEY(k1, k2) - DISTRIBUTED BY HASH(k1) BUCKETS 32 - PROPERTIES ( - "bloom_filter_columns" = "k2" - ); - ``` - -8. 创建一个动态分区表。 - - 该表每天提前创建 3 天的分区,并删除 3 天前的分区。例如今天为`2020-01-08`,则会创建分区名为`p20200108`, `p20200109`, `p20200110`, `p20200111`的分区。分区范围分别为: - - ``` - [types: [DATE]; keys: [2020-01-08]; ‥types: [DATE]; keys: [2020-01-09]; ) - [types: [DATE]; keys: [2020-01-09]; ‥types: [DATE]; keys: [2020-01-10]; ) - [types: [DATE]; keys: [2020-01-10]; ‥types: [DATE]; keys: [2020-01-11]; ) - [types: [DATE]; keys: [2020-01-11]; ‥types: [DATE]; keys: [2020-01-12]; ) - ``` - - ```sql - CREATE TABLE example_db.dynamic_partition - ( - k1 DATE, - k2 INT, - k3 SMALLINT, - v1 VARCHAR(2048), - v2 DATETIME DEFAULT "2014-02-04 15:36:00" - ) - DUPLICATE KEY(k1, k2, k3) - PARTITION BY RANGE (k1) () - DISTRIBUTED BY HASH(k2) BUCKETS 32 - PROPERTIES( - "dynamic_partition.time_unit" = "DAY", - "dynamic_partition.start" = "-3", - "dynamic_partition.end" = "3", - "dynamic_partition.prefix" = "p", - "dynamic_partition.buckets" = "32" - ); - ``` - -9. 创建一个带有物化视图(ROLLUP)的表。 - - ```sql - CREATE TABLE example_db.rolup_index_table - ( - event_day DATE, - siteid INT DEFAULT '10', - citycode SMALLINT, - username VARCHAR(32) DEFAULT '', - pv BIGINT SUM DEFAULT '0' - ) - AGGREGATE KEY(event_day, siteid, citycode, username) - DISTRIBUTED BY HASH(siteid) BUCKETS 10 - ROLLUP ( - r1(event_day,siteid), - r2(event_day,citycode), - r3(event_day) - ) - PROPERTIES("replication_num" = "3"); - ``` - -10. 通过 `replication_allocation` 属性设置表的副本。 - - ```sql - CREATE TABLE example_db.table_hash - ( - k1 TINYINT, - k2 DECIMAL(10, 2) DEFAULT "10.5" - ) - DISTRIBUTED BY HASH(k1) BUCKETS 32 - PROPERTIES ( - "replication_allocation"="tag.location.group_a:1, tag.location.group_b:2" - ); - ``` - ```sql - CREATE TABLE example_db.dynamic_partition - ( - k1 DATE, - k2 INT, - k3 SMALLINT, - v1 VARCHAR(2048), - v2 DATETIME DEFAULT "2014-02-04 15:36:00" - ) - PARTITION BY RANGE (k1) () - DISTRIBUTED BY HASH(k2) BUCKETS 32 - PROPERTIES( - "dynamic_partition.time_unit" = "DAY", - "dynamic_partition.start" = "-3", - "dynamic_partition.end" = "3", - "dynamic_partition.prefix" = "p", - "dynamic_partition.buckets" = "32", - "dynamic_partition.replication_allocation" = "tag.location.group_a:3" - ); - ``` - -11. 通过`storage_policy`属性设置表的冷热分层数据迁移策略 - ```sql - CREATE TABLE IF NOT EXISTS create_table_use_created_policy - ( - k1 BIGINT, - k2 LARGEINT, - v1 VARCHAR(2048) - ) - UNIQUE KEY(k1) - DISTRIBUTED BY HASH (k1) BUCKETS 3 - PROPERTIES( - "storage_policy" = "test_create_table_use_policy", - "replication_num" = "1" - ); - ``` -注:需要先创建 S3 Resource 和 Storage Policy,表才能关联迁移策略成功 - -12. 为表的分区添加冷热分层数据迁移策略 - ```sql - CREATE TABLE create_table_partion_use_created_policy - ( - k1 DATE, - k2 INT, - V1 VARCHAR(2048) REPLACE - ) PARTITION BY RANGE (k1) ( - PARTITION p1 VALUES LESS THAN ("2022-01-01") ("storage_policy" = "test_create_table_partition_use_policy_1" ,"replication_num"="1"), - PARTITION p2 VALUES LESS THAN ("2022-02-01") ("storage_policy" = "test_create_table_partition_use_policy_2" ,"replication_num"="1") - ) DISTRIBUTED BY HASH(k2) BUCKETS 1; - ``` -注:需要先创建 S3 Resource 和 Storage Policy,表才能关联迁移策略成功 - -1. 批量创建分区 - ```sql - CREATE TABLE create_table_multi_partion_date - ( - k1 DATE, - k2 INT, - V1 VARCHAR(20) - ) PARTITION BY RANGE (k1) ( - FROM ("2000-11-14") TO ("2021-11-14") INTERVAL 1 YEAR, - FROM ("2021-11-14") TO ("2022-11-14") INTERVAL 1 MONTH, - FROM ("2022-11-14") TO ("2023-01-03") INTERVAL 1 WEEK, - FROM ("2023-01-03") TO ("2023-01-14") INTERVAL 1 DAY, - PARTITION p_20230114 VALUES [('2023-01-14'), ('2023-01-15')) - ) DISTRIBUTED BY HASH(k2) BUCKETS 1 - PROPERTIES( - "replication_num" = "1" - ); - ``` - ```sql - CREATE TABLE create_table_multi_partion_date_hour - ( - k1 DATETIME, - k2 INT, - V1 VARCHAR(20) - ) PARTITION BY RANGE (k1) ( - FROM ("2023-01-03 12") TO ("2023-01-14 22") INTERVAL 1 HOUR - ) DISTRIBUTED BY HASH(k2) BUCKETS 1 - PROPERTIES( - "replication_num" = "1" - ); - ``` - ```sql - CREATE TABLE create_table_multi_partion_integer - ( - k1 BIGINT, - k2 INT, - V1 VARCHAR(20) - ) PARTITION BY RANGE (k1) ( - FROM (1) TO (100) INTERVAL 10 - ) DISTRIBUTED BY HASH(k2) BUCKETS 1 - PROPERTIES( - "replication_num" = "1" - ); - ``` -:::info 备注 -注:批量创建分区可以和常规手动创建分区混用,使用时需要限制分区列只能有一个,批量创建分区实际创建默认最大数量为 4096,这个参数可以在 FE 配置项 `max_multi_partition_num` 调整。 -::: - -1. 批量无排序列 Duplicate 表 - - ```sql - CREATE TABLE example_db.table_hash - ( - k1 DATE, - k2 DECIMAL(10, 2) DEFAULT "10.5", - k3 CHAR(10) COMMENT "string column", - k4 INT NOT NULL DEFAULT "1" COMMENT "int column" - ) - COMMENT "duplicate without keys" - PARTITION BY RANGE(k1) - ( - PARTITION p1 VALUES LESS THAN ("2020-02-01"), - PARTITION p2 VALUES LESS THAN ("2020-03-01"), - PARTITION p3 VALUES LESS THAN ("2020-04-01") - ) - DISTRIBUTED BY HASH(k1) BUCKETS 32 - PROPERTIES ( - "replication_num" = "1", - "enable_duplicate_without_keys_by_default" = "true" - ); - ``` - -### Keywords - - CREATE, TABLE - -### Best Practice - - -#### 分区和分桶 - -一个表必须指定分桶列,但可以不指定分区。关于分区和分桶的具体介绍,可参阅 [数据划分](../../../../table-design/data-partitioning/basic-concepts) 文档。 - -Doris 中的表可以分为分区表和无分区的表。这个属性在建表时确定,之后不可更改。即对于分区表,可以在之后的使用过程中对分区进行增删操作,而对于无分区的表,之后不能再进行增加分区等操作。 - -同时,分区列和分桶列在表创建之后不可更改,既不能更改分区和分桶列的类型,也不能对这些列进行任何增删操作。 - -所以建议在建表前,先确认使用方式来进行合理的建表。 - -#### 动态分区 - -动态分区功能主要用于帮助用户自动的管理分区。通过设定一定的规则,Doris 系统定期增加新的分区或删除历史分区。可参阅 [动态分区](../../../../table-design/data-partitioning/dynamic-partitioning) 文档查看更多帮助。 - -#### 自动分区 - -自动分区功能文档参见 [自动分区](../../../../table-design/data-partitioning/auto-partitioning)。 - -#### 物化视图 - -用户可以在建表的同时创建多个物化视图(ROLLUP)。物化视图也可以在建表之后添加。写在建表语句中可以方便用户一次性创建所有物化视图。 - -如果在建表时创建好物化视图,则后续的所有数据导入操作都会同步生成物化视图的数据。物化视图的数量可能会影响数据导入的效率。 - -如果在之后的使用过程中添加物化视图,如果表中已有数据,则物化视图的创建时间取决于当前数据量大小。 - -关于物化视图的介绍,请参阅文档 [同步物化视图](../../../../query/view-materialized-view/materialized-view)。 - - -#### 索引 - -用户可以在建表的同时创建多个列的索引。索引也可以在建表之后再添加。 - -如果在之后的使用过程中添加索引,如果表中已有数据,则需要重写所有数据,因此索引的创建时间取决于当前数据量。 - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-VIEW.md deleted file mode 100644 index 2a63c6ab901d6..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-VIEW.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -{ - "title": "CREATE-VIEW", - "language": "zh-CN" -} ---- - - - -## CREATE-VIEW - -### Name - -CREATE VIEW - -## 描述 - -该语句用于创建一个逻辑视图 -语法: - -```sql -CREATE VIEW [IF NOT EXISTS] - [db_name.]view_name - (column1[ COMMENT "col comment"][, column2, ...]) -AS query_stmt -``` - - -说明: - -- 视图为逻辑视图,没有物理存储。所有在视图上的查询相当于在视图对应的子查询上进行。 -- query_stmt 为任意支持的 SQL - -## 举例 - -1. 在 example_db 上创建视图 example_view - - ```sql - CREATE VIEW example_db.example_view (k1, k2, k3, v1) - AS - SELECT c1 as k1, k2, k3, SUM(v1) FROM example_table - WHERE k1 = 20160112 GROUP BY k1,k2,k3; - ``` - -2. 创建一个包含 comment 的 view - - ```sql - CREATE VIEW example_db.example_view - ( - k1 COMMENT "first key", - k2 COMMENT "second key", - k3 COMMENT "third key", - v1 COMMENT "first value" - ) - COMMENT "my first view" - AS - SELECT c1 as k1, k2, k3, SUM(v1) FROM example_table - WHERE k1 = 20160112 GROUP BY k1,k2,k3; - ``` - -### Keywords - - CREATE, VIEW - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-WORKLOAD-GROUP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-WORKLOAD-GROUP.md deleted file mode 100644 index 62f85804c6fa4..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-WORKLOAD-GROUP.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -{ - "title": "CREATE-WORKLOAD-GROUP", - "language": "zh-CN" -} ---- - - - -## CREATE-WORKLOAD-GROUP - -### Name - -CREATE WORKLOAD GROUP - -## 描述 - -该语句用于创建资源组。资源组可实现单个 be 上 cpu 资源和内存资源的隔离。 - -语法: - -```sql -CREATE WORKLOAD GROUP [IF NOT EXISTS] "rg_name" -PROPERTIES ( - property_list -); -``` - -说明: - -property_list 支持的属性: - -* cpu_share: 必选,用于设置资源组获取 cpu 时间的多少,可以实现 cpu 资源软隔离。cpu_share 是相对值,表示正在运行的资源组可获取 cpu 资源的权重。例如,用户创建了 3 个资源组 rg-a、rg-b 和 rg-c,cpu_share 分别为 10、30、40,某一时刻 rg-a 和 rg-b 正在跑任务,而 rg-c 没有任务,此时 rg-a 可获得 (10 / (10 + 30)) = 25% 的 cpu 资源,而资源组 rg-b 可获得 75% 的 cpu 资源。如果系统只有一个资源组正在运行,则不管其 cpu_share 的值为多少,它都可以获取全部的 cpu 资源。 - -* memory_limit: 必选,用于设置资源组可以使用 be 内存的百分比。资源组内存限制的绝对值为:`物理内存 * mem_limit * memory_limit`,其中 mem_limit 为 be 配置项。系统所有资源组的 memory_limit 总合不可超过 100%。资源组在绝大多数情况下保证组内任务可使用 memory_limit 的内存,当资源组内存使用超出该限制后,组内内存占用较大的任务可能会被 cancel 以释放超出的内存,参考 enable_memory_overcommit。 - -* enable_memory_overcommit: 可选,用于开启资源组内存软隔离,默认为 false。如果设置为 false,则该资源组为内存硬隔离,系统检测到资源组内存使用超出限制后将立即 cancel 组内内存占用最大的若干个任务,以释放超出的内存;如果设置为 true,则该资源组为内存软隔离,如果系统有空闲内存资源则该资源组在超出 memory_limit 的限制后可继续使用系统内存,在系统总内存紧张时会 cancel 组内内存占用最大的若干个任务,释放部分超出的内存以缓解系统内存压力。建议在有资源组开启该配置时,所有资源组的 memory_limit 总和低于 100%,剩余部分用于资源组内存超发。 - -## 举例 - -1. 创建名为 g1 的资源组: - - ```sql - create workload group if not exists g1 - properties ( - "cpu_share"="10", - "memory_limit"="30%", - "enable_memory_overcommit"="true" - ); - ``` - -### Keywords - - CREATE, WORKLOAD, GROUP - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-ASYNC-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-ASYNC-MATERIALIZED-VIEW.md deleted file mode 100644 index 74d81f0fb2745..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-ASYNC-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -{ - "title": "DROP-ASYNC-MATERIALIZED-VIEW", - "language": "zh-CN" -} ---- - - - -## DROP-ASYNC-MATERIALIZED-VIEW - -### Name - -DROP ASYNC MATERIALIZED VIEW - -## 描述 - -该语句用于删除异步物化视图。 - -语法: - -```sql -DROP MATERIALIZED VIEW (IF EXISTS)? mvName=multipartIdentifier -``` - - -1. IF EXISTS: - 如果物化视图不存在,不要抛出错误。如果不声明此关键字,物化视图不存在则报错。 - -2. mv_name: - 待删除的物化视图的名称。必填项。 - -## 举例 - -1. 删除表物化视图mv1 - -```sql -DROP MATERIALIZED VIEW mv1; -``` -2.如果存在,删除指定 database 的物化视图 - -```sql -DROP MATERIALIZED VIEW IF EXISTS db1.mv1; -``` - -### Keywords - - DROP, ASYNC, MATERIALIZED, VIEW - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-CATALOG-RECYCLE-BIN.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-CATALOG-RECYCLE-BIN.md deleted file mode 100644 index 8836cf2a9de1b..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-CATALOG-RECYCLE-BIN.md +++ /dev/null @@ -1,90 +0,0 @@ ---- -{ - "title": "DROP-CATALOG-RECYCLE-BIN", - "language": "zh-CN" -} ---- - - - -## DROP-CATALOG-RECYCLE-BIN - -### Name - -DROP CATALOG RECYCLE BIN - -## 描述 - -该语句用于立即删除回收站中的数据库、表 或者 分区。 - -可以通过 `SHOW CATALOG RECYCLE BIN` 来查询当前可删除的元信息。 - -语法: - -1. 根据 DbId 删除数据库 - - ```sql - DROP CATALOG RECYCLE BIN WHERE 'DbId' = db_id; - ``` - -2. 根据 TableId 删除表 - - ```sql - DROP CATALOG RECYCLE BIN WHERE 'TableId' = table_id; - ``` - -3. 根据 PartitionId 删除分区 - - ```sql - DROP CATALOG RECYCLE BIN WHERE 'PartitionId' = partition_id; - ``` - -说明: - -- 当删除数据库、表或者分区时,回收站会在 `catalog_trash_expire_second`秒后将其删除(在 `fe.conf` 中设置)。此语句将立即删除它们。 -- `'DbId'`、 `'TableId'` 和 `'PartitionId'` 大小写不敏感且不区分单引号和双引号。 -- 当删除不在回收站中的数据库时,也会删除回收站中具有相同 `DbId` 的所有表和分区。只有在没有删除任何内容(数据库、表或分区)的情况下,它才会报错。当删除不在回收站中的表时,处理方法类似。 - -## 举例 - -1. 删除 DbId 为 example_db_id 的数据库、表和分区 - - ```sql - DROP CATALOG RECYCLE BIN WHERE 'DbId' = example_db_id; - ``` - -2. 删除 TableId 为 example_tbl_id 的表和分区 - - ```sql - DROP CATALOG RECYCLE BIN WHERE 'TableId' = example_tbl_id; - ``` - -3. 删除 id 为 p1_id 的分区 - - ```sql - DROP CATALOG RECYCLE BIN WHERE 'PartitionId' = p1_id; - ``` - -### Keywords - -DROP, CATALOG, RECYCLE, BIN - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-CATALOG.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-CATALOG.md deleted file mode 100644 index 34bb5d9939bf4..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-CATALOG.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "DROP-CATALOG", - "language": "zh-CN" -} ---- - - - -## DROP-CATALOG - -### Name - -CREATE CATALOG - -## 描述 - -该语句用于删除外部数据目录(catalog) - -语法: - -```sql -DROP CATALOG [IF EXISTS] catalog_name; -``` - -## 举例 - -1. 删除数据目录 hive - - ```sql - DROP CATALOG hive; - ``` - -### Keywords - -DROP, CATALOG - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-DATABASE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-DATABASE.md deleted file mode 100644 index 49a4e570920b5..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-DATABASE.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -{ - "title": "DROP-DATABASE", - "language": "zh-CN" -} ---- - - - -## DROP-DATABASE - -### Name - -DOPR DATABASE - -## 描述 - -该语句用于删除数据库(database) -语法: - -```sql -DROP DATABASE [IF EXISTS] db_name [FORCE]; -``` - -说明: - -- 执行 DROP DATABASE 一段时间内,可以通过 RECOVER 语句恢复被删除的数据库。详见 [RECOVER](../../Database-Administration-Statements/RECOVER.md) 语句 -- 如果执行 DROP DATABASE FORCE,则系统不会检查该数据库是否存在未完成的事务,数据库将直接被删除并且不能被恢复,一般不建议执行此操作 - -## 举例 - -1. 删除数据库 db_test - - ```sql - DROP DATABASE db_test; - ``` - - -### Keywords - - DROP, DATABASE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-ENCRYPT-KEY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-ENCRYPT-KEY.md deleted file mode 100644 index b6f11a214a0f4..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-ENCRYPT-KEY.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -{ - "title": "DROP-ENCRYPT-KEY", - "language": "zh-CN" -} ---- - - - -## DROP-ENCRYPTKEY - -### Name - -DROP ENCRYPTKEY - -## 描述 - -语法: - -```sql -DROP ENCRYPTKEY key_name -``` - -参数说明: - -- `key_name`: 要删除密钥的名字, 可以包含数据库的名字。比如:`db1.my_key`。 - -删除一个自定义密钥。密钥的名字完全一致才能够被删除。 - -执行此命令需要用户拥有 `ADMIN` 权限。 - -## 举例 - -1. 删除掉一个密钥 - - ```sql - DROP ENCRYPTKEY my_key; - ``` - -### Keywords - - DROP, ENCRYPT, KEY - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-FILE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-FILE.md deleted file mode 100644 index ccdf90f3b663b..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-FILE.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -{ - "title": "DROP-FILE", - "language": "zh-CN" -} ---- - - - -## DROP-FILE - -### Name - -DROP FILE - -## 描述 - -该语句用于删除一个已上传的文件。 - -语法: - -```sql -DROP FILE "file_name" [FROM database] -[properties] -``` - -说明: - -- file_name: 文件名。 -- database: 文件归属的某一个 db,如果没有指定,则使用当前 session 的 db。 -- properties 支持以下参数: - - `catalog`: 必须。文件所属分类。 - -## 举例 - -1. 删除文件 ca.pem - - ```sql - DROP FILE "ca.pem" properties("catalog" = "kafka"); - ``` - -### Keywords - - DROP, FILE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-FUNCTION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-FUNCTION.md deleted file mode 100644 index a071aff773bfa..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-FUNCTION.md +++ /dev/null @@ -1,67 +0,0 @@ ---- -{ - "title": "DROP-FUNCTION", - "language": "zh-CN" -} ---- - - - -## DROP-FUNCTION - -### Name - -DROP FUNCTION - -## 描述 - -删除一个自定义函数。函数的名字、参数类型完全一致才能够被删除 - -语法: - -```sql -DROP [GLOBAL] FUNCTION function_name - (arg_type [, ...]) -``` - -参数说明: - -- `function_name`: 要删除函数的名字 -- `arg_type`: 要删除函数的参数列表 - -## 举例 - -1. 删除掉一个函数 - - ```sql - DROP FUNCTION my_add(INT, INT) - ``` -2. 删除掉一个全局函数 - - ```sql - DROP GLOBAL FUNCTION my_add(INT, INT) - ``` - -### Keywords - - DROP, FUNCTION - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-INDEX.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-INDEX.md deleted file mode 100644 index 60cfa16d4440c..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-INDEX.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -{ - "title": "DROP-INDEX", - "language": "zh-CN" -} ---- - - - -## DROP-INDEX - -### Name - -DROP INDEX - -## 描述 - -该语句用于从一个表中删除指定名称的索引,目前仅支持bitmap 索引 -语法: - -```sql -DROP INDEX [IF EXISTS] index_name ON [db_name.]table_name; -``` - -## 举例 - -1. 删除索引 - - ```sql - DROP INDEX [IF NOT EXISTS] index_name ON table1 ; - ``` - -### Keywords - - DROP, INDEX - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-JOB.md deleted file mode 100644 index 5a16df709eb38..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-JOB.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -{ -"title": "DROP-JOB", -"language": "zh-CN" -} ---- - - - -## DROP-JOB - -### Name - -DROP JOB - -## 描述 - -用户删除一个 JOB 作业。作业会被立即停止同时删除。 - -```sql -DROP JOB where jobName='jobname'; -``` - -## 举例 - -1. 停止名称为 example 的作业。 - - ```sql - DROP JOB where jobName='example'; - ``` - -### Keywords - - STOP, JOB - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-MATERIALIZED-VIEW.md deleted file mode 100644 index 41b89c11bd9f6..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,120 +0,0 @@ ---- -{ - "title": "DROP-MATERIALIZED-VIEW", - "language": "zh-CN" -} ---- - - - -## DROP-MATERIALIZED-VIEW - -### Name - -DROP MATERIALIZED VIEW - -## 描述 - -该语句用于删除物化视图。同步语法 - -语法: - -```sql -DROP MATERIALIZED VIEW [IF EXISTS] mv_name ON table_name; -``` - - -1. IF EXISTS: - 如果物化视图不存在,不要抛出错误。如果不声明此关键字,物化视图不存在则报错。 - -2. mv_name: - 待删除的物化视图的名称。必填项。 - -3. table_name: - 待删除的物化视图所属的表名。必填项。 - -## 举例 - -表结构为 - -```sql -mysql> desc all_type_table all; -+----------------+-------+----------+------+-------+---------+-------+ -| IndexName | Field | Type | Null | Key | Default | Extra | -+----------------+-------+----------+------+-------+---------+-------+ -| all_type_table | k1 | TINYINT | Yes | true | N/A | | -| | k2 | SMALLINT | Yes | false | N/A | NONE | -| | k3 | INT | Yes | false | N/A | NONE | -| | k4 | BIGINT | Yes | false | N/A | NONE | -| | k5 | LARGEINT | Yes | false | N/A | NONE | -| | k6 | FLOAT | Yes | false | N/A | NONE | -| | k7 | DOUBLE | Yes | false | N/A | NONE | -| | | | | | | | -| k1_sumk2 | k1 | TINYINT | Yes | true | N/A | | -| | k2 | SMALLINT | Yes | false | N/A | SUM | -+----------------+-------+----------+------+-------+---------+-------+ -``` - -1. 删除表 all_type_table 的名为 k1_sumk2 的物化视图 - - ```sql - drop materialized view k1_sumk2 on all_type_table; - ``` - - 物化视图被删除后的表结构 - - ```text - +----------------+-------+----------+------+-------+---------+-------+ - | IndexName | Field | Type | Null | Key | Default | Extra | - +----------------+-------+----------+------+-------+---------+-------+ - | all_type_table | k1 | TINYINT | Yes | true | N/A | | - | | k2 | SMALLINT | Yes | false | N/A | NONE | - | | k3 | INT | Yes | false | N/A | NONE | - | | k4 | BIGINT | Yes | false | N/A | NONE | - | | k5 | LARGEINT | Yes | false | N/A | NONE | - | | k6 | FLOAT | Yes | false | N/A | NONE | - | | k7 | DOUBLE | Yes | false | N/A | NONE | - +----------------+-------+----------+------+-------+---------+-------+ - ``` - -2. 删除表 all_type_table 中一个不存在的物化视图 - - ```sql - drop materialized view k1_k2 on all_type_table; - ERROR 1064 (HY000): errCode = 2, detailMessage = Materialized view [k1_k2] does not exist in table [all_type_table] - ``` - - 删除请求直接报错 - -3. 删除表 all_type_table 中的物化视图 k1_k2,不存在不报错。 - - ```sql - drop materialized view if exists k1_k2 on all_type_table; - Query OK, 0 rows affected (0.00 sec) - ``` - - 存在则删除,不存在则不报错。 - -### Keywords - - DROP, MATERIALIZED, VIEW - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-POLICY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-POLICY.md deleted file mode 100644 index 00cf3ef187f7f..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-POLICY.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -{ - "title": "DROP-POLICY", - "language": "zh-CN" -} ---- - - - -## DROP-POLICY - -### Name - -DROP POLICY - -## 描述 - -删除安全策略 - -#### 行安全策略 - -语法: - -1. 删除行安全策略 -```sql -DROP ROW POLICY test_row_policy_1 on table1 [FOR user| ROLE role]; -``` - -2. 删除存储策略 -```sql -DROP STORAGE POLICY policy_name1 -``` - -## 举例 - -1. 删除 table1 的 test_row_policy_1 - - ```sql - DROP ROW POLICY test_row_policy_1 on table1 - ``` - -2. 删除 table1 作用于 test 的 test_row_policy_1 行安全策略 - - ```sql - DROP ROW POLICY test_row_policy_1 on table1 for test - ``` - -3. 删除 table1 作用于 role1 的 test_row_policy_1 行安全策略 - - ```sql - DROP ROW POLICY test_row_policy_1 on table1 for role role1 - ``` - -4. 删除名字为policy_name1的存储策略 -```sql -DROP STORAGE POLICY policy_name1 -``` - -### Keywords - - DROP, POLICY - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-RESOURCE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-RESOURCE.md deleted file mode 100644 index 08e60ff0a4761..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-RESOURCE.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -{ - "title": "DROP-RESOURCE", - "language": "zh-CN" -} ---- - - - -## DROP-RESOURCE - -### Name - -DROP RESOURCE - -## 描述 - -该语句用于删除一个已有的资源。仅 root 或 admin 用户可以删除资源。 -语法: - -```sql -DROP RESOURCE 'resource_name' -``` - -注意:正在使用的 ODBC/S3 资源无法删除。 - -## 举例 - -1. 删除名为 spark0 的 Spark 资源: - - ```sql - DROP RESOURCE 'spark0'; - ``` - -### Keywords - - DROP, RESOURCE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-SQL-BLOCK-RULE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-SQL-BLOCK-RULE.md deleted file mode 100644 index 3da5d14b8b95c..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-SQL-BLOCK-RULE.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -{ - "title": "DROP-SQL-BLOCK-RULE", - "language": "zh-CN" -} ---- - - - -## DROP-SQL-BLOCK-RULE - -### Name - -DROP SQL BLOCK RULE - -## 描述 - -删除SQL阻止规则,支持多规则,以,隔开 - -语法: - -```sql -DROP SQL_BLOCK_RULE test_rule1,... -``` - -## 举例 - -1. 删除test_rule1、test_rule2阻止规则 - - ```sql - mysql> DROP SQL_BLOCK_RULE test_rule1,test_rule2; - Query OK, 0 rows affected (0.00 sec) - ``` - -### Keywords - -```text -DROP, SQL_BLOCK_RULE -``` - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-TABLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-TABLE.md deleted file mode 100644 index ed1fe8507bcff..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-TABLE.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -{ - "title": "DROP-TABLE", - "language": "zh-CN" -} ---- - - - -## DROP-TABLE - -### Name - -DROP TABLE - -## 描述 - -该语句用于删除 Table。 -语法: - -```sql -DROP TABLE [IF EXISTS] [db_name.]table_name [FORCE]; -``` - - -说明: - -- 执行 `DROP TABLE` 一段时间内,可以通过 RECOVER 语句恢复被删除的表。详见 [RECOVER](../../../../sql-manual/sql-statements/Database-Administration-Statements/RECOVER) 语句。 -- 如果执行 `DROP TABLE FORCE`,则系统不会检查该表是否存在未完成的事务,表将直接被删除并且不能被恢复,一般不建议执行此操作。 - -## 举例 - -1. 删除一个 Table - - ```sql - DROP TABLE my_table; - ``` - -2. 如果存在,删除指定 Database 的 Table - - ```sql - DROP TABLE IF EXISTS example_db.my_table; - ``` - - -### Keywords - - DROP, TABLE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-WORKLOAD-GROUP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-WORKLOAD-GROUP.md deleted file mode 100644 index 6abc59e4099de..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-WORKLOAD-GROUP.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -{ - "title": "DROP-WORKLOAD-GROUP", - "language": "zh-CN" -} ---- - - - -## DROP-WORKLOAD-GROUP - -### Name - -DROP WORKLOAD GROUP - -## 描述 - -该语句用于删除资源组。 - -```sql -DROP WORKLOAD GROUP [IF EXISTS] 'rg_name' -``` - -## 举例 - -1. 删除名为 g1 的资源组: - - ```sql - drop workload group if exists g1; - ``` - -### Keywords - - DROP, WORKLOAD, GROUP - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/TRUNCATE-TABLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/TRUNCATE-TABLE.md deleted file mode 100644 index 25e44f27cd2d6..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Definition-Statements/Drop/TRUNCATE-TABLE.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -{ - "title": "TRUNCATE-TABLE", - "language": "zh-CN" -} ---- - - - -## TRUNCATE-TABLE - -### Name - -TRUNCATE TABLE - -## 描述 - -该语句用于清空指定表和分区的数据 -语法: - -```sql -TRUNCATE TABLE [db.]tbl[ PARTITION(p1, p2, ...)]; -``` - -说明: - -- 该语句清空数据,但保留表或分区。 -- 不同于 DELETE,该语句只能整体清空指定的表或分区,不能添加过滤条件。 -- 不同于 DELETE,使用该方式清空数据不会对查询性能造成影响。 -- 该操作删除的数据不可恢复。 -- 使用该命令时,表状态需为 NORMAL,即不允许正在进行 SCHEMA CHANGE 等操作。 -- 该命令可能会导致正在进行的导入失败。 - -## 举例 - -1. 清空 example_db 下的表 tbl - - ```sql - TRUNCATE TABLE example_db.tbl; - ``` - -2. 清空表 tbl 的 p1 和 p2 分区 - - ```sql - TRUNCATE TABLE tbl PARTITION(p1, p2); - ``` - -### Keywords - - TRUNCATE, TABLE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/ALTER-ROUTINE-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/ALTER-ROUTINE-LOAD.md deleted file mode 100644 index f994c6a1f2e48..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/ALTER-ROUTINE-LOAD.md +++ /dev/null @@ -1,128 +0,0 @@ ---- -{ - "title": "ALTER-ROUTINE-LOAD", - "language": "zh-CN" -} ---- - - - -## ALTER-ROUTINE-LOAD - -### Name - -ALTER ROUTINE LOAD - -## 描述 - -该语法用于修改已经创建的例行导入作业。 - -只能修改处于 PAUSED 状态的作业。 - -语法: - -```sql -ALTER ROUTINE LOAD FOR [db.]job_name -[job_properties] -FROM data_source -[data_source_properties] -``` - -1. `[db.]job_name` - - 指定要修改的作业名称。 - -2. `tbl_name` - - 指定需要导入的表的名称。 - -3. `job_properties` - - 指定需要修改的作业参数。目前仅支持如下参数的修改: - - 1. `desired_concurrent_number` - 2. `max_error_number` - 3. `max_batch_interval` - 4. `max_batch_rows` - 5. `max_batch_size` - 6. `jsonpaths` - 7. `json_root` - 8. `strip_outer_array` - 9. `strict_mode` - 10. `timezone` - 11. `num_as_string` - 12. `fuzzy_parse` - 13. `partial_columns` - 14. `max_filter_ratio` - - -4. `data_source` - - 数据源的类型。当前支持: - - KAFKA - -5. `data_source_properties` - - 数据源的相关属性。目前仅支持: - - 1. `kafka_partitions` - 2. `kafka_offsets` - 3. `kafka_broker_list` - 4. `kafka_topic` - 5. 自定义 property,如 `property.group.id` - - 注: - - 1. `kafka_partitions` 和 `kafka_offsets` 用于修改待消费的 kafka partition 的offset,仅能修改当前已经消费的 partition。不能新增 partition。 - -## 举例 - -1. 将 `desired_concurrent_number` 修改为 1 - - ```sql - ALTER ROUTINE LOAD FOR db1.label1 - PROPERTIES - ( - "desired_concurrent_number" = "1" - ); - ``` - -2. 将 `desired_concurrent_number` 修改为 10,修改 partition 的offset,修改 group id。 - - ```sql - ALTER ROUTINE LOAD FOR db1.label1 - PROPERTIES - ( - "desired_concurrent_number" = "10" - ) - FROM kafka - ( - "kafka_partitions" = "0, 1, 2", - "kafka_offsets" = "100, 200, 100", - "property.group.id" = "new_group" - ); - -### Keywords - - ALTER, ROUTINE, LOAD - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/BROKER-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/BROKER-LOAD.md deleted file mode 100644 index 8063e0193e5e5..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/BROKER-LOAD.md +++ /dev/null @@ -1,570 +0,0 @@ ---- -{ - "title": "BROKER-LOAD", - "language": "zh-CN" -} ---- - - - -## BROKER-LOAD - -### Name - -BROKER LOAD - -## 描述 - -该命令主要用于通过 Broker 服务进程读取远端存储(如 S3、HDFS)上的数据导入到 Doris 表里。 - -```sql -LOAD LABEL load_label -( -data_desc1[, data_desc2, ...] -) -WITH BROKER broker_name -[broker_properties] -[load_properties] -[COMMENT "comments"]; -``` - -- `load_label` - - 每个导入需要指定一个唯一的 Label。后续可以通过这个 label 来查看作业进度。 - - `[database.]label_name` - -- `data_desc1` - - 用于描述一组需要导入的文件。 - - ```sql - [MERGE|APPEND|DELETE] - DATA INFILE - ( - "file_path1"[, file_path2, ...] - ) - [NEGATIVE] - INTO TABLE `table_name` - [PARTITION (p1, p2, ...)] - [COLUMNS TERMINATED BY "column_separator"] - [LINES TERMINATED BY "line_delimiter"] - [FORMAT AS "file_type"] - [COMPRESS_TYPE AS "compress_type"] - [(column_list)] - [COLUMNS FROM PATH AS (c1, c2, ...)] - [SET (column_mapping)] - [PRECEDING FILTER predicate] - [WHERE predicate] - [DELETE ON expr] - [ORDER BY source_sequence] - [PROPERTIES ("key1"="value1", ...)] - ``` - - - `[MERGE|APPEND|DELETE]` - - 数据合并类型。默认为 APPEND,表示本次导入是普通的追加写操作。MERGE 和 DELETE 类型仅适用于 Unique Key 模型表。其中 MERGE 类型需要配合 `[DELETE ON]` 语句使用,以标注 Delete Flag 列。而 DELETE 类型则表示本次导入的所有数据皆为删除数据。 - - - `DATA INFILE` - - 指定需要导入的文件路径。可以是多个。可以使用通配符。路径最终必须匹配到文件,如果只匹配到目录则导入会失败。 - - - `NEGATIVE` - - 该关键词用于表示本次导入为一批”负“导入。这种方式仅针对具有整型 SUM 聚合类型的聚合数据表。该方式会将导入数据中,SUM 聚合列对应的整型数值取反。主要用于冲抵之前导入错误的数据。 - - - `PARTITION(p1, p2, ...)` - - 可以指定仅导入表的某些分区。不在分区范围内的数据将被忽略。 - - - `COLUMNS TERMINATED BY` - - 指定列分隔符。仅在 CSV 格式下有效。仅能指定单字节分隔符。 - - - `LINES TERMINATED BY` - - 指定行分隔符。仅在 CSV 格式下有效。仅能指定单字节分隔符。 - - - `FORMAT AS` - - 指定文件类型,支持 CSV、PARQUET 和 ORC 格式。默认为 CSV。 - - - `COMPRESS_TYPE AS` - 指定文件压缩类型,支持 GZ/BZ2/LZ4FRAME。 - - - `column list` - - 用于指定原始文件中的列顺序。关于这部分详细介绍,可以参阅 [列的映射,转换与过滤](../../../../data-operate/import/import-scenes/load-data-convert.md) 文档。 - - `(k1, k2, tmpk1)` - - - `COLUMNS FROM PATH AS` - - 指定从导入文件路径中抽取的列。 - - - `SET (column_mapping)` - - 指定列的转换函数。 - - - `PRECEDING FILTER predicate` - - 前置过滤条件。数据首先根据 `column list` 和 `COLUMNS FROM PATH AS` 按顺序拼接成原始数据行。然后按照前置过滤条件进行过滤。关于这部分详细介绍,可以参阅 [列的映射,转换与过滤](../../../../data-operate/import/import-scenes/load-data-convert.md) 文档。 - - - `WHERE predicate` - - 根据条件对导入的数据进行过滤。关于这部分详细介绍,可以参阅 [列的映射,转换与过滤](../../../../data-operate/import/import-scenes/load-data-convert.md) 文档。 - - - `DELETE ON expr` - - 需配合 MEREGE 导入模式一起使用,仅针对 Unique Key 模型的表。用于指定导入数据中表示 Delete Flag 的列和计算关系。 - - - `ORDER BY` - - 仅针对 Unique Key 模型的表。用于指定导入数据中表示 Sequence Col 的列。主要用于导入时保证数据顺序。 - - - `PROPERTIES ("key1"="value1", ...)` - - 指定导入的 format 的一些参数。如导入的文件是`json`格式,则可以在这里指定`json_root`、`jsonpaths`、`fuzzy_parse`等参数。 - - - enclose - - 包围符。当 csv 数据字段中含有行分隔符或列分隔符时,为防止意外截断,可指定单字节字符作为包围符起到保护作用。例如列分隔符为",",包围符为"'",数据为"a,'b,c'",则"b,c"会被解析为一个字段。 - 注意:当 enclose 设置为`"`时,trim_double_quotes 一定要设置为 true。 - - - escape - - 转义符。用于转义在字段中出现的与包围符相同的字符。例如数据为"a,'b,'c'",包围符为"'",希望"b,'c 被作为一个字段解析,则需要指定单字节转义符,例如"\",然后将数据修改为"a,'b,\'c'"。 - -- `WITH BROKER broker_name` - - 指定需要使用的 Broker 服务名称。在公有云 Doris 中。Broker 服务名称为 `bos` - -- `broker_properties` - - 指定 broker 所需的信息。这些信息通常被用于 Broker 能够访问远端存储系统。如 BOS 或 HDFS。关于具体信息,可参阅 [Broker](../../../../advanced/broker.md) 文档。 - - ```text - ( - "key1" = "val1", - "key2" = "val2", - ... - ) - ``` - - - `load_properties` - - 指定导入的相关参数。目前支持以下参数: - - - `timeout` - - 导入超时时间。默认为 4 小时。单位秒。 - - - `max_filter_ratio` - - 最大容忍可过滤(数据不规范等原因)的数据比例。默认零容忍。取值范围为 0 到 1。 - - - `exec_mem_limit` - - 导入内存限制。默认为 2GB。单位为字节。 - - - `strict_mode` - - 是否对数据进行严格限制。默认为 false。 - - - `partial_columns` - - 布尔类型,为 true 表示使用部分列更新,默认值为 false,该参数只允许在表模型为 Unique 且采用 Merge on Write 时设置。 - - - `timezone` - - 指定某些受时区影响的函数的时区,如 `strftime/alignment_timestamp/from_unixtime` 等等,具体请查阅 [时区](../../../../advanced/time-zone.md) 文档。如果不指定,则使用 "Asia/Shanghai" 时区 - - - `load_parallelism` - - 导入并发度,默认为 1。调大导入并发度会启动多个执行计划同时执行导入任务,加快导入速度。 - - - `send_batch_parallelism` - - 用于设置发送批处理数据的并行度,如果并行度的值超过 BE 配置中的 `max_send_batch_parallelism_per_job`,那么作为协调点的 BE 将使用 `max_send_batch_parallelism_per_job` 的值。 - - - `load_to_single_tablet` - - 布尔类型,为 true 表示支持一个任务只导入数据到对应分区的一个 tablet,默认值为 false,作业的任务数取决于整体并发度。该参数只允许在对带有 random 分桶的 olap 表导数的时候设置。 - - - priority - - 设置导入任务的优先级,可选 `HIGH/NORMAL/LOW` 三种优先级,默认为 `NORMAL`,对于处在 `PENDING` 状态的导入任务,更高优先级的任务将优先被执行进入 `LOADING` 状态。 - -- comment - - 指定导入任务的备注信息。可选参数。 - -## 举例 - -1. 从 HDFS 导入一批数据 - - ```sql - LOAD LABEL example_db.label1 - ( - DATA INFILE("hdfs://hdfs_host:hdfs_port/input/file.txt") - INTO TABLE `my_table` - COLUMNS TERMINATED BY "," - ) - WITH BROKER hdfs - ( - "username"="hdfs_user", - "password"="hdfs_password" - ); - ``` - - 导入文件 `file.txt`,按逗号分隔,导入到表 `my_table`。 - -2. 从 HDFS 导入数据,使用通配符匹配两批文件。分别导入到两个表中。 - - ```sql - LOAD LABEL example_db.label2 - ( - DATA INFILE("hdfs://hdfs_host:hdfs_port/input/file-10*") - INTO TABLE `my_table1` - PARTITION (p1) - COLUMNS TERMINATED BY "," - (k1, tmp_k2, tmp_k3) - SET ( - k2 = tmp_k2 + 1, - k3 = tmp_k3 + 1 - ) - DATA INFILE("hdfs://hdfs_host:hdfs_port/input/file-20*") - INTO TABLE `my_table2` - COLUMNS TERMINATED BY "," - (k1, k2, k3) - ) - WITH BROKER hdfs - ( - "username"="hdfs_user", - "password"="hdfs_password" - ); - ``` - - 使用通配符匹配导入两批文件 `file-10*` 和 `file-20*`。分别导入到 `my_table1` 和 `my_table2` 两张表中。其中 `my_table1` 指定导入到分区 `p1` 中,并且将导入源文件中第二列和第三列的值 +1 后导入。 - -3. 从 HDFS 导入一批数据。 - - ```sql - LOAD LABEL example_db.label3 - ( - DATA INFILE("hdfs://hdfs_host:hdfs_port/user/doris/data/*/*") - INTO TABLE `my_table` - COLUMNS TERMINATED BY "\\x01" - ) - WITH BROKER my_hdfs_broker - ( - "username" = "", - "password" = "", - "fs.defaultFS" = "hdfs://my_ha", - "dfs.nameservices" = "my_ha", - "dfs.ha.namenodes.my_ha" = "my_namenode1, my_namenode2", - "dfs.namenode.rpc-address.my_ha.my_namenode1" = "nn1_host:rpc_port", - "dfs.namenode.rpc-address.my_ha.my_namenode2" = "nn2_host:rpc_port", - "dfs.client.failover.proxy.provider.my_ha" = "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider" - ); - ``` - - 指定分隔符为 Hive 的默认分隔符 `\\x01`,并使用通配符 * 指定 `data` 目录下所有目录的所有文件。使用简单认证,同时配置 namenode HA。 - -4. 导入 Parquet 格式数据,指定 FORMAT 为 parquet。默认是通过文件后缀判断 - - ```sql - LOAD LABEL example_db.label4 - ( - DATA INFILE("hdfs://hdfs_host:hdfs_port/input/file") - INTO TABLE `my_table` - FORMAT AS "parquet" - (k1, k2, k3) - ) - WITH BROKER hdfs - ( - "username"="hdfs_user", - "password"="hdfs_password" - ); - ``` - -5. 导入数据,并提取文件路径中的分区字段 - - ```sql - LOAD LABEL example_db.label10 - ( - DATA INFILE("hdfs://hdfs_host:hdfs_port/input/city=beijing/*/*") - INTO TABLE `my_table` - FORMAT AS "csv" - (k1, k2, k3) - COLUMNS FROM PATH AS (city, utc_date) - ) - WITH BROKER hdfs - ( - "username"="hdfs_user", - "password"="hdfs_password" - ); - ``` - - `my_table` 表中的列为 `k1, k2, k3, city, utc_date`。 - - 其中 `hdfs://hdfs_host:hdfs_port/user/doris/data/input/dir/city=beijing` 目录下包括如下文件: - - ```text - hdfs://hdfs_host:hdfs_port/input/city=beijing/utc_date=2020-10-01/0000.csv - hdfs://hdfs_host:hdfs_port/input/city=beijing/utc_date=2020-10-02/0000.csv - hdfs://hdfs_host:hdfs_port/input/city=tianji/utc_date=2020-10-03/0000.csv - hdfs://hdfs_host:hdfs_port/input/city=tianji/utc_date=2020-10-04/0000.csv - ``` - - 文件中只包含 `k1, k2, k3` 三列数据,`city, utc_date` 这两列数据会从文件路径中提取。 - -6. 对待导入数据进行过滤。 - - ```sql - LOAD LABEL example_db.label6 - ( - DATA INFILE("hdfs://host:port/input/file") - INTO TABLE `my_table` - (k1, k2, k3) - SET ( - k2 = k2 + 1 - ) - PRECEDING FILTER k1 = 1 - WHERE k1 > k2 - ) - WITH BROKER hdfs - ( - "username"="user", - "password"="pass" - ); - ``` - - 只有原始数据中,k1 = 1,并且转换后,k1 > k2 的行才会被导入。 - -7. 导入数据,提取文件路径中的时间分区字段,并且时间包含 %3A (在 hdfs 路径中,不允许有 ':',所有 ':' 会由 %3A 替换) - - ```sql - LOAD LABEL example_db.label7 - ( - DATA INFILE("hdfs://host:port/user/data/*/test.txt") - INTO TABLE `tbl12` - COLUMNS TERMINATED BY "," - (k2,k3) - COLUMNS FROM PATH AS (data_time) - SET ( - data_time=str_to_date(data_time, '%Y-%m-%d %H%%3A%i%%3A%s') - ) - ) - WITH BROKER hdfs - ( - "username"="user", - "password"="pass" - ); - ``` - - 路径下有如下文件: - - ```text - /user/data/data_time=2020-02-17 00%3A00%3A00/test.txt - /user/data/data_time=2020-02-18 00%3A00%3A00/test.txt - ``` - - 表结构为: - - ```text - data_time DATETIME, - k2 INT, - k3 INT - ``` - -8. 从 HDFS 导入一批数据,指定超时时间和过滤比例。使用明文 my_hdfs_broker 的 broker。简单认证。并且将原有数据中与 导入数据中 v2 大于 100 的列相匹配的列删除,其他列正常导入 - - ```sql - LOAD LABEL example_db.label8 - ( - MERGE DATA INFILE("HDFS://test:802/input/file") - INTO TABLE `my_table` - (k1, k2, k3, v2, v1) - DELETE ON v2 > 100 - ) - WITH HDFS - ( - "hadoop.username"="user", - "password"="pass" - ) - PROPERTIES - ( - "timeout" = "3600", - "max_filter_ratio" = "0.1" - ); - ``` - - 使用 MERGE 方式导入。`my_table` 必须是一张 Unique Key 的表。当导入数据中的 v2 列的值大于 100 时,该行会被认为是一个删除行。 - - 导入任务的超时时间是 3600 秒,并且允许错误率在 10% 以内。 - -9. 导入时指定 source_sequence 列,保证 UNIQUE_KEYS 表中的替换顺序: - - ```sql - LOAD LABEL example_db.label9 - ( - DATA INFILE("HDFS://test:802/input/file") - INTO TABLE `my_table` - COLUMNS TERMINATED BY "," - (k1,k2,source_sequence,v1,v2) - ORDER BY source_sequence - ) - WITH HDFS - ( - "hadoop.username"="user", - "password"="pass" - ) - ``` - - `my_table` 必须是 Unique Key 模型表,并且指定了 Sequcence Col。数据会按照源数据中 `source_sequence` 列的值来保证顺序性。 - -10. 从 HDFS 导入一批数据,指定文件格式为 `json` 并指定 `json_root`、`jsonpaths` - - ```sql - LOAD LABEL example_db.label10 - ( - DATA INFILE("HDFS://test:port/input/file.json") - INTO TABLE `my_table` - FORMAT AS "json" - PROPERTIES( - "json_root" = "$.item", - "jsonpaths" = "[$.id, $.city, $.code]" - ) - ) - with HDFS ( - "hadoop.username" = "user" - "password" = "" - ) - PROPERTIES - ( - "timeout"="1200", - "max_filter_ratio"="0.1" - ); - ``` - - `jsonpaths` 可与 `column list` 及 `SET (column_mapping)`配合: - - ```sql - LOAD LABEL example_db.label10 - ( - DATA INFILE("HDFS://test:port/input/file.json") - INTO TABLE `my_table` - FORMAT AS "json" - (id, code, city) - SET (id = id * 10) - PROPERTIES( - "json_root" = "$.item", - "jsonpaths" = "[$.id, $.code, $.city]" - ) - ) - with HDFS ( - "hadoop.username" = "user" - "password" = "" - ) - PROPERTIES - ( - "timeout"="1200", - "max_filter_ratio"="0.1" - ); - -11. 从腾讯云 cos 中以 csv 格式导入数据。 - - ```SQL - LOAD LABEL example_db.label10 - ( - DATA INFILE("cosn://my_bucket/input/file.csv") - INTO TABLE `my_table` - (k1, k2, k3) - ) - WITH BROKER "broker_name" - ( - "fs.cosn.userinfo.secretId" = "xxx", - "fs.cosn.userinfo.secretKey" = "xxxx", - "fs.cosn.bucket.endpoint_suffix" = "cos.xxxxxxxxx.myqcloud.com" - ) - ``` - -12. 导入 CSV 数据时去掉双引号,并跳过前 5 行。 - - ```SQL - LOAD LABEL example_db.label12 - ( - DATA INFILE("cosn://my_bucket/input/file.csv") - INTO TABLE `my_table` - (k1, k2, k3) - PROPERTIES("trim_double_quotes" = "true", "skip_lines" = "5") - ) - WITH BROKER "broker_name" - ( - "fs.cosn.userinfo.secretId" = "xxx", - "fs.cosn.userinfo.secretKey" = "xxxx", - "fs.cosn.bucket.endpoint_suffix" = "cos.xxxxxxxxx.myqcloud.com" - ) - ``` - -### Keywords - - BROKER, LOAD - -### Best Practice - -1. 查看导入任务状态 - - Broker Load 是一个异步导入过程,语句执行成功仅代表导入任务提交成功,并不代表数据导入成功。导入状态需要通过 [SHOW LOAD](../../Show-Statements/SHOW-LOAD.md) 命令查看。 - -2. 取消导入任务 - - 已提交切尚未结束的导入任务可以通过 [CANCEL LOAD](./CANCEL-LOAD.md) 命令取消。取消后,已写入的数据也会回滚,不会生效。 - -3. Label、导入事务、多表原子性 - - Doris 中所有导入任务都是原子生效的。并且在同一个导入任务中对多张表的导入也能够保证原子性。同时,Doris 还可以通过 Label 的机制来保证数据导入的不丢不重。具体说明可以参阅 [导入事务和原子性](../../../../data-operate/import/import-scenes/load-atomicity.md) 文档。 - -4. 列映射、衍生列和过滤 - - Doris 可以在导入语句中支持非常丰富的列转换和过滤操作。支持绝大多数内置函数和 UDF。关于如何正确的使用这个功能,可参阅 [列的映射,转换与过滤](../../../../data-operate/import/import-scenes/load-data-convert.md) 文档。 - -5. 错误数据过滤 - - Doris 的导入任务可以容忍一部分格式错误的数据。容忍了通过 `max_filter_ratio` 设置。默认为 0,即表示当有一条错误数据时,整个导入任务将会失败。如果用户希望忽略部分有问题的数据行,可以将次参数设置为 0~1 之间的数值,Doris 会自动跳过哪些数据格式不正确的行。 - - 关于容忍率的一些计算方式,可以参阅 [列的映射,转换与过滤](../../../../data-operate/import/import-scenes/load-data-convert.md) 文档。 - -6. 严格模式 - - `strict_mode` 属性用于设置导入任务是否运行在严格模式下。该格式会对列映射、转换和过滤的结果产生影响。关于严格模式的具体说明,可参阅 [严格模式](../../../../data-operate/import/import-scenes/load-strict-mode.md) 文档。 - -7. 超时时间 - - Broker Load 的默认超时时间为 4 小时。从任务提交开始算起。如果在超时时间内没有完成,则任务会失败。 - -8. 数据量和任务数限制 - - Broker Load 适合在一个导入任务中导入 100GB 以内的数据。虽然理论上在一个导入任务中导入的数据量没有上限。但是提交过大的导入会导致运行时间较长,并且失败后重试的代价也会增加。 - - 同时受限于集群规模,我们限制了导入的最大数据量为 ComputeNode 节点数 * 3GB。以保证系统资源的合理利用。如果有大数据量需要导入,建议分成多个导入任务提交。 - - Doris 同时会限制集群内同时运行的导入任务数量,通常在 3-10 个不等。之后提交的导入作业会排队等待。队列最大长度为 100。之后的提交会直接拒绝。注意排队时间也被计算到了作业总时间中。如果超时,则作业会被取消。所以建议通过监控作业运行状态来合理控制作业提交频率。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CANCEL-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CANCEL-LOAD.md deleted file mode 100644 index f5d35c0346193..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CANCEL-LOAD.md +++ /dev/null @@ -1,78 +0,0 @@ ---- -{ - "title": "CANCEL-LOAD", - "language": "zh-CN" -} ---- - - - -## CANCEL-LOAD - -### Name - -CANCEL LOAD - -## 描述 - -该语句用于撤销指定 label 的导入作业。或者通过模糊匹配批量撤销导入作业 - -```sql -CANCEL LOAD -[FROM db_name] -WHERE [LABEL = "load_label" | LABEL like "label_pattern" | STATE = "PENDING/ETL/LOADING"] -``` - -注:1.2.0 版本之后支持根据 State 取消作业。 - -## 举例 - -1. 撤销数据库 example_db 上,label 为 `example_db_test_load_label` 的导入作业 - - ```sql - CANCEL LOAD - FROM example_db - WHERE LABEL = "example_db_test_load_label"; - ``` - -2. 撤销数据库 example*db 上,所有包含 example* 的导入作业。 - - ```sql - CANCEL LOAD - FROM example_db - WHERE LABEL like "example_"; - ``` - -3. 取消状态为 LOADING 的导入作业。 - - ```sql - CANCEL LOAD - FROM example_db - WHERE STATE = "loading"; - ``` - -### Keywords - - CANCEL, LOAD - -### Best Practice - -1. 只能取消处于 PENDING、ETL、LOADING 状态的未完成的导入作业。 -2. 当执行批量撤销时,Doris 不会保证所有对应的导入作业原子的撤销。即有可能仅有部分导入作业撤销成功。用户可以通过 SHOW LOAD 语句查看作业状态,并尝试重复执行 CANCEL LOAD 语句。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CLEAN-LABEL.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CLEAN-LABEL.md deleted file mode 100644 index d6d5d6056e36f..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CLEAN-LABEL.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -{ - "title": "CLEAN-LABEL", - "language": "zh-CN" -} ---- - - - -## CLEAN-LABEL - -### Name - -CLEAN LABEL - -## 描述 - -用于手动清理历史导入作业的 Label。清理后,Label 可以重复使用。 - -语法: - -```sql -CLEAN LABEL [label] FROM db; -``` - -## 举例 - -1. 清理 db1 中,Label 为 label1 的导入作业。 - - ```sql - CLEAN LABEL label1 FROM db1; - ``` - -2. 清理 db1 中所有历史 Label。 - - ```sql - CLEAN LABEL FROM db1; - ``` - -### Keywords - - CLEAN, LABEL - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CLEAN-PROFILE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CLEAN-PROFILE.md deleted file mode 100644 index ebdae86acec06..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CLEAN-PROFILE.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "CLEAN-PROFILE", - "language": "zh-CN" -} ---- - - - -## CLEAN-PROFILE - -### Name - -CLEAN PROFILE - -## 描述 - -用于手动清理所有历史 query 或 load 的 profile 信息。 - -语法: - -```sql -CLEAN ALL PROFILE; -``` - -## 举例 - -1. 清理所有 profile 信息。 - - ```sql - CLEAN ALL PROFILE; - ``` - -### Keywords - - CLEAN, PROFILE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CREATE-ROUTINE-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CREATE-ROUTINE-LOAD.md deleted file mode 100644 index a40498c78aeac..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CREATE-ROUTINE-LOAD.md +++ /dev/null @@ -1,630 +0,0 @@ ---- -{ - "title": "CREATE-ROUTINE-LOAD", - "language": "zh-CN" -} - ---- - - - -## CREATE-ROUTINE-LOAD - -### Name - -CREATE ROUTINE LOAD - -## 描述 - -例行导入(Routine Load)功能,支持用户提交一个常驻的导入任务,通过不断的从指定的数据源读取数据,将数据导入到 Doris 中。 - -目前仅支持通过无认证或者 SSL 认证方式,从 Kakfa 导入 CSV 或 Json 格式的数据。 [导入 Json 格式数据使用示例](../../../../data-operate/import/import-way/routine-load-manual.md#导入Json格式数据使用示例) - -语法: - -```sql -CREATE ROUTINE LOAD [db.]job_name [ON tbl_name] -[merge_type] -[load_properties] -[job_properties] -FROM data_source [data_source_properties] -[COMMENT "comment"] -``` -``` - -- `[db.]job_name` - - 导入作业的名称,在同一个 database 内,相同名称只能有一个 job 在运行。 - -- `tbl_name` - - 指定需要导入的表的名称,可选参数,如果不指定,则采用动态表的方式,这个时候需要 Kafka 中的数据包含表名的信息。 - 目前仅支持从 Kafka 的 Value 中获取表名,且需要符合这种格式:以 json 为例:`table_name|{"col1": "val1", "col2": "val2"}`, - 其中 `tbl_name` 为表名,以 `|` 作为表名和表数据的分隔符。csv 格式的数据也是类似的,如:`table_name|val1,val2,val3`。注意,这里的 - `table_name` 必须和 Doris 中的表名一致,否则会导致导入失败. - - tips: 动态表不支持 `columns_mapping` 参数。如果你的表结构和 Doris 中的表结构一致,且存在大量的表信息需要导入,那么这种方式将是不二选择。 - -- `merge_type` - - 数据合并类型。默认为 APPEND,表示导入的数据都是普通的追加写操作。MERGE 和 DELETE 类型仅适用于 Unique Key 模型表。其中 MERGE 类型需要配合 [DELETE ON] 语句使用,以标注 Delete Flag 列。而 DELETE 类型则表示导入的所有数据皆为删除数据。 - tips: 当使用动态多表的时候,请注意此参数应该符合每张动态表的类型,否则会导致导入失败。 - -- load_properties - - 用于描述导入数据。组成如下: - - ```SQL - [column_separator], - [columns_mapping], - [preceding_filter], - [where_predicates], - [partitions], - [DELETE ON], - [ORDER BY] - ``` - - - `column_separator` - - 指定列分隔符,默认为 `\t` - - `COLUMNS TERMINATED BY ","` - - - `columns_mapping` - - 用于指定文件列和表中列的映射关系,以及各种列转换等。关于这部分详细介绍,可以参阅 [列的映射,转换与过滤] 文档。 - - `(k1, k2, tmpk1, k3 = tmpk1 + 1)` - - tips: 动态表不支持此参数。 - - - `preceding_filter` - - 过滤原始数据。关于这部分详细介绍,可以参阅 [列的映射,转换与过滤] 文档。 - - tips: 动态表不支持此参数。 - - - `where_predicates` - - 根据条件对导入的数据进行过滤。关于这部分详细介绍,可以参阅 [列的映射,转换与过滤] 文档。 - - `WHERE k1 > 100 and k2 = 1000` - - tips: 当使用动态多表的时候,请注意此参数应该符合每张动态表的列,否则会导致导入失败。通常在使用动态多表的时候,我们仅建议通用公共列使用此参数。 - - - `partitions` - - 指定导入目的表的哪些 partition 中。如果不指定,则会自动导入到对应的 partition 中。 - - `PARTITION(p1, p2, p3)` - - tips: 当使用动态多表的时候,请注意此参数应该符合每张动态表,否则会导致导入失败。 - - - `DELETE ON` - - 需配合 MEREGE 导入模式一起使用,仅针对 Unique Key 模型的表。用于指定导入数据中表示 Delete Flag 的列和计算关系。 - - `DELETE ON v3 >100` - - tips: 当使用动态多表的时候,请注意此参数应该符合每张动态表,否则会导致导入失败。 - - - `ORDER BY` - - 仅针对 Unique Key 模型的表。用于指定导入数据中表示 Sequence Col 的列。主要用于导入时保证数据顺序。 - - tips: 当使用动态多表的时候,请注意此参数应该符合每张动态表,否则会导致导入失败。 - -- `job_properties` - - 用于指定例行导入作业的通用参数。 - - ```text - PROPERTIES ( - "key1" = "val1", - "key2" = "val2" - ) - ``` - - 目前我们支持以下参数: - - 1. `desired_concurrent_number` - - 期望的并发度。一个例行导入作业会被分成多个子任务执行。这个参数指定一个作业最多有多少任务可以同时执行。必须大于 0。默认为 5。 - - 这个并发度并不是实际的并发度,实际的并发度,会通过集群的节点数、负载情况,以及数据源的情况综合考虑。 - - `"desired_concurrent_number" = "3"` - - 2. `max_batch_interval/max_batch_rows/max_batch_size` - - 这三个参数分别表示: - - 1. 每个子任务最大执行时间,单位是秒。必须大于等于 1。默认为 10。 - 2. 每个子任务最多读取的行数。必须大于等于 200000。默认是 20000000。 - 3. 每个子任务最多读取的字节数。单位是字节,范围是 100MB 到 10GB。默认是 1G。 - - 这三个参数,用于控制一个子任务的执行时间和处理量。当任意一个达到阈值,则任务结束。 - - ```text - "max_batch_interval" = "20", - "max_batch_rows" = "300000", - "max_batch_size" = "209715200" - ``` - - 3. `max_error_number` - - 采样窗口内,允许的最大错误行数。必须大于等于 0。默认是 0,即不允许有错误行。 - - 采样窗口为 `max_batch_rows * 10`。即如果在采样窗口内,错误行数大于 `max_error_number`,则会导致例行作业被暂停,需要人工介入检查数据质量问题。 - - 被 where 条件过滤掉的行不算错误行。 - - 4. `strict_mode` - - 是否开启严格模式,默认为关闭。如果开启后,非空原始数据的列类型变换如果结果为 NULL,则会被过滤。指定方式为: - - `"strict_mode" = "true"` - - strict mode 模式的意思是:对于导入过程中的列类型转换进行严格过滤。严格过滤的策略如下: - - 1. 对于列类型转换来说,如果 strict mode 为 true,则错误的数据将被 filter。这里的错误数据是指:原始数据并不为空值,在参与列类型转换后结果为空值的这一类数据。 - 2. 对于导入的某列由函数变换生成时,strict mode 对其不产生影响。 - 3. 对于导入的某列类型包含范围限制的,如果原始数据能正常通过类型转换,但无法通过范围限制的,strict mode 对其也不产生影响。例如:如果类型是 decimal(1,0), 原始数据为 10,则属于可以通过类型转换但不在列声明的范围内。这种数据 strict 对其不产生影响。 - - **strict mode 与 source data 的导入关系** - - 这里以列类型为 TinyInt 来举例 - - > 注:当表中的列允许导入空值时 - - | source data | source data example | string to int | strict_mode | result | - | ----------- | ------------------- | ------------- | ------------- | ---------------------- | - | 空值 | `\N` | N/A | true or false | NULL | - | not null | aaa or 2000 | NULL | true | invalid data(filtered) | - | not null | aaa | NULL | false | NULL | - | not null | 1 | 1 | true or false | correct data | - - 这里以列类型为 Decimal(1,0) 举例 - - > 注:当表中的列允许导入空值时 - - | source data | source data example | string to int | strict_mode | result | - | ----------- | ------------------- | ------------- | ------------- | ---------------------- | - | 空值 | \N | N/A | true or false | NULL | - | not null | aaa | NULL | true | invalid data(filtered) | - | not null | aaa | NULL | false | NULL | - | not null | 1 or 10 | 1 | true or false | correct data | - - > 注意:10 虽然是一个超过范围的值,但是因为其类型符合 decimal 的要求,所以 strict mode 对其不产生影响。10 最后会在其他 ETL 处理流程中被过滤。但不会被 strict mode 过滤。 - - 5. `timezone` - - 指定导入作业所使用的时区。默认为使用 Session 的 timezone 参数。该参数会影响所有导入涉及的和时区有关的函数结果。 - - 6. `format` - - 指定导入数据格式,默认是 csv,支持 json 格式。 - - 7. `jsonpaths` - - 当导入数据格式为 json 时,可以通过 jsonpaths 指定抽取 Json 数据中的字段。 - - `-H "jsonpaths: [\"$.k2\", \"$.k1\"]"` - - 8. `strip_outer_array` - - 当导入数据格式为 json 时,strip_outer_array 为 true 表示 Json 数据以数组的形式展现,数据中的每一个元素将被视为一行数据。默认值是 false。 - - `-H "strip_outer_array: true"` - - 9. `json_root` - - 当导入数据格式为 json 时,可以通过 json_root 指定 Json 数据的根节点。Doris 将通过 json_root 抽取根节点的元素进行解析。默认为空。 - - `-H "json_root: $.RECORDS"` - - 10. `send_batch_parallelism` - - 整型,用于设置发送批处理数据的并行度,如果并行度的值超过 BE 配置中的 `max_send_batch_parallelism_per_job`,那么作为协调点的 BE 将使用 `max_send_batch_parallelism_per_job` 的值。 - - 11. `load_to_single_tablet` - - 布尔类型,为 true 表示支持一个任务只导入数据到对应分区的一个 tablet,默认值为 false,该参数只允许在对带有 random 分桶的 olap 表导数的时候设置。 - - 12. `partial_columns` - 布尔类型,为 true 表示使用部分列更新,默认值为 false,该参数只允许在表模型为 Unique 且采用 Merge on Write 时设置。一流多表不支持此参数。 - - 13. `max_filter_ratio` - - 采样窗口内,允许的最大过滤率。必须在大于等于0到小于等于1之间。默认值是 0。 - - 采样窗口为 `max_batch_rows * 10`。即如果在采样窗口内,错误行数/总行数大于 `max_filter_ratio`,则会导致例行作业被暂停,需要人工介入检查数据质量问题。 - - 被 where 条件过滤掉的行不算错误行。 - - 14. `enclose` - 包围符。当 csv 数据字段中含有行分隔符或列分隔符时,为防止意外截断,可指定单字节字符作为包围符起到保护作用。例如列分隔符为",",包围符为"'",数据为"a,'b,c'",则"b,c"会被解析为一个字段。 - 注意:当 enclose 设置为`"`时,trim_double_quotes 一定要设置为 true。 - - 15. `escape` - 转义符。用于转义在csv字段中出现的与包围符相同的字符。例如数据为"a,'b,'c'",包围符为"'",希望"b,'c被作为一个字段解析,则需要指定单字节转义符,例如"\",然后将数据修改为"a,'b,\'c'"。 - -- `FROM data_source [data_source_properties]` - - 数据源的类型。当前支持: - - ```text - FROM KAFKA - ( - "key1" = "val1", - "key2" = "val2" - ) - ``` - - `data_source_properties` 支持如下数据源属性: - - 1. `kafka_broker_list` - - Kafka 的 broker 连接信息。格式为 ip:host。多个 broker 之间以逗号分隔。 - - `"kafka_broker_list" = "broker1:9092,broker2:9092"` - - 2. `kafka_topic` - - 指定要订阅的 Kafka 的 topic。 - - `"kafka_topic" = "my_topic"` - - 3. `kafka_partitions/kafka_offsets` - - 指定需要订阅的 kafka partition,以及对应的每个 partition 的起始 offset。如果指定时间,则会从大于等于该时间的最近一个 offset 处开始消费。 - - offset 可以指定从大于等于 0 的具体 offset,或者: - - - `OFFSET_BEGINNING`: 从有数据的位置开始订阅。 - - `OFFSET_END`: 从末尾开始订阅。 - - 时间格式,如:"2021-05-22 11:00:00" - - 如果没有指定,则默认从 `OFFSET_END` 开始订阅 topic 下的所有 partition。 - - ```text - "kafka_partitions" = "0,1,2,3", - "kafka_offsets" = "101,0,OFFSET_BEGINNING,OFFSET_END" - ``` - - ```text - "kafka_partitions" = "0,1,2,3", - "kafka_offsets" = "2021-05-22 11:00:00,2021-05-22 11:00:00,2021-05-22 11:00:00" - ``` - - 注意,时间格式不能和 OFFSET 格式混用。 - - 4. `property` - - 指定自定义 kafka 参数。功能等同于 kafka shell 中 "--property" 参数。 - - 当参数的 value 为一个文件时,需要在 value 前加上关键词:"FILE:"。 - - 关于如何创建文件,请参阅 [CREATE FILE](../../../Data-Definition-Statements/Create/CREATE-FILE) 命令文档。 - - 更多支持的自定义参数,请参阅 librdkafka 的官方 CONFIGURATION 文档中,client 端的配置项。如: - - ```text - "property.client.id" = "12345", - "property.ssl.ca.location" = "FILE:ca.pem" - ``` - - 1. 使用 SSL 连接 Kafka 时,需要指定以下参数: - - ```text - "property.security.protocol" = "ssl", - "property.ssl.ca.location" = "FILE:ca.pem", - "property.ssl.certificate.location" = "FILE:client.pem", - "property.ssl.key.location" = "FILE:client.key", - "property.ssl.key.password" = "abcdefg" - ``` - - 其中: - - `property.security.protocol` 和 `property.ssl.ca.location` 为必须,用于指明连接方式为 SSL,以及 CA 证书的位置。 - - 如果 Kafka server 端开启了 client 认证,则还需设置: - - ```text - "property.ssl.certificate.location" - "property.ssl.key.location" - "property.ssl.key.password" - ``` - - 分别用于指定 client 的 public key,private key 以及 private key 的密码。 - - 2. 指定 kafka partition 的默认起始 offset - - 如果没有指定 `kafka_partitions/kafka_offsets`,默认消费所有分区。 - - 此时可以指定 `kafka_default_offsets` 指定起始 offset。默认为 `OFFSET_END`,即从末尾开始订阅。 - - 示例: - - ```text - "property.kafka_default_offsets" = "OFFSET_BEGINNING" - ``` -- comment - - 例行导入任务的注释信息。 -## 举例 - -1. 为 example_db 的 example_tbl 创建一个名为 test1 的 Kafka 例行导入任务。指定列分隔符和 group.id 和 client.id,并且自动默认消费所有分区,且从有数据的位置(OFFSET_BEGINNING)开始订阅 - - - - ```sql - CREATE ROUTINE LOAD example_db.test1 ON example_tbl - COLUMNS TERMINATED BY ",", - COLUMNS(k1, k2, k3, v1, v2, v3 = k1 * 100) - PROPERTIES - ( - "desired_concurrent_number"="3", - "max_batch_interval" = "20", - "max_batch_rows" = "300000", - "max_batch_size" = "209715200", - "strict_mode" = "false" - ) - FROM KAFKA - ( - "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", - "kafka_topic" = "my_topic", - "property.group.id" = "xxx", - "property.client.id" = "xxx", - "property.kafka_default_offsets" = "OFFSET_BEGINNING" - ); - ``` - -2. 为 example_db 创建一个名为 test1 的 Kafka 例行动态多表导入任务。指定列分隔符和 group.id 和 client.id,并且自动默认消费所有分区, - 且从有数据的位置(OFFSET_BEGINNING)开始订阅 - - 我们假设需要将 Kafka 中的数据导入到 example_db 中的 test1 以及 test2 表中,我们创建了一个名为 test1 的例行导入任务,同时将 test1 和 - test2 中的数据写到一个名为 `my_topic` 的 Kafka 的 topic 中,这样就可以通过一个例行导入任务将 Kafka 中的数据导入到两个表中。 - - ```sql - CREATE ROUTINE LOAD example_db.test1 - PROPERTIES - ( - "desired_concurrent_number"="3", - "max_batch_interval" = "20", - "max_batch_rows" = "300000", - "max_batch_size" = "209715200", - "strict_mode" = "false" - ) - FROM KAFKA - ( - "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", - "kafka_topic" = "my_topic", - "property.group.id" = "xxx", - "property.client.id" = "xxx", - "property.kafka_default_offsets" = "OFFSET_BEGINNING" - ); - ``` - -3. 为 example_db 的 example_tbl 创建一个名为 test1 的 Kafka 例行导入任务。导入任务为严格模式。 - - - - ```sql - CREATE ROUTINE LOAD example_db.test1 ON example_tbl - COLUMNS(k1, k2, k3, v1, v2, v3 = k1 * 100), - PRECEDING FILTER k1 = 1, - WHERE k1 > 100 and k2 like "%doris%" - PROPERTIES - ( - "desired_concurrent_number"="3", - "max_batch_interval" = "20", - "max_batch_rows" = "300000", - "max_batch_size" = "209715200", - "strict_mode" = "true" - ) - FROM KAFKA - ( - "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", - "kafka_topic" = "my_topic", - "kafka_partitions" = "0,1,2,3", - "kafka_offsets" = "101,0,0,200" - ); - ``` - -4. 通过 SSL 认证方式,从 Kafka 集群导入数据。同时设置 client.id 参数。导入任务为非严格模式,时区为 Africa/Abidjan - - - - ```sql - CREATE ROUTINE LOAD example_db.test1 ON example_tbl - COLUMNS(k1, k2, k3, v1, v2, v3 = k1 * 100), - WHERE k1 > 100 and k2 like "%doris%" - PROPERTIES - ( - "desired_concurrent_number"="3", - "max_batch_interval" = "20", - "max_batch_rows" = "300000", - "max_batch_size" = "209715200", - "strict_mode" = "false", - "timezone" = "Africa/Abidjan" - ) - FROM KAFKA - ( - "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", - "kafka_topic" = "my_topic", - "property.security.protocol" = "ssl", - "property.ssl.ca.location" = "FILE:ca.pem", - "property.ssl.certificate.location" = "FILE:client.pem", - "property.ssl.key.location" = "FILE:client.key", - "property.ssl.key.password" = "abcdefg", - "property.client.id" = "my_client_id" - ); - ``` - -5. 导入 Json 格式数据。默认使用 Json 中的字段名作为列名映射。指定导入 0,1,2 三个分区,起始 offset 都为 0 - - - - ```sql - CREATE ROUTINE LOAD example_db.test_json_label_1 ON table1 - COLUMNS(category,price,author) - PROPERTIES - ( - "desired_concurrent_number"="3", - "max_batch_interval" = "20", - "max_batch_rows" = "300000", - "max_batch_size" = "209715200", - "strict_mode" = "false", - "format" = "json" - ) - FROM KAFKA - ( - "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", - "kafka_topic" = "my_topic", - "kafka_partitions" = "0,1,2", - "kafka_offsets" = "0,0,0" - ); - ``` - -6. 导入 Json 数据,并通过 Jsonpaths 抽取字段,并指定 Json 文档根节点 - - - - ```sql - CREATE ROUTINE LOAD example_db.test1 ON example_tbl - COLUMNS(category, author, price, timestamp, dt=from_unixtime(timestamp, '%Y%m%d')) - PROPERTIES - ( - "desired_concurrent_number"="3", - "max_batch_interval" = "20", - "max_batch_rows" = "300000", - "max_batch_size" = "209715200", - "strict_mode" = "false", - "format" = "json", - "jsonpaths" = "[\"$.category\",\"$.author\",\"$.price\",\"$.timestamp\"]", - "json_root" = "$.RECORDS" - "strip_outer_array" = "true" - ) - FROM KAFKA - ( - "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", - "kafka_topic" = "my_topic", - "kafka_partitions" = "0,1,2", - "kafka_offsets" = "0,0,0" - ); - ``` - -7. 为 example_db 的 example_tbl 创建一个名为 test1 的 Kafka 例行导入任务。并且使用条件过滤。 - - - - ```sql - CREATE ROUTINE LOAD example_db.test1 ON example_tbl - WITH MERGE - COLUMNS(k1, k2, k3, v1, v2, v3), - WHERE k1 > 100 and k2 like "%doris%", - DELETE ON v3 >100 - PROPERTIES - ( - "desired_concurrent_number"="3", - "max_batch_interval" = "20", - "max_batch_rows" = "300000", - "max_batch_size" = "209715200", - "strict_mode" = "false" - ) - FROM KAFKA - ( - "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", - "kafka_topic" = "my_topic", - "kafka_partitions" = "0,1,2,3", - "kafka_offsets" = "101,0,0,200" - ); - ``` - -8. 导入数据到含有 sequence 列的 Unique Key 模型表中 - - - - ```sql - CREATE ROUTINE LOAD example_db.test_job ON example_tbl - COLUMNS TERMINATED BY ",", - COLUMNS(k1,k2,source_sequence,v1,v2), - ORDER BY source_sequence - PROPERTIES - ( - "desired_concurrent_number"="3", - "max_batch_interval" = "30", - "max_batch_rows" = "300000", - "max_batch_size" = "209715200" - ) FROM KAFKA - ( - "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", - "kafka_topic" = "my_topic", - "kafka_partitions" = "0,1,2,3", - "kafka_offsets" = "101,0,0,200" - ); - ``` - -9. 从指定的时间点开始消费 - - - - ```sql - CREATE ROUTINE LOAD example_db.test_job ON example_tbl - PROPERTIES - ( - "desired_concurrent_number"="3", - "max_batch_interval" = "30", - "max_batch_rows" = "300000", - "max_batch_size" = "209715200" - ) FROM KAFKA - ( - "kafka_broker_list" = "broker1:9092,broker2:9092", - "kafka_topic" = "my_topic", - "kafka_default_offsets" = "2021-05-21 10:00:00" - ); - ``` - -### Keywords - - CREATE, ROUTINE, LOAD, CREATE LOAD - -### Best Practice - -关于指定消费的 Partition 和 Offset - -Doris 支持指定 Partition 和 Offset 开始消费,还支持了指定时间点进行消费的功能。这里说明下对应参数的配置关系。 - -有三个相关参数: - -- `kafka_partitions`:指定待消费的 partition 列表,如:"0, 1, 2, 3"。 -- `kafka_offsets`:指定每个分区的起始 offset,必须和 `kafka_partitions` 列表个数对应。如:"1000, 1000, 2000, 2000" -- `property.kafka_default_offsets:指定分区默认的起始 offset。 - -在创建导入作业时,这三个参数可以有以下组合: - -| 组合 | `kafka_partitions` | `kafka_offsets` | `property.kafka_default_offsets` | 行为 | -| ---- | ------------------ | --------------- | ------------------------------- | ------------------------------------------------------------ | -| 1 | No | No | No | 系统会自动查找 topic 对应的所有分区并从 OFFSET_END 开始消费 | -| 2 | No | No | Yes | 系统会自动查找 topic 对应的所有分区并从 default offset 指定的位置开始消费 | -| 3 | Yes | No | No | 系统会从指定分区的 OFFSET_END 开始消费 | -| 4 | Yes | Yes | No | 系统会从指定分区的指定 offset 处开始消费 | -| 5 | Yes | No | Yes | 系统会从指定分区,default offset 指定的位置开始消费 | - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CREATE-SYNC-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CREATE-SYNC-JOB.md deleted file mode 100644 index cff9cc1c29c7c..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/CREATE-SYNC-JOB.md +++ /dev/null @@ -1,161 +0,0 @@ ---- -{ - "title": "CREATE-SYNC-JOB", - "language": "zh-CN" -} ---- - - - -## CREATE-SYNC-JOB - -### Name - -CREATE SYNC JOB - -## 描述 - -数据同步(Sync Job)功能,支持用户提交一个常驻的数据同步作业,通过从指定的远端地址读取Binlog日志,增量同步用户在Mysql数据库的对数据更新操作的CDC(Change Data Capture)功能。 - -目前数据同步作业只支持对接Canal,从Canal Server上获取解析好的Binlog数据,导入到Doris内。 - -用户可通过 [SHOW SYNC JOB](../../Show-Statements/SHOW-SYNC-JOB.md) 查看数据同步作业状态。 - -语法: - -```sql -CREATE SYNC [db.]job_name - ( - channel_desc, - channel_desc - ... - ) -binlog_desc -``` - -1. `job_name` - - 同步作业名称,是作业在当前数据库内的唯一标识,相同`job_name`的作业只能有一个在运行。 - -2. `channel_desc` - - 作业下的数据通道,用来描述mysql源表到doris目标表的映射关系。 - - 语法: - - ```sql - FROM mysql_db.src_tbl INTO des_tbl - [columns_mapping] - ``` - - 1. `mysql_db.src_tbl` - - 指定mysql端的数据库和源表。 - - 2. `des_tbl` - - 指定doris端的目标表,只支持Unique表,且需开启表的batch delete功能(开启方法请看help alter table的'批量删除功能')。 - - 4. `column_mapping` - - 指定mysql源表和doris目标表的列之间的映射关系。如果不指定,FE会默认源表和目标表的列按顺序一一对应。 - - 不支持 col_name = expr 的形式表示列。 - - 示例: - - ``` - 假设目标表列为(k1, k2, v1), - - 改变列k1和k2的顺序 - (k2, k1, v1) - - 忽略源数据的第四列 - (k2, k1, v1, dummy_column) - ``` - -3. `binlog_desc` - - 用来描述远端数据源,目前仅支持canal一种。 - - 语法: - - ```sql - FROM BINLOG - ( - "key1" = "value1", - "key2" = "value2" - ) - ``` - - 1. Canal 数据源对应的属性,以`canal.`为前缀 - - 1. canal.server.ip: canal server的地址 - 2. canal.server.port: canal server的端口 - 3. canal.destination: instance的标识 - 4. canal.batchSize: 获取的batch大小的最大值,默认8192 - 5. canal.username: instance的用户名 - 6. canal.password: instance的密码 - 7. canal.debug: 可选,设置为true时,会将batch和每一行数据的详细信息都打印出来 - -## 举例 - -1. 简单为 `test_db` 的 `test_tbl` 创建一个名为 `job1` 的数据同步作业,连接本地的Canal服务器,对应Mysql源表 `mysql_db1.tbl1`。 - - ```SQL - CREATE SYNC `test_db`.`job1` - ( - FROM `mysql_db1`.`tbl1` INTO `test_tbl ` - ) - FROM BINLOG - ( - "type" = "canal", - "canal.server.ip" = "127.0.0.1", - "canal.server.port" = "11111", - "canal.destination" = "example", - "canal.username" = "", - "canal.password" = "" - ); - ``` - -2. 为 `test_db` 的多张表创建一个名为 `job1` 的数据同步作业,一一对应多张Mysql源表,并显式的指定列映射。 - - ```SQL - CREATE SYNC `test_db`.`job1` - ( - FROM `mysql_db`.`t1` INTO `test1` (k1, k2, v1), - FROM `mysql_db`.`t2` INTO `test2` (k3, k4, v2) - ) - FROM BINLOG - ( - "type" = "canal", - "canal.server.ip" = "xx.xxx.xxx.xx", - "canal.server.port" = "12111", - "canal.destination" = "example", - "canal.username" = "username", - "canal.password" = "password" - ); - ``` - -### Keywords - - CREATE, SYNC, JOB - -### Best Practice diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/MULTI-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/MULTI-LOAD.md deleted file mode 100644 index 538b9a80edd77..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/MULTI-LOAD.md +++ /dev/null @@ -1,123 +0,0 @@ ---- -{ - "title": "MULTI-LOAD", - "language": "zh-CN" -} ---- - - - -## MULTI-LOAD - -### Name - -MULTI LOAD - -## 描述 - -用户通过 HTTP 协议提交多个导入作业。Multi Load 可以保证多个导入作业的原子生效 - -``` -Syntax: - curl --location-trusted -u user:passwd -XPOST http://host:port/api/{db}/_multi_start?label=xxx - curl --location-trusted -u user:passwd -T data.file http://host:port/api/{db}/{table1}/_load?label=xxx\&sub_label=yyy - curl --location-trusted -u user:passwd -T data.file http://host:port/api/{db}/{table2}/_load?label=xxx\&sub_label=zzz - curl --location-trusted -u user:passwd -XPOST http://host:port/api/{db}/_multi_commit?label=xxx - curl --location-trusted -u user:passwd -XPOST http://host:port/api/{db}/_multi_desc?label=xxx - -'MULTI LOAD'在'MINI LOAD'的基础上,可以支持用户同时向多个表进行导入,具体的命令如上面所示 -'/api/{db}/_multi_start' 开始一个多表导入任务 -'/api/{db}/{table}/_load' 向一个导入任务添加一个要导入的表,与'MINI LOAD'的主要区别是,需要传入'sub_label'参数 -'/api/{db}/_multi_commit' 提交整个多表导入任务,后台开始进行处理 -'/api/{db}/_multi_abort' 放弃一个多表导入任务 -'/api/{db}/_multi_desc' 可以展示某个多表导入任务已经提交的作业数 - -HTTP协议相关说明 - 权限认证 当前 Doris 使用http的Basic方式权限认证。所以在导入的时候需要指定用户名密码 - 这种方式是明文传递密码的,鉴于我们当前都是内网环境。。。 - - Expect Doris 需要发送过来的http请求,需要有'Expect'头部信息,内容为'100-continue' - 为什么呢?因为我们需要将请求进行redirect,那么必须在传输数据内容之前, - 这样可以避免造成数据的多次传输,从而提高效率。 - - Content-Length Doris 需要在发送请求是带有'Content-Length'这个头部信息。如果发送的内容比 - 'Content-Length'要少,那么Palo认为传输出现问题,则提交此次任务失败。 - NOTE: 如果,发送的数据比'Content-Length'要多,那么 Doris 只读取'Content-Length' - 长度的内容,并进行导入 - -参数说明: - user: 用户如果是在default_cluster中的,user即为user_name。否则为user_name@cluster_name。 - - label: 用于指定这一批次导入的label号,用于后期进行作业状态查询等。 - 这个参数是必须传入的。 - - sub_label: 用于指定一个多表导入任务内部的子版本号。对于多表导入的load, 这个参数是必须传入的。 - - columns: 用于描述导入文件中对应的列名字。 - 如果不传入,那么认为文件中的列顺序与建表的顺序一致, - 指定的方式为逗号分隔,例如:columns=k1,k2,k3,k4 - - column_separator: 用于指定列与列之间的分隔符,默认的为'\t' - NOTE: 需要进行url编码,譬如需要指定'\t'为分隔符, - 那么应该传入'column_separator=%09' - - max_filter_ratio: 用于指定允许过滤不规范数据的最大比例,默认是0,不允许过滤 - 自定义指定应该如下:'max_filter_ratio=0.2',含义是允许20%的错误率 - 在'_multi_start'时传入有效果 - -NOTE: - 1. 此种导入方式当前是在一台机器上完成导入工作,因而不宜进行数据量较大的导入工作。 - 建议导入数据量不要超过1GB - - 2. 当前无法使用`curl -T "{file1, file2}"`这样的方式提交多个文件,因为curl是将其拆成多个 - 请求发送的,多个请求不能共用一个label号,所以无法使用 - - 3. 支持类似streaming的方式使用curl来向 Doris 中导入数据,但是,只有等这个streaming结束后 Doris - 才会发生真实的导入行为,这中方式数据量也不能过大。 -``` - -## 举例 - -``` -1. 将本地文件'testData1'中的数据导入到数据库'testDb'中'testTbl1'的表,并且 -把'testData2'的数据导入到'testDb'中的表'testTbl2'(用户是defalut_cluster中的) - curl --location-trusted -u root -XPOST http://host:port/api/testDb/_multi_start?label=123 - curl --location-trusted -u root -T testData1 http://host:port/api/testDb/testTbl1/_load?label=123\&sub_label=1 - curl --location-trusted -u root -T testData2 http://host:port/api/testDb/testTbl2/_load?label=123\&sub_label=2 - curl --location-trusted -u root -XPOST http://host:port/api/testDb/_multi_commit?label=123 - -2. 多表导入中途放弃(用户是defalut_cluster中的) - curl --location-trusted -u root -XPOST http://host:port/api/testDb/_multi_start?label=123 - curl --location-trusted -u root -T testData1 http://host:port/api/testDb/testTbl1/_load?label=123\&sub_label=1 - curl --location-trusted -u root -XPOST http://host:port/api/testDb/_multi_abort?label=123 - -3. 多表导入查看已经提交多少内容(用户是defalut_cluster中的) - curl --location-trusted -u root -XPOST http://host:port/api/testDb/_multi_start?label=123 - curl --location-trusted -u root -T testData1 http://host:port/api/testDb/testTbl1/_load?label=123\&sub_label=1 - curl --location-trusted -u root -XPOST http://host:port/api/testDb/_multi_desc?label=123 -``` - -### Keywords - -``` -MULTI, MINI, LOAD -``` - -### Best Practice diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/MYSQL-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/MYSQL-LOAD.md deleted file mode 100644 index de46c54ff1162..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/MYSQL-LOAD.md +++ /dev/null @@ -1,173 +0,0 @@ ---- -{ - "title": "MYSQL-LOAD", - "language": "zh-CN" -} ---- - - - -## MYSQL-LOAD - -### Name - - MYSQL LOAD - -## 描述 - -mysql-load: 使用 MySql 客户端导入本地数据 - -``` -LOAD DATA -[LOCAL] -INFILE 'file_name' -INTO TABLE tbl_name -[PARTITION (partition_name [, partition_name] ...)] -[COLUMNS TERMINATED BY 'string'] -[LINES TERMINATED BY 'string'] -[IGNORE number {LINES | ROWS}] -[(col_name_or_user_var [, col_name_or_user_var] ...)] -[SET (col_name={expr | DEFAULT} [, col_name={expr | DEFAULT}] ...)] -[PROPERTIES (key1 = value1 [, key2=value2]) ] -``` - -该语句用于向指定的 table 导入数据,与普通 Load 区别是,这种导入方式是同步导入。 - -这种导入方式仍然能够保证一批导入任务的原子性,要么全部数据导入成功,要么全部失败。 - -1. MySQL Load 以语法`LOAD DATA`开头,无须指定 LABEL -2. 指定`LOCAL`表示读取客户端文件。不指定表示读取 FE 服务端本地文件。导入 FE 本地文件的功能默认是关闭的,需要在 FE 节点上设置`mysql_load_server_secure_path`来指定安全路径,才能打开该功能。 -3. `INFILE`内填写本地文件路径,可以是相对路径,也可以是绝对路径。目前只支持单个文件,不支持多个文件 -4. `INTO TABLE`的表名可以指定数据库名,如案例所示。也可以省略,则会使用当前用户所在的数据库。 -5. `PARTITION`语法支持指定分区导入 -6. `COLUMNS TERMINATED BY`指定列分隔符 -7. `LINES TERMINATED BY`指定行分隔符 -8. `IGNORE num LINES`用户跳过 CSV 的表头,可以跳过任意行数。该语法也可以用`IGNORE num ROWS`代替 -9. 列映射语法,具体参数详见[导入的数据转换](../../../../data-operate/import/import-way/mysql-load-manual.md) 的列映射章节 -10. `PROPERTIES`参数配置,详见下文 - -### PROPERTIES - -1. max_filter_ratio:最大容忍可过滤(数据不规范等原因)的数据比例。默认零容忍。 - -2. timeout: 指定导入的超时时间。单位秒。默认是 600 秒。可设置范围为 1 秒 ~ 259200 秒。 - -3. strict_mode: 用户指定此次导入是否开启严格模式,默认为关闭。 - -4. timezone: 指定本次导入所使用的时区。默认为东八区。该参数会影响所有导入涉及的和时区有关的函数结果。 - -5. exec_mem_limit: 导入内存限制。默认为 2GB。单位为字节。 - -6. trim_double_quotes: 布尔类型,默认值为 false,为 true 时表示裁剪掉导入文件每个字段最外层的双引号。 - -7. enclose: 包围符。当 csv 数据字段中含有行分隔符或列分隔符时,为防止意外截断,可指定单字节字符作为包围符起到保护作用。例如列分隔符为",",包围符为"'",数据为"a,'b,c'",则"b,c"会被解析为一个字段。注意:当 enclose 设置为`"`时,trim_double_quotes 一定要设置为 true。 - -8. escape: 转义符。用于转义在 csv 字段中出现的与包围符相同的字符。例如数据为"a,'b,'c'",包围符为"'",希望"b,'c 被作为一个字段解析,则需要指定单字节转义符,例如"\",然后将数据修改为"a,'b,\'c'"。 - -## 举例 - -1. 将客户端本地文件'testData'中的数据导入到数据库'testDb'中'testTbl'的表。指定超时时间为 100 秒 - - ```sql - LOAD DATA LOCAL - INFILE 'testData' - INTO TABLE testDb.testTbl - PROPERTIES ("timeout"="100") - ``` - -2. 将服务端本地文件'/root/testData'(需设置 FE 配置`mysql_load_server_secure_path`为`/root`) 中的数据导入到数据库'testDb'中'testTbl'的表。指定超时时间为 100 秒 - - ```sql - LOAD DATA - INFILE '/root/testData' - INTO TABLE testDb.testTbl - PROPERTIES ("timeout"="100") - ``` - -3. 将客户端本地文件'testData'中的数据导入到数据库'testDb'中'testTbl'的表,允许 20% 的错误率 - - ```sql - LOAD DATA LOCAL - INFILE 'testData' - INTO TABLE testDb.testTbl - PROPERTIES ("max_filter_ratio"="0.2") - ``` - -4. 将客户端本地文件'testData'中的数据导入到数据库'testDb'中'testTbl'的表,允许 20% 的错误率,并且指定文件的列名 - - ```sql - LOAD DATA LOCAL - INFILE 'testData' - INTO TABLE testDb.testTbl - (k2, k1, v1) - PROPERTIES ("max_filter_ratio"="0.2") - ``` - -5. 将本地文件'testData'中的数据导入到数据库'testDb'中'testTbl'的表中的 p1, p2 分区,允许 20% 的错误率。 - - ```sql - LOAD DATA LOCAL - INFILE 'testData' - INTO TABLE testDb.testTbl - PARTITION (p1, p2) - PROPERTIES ("max_filter_ratio"="0.2") - ``` - -6. 将本地行分隔符为`0102`,列分隔符为`0304`的 CSV 文件'testData'中的数据导入到数据库'testDb'中'testTbl'的表中。 - - ```sql - LOAD DATA LOCAL - INFILE 'testData' - INTO TABLE testDb.testTbl - COLUMNS TERMINATED BY '0304' - LINES TERMINATED BY '0102' - ``` - -7. 将本地文件'testData'中的数据导入到数据库'testDb'中'testTbl'的表中的 p1, p2 分区,并跳过前面 3 行。 - - ```sql - LOAD DATA LOCAL - INFILE 'testData' - INTO TABLE testDb.testTbl - PARTITION (p1, p2) - IGNORE 1 LINES - ``` - -8. 导入数据进行严格模式过滤,并设置时区为 Africa/Abidjan - - ```sql - LOAD DATA LOCAL - INFILE 'testData' - INTO TABLE testDb.testTbl - PROPERTIES ("strict_mode"="true", "timezone"="Africa/Abidjan") - ``` - -9. 导入数据进行限制导入内存为 10GB, 并在 10 分钟超时 - - ```sql - LOAD DATA LOCAL - INFILE 'testData' - INTO TABLE testDb.testTbl - PROPERTIES ("exec_mem_limit"="10737418240", "timeout"="600") - ``` - -### Keywords - - MYSQL, LOAD diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/PAUSE-ROUTINE-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/PAUSE-ROUTINE-LOAD.md deleted file mode 100644 index 6dec3491b27b2..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/PAUSE-ROUTINE-LOAD.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -{ - "title": "PAUSE-ROUTINE-LOAD", - "language": "zh-CN" -} ---- - - - -## PAUSE-ROUTINE-LOAD - -### Name - -PAUSE ROUTINE LOAD - -## 描述 - -用于暂停一个 Routine Load 作业。被暂停的作业可以通过 RESUME 命令重新运行。 - -```sql -PAUSE [ALL] ROUTINE LOAD FOR job_name -``` - -## 举例 - -1. 暂停名称为 test1 的例行导入作业。 - - ```sql - PAUSE ROUTINE LOAD FOR test1; - ``` - -2. 暂停所有例行导入作业。 - - ```sql - PAUSE ALL ROUTINE LOAD; - ``` - -### Keywords - - PAUSE, ROUTINE, LOAD - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/PAUSE-SYNC-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/PAUSE-SYNC-JOB.md deleted file mode 100644 index 116c6ce163f71..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/PAUSE-SYNC-JOB.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "PAUSE-SYNC-JOB", - "language": "zh-CN" -} ---- - - - -## PAUSE-SYNC-JOB - -### Name - -PAUSE SYNC JOB - -## 描述 - -通过 `job_name` 暂停一个数据库内正在运行的常驻数据同步作业,被暂停的作业将停止同步数据,保持消费的最新位置,直到被用户恢复。 - -语法: - -```sql -PAUSE SYNC JOB [db.]job_name -``` - -## 举例 - -1. 暂停名称为 `job_name` 的数据同步作业。 - - ```sql - PAUSE SYNC JOB `job_name`; - ``` - -### Keywords - - PAUSE, SYNC, JOB - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/RESUME-ROUTINE-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/RESUME-ROUTINE-LOAD.md deleted file mode 100644 index 2a4d829f18e66..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/RESUME-ROUTINE-LOAD.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -{ - "title": "RESUME-ROUTINE-LOAD", - "language": "zh-CN" -} ---- - - - -## RESUME-ROUTINE-LOAD - -### Name - -RESUME ROUTINE LOAD - -## 描述 - -用于重启一个被暂停的 Routine Load 作业。重启的作业,将继续从之前已消费的 offset 继续消费。 - -```sql -RESUME [ALL] ROUTINE LOAD FOR job_name -``` - -## 举例 - -1. 重启名称为 test1 的例行导入作业。 - - ```sql - RESUME ROUTINE LOAD FOR test1; - ``` - -2. 重启所有例行导入作业。 - - ```sql - RESUME ALL ROUTINE LOAD; - ``` - -### Keywords - - RESUME, ROUTINE, LOAD - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/RESUME-SYNC-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/RESUME-SYNC-JOB.md deleted file mode 100644 index 764b608148f18..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/RESUME-SYNC-JOB.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "RESUME-SYNC-JOB", - "language": "zh-CN" -} ---- - - - -## RESUME-SYNC-JOB - -### Name - -RESUME SYNC JOB - -## 描述 - -通过 `job_name`恢复一个当前数据库已被暂停的常驻数据同步作业,作业将从上一次被暂停前最新的位置继续同步数据。 - -语法: - -```sql -RESUME SYNC JOB [db.]job_name -``` - -## 举例 - -1. 恢复名称为 `job_name` 的数据同步作业 - - ```sql - RESUME SYNC JOB `job_name`; - ``` - -### Keywords - - RESUME, SYNC, LOAD - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/STOP-ROUTINE-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/STOP-ROUTINE-LOAD.md deleted file mode 100644 index 2e072be3982cf..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/STOP-ROUTINE-LOAD.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -{ - "title": "STOP-ROUTINE-LOAD", - "language": "zh-CN" -} ---- - - - -## STOP-ROUTINE-LOAD - -### Name - -STOP ROUTINE LOAD - -## 描述 - -用户停止一个 Routine Load 作业。被停止的作业无法再重新运行。 - -```sql -STOP ROUTINE LOAD FOR job_name; -``` - -## 举例 - -1. 停止名称为 test1 的例行导入作业。 - - ```sql - STOP ROUTINE LOAD FOR test1; - ``` - -### Keywords - - STOP, ROUTINE, LOAD - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/STOP-SYNC-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/STOP-SYNC-JOB.md deleted file mode 100644 index 2b3723015e475..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/STOP-SYNC-JOB.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "STOP-SYNC-JOB", - "language": "zh-CN" -} ---- - - - -## STOP-SYNC-JOB - -### Name - -STOP SYNC JOB - -## 描述 - -通过 `job_name` 停止一个数据库内非停止状态的常驻数据同步作业。 - -语法: - -```sql -STOP SYNC JOB [db.]job_name -``` - -## 举例 - -1. 停止名称为 `job_name` 的数据同步作业 - - ```sql - STOP SYNC JOB `job_name`; - ``` - -### Keywords - - STOP, SYNC, JOB - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/STREAM-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/STREAM-LOAD.md deleted file mode 100644 index ed674353a2270..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Load/STREAM-LOAD.md +++ /dev/null @@ -1,461 +0,0 @@ ---- -{ - "title": "STREAM-LOAD", - "language": "zh-CN" -} ---- - - - -## STREAM-LOAD - -### Name - -STREAM LOAD - -## 描述 - -stream-load: load data to table in streaming - -``` -curl --location-trusted -u user:passwd [-H ""...] -T data.file -XPUT http://fe_host:http_port/api/{db}/{table}/_stream_load -``` - -该语句用于向指定的 table 导入数据,与普通 Load 区别是,这种导入方式是同步导入。 - -这种导入方式仍然能够保证一批导入任务的原子性,要么全部数据导入成功,要么全部失败。 - -该操作会同时更新和此 base table 相关的 rollup table 的数据。 - -这是一个同步操作,整个数据导入工作完成后返回给用户导入结果。 - -当前支持 HTTP chunked 与非 chunked 上传两种方式,对于非 chunked 方式,必须要有 Content-Length 来标示上传内容长度,这样能够保证数据的完整性。 - -另外,用户最好设置 Expect Header 字段内容 100-continue,这样可以在某些出错场景下避免不必要的数据传输。 - -参数介绍: - 用户可以通过 HTTP 的 Header 部分来传入导入参数 - -1. label: 一次导入的标签,相同标签的数据无法多次导入。用户可以通过指定 Label 的方式来避免一份数据重复导入的问题。 - - 当前 Doris 内部保留 30 分钟内最近成功的 label。 - -2. column_separator:用于指定导入文件中的列分隔符,默认为\t。如果是不可见字符,则需要加\x作为前缀,使用十六进制来表示分隔符。 - - 如 hive 文件的分隔符\x01,需要指定为-H "column_separator:\x01"。 - - 可以使用多个字符的组合作为列分隔符。 - -3. line_delimiter:用于指定导入文件中的换行符,默认为\n。可以使用做多个字符的组合作为换行符。 - -4. columns:用于指定导入文件中的列和 table 中的列的对应关系。如果源文件中的列正好对应表中的内容,那么是不需要指定这个字段的内容的。 - - 如果源文件与表 schema 不对应,那么需要这个字段进行一些数据转换。这里有两种形式 column,一种是直接对应导入文件中的字段,直接使用字段名表示; - - 一种是衍生列,语法为 `column_name` = expression。举几个例子帮助理解。 - - 例 1: 表中有 3 个列“c1, c2, c3”,源文件中的三个列一次对应的是"c3,c2,c1"; 那么需要指定-H "columns: c3, c2, c1" - - 例2: 表中有3个列“c1, c2, c3", 源文件中前三列依次对应,但是有多余1列;那么需要指定-H "columns: c1, c2, c3, xxx"; - - 最后一个列随意指定个名称占位即可 - - 例3: 表中有3个列“year, month, day"三个列,源文件中只有一个时间列,为”2018-06-01 01:02:03“格式; - - 那么可以指定-H "columns: col, year = year(col), month=month(col), day=day(col)"完成导入 - -5. where: 用于抽取部分数据。用户如果有需要将不需要的数据过滤掉,那么可以通过设定这个选项来达到。 - - 例 1: 只导入大于 k1 列等于 20180601 的数据,那么可以在导入时候指定-H "where: k1 = 20180601" - -6. max_filter_ratio:最大容忍可过滤(数据不规范等原因)的数据比例。默认零容忍。数据不规范不包括通过 where 条件过滤掉的行。 - -7. partitions: 用于指定这次导入所设计的 partition。如果用户能够确定数据对应的 partition,推荐指定该项。不满足这些分区的数据将被过滤掉。 - - 比如指定导入到 p1, p2 分区,-H "partitions: p1, p2" - -8. timeout: 指定导入的超时时间。单位秒。默认是 600 秒。可设置范围为 1 秒 ~ 259200 秒。 - -9. strict_mode: 用户指定此次导入是否开启严格模式,默认为关闭。开启方式为 -H "strict_mode: true"。 - -10. timezone: 指定本次导入所使用的时区。默认为东八区。在本次导入事务中,该变量起到了替代 session variable `time_zone` 的作用。详情请见[最佳实践](#best-practice)中“涉及时区的导入”一节。 - -11. exec_mem_limit: 导入内存限制。默认为 2GB。单位为字节。 - -12. format: 指定导入数据格式,支持 csv、json、csv_with_names(支持 csv 文件行首过滤)、csv_with_names_and_types(支持 csv 文件前两行过滤)、parquet、orc,默认是 csv。 - -13. jsonpaths: 导入 json 方式分为:简单模式和匹配模式。 - - 简单模式:没有设置 jsonpaths 参数即为简单模式,这种模式下要求 json 数据是对象类型,例如: - - ``` - {"k1":1, "k2":2, "k3":"hello"},其中 k1,k2,k3 是列名字。 - ``` - 匹配模式:用于 json 数据相对复杂,需要通过 jsonpaths 参数匹配对应的 value。 - -14. strip_outer_array: 布尔类型,为 true 表示 json 数据以数组对象开始且将数组对象中进行展平,默认值是 false。例如: - ``` - [ - {"k1" : 1, "v1" : 2}, - {"k1" : 3, "v1" : 4} - ] - 当strip_outer_array为true,最后导入到doris中会生成两行数据。 - ``` - -15. json_root: json_root 为合法的 jsonpath 字符串,用于指定 json document 的根节点,默认值为""。 - -16. merge_type: 数据的合并类型,一共支持三种类型 APPEND、DELETE、MERGE 其中,APPEND 是默认值,表示这批数据全部需要追加到现有数据中,DELETE 表示删除与这批数据 key 相同的所有行,MERGE 语义 需要与 DELETE 条件联合使用,表示满足 DELETE 条件的数据按照 DELETE 语义处理其余的按照 APPEND 语义处理,示例:`-H "merge_type: MERGE" -H "delete: flag=1"` - -17. delete: 仅在 MERGE 下有意义,表示数据的删除条件 - -18. function_column.sequence_col: 只适用于 UNIQUE_KEYS,相同 key 列下,保证 value 列按照 source_sequence 列进行 REPLACE, source_sequence 可以是数据源中的列,也可以是表结构中的一列。 - -19. fuzzy_parse: 布尔类型,为 true 表示 json 将以第一行为 schema 进行解析,开启这个选项可以提高 json 导入效率,但是要求所有 json 对象的 key 的顺序和第一行一致,默认为 false,仅用于 json 格式 - -20. num_as_string: 布尔类型,为 true 表示在解析 json 数据时会将数字类型转为字符串,然后在确保不会出现精度丢失的情况下进行导入。 - -21. read_json_by_line: 布尔类型,为 true 表示支持每行读取一个 json 对象,默认值为 false。 - -22. send_batch_parallelism: 整型,用于设置发送批处理数据的并行度,如果并行度的值超过 BE 配置中的 `max_send_batch_parallelism_per_job`,那么作为协调点的 BE 将使用 `max_send_batch_parallelism_per_job` 的值。 - -23. hidden_columns: 用于指定导入数据中包含的隐藏列,在 Header 中不包含 columns 时生效,多个 hidden column 用逗号分割。 - - ``` - hidden_columns: __DORIS_DELETE_SIGN__,__DORIS_SEQUENCE_COL__ - 系统会使用用户指定的数据导入数据。在上述用例中,导入数据中最后一列数据为__DORIS_SEQUENCE_COL__。 - ``` - -24. load_to_single_tablet: 布尔类型,为 true 表示支持一个任务只导入数据到对应分区的一个 tablet,默认值为 false,该参数只允许在对带有 random 分桶的 olap 表导数的时候设置。 - -25. compress_type: 指定文件的压缩格式。目前只支持 csv 文件的压缩。支持 gz, lzo, bz2, lz4, lzop, deflate 压缩格式。 - -26. trim_double_quotes: 布尔类型,默认值为 false,为 true 时表示裁剪掉 csv 文件每个字段最外层的双引号。 - -27. skip_lines: 整数类型,默认值为 0, 含义为跳过 csv 文件的前几行。当设置 format 设置为 `csv_with_names` 或、`csv_with_names_and_types` 时,该参数会失效。 - -28. comment: 字符串类型,默认值为空。给任务增加额外的信息。 - -29. enclose: 包围符。当 csv 数据字段中含有行分隔符或列分隔符时,为防止意外截断,可指定单字节字符作为包围符起到保护作用。例如列分隔符为",",包围符为"'",数据为"a,'b,c'",则"b,c"会被解析为一个字段。注意:当 enclose 设置为`"`时,trim_double_quotes 一定要设置为 true。 - -30. escape:转义符。用于转义在字段中出现的与包围符相同的字符。例如数据为"a,'b,'c'",包围符为"'",希望"b,'c 被作为一个字段解析,则需要指定单字节转义符,例如"\",然后将数据修改为"a,'b,\'c'"。 - -## 举例 - -1. 将本地文件'testData'中的数据导入到数据库'testDb'中'testTbl'的表,使用 Label 用于去重。指定超时时间为 100 秒 - - ``` - curl --location-trusted -u root -H "label:123" -H "timeout:100" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - -2. 将本地文件'testData'中的数据导入到数据库'testDb'中'testTbl'的表,使用 Label 用于去重,并且只导入 k1 等于 20180601 的数据 - - ``` - curl --location-trusted -u root -H "label:123" -H "where: k1=20180601" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - -3. 将本地文件'testData'中的数据导入到数据库'testDb'中'testTbl'的表,允许 20% 的错误率(用户是 defalut_cluster 中的) - - ``` - curl --location-trusted -u root -H "label:123" -H "max_filter_ratio:0.2" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - -4. 将本地文件'testData'中的数据导入到数据库'testDb'中'testTbl'的表,允许 20% 的错误率,并且指定文件的列名(用户是 defalut_cluster 中的) - - ``` - curl --location-trusted -u root -H "label:123" -H "max_filter_ratio:0.2" -H "columns: k2, k1, v1" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - -5. 将本地文件'testData'中的数据导入到数据库'testDb'中'testTbl'的表中的 p1, p2 分区,允许 20% 的错误率。 - - ``` - curl --location-trusted -u root -H "label:123" -H "max_filter_ratio:0.2" -H "partitions: p1, p2" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - -6. 使用 streaming 方式导入(用户是 defalut_cluster 中的) - - ``` - seq 1 10 | awk '{OFS="\t"}{print $1, $1 * 10}' | curl --location-trusted -u root -T - http://host:port/api/testDb/testTbl/_stream_load - ``` - -7. 导入含有 HLL 列的表,可以是表中的列或者数据中的列用于生成 HLL 列,也可使用 hll_empty 补充数据中没有的列 - - ``` - curl --location-trusted -u root -H "columns: k1, k2, v1=hll_hash(k1), v2=hll_empty()" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - -8. 导入数据进行严格模式过滤,并设置时区为 Africa/Abidjan - - ``` - curl --location-trusted -u root -H "strict_mode: true" -H "timezone: Africa/Abidjan" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - -9. 导入含有 BITMAP 列的表,可以是表中的列或者数据中的列用于生成 BITMAP 列,也可以使用 bitmap_empty 填充空的 Bitmap - - ``` - curl --location-trusted -u root -H "columns: k1, k2, v1=to_bitmap(k1), v2=bitmap_empty()" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - -10. 简单模式,导入 json 数据 - - 表结构: - ``` - `category` varchar(512) NULL COMMENT "", - `author` varchar(512) NULL COMMENT "", - `title` varchar(512) NULL COMMENT "", - `price` double NULL COMMENT "" - ``` - json数据格式: - ``` - {"category":"C++","author":"avc","title":"C++ primer","price":895} - ``` - 导入命令: - ``` - curl --location-trusted -u root -H "label:123" -H "format: json" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - 为了提升吞吐量,支持一次性导入多条json数据,每行为一个json对象,默认使用`\n`作为换行符,需要将`read_json_by_line`设置为true,json数据格式如下: - - ``` - {"category":"C++","author":"avc","title":"C++ primer","price":89.5} - {"category":"Java","author":"avc","title":"Effective Java","price":95} - {"category":"Linux","author":"avc","title":"Linux kernel","price":195} - ``` - -11. 匹配模式,导入 json 数据 - - json数据格式: - - ``` - [ - {"category":"xuxb111","author":"1avc","title":"SayingsoftheCentury","price":895},{"category":"xuxb222","author":"2avc","title":"SayingsoftheCentury","price":895}, - {"category":"xuxb333","author":"3avc","title":"SayingsoftheCentury","price":895} - ] - ``` - 通过指定jsonpath进行精准导入,例如只导入category、author、price三个属性 - ``` - curl --location-trusted -u root -H "columns: category, price, author" -H "label:123" -H "format: json" -H "jsonpaths: [\"$.category\",\"$.price\",\"$.author\"]" -H "strip_outer_array: true" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - - 说明: - 1)如果json数据是以数组开始,并且数组中每个对象是一条记录,则需要将strip_outer_array设置成true,表示展平数组。 - 2)如果json数据是以数组开始,并且数组中每个对象是一条记录,在设置jsonpath时,我们的ROOT节点实际上是数组中对象。 - -12. 用户指定 json 根节点 - - json数据格式: - ``` - { - "RECORDS":[ - {"category":"11","title":"SayingsoftheCentury","price":895,"timestamp":1589191587}, - {"category":"22","author":"2avc","price":895,"timestamp":1589191487}, - {"category":"33","author":"3avc","title":"SayingsoftheCentury","timestamp":1589191387} - ] - } - ``` - 通过指定jsonpath进行精准导入,例如只导入category、author、price三个属性 - ``` - curl --location-trusted -u root -H "columns: category, price, author" -H "label:123" -H "format: json" -H "jsonpaths: [\"$.category\",\"$.price\",\"$.author\"]" -H "strip_outer_array: true" -H "json_root: $.RECORDS" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` -13. 删除与这批导入 key 相同的数据 - - ``` - curl --location-trusted -u root -H "merge_type: DELETE" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - -14. 将这批数据中与 flag 列为 ture 的数据相匹配的列删除,其他行正常追加 - - ``` - curl --location-trusted -u root: -H "column_separator:," -H "columns: siteid, citycode, username, pv, flag" -H "merge_type: MERGE" -H "delete: flag=1" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` -15. 导入数据到含有 sequence 列的 UNIQUE_KEYS 表中 - - ``` - curl --location-trusted -u root -H "columns: k1,k2,source_sequence,v1,v2" -H "function_column.sequence_col: source_sequence" -T testData http://host:port/api/testDb/testTbl/_stream_load - ``` - -16. csv 文件行首过滤导入 - - 文件数据: - - ``` - id,name,age - 1,doris,20 - 2,flink,10 - ``` - 通过指定`format=csv_with_names`过滤首行导入 - ``` - curl --location-trusted -u root -T test.csv -H "label:1" -H "format:csv_with_names" -H "column_separator:," http://host:port/api/testDb/testTbl/_stream_load - ``` -17. 导入数据到表字段含有 DEFAULT CURRENT_TIMESTAMP 的表中 - - 表结构: - ```sql - `id` bigint(30) NOT NULL, - `order_code` varchar(30) DEFAULT NULL COMMENT '', - `create_time` datetimev2(3) DEFAULT CURRENT_TIMESTAMP - ``` - - json数据格式: - ``` - {"id":1,"order_Code":"avc"} - ``` - - 导入命令: - ``` - curl --location-trusted -u root -T test.json -H "label:1" -H "format:json" -H 'columns: id, order_code, create_time=CURRENT_TIMESTAMP()' http://host:port/api/testDb/testTbl/_stream_load - ``` -### Keywords - - STREAM, LOAD - -### Best Practice - -1. 查看导入任务状态 - - Stream Load 是一个同步导入过程,语句执行成功即代表数据导入成功。导入的执行结果会通过 HTTP 返回值同步返回。并以 Json 格式展示。示例如下: - - ```json - { - "TxnId": 17, - "Label": "707717c0-271a-44c5-be0b-4e71bfeacaa5", - "Status": "Success", - "Message": "OK", - "NumberTotalRows": 5, - "NumberLoadedRows": 5, - "NumberFilteredRows": 0, - "NumberUnselectedRows": 0, - "LoadBytes": 28, - "LoadTimeMs": 27, - "BeginTxnTimeMs": 0, - "StreamLoadPutTimeMs": 2, - "ReadDataTimeMs": 0, - "WriteDataTimeMs": 3, - "CommitAndPublishTimeMs": 18 - } - ``` - - 下面主要解释了 Stream load 导入结果参数: - - - TxnId:导入的事务 ID。用户可不感知。 - - - Label:导入 Label。由用户指定或系统自动生成。 - - - Status:导入完成状态。 - - "Success":表示导入成功。 - - "Publish Timeout":该状态也表示导入已经完成,只是数据可能会延迟可见,无需重试。 - - "Label Already Exists":Label 重复,需更换 Label。 - - "Fail":导入失败。 - - - ExistingJobStatus:已存在的 Label 对应的导入作业的状态。 - - 这个字段只有在当 Status 为 "Label Already Exists" 时才会显示。用户可以通过这个状态,知晓已存在 Label 对应的导入作业的状态。"RUNNING" 表示作业还在执行,"FINISHED" 表示作业成功。 - - - Message:导入错误信息。 - - - NumberTotalRows:导入总处理的行数。 - - - NumberLoadedRows:成功导入的行数。 - - - NumberFilteredRows:数据质量不合格的行数。 - - - NumberUnselectedRows:被 where 条件过滤的行数。 - - - LoadBytes:导入的字节数。 - - - LoadTimeMs:导入完成时间。单位毫秒。 - - - BeginTxnTimeMs:向 Fe 请求开始一个事务所花费的时间,单位毫秒。 - - - StreamLoadPutTimeMs:向 Fe 请求获取导入数据执行计划所花费的时间,单位毫秒。 - - - ReadDataTimeMs:读取数据所花费的时间,单位毫秒。 - - - WriteDataTimeMs:执行写入数据操作所花费的时间,单位毫秒。 - - - CommitAndPublishTimeMs:向 Fe 请求提交并且发布事务所花费的时间,单位毫秒。 - - - ErrorURL:如果有数据质量问题,通过访问这个 URL 查看具体错误行。 - - > 注意:由于 Stream load 是同步的导入方式,所以并不会在 Doris 系统中记录导入信息,用户无法异步的通过查看导入命令看到 Stream load。使用时需监听创建导入请求的返回值获取导入结果。 - -2. 如何正确提交 Stream Load 作业和处理返回结果。 - - Stream Load 是同步导入操作,因此用户需同步等待命令的返回结果,并根据返回结果决定下一步处理方式。 - - 用户首要关注的是返回结果中的 `Status` 字段。 - - 如果为 `Success`,则一切正常,可以进行之后的其他操作。 - - 如果返回结果出现大量的 `Publish Timeout`,则可能说明目前集群某些资源(如 IO)紧张导致导入的数据无法最终生效。`Publish Timeout` 状态的导入任务已经成功,无需重试,但此时建议减缓或停止新导入任务的提交,并观察集群负载情况。 - - 如果返回结果为 `Fail`,则说明导入失败,需根据具体原因查看问题。解决后,可以使用相同的 Label 重试。 - - 在某些情况下,用户的 HTTP 连接可能会异常断开导致无法获取最终的返回结果。此时可以使用相同的 Label 重新提交导入任务,重新提交的任务可能有如下结果: - - 1. `Status` 状态为 `Success`,`Fail` 或者 `Publish Timeout`。此时按照正常的流程处理即可。 - 2. `Status` 状态为 `Label Already Exists`。则此时需继续查看 `ExistingJobStatus` 字段。如果该字段值为 `FINISHED`,则表示这个 Label 对应的导入任务已经成功,无需在重试。如果为 `RUNNING`,则表示这个 Label 对应的导入任务依然在运行,则此时需每间隔一段时间(如 10 秒),使用相同的 Label 继续重复提交,直到 `Status` 不为 `Label Already Exists`,或者 `ExistingJobStatus` 字段值为 `FINISHED` 为止。 - -3. 取消导入任务 - - 已提交切尚未结束的导入任务可以通过 CANCEL LOAD 命令取消。取消后,已写入的数据也会回滚,不会生效。 - -4. Label、导入事务、多表原子性 - - Doris 中所有导入任务都是原子生效的。并且在同一个导入任务中对多张表的导入也能够保证原子性。同时,Doris 还可以通过 Label 的机制来保证数据导入的不丢不重。具体说明可以参阅 [导入事务和原子性](../../../../data-operate/import/import-scenes/load-atomicity.md) 文档。 - -5. 列映射、衍生列和过滤 - - Doris 可以在导入语句中支持非常丰富的列转换和过滤操作。支持绝大多数内置函数和 UDF。关于如何正确的使用这个功能,可参阅 [列的映射,转换与过滤](../../../../data-operate/import/import-scenes/load-data-convert.md) 文档。 - -6. 错误数据过滤 - - Doris 的导入任务可以容忍一部分格式错误的数据。容忍率通过 `max_filter_ratio` 设置。默认为 0,即表示当有一条错误数据时,整个导入任务将会失败。如果用户希望忽略部分有问题的数据行,可以将次参数设置为 0~1 之间的数值,Doris 会自动跳过哪些数据格式不正确的行。 - - 关于容忍率的一些计算方式,可以参阅 [列的映射,转换与过滤](../../../../data-operate/import/import-scenes/load-data-convert.md) 文档。 - -7. 严格模式 - - `strict_mode` 属性用于设置导入任务是否运行在严格模式下。该属性会对列映射、转换和过滤的结果产生影响,它同时也将控制部分列更新的行为。关于严格模式的具体说明,可参阅 [严格模式](../../../../data-operate/import/import-scenes/load-strict-mode.md) 文档。 - -8. 超时时间 - - Stream Load 的默认超时时间为 10 分钟。从任务提交开始算起。如果在超时时间内没有完成,则任务会失败。 - -9. 数据量和任务数限制 - - Stream Load 适合导入几个 GB 以内的数据,因为数据为单线程传输处理,因此导入过大的数据性能得不到保证。当有大量本地数据需要导入时,可以并行提交多个导入任务。 - - Doris 同时会限制集群内同时运行的导入任务数量,通常在 10-20 个不等。之后提交的导入作业会被拒绝。 - -10. 涉及时区的导入 - - 由于 Doris 目前没有内置时区的时间类型,所有 `DATETIME` 相关类型均只表示绝对的时间点,而不包含时区信息,不因 Doris 系统时区变化而发生变化。因此,对于带时区数据的导入,我们统一的处理方式为**将其转换为特定目标时区下的数据**。在 Doris 系统中,即 session variable `time_zone` 所代表的时区。 - - 而在导入中,我们的目标时区通过参数 `timezone` 指定,该变量在发生时区转换、运算时区敏感函数时将会替代 session variable `time_zone`。因此,如果没有特殊情况,在导入事务中应当设定 `timezone` 与当前 Doris 集群的 `time_zone` 一致。此时意味着所有带时区的时间数据,均会发生向该时区的转换。 - 例如,Doris 系统时区为 "+08:00",导入数据中的时间列包含两条数据,分别为 "2012-01-01 01:00:00Z" 和 "2015-12-12 12:12:12-08:00",则我们在导入时通过 `-H "timezone: +08:00"` 指定导入事务的时区后,这两条数据都会向该时区发生转换,从而得到结果 "2012-01-01 09:00:00" 和 "2015-12-13 04:12:12"。 - - 更详细的理解,请参阅[时区](../../../../admin-manual/cluster-management/time-zone)文档。 - -11. 导入的执行引擎使用 - - Session Variable `enable_pipeline_load` 决定是否尝试开启 Pipeline 引擎执行 Streamload 任务。详见[导入](../../../../data-operate/import/load-manual)文档。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/ANALYZE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/ANALYZE.md deleted file mode 100644 index 33c524957bd57..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/ANALYZE.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -{ - "title": "ANALYZE", - "language": "zh-CN" -} ---- - - - -## ANALYZE - -### Name - -ANALYZE - -## 描述 - -该语句用于收集各列的统计信息。 - -```sql -ANALYZE < TABLE | DATABASE table_name | db_name > - [ (column_name [, ...]) ] - [ [ WITH SYNC ] [ WITH SAMPLE PERCENT | ROWS ] ]; -``` - -- table_name: 指定的目标表。可以是  `db_name.table_name`  形式。 -- column_name: 指定的目标列。必须是  `table_name`  中存在的列,多个列名称用逗号分隔。 -- sync:同步收集统计信息。收集完后返回。若不指定则异步执行并返回 JOB ID。 -- sample percent | rows:抽样收集统计信息。可以指定抽样比例或者抽样行数。 - -## 举例 - -对一张表按照 10% 的比例采样收集统计数据: - -```sql -ANALYZE TABLE lineitem WITH SAMPLE PERCENT 10; -``` - -对一张表按采样 10 万行收集统计数据 - -```sql -ANALYZE TABLE lineitem WITH SAMPLE ROWS 100000; -``` - -### Keywords - -ANALYZE diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/CANCEL-EXPORT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/CANCEL-EXPORT.md deleted file mode 100644 index eaa7a479c6f2b..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/CANCEL-EXPORT.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -{ - "title": "CANCEL-EXPORT", - "language": "zh-CN" -} ---- - - - -## CANCEL-EXPORT - -### Name - -CANCEL EXPORT - -## 描述 - -该语句用于撤销指定 label 的 EXPORT 作业,或者通过模糊匹配批量撤销 EXPORT 作业 - -```sql -CANCEL EXPORT -[FROM db_name] -WHERE [LABEL = "export_label" | LABEL like "label_pattern" | STATE = "PENDING/IN_QUEUE/EXPORTING"] -``` - -## 举例 - -1. 撤销数据库 example_db 上,label 为 `example_db_test_export_label` 的 EXPORT 作业 - - ```sql - CANCEL EXPORT - FROM example_db - WHERE LABEL = "example_db_test_export_label" and STATE = "EXPORTING"; - ``` - -2. 撤销数据库 example*db 上,所有包含 example* 的 EXPORT 作业。 - - ```sql - CANCEL EXPORT - FROM example_db - WHERE LABEL like "%example%"; - ``` - -3. 取消状态为 PENDING 的导入作业。 - - ```sql - CANCEL EXPORT - FROM example_db - WHERE STATE = "PENDING"; - ``` - -### Keywords - - CANCEL, EXPORT - -### Best Practice - -1. 只能取消处于 PENDING、IN_QUEUE、EXPORTING 状态的未完成的导出作业。 -2. 当执行批量撤销时,Doris 不会保证所有对应的 EXPORT 作业原子的撤销。即有可能仅有部分 EXPORT 作业撤销成功。用户可以通过 SHOW EXPORT 语句查看作业状态,并尝试重复执行 CANCEL EXPORT 语句。 -3. 当撤销`EXPORTING`状态的作业时,有可能作业已经导出部分数据到存储系统上,用户需要自行处理 (删除) 该部分导出数据。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/DELETE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/DELETE.md deleted file mode 100644 index ae577db13a157..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/DELETE.md +++ /dev/null @@ -1,254 +0,0 @@ ---- -{ - "title": "DELETE", - "language": "zh-CN" -} ---- - - - -## DELETE - -### Name - -DELETE - -## 描述 - -该语句用于按条件删除指定 table(base index)partition 中的数据。 - -该操作会同时删除和此 base index 相关的 rollup index 的数据。 - -## 语法 - -语法一:该语法只能指定过滤谓词 - -```SQL -DELETE FROM table_name [table_alias] [PARTITION partition_name | PARTITIONS (partition_name [, partition_name])] -WHERE -column_name op { value | value_list } [ AND column_name op { value | value_list } ...]; -``` - -语法二:该语法只能在 UNIQUE KEY 模型表上使用 - -```sql -[cte] -DELETE FROM table_name [table_alias] - [PARTITION partition_name | PARTITIONS (partition_name [, partition_name])] - [USING additional_tables] - WHERE condition -``` - -#### Required Parameters - -+ table_name: 指定需要删除数据的表 -+ column_name: 属于 table_name 的列 -+ op: 逻辑比较操作符,可选类型包括:=, >, <, >=, <=, !=, in, not in -+ value | value_list: 做逻辑比较的值或值列表 -+ WHERE condition: 指定一个用于选择删除行的条件 - -#### Optional Parameters - -+ cte: 通用表达式。可以是 'WITH a AS SELECT * FROM tbl' 形式 -+ PARTITION partition_name | PARTITIONS (partition_name [, partition_name]): 指定执行删除数据的分区名,如果表不存在此分区,则报错 -+ table_alias: 表的别名 -+ USING additional_tables: 如果需要在 WHERE 语句中使用其他的表来帮助识别需要删除的行,则可以在 USING 中指定这些表或者查询。 - -#### Returned Results - -Delete 命令是一个 SQL 命令,返回结果是同步的,分为以下几种: - -##### 执行成功 - -如果 Delete 顺利执行完成并可见,将返回下列结果,`Query OK`表示成功 - -```sql -Query OK, 0 rows affected (0.04 sec) -{'label':'delete_e7830c72-eb14-4cb9-bbb6-eebd4511d251', 'status':'VISIBLE', 'txnId':'4005'} -``` - -##### 提交成功,但未可见 - -Doris 的事务提交分为两步:提交和发布版本,只有完成了发布版本步骤,结果才对用户是可见的。若已经提交成功了,那么就可以认为最终一定会发布成功,Doris 会尝试在提交完后等待发布一段时间,如果超时后即使发布版本还未完成也会优先返回给用户,提示用户提交已经完成。若如果 Delete 已经提交并执行,但是仍未发布版本和可见,将返回下列结果 - -```sql -Query OK, 0 rows affected (0.04 sec) -{'label':'delete_e7830c72-eb14-4cb9-bbb6-eebd4511d251', 'status':'COMMITTED', 'txnId':'4005', 'err':'delete job is committed but may be taking effect later' } -``` - -结果会同时返回一个 json 字符串: - -- `affected rows`:表示此次删除影响的行,由于 Doris 的删除目前是逻辑删除,因此对于这个值是恒为 0; - -- `label`:自动生成的 label,是该导入作业的标识。每个导入作业,都有一个在单 Database 内部唯一的 Label; - -- `status`:表示数据删除是否可见,如果可见则显示`VISIBLE`,如果不可见则显示`COMMITTED`; - -- `txnId`:这个 Delete job 对应的事务 id; - -- `err`:字段会显示一些本次删除的详细信息。 - -##### 提交失败,事务取消 - -如果 Delete 语句没有提交成功,将会被 Doris 自动中止,返回下列结果 - -```sql -ERROR 1064 (HY000): errCode = 2, detailMessage = {错误原因} -``` - -比如说一个超时的删除,将会返回 `timeout` 时间和未完成的`(tablet=replica)` - -```sql -ERROR 1064 (HY000): errCode = 2, detailMessage = failed to delete replicas from job: 4005, Unfinished replicas:10000=60000, 10001=60000, 10002=60000 -``` - -#### Note - -1. 使用聚合类的表模型(AGGREGATE、UNIQUE)只能指定 key 列上的条件。 -2. 当选定的 key 列不存在于某个 rollup 中时,无法进行 delete。 -3. 语法一中,条件之间只能是“与”的关系。若希望达成“或”的关系,需要将条件分写在两个 DELETE 语句中。 -4. 语法一中,如果为分区表,需要指定分区,如果不指定,doris 会从条件中推断出分区。两种情况下,doris 无法从条件中推断出分区:1) 条件中不包含分区列;2) 分区列的 op 为 not in。当分区表未指定分区,或者无法从条件中推断分区的时候,需要设置会话变量 delete_without_partition 为 true,此时 delete 会应用到所有分区。 -5. 该语句可能会降低执行后一段时间内的查询效率。影响程度取决于语句中指定的删除条件的数量。指定的条件越多,影响越大。 - -## 举例 - -1. 删除 my_table partition p1 中 k1 列值为 3 的数据行 - - ```sql - DELETE FROM my_table PARTITION p1 - WHERE k1 = 3; - ``` - -2. 删除 my_table partition p1 中 k1 列值大于等于 3 且 k2 列值为 "abc" 的数据行 - - ```sql - DELETE FROM my_table PARTITION p1 - WHERE k1 >= 3 AND k2 = "abc"; - ``` - -3. 删除 my_table partition p1, p2 中 k1 列值大于等于 3 且 k2 列值为 "abc" 的数据行 - - ```sql - DELETE FROM my_table PARTITIONS (p1, p2) - WHERE k1 >= 3 AND k2 = "abc"; - ``` - -4. 使用`t2`和`t3`表连接的结果,删除`t1`中的数据,删除的表只支持 unique 模型 - - ```sql - -- 创建 t1, t2, t3 三张表 - CREATE TABLE t1 - (id INT, c1 BIGINT, c2 STRING, c3 DOUBLE, c4 DATE) - UNIQUE KEY (id) - DISTRIBUTED BY HASH (id) - PROPERTIES('replication_num'='1', "function_column.sequence_col" = "c4"); - - CREATE TABLE t2 - (id INT, c1 BIGINT, c2 STRING, c3 DOUBLE, c4 DATE) - DISTRIBUTED BY HASH (id) - PROPERTIES('replication_num'='1'); - - CREATE TABLE t3 - (id INT) - DISTRIBUTED BY HASH (id) - PROPERTIES('replication_num'='1'); - - -- 插入数据 - INSERT INTO t1 VALUES - (1, 1, '1', 1.0, '2000-01-01'), - (2, 2, '2', 2.0, '2000-01-02'), - (3, 3, '3', 3.0, '2000-01-03'); - - INSERT INTO t2 VALUES - (1, 10, '10', 10.0, '2000-01-10'), - (2, 20, '20', 20.0, '2000-01-20'), - (3, 30, '30', 30.0, '2000-01-30'), - (4, 4, '4', 4.0, '2000-01-04'), - (5, 5, '5', 5.0, '2000-01-05'); - - INSERT INTO t3 VALUES - (1), - (4), - (5); - - -- 删除 t1 中的数据 - DELETE FROM t1 - USING t2 INNER JOIN t3 ON t2.id = t3.id - WHERE t1.id = t2.id; - ``` - - 预期结果为,删除了`t1`表`id`为`1`的列 - - ``` - +----+----+----+--------+------------+ - | id | c1 | c2 | c3 | c4 | - +----+----+----+--------+------------+ - | 2 | 2 | 2 | 2.0 | 2000-01-02 | - | 3 | 3 | 3 | 3.0 | 2000-01-03 | - +----+----+----+--------+------------+ - ``` - -5. 使用 cte 关联删除 - - ```sql - create table orders( - o_orderkey bigint, - o_totalprice decimal(15, 2) - ) unique key(o_orderkey) - distributed by hash(o_orderkey) buckets 1 - properties ( - "replication_num" = "1" - ); - - insert into orders values - (1, 34.1), - (2, 432.8); - - create table lineitem( - l_linenumber int, - o_orderkey bigint, - l_discount decimal(15, 2) - ) unique key(l_linenumber) - distributed by hash(l_linenumber) buckets 1 - properties ( - "replication_num" = "1" - ); - - insert into lineitem values - (1, 1, 1.23), - (2, 1, 3.21), - (3, 2, 18.08), - (4, 2, 23.48); - - with discount_orders as ( - select * from orders - where o_totalprice > 100 - ) - delete from lineitem - using discount_orders - where lineitem.o_orderkey = discount_orders.o_orderkey; - ``` - -### Keywords - - DELETE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/EXPORT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/EXPORT.md deleted file mode 100644 index cbb571d62c430..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/EXPORT.md +++ /dev/null @@ -1,379 +0,0 @@ ---- -{ - "title": "EXPORT", - "language": "zh-CN" -} ---- - - - -## EXPORT - -### Name - -EXPORT - -## 描述 - - `EXPORT` 命令用于将指定表的数据导出为文件到指定位置。目前支持通过 Broker 进程,S3 协议或 HDFS 协议,导出到远端存储,如 HDFS,S3,BOS,COS(腾讯云)上。 - -`EXPORT`是一个异步操作,该命令会提交一个`EXPORT JOB`到 Doris,任务提交成功立即返回。执行后可使用 [SHOW EXPORT](../../Show-Statements/SHOW-EXPORT.md) 命令查看进度。 - -语法: - - ```sql - EXPORT TABLE table_name - [PARTITION (p1[,p2])] - [WHERE] - TO export_path - [opt_properties] - WITH BROKER/S3/HDFS - [broker_properties]; - ``` - - - -**说明**: - -- `table_name` - - 当前要导出的表的表名。支持 Doris 本地表、视图 View、Catalog 外表数据的导出。 - -- `partition` - - 可以只导出指定表的某些指定分区,只对 Doris 本地表有效。 - -- `export_path` - - 导出的文件路径。可以是目录,也可以是文件目录加文件前缀,如`hdfs://path/to/my_file_` - -- `opt_properties` - - 用于指定一些导出参数。 - - ```sql - [PROPERTIES ("key"="value", ...)] - ``` - - 可以指定如下参数: - - - `label`: 可选参数,指定此次 Export 任务的 Label,当不指定时系统会随机生成一个 Label。 - - - `column_separator`:指定导出的列分隔符,默认为 \t,支持多字节。该参数只用于 CSV 文件格式。 - - - `line_delimiter`:指定导出的行分隔符,默认为 \n,支持多字节。该参数只用于 CSV 文件格式。 - - - `columns`:指定导出表的某些列。 - - - `format`:指定导出作业的文件格式,支持:parquet, orc, csv, csv_with_names、csv_with_names_and_types。默认为 CSV 格式。 - - - `max_file_size`:导出作业单个文件大小限制,如果结果超过这个值,将切割成多个文件。`max_file_size`取值范围是[5MB, 2GB], 默认为 1GB。(当指定导出为 orc 文件格式时,实际切分文件的大小将是 64MB 的倍数,如:指定 max_file_size = 5MB, 实际将以 64MB 为切分;指定 max_file_size = 65MB, 实际将以 128MB 为切分) - - - `parallelism`:导出作业的并发度,默认为`1`,导出作业会开启`parallelism`个数的线程去执行`select into outfile`语句。(如果 Parallelism 个数大于表的 Tablets 个数,系统将自动把 Parallelism 设置为 Tablets 个数大小,即每一个`select into outfile`语句负责一个 Tablets) - - - `delete_existing_files`: 默认为 `false`,若指定为 `true`,则会先删除`export_path`所指定目录下的所有文件,然后导出数据到该目录下。例如:"export_path" = "/user/tmp", 则会删除"/user/"下所有文件及目录;"file_path" = "/user/tmp/", 则会删除"/user/tmp/"下所有文件及目录。 - - - `with_bom`: 默认为 `false`,若指定为 `true`,则导出的文件编码为带有 BOM 的 UTF8 编码(只对 csv 相关的文件格式生效)。 - - - `data_consistency`: 可以设置为 `none` / `partition` ,默认为 `partition` 。指示以何种粒度切分导出表,`none` 代表 Tablets 级别,`partition`代表 Partition 级别。 - - - `timeout`:导出作业的超时时间,默认为 2 小时,单位是秒。 - - - `compress_type`:(自 2.1.5 支持) 当指定导出的文件格式为 Parquet / ORC 文件时,可以指定 Parquet / ORC 文件使用的压缩方式。Parquet 文件格式可指定压缩方式为 SNAPPY,GZIP,BROTLI,ZSTD,LZ4 及 PLAIN,默认值为 SNAPPY。ORC 文件格式可指定压缩方式为 PLAIN,SNAPPY,ZLIB 以及 ZSTD,默认值为 ZLIB。该参数自 2.1.5 版本开始支持。(PLAIN 就是不采用压缩) - - :::caution 注意 - 要使用 delete_existing_files 参数,还需要在 fe.conf 中添加配置`enable_delete_existing_files = true`并重启 fe,此时 delete_existing_files 才会生效。delete_existing_files = true 是一个危险的操作,建议只在测试环境中使用。 - ::: - - - -- `WITH BROKER` - - 可以通过 Broker 进程写数据到远端存储上。这里需要定义相关的连接信息供 Broker 使用。 - - ```sql - 语法: - WITH BROKER "broker_name" - ("key"="value"[,...]) - - Broker 相关属性: - username: 用户名 - password: 密码 - hadoop.security.authentication: 指定认证方式为 kerberos - kerberos_principal: 指定 kerberos 的 principal - kerberos_keytab: 指定 kerberos 的 keytab 文件路径。该文件必须为 Broker 进程所在服务器上的文件的绝对路径。并且可以被 Broker 进程访问 - ``` - - -- `WITH HDFS` - - 可以直接将数据写到远端 HDFS 上。 - - ```sql - 语法: - WITH HDFS ("key"="value"[,...]) - - HDFS 相关属性: - fs.defaultFS: namenode 地址和端口 - hadoop.username: hdfs 用户名 - dfs.nameservices: name service 名称,与 hdfs-site.xml 保持一致 - dfs.ha.namenodes.[nameservice ID]: namenode 的 id 列表,与 hdfs-site.xml 保持一致 - dfs.namenode.rpc-address.[nameservice ID].[name node ID]: Name node 的 rpc 地址,数量与 namenode 数量相同,与 hdfs-site.xml 保 - - 对于开启kerberos认证的Hadoop 集群,还需要额外设置如下 PROPERTIES 属性: - dfs.namenode.kerberos.principal: HDFS namenode 服务的 principal 名称 - hadoop.security.authentication: 认证方式设置为 kerberos - hadoop.kerberos.principal: 设置 Doris 连接 HDFS 时使用的 Kerberos 主体 - hadoop.kerberos.keytab: 设置 keytab 本地文件路径 - ``` - -- `WITH S3` - - 可以直接将数据写到远端 S3 对象存储上。 - - ```sql - 语法: - WITH S3 ("key"="value"[,...]) - - S3 相关属性: - AWS_ENDPOINT - AWS_ACCESS_KEY - AWS_SECRET_KEY - AWS_REGION - use_path_style: (选填) 默认为 `false`。S3 SDK 默认使用 Virtual-hosted Style 方式。但某些对象存储系统可能没开启或不支持 Virtual-hosted Style 方式的访问,此时可以添加 `use_path_style` 参数来强制使用 Path Style 访问方式。 - ``` - -## 举例 - -#### Export 数据到本地 -> Export 数据到本地文件系统,需要在 `fe.conf` 中添加 `enable_outfile_to_local=true` 并且重启 FE。 - -1. 将 Test 表中的所有数据导出到本地存储,默认导出 CSV 格式文件 -```sql -EXPORT TABLE test TO "file:///home/user/tmp/"; -``` - -2. 将 Test 表中的 k1,k2 列导出到本地存储,默认导出 CSV 文件格式,并设置 Label -```sql -EXPORT TABLE test TO "file:///home/user/tmp/" -PROPERTIES ( - "label" = "label1", - "columns" = "k1,k2" -); -``` - -3. 将 Test 表中的 `k1 < 50` 的行导出到本地存储,默认导出 CSV 格式文件,并以 `,` 作为列分割符 -```sql -EXPORT TABLE test WHERE k1 < 50 TO "file:///home/user/tmp/" -PROPERTIES ( - "columns" = "k1,k2", - "column_separator"="," -); -``` - -4. 将 Test 表中的分区 p1,p2 导出到本地存储,默认导出 csv 格式文件 -```sql -EXPORT TABLE test PARTITION (p1,p2) TO "file:///home/user/tmp/" -PROPERTIES ("columns" = "k1,k2"); -``` - -5. 将 Test 表中的所有数据导出到本地存储,导出其他格式的文件 -```sql -// parquet格式 -EXPORT TABLE test TO "file:///home/user/tmp/" -PROPERTIES ( - "columns" = "k1,k2", - "format" = "parquet" -); - -// orc格式 -EXPORT TABLE test TO "file:///home/user/tmp/" -PROPERTIES ( - "columns" = "k1,k2", - "format" = "orc" -); - -// csv_with_names格式, 以’AA‘为列分割符,‘zz’为行分割符 -EXPORT TABLE test TO "file:///home/user/tmp/" -PROPERTIES ( - "format" = "csv_with_names", - "column_separator"="AA", - "line_delimiter" = "zz" -); - -// csv_with_names_and_types格式 -EXPORT TABLE test TO "file:///home/user/tmp/" -PROPERTIES ( - "format" = "csv_with_names_and_types" -); -``` - -6. 设置 `max_file_sizes` 属性 -```sql -EXPORT TABLE test TO "file:///home/user/tmp/" -PROPERTIES ( - "format" = "parquet", - "max_file_size" = "5MB" -); -``` -当导出文件大于 5MB 时,将切割数据为多个文件,每个文件最大为 5MB。 - -7. 设置 `parallelism` 属性 -```sql -EXPORT TABLE test TO "file:///home/user/tmp/" -PROPERTIES ( - "format" = "parquet", - "max_file_size" = "5MB", - "parallelism" = "5" -); -``` - -8. 设置 `delete_existing_files` 属性 -```sql -EXPORT TABLE test TO "file:///home/user/tmp" -PROPERTIES ( - "format" = "parquet", - "max_file_size" = "5MB", - "delete_existing_files" = "true" -); -``` -Export 导出数据时会先将`/home/user/`目录下所有文件及目录删除,然后导出数据到该目录下。 - -#### export with S3 - -1. 将 s3_test 表中的所有数据导出到 S3 上,以不可见字符 `\x07` 作为列或者行分隔符。如果需要将数据导出到 minio,还需要指定 `use_path_style`=`true`。 - -```sql -EXPORT TABLE s3_test TO "s3://bucket/a/b/c" -PROPERTIES ( - "column_separator"="\\x07", - "line_delimiter" = "\\x07" -) WITH s3 ( - "s3.endpoint" = "xxxxx", - "s3.region" = "xxxxx", - "s3.secret_key"="xxxx", - "s3.access_key" = "xxxxx" -) -``` - -#### export with HDFS - -1. 将 Test 表中的所有数据导出到 HDFS 上,导出文件格式为 Parquet,导出作业单个文件大小限制为 512MB,保留所指定目录下的所有文件。 - -```sql -EXPORT TABLE test TO "hdfs://hdfs_host:port/a/b/c/" -PROPERTIES( - "format" = "parquet", - "max_file_size" = "512MB", - "delete_existing_files" = "false" -) -with HDFS ( -"fs.defaultFS"="hdfs://hdfs_host:port", -"hadoop.username" = "hadoop" -); -``` - -#### export with Broker -需要先启动 Broker 进程,并在 FE 中添加该 Broker。 -1. 将 Test 表中的所有数据导出到 hdfs 上 -```sql -EXPORT TABLE test TO "hdfs://hdfs_host:port/a/b/c" -WITH BROKER "broker_name" -( - "username"="xxx", - "password"="yyy" -); -``` - -2. 将 testTbl 表中的分区 p1,p2 导出到 hdfs 上,以","作为列分隔符,并指定 Label - -```sql -EXPORT TABLE testTbl PARTITION (p1,p2) TO "hdfs://hdfs_host:port/a/b/c" -PROPERTIES ( - "label" = "mylabel", - "column_separator"="," -) -WITH BROKER "broker_name" -( - "username"="xxx", - "password"="yyy" -); -``` - -3. 将 testTbl 表中的所有数据导出到 hdfs 上,以不可见字符 "\x07" 作为列或者行分隔符。 - -```sql -EXPORT TABLE testTbl TO "hdfs://hdfs_host:port/a/b/c" -PROPERTIES ( - "column_separator"="\\x07", - "line_delimiter" = "\\x07" -) -WITH BROKER "broker_name" -( - "username"="xxx", - "password"="yyy" -) -``` - -### Keywords - - EXPORT - -### Best Practice - -#### 并发执行 - -一个 Export 作业可以设置`parallelism`参数来并发导出数据。`parallelism`参数实际就是指定执行 EXPORT 作业的线程数量。当设置`"data_consistency" = "none"`时,每一个线程会负责导出表的部分 Tablets。 - -一个 Export 作业的底层执行逻辑实际上是`SELECT INTO OUTFILE`语句,`parallelism`参数设置的每一个线程都会去执行独立的`SELECT INTO OUTFILE`语句。 - -Export 作业拆分成多个`SELECT INTO OUTFILE`的具体逻辑是:将该表的所有 tablets 平均的分给所有 parallel 线程,如: -- num(tablets) = 40, parallelism = 3,则这 3 个线程各自负责的 tablets 数量分别为 14,13,13 个。 -- num(tablets) = 2, parallelism = 3,则 Doris 会自动将 parallelism 设置为 2,每一个线程负责一个 tablets。 - -当一个线程负责的 tablest 超过 `maximum_tablets_of_outfile_in_export` 数值(默认为 10,可在 fe.conf 中添加`maximum_tablets_of_outfile_in_export`参数来修改该值)时,该线程就会拆分为多个`SELECT INTO OUTFILE`语句,如: -- 一个线程负责的 tablets 数量分别为 14,`maximum_tablets_of_outfile_in_export = 10`,则该线程负责两个`SELECT INTO OUTFILE`语句,第一个`SELECT INTO OUTFILE`语句导出 10 个 tablets,第二个`SELECT INTO OUTFILE`语句导出 4 个 tablets,两个`SELECT INTO OUTFILE`语句由该线程串行执行。 - - -当所要导出的数据量很大时,可以考虑适当调大`parallelism`参数来增加并发导出。若机器核数紧张,无法再增加`parallelism` 而导出表的 Tablets 又较多时,可以考虑调大`maximum_tablets_of_outfile_in_export`来增加一个`SELECT INTO OUTFILE`语句负责的 tablets 数量,也可以加快导出速度。 - -若希望以 Parition 粒度导出 Table,可以设置 Export 属性 `"data_consistency" = "partition"` ,此时 Export 任务并发的线程会以 Parition 粒度来划分为多个 Outfile 语句,不同的 Outfile 语句导出的 Parition 不同,而同一个 Outfile 语句导出的数据一定属于同一个 Partition。如:设置 `"data_consistency" = "partition"` 后 - -- num(partition) = 40, parallelism = 3,则这 3 个线程各自负责的 Partition 数量分别为 14,13,13 个。 -- num(partition) = 2, parallelism = 3,则 Doris 会自动将 Parallelism 设置为 2,每一个线程负责一个 Partition。 - - -#### 内存限制 - -通常一个 Export 作业的查询计划只有 `扫描-导出` 两部分,不涉及需要太多内存的计算逻辑。所以通常 2GB 的默认内存限制可以满足需求。 - -但在某些场景下,比如一个查询计划,在同一个 BE 上需要扫描的 Tablet 过多,或者 Tablet 的数据版本过多时,可能会导致内存不足。可以调整 Session 变量 `exec_mem_limit` 来调大内存使用限制。 - -#### 注意事项 - -- 不建议一次性导出大量数据。一个 Export 作业建议的导出数据量最大在几十 GB。过大的导出会导致更多的垃圾文件和更高的重试成本。如果表数据量过大,建议按照分区导出。 - -- 如果 Export 作业运行失败,已经生成的文件不会被删除,需要用户手动删除。 - -- Export 作业会扫描数据,占用 IO 资源,可能会影响系统的查询延迟。 - -- 目前在 Export 时只是简单检查 Tablets 版本是否一致,建议在执行 Export 过程中不要对该表进行导入数据操作。 - -- 一个 Export Job 允许导出的分区数量最大为 2000,可以在 `fe.conf` 中添加参数 `maximum_number_of_export_partitions` 并重启 FE 来修改该设置。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/INSERT-OVERWRITE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/INSERT-OVERWRITE.md deleted file mode 100644 index b169052047ff8..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/INSERT-OVERWRITE.md +++ /dev/null @@ -1,299 +0,0 @@ ---- -{ - "title": "INSERT-OVERWRITE", - "language": "zh-CN" -} - ---- - - - -## INSERT OVERWRITE - -### Name - -INSERT OVERWRITE - -## 描述 - -该语句的功能是重写表或表的某些分区 - -```sql -INSERT OVERWRITE table table_name - [ PARTITION (p1, ... | *) ] - [ WITH LABEL label] - [ (column [, ...]) ] - [ [ hint [, ...] ] ] - { VALUES ( { expression | DEFAULT } [, ...] ) [, ...] | query } -``` - - Parameters - -> table_name: 需要重写的目的表。这个表必须存在。可以是 `db_name.table_name` 形式 -> -> partitions: 需要重写的目标分区,支持两种形式: -> ->> 1. 分区名。必须是 `table_name` 中存在的分区,多个分区名称用逗号分隔。 ->> 2. 星号(*)。开启[自动检测分区](#overwrite-auto-detect-partition)功能。写入操作将会自动检测数据所涉及的分区,并覆写这些分区。 -> -> label: 为 Insert 任务指定一个 label -> -> column_name: 指定的目的列,必须是 `table_name` 中存在的列 -> -> expression: 需要赋值给某个列的对应表达式 -> -> DEFAULT: 让对应列使用默认值 -> -> query: 一个普通查询,查询的结果会重写到目标中 -> -> hint: 用于指示 `INSERT` 执行行为的一些指示符。目前 hint 有三个可选值`/*+ STREAMING */`、`/*+ SHUFFLE */`或`/*+ NOSHUFFLE */` -> -> 1. STREAMING:目前无实际作用,只是为了兼容之前的版本,因此保留。(之前的版本加上这个 hint 会返回 label,现在默认都会返回 label) -> 2. SHUFFLE:当目标表是分区表,开启这个 hint 会进行 repartiiton。 -> 3. NOSHUFFLE:即使目标表是分区表,也不会进行 repartiiton,但会做一些其他操作以保证数据正确落到各个分区中。 - -注意: - -1. 在当前版本中,会话变量 `enable_insert_strict` 默认为 `true`,如果执行 `INSERT OVERWRITE` 语句时,对于有不符合目标表格式的数据被过滤掉的话会重写目标表失败(比如重写分区时,不满足所有分区条件的数据会被过滤)。 -2. INSERT OVERWRITE 语句会首先创建一个新表,将需要重写的数据插入到新表中,最后原子性的用新表替换旧表并修改名称。因此,在重写表的过程中,旧表中的数据在重写完毕之前仍然可以正常访问。 - -#### For Auto Partition Table - -如果 INSERT OVERWRITE 的目标表是自动分区表,那么行为受到 [Session Variable](../query/query-variables/variables#变量) `enable_auto_create_when_overwrite` 的控制,具体行为如下: -1. 若未指定 PARTITION (覆写整表),当 `enable_auto_create_when_overwrite` 为 `true`,在覆写整表已有数据的同时,对于没有对应分区的数据,按照该表的自动分区规则创建分区,并容纳这些原本没有对应分区的数据。如果 `enable_auto_create_when_overwrite` 为 `false`,未找到分区的数据将累计错误行直到失败。 -2. 如果指定了覆写的PARTITION,那么在此过程中,AUTO PARTITION 表表现得如同普通分区表一样,不满足现有分区条件的数据将被过滤,而非创建新的分区。 -3. 若指定 PARTITION 为 `partition(*)` (自动检测分区并覆写),当 `enable_auto_create_when_overwrite` 为 `true`,对于那些在表中有对应分区的数据,覆写它们对应的分区,其他已有分区不变。同时,对于没有对应分区的数据,按照该表的自动分区规则创建分区,并容纳这些原本没有对应分区的数据。如果 `enable_auto_create_when_overwrite` 为 `false`,未找到分区的数据将累计错误行直到失败。 - -在没有 `enable_auto_create_when_overwrite` 的版本,行为如同该变量值为 `false`。 - -示例如下: - -```sql -mysql> create table auto_list( - -> k0 varchar null - -> ) - -> auto partition by list (k0) - -> ( - -> PARTITION p1 values in (("Beijing"), ("BEIJING")), - -> PARTITION p2 values in (("Shanghai"), ("SHANGHAI")), - -> PARTITION p3 values in (("xxx"), ("XXX")), - -> PARTITION p4 values in (("list"), ("LIST")), - -> PARTITION p5 values in (("1234567"), ("7654321")) - -> ) - -> DISTRIBUTED BY HASH(`k0`) BUCKETS 1 - -> properties("replication_num" = "1"); -Query OK, 0 rows affected (0.14 sec) - -mysql> insert into auto_list values ("Beijing"),("Shanghai"),("xxx"),("list"),("1234567"); -Query OK, 5 rows affected (0.22 sec) - -mysql> insert overwrite table auto_list partition(*) values ("BEIJING"), ("new1"); -Query OK, 2 rows affected (0.28 sec) - -mysql> select * from auto_list; -+----------+ --- p1 被覆写,new1 得到了新分区,其他分区数据未变 -| k0 | -+----------+ -| 1234567 | -| BEIJING | -| list | -| xxx | -| new1 | -| Shanghai | -+----------+ -6 rows in set (0.48 sec) - -mysql> insert overwrite table auto_list values ("SHANGHAI"), ("new2"); -Query OK, 2 rows affected (0.17 sec) - -mysql> select * from auto_list; -+----------+ --- 整表原有数据被覆写,同时 new2 得到了新分区 -| k0 | -+----------+ -| new2 | -| SHANGHAI | -+----------+ -2 rows in set (0.15 sec) -``` - -## 举例 - -假设有`test` 表。该表包含两个列`c1`, `c2`,两个分区`p1`,`p2`。建表语句如下所示 - -```sql -CREATE TABLE IF NOT EXISTS test ( - `c1` int NOT NULL DEFAULT "1", - `c2` int NOT NULL DEFAULT "4" -) ENGINE=OLAP -UNIQUE KEY(`c1`) -PARTITION BY LIST (`c1`) -( -PARTITION p1 VALUES IN ("1","2","3"), -PARTITION p2 VALUES IN ("4","5","6") -) -DISTRIBUTED BY HASH(`c1`) BUCKETS 3 -PROPERTIES ( - "replication_allocation" = "tag.location.default: 1", - "in_memory" = "false", - "storage_format" = "V2" -); -``` - -#### Overwrite Table - -1. VALUES的形式重写`test`表 - - ```sql - # 单行重写 - INSERT OVERWRITE table test VALUES (1, 2); - INSERT OVERWRITE table test (c1, c2) VALUES (1, 2); - INSERT OVERWRITE table test (c1, c2) VALUES (1, DEFAULT); - INSERT OVERWRITE table test (c1) VALUES (1); - # 多行重写 - INSERT OVERWRITE table test VALUES (1, 2), (3, 2 + 2); - INSERT OVERWRITE table test (c1, c2) VALUES (1, 2), (3, 2 * 2); - INSERT OVERWRITE table test (c1, c2) VALUES (1, DEFAULT), (3, DEFAULT); - INSERT OVERWRITE table test (c1) VALUES (1), (3); - ``` - -- 第一条语句和第二条语句的效果一致,重写时如果不指定目标列,会使用表中的列顺序来作为默认的目标列。重写成功后表`test`中只有一行数据。 -- 第三条语句和第四条语句的效果一致,没有指定的列`c2`会使用默认值4来完成数据重写。重写成功后表`test`中只有一行数据。 -- 第五条语句和第六条语句的效果一致,在语句中可以使用表达式(如`2+2`,`2*2`),执行语句的时候会计算出表达式的结果再重写表`test`。重写成功后表`test`中有两行数据。 - -- 第七条语句和第八条语句的效果一致,没有指定的列`c2`会使用默认值4来完成数据重写。重写成功后表`test`中有两行数据。 - -2. 查询语句的形式重写`test`表,表`test2`和表`test`的数据格式需要保持一致,如果不一致会触发数据类型的隐式转换 - - ```sql - INSERT OVERWRITE table test SELECT * FROM test2; - INSERT OVERWRITE table test (c1, c2) SELECT * from test2; - ``` - -- 第一条语句和第二条语句的效果一致,该语句的作用是将数据从表`test2`中取出,使用取出的数据重写表`test`。重写成功后表`test`中的数据和表`test2`中的数据保持一致。 - -3. 重写 `test` 表并指定label - - ```sql - INSERT OVERWRITE table test WITH LABEL `label1` SELECT * FROM test2; - INSERT OVERWRITE table test WITH LABEL `label2` (c1, c2) SELECT * from test2; - ``` - -- 用户可以通过`SHOW LOAD;`命令查看此`label`导入作业的状态。需要注意的是label具有唯一性。 - - -#### Overwrite Table Partition - -使用 INSERT OVERWRITE 重写分区时,实际我们是将如下三步操作封装为一个事务并执行,如果中途失败,已进行的操作将会回滚: -1. 假设指定重写分区 p1,首先创建一个与重写的目标分区结构相同的空临时分区 `pTMP` -2. 向 `pTMP` 中写入数据 -3. 使用 `pTMP` 原子替换 `p1` 分区 - -举例如下: - -1. VALUES的形式重写`test`表分区`P1`和`p2` - - ```sql - # 单行重写 - INSERT OVERWRITE table test PARTITION(p1,p2) VALUES (1, 2); - INSERT OVERWRITE table test PARTITION(p1,p2) (c1, c2) VALUES (1, 2); - INSERT OVERWRITE table test PARTITION(p1,p2) (c1, c2) VALUES (1, DEFAULT); - INSERT OVERWRITE table test PARTITION(p1,p2) (c1) VALUES (1); - # 多行重写 - INSERT OVERWRITE table test PARTITION(p1,p2) VALUES (1, 2), (4, 2 + 2); - INSERT OVERWRITE table test PARTITION(p1,p2) (c1, c2) VALUES (1, 2), (4, 2 * 2); - INSERT OVERWRITE table test PARTITION(p1,p2) (c1, c2) VALUES (1, DEFAULT), (4, DEFAULT); - INSERT OVERWRITE table test PARTITION(p1,p2) (c1) VALUES (1), (4); - ``` - - 以上语句与重写表不同的是,它们都是重写表中的分区。分区可以一次重写一个分区也可以一次重写多个分区。需要注意的是,只有满足对应分区过滤条件的数据才能够重写成功。如果重写的数据中有数据不满足其中任意一个分区,那么本次重写会失败。一个失败的例子如下所示 - - ```sql - INSERT OVERWRITE table test PARTITION(p1,p2) VALUES (7, 2); - ``` - - 以上语句重写的数据`c1=7`分区`p1`和`p2`的条件都不满足,因此会重写失败。 - -2. 查询语句的形式重写`test`表分区`P1`和`p2`,表`test2`和表`test`的数据格式需要保持一致,如果不一致会触发数据类型的隐式转换 - - ```sql - INSERT OVERWRITE table test PARTITION(p1,p2) SELECT * FROM test2; - INSERT OVERWRITE table test PARTITION(p1,p2) (c1, c2) SELECT * from test2; - ``` - -3. 重写 `test` 表分区`P1`和`p2`并指定label - - ```sql - INSERT OVERWRITE table test PARTITION(p1,p2) WITH LABEL `label3` SELECT * FROM test2; - INSERT OVERWRITE table test PARTITION(p1,p2) WITH LABEL `label4` (c1, c2) SELECT * from test2; - ``` - -#### Overwrite Auto Detect Partition - -当 INSERT OVERWRITE 命令指定的 PARTITION 子句为 `PARTITION(*)` 时,此次覆写将会自动检测分区数据所在的分区。例如: - -```sql -mysql> create table test( - -> k0 int null - -> ) - -> partition by range (k0) - -> ( - -> PARTITION p10 values less than (10), - -> PARTITION p100 values less than (100), - -> PARTITION pMAX values less than (maxvalue) - -> ) - -> DISTRIBUTED BY HASH(`k0`) BUCKETS 1 - -> properties("replication_num" = "1"); -Query OK, 0 rows affected (0.11 sec) - -mysql> insert into test values (1), (2), (15), (100), (200); -Query OK, 5 rows affected (0.29 sec) - -mysql> select * from test order by k0; -+------+ -| k0 | -+------+ -| 1 | -| 2 | -| 15 | -| 100 | -| 200 | -+------+ -5 rows in set (0.23 sec) - -mysql> insert overwrite table test partition(*) values (3), (1234); -Query OK, 2 rows affected (0.24 sec) - -mysql> select * from test order by k0; -+------+ -| k0 | -+------+ -| 3 | -| 15 | -| 1234 | -+------+ -3 rows in set (0.20 sec) -``` - -可以看到,数据 3、1234 所在的分区 `p10` 和 `pMAX` 中的全部数据均被覆写,而 `p100` 分区未发生变化。该操作可以理解为 INSERT OVERWRITE 操作时通过 PARTITION 子句指定覆写特定分区的语法糖,它的实现原理与[指定重写特定分区](#overwrite-table-partition)相同。通过 `PARTITION(*)` 的语法,在覆写大量分区数据时我们可以免于手动填写全部分区名的繁琐。 - -### Keywords - - INSERT OVERWRITE, OVERWRITE, AUTO DETECT - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/INSERT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/INSERT.md deleted file mode 100644 index e7b00f9cecc07..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/INSERT.md +++ /dev/null @@ -1,234 +0,0 @@ ---- -{ - "title": "INSERT", - "language": "zh-CN" -} ---- - - - -## INSERT - -### Name - -INSERT - -## 描述 - -该语句是完成数据插入操作。 - -```sql -INSERT INTO table_name - [ PARTITION (p1, ...) ] - [ WITH LABEL label] - [ (column [, ...]) ] - [ [ hint [, ...] ] ] - { VALUES ( { expression | DEFAULT } [, ...] ) [, ...] | query } -``` - - Parameters - -> tablet_name: 导入数据的目的表。可以是 `db_name.table_name` 形式 -> -> partitions: 指定待导入的分区,必须是 `table_name` 中存在的分区,多个分区名称用逗号分隔 -> -> label: 为 Insert 任务指定一个 label -> -> column_name: 指定的目的列,必须是 `table_name` 中存在的列 -> -> expression: 需要赋值给某个列的对应表达式 -> -> DEFAULT: 让对应列使用默认值 -> -> query: 一个普通查询,查询的结果会写入到目标中 -> -> hint: 用于指示 `INSERT` 执行行为的一些指示符。目前 hint 有三个可选值`/*+ STREAMING */`、`/*+ SHUFFLE */`或`/*+ NOSHUFFLE */` -> 1. STREAMING:目前无实际作用,只是为了兼容之前的版本,因此保留。(之前的版本加上这个 hint 会返回 label,现在默认都会返回 label) -> 2. SHUFFLE:当目标表是分区表,开启这个 hint 会进行 repartiiton。 -> 3. NOSHUFFLE:即使目标表是分区表,也不会进行 repartiiton,但会做一些其他操作以保证数据正确落到各个分区中。 - -对于开启了 merge-on-write 的 Unique 表,还可以使用 insert 语句进行部分列更新的操作。要使用 insert 语句进行部分列更新,需要将会话变量 enable_unique_key_partial_update 的值设置为 true(该变量默认值为 false,即默认无法通过 insert 语句进行部分列更新)。进行部分列更新时,插入的列必须至少包含所有的 Key 列,同时指定需要更新的列。如果插入行 Key 列的值在原表中存在,则将更新具有相同 key 列值那一行的数据。如果插入行 Key 列的值在原表中不存在,则将向表中插入一条新的数据,此时 insert 语句中没有指定的列必须有默认值或可以为 null,这些缺失列会首先尝试用默认值填充,如果该列没有默认值,则尝试使用 null 值填充,如果该列不能为 null,则本次插入失败。 - -需要注意的是,控制 insert 语句是否开启严格模式的会话变量`enable_insert_strict`的默认值为 true,即 insert 语句默认开启严格模式,而在严格模式下进行部分列更新不允许更新不存在的 key。所以,在使用 insert 语句进行部分列更新的时候如果希望能插入不存在的 key,需要在`enable_unique_key_partial_update`设置为 true 的基础上同时将`enable_insert_strict`设置为 false。 - -注意: - -当前执行 `INSERT` 语句时,对于有不符合目标表格式的数据,默认的行为是过滤,比如字符串超长等。但是对于有要求数据不能够被过滤的业务场景,可以通过设置会话变量 `enable_insert_strict` 为 `true` 来确保当有数据被过滤掉的时候,`INSERT` 不会被执行成功。 - -## 举例 - -`test` 表包含两个列`c1`, `c2`。 - -1. 向`test`表中导入一行数据 - -```sql -INSERT INTO test VALUES (1, 2); -INSERT INTO test (c1, c2) VALUES (1, 2); -INSERT INTO test (c1, c2) VALUES (1, DEFAULT); -INSERT INTO test (c1) VALUES (1); -``` - -其中第一条、第二条语句是一样的效果。在不指定目标列时,使用表中的列顺序来作为默认的目标列。 -第三条、第四条语句表达的意思是一样的,使用`c2`列的默认值,来完成数据导入。 - -2. 向`test`表中一次性导入多行数据 - -```sql -INSERT INTO test VALUES (1, 2), (3, 2 + 2); -INSERT INTO test (c1, c2) VALUES (1, 2), (3, 2 * 2); -INSERT INTO test (c1) VALUES (1), (3); -INSERT INTO test (c1, c2) VALUES (1, DEFAULT), (3, DEFAULT); -``` - -其中第一条、第二条语句效果一样,向`test`表中一次性导入两条数据 -第三条、第四条语句效果已知,使用`c2`列的默认值向`test`表中导入两条数据 - -3. 向 `test` 表中导入一个查询语句结果 - -```sql -INSERT INTO test SELECT * FROM test2; -INSERT INTO test (c1, c2) SELECT * from test2; -``` - -4. 向 `test` 表中导入一个查询语句结果,并指定 partition 和 label - -```sql -INSERT INTO test PARTITION(p1, p2) WITH LABEL `label1` SELECT * FROM test2; -INSERT INTO test WITH LABEL `label1` (c1, c2) SELECT * from test2; -``` - - -### Keywords - - INSERT - -### Best Practice - -1. 查看返回结果 - - INSERT 操作是一个同步操作,返回结果即表示操作结束。用户需要根据返回结果的不同,进行对应的处理。 - - 1. 执行成功,结果集为空 - - 如果 insert 对应 select 语句的结果集为空,则返回如下: - - ```sql - mysql> insert into tbl1 select * from empty_tbl; - Query OK, 0 rows affected (0.02 sec) - ``` - - `Query OK` 表示执行成功。`0 rows affected` 表示没有数据被导入。 - - 2. 执行成功,结果集不为空 - - 在结果集不为空的情况下。返回结果分为如下几种情况: - - 1. Insert 执行成功并可见: - - ```sql - mysql> insert into tbl1 select * from tbl2; - Query OK, 4 rows affected (0.38 sec) - {'label':'insert_8510c568-9eda-4173-9e36-6adc7d35291c', 'status':'visible', 'txnId':'4005'} - - mysql> insert into tbl1 with label my_label1 select * from tbl2; - Query OK, 4 rows affected (0.38 sec) - {'label':'my_label1', 'status':'visible', 'txnId':'4005'} - - mysql> insert into tbl1 select * from tbl2; - Query OK, 2 rows affected, 2 warnings (0.31 sec) - {'label':'insert_f0747f0e-7a35-46e2-affa-13a235f4020d', 'status':'visible', 'txnId':'4005'} - - mysql> insert into tbl1 select * from tbl2; - Query OK, 2 rows affected, 2 warnings (0.31 sec) - {'label':'insert_f0747f0e-7a35-46e2-affa-13a235f4020d', 'status':'committed', 'txnId':'4005'} - ``` - - `Query OK` 表示执行成功。`4 rows affected` 表示总共有 4 行数据被导入。`2 warnings` 表示被过滤的行数。 - - 同时会返回一个 json 串: - - ```json - {'label':'my_label1', 'status':'visible', 'txnId':'4005'} - {'label':'insert_f0747f0e-7a35-46e2-affa-13a235f4020d', 'status':'committed', 'txnId':'4005'} - {'label':'my_label1', 'status':'visible', 'txnId':'4005', 'err':'some other error'} - ``` - - `label` 为用户指定的 label 或自动生成的 label。Label 是该 Insert Into 导入作业的标识。每个导入作业,都有一个在单 database 内部唯一的 Label。 - - `status` 表示导入数据是否可见。如果可见,显示 `visible`,如果不可见,显示 `committed`。 - - `txnId` 为这个 insert 对应的导入事务的 id。 - - `err` 字段会显示一些其他非预期错误。 - - 当需要查看被过滤的行时,用户可以通过如下语句 - - ```sql - show load where label="xxx"; - ``` - - 返回结果中的 URL 可以用于查询错误的数据,具体见后面 **查看错误行** 小结。 - - **数据不可见是一个临时状态,这批数据最终是一定可见的** - - 可以通过如下语句查看这批数据的可见状态: - - ```sql - show transaction where id=4005; - ``` - - 返回结果中的 `TransactionStatus` 列如果为 `visible`,则表述数据可见。 - - 3. 执行失败 - - 执行失败表示没有任何数据被成功导入,并返回如下: - - ```sql - mysql> insert into tbl1 select * from tbl2 where k1 = "a"; - ERROR 1064 (HY000): all partitions have no load data. url: http://10.74.167.16:8042/api/_load_error_log?file=__shard_2/error_log_insert_stmt_ba8bb9e158e4879-ae8de8507c0bf8a2_ba8bb9e158e4879_ae8de8507c0bf8a2 - ``` - - 其中 `ERROR 1064 (HY000): all partitions have no load data` 显示失败原因。后面的 url 可以用于查询错误的数据: - - ```sql - show load warnings on "url"; - ``` - - 可以查看到具体错误行。 - -2. 超时时间 - - INSERT 操作的超时时间由 [会话变量](../../../../advanced/variables.md) `insert_timeout` 控制。默认为 4 小时。超时则作业会被取消。 - -3. Label 和原子性 - - INSERT 操作同样能够保证导入的原子性,可以参阅 [导入事务和原子性](../../../../data-operate/import/import-scenes/load-atomicity.md) 文档。 - - 当需要使用 `CTE(Common Table Expressions)` 作为 insert 操作中的查询部分时,必须指定 `WITH LABEL` 和 `column` 部分。 - -4. 过滤阈值 - - 与其他导入方式不同,INSERT 操作不能指定过滤阈值(`max_filter_ratio`)。默认的过滤阈值为 1,即素有错误行都可以被忽略。 - - 对于有要求数据不能够被过滤的业务场景,可以通过设置 [会话变量](../../../../advanced/variables.md) `enable_insert_strict` 为 `true` 来确保当有数据被过滤掉的时候,`INSERT` 不会被执行成功。 - -5. 性能问题 - - 不建议使用 `VALUES` 方式进行单行的插入。如果必须这样使用,请将多行数据合并到一个 INSERT 语句中进行批量提交。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/SELECT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/SELECT.md deleted file mode 100644 index 489058a760edf..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/SELECT.md +++ /dev/null @@ -1,416 +0,0 @@ ---- -{ - "title": "SELECT", - "language": "zh-CN" -} - ---- - - - -## SELECT - -### Name - -SELECT - -## 描述 - -主要介绍 Select 语法使用 - -语法: - -```sql -SELECT - [hint_statement, ...] - [ALL | DISTINCT | DISTINCTROW | ALL EXCEPT ( col_name1 [, col_name2, col_name3, ...] )] - select_expr [, select_expr ...] - [FROM table_references - [PARTITION partition_list] - [TABLET tabletid_list] - [TABLESAMPLE sample_value [ROWS | PERCENT] - [REPEATABLE pos_seek]] - [WHERE where_condition] - [GROUP BY [GROUPING SETS | ROLLUP | CUBE] {col_name | expr | position}] - [HAVING where_condition] - [ORDER BY {col_name | expr | position} - [ASC | DESC], ...] - [LIMIT {[offset,] row_count | row_count OFFSET offset}] - [INTO OUTFILE 'file_name'] -``` - -**语法说明:** - -1. select_expr, ... 检索并在结果中显示的列,使用别名时,as 为自选。 - -2. select_expr, ... 检索的目标表(一个或者多个表(包括子查询产生的临时表) - -3. where_definition 检索条件(表达式),如果存在 WHERE 子句,其中的条件对行数据进行筛选。where_condition 是一个表达式,对于要选择的每一行,其计算结果为 true。如果没有 WHERE 子句,该语句将选择所有行。在 WHERE 表达式中,您可以使用除聚合函数之外的任何 MySQL 支持的函数和运算符 - -4. `ALL | DISTINCT ` :对结果集进行刷选,all 为全部,distinct/distinctrow 将刷选出重复列,默认为 all - -5. `ALL EXCEPT`:对全部(all)结果集进行筛选,except 指定要从全部结果集中排除的一个或多个列的名称。输出中将忽略所有匹配的列名称。 - -6. `INTO OUTFILE 'file_name' ` :保存结果至新文件(之前不存在)中,区别在于保存的格式。 - -7. `Group by having`:对结果集进行分组,having 出现则对 group by 的结果进行刷选。`Grouping Sets`、`Rollup`、`Cube` 为 group by 的扩展,详细可参考[GROUPING SETS 设计文档](https://doris.apache.org/zh-CN/community/design/grouping_sets_design)。 - -8. `Order by `: 对最后的结果进行排序,Order by 通过比较一列或者多列的大小来对结果集进行排序。 - - Order by 是比较耗时耗资源的操作,因为所有数据都需要发送到 1 个节点后才能排序,排序操作相比不排序操作需要更多的内存。 - - 如果需要返回前 N 个排序结果,需要使用 LIMIT 从句;为了限制内存的使用,如果用户没有指定 LIMIT 从句,则默认返回前 65535 个排序结果。 - -9. `Limit n`: 限制输出结果中的行数,`limit m,n` 表示从第 m 行开始输出 n 条记录,**使用 limit m,n 的时候要加上 order by 才有意义,否则每次执行的数据可能会不一致** - -10. `Having` 从句不是过滤表中的行数据,而是过滤聚合函数产出的结果。 - - 通常来说 `having` 要和聚合函数(例如 :`COUNT(), SUM(), AVG(), MIN(), MAX()`)以及 `group by` 从句一起使用。 - -11. SELECT 支持使用 PARTITION 显式分区选择,其中包含 `table_reference` 中表的名称后面的分区或子分区(或两者)列表。 - -12. `[TABLET tids] TABLESAMPLE n [ROWS | PERCENT] [REPEATABLE seek]`: 在 FROM 子句中限制表的读取行数,根据指定的行数或百分比从表中伪随机的选择数个 Tablet,REPEATABLE 指定种子数可使选择的样本再次返回,此外也可手动指定 TableID,注意这只能用于 OLAP 表。 - -13. `hint_statement`: 在 selectlist 前面使用 hint 表示可以通过 hint 去影响优化器的行为以期得到想要的执行计划,详情可参考[joinHint 使用文档](https://doris.apache.org/zh-CN/docs/2.0/query/join-optimization/join-hint)。 - -**语法约束:** - -1. SELECT 也可用于检索计算的行而不引用任何表。 -2. 所有的字句必须严格地按照上面格式排序,一个 HAVING 子句必须位于 GROUP BY 子句之后,并位于 ORDER BY 子句之前。 -3. 别名关键词 AS 自选。别名可用于 group by,order by 和 having -4. Where 子句:执行 WHERE 语句以确定哪些行应被包含在 GROUP BY 部分中,而 HAVING 用于确定应使用结果集中的哪些行。 -5. HAVING 子句可以引用总计函数,而 WHERE 子句不能引用,如 count,sum,max,min,avg,同时,where 子句可以引用除总计函数外的其他函数。Where 子句中不能使用列别名来定义条件。 -6. Group by 后跟 with rollup 可以对结果进行一次或者多次统计。 - -**联接查询:** - -Doris 支持以下 JOIN 语法 - -```sql -JOIN -table_references: - table_reference [, table_reference] … -table_reference: - table_factor - | join_table -table_factor: - tbl_name [[AS] alias] - [{USE|IGNORE|FORCE} INDEX (key_list)] - | ( table_references ) - | { OJ table_reference LEFT OUTER JOIN table_reference - ON conditional_expr } -join_table: - table_reference [INNER | CROSS] JOIN table_factor [join_condition] - | table_reference LEFT [OUTER] JOIN table_reference join_condition - | table_reference NATURAL [LEFT [OUTER]] JOIN table_factor - | table_reference RIGHT [OUTER] JOIN table_reference join_condition - | table_reference NATURAL [RIGHT [OUTER]] JOIN table_factor -join_condition: - ON conditional_expr -``` - -**UNION 语法:** - -```sql -SELECT ... -UNION [ALL| DISTINCT] SELECT ...... -[UNION [ALL| DISTINCT] SELECT ...] -``` - -`UNION` 用于将多个 `SELECT` 语句 的结果组合 到单个结果集中。 - -第一个 `SELECT` 语句中的列名称用作返回结果的列名称。在每个 `SELECT`语句的 相应位置列出的选定列 应具有相同的数据类型。 (例如,第一个语句选择的第一列应该与其他语句选择的第一列具有相同的类型。) - -默认行为 `UNION`是从结果中删除重复的行。可选 `DISTINCT` 关键字除了默认值之外没有任何效果,因为它还指定了重复行删除。使用可选 `ALL` 关键字,不会发生重复行删除,结果包括所有 `SELECT` 语句中的 所有匹配行 - -**WITH 语句**: - -要指定公用表表达式,请使用 `WITH` 具有一个或多个逗号分隔子句的子句。每个子条款都提供一个子查询,用于生成结果集,并将名称与子查询相关联。下面的示例定义名为的 CTE `cte1` 和 `cte2` 中 `WITH` 子句,并且是指在它们的顶层 `SELECT` 下面的 `WITH` 子句: - -```sql -WITH - cte1 AS (SELECT a,b FROM table1), - cte2 AS (SELECT c,d FROM table2) -SELECT b,d FROM cte1 JOIN cte2 -WHERE cte1.a = cte2.c; -``` - -在包含该 `WITH`子句 的语句中,可以引用每个 CTE 名称以访问相应的 CTE 结果集。 - -CTE 名称可以在其他 CTE 中引用,从而可以基于其他 CTE 定义 CTE。 - -目前不支持递归的 CTE。 - -## 举例 - -1. 查询年龄分别是 18,20,25 的学生姓名 - - ```sql - select Name from student where age in (18,20,25); - ``` - -2. ALL EXCEPT 示例 - ```sql - -- 查询除了学生年龄的所有信息 - select * except(age) from student; - ``` - -3. GROUP BY 示例 - - ```sql - --查询 tb_book 表,按照 type 分组,求每类图书的平均价格, - select type,avg(price) from tb_book group by type; - ``` - -4. DISTINCT 使用 - - ``` - --查询 tb_book 表,除去重复的 type 数据 - select distinct type from tb_book; - ``` - -5. ORDER BY 示例 - - 对查询结果进行升序(默认)或降序(DESC)排列。升序 NULL 在最前面,降序 NULL 在最后面 - - ```sql - --查询 tb_book 表中的所有记录,按照 id 降序排列,显示三条记录 - select * from tb_book order by id desc limit 3; - ``` - -6. LIKE 模糊查询 - - 可实现模糊查询,它有两种通配符:`%`和`_`,`%`可以匹配一个或多个字符,`_`可以匹配一个字符 - - ``` - --查找所有第二个字符是 h 的图书 - select * from tb_book where name like('_h%'); - ``` - -7. LIMIT 限定结果行数 - - ```sql - --1.降序显示 3 条记录 - select * from tb_book order by price desc limit 3; - - --2.从 id=1 显示 4 条记录 - select * from tb_book where id limit 1,4; - ``` - -8. CONCAT 联合多列 - - ```sql - --把 name 和 price 合并成一个新的字符串输出 - select id,concat(name,":",price) as info,type from tb_book; - ``` - -9. 使用函数和表达式 - - ```sql - --计算 tb_book 表中各类图书的总价格 - select sum(price) as total,type from tb_book group by type; - --price 打八折 - select *,(price * 0.8) as "八折" from tb_book; - ``` - -10. UNION 示例 - - ```sql - SELECT a FROM t1 WHERE a = 10 AND B = 1 ORDER by a LIMIT 10 - UNION - SELECT a FROM t2 WHERE a = 11 AND B = 2 ORDER by a LIMIT 10; - ``` - -11. WITH 子句示例 - - ```sql - WITH cte AS - ( - SELECT 1 AS col1, 2 AS col2 - UNION ALL - SELECT 3, 4 - ) - SELECT col1, col2 FROM cte; - ``` - -12. JOIN 示例 - - ```sql - SELECT * FROM t1 LEFT JOIN (t2, t3, t4) - ON (t2.a = t1.a AND t3.b = t1.b AND t4.c = t1.c) - ``` - - 等同于 - - ```sql - SELECT * FROM t1 LEFT JOIN (t2 CROSS JOIN t3 CROSS JOIN t4) - ON (t2.a = t1.a AND t3.b = t1.b AND t4.c = t1.c) - ``` - -13. INNER JOIN - - ```sql - SELECT t1.name, t2.salary - FROM employee AS t1 INNER JOIN info AS t2 ON t1.name = t2.name; - - SELECT t1.name, t2.salary - FROM employee t1 INNER JOIN info t2 ON t1.name = t2.name; - ``` - -14. LEFT JOIN - - ```sql - SELECT left_tbl.* - FROM left_tbl LEFT JOIN right_tbl ON left_tbl.id = right_tbl.id - WHERE right_tbl.id IS NULL; - ``` - -15. RIGHT JOIN - - ```sql - mysql> SELECT * FROM t1 RIGHT JOIN t2 ON (t1.a = t2.a); - +------+------+------+------+ - | a | b | a | c | - +------+------+------+------+ - | 2 | y | 2 | z | - | NULL | NULL | 3 | w | - +------+------+------+------+ - ``` - -16. TABLESAMPLE - - ```sql - --在t1中伪随机的抽样1000行。注意实际是根据表的统计信息选择若干Tablet,被选择的Tablet总行数可能大于1000,所以若想明确返回1000行需要加上Limit。 - SELECT * FROM t1 TABLET(10001) TABLESAMPLE(1000 ROWS) REPEATABLE 2 limit 1000; - ``` - -### keywords - - SELECT - -### Best Practice - -1. 关于 SELECT 子句的一些附加知识 - - - 可以使用 AS alias_name 为 select_expr 指定别名。别名用作表达式的列名,可用于 GROUP BY,ORDER BY 或 HAVING 子句。AS 关键字是在指定列的别名时养成使用 AS 是一种好习惯。 - - - FROM 后的 table_references 指示参与查询的一个或者多个表。如果列出了多个表,就会执行 JOIN 操作。而对于每一个指定表,都可以为其定义别名 - - - SELECT 后被选择的列,可以在 ORDER IN 和 GROUP BY 中,通过列名、列别名或者代表列位置的整数(从 1 开始)来引用 - - ```sql - SELECT college, region, seed FROM tournament - ORDER BY region, seed; - - SELECT college, region AS r, seed AS s FROM tournament - ORDER BY r, s; - - SELECT college, region, seed FROM tournament - ORDER BY 2, 3; - ``` - - - 如果 ORDER BY 出现在子查询中,并且也应用于外部查询,则最外层的 ORDER BY 优先。 - - - 如果使用了 GROUP BY,被分组的列会自动按升序排列(就好像有一个 ORDER BY 语句后面跟了同样的列)。如果要避免 GROUP BY 因为自动排序生成的开销,添加 ORDER BY NULL 可以解决: - - ```sql - SELECT a, COUNT(b) FROM test_table GROUP BY a ORDER BY NULL; - ``` - - - - - 当使用 ORDER BY 或 GROUP BY 对 SELECT 中的列进行排序时,服务器仅使用 max_sort_length 系统变量指示的初始字节数对值进行排序。 - - - Having 子句一般应用在最后,恰好在结果集被返回给 MySQL 客户端前,且没有进行优化。(而 LIMIT 应用在 HAVING 后) - - SQL 标准要求:HAVING 必须引用在 GROUP BY 列表中或者聚合函数使用的列。然而,MySQL 对此进行了扩展,它允许 HAVING 引用 Select 子句列表中的列,还有外部子查询的列。 - - 如果 HAVING 引用的列具有歧义,会有警告产生。下面的语句中,col2 具有歧义: - - ```sql - SELECT COUNT(col1) AS col2 FROM t GROUP BY col2 HAVING col2 = 2; - ``` - - - 切记不要在该使用 WHERE 的地方使用 HAVING。HAVING 是和 GROUP BY 搭配的。 - - - HAVING 子句可以引用聚合函数,而 WHERE 不能。 - - ```sql - SELECT user, MAX(salary) FROM users - GROUP BY user HAVING MAX(salary) > 10; - ``` - - - LIMIT 子句可用于约束 SELECT 语句返回的行数。LIMIT 可以有一个或者两个参数,都必须为非负整数。 - - ```sql - /*取回结果集中的 6~15 行*/ - SELECT * FROM tbl LIMIT 5,10; - /*那如果要取回一个设定某个偏移量之后的所有行,可以为第二参数设定一个非常大的常量。以下查询取回从第 96 行起的所有数据*/ - SELECT * FROM tbl LIMIT 95,18446744073709551615; - /*若 LIMIT 只有一个参数,则参数指定应该取回的行数,偏移量默认为 0,即从第一行起*/ - ``` - - - SELECT...INTO 可以让查询结果写入到文件中 - -2. SELECT 关键字的修饰符 - - - 去重 - - ALL 和 DISTINCT 修饰符指定是否对结果集中的行(应该不是某个列)去重。 - - ALL 是默认修饰符,即满足要求的所有行都要被取回来。 - - DISTINCT 删除重复的行。 - -3. 子查询的主要优势 - - - 子查询允许结构化的查询,这样就可以把一个语句的每个部分隔离开。 - - 有些操作需要复杂的联合和关联。子查询提供了其它的方法来执行这些操作 - -4. 加速查询 - - - 尽可能利用 Doris 的分区分桶作为数据过滤条件,减少数据扫描范围 - - 充分利用 Doris 的前缀索引字段作为数据过滤条件加速查询速度 - -4. UNION - - - 只使用 union 关键词和使用 union disitnct 的效果是相同的。由于去重工作是比较耗费内存的,因此使用 union all 操作查询速度会快些,耗费内存会少些。如果用户想对返回结果集进行 order by 和 limit 操作,需要将 union 操作放在子查询中,然后 select from subquery,最后把 subquery 和 order by 放在子查询外面。 - - ```sql - select * from (select age from student_01 union all select age from student_02) as t1 - order by age limit 4; - - +-------------+ - | age | - +-------------+ - | 18 | - | 19 | - | 20 | - | 21 | - +-------------+ - 4 rows in set (0.01 sec) - ``` - -4. JOIN - - - 在 inner join 条件里除了支持等值 join,还支持不等值 join,为了性能考虑,推荐使用等值 join。 - - 其它 join 只支持等值 join - - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/UPDATE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/UPDATE.md deleted file mode 100644 index cc20f8b0e6ff1..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/UPDATE.md +++ /dev/null @@ -1,181 +0,0 @@ ---- -{ - "title": "UPDATE", - "language": "zh-CN" -} ---- - - - -## UPDATE - -### Name - -UPDATE - -## 描述 - -该语句是为进行对数据进行更新的操作,UPDATE 语句目前仅支持 UNIQUE KEY 模型。 - -UPDATE操作目前只支持更新Value列,Key列的更新可参考[使用FlinkCDC更新Key列](../../../../ecosystem/flink-doris-connector.md#使用flinkcdc更新key列)。 - -## 语法 - -```sql -[cte] -UPDATE target_table [table_alias] - SET assignment_list - [ FROM additional_tables] - WHERE condition -``` - -#### Required Parameters - -+ target_table: 待更新数据的目标表。可以是 'db_name.table_name' 形式 -+ assignment_list: 待更新的目标列,形如 'col_name = value, col_name = value' 格式 -+ WHERE condition: 期望更新的条件,一个返回 true 或者 false 的表达式即可 - -#### Optional Parameters - -+ cte: 通用表达式。可以是 'WITH a AS SELECT * FROM tbl' 形式 -+ table_alias: 表的别名 -+ FROM additional_tables: 指定一个或多个表,用于选中更新的行,或者获取更新的值。注意,如需要在此列表中再次使用目标表,需要为其显式指定别名。 - -#### Note - -当前 UPDATE 语句仅支持在 UNIQUE KEY 模型上的行更新。 - -## 举例 - -`test` 表是一个 unique 模型的表,包含: k1, k2, v1, v2 四个列。其中 k1, k2 是 key,v1, v2 是value,聚合方式是 Replace。 - -1. 将 'test' 表中满足条件 k1 =1 , k2 =2 的 v1 列更新为 1 - -```sql -UPDATE test SET v1 = 1 WHERE k1=1 and k2=2; -``` - -2. 将 'test' 表中 k1=1 的列的 v1 列自增1 - -```sql -UPDATE test SET v1 = v1+1 WHERE k1=1; -``` - -3. 使用`t2`和`t3`表连接的结果,更新`t1` - -```sql --- 创建t1, t2, t3三张表 -CREATE TABLE t1 - (id INT, c1 BIGINT, c2 STRING, c3 DOUBLE, c4 DATE) -UNIQUE KEY (id) -DISTRIBUTED BY HASH (id) -PROPERTIES('replication_num'='1', "function_column.sequence_col" = "c4"); - -CREATE TABLE t2 - (id INT, c1 BIGINT, c2 STRING, c3 DOUBLE, c4 DATE) -DISTRIBUTED BY HASH (id) -PROPERTIES('replication_num'='1'); - -CREATE TABLE t3 - (id INT) -DISTRIBUTED BY HASH (id) -PROPERTIES('replication_num'='1'); - --- 插入数据 -INSERT INTO t1 VALUES - (1, 1, '1', 1.0, '2000-01-01'), - (2, 2, '2', 2.0, '2000-01-02'), - (3, 3, '3', 3.0, '2000-01-03'); - -INSERT INTO t2 VALUES - (1, 10, '10', 10.0, '2000-01-10'), - (2, 20, '20', 20.0, '2000-01-20'), - (3, 30, '30', 30.0, '2000-01-30'), - (4, 4, '4', 4.0, '2000-01-04'), - (5, 5, '5', 5.0, '2000-01-05'); - -INSERT INTO t3 VALUES - (1), - (4), - (5); - --- 更新 t1 -UPDATE t1 - SET t1.c1 = t2.c1, t1.c3 = t2.c3 * 100 - FROM t2 INNER JOIN t3 ON t2.id = t3.id - WHERE t1.id = t2.id; -``` - -预期结果为,更新了`t1`表`id`为`1`的列 - -``` -+----+----+----+--------+------------+ -| id | c1 | c2 | c3 | c4 | -+----+----+----+--------+------------+ -| 1 | 10 | 1 | 1000.0 | 2000-01-01 | -| 2 | 2 | 2 | 2.0 | 2000-01-02 | -| 3 | 3 | 3 | 3.0 | 2000-01-03 | -+----+----+----+--------+------------+ -``` - -4. 使用 cte 更新表 - -```sql -create table orders( - o_orderkey bigint, - o_totalprice decimal(15, 2) -) unique key(o_orderkey) -distributed by hash(o_orderkey) buckets 1 -properties ( - "replication_num" = "1" -); - -insert into orders values -(1, 34.1), -(2, 432.8); - -create table lineitem( - l_linenumber int, - o_orderkey bigint, - l_discount decimal(15, 2) -) unique key(l_linenumber) -distributed by hash(l_linenumber) buckets 1 -properties ( - "replication_num" = "1" -); - -insert into lineitem values -(1, 1, 1.23), -(2, 1, 3.21), -(3, 2, 18.08), -(4, 2, 23.48); - -with discount_orders as ( - select * from orders - where o_totalprice > 100 -) -update lineitem set l_discount = l_discount*0.9 -from discount_orders -where lineitem.o_orderkey = discount_orders.o_orderkey; -``` - -### Keywords - - UPDATE diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/OUTFILE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/OUTFILE.md deleted file mode 100644 index 3aef1b0ff4216..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/OUTFILE.md +++ /dev/null @@ -1,419 +0,0 @@ ---- -{ - "title": "OUTFILE", - "language": "zh-CN" -} ---- - - - -## OUTFILE - -### Name - -OUTFILE - -## 描述 - - `SELECT INTO OUTFILE` 命令用于将查询结果导出为文件。目前支持通过 Broker 进程, S3 协议或 HDFS 协议,导出到远端存储,如 HDFS,S3,BOS,COS(腾讯云)上。 - -#### 语法: - -``` -query_stmt -INTO OUTFILE "file_path" -[format_as] -[properties] -``` - -#### 说明: - -1. file_path - - 文件存储的路径及文件前缀。 - - ``` - file_path 指向文件存储的路径以及文件前缀。如 `hdfs://path/to/my_file_`。 - - 最终的文件名将由 `my_file_`、文件序号以及文件格式后缀组成。其中文件序号由0开始,数量为文件被分割的数量。如: - my_file_abcdefg_0.csv - my_file_abcdefg_1.csv - my_file_abcdegf_2.csv - ``` - - 也可以省略文件前缀,只指定文件目录,如`hdfs://path/to/` - -2. format_as - - ``` - FORMAT AS CSV - ``` - - 指定导出格式. 支持 CSV、PARQUET、CSV_WITH_NAMES、CSV_WITH_NAMES_AND_TYPES、ORC. 默认为 CSV。 - - > 注:PARQUET、CSV_WITH_NAMES、CSV_WITH_NAMES_AND_TYPES、ORC 在 1.2 版本开始支持。 - -3. properties - - ``` - 指定相关属性。目前支持通过 Broker 进程, 或通过 S3/HDFS 协议进行导出。 - - 语法: - [PROPERTIES ("key"="value", ...)] - 支持如下属性: - - 文件相关的属性: - `column_separator`: 列分隔符,只用于 CSV 相关格式。在 1.2 版本开始支持多字节分隔符,如:"\\x01", "abc"。 - `line_delimiter`: 行分隔符,只用于 CSV 相关格式。在 1.2 版本开始支持多字节分隔符,如:"\\x01", "abc"。 - `max_file_size`: 单个文件大小限制,如果结果超过这个值,将切割成多个文件, `max_file_size` 取值范围是[5MB, 2GB], 默认为 `1GB`。(当指定导出为 OCR 文件格式时,实际切分文件的大小将是 64MB 的倍数,如:指定 `max_file_size = 5MB`, 实际将以 64 MB 为切分;指定 `max_file_size = 65MB`, 实际将以 128 MB 为切分) - `delete_existing_files`: 默认为 `false`,若指定为 `true`,则会先删除 `file_path` 指定的目录下的所有文件,然后导出数据到该目录下。例如:"file_path" = "/user/tmp", 则会删除"/user/"下所有文件及目录;"file_path" = "/user/tmp/", 则会删除"/user/tmp/"下所有文件及目录。 - `file_suffix`: 指定导出文件的后缀,若不指定该参数,将使用文件格式的默认后缀。 - `compress_type`:当指定导出的文件格式为 Parquet / ORC 文件时,可以指定 Parquet / ORC 文件使用的压缩方式。Parquet 文件格式可指定压缩方式为 SNAPPY,GZIP,BROTLI,ZSTD,LZ4 及 PLAIN,默认值为 SNAPPY。ORC 文件格式可指定压缩方式为 PLAIN,SNAPPY,ZLIB 以及 ZSTD,默认值为 ZLIB。该参数自 2.1.5 版本开始支持。(PLAIN 就是不采用压缩) - - Broker 相关属性需加前缀 `broker.`: - broker.name: broker名称 - broker.hadoop.security.authentication: 指定认证方式为 kerberos - broker.kerberos_principal: 指定 kerberos 的 principal - broker.kerberos_keytab: 指定 kerberos 的 keytab 文件路径。该文件必须为 Broker 进程所在服务器上的文件的绝对路径。并且可以被 Broker 进程访问 - - HDFS 相关属性: - fs.defaultFS: namenode 地址和端口 - hadoop.username: hdfs 用户名 - dfs.nameservices: name service名称,与hdfs-site.xml保持一致 - dfs.ha.namenodes.[nameservice ID]: namenode的id列表,与hdfs-site.xml保持一致 - dfs.namenode.rpc-address.[nameservice ID].[name node ID]: Name node的rpc地址,数量与namenode数量相同,与hdfs-site.xml保持一致 - dfs.client.failover.proxy.provider.[nameservice ID]: HDFS客户端连接活跃namenode的java类,通常是"org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider" - - 对于开启kerberos认证的Hadoop 集群,还需要额外设置如下 PROPERTIES 属性: - dfs.namenode.kerberos.principal: HDFS namenode 服务的 principal 名称 - hadoop.security.authentication: 认证方式设置为 kerberos - hadoop.kerberos.principal: 设置 Doris 连接 HDFS 时使用的 Kerberos 主体 - hadoop.kerberos.keytab: 设置 keytab 本地文件路径 - - S3 协议则直接执行 S3 协议配置即可: - s3.endpoint - s3.access_key - s3.secret_key - s3.region - use_path_style: (选填) 默认为 `false` 。S3 SDK 默认使用 Virtual-hosted Style 方式。但某些对象存储系统可能没开启或不支持 Virtual-hosted Style 方式的访问,此时可以添加 `use_path_style` 参数来强制使用 Path Style 访问方式。 - ``` - - > 注意:若要使用 `delete_existing_files` 参数,还需要在 `fe.conf` 中添加配置`enable_delete_existing_files = true`并重启fe,此时delete_existing_files才会生效。delete_existing_files = true 是一个危险的操作,建议只在测试环境中使用。 - -4. 导出的数据类型 - - 所有文件类型都支持导出基本数据类型,而对于复杂数据类型(ARRAY/MAP/STRUCT),当前只有csv/orc/csv_with_names/csv_with_names_and_types支持导出复杂类型,且不支持嵌套复杂类型。 - -5. 并发导出 - - 设置 Session 变量```set enable_parallel_outfile = true;```可开启 Outfile 并发导出,详细使用方法见[导出查询结果集](../../../data-operate/export/outfile.md) - -6. 导出到本地 - - 导出到本地文件时需要先在 `fe.conf` 中配置`enable_outfile_to_local=true` - - ```sql - select * from tbl1 limit 10 - INTO OUTFILE "file:///home/work/path/result_"; - ``` - -#### 返回结果说明 - -Outfile 语句返回的结果,各个列的含义如下: -* FileNumber:最终生成的文件个数。 -* TotalRows:结果集行数。 -* FileSize:导出文件总大小。单位字节。 -* URL:导出的文件路径的前缀,多个文件会以后缀 `_0`,`_1` 依次编号。 - -#### 数据类型映射 - -Parquet、ORC 文件格式拥有自己的数据类型,Doris的导出功能能够自动将 Doris 的数据类型导出到 Parquet/ORC 文件格式的对应数据类型,以下是 Apache Doris 数据类型和 Parquet/ORC 文件格式的数据类型映射关系表: - -1. Doris 导出到 ORC 文件格式的数据类型映射表: - - | Doris Type | Orc Type | - | --- | --- | - | boolean | boolean | - | tinyint | tinyint | - | smallint | smallint | - | int | int | - | bigint | bigint | - | largeInt | string | - | date | string | - | datev2 | string | - | datetime | string | - | datetimev2 | timestamp | - | float | float | - | double | double | - | char / varchar / string | string | - | decimal | decimal | - | struct | struct | - | map | map | - | array | array | - - -2. Doris 导出到 Parquet 文件格式时,会先将 Doris 内存数据转换为 Arrow 内存数据格式,然后由 Arrow 写出到 Parquet 文件格式。Doris 数据类型到 Arrow 数据类的映射关系为: - - | Doris Type | Arrow Type | - | --- | --- | - | boolean | boolean | - | tinyint | int8 | - | smallint | int16 | - | int | int32 | - | bigint | int64 | - | largeInt | utf8 | - | date | utf8 | - | datev2 | utf8 | - | datetime | utf8 | - | datetimev2 | utf8 | - | float | float32 | - | double | float64 | - | char / varchar / string | utf8 | - | decimal | decimal128 | - | struct | struct | - | map | map | - | array | list | - -## 举例 - -1. 使用 Broker 方式导出,将简单查询结果导出到文件 `hdfs://path/to/result.txt`。指定导出格式为 CSV。使用 `my_broker` 并设置 kerberos 认证信息。指定列分隔符为 `,`,行分隔符为 `\n`。 - - ```sql - SELECT * FROM tbl - INTO OUTFILE "hdfs://path/to/result_" - FORMAT AS CSV - PROPERTIES - ( - "broker.name" = "my_broker", - "broker.hadoop.security.authentication" = "kerberos", - "broker.kerberos_principal" = "doris@YOUR.COM", - "broker.kerberos_keytab" = "/home/doris/my.keytab", - "column_separator" = ",", - "line_delimiter" = "\n", - "max_file_size" = "100MB" - ); - ``` - - 最终生成文件如如果不大于 100MB,则为:`result_0.csv`。 - 如果大于 100MB,则可能为 `result_0.csv, result_1.csv, ...`。 - -2. 将简单查询结果导出到文件 `hdfs://path/to/result.parquet`。指定导出格式为 PARQUET。使用 `my_broker` 并设置 kerberos 认证信息。 - - ```sql - SELECT c1, c2, c3 FROM tbl - INTO OUTFILE "hdfs://path/to/result_" - FORMAT AS PARQUET - PROPERTIES - ( - "broker.name" = "my_broker", - "broker.hadoop.security.authentication" = "kerberos", - "broker.kerberos_principal" = "doris@YOUR.COM", - "broker.kerberos_keytab" = "/home/doris/my.keytab" - ); - ``` - -3. 将 CTE 语句的查询结果导出到文件 `hdfs://path/to/result.txt`。默认导出格式为 CSV。使用 `my_broker` 并设置 HDFS 高可用信息。使用默认的行列分隔符。 - - ```sql - WITH - x1 AS - (SELECT k1, k2 FROM tbl1), - x2 AS - (SELECT k3 FROM tbl2) - SELEC k1 FROM x1 UNION SELECT k3 FROM x2 - INTO OUTFILE "hdfs://path/to/result_" - PROPERTIES - ( - "broker.name" = "my_broker", - "broker.username"="user", - "broker.password"="passwd", - "broker.dfs.nameservices" = "my_ha", - "broker.dfs.ha.namenodes.my_ha" = "my_namenode1, my_namenode2", - "broker.dfs.namenode.rpc-address.my_ha.my_namenode1" = "nn1_host:rpc_port", - "broker.dfs.namenode.rpc-address.my_ha.my_namenode2" = "nn2_host:rpc_port", - "broker.dfs.client.failover.proxy.provider" = "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider" - ); - ``` - - 最终生成文件如如果不大于 1GB,则为:`result_0.csv`。 - 如果大于 1GB,则可能为 `result_0.csv, result_1.csv, ...`。 - -4. 将 UNION 语句的查询结果导出到文件 `bos://bucket/result.txt`。指定导出格式为 PARQUET。使用 `my_broker` 并设置 HDFS 高可用信息。PARQUET 格式无需指定列分割符。 - 导出完成后,生成一个标识文件。 - - ```sql - SELECT k1 FROM tbl1 UNION SELECT k2 FROM tbl1 - INTO OUTFILE "bos://bucket/result_" - FORMAT AS PARQUET - PROPERTIES - ( - "broker.name" = "my_broker", - "broker.bos_endpoint" = "http://bj.bcebos.com", - "broker.bos_accesskey" = "xxxxxxxxxxxxxxxxxxxxxxxxxx", - "broker.bos_secret_accesskey" = "yyyyyyyyyyyyyyyyyyyyyyyyyy" - ); - ``` - -5. 将 Select 语句的查询结果导出到文件 `s3a://${bucket_name}/path/result.txt`。指定导出格式为 CSV。 - 导出完成后,生成一个标识文件。 - - ```sql - select k1,k2,v1 from tbl1 limit 100000 - into outfile "s3a://my_bucket/export/my_file_" - FORMAT AS CSV - PROPERTIES - ( - "broker.name" = "hdfs_broker", - "broker.fs.s3a.access.key" = "xxx", - "broker.fs.s3a.secret.key" = "xxxx", - "broker.fs.s3a.endpoint" = "https://cos.xxxxxx.myqcloud.com/", - "column_separator" = ",", - "line_delimiter" = "\n", - "max_file_size" = "1024MB", - "success_file_name" = "SUCCESS" - ) - ``` - - 最终生成文件如如果不大于 1GB,则为:`my_file_0.csv`。 - 如果大于 1GB,则可能为 `my_file_0.csv, result_1.csv, ...`。 - 在cos上验证 - - 1. 不存在的path会自动创建 - 2. access.key/secret.key/endpoint需要和cos的同学确认。尤其是endpoint的值,不需要填写bucket_name。 - -6. 使用 S3 协议导出到 bos,并且并发导出开启。 - - ```sql - set enable_parallel_outfile = true; - select k1 from tb1 limit 1000 - into outfile "s3://my_bucket/export/my_file_" - format as csv - properties - ( - "s3.endpoint" = "http://s3.bd.bcebos.com", - "s3.access_key" = "xxxx", - "s3.secret_key" = "xxx", - "s3.region" = "bd" - ) - ``` - - 最终生成的文件前缀为 `my_file_{fragment_instance_id}_`。 - -7. 使用 S3 协议导出到 bos,并且并发导出 Session 变量开启。 - 注意:但由于查询语句带了一个顶层的排序节点,所以这个查询即使开启并发导出的 Session 变量,也是无法并发导出的。 - - ```sql - set enable_parallel_outfile = true; - select k1 from tb1 order by k1 limit 1000 - into outfile "s3://my_bucket/export/my_file_" - format as csv - properties - ( - "s3.endpoint" = "http://s3.bd.bcebos.com", - "s3.access_key" = "xxxx", - "s3.secret_key" = "xxx", - "s3.region" = "bd" - ) - ``` - -8. 使用 HDFS 方式导出,将简单查询结果导出到文件 `hdfs://${host}:${fileSystem_port}/path/to/result.txt`。指定导出格式为 CSV,用户名为work。指定列分隔符为 `,`,行分隔符为 `\n`。 - - ```sql - -- fileSystem_port默认值为9000 - SELECT * FROM tbl - INTO OUTFILE "hdfs://${host}:${fileSystem_port}/path/to/result_" - FORMAT AS CSV - PROPERTIES - ( - "fs.defaultFS" = "hdfs://ip:port", - "hadoop.username" = "work" - ); - ``` - - 如果 Hadoop 集群开启高可用并且启用 Kerberos 认证,可以参考如下 SQL 语句: - - ```sql - SELECT * FROM tbl - INTO OUTFILE "hdfs://path/to/result_" - FORMAT AS CSV - PROPERTIES - ( - 'fs.defaultFS'='hdfs://hacluster/', - 'dfs.nameservices'='hacluster', - 'dfs.ha.namenodes.hacluster'='n1,n2', - 'dfs.namenode.rpc-address.hacluster.n1'='192.168.0.1:8020', - 'dfs.namenode.rpc-address.hacluster.n2'='192.168.0.2:8020', - 'dfs.client.failover.proxy.provider.hacluster'='org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider', - 'dfs.namenode.kerberos.principal'='hadoop/_HOST@REALM.COM' - 'hadoop.security.authentication'='kerberos', - 'hadoop.kerberos.principal'='doris_test@REALM.COM', - 'hadoop.kerberos.keytab'='/path/to/doris_test.keytab' - ); - ``` - - 最终生成文件如如果不大于 100 MB,则为:`result_0.csv`。 - 如果大于 100 MB,则可能为 `result_0.csv, result_1.csv, ...`。 - -9. 将 Select 语句的查询结果导出到腾讯云 cos 的文件 `cosn://${bucket_name}/path/result.txt`。指定导出格式为 CSV。 - 导出完成后,生成一个标识文件。 - - ```sql - select k1,k2,v1 from tbl1 limit 100000 - into outfile "cosn://my_bucket/export/my_file_" - FORMAT AS CSV - PROPERTIES - ( - "broker.name" = "broker_name", - "broker.fs.cosn.userinfo.secretId" = "xxx", - "broker.fs.cosn.userinfo.secretKey" = "xxxx", - "broker.fs.cosn.bucket.endpoint_suffix" = "cos.xxxxxx.myqcloud.com", - "column_separator" = ",", - "line_delimiter" = "\n", - "max_file_size" = "1024MB", - "success_file_name" = "SUCCESS" - ) - ``` - -### keywords - SELECT, INTO, OUTFILE - -### Best Practice - -1. 导出数据量和导出效率 - - 该功能本质上是执行一个 SQL 查询命令。最终的结果是单线程输出的。所以整个导出的耗时包括查询本身的耗时,和最终结果集写出的耗时。如果查询较大,需要设置会话变量 `query_timeout` 适当的延长查询超时时间。 - -2. 导出文件的管理 - - Doris 不会管理导出的文件。包括导出成功的,或者导出失败后残留的文件,都需要用户自行处理。 - -3. 导出到本地文件 - - 导出到本地文件的功能不适用于公有云用户,仅适用于私有化部署的用户。并且默认用户对集群节点有完全的控制权限。Doris 对于用户填写的导出路径不会做合法性检查。如果 Doris 的进程用户对该路径无写权限,或路径不存在,则会报错。同时处于安全性考虑,如果该路径已存在同名的文件,则也会导出失败。 - - Doris 不会管理导出到本地的文件,也不会检查磁盘空间等。这些文件需要用户自行管理,如清理等。 - -4. 结果完整性保证 - - 该命令是一个同步命令,因此有可能在执行过程中任务连接断开了,从而无法获悉导出的数据是否正常结束,或是否完整。此时可以使用 `success_file_name` 参数要求任务成功后,在目录下生成一个成功文件标识。用户可以通过这个文件,来判断导出是否正常结束。 - -5. 其他注意事项 - - 见[导出查询结果集](../../../data-operate/export/outfile.md) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CANCEL-REBALANCE-DISK.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CANCEL-REBALANCE-DISK.md deleted file mode 100644 index a7e97ba45f805..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CANCEL-REBALANCE-DISK.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "ADMIN-CANCEL-REBALANCE-DISK", - "language": "zh-CN" -} ---- - - - -## ADMIN-CANCEL-REBALANCE-DISK - -### Name -ADMIN CANCEL REBALANCE DISK -## 描述 - - 该语句用于取消优先均衡BE的磁盘 - - 语法: - - ADMIN CANCEL REBALANCE DISK [ON ("BackendHost1:BackendHeartBeatPort1", "BackendHost2:BackendHeartBeatPort2", ...)]; - - 说明: - - 1. 该语句仅表示系统不再优先均衡指定BE的磁盘数据。系统仍会以默认调度方式均衡BE的磁盘数据。 - -## 举例 - - 1. 取消集群所有BE的优先磁盘均衡 - - ADMIN CANCEL REBALANCE DISK; - - 2. 取消指定BE的优先磁盘均衡 - - ADMIN CANCEL REBALANCE DISK ON ("192.168.1.1:1234", "192.168.1.2:1234"); - -### Keywords - - ADMIN,CANCEL,REBALANCE,DISK - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CANCEL-REPAIR.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CANCEL-REPAIR.md deleted file mode 100644 index fb858cfa5d133..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CANCEL-REPAIR.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -{ - "title": "ADMIN-CANCEL-REPAIR", - "language": "zh-CN" -} ---- - - - -## ADMIN-CANCEL-REPAIR - -### Name - -ADMIN CANCEL REPAIR - -## 描述 - -该语句用于取消以高优先级修复指定表或分区 - -语法: - -```sql -ADMIN CANCEL REPAIR TABLE table_name[ PARTITION (p1,...)]; -``` - -说明: - -1. 该语句仅表示系统不再以高优先级修复指定表或分区的分片副本。系统仍会以默认调度方式修复副本。 - -## 举例 - - 1. 取消高优先级修复 - - ```sql - ADMIN CANCEL REPAIR TABLE tbl PARTITION(p1); - ``` - -### Keywords - - ADMIN, CANCEL, REPAIR - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CHECK-TABLET.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CHECK-TABLET.md deleted file mode 100644 index b5ac852ac72e9..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CHECK-TABLET.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -{ - "title": "ADMIN-CHECK-TABLET", - "language": "zh-CN" -} ---- - - - -## ADMIN-CHECK-TABLET - -### Name - -ADMIN CHECK TABLET - -## 描述 - -该语句用于对一组 tablet 执行指定的检查操作 - -语法: - -```sql -ADMIN CHECK TABLET (tablet_id1, tablet_id2, ...) -PROPERTIES("type" = "..."); -``` - -说明: - -1. 必须指定 tablet id 列表以及 PROPERTIES 中的 type 属性。 -2. 目前 type 仅支持: - - * consistency: 对tablet的副本数据一致性进行检查。该命令为异步命令,发送后,Doris 会开始执行对应 tablet 的一致性检查作业。最终的结果,将体现在 `SHOW PROC "/cluster_health/tablet_health";` 结果中的 InconsistentTabletNum 列。 - -## 举例 - -1. 对指定的一组 tablet 进行副本数据一致性检查 - - ``` - ADMIN CHECK TABLET (10000, 10001) - PROPERTIES("type" = "consistency"); - -### Keywords - - ADMIN, CHECK, TABLET - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CLEAN-TRASH.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CLEAN-TRASH.md deleted file mode 100644 index d7f9b0d718d54..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CLEAN-TRASH.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -{ - "title": "ADMIN-CLEAN-TRASH", - "language": "zh-CN" -} - ---- - - - -## ADMIN-CLEAN-TRASH - -### Name - -ADMIN CLEAN TRASH - -## 描述 - -该语句用于清理 backend 内的垃圾数据 - -语法: - -```sql -ADMIN CLEAN TRASH [ON ("BackendHost1:BackendHeartBeatPort1", "BackendHost2:BackendHeartBeatPort2", ...)]; -``` - -说明: - -1. 以 BackendHost:BackendHeartBeatPort 表示需要清理的 backend ,不添加on限定则清理所有 backend 。 - -## 举例 - -1. 清理所有be节点的垃圾数据。 - - ADMIN CLEAN TRASH; - -2. 清理'192.168.0.1:9050'和'192.168.0.2:9050'的垃圾数据。 - - ADMIN CLEAN TRASH ON ("192.168.0.1:9050","192.168.0.2:9050"); - -### Keywords - - ADMIN, CLEAN, TRASH - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-COPY-TABLET.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-COPY-TABLET.md deleted file mode 100644 index 3d0efcd630b7c..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-COPY-TABLET.md +++ /dev/null @@ -1,101 +0,0 @@ ---- -{ - "title": "ADMIN-COPY-TABLET", - "language": "zh-CN" -} ---- - - - -## ADMIN-COPY-TABLET - -### Name - -ADMIN COPY TABLET - -## 描述 - -该语句用于为指定的 tablet 制作快照,主要用于本地加载 tablet 来复现问题。 - -语法: - -```sql -ADMIN COPY TABLET tablet_id PROPERTIES("xxx"); -``` - -说明: - -该命令需要 ROOT 权限。 - -PROPERTIES 支持如下属性: - -1. backend_id:指定副本所在的 BE 节点的 id。如果不指定,则随机选择一个副本。 - -2. version:指定快照的版本。该版本需小于等于副本的最大版本。如不指定,则使用最大版本。 - -3. expiration_minutes:快照保留时长。默认为1小时。超时后会自动清理。单位分钟。 - -结果展示如下: - -``` - TabletId: 10020 - BackendId: 10003 - Ip: 192.168.10.1 - Path: /path/to/be/storage/snapshot/20220830101353.2.3600 -ExpirationMinutes: 60 - CreateTableStmt: CREATE TABLE `tbl1` ( - `k1` int(11) NULL, - `k2` int(11) NULL -) ENGINE=OLAP -DUPLICATE KEY(`k1`, `k2`) -DISTRIBUTED BY HASH(k1) BUCKETS 1 -PROPERTIES ( -"replication_num" = "1", -"version_info" = "2" -); -``` - -* TabletId: tablet id -* BackendId: BE 节点 id -* Ip: BE 节点 ip -* Path: 快照所在目录 -* ExpirationMinutes: 快照过期时间 -* CreateTableStmt: tablet 对应的表的建表语句。该语句不是原始的建表语句,而是用于之后本地加载 tablet 的简化后的建表语句。 - -## 举例 - -1. 对指定 BE 节点上的副本做快照 - - ```sql - ADMIN COPY TABLET 10010 PROPERTIES("backend_id" = "10001"); - ``` - -2. 对指定 BE 节点上的副本,做指定版本的快照 - - ```sql - ADMIN COPY TABLET 10010 PROPERTIES("backend_id" = "10001", "version" = "10"); - ``` - -### Keywords - - ADMIN, COPY, TABLET - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-REBALANCE-DISK.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-REBALANCE-DISK.md deleted file mode 100644 index c0603299cf0f8..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-REBALANCE-DISK.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -{ - "title": "ADMIN-REBALANCE-DISK", - "language": "zh-CN" -} ---- - - - -## ADMIN-REBALANCE-DISK - -### Name -ADMIN REBALANCE DISK -## 描述 - -该语句用于尝试优先均衡指定的BE磁盘数据 - -语法: - - ``` - ADMIN REBALANCE DISK [ON ("BackendHost1:BackendHeartBeatPort1", "BackendHost2:BackendHeartBeatPort2", ...)]; - ``` - -说明: - - 1. 该语句表示让系统尝试优先均衡指定BE的磁盘数据,不受限于集群是否均衡。 - 2. 默认的 timeout 是 24小时。超时意味着系统将不再优先均衡指定的BE磁盘数据。需要重新使用该命令设置。 - 3. 指定BE的磁盘数据均衡后,该BE的优先级将会失效。 - -## 举例 - -1. 尝试优先均衡集群内的所有BE - - ``` - ADMIN REBALANCE DISK; - ``` - -2. 尝试优先均衡指定BE - - ``` - ADMIN REBALANCE DISK ON ("192.168.1.1:1234", "192.168.1.2:1234"); - ``` - -### Keywords - - ADMIN,REBALANCE,DISK - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-REPAIR-TABLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-REPAIR-TABLE.md deleted file mode 100644 index dae3a35d51704..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-REPAIR-TABLE.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -{ - "title": "ADMIN-REPAIR-TABLE", - "language": "zh-CN" -} ---- - - - -## ADMIN-REPAIR-TABLE - -### Name - -ADMIN REPAIR TABLE - -## 描述 - -语句用于尝试优先修复指定的表或分区 - -语法: - -```sql -ADMIN REPAIR TABLE table_name[ PARTITION (p1,...)] -``` - -说明: - -1. 该语句仅表示让系统尝试以高优先级修复指定表或分区的分片副本,并不保证能够修复成功。用户可以通过 `SHOW REPLICA STATUS` 命令查看修复情况。 -2. 默认的 timeout 是 14400 秒(4小时)。超时意味着系统将不再以高优先级修复指定表或分区的分片副本。需要重新使用该命令设置 - -## 举例 - -1. 尝试修复指定表 - - ADMIN REPAIR TABLE tbl1; - -2. 尝试修复指定分区 - - ADMIN REPAIR TABLE tbl1 PARTITION (p1, p2); - -### Keywords - - ADMIN, REPAIR, TABLE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-CONFIG.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-CONFIG.md deleted file mode 100644 index c2560ce7090fe..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-CONFIG.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -{ - "title": "ADMIN-SET-CONFIG", - "language": "zh-CN" -} ---- - - - -## ADMIN-SET-CONFIG - -### Name - -ADMIN SET CONFIG - -## 描述 - -该语句用于设置集群的配置项(当前仅支持设置 FE 的配置项)。 - -可设置的配置项,可以通过 `SHOW FRONTEND CONFIG;` 命令查看。 - -语法: - -```sql -ADMIN SET FRONTEND CONFIG ("key" = "value") [ALL]; --- or -ADMIN SET ALL FRONTENDS CONFIG ("key" = "value"); -``` - -:::tip 提示 - -- 2.0.11 和 2.1.5 版本开始支持 `ALL` 关键词。使用 `ALL` 关键字后配置参数将应用于所有 FE(除 `master_only` 参数外)。 -- 该语法不会持久化修改的配置,FE 重启后,修改的配置失效。如需持久化,需要在 fe.conf 中同步添加配置项。 -- -::: - -## 举例 - -1. 设置 `disable_balance` 为 true - - `ADMIN SET FRONTEND CONFIG ("disable_balance" = "true");` - -### Keywords - - ADMIN, SET, CONFIG - -### Best Practice diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md deleted file mode 100644 index 73aad8f7994ae..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION.md +++ /dev/null @@ -1,67 +0,0 @@ ---- -{ - "title": "ADMIN-SET-PARTITION-VERSION", - "language": "zh-CN" -} ---- - - - -## ADMIN-SET-PARTITION-VERSION - -### Name - -ADMIN SET PARTITION VERSION - -## 描述 - -该语句用于手动改变指定分区的可见版本。 - -在某些特殊情况下,元数据中分区的版本有可能和实际副本的版本不一致,该命令可手动改变元数据中分区的版本。 - -语法: - -```sql -ADMIN SET TABLE table_name PARTITION VERSION - PROPERTIES ("key" = "value", ...); -``` - -目前支持如下属性: - -1. "partition_id":必需。指定一个 Partition Id. -2. "visible_version":必需。指定 Version. - -> 注意: -> -> 设置分区的版本需要先确认Be机器上实际副本的版本,此命令一般只用于紧急故障修复,请谨慎操作。 - -## 举例 - -1. 设置 partition 1769152 在 FE 元数据上的版本为 100。 - -```sql -ADMIN SET TABLE tbl1 PARTITION VERSION PROPERTIES("partition_id" = "1769152", "visible_version" = "100"); -``` - -### Keywords - - ADMIN, SET, PARTITION, VERSION - -### Best Practice diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-REPLICA-STATUS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-REPLICA-STATUS.md deleted file mode 100644 index 3944f3d492a5d..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-REPLICA-STATUS.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -{ - "title": "ADMIN-SET-REPLICA-STATUS", - "language": "zh-CN" -} ---- - - - -## ADMIN-SET-REPLICA-STATUS - -### Name - -ADMIN SET REPLICA STATUS - -## 描述 - -该语句用于设置指定副本的状态。 - -该命令目前仅用于手动将某些副本状态设置为 BAD 、DROP 和 OK,从而使得系统能够自动修复这些副本 - -语法: - -```sql -ADMIN SET REPLICA STATUS - PROPERTIES ("key" = "value", ...); -``` - - 目前支持如下属性: - -1. "tablet_id":必需。指定一个 Tablet Id. -2. "backend_id":必需。指定 Backend Id. -3. "status":必需。指定状态。当前仅支持 "drop"、"bad"、 "ok" - -如果指定的副本不存在,或状态已经是 bad,则会被忽略。 - -> 注意: -> -> 设置为 Bad 状态的副本,它将不能读写。另外,设置 Bad 有时是不生效的。如果该副本实际数据是正确的,当 BE 上报该副本状态是 ok 的,fe 将把副本自动恢复回ok状态。操作可能立刻删除该副本,请谨慎操作。 -> -> 设置为 Drop 状态的副本,它仍然可以读写。会在其他机器先增加一个健康副本,再删除该副本。相比设置Bad, 设置Drop的操作是安全的。 - -## 举例 - - 1. 设置 tablet 10003 在 BE 10001 上的副本状态为 bad。 - -```sql -ADMIN SET REPLICA STATUS PROPERTIES("tablet_id" = "10003", "backend_id" = "10001", "status" = "bad"); -``` - - 2. 设置 tablet 10003 在 BE 10001 上的副本状态为 drop。 - -```sql -ADMIN SET REPLICA STATUS PROPERTIES("tablet_id" = "10003", "backend_id" = "10001", "status" = "drop"); -``` - - 3. 设置 tablet 10003 在 BE 10001 上的副本状态为 ok。 - -```sql -ADMIN SET REPLICA STATUS PROPERTIES("tablet_id" = "10003", "backend_id" = "10001", "status" = "ok"); -``` - -### Keywords - - ADMIN, SET, REPLICA, STATUS - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-REPLICA-VERSION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-REPLICA-VERSION.md deleted file mode 100644 index b83ca72e7ad5e..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-REPLICA-VERSION.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -{ - "title": "ADMIN-SET-REPLICA-VERSION", - "language": "zh-CN" -} ---- - - - -## ADMIN-SET-REPLICA-VERSION - -### Name - -ADMIN SET REPLICA VERSION - -## 描述 - -该语句用于设置指定副本的版本、最大成功版本、最大失败版本。 - -该命令目前仅用于在程序异常情况下,手动修复副本的版本,从而使得副本从异常状态恢复过来。 - -语法: - -```sql -ADMIN SET REPLICA VERSION - PROPERTIES ("key" = "value", ...); -``` - - 目前支持如下属性: - -1. `tablet_id`:必需。指定一个 Tablet Id. -2. `backend_id`:必需。指定 Backend Id. -3. `version`:可选。设置副本的版本. -4. `last_success_version`:可选。设置副本的最大成功版本. -5. `last_failed_version`:可选。设置副本的最大失败版本。 - - -如果指定的副本不存在,则会被忽略。 - -> 注意: -> -> 修改这几个数值,可能会导致后面数据读写失败,造成数据不一致,请谨慎操作! -> -> 修改之前先记录原来的值。修改完毕之后,对表进行读写验证,如果读写失败,请恢复原来的值!但可能会恢复失败! -> -> 严禁对正在写入数据的tablet进行操作 ! - - -## 举例 - - 1. 清除 tablet 10003 在 BE 10001 上的副本状态失败标志。 - -```sql -ADMIN SET REPLICA VERSION PROPERTIES("tablet_id" = "10003", "backend_id" = "10001", "last_failed_version" = "-1"); -``` - -2. 设置 tablet 10003 在 BE 10001 上的副本版本号为 1004。 - -```sql -ADMIN SET REPLICA VERSION PROPERTIES("tablet_id" = "10003", "backend_id" = "10001", "version" = "1004"); -``` - -### Keywords - - ADMIN, SET, REPLICA, VERSION - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-TABLE-STATUS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-TABLE-STATUS.md deleted file mode 100644 index 6d4faebc453a7..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-TABLE-STATUS.md +++ /dev/null @@ -1,84 +0,0 @@ ---- -{ - "title": "ADMIN-SET-TABLE-STATUS", - "language": "zh-CN" -} ---- - - - -## ADMIN-SET-TABLE-STATUS - -### Name - -ADMIN SET TABLE STATUS - -## 描述 - -该语句用于设置指定表的状态,仅支持OLAP表。 - -该命令目前仅用于手动将 OLAP 表状态设置为指定状态,从而使得某些由于表状态被阻碍的任务能够继续运行。 - -语法: - -```sql -ADMIN SET TABLE table_name STATUS - PROPERTIES ("key" = "value", ...); -``` - -目前支持以下属性: - -1. "state":必需。指定一个目标状态,将会修改 OLAP 表的状态至此状态。 - -> 当前可修改的目标状态包括: -> -> 1. NORMAL -> 2. ROLLUP -> 3. SCHEMA_CHANGE -> 4. BACKUP -> 5. RESTORE -> 6. WAITING_STABLE -> -> 如果表的状态已经是指定的状态,则会被忽略。 - -**注意:此命令一般只用于紧急故障修复,请谨慎操作。** - -## 举例 - -1. 设置表 tbl1 的状态为 NORMAL。 - -```sql -admin set table tbl1 status properties("state" = "NORMAL"); -``` - -2. 设置表 tbl2 的状态为 SCHEMA_CHANGE。 - -```sql -admin set table test_set_table_status status properties("state" = "SCHEMA_CHANGE"); -``` - -### Keywords - - ADMIN, SET, TABLE, STATUS - -### Best Practice - - - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/INSTALL-PLUGIN.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/INSTALL-PLUGIN.md deleted file mode 100644 index be0c537122086..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/INSTALL-PLUGIN.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -{ - "title": "INSTALL-PLUGIN", - "language": "zh-CN" -} ---- - - - -## INSTALL-PLUGIN - -### Name - -INSTALL PLUGIN - -## 描述 - -该语句用于安装一个插件。 - -语法: - -```sql -INSTALL PLUGIN FROM [source] [PROPERTIES ("key"="value", ...)] -``` - -source 支持三种类型: - -1. 指向一个 zip 文件的绝对路径。 -2. 指向一个插件目录的绝对路径。 -3. 指向一个 http 或 https 协议的 zip 文件下载路径 - -## 举例 - -1. 安装一个本地 zip 文件插件: - - ```sql - INSTALL PLUGIN FROM "/home/users/doris/auditdemo.zip"; - ``` - -2. 安装一个本地目录中的插件: - - ```sql - INSTALL PLUGIN FROM "/home/users/doris/auditdemo/"; - ``` - -3. 下载并安装一个插件: - - ```sql - INSTALL PLUGIN FROM "http://mywebsite.com/plugin.zip"; - ``` - - 注意需要放置一个和 `.zip` 文件同名的 md5 文件, 如 `http://mywebsite.com/plugin.zip.md5` 。其中内容为 .zip 文件的 MD5 值。 - -4. 下载并安装一个插件,同时设置了zip文件的md5sum的值: - - ```sql - INSTALL PLUGIN FROM "http://mywebsite.com/plugin.zip" PROPERTIES("md5sum" = "73877f6029216f4314d712086a146570"); - ``` - -### Keywords - - INSTALL, PLUGIN - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/KILL.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/KILL.md deleted file mode 100644 index 0496251824838..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/KILL.md +++ /dev/null @@ -1,97 +0,0 @@ ---- -{ - "title": "KILL", - "language": "zh-CN" -} ---- - - - -## KILL - -### Name - -KILL - -## 描述 - -每个 Doris 的连接都在一个单独的线程中运行。 您可以使用 KILL processlist_id 语句终止线程。 - -线程进程列表标识符可以从 SHOW PROCESSLIST 输出的 Id 列查询 或者 SELECT CONNECTION_ID() 来查询当前connection id。 - -语法: - -```sql -KILL [CONNECTION] processlist_id -``` - -除此之外,您还可以使用 processlist_id 或者 query_id 终止正在执行的查询命令 - -语法: - -```sql -KILL QUERY processlist_id | query_id -``` - - - -## 举例 - -1. 查看当前连接的connection id。 - -```sql -mysql> select connection_id(); -+-----------------+ -| connection_id() | -+-----------------+ -| 48 | -+-----------------+ -1 row in set (0.00 sec) -``` - -2. 查看所有连接的connection id。 - -```sql -mysql> SHOW PROCESSLIST; -+------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ -| CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | -+------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ -| Yes | 48 | root | 10.16.xx.xx:44834 | 2023-12-29 16:49:47 | internal | test | Query | 0 | OK | e6e4ce9567b04859-8eeab8d6b5513e38 | SHOW PROCESSLIST | -| | 50 | root | 192.168.xx.xx:52837 | 2023-12-29 16:51:34 | internal | | Sleep | 1837 | EOF | deaf13c52b3b4a3b-b25e8254b50ff8cb | SELECT @@session.transaction_isolation | -| | 51 | root | 192.168.xx.xx:52843 | 2023-12-29 16:51:35 | internal | | Sleep | 907 | EOF | 437f219addc0404f-9befe7f6acf9a700 | /* ApplicationName=DBeaver Ultimate 23.1.3 - Metadata */ SHOW STATUS | -| | 55 | root | 192.168.xx.xx:55533 | 2023-12-29 17:09:32 | internal | test | Sleep | 271 | EOF | f02603dc163a4da3-beebbb5d1ced760c | /* ApplicationName=DBeaver Ultimate 23.1.3 - SQLEditor */ SELECT DATABASE() | -| | 47 | root | 10.16.xx.xx:35678 | 2023-12-29 16:21:56 | internal | test | Sleep | 3528 | EOF | f4944c543dc34a99-b0d0f3986c8f1c98 | select * from test | -+------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ -5 rows in set (0.00 sec) -``` - -3. 终止正在运行的查询, 正在运行的查询会显示被取消。 - -```sql -mysql> kill query 55; -Query OK, 0 rows affected (0.01 sec) -``` - -### Keywords - - KILL - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/RECOVER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/RECOVER.md deleted file mode 100644 index 5e046cd67a99c..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/RECOVER.md +++ /dev/null @@ -1,163 +0,0 @@ ---- -{ - "title": "RECOVER", - "language": "zh-CN" -} ---- - - - -## RECOVER - -### Name - -RECOVER - -## 描述 - -该语句用于恢复之前删除的 database、table 或者 partition。支持通过name、id来恢复指定的元信息,并且支持将恢复的元信息重命名。 - -可以通过 `SHOW CATALOG RECYCLE BIN` 来查询当前可恢复的元信息。 - -语法: - -1. 以name恢复 database - - ```sql - RECOVER DATABASE db_name; - ``` - -2. 以name恢复 table - - ```sql - RECOVER TABLE [db_name.]table_name; - ``` - -3. 以name恢复 partition - - ```sql - RECOVER PARTITION partition_name FROM [db_name.]table_name; - ``` - -4. 以name和id恢复 database - - ```sql - RECOVER DATABASE db_name db_id; - ``` - -5. 以name和id恢复 table - - ```sql - RECOVER TABLE [db_name.]table_name table_id; - ``` - -6. 以name和id恢复 partition - - ```sql - RECOVER PARTITION partition_name partition_id FROM [db_name.]table_name; - ``` - -7. 以name恢复 database 并设定新名字 - - ```sql - RECOVER DATABASE db_name AS new_db_name; - ``` - -8. 以name和id恢复 table 并设定新名字 - - ```sql - RECOVER TABLE [db_name.]table_name table_id AS new_table_name; - ``` - -9. 以name和id恢复 partition 并设定新名字 - - ```sql - RECOVER PARTITION partition_name partition_id AS new_partition_name FROM [db_name.]table_name; - ``` - -说明: - -- 该操作仅能恢复之前一段时间内删除的元信息。默认为 1 天。(可通过fe.conf中`catalog_trash_expire_second`参数配置) -- 如果恢复元信息时没有指定id,则默认恢复最后一个删除的同名元数据。 -- 可以通过 `SHOW CATALOG RECYCLE BIN` 来查询当前可恢复的元信息。 - -## 举例 - -1. 恢复名为 example_db 的 database - -```sql -RECOVER DATABASE example_db; -``` - -2. 恢复名为 example_tbl 的 table - -```sql -RECOVER TABLE example_db.example_tbl; -``` - -3. 恢复表 example_tbl 中名为 p1 的 partition - -```sql -RECOVER PARTITION p1 FROM example_tbl; -``` - -4. 恢复 example_db_id 且名为 example_db 的 database - -```sql -RECOVER DATABASE example_db example_db_id; -``` - -5. 恢复 example_tbl_id 且名为 example_tbl 的 table - -```sql -RECOVER TABLE example_db.example_tbl example_tbl_id; -``` - -6. 恢复表 example_tbl 中 p1_id 且名为 p1 的 partition - -```sql -RECOVER PARTITION p1 p1_id FROM example_tbl; -``` - -7. 恢复 example_db_id 且名为 example_db 的 database,并设定新名字 new_example_db - -```sql -RECOVER DATABASE example_db example_db_id AS new_example_db; -``` - -8. 恢复名为 example_tbl 的 table,并设定新名字 new_example_tbl - -```sql -RECOVER TABLE example_db.example_tbl AS new_example_tbl; -``` - -9. 恢复表 example_tbl 中 p1_id 且名为 p1 的 partition,并设定新名字 new_p1 - -```sql -RECOVER PARTITION p1 p1_id AS new_p1 FROM example_tbl; -``` - -### Keywords - - RECOVER - -### Best Practice - - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SET-DEFAULT-STORAGE-VAULT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SET-DEFAULT-STORAGE-VAULT.md deleted file mode 100644 index 8a5344b23262b..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SET-DEFAULT-STORAGE-VAULT.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -{ - "title": "SET-DEFAULT-STORAGE-VAULT", - "language": "zh-CN" -} ---- - - - -## 描述 - -该语句用于在Doris中设置默认存储库。默认存储库用于存储内部或系统表的数据。如果未设置默认存储库,Doris将无法正常运行。一旦设置了默认存储库,就无法移除它。 - -## 语法 - -```sql -SET vault_name DEFAULT STORAGE VAULT -``` - -> 注意: -> -> 1. 只有ADMIN用户可以设置默认存储库 - -## 示例 - -1. 将名为s3_vault的存储库设置为默认存储库 - - ```sql - SET s3_vault AS DEFAULT STORAGE VAULT; - ``` - -## 相关命令 - -## 关键词 - - SET, DEFAULT, STORAGE, VAULT \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SET-VARIABLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SET-VARIABLE.md deleted file mode 100644 index 40b2edba2a12e..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SET-VARIABLE.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -{ - "title": "SET-VARIABLE", - "language": "zh-CN" -} ---- - - - -## SET-VARIABLE - -### Name - -SET VARIABLE - -## 描述 - -该语句主要是用来修改 Doris 系统变量,这些系统变量可以分为全局以及会话级别层面来修改,有些也可以进行动态修改。你也可以通过 `SHOW VARIABLE` 来查看这些系统变量。 - -语法: - -```sql -SET variable_assignment [, variable_assignment] ... -``` - -说明: - -1. variable_assignment: - user_var_name = expr - | [GLOBAL | SESSION] system_var_name = expr - -> 注意: -> -> 1. 只有 ADMIN 用户可以设置变量的全局生效 -> 2. 全局生效的变量影响当前会话和此后的新会话,不影响当前已经存在的其他会话。 - -## 举例 - -1. 设置时区为东八区 - - ``` - SET time_zone = "Asia/Shanghai"; - ``` - -2. 设置全局的执行内存大小 - - ``` - SET GLOBAL exec_mem_limit = 137438953472 - ``` - -### Keywords - - SET, VARIABLE - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SHOW-CONFIG.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SHOW-CONFIG.md deleted file mode 100644 index 5d09452908054..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SHOW-CONFIG.md +++ /dev/null @@ -1,100 +0,0 @@ ---- -{ - "title": "SHOW-CONFIG", - "language": "zh-CN" -} ---- - - - -## SHOW-CONFIG - -### Name - -SHOW CONFIG - -## 描述 - -该语句用于展示当前集群的配置 - -语法: - -```sql -SHOW (FRONTEND|BACKEND) CONFIG [LIKE "pattern"]; -``` - -查看FE配置项的结果中的各列含义如下: - -1. Key: 配置项名称 -2. Value: 配置项值 -3. Type: 配置项类型 -4. IsMutable: 是否可以通过 ADMIN SET CONFIG 命令设置 -5. MasterOnly: 是否仅适用于 Master FE -6. Comment: 配置项说明 - -查看BE配置项的结果中的各列含义如下: - -1. BackendId: BE ID -2. Host: BE的IP地址 -3. Key: 配置项名称 -4. Value: 配置项值 -5. Type: 配置型类型 -6. IsMutable: 是否可以修改 - -## 举例 - -1. 查看当前FE节点的配置 - - ```sql - SHOW FRONTEND CONFIG; - ``` - -2. 使用like谓词搜索当前Fe节点的配置 - - ``` - mysql> SHOW FRONTEND CONFIG LIKE '%check_java_version%'; - +--------------------+-------+---------+-----------+------------+---------+ - | Key | Value | Type | IsMutable | MasterOnly | Comment | - +--------------------+-------+---------+-----------+------------+---------+ - | check_java_version | true | boolean | false | false | | - +--------------------+-------+---------+-----------+------------+---------+ - 1 row in set (0.01 sec) - ``` - -3. 查看Be ID为`10001`的BE节点的配置项 - - ```sql - SHOW BACKEND CONFIG FROM 10001; - ``` -4. 使用like谓词查看Be ID为`10001`的配置 - ``` - mysql> SHOW BACKEND CONFIG LIKE "be_port" FROM 10001; - +-----------+---------------+---------+-------+---------+-----------+ - | BackendId | Host | Key | Value | Type | IsMutable | - +-----------+---------------+---------+-------+---------+-----------+ - | 10001 | xx.xx.xxx.xxx | be_port | 9060 | int32_t | false | - +-----------+---------------+---------+-------+---------+-----------+ - ``` -### Keywords - - SHOW, CONFIG - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SHOW-REPLICA-DISTRIBUTION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SHOW-REPLICA-DISTRIBUTION.md deleted file mode 100644 index 9607e9fffc470..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SHOW-REPLICA-DISTRIBUTION.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -{ - "title": "SHOW-REPLICA-DISTRIBUTION", - "language": "zh-CN" -} ---- - - - -## SHOW-REPLICA-DISTRIBUTION - -### Name - -SHOW REPLICA DISTRIBUTION - -## 描述 - -该语句用于展示一个表或分区副本分布状态 - -语法: - -```sql -SHOW REPLICA DISTRIBUTION FROM [db_name.]tbl_name [PARTITION (p1, ...)]; -``` - -说明: - -1. 结果中的 Graph 列以图形的形式展示副本分布比例 - -## 举例 - -1. 查看表的副本分布 - - ```sql - SHOW REPLICA DISTRIBUTION FROM tbl1; - ``` - - 2. 查看表的分区的副本分布 - - ```sql - SHOW REPLICA DISTRIBUTION FROM db1.tbl1 PARTITION(p1, p2); - ``` - -### Keywords - - SHOW, REPLICA, DISTRIBUTION - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SHOW-REPLICA-STATUS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SHOW-REPLICA-STATUS.md deleted file mode 100644 index 082cf8444eb2d..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SHOW-REPLICA-STATUS.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -{ - "title": "SHOW-REPLICA-STATUS", - "language": "zh-CN" -} ---- - - - -## SHOW-REPLICA-STATUS - -### Name - -SHOW REPLICA STATUS - -## 描述 - -该语句用于展示一个表或分区的副本状态信息。 - -语法: - -```sql -SHOW REPLICA STATUS FROM [db_name.]tbl_name [PARTITION (p1, ...)] -[where_clause]; -``` - -说明 - -1. where_clause: - WHERE STATUS [!]= "replica_status" - -2. replica_status: - OK: replica 处于健康状态 - DEAD: replica 所在 Backend 不可用 - VERSION_ERROR: replica 数据版本有缺失 - SCHEMA_ERROR: replica 的 schema hash 不正确 - MISSING: replica 不存在 - -## 举例 - -1. 查看表全部的副本状态 - - ```sql - SHOW REPLICA STATUS FROM db1.tbl1; - ``` - -2. 查看表某个分区状态为 VERSION_ERROR 的副本 - - ```sql - SHOW REPLICA STATUS FROM tbl1 PARTITION (p1, p2) - WHERE STATUS = "VERSION_ERROR"; - ``` - -3. 查看表所有状态不健康的副本 - - ```sql - SHOW REPLICA STATUS FROM tbl1 - WHERE STATUS != "OK"; - ``` - -### Keywords - - SHOW, REPLICA, STATUS - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SHOW-TABLET-DIAGNOSIS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SHOW-TABLET-DIAGNOSIS.md deleted file mode 100644 index 32ac18d106435..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SHOW-TABLET-DIAGNOSIS.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -{ - "title": "SHOW TABLET DIAGNOSIS", - "language": "zh-CN" -} ---- - - - -## SHOW TABLET DIAGNOSIS -## 描述 - - 该语句用于诊断指定 tablet。结果中将显示这个 tablet 的信息和一些潜在的问题。 - - 语法: - - SHOW TABLET DIAGNOSIS tablet_id - - 说明: - - 结果中的各行信息如下: - 1. TabletExist: Tablet是否存在 - 2. TabletId: Tablet ID - 3. Database: Tablet 所属 DB 和其 ID - 4. Table: Tablet 所属 Table 和其 ID - 5. Partition: Tablet 所属 Partition 和其 ID - 6. MaterializedIndex: Tablet 所属物化视图和其 ID - 7. Replicas(ReplicaId -> BackendId): Tablet 各副本和其所在 BE。 - 8. ReplicasNum: 副本数量是否正确。 - 9. ReplicaBackendStatus: 副本所在 BE 节点是否正常。 - 10.ReplicaVersionStatus: 副本的版本号是否正常。 - 11.ReplicaStatus: 副本状态是否正常。 - 12.ReplicaCompactionStatus: 副本 Compaction 状态是否正常。 - -## 举例 - - 1. 查看 Tablet 10001 的诊断结果 - - SHOW TABLET DIAGNOSIS 10001; - -### keywords - - SHOW, DIAGNOSIS, TABLET diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SHOW-TABLET-STORAGE-FORMAT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SHOW-TABLET-STORAGE-FORMAT.md deleted file mode 100644 index 9928bc8159ffd..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/SHOW-TABLET-STORAGE-FORMAT.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -{ - "title": "SHOW TABLET STORAGE FORMAT", - "language": "zh-CN" -} ---- - - - -## SHOW TABLET STORAGE FORMAT -## 描述 - - 该语句用于显示Backend上的存储格式信息(仅管理员使用) - 语法: - SHOW TABLET STORAGE FORMAT [VERBOSE] - -## 举例 - - ``` - MySQL [(none)]> show tablet storage format; - +-----------+---------+---------+ - | BackendId | V1Count | V2Count | - +-----------+---------+---------+ - | 10002 | 0 | 2867 | - +-----------+---------+---------+ - 1 row in set (0.003 sec) - - MySQL [test_query_qa]> show tablet storage format verbose; - +-----------+----------+---------------+ - | BackendId | TabletId | StorageFormat | - +-----------+----------+---------------+ - | 10002 | 39227 | V2 | - | 10002 | 39221 | V2 | - | 10002 | 39215 | V2 | - | 10002 | 39199 | V2 | - +-----------+----------+---------------+ - 4 rows in set (0.034 sec) - ``` - -### keywords - SHOW, TABLET, STORAGE, FORMAT - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/UNINSTALL-PLUGIN.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/UNINSTALL-PLUGIN.md deleted file mode 100644 index 7d40e9e236500..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/UNINSTALL-PLUGIN.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -{ - "title": "UNINSTALL-PLUGIN", - "language": "zh-CN" -} ---- - - - -## UNINSTALL-PLUGIN - -### Name - -UNINSTALL PLUGIN - -## 描述 - -该语句用于卸载一个插件。 - -语法: - -```sql -UNINSTALL PLUGIN plugin_name; -``` - - plugin_name 可以通过 `SHOW PLUGINS;` 命令查看。 - -只能卸载非 builtin 的插件。 - -## 举例 - -1. 卸载一个插件: - - ```sql - UNINSTALL PLUGIN auditdemo; - ``` - -### Keywords - - UNINSTALL, PLUGIN - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/UNSET-VARIABLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/UNSET-VARIABLE.md deleted file mode 100644 index aabec869f394b..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/UNSET-VARIABLE.md +++ /dev/null @@ -1,78 +0,0 @@ ---- -{ - "title": "UNSET-VARIABLE", - "language": "zh-CN" -} ---- - - - -## UNSET-VARIABLE - -### Name - -UNSET VARIABLE - -## 描述 - -该语句主要是用来恢复 Doris 系统变量为默认值,可以是全局也可以是会话级别。 - -语法: - -```sql -UNSET [SESSION|GLOBAL] VARIABLE (variable_name | ALL) -``` - -说明: - -1. (variable_name | ALL) :必须指定变量名或使用 ALL , ALL 会恢复所有变量的值。 - -> 注意: -> -> 1. 只有 ADMIN 用户可以全局得恢复变量的值。 -> 2. 使用 `GLOBAL` 恢复变量值时仅在执行命令的当前会话和之后打开的会话中生效,不会恢复当前已有的其它会话中的值。 - - -## 举例 - -1. 恢复时区为默认值东八区 - - ``` - UNSET VARIABLE time_zone; - ``` - -2. 恢复全局的执行内存大小 - - ``` - UNSET GLOBAL VARIABLE exec_mem_limit; - ``` - -3. 从全局范围恢复所有变量的值 - - ``` - UNSET GLOBAL VARIABLE ALL; - ``` - -### Keywords - - UNSET, VARIABLE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/WARM-UP-COMPUTE-GROUP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/WARM-UP-COMPUTE-GROUP.md deleted file mode 100644 index 4ae1e7cc12761..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Database-Administration-Statements/WARM-UP-COMPUTE-GROUP.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -{ - "title": "WARM UP COMPUTE GROUP", - "language": "zh_CN" -} ---- - - - -## 描述 - -WARM UP COMPUTE GROUP 语句用于预热计算组中的数据,以提高查询性能。预热操作可以从另一个计算组中获取资源,也可以指定特定的表和分区进行预热。预热操作返回一个作业ID,可以用于追踪预热作业的状态。 - -## 语法 - -```sql - -WARM UP COMPUTE GROUP WITH COMPUTE GROUP FORCE; - -WARM UP COMPUTE GROUP WITH ; - -warm_up_list ::= warm_up_item [AND warm_up_item...]; - -warm_up_item ::= TABLE [PARTITION ]; - -``` - -## 参数 - -* destination_compute_group_name: 要预热的目标计算组的名称。 - -* source_compute_group_name: 从中获取资源的源集群的名称。 - -* warm_up_list: 要预热的特定项目的列表,可以包括表和分区。 - -* table_name: 用于预热的表的名称。 - -* partition_name: 用于预热的分区的名称。 - -## 返回值 - -* JobId: 预热作业的ID。 - -## 示例 - -1. 使用名为source_group_name的计算组预热名为destination_group_name的计算组。 - -```sql - WARM UP COMPUTE GROUP destination_group_name WITH COMPUTE GROUP source_group_name; - -``` - -2. 使用名为destination_group的计算组预热表sales_data和customer_info以及表orders的分区q1_2024。 - -``` - WARM UP COMPUTE GROUP destination_group WITH - TABLE sales_data - AND TABLE customer_info - AND TABLE orders PARTITION q1_2024; - -``` - -## 关键字 - - WARM UP, COMPUTE GROUP, CACHE diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Operators/in.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Operators/in.md deleted file mode 100644 index 69c750adecf74..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Operators/in.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -{ - "title": "IN", - "language": "zh-CN" -} ---- - - - -## IN - -IN - -## 描述 -## 语法 - -`expr IN (value, ...)` - -`expr IN (subquery)` - -如果 expr 等于 IN 列表中的任何值则返回true,否则返回false。 - -subquery 只能返回一列,并且子查询返回的列类型必须 expr 类型兼容。 - -如果 subquery 返回bitmap数据类型列,expr必须是整型。 - -## 举例 - -``` -mysql> select id from cost where id in (1, 2); -+------+ -| id | -+------+ -| 2 | -| 1 | -+------+ -``` -``` -mysql> select id from tbl1 where id in (select id from tbl2); -+------+ -| id | -+------+ -| 1 | -| 4 | -| 5 | -+------+ -``` -``` -mysql> select id from tbl1 where id in (select bitmap_col from tbl3); -+------+ -| id | -+------+ -| 1 | -| 3 | -+------+ -``` - -### keywords - - IN diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ALTER-TABLE-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ALTER-TABLE-MATERIALIZED-VIEW.md deleted file mode 100644 index 905eed753717a..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ALTER-TABLE-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,120 +0,0 @@ ---- -{ - "title": "SHOW ALTER TABLE MATERIALIZED VIEW", - "language": "zh-CN" -} ---- - - - -## SHOW ALTER TABLE MATERIALIZED VIEW - -### Name - -SHOW ALTER TABLE MATERIALIZED VIEW - -## 描述 - -该命令用于查看通过 [CREATE-MATERIALIZED-VIEW](../../sql-statements/Data-Definition-Statements/Create/CREATE-MATERIALIZED-VIEW.md) 语句提交的创建物化视图作业的执行情况。 - -> 该语句等同于 `SHOW ALTER TABLE ROLLUP`; - -```sql -SHOW ALTER TABLE MATERIALIZED VIEW -[FROM database] -[WHERE] -[ORDER BY] -[LIMIT OFFSET] -``` - -- database:查看指定数据库下的作业。如不指定,使用当前数据库。 -- WHERE:可以对结果列进行筛选,目前仅支持对以下列进行筛选: - - TableName:仅支持等值筛选。 - - State:仅支持等值筛选。 - - Createtime/FinishTime:支持 =,>=,<=,>,<,!= -- ORDER BY:可以对结果集按任意列进行排序。 -- LIMIT:配合 ORDER BY 进行翻页查询。 - -返回结果说明: - -```sql -mysql> show alter table materialized view\G -*************************** 1. row *************************** - JobId: 11001 - TableName: tbl1 - CreateTime: 2020-12-23 10:41:00 - FinishTime: NULL - BaseIndexName: tbl1 -RollupIndexName: r1 - RollupId: 11002 - TransactionId: 5070 - State: WAITING_TXN - Msg: - Progress: NULL - Timeout: 86400 -1 row in set (0.00 sec) -``` - -- `JobId`:作业唯一 ID。 - -- `TableName`:基表名称 - -- `CreateTime/FinishTime`:作业创建时间和结束时间。 - -- `BaseIndexName/RollupIndexName`:基表名称和物化视图名称。 - -- `RollupId`:物化视图的唯一 ID。 - -- `TransactionId`:见 State 字段说明。 - -- `State`:作业状态。 - - - PENDING:作业准备中。 - - - WAITING_TXN: - - 在正式开始产生物化视图数据前,会等待当前这个表上的正在运行的导入事务完成。而 `TransactionId` 字段就是当前正在等待的事务 ID。当这个 ID 之前的导入都完成后,就会实际开始作业。 - - - RUNNING:作业运行中。 - - - FINISHED:作业运行成功。 - - - CANCELLED:作业运行失败。 - -- `Msg`:错误信息 - -- `Progress`:作业进度。这里的进度表示 `已完成的tablet数量/总tablet数量`。创建物化视图是按 tablet 粒度进行的。 - -- `Timeout`:作业超时时间,单位秒。 - -## 举例 - -1. 查看数据库 example_db 下的物化视图作业 - - ```sql - SHOW ALTER TABLE MATERIALIZED VIEW FROM example_db; - ``` - -### Keywords - - SHOW, ALTER, TABLE, MATERIALIZED, VIEW - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ALTER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ALTER.md deleted file mode 100644 index 48dfc113dfb7a..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ALTER.md +++ /dev/null @@ -1,92 +0,0 @@ ---- -{ - "title": "SHOW-ALTER", - "language": "zh-CN" -} - ---- - - - -## 描述 - -该语句用于展示当前正在进行的各类修改任务的执行情况 - -```sql -SHOW ALTER [TABLE [COLUMN | ROLLUP] [FROM db_name]]; -``` - -说明: - -1. TABLE COLUMN:展示修改列的 ALTER 任务 -2. 支持语法[WHERE TableName|CreateTime|FinishTime|State] [ORDER BY] [LIMIT] -3. TABLE ROLLUP:展示创建或删除 ROLLUP 的任务 -4. 如果不指定 db_name,使用当前默认 db - -## Result - -*SHOW ALTER TABLE COLUMN* - -| 字段名 | 描述 | -|-----------------------|------------------------------------------------------------------| -| JobId | 每个 Schema Change 作业的唯一 ID。 | -| TableName | 对应 Schema Change 的基表的表名。 | -| CreateTime | 作业创建时间。 | -| FinishedTime | 作业完成时间。如果未完成,显示 "N/A"。 | -| IndexName | 此修改中涉及的一个基表/同步物化视图的名称。 | -| IndexId | 新基表/同步物化视图的 ID。 | -| OriginIndexId | 此修改中涉及的一个基表/同步物化视图的 ID。 | -| SchemaVersion | 以 M:N 的格式显示。M 代表 Schema Change 的版本,N 代表对应的 Hash 值。每次 Schema Change 都会增加版本。 | -| TransactionId | 用于转换历史数据的事务 ID。 | -| State | 作业的阶段。 | -| | - PENDING: 作业正在等待在队列中调度。 | -| | - WAITING_TXN: 等待分界事务 ID 前的导入任务完成。 | -| | - RUNNING: 正在进行历史数据转换。 | -| | - FINISHED: 作业成功完成。 | -| | - CANCELLED: 作业失败。 | -| Msg | 如果作业失败,显示失败信息。 | -| Progress | 作业进度。仅在 RUNNING 状态下显示。进度以 M/N 的形式显示。N 是 Schema Change 中涉及的副本的总数。M 是已完成历史数据转换的副本数。 | -| Timeout | 作业超时时间,以秒为单位。 | - -## 举例 - -1. 展示默认 db 的所有修改列的任务执行情况 - - ```sql - SHOW ALTER TABLE COLUMN; - ``` - -2. 展示某个表最近一次修改列的任务执行情况 - - ```sql - SHOW ALTER TABLE COLUMN WHERE TableName = "table1" ORDER BY CreateTime DESC LIMIT 1; - ``` - -3. 展示指定 db 的创建或删除 ROLLUP 的任务执行情况 - - ```sql - SHOW ALTER TABLE ROLLUP FROM example_db; - ``` - -### Keywords - - SHOW, ALTER - -### Best Practice diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ANALYZE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ANALYZE.md deleted file mode 100644 index 940ffba9e4f5f..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ANALYZE.md +++ /dev/null @@ -1,111 +0,0 @@ ---- -{ - "title": "SHOW-ANALYZE", - "language": "zh-CN" -} ---- - - - -## SHOW-ANALYZE - -### Name - -SHOW ANALYZE - -## 描述 - -通过 `SHOW ANALYZE` 来查看统计信息收集作业的信息。 - -语法如下: - -```SQL -SHOW [AUTO] ANALYZE < table_name | job_id > - [ WHERE [ STATE = [ "PENDING" | "RUNNING" | "FINISHED" | "FAILED" ] ] ]; -``` - -- AUTO:仅仅展示自动收集历史作业信息。需要注意的是默认只保存过去 20000 个执行完毕的自动收集作业的状态。 -- table_name:表名,指定后可查看该表对应的统计作业信息。可以是  `db_name.table_name`  形式。不指定时返回所有统计作业信息。 -- job_id:统计信息作业 ID,执行 `ANALYZE` 异步收集时得到。不指定 id 时此命令返回所有统计作业信息。 - -输出: - -| 列名 | 说明 | -| :--------------------- | :----------- | -| `job_id` | 统计作业 ID | -| `catalog_name` | catalog 名称 | -| `db_name` | 数据库名称 | -| `tbl_name` | 表名称 | -| `col_name` | 列名称列表 | -| `job_type` | 作业类型 | -| `analysis_type` | 统计类型 | -| `message` | 作业信息 | -| `last_exec_time_in_ms` | 上次执行时间 | -| `state` | 作业状态 | -| `schedule_type` | 调度方式 | - -下面是一个例子: - -```sql -mysql> show analyze 245073\G; -*************************** 1. row *************************** - job_id: 245073 - catalog_name: internal - db_name: default_cluster:tpch - tbl_name: lineitem - col_name: [l_returnflag,l_receiptdate,l_tax,l_shipmode,l_suppkey,l_shipdate,l_commitdate,l_partkey,l_orderkey,l_quantity,l_linestatus,l_comment,l_extendedprice,l_linenumber,l_discount,l_shipinstruct] - job_type: MANUAL - analysis_type: FUNDAMENTALS - message: -last_exec_time_in_ms: 2023-11-07 11:00:52 - state: FINISHED - progress: 16 Finished | 0 Failed | 0 In Progress | 16 Total - schedule_type: ONCE -``` - -
- -每个收集作业中可以包含一到多个任务,每个任务对应一列的收集。用户可通过如下命令查看具体每列的统计信息收集完成情况。 - -语法: - -```sql -SHOW ANALYZE TASK STATUS [job_id] -``` - -下面是一个例子: - -``` -mysql> show analyze task status 20038 ; -+---------+----------+---------+----------------------+----------+ -| task_id | col_name | message | last_exec_time_in_ms | state | -+---------+----------+---------+----------------------+----------+ -| 20039 | col4 | | 2023-06-01 17:22:15 | FINISHED | -| 20040 | col2 | | 2023-06-01 17:22:15 | FINISHED | -| 20041 | col3 | | 2023-06-01 17:22:15 | FINISHED | -| 20042 | col1 | | 2023-06-01 17:22:15 | FINISHED | -+---------+----------+---------+----------------------+----------+ - - -``` - -### Keywords - -SHOW, ANALYZE diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-BACKENDS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-BACKENDS.md deleted file mode 100644 index 40524d39e2156..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-BACKENDS.md +++ /dev/null @@ -1,65 +0,0 @@ ---- -{ - "title": "SHOW-BACKENDS", - "language": "zh-CN" -} ---- - - - -## SHOW-BACKENDS - -### Name - -SHOW BACKENDS - -## 描述 - -该语句用于查看 cluster 内的 BE 节点 - -```sql - SHOW BACKENDS; -``` - -说明: - - 1. LastStartTime 表示最近一次 BE 启动时间。 - 2. LastHeartbeat 表示最近一次心跳。 - 3. Alive 表示节点是否存活。 - 4. SystemDecommissioned 为 true 表示节点正在安全下线中。 - 5. ClusterDecommissioned 为 true 表示节点正在冲当前cluster中下线。 - 6. TabletNum 表示该节点上分片数量。 - 7. DataUsedCapacity 表示实际用户数据所占用的空间。 - 8. AvailCapacity 表示磁盘的可使用空间。 - 9. TotalCapacity 表示总磁盘空间。TotalCapacity = AvailCapacity + DataUsedCapacity + 其他非用户数据文件占用空间。 - 10. UsedPct 表示磁盘已使用量百分比。 - 11. ErrMsg 用于显示心跳失败时的错误信息。 - 12. Status 用于以 JSON 格式显示BE的一些状态信息, 目前包括最后一次BE汇报其tablet的时间信息。 - 13. HeartbeatFailureCounter:现在当前连续失败的心跳次数,如果次数超过 `max_backend_heartbeat_failure_tolerance_count` 配置,则 isAlive 字段会置为 false。 - 14. NodeRole用于展示节点角色, 现在有两种类型: Mix代表原来的节点类型, computation代表只做计算的节点类型. - -## 举例 - -### Keywords - - SHOW, BACKENDS - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-BACKUP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-BACKUP.md deleted file mode 100644 index 73c1938f5a07f..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-BACKUP.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -{ - "title": "SHOW-BACKUP", - "language": "zh-CN" -} ---- - - - -## SHOW-BACKUP - -### Name - -SHOW BACKUP - -## 描述 - -该语句用于查看 BACKUP 任务 - -语法: - -```sql - SHOW BACKUP [FROM db_name] - [WHERE SnapshotName ( LIKE | = ) 'snapshot name' ] -``` - -说明: - - 1. Doris 中仅保存最近一次 BACKUP 任务。 - 2. 各列含义如下: - JobId: 唯一作业id - SnapshotName: 备份的名称 - DbName: 所属数据库 - State: 当前阶段 - PENDING: 提交作业后的初始状态 - SNAPSHOTING: 执行快照中 - UPLOAD_SNAPSHOT:快照完成,准备上传 - UPLOADING: 快照上传中 - SAVE_META: 将作业元信息保存为本地文件 - UPLOAD_INFO: 上传作业元信息 - FINISHED: 作业成功 - CANCELLED: 作业失败 - BackupObjs: 备份的表和分区 - CreateTime: 任务提交时间 - SnapshotFinishedTime: 快照完成时间 - UploadFinishedTime: 快照上传完成时间 - FinishedTime: 作业结束时间 - UnfinishedTasks: 在 SNAPSHOTING 和 UPLOADING 阶段会显示还未完成的子任务id - Status: 如果作业失败,显示失败信息 - Timeout: 作业超时时间,单位秒 - -## 举例 - -1. 查看 example_db 下最后一次 BACKUP 任务。 - - ```sql - SHOW BACKUP FROM example_db; - ``` - -### Keywords - - SHOW, BACKUP - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-BROKER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-BROKER.md deleted file mode 100644 index b38899398174f..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-BROKER.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -{ - "title": "SHOW-BROKER", - "language": "zh-CN" -} ---- - - - -## SHOW-BROKER - -### Name - -SHOW BROKER - -## 描述 - -该语句用于查看当前存在的 broker - -语法: - -```sql -SHOW BROKER; -``` - -说明: - - 1. LastStartTime 表示最近一次 BE 启动时间。 - 2. LastHeartbeat 表示最近一次心跳。 - 3. Alive 表示节点是否存活。 - 4. ErrMsg 用于显示心跳失败时的错误信息。 - -## 举例 - -### Keywords - - SHOW, BROKER - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CACHE-HOTSPOT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CACHE-HOTSPOT.md deleted file mode 100644 index 0219e8aeba298..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CACHE-HOTSPOT.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -{ - "title": "SHOW-CACHE-HOTSPOT", - "language": "zh-CN" -} ---- - - - -## 描述 - -该语句用于显示文件缓存的热点信息。 - -## 语法 - -```sql - SHOW CACHE HOTSPOT '/[compute_group_name/table_name]'; -``` - -## 参数 - -1. compute_group_name : 计算组的名称。 -2. table_name : 表的名称。 - -## 示例 - -1. 查看某个表的创建语句 - - ```sql - SHOW CACHE HOTSPOT '/'; - ``` - -## 相关命令 - - - [WARMUP CACHE](../Database-Administration-Statements/WARM-UP-COMPUTE-GROUP.md) - -## 参考 - - - [MANAGING FILE CACHE](../../../compute-storage-decoupled/file-cache.md) - -## 关键词 - - SHOW, CACHE, HOTSPOT - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CATALOG-RECYCLE-BIN.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CATALOG-RECYCLE-BIN.md deleted file mode 100644 index ccc3f6181f29f..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CATALOG-RECYCLE-BIN.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -{ - "title": "SHOW-CATALOG-RECYCLE-BIN", - "language": "zh-CN" -} ---- - - - -## SHOW-CATALOG-RECYCLE-BIN - -### Name - -SHOW CATALOG RECYCLE BIN - -## 描述 - -该语句用于展示回收站中可回收的库,表或分区元数据信息 - -语法: - -```sql -SHOW CATALOG RECYCLE BIN [ WHERE NAME [ = "name" | LIKE "name_matcher"] ] -``` - -说明: - -``` -各列含义如下: - Type: 元数据类型:Database、Table、Partition - Name: 元数据名称 - DbId: database对应的id - TableId: table对应的id - PartitionId: partition对应的id - DropTime: 元数据放入回收站的时间 - DataSize: 数据量. 如果元数据类型是database, 该值包含了database下在回收站中的所有table和partition的数据量 - RemoteDataSize: remote storage(hdfs或对象存储)的数据量. 如果元数据类型是database, 该值包含了database下在回收站中的所有table和partition的remote storage数据量 -``` - - -## 举例 - - 1. 展示所有回收站元数据 - - ```sql - SHOW CATALOG RECYCLE BIN; - ``` - - 2. 展示回收站中名称'test'的元数据 - - ```sql - SHOW CATALOG RECYCLE BIN WHERE NAME = 'test'; - ``` - -### Keywords - - SHOW, CATALOG RECYCLE BIN - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CATALOGS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CATALOGS.md deleted file mode 100644 index 577f19cd1f3cd..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CATALOGS.md +++ /dev/null @@ -1,84 +0,0 @@ ---- -{ - "title": "SHOW-CATALOGS", - "language": "zh-CN" -} ---- - - - -## SHOW-CATALOGS - -### Name - -SHOW CATALOGS - -## 描述 - -该语句用于显示已存在是数据目录(catalog) - -语法: - -```sql -SHOW CATALOGS [LIKE] -``` - -说明: - -LIKE:可按照 CATALOG 名进行模糊查询 - -返回结果说明: - -* CatalogId:数据目录唯一 ID -* CatalogName:数据目录名称。其中 internal 是默认内置的 catalog,不可修改。 -* Type:数据目录类型。 -* IsCurrent: 是否为当前正在使用的数据目录。 - -## 举例 - -1. 查看当前已创建的数据目录 - - ```sql - SHOW CATALOGS; - +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ - | CatalogId | CatalogName | Type | IsCurrent | CreateTime | LastUpdateTime | Comment | - +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ - | 130100 | hive | hms | | 2023-12-25 16:11:41.687 | 2023-12-25 20:43:18 | NULL | - | 0 | internal | internal | yes | UNRECORDED | NULL | Doris internal catalog | - +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ - ``` - -2. 按照目录名进行模糊搜索 - - ```sql - SHOW CATALOGS LIKE 'hi%'; - +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ - | CatalogId | CatalogName | Type | IsCurrent | CreateTime | LastUpdateTime | Comment | - +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ - | 130100 | hive | hms | | 2023-12-25 16:11:41.687 | 2023-12-25 20:43:18 | NULL | - +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ - ``` - -### Keywords - -SHOW, CATALOG, CATALOGS - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CHARSET.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CHARSET.md deleted file mode 100644 index 1984ea1a02389..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CHARSET.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -{ - "title": "SHOW-CHARSET", - "language": "zh-CN" -} ---- - - - -## SHOW-CHARSET - -## 描述 - -"SHOW CHARACTER" 命令用于显示当前数据库管理系统中可用的字符集(character set)以及与每个字符集相关联的一些属性。这些属性可能包括字符集的名称、默认排序规则、最大字节长度等。通过运行 "SHOW CHARACTER" 命令,可以查看系统中支持的字符集列表及其详细信息。 - -SHOW CHARACTER 命令返回以下字段: - - -Charset:字符集 -Description:描述 -Default Collation:默认校对名称 -Maxlen:最大字节长度 - -## 举例 - -```sql -mysql> show charset; - -| Charset | Description | Default collation | Maxlen | -|-----------|-----------------|-------------------|--------| -| utf8mb4 | UTF-8 Unicode | utf8mb4_0900_bin | 4 | - -``` - -### Keywords - - SHOW, CHARSET - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-COLLATION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-COLLATION.md deleted file mode 100644 index cad0aa2eb927f..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-COLLATION.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -{ - "title": "SHOW-COLLATION", - "language": "zh-CN" -} ---- - - - -## 描述 - -在 Doris 中,`SHOW COLLATION` 命令用于显示数据库中可用的字符集校对。校对是一组决定数据如何排序和比较的规则。这些规则会影响字符数据的存储和检索。Doris 目前主要支持 utf8mb4_0900_bin 这一种校对方式。 - -## 语法 - -``` -SHOW COLLATION -``` - -## 返回结果 - -`SHOW COLLATION` 命令返回以下字段: - -* Collation:校对名称 -* Charset:字符集 -* Id:校对的ID -* Default:是否是该字符集的默认校对 -* Compiled:是否已编译 -* Sortlen:排序长度 - -## 示例 - -```sql -how collation; -``` - -``` -+------------------+---------+------+---------+----------+---------+ -| Collation | Charset | Id | Default | Compiled | Sortlen | -+------------------+---------+------+---------+----------+---------+ -| utf8mb4_0900_bin | utf8mb4 | 33 | Yes | Yes | 1 | -+------------------+---------+------+---------+----------+---------+ -``` - -## 注意事项 - -在 Doris 中,虽然兼容 MySQL 的设置 collation 的命令。但是实际并不会生效。执行时,永远会使用 utf8mb4_0900_bin 作为比较规则。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-COLUMN-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-COLUMN-STATS.md deleted file mode 100644 index c31188403dcda..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-COLUMN-STATS.md +++ /dev/null @@ -1,72 +0,0 @@ ---- -{ - "title": "SHOW-COLUMN-STATS", - "language": "zh-CN" -} ---- - - - -## SHOW-COLUMN-STATS - -### Name - -SHOW COLUMN STATS - -## 描述 - -通过 `SHOW COLUMN STATS` 来查看列的各项统计数据。 - -语法如下: - -```SQL -SHOW COLUMN [cached] STATS table_name [ (column_name [, ...]) ]; -``` - -其中: - -- cached: 展示当前 FE 内存缓存中的统计信息。 -- table_name: 收集统计信息的目标表。可以是  `db_name.table_name`  形式。 -- column_name: 指定的目标列,必须是  `table_name`  中存在的列,多个列名称用逗号分隔。 - -下面是一个例子: - -```sql -mysql> show column stats lineitem(l_tax)\G; -*************************** 1. row *************************** - column_name: l_tax - count: 6001215.0 - ndv: 9.0 - num_null: 0.0 - data_size: 4.800972E7 -avg_size_byte: 8.0 - min: 0.00 - max: 0.08 - method: FULL - type: FUNDAMENTALS - trigger: MANUAL - query_times: 0 - updated_time: 2023-11-07 11:00:46 - -``` - -### Keywords - -SHOW, COLUMN, STATS diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-COLUMNS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-COLUMNS.md deleted file mode 100644 index 5f72df5d956b6..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-COLUMNS.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "SHOW-COLUMNS", - "language": "zh-CN" -} ---- - - - -## SHOW-COLUMNS - -### Name - -SHOW FULL COLUMNS - -## 描述 - -该语句用于指定表的列信息 - -语法: - -```sql -SHOW [FULL] COLUMNS FROM tbl; -``` - -## 举例 - -1. 查看指定表的列信息 - - ```sql - SHOW FULL COLUMNS FROM tbl; - ``` - -### Keywords - - SHOW, FULL, COLUMNS - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-COMPUTE-GROUPS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-COMPUTE-GROUPS.md deleted file mode 100644 index 7912f60267c36..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-COMPUTE-GROUPS.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -{ - "title": "SHOW COMPUTE GROUPS", - "language": "zh-CN" -} ---- - - - -## 描述 - -SHOW COMPUTE GROUPS 命令用于显示系统中所有已配置的计算组的信息。计算组是用于管理和组织计算资源的逻辑单元,可以帮助用户更有效地分配和使用系统资源。 - -此命令可以帮助管理员和用户快速了解系统中现有的计算组配置,包括每个计算组的名称、属性和其他相关信息。这对于资源管理、性能优化和系统监控非常有用。 - -## 语法 - -```sql - SHOW COMPUTE GROUPS -``` - -## 返回值 - -此命令返回一个结果集,包含以下列: - -- `Name`: 计算组的名称。 -- `IsCurrent`: 是否当前工作计算组。 -- `Users`: 显示有权限使用该计算组的用户列表。 -- `BackendNum`: 显示当前分配给该计算组的后端(计算节点)数量。 - -## 相关命令 - -- [ALTER SYSTEM ADD BACKEND](../Administration-Statements/ALTER-SYSTEM-ADD-BACKEND.md) -- [GRANT](../Account-Management-Statements/GRANT.md) -- [REVOKE](../Account-Management-Statements/REVOKE.md) -- [SET DEFAULT COMPUTE GROUP](../Administration-Statements/SET-DEFAULT-COMPUTE-GROUP.md) - -### Keywords - - SHOW, COMPUTE GROUPS diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CONVERT-LIGHT-SCHEMA-CHANGE-PROCESS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CONVERT-LIGHT-SCHEMA-CHANGE-PROCESS.md deleted file mode 100644 index 4bb9b9481862e..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CONVERT-LIGHT-SCHEMA-CHANGE-PROCESS.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -{ - "title": "SHOW-CONVERT-LIGHT-SCHEMA-CHANGE-PROCESS", - "language": "zh-CN" -} ---- - - - -## SHOW-CONVERT-LIGHT-SCHEMA-CHANGE-PROCESS - -### Name - -SHOW CONVERT LIGHT SCHEMA CHANGE PROCESS - -## 描述 - -用来查看将非light schema change的olpa表转换为light schema change表的情况, 需要开启配置`enable_convert_light_weight_schema_change` - -语法: - -```sql -SHOW CONVERT_LIGHT_SCHEMA_CHANGE_PROCESS [FROM db] -``` - -## 举例 - -1. 查看在database test上的转换情况 - - ```sql - SHOW CONVERT_LIGHT_SCHEMA_CHANGE_PROCESS FROM test; - ``` - -2. 查看全局的转换情况 - - ```sql - SHOW CONVERT_LIGHT_SCHEMA_CHANGE_PROCESS; - ``` - - -### Keywords - - SHOW, CONVERT_LIGHT_SCHEMA_CHANGE_PROCESS - -### Best Practice \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-ASYNC-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-ASYNC-MATERIALIZED-VIEW.md deleted file mode 100644 index cffbf77949cd6..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-ASYNC-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -{ - "title": "SHOW-CREATE-ASYNC-MATERIALIZED-VIEW", - "language": "zh-CN" -} ---- - - - -## SHOW-CREATE-ASYNC-MATERIALIZED-VIEW - -### Name - -SHOW CREATE ASYNC MATERIALIZED VIEW - -## 描述 - -该语句用于展示异步物化视图的创建语句。 - -语法: - -```sql -SHOW CREATE MATERIALIZED VIEW [DBNAME.]MV_NAME -``` - -说明: - -1. `DBNAMNE` : 数据库名称 -2. `MV_NAME` : 异步物化视图的名称 - -## 举例 - -1. 查看 mv1 的创建语句 - - ```sql - SHOW CREATE MATERIALIZED VIEW mv1; - ``` - -### Keywords - - SHOW, CREATE, MATERIALIZED, VIEW, ASYNC - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-CATALOG.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-CATALOG.md deleted file mode 100644 index 1a2648e646a55..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-CATALOG.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -{ - "title": "SHOW-CREATE-CATALOG", - "language": "zh-CN" -} ---- - - - -## SHOW-CREATE-CATALOG - -### Name - -SHOW CREATE CATALOG - -## 描述 - -该语句查看 doris 数据目录的创建语句。 - -语法: - -```sql -SHOW CREATE CATALOG catalog_name; -``` - -说明: - -- `catalog_name`: 为 doris 中存在的数据目录的名称。 - -## 举例 - -1. 查看 doris 中 hive 数据目录的创建语句 - - ```sql - SHOW CREATE CATALOG hive; - ``` - -### Keywords - - SHOW, CREATE, CATALOG - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-DATABASE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-DATABASE.md deleted file mode 100644 index f0c55b2fe1d29..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-DATABASE.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -{ - "title": "SHOW-CREATE-DATABASE", - "language": "zh-CN" -} ---- - - - -## SHOW-CREATE-DATABASE - -### Name - -SHOW CREATE DATABASE - -## 描述 - -该语句查看 doris 内置数据库和 hms catalog 数据库的创建信息。 - -语法: - -```sql -SHOW CREATE DATABASE db_name; -``` - -说明: - -- `db_name`: 为 内置数据库或 hms catalog 数据库的名称。 -- 如果查看 hms catalog 内数据库,返回信息和 hive 中同名命令结果一样。 - -## 举例 - -1. 查看doris中test数据库的创建情况 - - ```sql - mysql> SHOW CREATE DATABASE test; - +----------+------------------------+ - | Database | Create Database | - +----------+------------------------+ - | test | CREATE DATABASE `test` | - +----------+------------------------+ - 1 row in set (0.00 sec) - ``` -2. 查看 hive catalog 中数据库hdfs_text的创建信息 - - ```sql - mysql> show create database hdfs_text; - +-----------+------------------------------------------------------------------------------------+ - | Database | Create Database | - +-----------+------------------------------------------------------------------------------------+ - | hdfs_text | CREATE DATABASE `hdfs_text` LOCATION 'hdfs://HDFS1009138/hive/warehouse/hdfs_text' | - +-----------+------------------------------------------------------------------------------------+ - 1 row in set (0.01 sec) - ``` -### Keywords - - SHOW, CREATE, DATABASE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-FUNCTION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-FUNCTION.md deleted file mode 100644 index 178f38d64bad0..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-FUNCTION.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -{ - "title": "SHOW-CREATE-FUNCTION", - "language": "zh-CN" -} ---- - - - -## SHOW-CREATE-FUNCTION - -### Name - -SHOW CREATE FUNCTION - -## 描述 - -该语句用于展示用户自定义函数的创建语句 - -语法: - -```sql -SHOW CREATE [GLOBAL] FUNCTION function_name(arg_type [, ...]) [FROM db_name]]; -``` - -说明: - 1. `global`: 要展示的是全局函数 - 2. `function_name`: 要展示的函数名称 - 3. `arg_type`: 要展示的函数的参数列表 - 4. 如果不指定 db_name,使用当前默认 db - -**注意: "global"关键字在v2.0版本及以后才可用** - -## 举例 - -1. 展示默认db下指定函数的创建语句 - - ```sql - SHOW CREATE FUNCTION my_add(INT, INT) - ``` - -2. 展示指定的全局函数的创建语句 - - ```sql - SHOW CREATE GLOBAL FUNCTION my_add(INT, INT) - ``` - -### Keywords - - SHOW, CREATE, FUNCTION - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-LOAD.md deleted file mode 100644 index 04befe5939fbe..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-LOAD.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -{ - "title": "SHOW-CREATE-LOAD", - "language": "zh-CN" -} ---- - - - -## SHOW-CREATE-LOAD - -### Name - -SHOW CREATE LOAD - -## 描述 - -该语句用于展示导入作业的创建语句. - -语法: - -```sql -SHOW CREATE LOAD for load_name; -``` - -说明: - 1. `load_name`: 例行导入作业名称 - -## 举例 - -1. 展示默认db下指定导入作业的创建语句 - - ```sql - SHOW CREATE LOAD for test_load - ``` - -### Keywords - - SHOW, CREATE, LOAD - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-MATERIALIZED-VIEW.md deleted file mode 100644 index 97d7e8e22b7e2..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -{ - "title": "SHOW-CREATE-MATERIALIZED-VIEW", - "language": "zh-CN" -} ---- - - - -## SHOW-CREATE-MATERIALIZED-VIEW - -### Name - -SHOW CREATE MATERIALIZED VIEW - -## 描述 - -该语句用于查询创建物化视图的语句。 - -语法: - -```sql -SHOW CREATE MATERIALIZED VIEW mv_name ON table_name -``` - -1. mv_name: - 物化视图的名称。必填项。 - -2. table_name: - 物化视图所属的表名。必填项。 - -## 举例 - -创建物化视图的语句为 - -```sql -create materialized view id_col1 as select id,col1 from table3; -``` - -查询后返回 - -```sql -mysql> show create materialized view id_col1 on table3; -+-----------+----------+----------------------------------------------------------------+ -| TableName | ViewName | CreateStmt | -+-----------+----------+----------------------------------------------------------------+ -| table3 | id_col1 | create materialized view id_col1 as select id,col1 from table3 | -+-----------+----------+----------------------------------------------------------------+ -1 row in set (0.00 sec) -``` - -### Keywords - - SHOW, MATERIALIZED, VIEW - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-REPOSITORY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-REPOSITORY.md deleted file mode 100644 index d16beda52f679..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-REPOSITORY.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -{ - "title": "SHOW-CREATE-REPOSITORY", - "language": "zh-CN" -} ---- - - - -## SHOW-CREATE-REPOSITORY - -### Name - -SHOW CREATE REPOSITORY - -## 描述 - -该语句用于展示仓库的创建语句. - -语法: - -```sql -SHOW CREATE REPOSITORY for repository_name; -``` - -说明: -- `repository_name`: 仓库名称 - -## 举例 - -1. 展示指定仓库的创建语句 - - ```sql - SHOW CREATE REPOSITORY for test_repository - ``` - -### Keywords - - SHOW, CREATE, REPOSITORY - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-ROUTINE-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-ROUTINE-LOAD.md deleted file mode 100644 index 8b16fd7431e47..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-ROUTINE-LOAD.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -{ - "title": "SHOW-CREATE-ROUTINE-LOAD", - "language": "zh-CN" -} ---- - - - -## SHOW-CREATE-ROUTINE-LOAD - -### Name - -SHOW CREATE ROUTINE LOAD - -## 描述 - -该语句用于展示例行导入作业的创建语句. - -结果中的 kafka partition 和 offset 展示的当前消费的 partition,以及对应的待消费的 offset。 - -语法: - -```sql -SHOW [ALL] CREATE ROUTINE LOAD for load_name; -``` - -说明: - 1. `ALL`: 可选参数,代表获取所有作业,包括历史作业 - 2. `load_name`: 例行导入作业名称 - -## 举例 - -1. 展示默认db下指定例行导入作业的创建语句 - - ```sql - SHOW CREATE ROUTINE LOAD for test_load - ``` - -### Keywords - - SHOW, CREATE, ROUTINE, LOAD - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-TABLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-TABLE.md deleted file mode 100644 index 07fbf5217ec14..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-CREATE-TABLE.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -{ - "title": "SHOW-CREATE-TABLE", - "language": "zh-CN" -} ---- - - - -## SHOW-CREATE-TABLE - -### Name - -SHOW CREATE TABLE - -## 描述 - -该语句用于展示数据表的创建语句。 - -语法: - -```sql -SHOW [BRIEF] CREATE TABLE [DBNAME.]TABLE_NAME -``` - -说明: - -1. `BRIEF` : 返回结果中不展示分区信息 -2. `DBNAMNE` : 数据库名称 -3. `TABLE_NAME` : 表名 - -## 举例 - -1. 查看某个表的建表语句 - - ```sql - SHOW CREATE TABLE demo.tb1 - ``` - -### Keywords - - SHOW, CREATE, TABLE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DATA-SKEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DATA-SKEW.md deleted file mode 100644 index 42a1aa3bee5a1..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DATA-SKEW.md +++ /dev/null @@ -1,159 +0,0 @@ ---- -{ -"title": "SHOW-DATA-SKEW", -"language": "zh-CN" -} ---- - - - -## SHOW-DATA-SKEW - -### Name - -SHOW DATA SKEW - -## 描述 - - 该语句用于查看表或某个分区的数据倾斜情况。 - - 语法: - - SHOW DATA SKEW FROM [db_name.]tbl_name [PARTITION (partition_name, ...)]; - - 说明: - - 1. 结果将展示指定分区下,各个分桶的数据行数,数据量,以及每个分桶数据量在总数据量中的占比。 - 2. 对于非分区表,查询结果中分区名称同表名。 - -## 举例 -1. 分区表场景 - -* 建表语句 - ```sql - CREATE TABLE test_show_data_skew - ( - id int, - name string, - pdate date - ) - PARTITION BY RANGE(pdate) - ( - FROM ("2023-04-16") TO ("2023-04-20") INTERVAL 1 DAY - ) - DISTRIBUTED BY HASH(id) BUCKETS 5 - PROPERTIES ( - "replication_num" = "1" - ); - ``` -* 查询整表的数据倾斜情况 - ```sql - mysql> SHOW DATA SKEW FROM test_show_data_skew; - +---------------+-----------+-------------+-------------+------------------------------------------------------------------------------------------------------+---------+ - | PartitionName | BucketIdx | AvgRowCount | AvgDataSize | Graph | Percent | - +---------------+-----------+-------------+-------------+------------------------------------------------------------------------------------------------------+---------+ - | p_20230416 | 0 | 1 | 648 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 49.77 % | - | p_20230416 | 1 | 2 | 654 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 50.23 % | - | p_20230416 | 2 | 0 | 0 | | 00.00 % | - | p_20230416 | 3 | 0 | 0 | | 00.00 % | - | p_20230416 | 4 | 0 | 0 | | 00.00 % | - | p_20230417 | 0 | 0 | 0 | | 00.00 % | - | p_20230417 | 1 | 0 | 0 | | 00.00 % | - | p_20230417 | 2 | 0 | 0 | | 00.00 % | - | p_20230417 | 3 | 0 | 0 | | 00.00 % | - | p_20230417 | 4 | 2 | 656 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 100.00% | - | p_20230418 | 0 | 0 | 0 | | 00.00 % | - | p_20230418 | 1 | 1 | 648 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 100.00% | - | p_20230418 | 2 | 0 | 0 | | 00.00 % | - | p_20230418 | 3 | 0 | 0 | | 00.00 % | - | p_20230418 | 4 | 0 | 0 | | 00.00 % | - | p_20230419 | 0 | 0 | 0 | | 00.00 % | - | p_20230419 | 1 | 1 | 648 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 49.96 % | - | p_20230419 | 2 | 0 | 0 | | 00.00 % | - | p_20230419 | 3 | 1 | 649 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 50.04 % | - | p_20230419 | 4 | 0 | 0 | | 00.00 % | - +---------------+-----------+-------------+-------------+------------------------------------------------------------------------------------------------------+---------+ - ``` -* 查询指定分区的数据倾斜情况 - ```sql - mysql> SHOW DATA SKEW FROM test_show_data_skew PARTITION(p_20230416, p_20230418); - +---------------+-----------+-------------+-------------+------------------------------------------------------------------------------------------------------+---------+ - | PartitionName | BucketIdx | AvgRowCount | AvgDataSize | Graph | Percent | - +---------------+-----------+-------------+-------------+------------------------------------------------------------------------------------------------------+---------+ - | p_20230416 | 0 | 1 | 648 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 49.77 % | - | p_20230416 | 1 | 2 | 654 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 50.23 % | - | p_20230416 | 2 | 0 | 0 | | 00.00 % | - | p_20230416 | 3 | 0 | 0 | | 00.00 % | - | p_20230416 | 4 | 0 | 0 | | 00.00 % | - | p_20230418 | 0 | 0 | 0 | | 00.00 % | - | p_20230418 | 1 | 1 | 648 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 100.00% | - | p_20230418 | 2 | 0 | 0 | | 00.00 % | - | p_20230418 | 3 | 0 | 0 | | 00.00 % | - | p_20230418 | 4 | 0 | 0 | | 00.00 % | - +---------------+-----------+-------------+-------------+------------------------------------------------------------------------------------------------------+---------+ - ``` - -2. 非分区表场景 - -* 建表语句 - ```sql - CREATE TABLE test_show_data_skew2 - ( - id int, - name string, - pdate date - ) - DISTRIBUTED BY HASH(id) BUCKETS 5 - PROPERTIES ( - "replication_num" = "1" - ); - ``` -* 查询整表的数据倾斜情况 - ```sql - mysql> SHOW DATA SKEW FROM test_show_data_skew2; - +----------------------+-----------+-------------+-------------+---------------------------+---------+ - | PartitionName | BucketIdx | AvgRowCount | AvgDataSize | Graph | Percent | - +----------------------+-----------+-------------+-------------+---------------------------+---------+ - | test_show_data_skew2 | 0 | 1 | 648 | >>>>>>>>>>>>>>>>>>>>>>>> | 24.73 % | - | test_show_data_skew2 | 1 | 4 | 667 | >>>>>>>>>>>>>>>>>>>>>>>>> | 25.46 % | - | test_show_data_skew2 | 2 | 0 | 0 | | 00.00 % | - | test_show_data_skew2 | 3 | 1 | 649 | >>>>>>>>>>>>>>>>>>>>>>>> | 24.77 % | - | test_show_data_skew2 | 4 | 2 | 656 | >>>>>>>>>>>>>>>>>>>>>>>>> | 25.04 % | - +----------------------+-----------+-------------+-------------+---------------------------+---------+ - - - - mysql> SHOW DATA SKEW FROM test_show_data_skew2 PARTITION(test_show_data_skew2); - +----------------------+-----------+-------------+-------------+---------------------------+---------+ - | PartitionName | BucketIdx | AvgRowCount | AvgDataSize | Graph | Percent | - +----------------------+-----------+-------------+-------------+---------------------------+---------+ - | test_show_data_skew2 | 0 | 1 | 648 | >>>>>>>>>>>>>>>>>>>>>>>> | 24.73 % | - | test_show_data_skew2 | 1 | 4 | 667 | >>>>>>>>>>>>>>>>>>>>>>>>> | 25.46 % | - | test_show_data_skew2 | 2 | 0 | 0 | | 00.00 % | - | test_show_data_skew2 | 3 | 1 | 649 | >>>>>>>>>>>>>>>>>>>>>>>> | 24.77 % | - | test_show_data_skew2 | 4 | 2 | 656 | >>>>>>>>>>>>>>>>>>>>>>>>> | 25.04 % | - +----------------------+-----------+-------------+-------------+---------------------------+---------+ - ``` - -### Keywords - - SHOW,DATA,SKEW - -### Best Practice \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DATA-TYPES.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DATA-TYPES.md deleted file mode 100644 index d5b32c3bc430e..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DATA-TYPES.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -{ - "title": "SHOW-DATA-TYPES", - "language": "zh-CN" -} ---- - - - -## SHOW-DATA-TYPES - -### Name - -SHOW DATA TYPES - -## 描述 - - 该语句用于查看DORIS支持的所有数据类型。 - - 语法: - ```sql - SHOW DATA TYPES; - ``` - -## 举例 - - 1. 查看Doris支持的所有数据类型 - - SHOW DATA TYPES; - -### Keywords - - SHOW,DATA,TYPES - -### Best Practice diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DATA.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DATA.md deleted file mode 100644 index 69b5c28494f8a..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DATA.md +++ /dev/null @@ -1,141 +0,0 @@ ---- -{ - "title": "SHOW-DATA", - "language": "zh-CN" -} ---- - - - -## SHOW-DATA - -### Name - -SHOW DATA - -## 描述 - -该语句用于展示数据量、副本数量以及统计行数。 - -语法: - -```sql -SHOW DATA [FROM [db_name.]table_name] [ORDER BY ...]; -``` - -说明: - -1. 如果不指定 FROM 子句,则展示当前 db 下细分到各个 table 的数据量和副本数量。其中数据量为所有副本的总数据量。而副本数量为表的所有分区以及所有物化视图的副本数量。 - -2. 如果指定 FROM 子句,则展示 table 下细分到各个物化视图的数据量、副本数量和统计行数。其中数据量为所有副本的总数据量。副本数量为对应物化视图的所有分区的副本数量。统计行数为对应物化视图的所有分区统计行数。 - -3. 统计行数时,以多个副本中,行数最大的那个副本为准。 - -4. 结果集中的 `Total` 行表示汇总行。`Quota` 行表示当前数据库设置的配额。`Left` 行表示剩余配额。 - -5. 如果想查看各个 Partition 的大小,请参阅 `help show partitions`。 - -6. 可以使用 ORDER BY 对任意列组合进行排序。 - -## 举例 - -1. 默认展示各个db的汇总数据量,RecycleBin中的数据量 - - ``` - SHOW DATA; - ``` - - ``` - +-------+-----------------------------------+--------+------------+-------------+-------------------+ - | DbId | DbName | Size | RemoteSize | RecycleSize | RecycleRemoteSize | - +-------+-----------------------------------+--------+------------+-------------+-------------------+ - | 21009 | db1 | 0 | 0 | 0 | 0 | - | 22011 | regression_test_inverted_index_p0 | 72764 | 0 | 0 | 0 | - | 0 | information_schema | 0 | 0 | 0 | 0 | - | 22010 | regression_test | 0 | 0 | 0 | 0 | - | 1 | mysql | 0 | 0 | 0 | 0 | - | 22017 | regression_test_show_p0 | 0 | 0 | 0 | 0 | - | 10002 | __internal_schema | 46182 | 0 | 0 | 0 | - | Total | NULL | 118946 | 0 | 0 | 0 | - +-------+-----------------------------------+--------+------------+-------------+-------------------+ - ``` - -2. 展示特定 db 的各个 table 的数据量,副本数量,汇总数据量和汇总副本数量。 - - ```sql - USE db1; - SHOW DATA; - ``` - - ``` - +-----------+-------------+--------------+ - | TableName | Size | ReplicaCount | - +-----------+-------------+--------------+ - | tbl1 | 900.000 B | 6 | - | tbl2 | 500.000 B | 3 | - | Total | 1.400 KB | 9 | - | Quota | 1024.000 GB | 1073741824 | - | Left | 1021.921 GB | 1073741815 | - +-----------+-------------+--------------+ - ``` - -3. 展示指定 db 的下指定表的细分数据量、副本数量和统计行数 - - ```sql - SHOW DATA FROM example_db.test; - ``` - - ``` - +-----------+-----------+-----------+--------------+----------+ - | TableName | IndexName | Size | ReplicaCount | RowCount | - +-----------+-----------+-----------+--------------+----------+ - | test | r1 | 10.000MB | 30 | 10000 | - | | r2 | 20.000MB | 30 | 20000 | - | | test2 | 50.000MB | 30 | 50000 | - | | Total | 80.000 | 90 | | - +-----------+-----------+-----------+--------------+----------+ - ``` - -4. 可以按照数据量、副本数量、统计行数等进行组合排序 - - ```sql - SHOW DATA ORDER BY ReplicaCount desc,Size asc; - ``` - - ``` - +-----------+-------------+--------------+ - | TableName | Size | ReplicaCount | - +-----------+-------------+--------------+ - | table_c | 3.102 KB | 40 | - | table_d | .000 | 20 | - | table_b | 324.000 B | 20 | - | table_a | 1.266 KB | 10 | - | Total | 4.684 KB | 90 | - | Quota | 1024.000 GB | 1073741824 | - | Left | 1024.000 GB | 1073741734 | - +-----------+-------------+--------------+ - ``` - -### Keywords - - SHOW, DATA - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DATABASE-ID.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DATABASE-ID.md deleted file mode 100644 index b25e3c7670044..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DATABASE-ID.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "SHOW-DATABASE-ID", - "language": "zh-CN" -} ---- - - - -## SHOW-DATABASE-ID - -### Name - -SHOW DATABASE ID - -## 描述 - -该语句用于根据 database id 查找对应的 database name(仅管理员使用) - -语法: - -```sql -SHOW DATABASE [database_id] -``` - -## 举例 - -1. 根据 database id 查找对应的 database name - - ```sql - SHOW DATABASE 1001; - ``` - -### Keywords - - SHOW, DATABASE, ID - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DATABASES.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DATABASES.md deleted file mode 100644 index 4ccc1da24f6fa..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DATABASES.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -{ - "title": "SHOW-DATABASES", - "language": "zh-CN" -} ---- - - - -## SHOW-DATABASES - -### Name - -SHOW DATABASES - -## 描述 - -该语句用于展示当前可见的 db - -语法: - -```sql -SHOW DATABASES [FROM catalog] [filter expr]; -``` - -说明: -1. `SHOW DATABASES` 会展示当前所有的数据库名称. -2. `SHOW DATABASES FROM catalog` 会展示`catalog`中所有的数据库名称. -3. `SHOW DATABASES filter_expr` 会展示当前所有经过过滤后的数据库名称. -4. `SHOW DATABASES FROM catalog filter_expr` 这种语法不支持. - -## 举例 -1. 展示当前所有的数据库名称. - - ```sql - SHOW DATABASES; - ``` - - ``` - +--------------------+ - | Database | - +--------------------+ - | test | - | information_schema | - +--------------------+ - ``` - -2. 会展示`hms_catalog`中所有的数据库名称. - - ```sql - SHOW DATABASES from hms_catalog; - ``` - - ``` - +---------------+ - | Database | - +---------------+ - | default | - | tpch | - +---------------+ - ``` - -3. 展示当前所有经过表示式`like 'infor%'`过滤后的数据库名称. - - ```sql - SHOW DATABASES like 'infor%'; - ``` - - ``` - +--------------------+ - | Database | - +--------------------+ - | information_schema | - +--------------------+ - ``` - -### Keywords - - SHOW, DATABASES - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DELETE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DELETE.md deleted file mode 100644 index 7c177e839eff8..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DELETE.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "SHOW-DELETE", - "language": "zh-CN" -} ---- - - - -## SHOW-DELETE - -### Name - -SHOW DELETE - -## 描述 - -该语句用于展示已执行成功的历史 delete 任务 - -语法: - -```sql -SHOW DELETE [FROM db_name] -``` - -## 举例 - - 1. 展示数据库 database 的所有历史 delete 任务 - - ```sql - SHOW DELETE FROM database; - ``` - -### Keywords - - SHOW, DELETE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DYNAMIC-PARTITION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DYNAMIC-PARTITION.md deleted file mode 100644 index 6d020429ee670..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-DYNAMIC-PARTITION.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "SHOW-DYNAMIC-PARTITION", - "language": "zh-CN" -} ---- - - - -## SHOW-DYNAMIC-PARTITION - -### Name - -SHOW DYNAMIC - -## 描述 - -该语句用于展示当前db下所有的动态分区表状态 - -语法: - -```sql -SHOW DYNAMIC PARTITION TABLES [FROM db_name]; -``` - -## 举例 - - 1. 展示数据库 database 的所有动态分区表状态 - - ```sql - SHOW DYNAMIC PARTITION TABLES FROM database; - ``` - -### Keywords - - SHOW, DYNAMIC, PARTITION - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ENCRYPT-KEY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ENCRYPT-KEY.md deleted file mode 100644 index 3ae27cf183f3b..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ENCRYPT-KEY.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -{ - "title": "SHOW-ENCRYPT-KEY", - "language": "zh-CN" -} ---- - - - -## SHOW-ENCRYPT-KEY - -### Name - -SHOW ENCRYPTKEYS - -## 描述 - -查看数据库下所有的自定义的密钥。如果用户指定了数据库,那么查看对应数据库的,否则直接查询当前会话所在数据库。 - -需要对这个数据库拥有 `ADMIN` 权限 - -语法: - -```sql -SHOW ENCRYPTKEYS [IN|FROM db] [LIKE 'key_pattern'] -``` - -参数 - ->`db`: 要查询的数据库名字 ->`key_pattern`: 用来过滤密钥名称的参数 - -## 举例 - - ```sql - mysql> SHOW ENCRYPTKEYS; - +-------------------+-------------------+ - | EncryptKey Name | EncryptKey String | - +-------------------+-------------------+ - | example_db.my_key | ABCD123456789 | - +-------------------+-------------------+ - 1 row in set (0.00 sec) - - mysql> SHOW ENCRYPTKEYS FROM example_db LIKE "%my%"; - +-------------------+-------------------+ - | EncryptKey Name | EncryptKey String | - +-------------------+-------------------+ - | example_db.my_key | ABCD123456789 | - +-------------------+-------------------+ - 1 row in set (0.00 sec) - ``` - -### Keywords - - SHOW, ENCRYPT, KEY - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ENGINES.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ENGINES.md deleted file mode 100644 index 0a6b91c59ffbc..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ENGINES.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -{ - "title": "SHOW-ENGINES", - "language": "zh-CN" -} ---- - - - -## SHOW-ENGINES - -### Name - -SHOW ENGINES - -## 描述 - -## 举例 - -### Keywords - - SHOW, ENGINES - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-EVENTS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-EVENTS.md deleted file mode 100644 index 89ab5831b20c8..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-EVENTS.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -{ - "title": "SHOW-EVENTS", - "language": "zh-CN" -} ---- - - - -## SHOW-EVENTS - -### Name - -SHOW EVENTS - -## 描述 - -## 举例 - -### Keywords - - SHOW, EVENTS - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-EXPORT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-EXPORT.md deleted file mode 100644 index 7bb097fedd071..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-EXPORT.md +++ /dev/null @@ -1,123 +0,0 @@ ---- -{ - "title": "SHOW-EXPORT", - "language": "zh-CN" -} ---- - - - -## SHOW-EXPORT - -### Name - -SHOW EXPORT - -## 描述 - -该语句用于展示指定的导出任务的执行情况 - -语法: - -```sql -SHOW EXPORT -[FROM db_name] - [ - WHERE - [ID = your_job_id] - [STATE = ["PENDING"|"EXPORTING"|"FINISHED"|"CANCELLED"]] - [LABEL = your_label] - ] -[ORDER BY ...] -[LIMIT limit]; -``` -说明: - 1. 如果不指定 db_name,使用当前默认db - 2. 如果指定了 STATE,则匹配 EXPORT 状态 - 3. 可以使用 ORDER BY 对任意列组合进行排序 - 4. 如果指定了 LIMIT,则显示 limit 条匹配记录。否则全部显示 - -`show export` 命令返回的结果各个列的含义如下: - -* JobId:作业的唯一 ID -* Label:该导出作业的标签,如果 Export 没有指定,则系统会默认生成一个。 -* State:作业状态: - * PENDING:作业待调度 - * EXPORTING:数据导出中 - * FINISHED:作业成功 - * CANCELLED:作业失败 -* Progress:作业进度。该进度以查询计划为单位。假设一共 10 个线程,当前已完成 3 个,则进度为 30%。 -* TaskInfo:以 Json 格式展示的作业信息: - * db:数据库名 - * tbl:表名 - * partitions:指定导出的分区。`空`列表 表示所有分区。 - * column\_separator:导出文件的列分隔符。 - * line\_delimiter:导出文件的行分隔符。 - * tablet num:涉及的总 Tablet 数量。 - * broker:使用的 broker 的名称。 - * coord num:查询计划的个数。 - * max\_file\_size:一个导出文件的最大大小。 - * delete\_existing\_files:是否删除导出目录下已存在的文件及目录。 - * columns:指定需要导出的列名,空值代表导出所有列。 - * format:导出的文件格式 -* Path:远端存储上的导出路径。 -* CreateTime/StartTime/FinishTime:作业的创建时间、开始调度时间和结束时间。 -* Timeout:作业超时时间。单位是秒。该时间从 CreateTime 开始计算。 -* ErrorMsg:如果作业出现错误,这里会显示错误原因。 -* OutfileInfo:如果作业导出成功,这里会显示具体的`SELECT INTO OUTFILE`结果信息。 - -## 举例 - -1. 展示默认 db 的所有导出任务 - - ```sql - SHOW EXPORT; - ``` - -2. 展示指定 db 的导出任务,按 StartTime 降序排序 - - ```sql - SHOW EXPORT FROM example_db ORDER BY StartTime DESC; - ``` - -3. 展示指定 db 的导出任务,state 为 "exporting", 并按 StartTime 降序排序 - - ```sql - SHOW EXPORT FROM example_db WHERE STATE = "exporting" ORDER BY StartTime DESC; - ``` - -4. 展示指定db,指定job_id的导出任务 - - ```sql - SHOW EXPORT FROM example_db WHERE ID = job_id; - ``` - -5. 展示指定db,指定label的导出任务 - - ```sql - SHOW EXPORT FROM example_db WHERE LABEL = "mylabel"; - ``` - -### Keywords - - SHOW, EXPORT - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-FILE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-FILE.md deleted file mode 100644 index 639923668f8b3..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-FILE.md +++ /dev/null @@ -1,67 +0,0 @@ ---- -{ - "title": "SHOW-FILE", - "language": "zh-CN" -} ---- - - - -## SHOW-FILE - -### Name - -SHOW FILE - -## 描述 - -该语句用于展示一个 database 内创建的文件 - -语法: - -```sql -SHOW FILE [FROM database]; -``` - -说明: - -```text -FileId: 文件ID,全局唯一 -DbName: 所属数据库名称 -Catalog: 自定义分类 -FileName: 文件名 -FileSize: 文件大小,单位字节 -MD5: 文件的 MD5 -``` - -## 举例 - -1. 查看数据库 my_database 中已上传的文件 - - ```sql - SHOW FILE FROM my_database; - ``` - -### Keywords - - SHOW, FILE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-FRONTENDS-DISKS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-FRONTENDS-DISKS.md deleted file mode 100644 index ef3cd773f9a5d..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-FRONTENDS-DISKS.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -{ - "title": "SHOW-FRONTENDS-DISKS", - "language": "zh-CN" -} ---- - - - -## SHOW-FRONTENDS-DISKS - -### Name - -SHOW FRONTENDS DISKS - -## 描述 - - 该语句用于查看 FE 节点的重要目录如:元数据、日志、审计日志、临时目录对应的磁盘信息 - - 语法: - -```sql -SHOW FRONTENDS DISKS; -``` - -说明: -1. Name 表示该 FE 节点在 bdbje 中的名称。 -2. Host 表示该 FE 节点的IP。 -3. DirType 表示要展示的目录类型,分别有四种类型:meta、log、audit-log、temp、deploy。 -4. Dir 表示要展示的目录类型的目录。 -5. FileSystem 表示要展示的目录类型所在的linux系统的文件系统。 -6. Capacity 文件系统的容量。 -7. Used 文件系统已用大小。 -8. Available 文件系统剩余容量。 -9. UseRate 文件系统使用容量占比。 -10. MountOn 文件系统挂在目录。 - -## 举例 -` -mysql> show frontends disks; -+-----------------------------------------+-------------+-----------+---------------------------------+------------+----------+------+-----------+---------+------------+ -| Name | Host | DirType | Dir | Filesystem | Capacity | Used | Available | UseRate | MountOn | -+-----------------------------------------+-------------+-----------+---------------------------------+------------+----------+------+-----------+---------+------------+ -| fe_a1daac68_5ec0_477c_b5e8_f90a33cdc1bb | 10.xx.xx.90 | meta | /home/disk/output/fe/doris-meta | /dev/sdf1 | 7T | 2T | 4T | 36% | /home/disk | -| fe_a1daac68_5ec0_477c_b5e8_f90a33cdc1bb | 10.xx.xx.90 | log | /home/disk/output/fe/log | /dev/sdf1 | 7T | 2T | 4T | 36% | /home/disk | -| fe_a1daac68_5ec0_477c_b5e8_f90a33cdc1bb | 10.xx.xx.90 | audit-log | /home/disk/output/fe/log | /dev/sdf1 | 7T | 2T | 4T | 36% | /home/disk | -| fe_a1daac68_5ec0_477c_b5e8_f90a33cdc1bb | 10.xx.xx.90 | temp | /home/disk/output/fe/temp_dir | /dev/sdf1 | 7T | 2T | 4T | 36% | /home/disk | -| fe_a1daac68_5ec0_477c_b5e8_f90a33cdc1bb | 10.xx.xx.90 | deploy | /home/disk/output/fe | /dev/sdf1 | 7T | 2T | 4T | 36% | /home/disk | -+-----------------------------------------+-------------+-----------+---------------------------------+------------+----------+------+-----------+---------+------------+ -5 rows in set (0.00 sec) -` - -### Keywords - - SHOW, FRONTENDS - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-FRONTENDS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-FRONTENDS.md deleted file mode 100644 index 959fcbd7bc85c..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-FRONTENDS.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -{ - "title": "SHOW-FRONTENDS", - "language": "zh-CN" -} ---- - - - -## SHOW-FRONTENDS - -### Name - -SHOW FRONTENDS - -## 描述 - - 该语句用于查看 FE 节点 - - 语法: - -```sql -SHOW FRONTENDS; -``` - -说明: -1. name 表示该 FE 节点在 bdbje 中的名称。 -2. Join 为 true 表示该节点曾经加入过集群。但不代表当前还在集群内(可能已失联) -3. Alive 表示节点是否存活。 -4. ReplayedJournalId 表示该节点当前已经回放的最大元数据日志id。 -5. LastHeartbeat 是最近一次心跳。 -6. IsHelper 表示该节点是否是 bdbje 中的 helper 节点。 -7. ErrMsg 用于显示心跳失败时的错误信息。 -8. CurrentConnected 表示是否是当前连接的FE节点 - -## 举例 - -### Keywords - - SHOW, FRONTENDS - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-FUNCTIONS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-FUNCTIONS.md deleted file mode 100644 index dd60c47115ad1..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-FUNCTIONS.md +++ /dev/null @@ -1,132 +0,0 @@ ---- -{ - "title": "SHOW-FUNCTIONS", - "language": "zh-CN" -} ---- - - - -## SHOW-FUNCTIONS - -### Name - -SHOW FUNCTIONS - -## 描述 - -查看数据库下所有的自定义(系统提供)的函数。如果用户指定了数据库,那么查看对应数据库的,否则直接查询当前会话所在数据库 - -需要对这个数据库拥有 `SHOW` 权限 - -语法 - -```sql -SHOW [FULL] [BUILTIN] FUNCTIONS [IN|FROM db] [LIKE 'function_pattern'] -``` - -Parameters - ->`full`:表示显示函数的详细信息 ->`builtin`:表示显示系统提供的函数 ->`db`: 要查询的数据库名字 ->`function_pattern`: 用来过滤函数名称的参数 - -语法 - -```sql -SHOW GLOBAL [FULL] FUNCTIONS [LIKE 'function_pattern'] -``` - -Parameters - ->`global`:表示要展示的是全局函数 ->`full`:表示显示函数的详细信息 ->`function_pattern`: 用来过滤函数名称的参数 - -**注意: "global"关键字在v2.0版本及以后才可用** - -## 举例 - -```sql -mysql> show full functions in testDb\G -*************************** 1. row *************************** - Signature: my_add(INT,INT) - Return Type: INT - Function Type: Scalar -Intermediate Type: NULL - Properties: {"symbol":"_ZN9doris_udf6AddUdfEPNS_15FunctionContextERKNS_6IntValES4_","object_file":"http://host:port/libudfsample.so","md5":"cfe7a362d10f3aaf6c49974ee0f1f878"} -*************************** 2. row *************************** - Signature: my_count(BIGINT) - Return Type: BIGINT - Function Type: Aggregate -Intermediate Type: NULL - Properties: {"object_file":"http://host:port/libudasample.so","finalize_fn":"_ZN9doris_udf13CountFinalizeEPNS_15FunctionContextERKNS_9BigIntValE","init_fn":"_ZN9doris_udf9CountInitEPNS_15FunctionContextEPNS_9BigIntValE","merge_fn":"_ZN9doris_udf10CountMergeEPNS_15FunctionContextERKNS_9BigIntValEPS2_","md5":"37d185f80f95569e2676da3d5b5b9d2f","update_fn":"_ZN9doris_udf11CountUpdateEPNS_15FunctionContextERKNS_6IntValEPNS_9BigIntValE"} -*************************** 3. row *************************** - Signature: id_masking(BIGINT) - Return Type: VARCHAR - Function Type: Alias -Intermediate Type: NULL - Properties: {"parameter":"id","origin_function":"concat(left(`id`, 3), `****`, right(`id`, 4))"} - -3 rows in set (0.00 sec) -mysql> show builtin functions in testDb like 'year%'; -+---------------+ -| Function Name | -+---------------+ -| year | -| years_add | -| years_diff | -| years_sub | -+---------------+ -2 rows in set (0.00 sec) - -mysql> show global full functions\G; -*************************** 1. row *************************** - Signature: decimal(ALL, INT, INT) - Return Type: VARCHAR - Function Type: Alias -Intermediate Type: NULL - Properties: {"parameter":"col, precision, scale","origin_function":"CAST(`col` AS decimal(`precision`, `scale`))"} -*************************** 2. row *************************** - Signature: id_masking(BIGINT) - Return Type: VARCHAR - Function Type: Alias -Intermediate Type: NULL - Properties: {"parameter":"id","origin_function":"concat(left(`id`, 3), `****`, right(`id`, 4))"} -2 rows in set (0.00 sec) - -mysql> show global functions ; -+---------------+ -| Function Name | -+---------------+ -| decimal | -| id_masking | -+---------------+ -2 rows in set (0.00 sec) - -``` - -### Keywords - - SHOW, FUNCTIONS - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-GRANTS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-GRANTS.md deleted file mode 100644 index 89ea1b8b34206..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-GRANTS.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -{ - "title": "SHOW-GRANTS", - "language": "zh-CN" -} ---- - - - -## SHOW-GRANTS - -### Name - -SHOW GRANTS - -## 描述 - - 该语句用于查看用户权限。 - -语法: - -```sql -SHOW [ALL] GRANTS [FOR user_identity]; -``` - -说明: - -1. SHOW ALL GRANTS 可以查看所有用户的权限。 -2. 如果指定 user_identity,则查看该指定用户的权限。且该 user_identity 必须为通过 CREATE USER 命令创建的。 -3. 如果不指定 user_identity,则查看当前用户的权限。 - -## 举例 - -1. 查看所有用户权限信息 - - ```sql - SHOW ALL GRANTS; - ``` - -2. 查看指定 user 的权限 - - ```sql - SHOW GRANTS FOR jack@'%'; - ``` - -3. 查看当前用户的权限 - - ```sql - SHOW GRANTS; - ``` - -### Keywords - - SHOW, GRANTS - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-INDEX.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-INDEX.md deleted file mode 100644 index 7afd6ebc04d5a..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-INDEX.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -{ - "title": "SHOW-INDEX", - "language": "zh-CN" -} ---- - - - -## SHOW-INDEX - -### Name - -SHOW INDEX - -## 描述 - - 该语句用于展示一个表中索引的相关信息,目前只支持bitmap 索引 - -语法: - -```SQL -SHOW INDEX[ES] FROM [db_name.]table_name [FROM database]; -或者 -SHOW KEY[S] FROM [db_name.]table_name [FROM database]; -``` - -## 举例 - - 1. 展示指定 table_name 的下索引 - - ```SQL - SHOW INDEX FROM example_db.table_name; - ``` - -### Keywords - - SHOW, INDEX - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-LAST-INSERT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-LAST-INSERT.md deleted file mode 100644 index ffbc90f6ffee8..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-LAST-INSERT.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -{ - "title": "SHOW-LAST-INSERT", - "language": "zh-CN" -} ---- - - - -## SHOW-LAST-INSERT - -### Name - -SHOW LAST INSERT - -## 描述 - -该语法用于查看在当前session连接中,最近一次 insert 操作的结果 - -语法: - -```sql -SHOW LAST INSERT -``` - -返回结果示例: - -``` - TransactionId: 64067 - Label: insert_ba8f33aea9544866-8ed77e2844d0cc9b - Database: default_cluster:db1 - Table: t1 -TransactionStatus: VISIBLE - LoadedRows: 2 - FilteredRows: 0 -``` - -说明: - -* TransactionId:事务id -* Label:insert任务对应的 label -* Database:insert对应的数据库 -* Table:insert对应的表 -* TransactionStatus:事务状态 - * PREPARE:准备阶段 - * PRECOMMITTED:预提交阶段 - * COMMITTED:事务成功,但数据不可见 - * VISIBLE:事务成功且数据可见 - * ABORTED:事务失败 -* LoadedRows:导入的行数 -* FilteredRows:被过滤的行数 - -## 举例 - -### Keywords - - SHOW, LAST, INSERT - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-LOAD-PROFILE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-LOAD-PROFILE.md deleted file mode 100644 index ea96de0061de6..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-LOAD-PROFILE.md +++ /dev/null @@ -1,234 +0,0 @@ ---- -{ - "title": "SHOW-LOAD-PROFILE", - "language": "zh-CN" -} ---- - - - -## SHOW-LOAD-PROFILE - -### Name - -SHOW LOAD PROFILE - -:::caution -自 2.1.1 起,此语法被弃用。 -::: - -## 描述 - -该语句是用来查看导入操作的 Profile 信息,该功能需要用户打开 Profile 设置,0.15 之前版本执行下面的设置: - -```sql -SET is_report_success=true; -``` - -0.15 及之后的版本执行下面的设置: - -```sql -SET [GLOBAL] enable_profile=true; -``` - -语法: - -```sql -show load profile "/"; - -show load profile "/[queryId]" - -show load profile "/[queryId]/[TaskId]" - -show load profile "/[queryId]/[TaskId]/[FragmentId]/" - -show load profile "/[queryId]/[TaskId]/[FragmentId]/[InstanceId]" -``` - -这个命令会列出当前保存的所有导入 Profile。每行对应一个导入。其中 QueryId 列为导入作业的 ID。这个 ID 也可以通过 SHOW LOAD 语句查看拿到。我们可以选择我们想看的 Profile 对应的 QueryId,查看具体情况 - -## 举例 - -**1. 列出所有的 Load Profile** - -```sql -mysql> show load profile "/"\G -*************************** 1. row *************************** - JobId: 20010 - QueryId: 980014623046410a-af5d36f23381017f - User: root - DefaultDb: default_cluster:test - SQL: LOAD LABEL xxx - QueryType: Load - StartTime: 2023-03-07 19:48:24 - EndTime: 2023-03-07 19:50:45 - TotalTime: 2m21s - QueryState: N/A - TraceId: - AnalysisTime: NULL - PlanTime: NULL - ScheduleTime: NULL - FetchResultTime: NULL - WriteResultTime: NULL -WaitAndFetchResultTime: NULL -*************************** 2. row *************************** - JobId: N/A - QueryId: 7cc2d0282a7a4391-8dd75030185134d8 - User: root - DefaultDb: default_cluster:test - SQL: insert into xxx - QueryType: Load - StartTime: 2023-03-07 19:49:15 - EndTime: 2023-03-07 19:49:15 - TotalTime: 102ms - QueryState: OK - TraceId: - AnalysisTime: 825.277us - PlanTime: 4.126ms - ScheduleTime: N/A - FetchResultTime: 0ns - WriteResultTime: 0ns -WaitAndFetchResultTime: N/A -``` - -**2. 查看有导入作业的子任务概况:** - -```sql -mysql> show load profile "/980014623046410a-af5d36f23381017f"; -+-----------------------------------+------------+ -| TaskId | ActiveTime | -+-----------------------------------+------------+ -| 980014623046410a-af5d36f23381017f | 3m14s | -+-----------------------------------+------------+ - ``` -**3. 查看子任务的执行树:** - -```sql -show load profile "/980014623046410a-af5d36f23381017f/980014623046410a-af5d36f23381017f"; - - ┌───────────────────────┐ - │[-1: OlapTableSink] │ - │Fragment: 0 │ - │MaxActiveTime: 86.541ms│ - └───────────────────────┘ - │ - │ - ┌───────────────────┐ - │[1: VEXCHANGE_NODE]│ - │Fragment: 0 │ - └───────────────────┘ - ┌─────────────────────────┴───────┐ - │ │ - ┌─────────────┐ ┌───────────────────────┐ - │[MemoryUsage]│ │[1: VDataStreamSender] │ - │Fragment: 0 │ │Fragment: 1 │ - └─────────────┘ │MaxActiveTime: 34.882ms│ - └───────────────────────┘ - │ - │ - ┌───────────────────────────┐ - │[0: VNewOlapScanNode(tbl1)]│ - │Fragment: 1 │ - └───────────────────────────┘ - ┌─────────────────┴───────┐ - │ │ - ┌─────────────┐ ┌───────────┐ - │[MemoryUsage]│ │[VScanner] │ - │Fragment: 1 │ │Fragment: 1│ - └─────────────┘ └───────────┘ - ┌───────┴─────────┐ - │ │ - ┌─────────────────┐ ┌─────────────┐ - │[SegmentIterator]│ │[MemoryUsage]│ - │Fragment: 1 │ │Fragment: 1 │ - └─────────────────┘ └─────────────┘ - -``` - -这一层会显示子任务的查询树,其中标注了 Fragment id。 - -**4. 查看指定 Fragment 的 Instance 概况** - -```sql -mysql> show load profile "/980014623046410a-af5d36f23381017f/980014623046410a-af5d36f23381017f/1"; -+-----------------------------------+------------------+------------+ -| Instances | Host | ActiveTime | -+-----------------------------------+------------------+------------+ -| 980014623046410a-88e260f0c43031f2 | 10.81.85.89:9067 | 3m7s | -| 980014623046410a-88e260f0c43031f3 | 10.81.85.89:9067 | 3m6s | -| 980014623046410a-88e260f0c43031f4 | 10.81.85.89:9067 | 3m10s | -| 980014623046410a-88e260f0c43031f5 | 10.81.85.89:9067 | 3m14s | -+-----------------------------------+------------------+------------+ -``` - -**5. 继续查看某一个具体的 Instance 上各个算子的详细 Profile** - -```sql -mysql> show load profile "/980014623046410a-af5d36f23381017f/980014623046410a-af5d36f23381017f/1/980014623046410a-88e260f0c43031f5"\G - -*************************** 1. row *************************** - -Instance: - - ┌-----------------------------------------┐ - │[-1: OlapTableSink] │ - │(Active: 2m17s, non-child: 70.91) │ - │ - Counters: │ - │ - CloseWaitTime: 1m53s │ - │ - ConvertBatchTime: 0ns │ - │ - MaxAddBatchExecTime: 1m46s │ - │ - NonBlockingSendTime: 3m11s │ - │ - NumberBatchAdded: 782 │ - │ - NumberNodeChannels: 1 │ - │ - OpenTime: 743.822us │ - │ - RowsFiltered: 0 │ - │ - RowsRead: 1.599729M (1599729) │ - │ - RowsReturned: 1.599729M (1599729)│ - │ - SendDataTime: 11s761ms │ - │ - TotalAddBatchExecTime: 1m46s │ - │ - ValidateDataTime: 9s802ms │ - └-----------------------------------------┘ - │ -┌-----------------------------------------------------┐ -│[0: BROKER_SCAN_NODE] │ -│(Active: 56s537ms, non-child: 29.06) │ -│ - Counters: │ -│ - BytesDecompressed: 0.00 │ -│ - BytesRead: 5.77 GB │ -│ - DecompressTime: 0ns │ -│ - FileReadTime: 34s263ms │ -│ - MaterializeTupleTime(*): 45s54ms │ -│ - NumDiskAccess: 0 │ -│ - PeakMemoryUsage: 33.03 MB │ -│ - RowsRead: 1.599729M (1599729) │ -│ - RowsReturned: 1.599729M (1599729) │ -│ - RowsReturnedRate: 28.295K sec │ -│ - TotalRawReadTime(*): 1m20s │ -│ - TotalReadThroughput: 30.39858627319336 MB/sec│ -│ - WaitScannerTime: 56s528ms │ -└-----------------------------------------------------┘ -``` - -### Keywords - - SHOW, LOAD, PROFILE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-LOAD-WARNINGS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-LOAD-WARNINGS.md deleted file mode 100644 index 2a09cd70c5436..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-LOAD-WARNINGS.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -{ - "title": "SHOW-LOAD-WARNINGS", - "language": "zh-CN" -} ---- - - - -## SHOW-LOAD-WARNINGS - -### Name - -SHOW LOAD WARNINGS - -## 描述 - -如果导入任务失败且错误信息为 `ETL_QUALITY_UNSATISFIED`,则说明存在导入质量问题, 如果想看到这些有质量问题的导入任务,该语句就是完成这个操作的。 - -语法: - -```sql -SHOW LOAD WARNINGS -[FROM db_name] -[ - WHERE - [LABEL [ = "your_label" ]] - [LOAD_JOB_ID = ["job id"]] -] -``` - -1. 如果不指定 db_name,使用当前默认db -2. 如果使用 LABEL = ,则精确匹配指定的 label -3. 如果指定了 LOAD_JOB_ID,则精确匹配指定的 JOB ID - -## 举例 - -1. 展示指定 db 的导入任务中存在质量问题的数据,指定 label 为 "load_demo_20210112" - - ```sql - SHOW LOAD WARNINGS FROM demo WHERE LABEL = "load_demo_20210112" - ``` - -### Keywords - - SHOW, LOAD, WARNINGS - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-LOAD.md deleted file mode 100644 index a5d3d96390226..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-LOAD.md +++ /dev/null @@ -1,117 +0,0 @@ ---- -{ - "title": "SHOW-LOAD", - "language": "zh-CN" -} ---- - - - -## SHOW-LOAD - -### Name - -SHOW LOAD - -## 描述 - -该语句用于展示指定的导入任务的执行情况 - -语法: - -```sql -SHOW LOAD -[FROM db_name] -[ - WHERE - [LABEL [ = "your_label" | LIKE "label_matcher"]] - [STATE = ["PENDING"|"ETL"|"LOADING"|"FINISHED"|"CANCELLED"|]] -] -[ORDER BY ...] -[LIMIT limit][OFFSET offset]; -``` - -说明: - -1) 如果不指定 db_name,使用当前默认db - -2) 如果使用 LABEL LIKE,则会匹配导入任务的 label 包含 label_matcher 的导入任务 - -3) 如果使用 LABEL = ,则精确匹配指定的 label - -4) 如果指定了 STATE,则匹配 LOAD 状态 - -5) 可以使用 ORDER BY 对任意列组合进行排序 - -6) 如果指定了 LIMIT,则显示 limit 条匹配记录。否则全部显示 - -7) 如果指定了 OFFSET,则从偏移量offset开始显示查询结果。默认情况下偏移量为0。 - -8) 如果是使用 broker/mini load,则 URL 列中的连接可以使用以下命令查看: - - ```sql - SHOW LOAD WARNINGS ON 'url' - ``` - -## 举例 - -1. 展示默认 db 的所有导入任务 - - ```sql - SHOW LOAD; - ``` - -2. 展示指定 db 的导入任务,label 中包含字符串 "2014_01_02",展示最老的10个 - - ```sql - SHOW LOAD FROM example_db WHERE LABEL LIKE "2014_01_02" LIMIT 10; - ``` - -3. 展示指定 db 的导入任务,指定 label 为 "load_example_db_20140102" 并按 LoadStartTime 降序排序 - - ```sql - SHOW LOAD FROM example_db WHERE LABEL = "load_example_db_20140102" ORDER BY LoadStartTime DESC; - ``` - -4. 展示指定 db 的导入任务,指定 label 为 "load_example_db_20140102" ,state 为 "loading", 并按 LoadStartTime 降序排序 - - ```sql - SHOW LOAD FROM example_db WHERE LABEL = "load_example_db_20140102" AND STATE = "loading" ORDER BY LoadStartTime DESC; - ``` - -5. 展示指定 db 的导入任务 并按 LoadStartTime 降序排序,并从偏移量5开始显示10条查询结果 - - ```sql - SHOW LOAD FROM example_db ORDER BY LoadStartTime DESC limit 5,10; - SHOW LOAD FROM example_db ORDER BY LoadStartTime DESC limit 10 offset 5; - ``` - -6. 小批量导入是查看导入状态的命令 - - ``` - curl --location-trusted -u {user}:{passwd} http://{hostname}:{port}/api/{database}/_load_info?label={labelname} - ``` - -### Keywords - - SHOW, LOAD - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-OPEN-TABLES.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-OPEN-TABLES.md deleted file mode 100644 index a517cfe05cd12..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-OPEN-TABLES.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -{ - "title": "SHOW-OPEN-TABLES", - "language": "zh-CN" -} ---- - - - -## SHOW-OPEN-TABLES - -### Name - -SHOW TABLES - -## 描述 - -该语句用于展示当前 db 下所有的 table - -语法: - -```SQL -SHOW TABLES -``` - -## 举例 - -### Keywords - - SHOW, OPEN, TABLES - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PARTITIONS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PARTITIONS.md deleted file mode 100644 index 7d8e7384c7074..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PARTITIONS.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -{ - "title": "SHOW-PARTITIONS", - "language": "zh-CN" -} ---- - - - -## SHOW-PARTITIONS - -### Name - -SHOW PARTITIONS - -## 描述 - -该语句用于展示分区信息。支持 Internal catalog 和 Hive Catalog - -语法: - -```SQL - SHOW [TEMPORARY] PARTITIONS FROM [db_name.]table_name [WHERE] [ORDER BY] [LIMIT]; -``` - -说明: - -对于 Internal catalog: -1. 支持 PartitionId,PartitionName,State,Buckets,ReplicationNum,LastConsistencyCheckTime 等列的过滤 -2. TEMPORARY 指定列出临时分区 - -对于 Hive Catalog: -支持返回所有分区,包括多级分区 - -## 举例 - -1. 展示指定 db 下指定表的所有非临时分区信息 - - ```SQL - SHOW PARTITIONS FROM example_db.table_name; - ``` - -2. 展示指定 db 下指定表的所有临时分区信 - - ```SQL - SHOW TEMPORARY PARTITIONS FROM example_db.table_name; - ``` - -3. 展示指定 db 下指定表的指定非临时分区的信息 - - ```SQL - SHOW PARTITIONS FROM example_db.table_name WHERE PartitionName = "p1"; - ``` - -4. 展示指定 db 下指定表的最新非临时分区的信息 - - ```SQL - SHOW PARTITIONS FROM example_db.table_name ORDER BY PartitionId DESC LIMIT 1; - ``` - -### Keywords - - SHOW, PARTITIONS - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PLUGINS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PLUGINS.md deleted file mode 100644 index 819442f45a540..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PLUGINS.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -{ - "title": "SHOW-PLUGINS", - "language": "zh-CN" -} ---- - - - -## SHOW-PLUGINS - -### Name - -SHOW PLUGINS - -## 描述 - -该语句用于展示已安装的插件 - -语法: - -```SQL -SHOW PLUGINS -``` - -该命令会展示所有用户安装的和系统内置的插件 - -## 举例 - -1. 展示已安装的插件: - - ```SQL - SHOW PLUGINS; - ``` - -### Keywords - - SHOW, PLUGINS - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-POLICY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-POLICY.md deleted file mode 100644 index 0f2c486dbda6e..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-POLICY.md +++ /dev/null @@ -1,113 +0,0 @@ ---- -{ - "title": "SHOW-POLICY", - "language": "zh-CN" -} ---- - - - -## SHOW-POLICY - -### Name - -SHOW ROW POLICY - -## 描述 - -查看当前 DB 下的行安全策略 - -语法: - -```sql -SHOW ROW POLICY [FOR user| ROLE role] -``` - -## 举例 - -1. 查看所有安全策略。 - - ```sql - mysql> SHOW ROW POLICY; - +-------------------+----------------------+-----------+------+-------------+-------------------+------+-------------------------------------------------------------------------------------------------------------------------------------------+ - | PolicyName | DbName | TableName | Type | FilterType | WherePredicate | User | OriginStmt | - +-------------------+----------------------+-----------+------+-------------+-------------------+------+-------------------------------------------------------------------------------------------------------------------------------------------+ - | test_row_policy_1 | default_cluster:test | table1 | ROW | RESTRICTIVE | `id` IN (1, 2) | root | /* ApplicationName=DataGrip 2021.3.4 */ CREATE ROW POLICY test_row_policy_1 ON test.table1 AS RESTRICTIVE TO root USING (id in (1, 2)); - | - | test_row_policy_2 | default_cluster:test | table1 | ROW | RESTRICTIVE | `col1` = 'col1_1' | root | /* ApplicationName=DataGrip 2021.3.4 */ CREATE ROW POLICY test_row_policy_2 ON test.table1 AS RESTRICTIVE TO root USING (col1='col1_1'); - | - +-------------------+----------------------+-----------+------+-------------+-------------------+------+-------------------------------------------------------------------------------------------------------------------------------------------+ - 2 rows in set (0.00 sec) - ``` - -2. 指定用户名查询 - - ```sql - mysql> SHOW ROW POLICY FOR test; - +-------------------+----------------------+-----------+------+------------+-------------------+----------------------+------------------------------------------------------------------------------------------------------------------------------------------+ - | PolicyName | DbName | TableName | Type | FilterType | WherePredicate | User | OriginStmt | - +-------------------+----------------------+-----------+------+------------+-------------------+----------------------+------------------------------------------------------------------------------------------------------------------------------------------+ - | test_row_policy_3 | default_cluster:test | table1 | ROW | PERMISSIVE | `col1` = 'col1_2' | default_cluster:test | /* ApplicationName=DataGrip 2021.3.4 */ CREATE ROW POLICY test_row_policy_3 ON test.table1 AS PERMISSIVE TO test USING (col1='col1_2'); - | - +-------------------+----------------------+-----------+------+------------+-------------------+----------------------+------------------------------------------------------------------------------------------------------------------------------------------+ - 1 row in set (0.01 sec) - ``` - -3. 指定角色名查询 - - ```sql - mysql> SHOW ROW POLICY for role role1; - +------------+--------+-----------+------+-------------+----------------+------+-------+----------------------------------------------------------------------------------+ - | PolicyName | DbName | TableName | Type | FilterType | WherePredicate | User | Role | OriginStmt | - +------------+--------+-----------+------+-------------+----------------+------+-------+----------------------------------------------------------------------------------+ - | zdtest1 | zd | user | ROW | RESTRICTIVE | `user_id` = 1 | NULL | role1 | create row policy zdtest1 on user as restrictive to role role1 using (user_id=1) | - +------------+--------+-----------+------+-------------+----------------+------+-------+----------------------------------------------------------------------------------+ - 1 row in set (0.01 sec) - ``` - -4. 展示数据迁移策略 - ```sql - mysql> SHOW STORAGE POLICY; - +---------------------+---------+-----------------------+---------------------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | PolicyName | Type | StorageResource | CooldownDatetime | CooldownTtl | properties | - +---------------------+---------+-----------------------+---------------------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | showPolicy_1_policy | STORAGE | showPolicy_1_resource | 2022-06-08 00:00:00 | -1 | { - "type": "s3", - "s3.endpoint": "bj.s3.comaaaa", - "s3.region": "bj", - "s3.access_key": "bbba", - "s3.secret_key": "******", - "s3.root.path": "path/to/rootaaaa", - "s3.bucket": "test-bucket", - "s3.connection.request.timeout": "3000" - "3.connection.maximum": "50", - "s3.connection.timeout": "1000", - } | - +---------------------+---------+-----------------------+---------------------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - 1 row in set (0.00 sec) - ``` - - -### Keywords - - SHOW, POLICY - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PRIVILEGES.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PRIVILEGES.md deleted file mode 100644 index c9348437bda08..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PRIVILEGES.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "Show Privileges", - "language": "zh-CN" -} ---- - - - -## SHOW-PRIVILEGES - -### Name - -SHOW PRIVILEGES - -## 描述 - -该语句用于展示所有权限项。 - -语法: - -```SQL -SHOW PRIVILEGES -``` - -## 举例 - -1. 查看所有权限项 - - ```SQL - SHOW PRIVILEGES - ``` - -### Keywords - - SHOW, PRIVILEGES - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PROC.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PROC.md deleted file mode 100644 index 53a6667631db4..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PROC.md +++ /dev/null @@ -1,278 +0,0 @@ ---- -{ - "title": "SHOW-PROC", - "language": "zh-CN" -} ---- - - - -## SHOW-PROC - -### Name - -SHOW PROC - -## 描述 - -Proc 系统是 Doris 的一个比较有特色的功能。使用过 Linux 的同学可能比较了解这个概念。在 Linux 系统中,proc 是一个虚拟的文件系统,通常挂载在 /proc 目录下。用户可以通过这个文件系统来查看系统内部的数据结构。比如可以通过 /proc/pid 查看指定 pid 进程的详细情况。 - -和 Linux 中的 proc 系统类似,Doris 中的 proc 系统也被组织成一个类似目录的结构,根据用户指定的“目录路径(proc 路径)”,来查看不同的系统信息。 - -proc 系统被设计为主要面向系统管理人员,方便其查看系统内部的一些运行状态。如表的tablet状态、集群均衡状态、各种作业的状态等等。是一个非常实用的功能 - -Doris 中有两种方式可以查看 proc 系统。 - -1. 通过 Doris 提供的 WEB UI 界面查看,访问地址:`http://FE_IP:FE_HTTP_PORT` -2. 另外一种方式是通过命令 - -通过 ` SHOW PROC "/";` 可看到 Doris PROC支持的所有命令 - -通过 MySQL 客户端连接 Doris 后,可以执行 SHOW PROC 语句查看指定 proc 目录的信息。proc 目录是以 "/" 开头的绝对路径。 - -show proc 语句的结果以二维表的形式展现。而通常结果表的第一列的值为 proc 的下一级子目录。 - -```sql -mysql> show proc "/"; -+---------------------------+ -| name | -+---------------------------+ -| auth | -| backends | -| bdbje | -| brokers | -| catalogs | -| cluster_balance | -| cluster_health | -| colocation_group | -| current_backend_instances | -| current_queries | -| current_query_stmts | -| dbs | -| diagnose | -| frontends | -| jobs | -| load_error_hub | -| monitor | -| resources | -| routine_loads | -| statistic | -| stream_loads | -| tasks | -| transactions | -| trash | -+---------------------------+ -23 rows in set (0.00 sec) -``` - -说明: - -1. auth:用户名称及对应的权限信息 -2. backends :显示集群中 BE 的节点列表 , 等同于 [SHOW BACKENDS](./SHOW-BACKENDS.md) -3. bdbje:查看 bdbje 数据库列表,需要修改 `fe.conf` 文件增加 `enable_bdbje_debug_mode=true` , 然后通过 `sh start_fe.sh --daemon` 启动 `FE` 即可进入 `debug` 模式。 进入 `debug` 模式之后,仅会启动 `http server` 和 `MySQLServer` 并打开 `BDBJE` 实例,但不会进入任何元数据的加载及后续其他启动流程, -4. brokers : 查看集群 Broker 节点信息,等同于 [SHOW BROKER](./SHOW-BROKER.md) -5. catalogs : 查看当前已创建的数据目录,等同于 [SHOW CATALOGS](./SHOW-CATALOGS.md) -6. cluster_balance : 查看集群均衡情况,具体参照 [数据副本管理](../../../admin-manual/maint-monitor/tablet-repair-and-balance.md) -7. cluster_health : 通过 SHOW PROC '/cluster_health/tablet_health'; 命令可以查看整个集群的副本状态。 -8. colocation_group : 该命令可以查看集群内已存在的 Group 信息, 具体可以查看 [Colocation Join](../../../query-acceleration/join-optimization/colocation-join.md) 章节 -9. current_backend_instances :显示当前正在执行作业的be节点列表 -10. current_queries : 查看正在执行的查询列表,当前正在运行的SQL语句。 -11. current_query_stmts : 返回当前正在执行的 query。 -12. dbs : 主要用于查看 Doris 集群中各个数据库以及其中的表的元数据信息。这些信息包括表结构、分区、物化视图、数据分片和副本等等。通过这个目录和其子目录,可以清楚的展示集群中的表元数据情况,以及定位一些如数据倾斜、副本故障等问题 -13. diagnose : 报告和诊断集群中的常见管控问题,主要包括副本均衡和迁移、事务异常等 -14. frontends :显示集群中所有的 FE 节点信息,包括IP地址、角色、状态、是否是master等,等同于 [SHOW FRONTENDS](./SHOW-FRONTENDS.md) -15. jobs :各类任务的统计信息,可查看指定数据库的 Job 的统计信息,如果 `dbId` = -1, 则返回所有库的汇总信息 -16. load_error_hub :Doris 支持将 load 作业产生的错误信息集中存储到一个 error hub 中。然后直接通过 SHOW LOAD WARNINGS; 语句查看错误信息。这里展示的就是 error hub 的配置信息。 -17. monitor : 显示的是 FE JVM 的资源使用情况 -18. resources : 查看系统资源,普通账户只能看到自己有 USAGE_PRIV 使用权限的资源。只有root和admin账户可以看到所有的资源。等同于 [SHOW RESOURCES](./SHOW-RESOURCES.md) -19. routine_loads : 显示所有的 routine load 作业信息,包括作业名称、状态等 -20. statistics:主要用于汇总查看 Doris 集群中数据库、表、分区、分片、副本的数量。以及不健康副本的数量。这个信息有助于我们总体把控集群元信息的规模。帮助我们从整体视角查看集群分片情况,能够快速查看集群分片的健康情况。从而进一步定位有问题的数据分片。 -21. stream_loads : 返回当前正在执行的stream load 任务。 -22. tasks : 显示现在各种作业的任务总量,及失败的数量。 -23. transactions :用于查看指定 transaction id 的事务详情,等同于 [SHOW TRANSACTION](./SHOW-TRANSACTION.md) -24. trash :该语句用于查看 backend 内的垃圾数据占用空间。 等同于 [SHOW TRASH](./SHOW-TRASH.md) - -## 举例 - -1. 如 "/dbs" 展示所有数据库,而 "/dbs/10002" 展示 id 为 10002 的数据库下的所有表 - - ```sql - mysql> show proc "/dbs/10002"; - +---------+----------------------+----------+---------------------+--------------+--------+------+--------------------------+--------------+ - | TableId | TableName | IndexNum | PartitionColumnName | PartitionNum | State | Type | LastConsistencyCheckTime | ReplicaCount | - +---------+----------------------+----------+---------------------+--------------+--------+------+--------------------------+--------------+ - | 10065 | dwd_product_live | 1 | dt | 9 | NORMAL | OLAP | NULL | 18 | - | 10109 | ODS_MR_BILL_COSTS_DO | 1 | NULL | 1 | NORMAL | OLAP | NULL | 1 | - | 10119 | test | 1 | NULL | 1 | NORMAL | OLAP | NULL | 1 | - | 10124 | test_parquet_import | 1 | NULL | 1 | NORMAL | OLAP | NULL | 1 | - +---------+----------------------+----------+---------------------+--------------+--------+------+--------------------------+--------------+ - 4 rows in set (0.00 sec) - ``` - -2. 展示集群中所有库表个数相关的信息。 - - ```sql - mysql> show proc '/statistic'; - +-------+----------------------+----------+--------------+----------+-----------+------------+ - | DbId | DbName | TableNum | PartitionNum | IndexNum | TabletNum | ReplicaNum | - +-------+----------------------+----------+--------------+----------+-----------+------------+ - | 10002 | default_cluster:test | 4 | 12 | 12 | 21 | 21 | - | Total | 1 | 4 | 12 | 12 | 21 | 21 | - +-------+----------------------+----------+--------------+----------+-----------+------------+ - 2 rows in set (0.00 sec) - ``` - -3. 以下命令可以查看集群内已存在的 Group 信息。 - - ```sql - SHOW PROC '/colocation_group'; - - +-------------+--------------+--------------+------------+----------------+----------+----------+ - | GroupId | GroupName | TableIds | BucketsNum | ReplicationNum | DistCols | IsStable | - +-------------+--------------+--------------+------------+----------------+----------+----------+ - | 10005.10008 | 10005_group1 | 10007, 10040 | 10 | 3 | int(11) | true | - +-------------+--------------+--------------+------------+----------------+----------+----------+ - ``` - - - GroupId: 一个 Group 的全集群唯一标识,前半部分为 db id,后半部分为 group id。 - - GroupName: Group 的全名。 - - TabletIds: 该 Group 包含的 Table 的 id 列表。 - - BucketsNum: 分桶数。 - - ReplicationNum: 副本数。 - - DistCols: Distribution columns,即分桶列类型。 - - IsStable: 该 Group 是否稳定(稳定的定义,见 `Colocation 副本均衡和修复` 一节)。 - -4. 通过以下命令可以进一步查看一个 Group 的数据分布情况: - - ```sql - SHOW PROC '/colocation_group/10005.10008'; - - +-------------+---------------------+ - | BucketIndex | BackendIds | - +-------------+---------------------+ - | 0 | 10004, 10002, 10001 | - | 1 | 10003, 10002, 10004 | - | 2 | 10002, 10004, 10001 | - | 3 | 10003, 10002, 10004 | - | 4 | 10002, 10004, 10003 | - | 5 | 10003, 10002, 10001 | - | 6 | 10003, 10004, 10001 | - | 7 | 10003, 10004, 10002 | - +-------------+---------------------+ - ``` - - - BucketIndex: 分桶序列的下标。 - - BackendIds: 分桶中数据分片所在的 BE 节点 id 列表。 - -5. 显示现在各种作业的任务总量,及失败的数量。 - - ```sql - mysql> show proc '/tasks'; - +-------------------------+-----------+----------+ - | TaskType | FailedNum | TotalNum | - +-------------------------+-----------+----------+ - | CREATE | 0 | 0 | - | DROP | 0 | 0 | - | PUSH | 0 | 0 | - | CLONE | 0 | 0 | - | STORAGE_MEDIUM_MIGRATE | 0 | 0 | - | ROLLUP | 0 | 0 | - | SCHEMA_CHANGE | 0 | 0 | - | CANCEL_DELETE | 0 | 0 | - | MAKE_SNAPSHOT | 0 | 0 | - | RELEASE_SNAPSHOT | 0 | 0 | - | CHECK_CONSISTENCY | 0 | 0 | - | UPLOAD | 0 | 0 | - | DOWNLOAD | 0 | 0 | - | CLEAR_REMOTE_FILE | 0 | 0 | - | MOVE | 0 | 0 | - | REALTIME_PUSH | 0 | 0 | - | PUBLISH_VERSION | 0 | 0 | - | CLEAR_ALTER_TASK | 0 | 0 | - | CLEAR_TRANSACTION_TASK | 0 | 0 | - | RECOVER_TABLET | 0 | 0 | - | STREAM_LOAD | 0 | 0 | - | UPDATE_TABLET_META_INFO | 0 | 0 | - | ALTER | 0 | 0 | - | INSTALL_PLUGIN | 0 | 0 | - | UNINSTALL_PLUGIN | 0 | 0 | - | Total | 0 | 0 | - +-------------------------+-----------+----------+ - 26 rows in set (0.01 sec) - ``` - -6. 显示整个集群的副本状态。 - - ```sql - mysql> show proc '/cluster_health/tablet_health'; - +----------+---------------------------+-----------+------------+-------------------+----------------------+----------------------+--------------+----------------------------+-------------------------+-------------------+---------------------+----------------------+----------------------+------------------+-----------------------------+-----------------+-------------+------------+ - | DbId | DbName | TabletNum | HealthyNum | ReplicaMissingNum | VersionIncompleteNum | ReplicaRelocatingNum | RedundantNum | ReplicaMissingInClusterNum | ReplicaMissingForTagNum | ForceRedundantNum | ColocateMismatchNum | ColocateRedundantNum | NeedFurtherRepairNum | UnrecoverableNum | ReplicaCompactionTooSlowNum | InconsistentNum | OversizeNum | CloningNum | - +----------+---------------------------+-----------+------------+-------------------+----------------------+----------------------+--------------+----------------------------+-------------------------+-------------------+---------------------+----------------------+----------------------+------------------+-----------------------------+-----------------+-------------+------------+ - | 25852112 | default_cluster:bowen | 1920 | 1920 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | - | 25342914 | default_cluster:bw | 128 | 128 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | - | 2575532 | default_cluster:cps | 1440 | 1440 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 16 | 0 | - | 26150325 | default_cluster:db | 38374 | 38374 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 453 | 0 | - +----------+---------------------------+-----------+------------+-------------------+----------------------+----------------------+--------------+----------------------------+-------------------------+-------------------+---------------------+----------------------+----------------------+------------------+-----------------------------+-----------------+-------------+------------+ - 4 rows in set (0.01 sec) - ``` - - 查看某个数据库下面的副本状态, 如 DbId 为 25852112 的数据库。 - - ```sql - mysql> show proc '/cluster_health/tablet_health/25852112'; - ``` - -7. 报告和诊断集群管控问题 - - ``` - MySQL > show proc "/diagnose"; - +-----------------+----------+------------+ - | Item | ErrorNum | WarningNum | - +-----------------+----------+------------+ - | cluster_balance | 2 | 0 | - | Total | 2 | 0 | - +-----------------+----------+------------+ - - 2 rows in set - ``` - - 查看副本均衡迁移问题 - - ```sql - MySQL > show proc "/diagnose/cluster_balance"; - +-----------------------+--------+-------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+------------+ - | Item | Status | Content | Detail Cmd | Suggestion | - +-----------------------+--------+-------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+------------+ - | Tablet Health | ERROR | healthy tablet num 691 < total tablet num 1014 | show proc "/cluster_health/tablet_health"; | | - | BeLoad Balance | ERROR | backend load not balance for tag {"location" : "default"}, low load backends [], high load backends [10009] | show proc "/cluster_balance/cluster_load_stat/location_default/HDD" | | - | Disk Balance | OK | | | | - | Colocate Group Stable | OK | | | | - | History Tablet Sched | OK | | | | - +-----------------------+--------+-------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+------------+ - - 5 rows in set - ``` - -### Keywords - - SHOW, PROC - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PROCEDURE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PROCEDURE.md deleted file mode 100644 index 74ae4f8173572..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PROCEDURE.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -{ - "title": "SHOW-PROCEDURE", - "language": "zh-CN" -} ---- - - - -## SHOW-PROCEDURE - -## 描述 - -## 举例 - -### Keywords - - SHOW, PROCEDURE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PROCESSLIST.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PROCESSLIST.md deleted file mode 100644 index 3d86b10c622db..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PROCESSLIST.md +++ /dev/null @@ -1,91 +0,0 @@ ---- -{ - "title": "SHOW-PROCESSLIST", - "language": "zh-CN" -} ---- - - - -## SHOW-PROCESSLIST - -### Name - -SHOW PROCESSLIST - -## 描述 - -显示用户正在运行的线程,需要注意的是,除了 root 用户能看到所有正在运行的线程外,其他用户都只能看到自己正在运行的线程,看不到其它用户正在运行的线程 - -默认只限制当前连接的FE的连接列表,可以通过设置session变量```set show_all_fe_connection = true```来查看所有FE的连接 - -语法: - -```sql -SHOW [FULL] PROCESSLIST -``` - -说明: - -- CurrentConnected: 是否为当前连接。 -- Id: 就是这个线程的唯一标识,当我们发现这个线程有问题的时候,可以通过 kill 命令,加上这个Id值将这个线程杀掉。 -- User: 就是指启动这个线程的用户。 -- Host: 记录了发送请求的客户端的 IP 和 端口号。通过这些信息在排查问题的时候,我们可以定位到是哪个客户端的哪个进程发送的请求。 -- LoginTime: 建立连接的时间。 -- Catalog: 当前执行的命令是在哪一个数据目录上。 -- Db: 当前执行的命令是在哪一个数据库上。如果没有指定数据库,则该值为 NULL 。 -- Command: 是指此刻该线程正在执行的命令。 -- Time: 上一条命令提交到当前状态的时间,单位为秒。 -- State: 线程的状态,和 Command 对应。 -- QueryId: 当前查询语句的ID。 -- Info: 一般记录的是线程执行的语句。默认只显示前100个字符,也就是你看到的语句可能是截断了的,要看全部信息,需要使用 show full processlist。 - -常见的 Command 类型如下: - -- Query: 该线程正在执行一个语句 -- Sleep: 正在等待客户端向它发送执行语句 -- Quit: 该线程正在退出 -- Kill : 正在执行 kill 语句,杀死指定线程 - -其他类型可以参考 [MySQL 官网解释](https://dev.mysql.com/doc/refman/5.6/en/thread-commands.html) - -## 举例 - -1. 查看当前用户正在运行的线程 - ```SQL - SHOW PROCESSLIST - ``` - 返回结果 - ``` - MySQL [test]> show full processlist; - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - | CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - | Yes | 0 | root | 127.0.0.1:34650 | 2023-09-06 12:01:02 | internal | test | Query | 0 | OK | c84e397193a54fe7-bbe9bc219318b75e | select 1 | - | | 1 | root | 127.0.0.1:34776 | 2023-09-06 12:01:07 | internal | | Sleep | 29 | EOF | 886ffe2894314f50-8dd73a6ca06699e4 | show full processlist | - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - ``` - -### Keywords - - SHOW, PROCESSLIST - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PROPERTY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PROPERTY.md deleted file mode 100644 index ede3dc7f81c95..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PROPERTY.md +++ /dev/null @@ -1,120 +0,0 @@ ---- -{ - "title": "SHOW-PROPERTY", - "language": "zh-CN" -} ---- - - - -## SHOW-PROPERTY - -### Name - -SHOW PROPERTY - -## 描述 - -该语句用于查看用户的属性 - -语法: - -```sql -SHOW PROPERTY [FOR user] [LIKE key] -SHOW ALL PROPERTIES [LIKE key] -``` - -* `user` - - 查看指定用户的属性。 如果未指定,请检查当前用户的。 - -* `LIKE` - - 模糊匹配可以通过属性名来完成。 - -* `ALL` - - 查看所有用户的属性(从2.0.3版本开始支持) - -返回结果说明: - -```sql -mysql> show property like'%connection%'; -+----------------------+-------+ -| Key | Value | -+----------------------+-------+ -| max_user_connections | 100 | -+----------------------+-------+ -1 row in set (0.01 sec) -``` - -* `Key` - - 属性名. - -* `Value` - - 属性值. - - -```sql -mysql> show all properties like "%connection%"; -+-------------------+--------------------------------------+ -| User | Properties | -+-------------------+--------------------------------------+ -| root | {"max_user_connections": "100"} | -| admin | {"max_user_connections": "100"} | -| default_cluster:a | {"max_user_connections": "1000"} | -+-------------------+--------------------------------------+ -``` - -* `User` - - 用户名. - -* `Properties` - - 对应用户各个property的key:value. - -## 举例 - -1. 查看 jack 用户的属性 - - ```sql - SHOW PROPERTY FOR 'jack' - ``` - -2. 查看 jack 用户导入cluster相关属性 - - ```sql - SHOW PROPERTY FOR 'jack' LIKE '%load_cluster%' - ``` - -3. 查看所有用户导入cluster相关属性 - - ```sql - SHOW ALL PROPERTIES LIKE '%load_cluster%' - ``` - -### Keywords - - SHOW, PROPERTY, ALL - -### Best Practice diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-QUERY-PROFILE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-QUERY-PROFILE.md deleted file mode 100644 index 8c4b528f2b0a8..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-QUERY-PROFILE.md +++ /dev/null @@ -1,225 +0,0 @@ ---- -{ - "title": "SHOW-QUERY-PROFILE", - "language": "zh-CN" -} ---- - - - -## SHOW-QUERY-PROFILE - -### Name - -SHOW QUERY PROFILE - -:::caution -自 2.1.1 起,此语法被弃用。你仍然可以从 http://:/QueryProfile 上下载 profile 文件。 -::: - -## 描述 - -该语句是用来查看QUERY操作的树状Profile信息,该功能需要用户打开 Profile 设置,0.15 之前版本执行下面的设置: - -```sql -SET is_report_success=true; -``` - -0.15 及之后的版本执行下面的设置: - -```sql -SET [GLOBAL] enable_profile=true; -``` - -语法: - -```sql -show query profile "/"; -``` -这个命令会列出当前保存的所有query操作的 Profile 。 - -```sql -show query profile "/queryId"\G; -show query profile "/queryId/fragment_id/instance_id"; -``` -获取指定query id树状profile信息,返回profile 简易树形图。指定fragment_id和instance_id则返回对应的详细profile树形图。 - - -## 举例 - -1. 列出所有的 query Profile - - ```sql - mysql> show query profile "/"; - +-----------------------------------+------+-------------------------+--------------------+-----------+---------------------+---------------------+-----------+------------+ - | QueryId | User | DefaultDb | SQL | QueryType | StartTime | EndTime | TotalTime | QueryState | - +-----------------------------------+------+-------------------------+--------------------+-----------+---------------------+---------------------+-----------+------------+ - | 327167e0db4749a9-adce3b3d770b2bb1 | root | default_cluster:test_db | select * from test | Query | 2022-08-09 10:50:09 | 2022-08-09 10:50:09 | 19ms | EOF | - +-----------------------------------+------+-------------------------+--------------------+-----------+---------------------+---------------------+-----------+------------+ - 1 row in set (0.00 sec) - ``` - -2. 列出指定QueryId的 query Profile - - ```sql - mysql> show query profile "/327167e0db4749a9-adce3b3d770b2bb1"\G - *************************** 1. row *************************** - Fragments: ┌────────────────────────┐ - │[-1: VDataBufferSender] │ - │Fragment: 0 │ - │MaxActiveTime: 783.263us│ - └────────────────────────┘ - ┌┘ - │ - ┌───────────────────┐ - │[1: VEXCHANGE_NODE]│ - │Fragment: 0 │ - └───────────────────┘ - └┐ - │ - ┌────────────────────────┐ - │[1: VDataStreamSender] │ - │Fragment: 1 │ - │MaxActiveTime: 847.612us│ - └────────────────────────┘ - │ - │ - ┌────────────────────┐ - │[0: VOLAP_SCAN_NODE]│ - │Fragment: 1 │ - └────────────────────┘ - ┌┘ - │ - ┌─────────────┐ - │[OlapScanner]│ - │Fragment: 1 │ - └─────────────┘ - │ - │ - ┌─────────────────┐ - │[SegmentIterator]│ - │Fragment: 1 │ - └─────────────────┘ - 1 row in set (0.00 sec) - ``` -3. 列出指定 Fragment 的 Instance 概况 - - ```sql - mysql> show query profile "/327167e0db4749a9-adce3b3d770b2bb1/1/"\G - *************************** 1. row *************************** - Instances: 327167e0db4749a9-adce3b3d770b2bb2 - Host: 172.26.0.1:9111 - ActiveTime: 847.612us - 1 row in set (0.01 sec) - ``` - -4. 继续查看某一个具体的 Instance 上各个算子的详细 Profile - - ```sql - mysql> show query profile "/327167e0db4749a9-adce3b3d770b2bb1/1/327167e0db4749a9-adce3b3d770b2bb2"\G - *************************** 1. row *************************** - Instance: ┌───────────────────────────────────────┐ - │[1: VDataStreamSender] │ - │(Active: 36.944us, non-child: 0.20) │ - │ - Counters: │ - │ - BytesSent: 0.00 │ - │ - IgnoreRows: 0 │ - │ - LocalBytesSent: 20.00 B │ - │ - OverallThroughput: 0.0 /sec │ - │ - PeakMemoryUsage: 0.00 │ - │ - SerializeBatchTime: 0ns │ - │ - UncompressedRowBatchSize: 0.00 │ - └───────────────────────────────────────┘ - │ - │ - ┌───────────────────────────────────────┐ - │[0: VOLAP_SCAN_NODE] │ - │(Active: 563.241us, non-child: 3.00) │ - │ - Counters: │ - │ - BatchQueueWaitTime: 444.714us │ - │ - BytesRead: 37.00 B │ - │ - NumDiskAccess: 1 │ - │ - NumScanners: 2 │ - │ - PeakMemoryUsage: 320.00 KB │ - │ - RowsRead: 4 │ - │ - RowsReturned: 4 │ - │ - RowsReturnedRate: 7.101K /sec │ - │ - ScannerBatchWaitTime: 206.40us │ - │ - ScannerSchedCount : 2 │ - │ - ScannerWorkerWaitTime: 34.640us│ - │ - TabletCount : 2 │ - │ - TotalReadThroughput: 0.0 /sec │ - └───────────────────────────────────────┘ - │ - │ - ┌─────────────────────────────────┐ - │[OlapScanner] │ - │(Active: 0ns, non-child: 0.00) │ - │ - Counters: │ - │ - BlockConvertTime: 0ns │ - │ - BlockFetchTime: 183.741us│ - │ - ReaderInitTime: 180.741us│ - │ - RowsDelFiltered: 0 │ - │ - RowsPushedCondFiltered: 0│ - │ - ScanCpuTime: 388.576us │ - │ - ScanTime: 0ns │ - │ - ShowHintsTime_V1: 0ns │ - └─────────────────────────────────┘ - │ - │ - ┌─────────────────────────────────────┐ - │[SegmentIterator] │ - │(Active: 0ns, non-child: 0.00) │ - │ - Counters: │ - │ - BitmapIndexFilterTimer: 124ns│ - │ - BlockLoadTime: 179.202us │ - │ - BlockSeekCount: 5 │ - │ - BlockSeekTime: 18.792us │ - │ - BlocksLoad: 4 │ - │ - CachedPagesNum: 2 │ - │ - CompressedBytesRead: 0.00 │ - │ - DecompressorTimer: 0ns │ - │ - IOTimer: 0ns │ - │ - IndexLoadTime_V1: 0ns │ - │ - NumSegmentFiltered: 0 │ - │ - NumSegmentTotal: 2 │ - │ - RawRowsRead: 4 │ - │ - RowsBitmapIndexFiltered: 0 │ - │ - RowsBloomFilterFiltered: 0 │ - │ - RowsConditionsFiltered: 0 │ - │ - RowsKeyRangeFiltered: 0 │ - │ - RowsStatsFiltered: 0 │ - │ - RowsVectorPredFiltered: 0 │ - │ - TotalPagesNum: 2 │ - │ - UncompressedBytesRead: 0.00 │ - │ - VectorPredEvalTime: 0ns │ - └─────────────────────────────────────┘ - - 1 row in set (0.01 sec) - ``` - -### Keywords - - SHOW, QUERY, PROFILE - -### Best Practice - - - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-QUERY-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-QUERY-STATS.md deleted file mode 100644 index 0497353206fb5..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-QUERY-STATS.md +++ /dev/null @@ -1,194 +0,0 @@ ---- -{ - "title": "SHOW-QUERY-STATS", - "language": "zh-CN" -} ---- - - - -## SHOW-QUERY-STATS - - -### Name - -SHOW QUERY STATS - -## 描述 - -该语句用于展示数据库中历史查询命中的库表列的情况 - -```sql -SHOW QUERY STATS [[FOR db_name]|[FROM table_name]] [ALL] [VERBOSE]]; -``` - -说明: - -1. 支持查询数据库和表的历史查询命中情况,重启 fe 后数据会重置,每个 fe 单独统计 -2. 通过 FOR DATABASE 和 FROM TABLE 可以指定查询数据库或者表的命中情况,后面分别接数据库名或者表名 -3. ALL 可以指定是否展示所有 index 的查询命中情况,VERBOSE 可以展示更详细的命中情况,这两个参数可以单独使用, - 也可以一起使用,但是必须放在最后 而且只能用在表的查询上 -4. 如果没有 use 任何数据库那么直接执行`SHOW QUERY STATS` 将展示所有数据库的命中情况 -5. 命中结果中可能有两列: - QueryCount:该列被查询次数 - FilterCount: 该列作为 where 条件被查询的次数 -## 举例 - -1. 展示表`baseall` 的查询命中情况 - - ```sql - MySQL [test_query_db]> show query stats from baseall; - +-------+------------+-------------+ - | Field | QueryCount | FilterCount | - +-------+------------+-------------+ - | k0 | 0 | 0 | - | k1 | 0 | 0 | - | k2 | 0 | 0 | - | k3 | 0 | 0 | - | k4 | 0 | 0 | - | k5 | 0 | 0 | - | k6 | 0 | 0 | - | k10 | 0 | 0 | - | k11 | 0 | 0 | - | k7 | 0 | 0 | - | k8 | 0 | 0 | - | k9 | 0 | 0 | - | k12 | 0 | 0 | - | k13 | 0 | 0 | - +-------+------------+-------------+ - 14 rows in set (0.002 sec) - - MySQL [test_query_db]> select k0, k1,k2, sum(k3) from baseall where k9 > 1 group by k0,k1,k2; - +------+------+--------+-------------+ - | k0 | k1 | k2 | sum(`k3`) | - +------+------+--------+-------------+ - | 0 | 6 | 32767 | 3021 | - | 1 | 12 | 32767 | -2147483647 | - | 0 | 3 | 1989 | 1002 | - | 0 | 7 | -32767 | 1002 | - | 1 | 8 | 255 | 2147483647 | - | 1 | 9 | 1991 | -2147483647 | - | 1 | 11 | 1989 | 25699 | - | 1 | 13 | -32767 | 2147483647 | - | 1 | 14 | 255 | 103 | - | 0 | 1 | 1989 | 1001 | - | 0 | 2 | 1986 | 1001 | - | 1 | 15 | 1992 | 3021 | - +------+------+--------+-------------+ - 12 rows in set (0.050 sec) - - MySQL [test_query_db]> show query stats from baseall; - +-------+------------+-------------+ - | Field | QueryCount | FilterCount | - +-------+------------+-------------+ - | k0 | 1 | 0 | - | k1 | 1 | 0 | - | k2 | 1 | 0 | - | k3 | 1 | 0 | - | k4 | 0 | 0 | - | k5 | 0 | 0 | - | k6 | 0 | 0 | - | k10 | 0 | 0 | - | k11 | 0 | 0 | - | k7 | 0 | 0 | - | k8 | 0 | 0 | - | k9 | 1 | 1 | - | k12 | 0 | 0 | - | k13 | 0 | 0 | - +-------+------------+-------------+ - 14 rows in set (0.001 sec) - ``` - -2. 展示表的所物化视图的的命中的汇总情况 - - ```sql - MySQL [test_query_db]> show query stats from baseall all; - +-----------+------------+ - | IndexName | QueryCount | - +-----------+------------+ - | baseall | 1 | - +-----------+------------+ - 1 row in set (0.005 sec) - ``` - -3. 展示表的所物化视图的的命中的详细情况 - - ```sql - MySQL [test_query_db]> show query stats from baseall all verbose; - +-----------+-------+------------+-------------+ - | IndexName | Field | QueryCount | FilterCount | - +-----------+-------+------------+-------------+ - | baseall | k0 | 1 | 0 | - | | k1 | 1 | 0 | - | | k2 | 1 | 0 | - | | k3 | 1 | 0 | - | | k4 | 0 | 0 | - | | k5 | 0 | 0 | - | | k6 | 0 | 0 | - | | k10 | 0 | 0 | - | | k11 | 0 | 0 | - | | k7 | 0 | 0 | - | | k8 | 0 | 0 | - | | k9 | 1 | 1 | - | | k12 | 0 | 0 | - | | k13 | 0 | 0 | - +-----------+-------+------------+-------------+ - 14 rows in set (0.017 sec) - ``` - -4. 展示数据库的命中情况 - - ```sql - MySQL [test_query_db]> show query stats for test_query_db; - +----------------------------+------------+ - | TableName | QueryCount | - +----------------------------+------------+ - | compaction_tbl | 0 | - | bigtable | 0 | - | empty | 0 | - | tempbaseall | 0 | - | test | 0 | - | test_data_type | 0 | - | test_string_function_field | 0 | - | baseall | 1 | - | nullable | 0 | - +----------------------------+------------+ - 9 rows in set (0.005 sec) - ``` - -5. 展示所有数据库的命中情况,这时不能 use 任何数据库 - - ```sql - MySQL [(none)]> show query stats; - +-----------------+------------+ - | Database | QueryCount | - +-----------------+------------+ - | test_query_db | 1 | - +-----------------+------------+ - 1 rows in set (0.005 sec) - ``` - SHOW QUERY STATS; - ``` - -### Keywords - - SHOW, QUERY, STATS; - -### Best Practice diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-REPOSITORIES.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-REPOSITORIES.md deleted file mode 100644 index eab556349498b..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-REPOSITORIES.md +++ /dev/null @@ -1,67 +0,0 @@ ---- -{ - "title": "SHOW-REPOSITORIES", - "language": "zh-CN" -} ---- - - - -## SHOW-REPOSITORIES - -### Name - -SHOW REPOSITORIES - -## 描述 - -该语句用于查看当前已创建的仓库 - -语法: - -```sql -SHOW REPOSITORIES; -``` - -说明: - -1. 各列含义如下: - RepoId: 唯一的仓库ID - RepoName: 仓库名称 - CreateTime: 第一次创建该仓库的时间 - IsReadOnly: 是否为只读仓库 - Location: 仓库中用于备份数据的根目录 - Broker: 依赖的 Broker - ErrMsg: Doris 会定期检查仓库的连通性,如果出现问题,这里会显示错误信息 - -## 举例 - -1. 查看已创建的仓库: - -```sql - SHOW REPOSITORIES; -``` - -### Keywords - - SHOW, REPOSITORIES - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-RESOURCES.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-RESOURCES.md deleted file mode 100644 index fb25cc0012af2..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-RESOURCES.md +++ /dev/null @@ -1,91 +0,0 @@ ---- -{ - "title": "SHOW-RESOURCES", - "language": "zh-CN" -} ---- - - - -## SHOW-RESOURCES - -### Name - -SHOW RESOURCES - -## 描述 - -该语句用于展示用户有使用权限的资源。普通用户仅能展示有使用权限的资源,root 或 admin 用户会展示所有的资源。 - -语法: - -```sql -SHOW RESOURCES -[ - WHERE - [NAME [ = "your_resource_name" | LIKE "name_matcher"]] - [RESOURCETYPE = ["SPARK"]] -] | [LIKE "pattern"] -[ORDER BY ...] -[LIMIT limit][OFFSET offset]; -``` - -说明: - -1. 如果使用 NAME LIKE,则会匹配 RESOURCES 的 Name 包含 name_matcher 的Resource -2. 如果使用 NAME = ,则精确匹配指定的 Name -3. 如果指定了 RESOURCETYPE,则匹配对应的 Resrouce 类型 -4. 可以使用 ORDER BY 对任意列组合进行排序 -5. 如果指定了 LIMIT,则显示 limit 条匹配记录。否则全部显示 -6. 如果指定了 OFFSET,则从偏移量 offset 开始显示查询结果。默认情况下偏移量为0。 -7. 如果使用了 LIKE,则会忽略 WHERE 语句。 - -## 举例 - -1. 展示当前用户拥有权限的所有 Resource - - ```sql - SHOW RESOURCES; - ``` - -2. 展示指定 Resource ,NAME 中包含字符串 "20140102",展示10个属性 - - ```sql - SHOW RESOURCES WHERE NAME LIKE "2014_01_02" LIMIT 10; - ``` - -3. 展示指定 Resource ,指定 NAME 为 "20140102" 并按 KEY 降序排序 - - ```sql - SHOW RESOURCES WHERE NAME = "20140102" ORDER BY `KEY` DESC; - ``` - -4. 使用 LIKE 进行模糊匹配 - - ```sql - SHOW RESOURCES LIKE "jdbc%"; - ``` - -### Keywords - - SHOW, RESOURCES - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-RESTORE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-RESTORE.md deleted file mode 100644 index c4a629170da52..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-RESTORE.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -{ - "title": "SHOW-RESTORE", - "language": "zh-CN" -} ---- - - - -## SHOW-RESTORE - -### Name - -SHOW RESTORE - -## 描述 - -该语句用于查看 RESTORE 任务 - -语法: - -```SQL -SHOW [BRIEF] RESTORE [FROM DB_NAME] -``` - -说明: - 1. Doris 中仅保存最近一次 RESTORE 任务。 - 2. 各列含义如下: - JobId:唯一作业 id - Label:要恢复的备份的名称 - Timestamp:要恢复的备份的时间版本 - DbName:所属数据库 - State:当前阶段 - PENDING:提交作业后的初始状态 - SNAPSHOTING:执行快照中 - DOWNLOAD:快照完成,准备下载仓库中的快照 - DOWNLOADING:快照下载中 - COMMIT:快照下载完成,准备生效 - COMMITTING:生效中 - FINISHED:作业成功 - CANCELLED:作业失败 - AllowLoad:恢复时是否允许导入(当前不支持) - ReplicationNum:指定恢复的副本数 - RestoreJobs:要恢复的表和分区 - CreateTime:任务提交时间 - MetaPreparedTime:元数据准备完成时间 - SnapshotFinishedTime:快照完成时间 - DownloadFinishedTime:快照下载完成时间 - FinishedTime:作业结束时间 - UnfinishedTasks:在 SNAPSHOTING、DOWNLOADING 和 COMMITTING 阶段会显示还未完成的子任务 id - Status:如果作业失败,显示失败信息 - Timeout:作业超时时间,单位秒 - - 2. brief: 仅返回精简格式的 RESTORE 任务信息,不包含 RestoreObjs, Progress, TaskErrMsg 三列 - -## 举例 - -1. 查看 example_db 下最近一次 RESTORE 任务。 - - ```sql - SHOW RESTORE FROM example_db; - ``` - -### Keywords - - SHOW, RESTORE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ROLES.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ROLES.md deleted file mode 100644 index e713ee8cf32e2..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ROLES.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "SHOW-ROLES", - "language": "zh-CN" -} ---- - - - -## SHOW-ROLES - -### Name - -SHOW ROLES - -## 描述 - -该语句用于展示所有已创建的角色信息,包括角色名称,包含的用户以及权限。 - -语法: - -```SQL -SHOW ROLES -``` - -## 举例 - -1. 查看已创建的角色 - - ```SQL - SHOW ROLES - ``` - -### Keywords - - SHOW, ROLES - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ROUTINE-LOAD-TASK.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ROUTINE-LOAD-TASK.md deleted file mode 100644 index e5a8646733016..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ROUTINE-LOAD-TASK.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -{ - "title": "SHOW-ROUTINE-LOAD-TASK", - "language": "zh-CN" -} ---- - - - -## SHOW-ROUTINE-LOAD-TASK - -### Name - -SHOW ROUTINE LOAD TASK - -## 描述 - -查看一个指定的 Routine Load 作业的当前正在运行的子任务情况。 - -```sql -SHOW ROUTINE LOAD TASK -WHERE JobName = "job_name"; -``` - -返回结果如下: - -```text - TaskId: d67ce537f1be4b86-abf47530b79ab8e6 - TxnId: 4 - TxnStatus: UNKNOWN - JobId: 10280 - CreateTime: 2020-12-12 20:29:48 - ExecuteStartTime: 2020-12-12 20:29:48 - Timeout: 20 - BeId: 10002 -DataSourceProperties: {"0":19} -``` - -- `TaskId`:子任务的唯一 ID。 -- `TxnId`:子任务对应的导入事务 ID。 -- `TxnStatus`:子任务对应的导入事务状态。为 null 时表示子任务还未开始调度。 -- `JobId`:子任务对应的作业 ID。 -- `CreateTime`:子任务的创建时间。 -- `ExecuteStartTime`:子任务被调度执行的时间,通常晚于创建时间。 -- `Timeout`:子任务超时时间,通常是作业设置的 `max_batch_interval` 的两倍。 -- `BeId`:执行这个子任务的 BE 节点 ID。 -- `DataSourceProperties`:子任务准备消费的 Kafka Partition 的起始 offset。是一个 Json 格式字符串。Key 为 Partition Id。Value 为消费的起始 offset。 - -## 举例 - -1. 展示名为 test1 的例行导入任务的子任务信息。 - - ```sql - SHOW ROUTINE LOAD TASK WHERE JobName = "test1"; - ``` - -### Keywords - - SHOW, ROUTINE, LOAD, TASK - -### Best Practice - -通过这个命令,可以查看一个 Routine Load 作业当前有多少子任务在运行,具体运行在哪个 BE 节点上。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ROUTINE-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ROUTINE-LOAD.md deleted file mode 100644 index 09ebe99d01b05..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-ROUTINE-LOAD.md +++ /dev/null @@ -1,130 +0,0 @@ ---- -{ - "title": "SHOW-ROUTINE-LOAD", - "language": "zh-CN" -} ---- - - - -## SHOW-ROUTINE-LOAD - -### Name - -SHOW ROUTINE LOAD - -## 描述 - -该语句用于展示 Routine Load 作业运行状态 - -语法: - -```sql -SHOW [ALL] ROUTINE LOAD [FOR jobName]; -``` - -结果说明: - -``` - Id: 作业ID - Name: 作业名称 - CreateTime: 作业创建时间 - PauseTime: 最近一次作业暂停时间 - EndTime: 作业结束时间 - DbName: 对应数据库名称 - TableName: 对应表名称 (多表的情况下由于是动态表,因此不显示具体表名,我们统一显示 multi-table ) - IsMultiTbl: 是否为多表 - State: 作业运行状态 - DataSourceType: 数据源类型:KAFKA - CurrentTaskNum: 当前子任务数量 - JobProperties: 作业配置详情 -DataSourceProperties: 数据源配置详情 - CustomProperties: 自定义配置 - Statistic: 作业运行状态统计信息 - Progress: 作业运行进度 - Lag: 作业延迟状态 -ReasonOfStateChanged: 作业状态变更的原因 - ErrorLogUrls: 被过滤的质量不合格的数据的查看地址 - OtherMsg: 其他错误信息 -``` - -* State - - 有以下5种State: - * NEED_SCHEDULE:作业等待被调度 - * RUNNING:作业运行中 - * PAUSED:作业被暂停 - * STOPPED:作业已结束 - * CANCELLED:作业已取消 - -* Progress - - 对于Kafka数据源,显示每个分区当前已消费的offset。如 {"0":"2"} 表示Kafka分区0的消费进度为2。 - -* Lag - - 对于Kafka数据源,显示每个分区的消费延迟。如{"0":10} 表示Kafka分区0的消费延迟为10。 - -## 举例 - -1. 展示名称为 test1 的所有例行导入作业(包括已停止或取消的作业)。结果为一行或多行。 - - ```sql - SHOW ALL ROUTINE LOAD FOR test1; - ``` - -2. 展示名称为 test1 的当前正在运行的例行导入作业 - - ```sql - SHOW ROUTINE LOAD FOR test1; - ``` - -3. 显示 example_db 下,所有的例行导入作业(包括已停止或取消的作业)。结果为一行或多行。 - - ```sql - use example_db; - SHOW ALL ROUTINE LOAD; - ``` - -4. 显示 example_db 下,所有正在运行的例行导入作业 - - ```sql - use example_db; - SHOW ROUTINE LOAD; - ``` - -5. 显示 example_db 下,名称为 test1 的当前正在运行的例行导入作业 - - ```sql - SHOW ROUTINE LOAD FOR example_db.test1; - ``` - -6. 显示 example_db 下,名称为 test1 的所有例行导入作业(包括已停止或取消的作业)。结果为一行或多行。 - - ```sql - SHOW ALL ROUTINE LOAD FOR example_db.test1; - ``` - -### Keywords - - SHOW, ROUTINE, LOAD - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-SMALL-FILES.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-SMALL-FILES.md deleted file mode 100644 index e96e1390a06ff..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-SMALL-FILES.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -{ - "title": "SHOW-SMALL-FILES", - "language": "zh-CN" -} ---- - - - -## SHOW-SMALL-FILES - -### Name - -SHOW FILE - -## 描述 - -该语句用于展示一个数据库内,由 CREATE FILE 命令创建的文件。 - -```sql -SHOW FILE [FROM database]; -``` - -返回结果说明: - -- FileId: 文件ID,全局唯一 -- DbName: 所属数据库名称 -- Catalog: 自定义分类 -- FileName: 文件名 -- FileSize: 文件大小,单位字节 -- MD5: 文件的 MD5 - -## 举例 - -1. 查看数据库 my_database 中已上传的文件 - - ```sql - SHOW FILE FROM my_database; - ``` - -### Keywords - - SHOW, SMALL, FILES - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-SNAPSHOT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-SNAPSHOT.md deleted file mode 100644 index 54d2b5cea2240..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-SNAPSHOT.md +++ /dev/null @@ -1,79 +0,0 @@ ---- -{ - "title": "SHOW-SNAPSHOT", - "language": "zh-CN" -} ---- - - - -## SHOW-SNAPSHOT - -### Name - -SHOW SNAPSHOT - -## 描述 - -该语句用于查看仓库中已存在的备份。 - -语法: - -```sql -SHOW SNAPSHOT ON `repo_name` -[WHERE SNAPSHOT = "snapshot" [AND TIMESTAMP = "backup_timestamp"]]; -``` - -说明: - 1. 各列含义如下: - Snapshot: 备份的名称 - Timestamp: 对应备份的时间版本 - Status: 如果备份正常,则显示 OK,否则显示错误信息 - 2. 如果指定了 TIMESTAMP,则会额外显示如下信息: - Database: 备份数据原属的数据库名称 - Details: 以 Json 的形式,展示整个备份的数据目录及文件结构 - -## 举例 - -1. 查看仓库 example_repo 中已有的备份 - - ```sql - SHOW SNAPSHOT ON example_repo; - ``` - -2. 仅查看仓库 example_repo 中名称为 backup1 的备份: - - ```sql - SHOW SNAPSHOT ON example_repo WHERE SNAPSHOT = "backup1"; - ``` - -3. 查看仓库 example_repo 中名称为 backup1 的备份,时间版本为 "2018-05-05-15-34-26" 的详细信息: - - ```sql - SHOW SNAPSHOT ON example_repo - WHERE SNAPSHOT = "backup1" AND TIMESTAMP = "2018-05-05-15-34-26"; - ``` - -### Keywords - - SHOW, SNAPSHOT - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-SQL-BLOCK-RULE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-SQL-BLOCK-RULE.md deleted file mode 100644 index f7f1c72582edb..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-SQL-BLOCK-RULE.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -{ - "title": "SHOW-SQL-BLOCK-RULE", - "language": "zh-CN" -} ---- - - - -## SHOW-SQL-BLOCK-RULE - -### Name - -SHOW SQL BLOCK RULE - -## 描述 - -查看已配置的SQL阻止规则,不指定规则名则为查看所有规则。 - -语法: - -```sql -SHOW SQL_BLOCK_RULE [FOR RULE_NAME]; -``` - -## 举例 - -1. 查看所有规则。 - - ```sql - mysql> SHOW SQL_BLOCK_RULE; - +------------+------------------------+---------+--------------+-----------+-------------+--------+--------+ - | Name | Sql | SqlHash | PartitionNum | TabletNum | Cardinality | Global | Enable | - +------------+------------------------+---------+--------------+-----------+-------------+--------+--------+ - | test_rule | select * from order_analysis | NULL | 0 | 0 | 0 | true | true | - | test_rule2 | NULL | NULL | 30 | 0 | 10000000000 | false | true | - +------------+------------------------+---------+--------------+-----------+-------------+--------+--------+ - 2 rows in set (0.01 sec) - ``` - -2. 指定规则名查询 - - ```sql - mysql> SHOW SQL_BLOCK_RULE FOR test_rule2; - +------------+------+---------+--------------+-----------+-------------+--------+--------+ - | Name | Sql | SqlHash | PartitionNum | TabletNum | Cardinality | Global | Enable | - +------------+------+---------+--------------+-----------+-------------+--------+--------+ - | test_rule2 | NULL | NULL | 30 | 0 | 10000000000 | false | true | - +------------+------+---------+--------------+-----------+-------------+--------+--------+ - 1 row in set (0.00 sec) - - ``` - - -### Keywords - - SHOW, SQL_BLOCK_RULE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-STATUS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-STATUS.md deleted file mode 100644 index 80ed6f378a0db..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-STATUS.md +++ /dev/null @@ -1,114 +0,0 @@ ---- -{ - "title": "SHOW-STATUS", - "language": "zh-CN" -} ---- - - - -## SHOW-STATUS - -### Name - -SHOW STATUS - -## 描述 - -该命令用于查看通过[创建物化视图](../Data-Definition-Statements/Create/CREATE-MATERIALIZED-VIEW.md)语句提交的创建物化视图作业的执行情况。 - -> 该语句相当于`SHOW ALTER TABLE ROLLUP`; - -```sql -SHOW ALTER TABLE MATERIALIZED VIEW -[FROM database] -[WHERE] -[ORDER BY] -[LIMIT OFFSET] -``` - -- database :查看指定数据库下的作业。 如果未指定,则使用当前数据库。 -- WHERE:您可以过滤结果列,目前仅支持以下列: - - TableName:仅支持等值过滤。 - - State:仅支持等效过滤。 - - Createtime/FinishTime:支持 =、>=、<=、>、<、!= -- ORDER BY:结果集可以按任何列排序。 -- LIMIT:使用 ORDER BY 进行翻页查询。 - -Return result description: - -```sql -mysql> show alter table materialized view\G -**************************** 1. row ******************** ****** - JobId: 11001 - TableName: tbl1 - CreateTime: 2020-12-23 10:41:00 - FinishTime: NULL - BaseIndexName: tbl1 -RollupIndexName: r1 - RollupId: 11002 - TransactionId: 5070 - State: WAITING_TXN - Msg: - Progress: NULL - Timeout: 86400 -1 row in set (0.00 sec) -``` - -- `JobId`:作业唯一 ID。 - -- `TableName`:基表名称 - -- `CreateTime/FinishTime`:作业创建时间和结束时间。 - -- `BaseIndexName/RollupIndexName`:基表名称和物化视图名称。 - -- `RollupId`:物化视图的唯一 ID。 - -- `TransactionId`:参见State字段的描述。 - -- `State`:工作状态。 - - - PENDING:工作正在准备中。 - - - WAITING_TXN: - - 在正式开始生成物化视图数据之前,它会等待当前正在运行的该表上的导入事务完成。而 `TransactionId` 字段是当前等待的交易 ID。当此 ID 的所有先前导入完成后,作业将真正开始。 - - - RUNNING:作业正在运行。 - - - FINISHED :作业成功运行。 - - - CANCELLED:作业运行失败。 - -- `Msg`:错误信息 - -- `Progress`:作业进度。这里的进度是指 `完completed tablets/total tablets`。物化视图以 tablet 粒度创建。 - -- `Timeout`:作业超时,以秒为单位。 - -## 举例 - -### Keywords - - SHOW, STATUS - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-STORAGE-POLICY-USING.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-STORAGE-POLICY-USING.md deleted file mode 100644 index 7db96b23e6279..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-STORAGE-POLICY-USING.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -{ - "title": "SHOW-STORAGE-POLICY-USING", - "language": "zh-CN" -} ---- - - - -## SHOW-STORAGE-POLICY-USING - -### Name - -SHOW STORAGE POLICY USING - -## 描述 - -查看所有/指定存储策略关联的表和分区 - -语法: - -```sql -SHOW STORAGE POLICY USING [FOR some_policy] -``` - -## 举例 - -1. 查看所有启用了存储策略的对象 - ```sql - mysql> show storage policy using; - +-----------------------+-----------------------------------------+----------------------------------------+------------+ - | PolicyName | Database | Table | Partitions | - +-----------------------+-----------------------------------------+----------------------------------------+------------+ - | test_storage_policy | regression_test_cold_heat_separation_p2 | table_with_storage_policy_1 | ALL | - | test_storage_policy | regression_test_cold_heat_separation_p2 | partition_with_multiple_storage_policy | p201701 | - | test_storage_policy_2 | regression_test_cold_heat_separation_p2 | partition_with_multiple_storage_policy | p201702 | - | test_storage_policy_2 | regression_test_cold_heat_separation_p2 | table_with_storage_policy_2 | ALL | - | test_policy | db2 | db2_test_1 | ALL | - +-----------------------+-----------------------------------------+----------------------------------------+------------+ - ``` -2. 查看使用存储策略test_storage_policy的对象 - - ```sql - mysql> show storage policy using for test_storage_policy; - +---------------------+-----------+---------------------------------+------------+ - | PolicyName | Database | Table | Partitions | - +---------------------+-----------+---------------------------------+------------+ - | test_storage_policy | db_1 | partition_with_storage_policy_1 | p201701 | - | test_storage_policy | db_1 | table_with_storage_policy_1 | ALL | - +---------------------+-----------+---------------------------------+------------+ - ``` - -### Keywords - - SHOW, STORAGE, POLICY, USING - -### Best Practice diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-STORAGE-VAULTS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-STORAGE-VAULTS.md deleted file mode 100644 index 73fd4e8fa3a68..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-STORAGE-VAULTS.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -{ - "title": "SHOW STORAGE VAULTS", - "language": "zh-CN" -} ---- - - - -## 描述 - -SHOW STORAGE VAULTS 命令用于显示系统中配置的所有storage vault的信息。storage vault用于管理数据外部存储位置。 - -## 语法 - -```sql - SHOW STORAGE VAULTS -``` - -## 返回值 - -此命令返回一个结果集,包含以下列: - -- `StorageVaultName`: storage vault 的名称。 -- `StorageVaultId`: storage vault 的ID。 -- `Properties`: 包含 storage vault 配置属性的JSON字符串。 -- `IsDefault`: 指示该 storage vault 是否设置为默认值(TRUE或FALSE)。 - -## 相关命令 - -- [CREATE STORAGE VAULT](../Data-Definition-Statements/CREATE-STORAGE-VAULT.md) -- [GRANT](../Account-Management-Statements/GRANT.md) -- [REVOKE](../Account-Management-Statements/REVOKE.md) -- [SET DEFAULT STORAGE VAULT](../Data-Definition-Statements/SET-DEFAULT-STORAGE-VAULT.md) - -## Keywords - - SHOW, STORAGE VAULTS diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-STREAM-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-STREAM-LOAD.md deleted file mode 100644 index ba84ba275841d..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-STREAM-LOAD.md +++ /dev/null @@ -1,101 +0,0 @@ ---- -{ - "title": "SHOW-STREAM-LOAD", - "language": "zh-CN" -} ---- - - - -## SHOW-STREAM-LOAD - -### Name - -SHOW STREAM LOAD - -## 描述 - -该语句用于展示指定的Stream Load任务的执行情况 - -语法: - -```sql -SHOW STREAM LOAD -[FROM db_name] -[ - WHERE - [LABEL [ = "your_label" | LIKE "label_matcher"]] - [STATUS = ["SUCCESS"|"FAIL"]] -] -[ORDER BY ...] -[LIMIT limit][OFFSET offset]; -``` - -说明: - -1. 默认 BE 是不记录 Stream Load 的记录,如果你要查看需要在 BE 上启用记录,配置参数是:`enable_stream_load_record=true` ,具体怎么配置请参照 [BE 配置项](../../../admin-manual/config/be-config.md) -2. 如果不指定 db_name,使用当前默认db - -2. 如果使用 LABEL LIKE,则会匹配Stream Load任务的 label 包含 label_matcher 的任务 -3. 如果使用 LABEL = ,则精确匹配指定的 label -4. 如果指定了 STATUS,则匹配 STREAM LOAD 状态 -5. 可以使用 ORDER BY 对任意列组合进行排序 -6. 如果指定了 LIMIT,则显示 limit 条匹配记录。否则全部显示 -7. 如果指定了 OFFSET,则从偏移量offset开始显示查询结果。默认情况下偏移量为0。 - -## 举例 - -1. 展示默认 db 的所有Stream Load任务 - - ```sql - SHOW STREAM LOAD; - ``` - -2. 展示指定 db 的Stream Load任务,label 中包含字符串 "2014_01_02",展示最老的10个 - - ```sql - SHOW STREAM LOAD FROM example_db WHERE LABEL LIKE "2014_01_02" LIMIT 10; - ``` - -2. 展示指定 db 的Stream Load任务,指定 label 为 "load_example_db_20140102" - - ```sql - SHOW STREAM LOAD FROM example_db WHERE LABEL = "load_example_db_20140102"; - ``` - -2. 展示指定 db 的Stream Load任务,指定 status 为 "success", 并按 StartTime 降序排序 - - ```sql - SHOW STREAM LOAD FROM example_db WHERE STATUS = "success" ORDER BY StartTime DESC; - ``` - -2. 展示指定 db 的导入任务 并按 StartTime 降序排序,并从偏移量5开始显示10条查询结果 - - ```sql - SHOW STREAM LOAD FROM example_db ORDER BY StartTime DESC limit 5,10; - SHOW STREAM LOAD FROM example_db ORDER BY StartTime DESC limit 10 offset 5; - ``` - -### Keywords - - SHOW, STREAM, LOAD - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-SYNC-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-SYNC-JOB.md deleted file mode 100644 index 77b2fc4498515..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-SYNC-JOB.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -{ - "title": "SHOW-SYNC-JOB", - "language": "zh-CN" -} - ---- - - - -## SHOW-SYNC-JOB - -### Name - -SHOW SYNC JOB - -## 描述 - -此命令用于当前显示所有数据库内的常驻数据同步作业状态。 - -语法: - -```sql -SHOW SYNC JOB [FROM db_name] -``` - -## 举例 - -1. 展示当前数据库的所有数据同步作业状态。 - - ```sql - SHOW SYNC JOB; - ``` - -2. 展示数据库 `test_db` 下的所有数据同步作业状态。 - - ```sql - SHOW SYNC JOB FROM `test_db`; - ``` - -### Keywords - - SHOW, SYNC, JOB - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLE-ID.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLE-ID.md deleted file mode 100644 index 0042f4ae4fc01..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLE-ID.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "SHOW-TABLE-ID", - "language": "zh-CN" -} ---- - - - -## SHOW-TABLE-ID - -### Name - -SHOW TABLE ID - -## 描述 - -该语句用于根据 table id 查找对应的 database name, table name(仅管理员使用) - -语法: - -```sql -SHOW TABLE [table_id] -``` - -## 举例 - - 1. 根据 table id 查找对应的 database name, table name - - ```sql - SHOW TABLE 10001; - ``` - -### Keywords - - SHOW, TABLE, ID - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLE-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLE-STATS.md deleted file mode 100644 index d756e216417a5..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLE-STATS.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -{ - "title": "SHOW-TABLE-STATS", - "language": "zh-CN" -} ---- - - - -## SHOW-TABLE-STATS - -### Name - -SHOW TABLE STATS - -## 描述 - -通过 `SHOW TABLE STATS` 查看表的统计信息收集概况。 - -语法如下: - -```SQL -SHOW TABLE STATS table_name; -``` - -其中: - -- table_name: 目标表表名。可以是  `db_name.table_name`  形式。 - -输出: - -| 列名 | 说明 | -| :------------------ | :--------------------- | -|`updated_rows`|自上次 ANALYZE 以来该表的更新行数| -|`query_times`|保留列,后续版本用以记录该表查询次数| -|`row_count`| 行数(不反映命令执行时的准确行数)| -|`updated_time`| 上次更新时间| -|`columns`| 收集过统计信息的列| -|`trigger`|触发方式| - -下面是一个例子: - -```sql -mysql> show table stats lineitem \G; -*************************** 1. row *************************** -updated_rows: 0 - query_times: 0 - row_count: 6001215 -updated_time: 2023-11-07 - columns: [l_returnflag, l_receiptdate, l_tax, l_shipmode, l_suppkey, l_shipdate, l_commitdate, l_partkey, l_orderkey, l_quantity, l_linestatus, l_comment, l_extendedprice, l_linenumber, l_discount, l_shipinstruct] - trigger: MANUAL -``` - -
- -
- -### Keywords - -SHOW, TABLE, STATS diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLE-STATUS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLE-STATUS.md deleted file mode 100644 index b2e28b9694505..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLE-STATUS.md +++ /dev/null @@ -1,67 +0,0 @@ ---- -{ - "title": "SHOW-TABLE-STATUS", - "language": "zh-CN" -} ---- - - - -## SHOW-TABLE-STATUS - -### Name - -SHOW TABLE STATUS - -## 描述 - -该语句用于查看 Table 的一些信息。 - -语法: - -```sql -SHOW TABLE STATUS -[FROM db] [LIKE "pattern"] -``` - -说明: - -1. 该语句主要用于兼容 MySQL 语法,目前仅显示 Comment 等少量信息 - -## 举例 - - 1. 查看当前数据库下所有表的信息 - - ```sql - SHOW TABLE STATUS; - ``` - - 1. 查看指定数据库下,名称包含 example 的表的信息 - - ```sql - SHOW TABLE STATUS FROM db LIKE "%example%"; - ``` - -### Keywords - - SHOW, TABLE, STATUS - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLES.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLES.md deleted file mode 100644 index 85588f151c893..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLES.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -{ - "title": "SHOW-TABLES", - "language": "zh-CN" -} ---- - - - -## SHOW-TABLES - -### Name - -SHOW TABLES - -## 描述 - -该语句用于展示当前 db 下所有的 table - -语法: - -```sql -SHOW [FULL] TABLES [LIKE] -``` - -说明: - -1. LIKE:可按照表名进行模糊查询 - -## 举例 - - 1. 查看DB下所有表 - - ```sql - mysql> show tables; - +---------------------------------+ - | Tables_in_demo | - +---------------------------------+ - | ads_client_biz_aggr_di_20220419 | - | cmy1 | - | cmy2 | - | intern_theme | - | left_table | - +---------------------------------+ - 5 rows in set (0.00 sec) - ``` - -2. 按照表名进行模糊查询 - - ```sql - mysql> show tables like '%cm%'; - +----------------+ - | Tables_in_demo | - +----------------+ - | cmy1 | - | cmy2 | - +----------------+ - 2 rows in set (0.00 sec) - ``` - -### Keywords - - SHOW, TABLES - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLET.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLET.md deleted file mode 100644 index 8953d2b88377b..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLET.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "SHOW-TABLET", - "language": "zh-CN" -} ---- - - - -## SHOW-TABLET - -### Name - -SHOW TABLET - -## 描述 - -该语句用于显示指定tablet id 信息(仅管理员使用) - -语法: - -```sql -SHOW TABLET tablet_id -``` - -## 举例 - -1. 显示指定 tablet id 为 10000 的 tablet 的父层级 id 信息 - - ```sql - SHOW TABLET 10000; - ``` - -### Keywords - - SHOW, TABLET - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLETS-BELONG.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLETS-BELONG.md deleted file mode 100644 index 745f05d12581f..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLETS-BELONG.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -{ - "title": "SHOW-TABLETS-BELONG", - "language": "zh-CN" -} ---- - - - -## SHOW-TABLETS-BELONG - -### Name - -SHOW TABLETS BELONG - -## 描述 - -该语句用于展示指定 Tablets 归属的表的信息 - -语法: - -```sql -SHOW TABLETS BELONG tablet-ids; -``` - -说明: - -1. tablet-ids:代表一到多个 tablet-id 构成的列表。如有多个,使用逗号分隔 -2. 结果中 table 相关的信息和 `SHOW-DATA` 语句的口径一致 - -## 举例 - -1. 展示 3 个 tablet-id 的相关信息(tablet-id 可去重) - - ```sql - SHOW TABLETS BELONG 27028,78880,78382,27028; - ``` - - ``` -+---------------------+-----------+-----------+--------------+-----------+--------------+----------------+ -| DbName | TableName | TableSize | PartitionNum | BucketNum | ReplicaCount | TabletIds | -+---------------------+-----------+-----------+--------------+-----------+--------------+----------------+ -| default_cluster:db1 | kec | 613.000 B | 379 | 604 | 604 | [78880, 78382] | -| default_cluster:db1 | test | 1.874 KB | 1 | 1 | 1 | [27028] | -+---------------------+-----------+-----------+--------------+-----------+--------------+----------------+ - ``` - -### Keywords - - SHOW, TABLETS, BELONG - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLETS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLETS.md deleted file mode 100644 index 1f5250ed9ad48..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TABLETS.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -{ - "title": "SHOW-TABLETS", - "language": "zh-CN" -} ---- - - - -## SHOW-TABLETS - -### Name - -SHOW TABLETS - -## 描述 - -该语句用于列出指定table的所有tablets(仅管理员使用) - -语法: - -```sql -SHOW TABLETS FROM [database.]table [PARTITIONS(p1,p2)] -[WHERE where_condition] -[ORDER BY col_name] -[LIMIT [offset,] row_count] -``` -1. **Syntax Description:** - -where_condition 可以为下列条件之一: -``` -Version = version -state = "NORMAL|ROLLUP|CLONE|DECOMMISSION" -BackendId = backend_id -IndexName = rollup_name -``` -或者通过`AND`组合的复合条件. - -## 举例 - -1. 列出指定table所有的tablets - - ```sql - SHOW TABLETS FROM example_db.table_name; - ``` - -2. 列出指定partitions的所有tablets - - ```sql - SHOW TABLETS FROM example_db.table_name PARTITIONS(p1, p2); - ``` - -3. 列出某个backend上状态为DECOMMISSION的tablets - - ```sql - SHOW TABLETS FROM example_db.table_name WHERE state="DECOMMISSION" AND BackendId=11003; - ``` - -### Keywords - - SHOW, TABLETS - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TRANSACTION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TRANSACTION.md deleted file mode 100644 index c5fdb0736d252..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TRANSACTION.md +++ /dev/null @@ -1,106 +0,0 @@ ---- -{ - "title": "SHOW-TRANSACTION", - "language": "zh-CN" -} ---- - - - -## SHOW-TRANSACTION - -### Name - -SHOW TRANSACTION - -## 描述 - -该语法用于查看指定 transaction id 或 label 的事务详情。 - -语法: - -```sql -SHOW TRANSACTION -[FROM db_name] -WHERE -[id = transaction_id] -[label = label_name]; -``` - -返回结果示例: - -``` - TransactionId: 4005 - Label: insert_8d807d5d-bcdd-46eb-be6d-3fa87aa4952d - Coordinator: FE: 10.74.167.16 - TransactionStatus: VISIBLE - LoadJobSourceType: INSERT_STREAMING - PrepareTime: 2020-01-09 14:59:07 - CommitTime: 2020-01-09 14:59:09 - FinishTime: 2020-01-09 14:59:09 - Reason: -ErrorReplicasCount: 0 - ListenerId: -1 - TimeoutMs: 300000 -``` - -* TransactionId:事务id -* Label:导入任务对应的 label -* Coordinator:负责事务协调的节点 -* TransactionStatus:事务状态 - * PREPARE:准备阶段 - * COMMITTED:事务成功,但数据不可见 - * VISIBLE:事务成功且数据可见 - * ABORTED:事务失败 -* LoadJobSourceType:导入任务的类型。 -* PrepareTime:事务开始时间 -* CommitTime:事务提交成功的时间 -* FinishTime:数据可见的时间 -* Reason:错误信息 -* ErrorReplicasCount:有错误的副本数 -* ListenerId:相关的导入作业的id -* TimeoutMs:事务超时时间,单位毫秒 - -## 举例 - -1. 查看 id 为 4005 的事务: - - ```sql - SHOW TRANSACTION WHERE ID=4005; - ``` - -2. 指定 db 中,查看 id 为 4005 的事务: - - ```sql - SHOW TRANSACTION FROM db WHERE ID=4005; - ``` - -3. 查看 label 为 label_name的事务: - - ```sql - SHOW TRANSACTION WHERE LABEL = 'label_name'; - ``` - -### Keywords - - SHOW, TRANSACTION - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TRASH.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TRASH.md deleted file mode 100644 index 518d8131c00d0..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TRASH.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -{ - "title": "SHOW-TRASH", - "language": "zh-CN" -} - ---- - - - -## SHOW-TRASH - -### Name - -SHOW TRASH - -## 描述 - -该语句用于查看 backend 内的垃圾数据占用空间。 - -语法: - -```sql -SHOW TRASH [ON BackendHost:BackendHeartBeatPort]; -``` - -说明: - -1. Backend 格式为该节点的BackendHost:BackendHeartBeatPort -2. TrashUsedCapacity 表示该节点垃圾数据占用空间。 - -## 举例 - -1. 查看所有be节点的垃圾数据占用空间。 - - ```sql - SHOW TRASH; - ``` - -2. 查看'192.168.0.1:9050'的垃圾数据占用空间(会显示具体磁盘信息)。 - - ```sql - SHOW TRASH ON "192.168.0.1:9050"; - ``` - -### Keywords - - SHOW, TRASH - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TRIGGERS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TRIGGERS.md deleted file mode 100644 index bc6f6cebceec7..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TRIGGERS.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -{ - "title": "SHOW-TRIGGERS", - "language": "zh-CN" -} ---- - - - -## SHOW-TRIGGERS - -## 描述 - -## 举例 - -### Keywords - - SHOW, TRIGGERS - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TYPECAST.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TYPECAST.md deleted file mode 100644 index 1b1e4be4b4ee5..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-TYPECAST.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -{ - "title": "SHOW-TYPECAST", - "language": "zh-CN" -} ---- - - - -## SHOW-TYPECAST - -### Name - -SHOW TYPECAST - -## 描述 - -查看数据库下所有的类型转换。如果用户指定了数据库,那么查看对应数据库的,否则直接查询当前会话所在数据库 - -需要对这个数据库拥有 `SHOW` 权限 - -语法 - -```sql -SHOW TYPE_CAST [IN|FROM db] -``` - - Parameters - ->`db`: database name to query - -## 举例 - -```sql -mysql> show type_cast in testDb\G -**************************** 1. row ******************** ****** -Origin Type: TIMEV2 - Cast Type: TIMEV2 -**************************** 2. row ******************** ****** -Origin Type: TIMEV2 - Cast Type: TIMEV2 -**************************** 3. row ******************** ****** -Origin Type: TIMEV2 - Cast Type: TIMEV2 - -3 rows in set (0.00 sec) -``` - -### Keywords - - SHOW, TYPECAST - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-VARIABLES.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-VARIABLES.md deleted file mode 100644 index ce8b60c46c8d4..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-VARIABLES.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -{ - "title": "SHOW-VARIABLES", - "language": "zh-CN" -} ---- - - - -## SHOW-VARIABLES - -### Name - -SHOW VARIABLES - -## 描述 - -该语句是用来显示Doris系统变量,可以通过条件查询 - -语法: - -```sql -SHOW [GLOBAL | SESSION] VARIABLES - [LIKE 'pattern' | WHERE expr] -``` - -说明: - -- show variables主要是用来查看系统变量的值. -- 执行SHOW VARIABLES命令不需要任何权限,只要求能够连接到服务器就可以. -- 使用like语句表示用variable_name进行匹配. -- %百分号通配符可以用在匹配模式中的任何位置 - -## 举例 - -1. 这里默认的就是对Variable_name进行匹配,这里是准确匹配 - - ```sql - show variables like 'max_connections'; - ``` - -2. 通过百分号(%)这个通配符进行匹配,可以匹配多项 - - ```sql - show variables like '%connec%'; - ``` - -3. 使用 Where 子句进行匹配查询 - - ```sql - show variables where variable_name = 'version'; - ``` - -### Keywords - - SHOW, VARIABLES - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-VIEW.md deleted file mode 100644 index 8a884eac24860..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-VIEW.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "SHOW-VIEW", - "language": "zh-CN" -} ---- - - - -## SHOW-VIEW - -### Name - -SHOW VIEW - -## 描述 - -该语句用于展示基于给定表建立的所有视图 - -语法: - -```sql - SHOW VIEW { FROM | IN } table [ FROM db ] -``` - -## 举例 - -1. 展示基于表 testTbl 建立的所有视图 view - - ```sql - SHOW VIEW FROM testTbl; - ``` - -### Keywords - - SHOW, VIEW - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-WARM-UP-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-WARM-UP-JOB.md deleted file mode 100644 index 9a01e334640ee..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-WARM-UP-JOB.md +++ /dev/null @@ -1,65 +0,0 @@ ---- -{ - "title": "SHOW-WARM-UP-JOB", - "language": "en" -} ---- - - - -## 描述 - -这些命令用于在Doris中显示预热作业。 - -## 语法 - -```sql - SHOW WARM UP JOB [ WHERE id = 'id' ] ; -``` - -## 参数 - -* id : 预热作业的id。 - -## 示例 - -1. 查看所有预热作业 - - ```sql - SHOW WARM UP JOB; - ``` - -2. 查看 id 为 13418 的预热作业 - -```sql - SHOW WARM UP JOB WHERE id = 13418; -``` - -## 相关命令 - - - [WARMUP COMPUTE GROUP](../Database-Administration-Statements/WARM-UP-COMPUTE-GROUP.md) - -## 参考 - - - [管理文件缓存](../../../compute-storage-decoupled/file-cache.md) - -## 关键字 - - SHOW, CACHE, HOTSPOT, COMPUTE GROUP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-WARNING.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-WARNING.md deleted file mode 100644 index a23f5cbc7eb59..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-WARNING.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -{ - "title": "SHOW-WARNING", - "language": "zh-CN" -} ---- - - - -## SHOW-WARNING - -## 描述 - -## 举例 - -### Keywords - - SHOW, WARNING - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-WHITE-LIST.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-WHITE-LIST.md deleted file mode 100644 index 913b0f58431ff..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-WHITE-LIST.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -{ - "title": "SHOW-WHITE-LIST", - "language": "zh-CN" -} ---- - - - -## SHOW-WHITE-LIST - -## 描述 - -## 举例 - -### Keywords - - SHOW, WHITE, LIST - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-WORKLOAD-GROUPS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-WORKLOAD-GROUPS.md deleted file mode 100644 index 3e45208cc97c5..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-WORKLOAD-GROUPS.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -{ - "title": "SHOW-WORKLOAD-GROUPS", - "language": "zh-CN" -} ---- - - - -## SHOW-WORKLOAD-GROUPS - -### Name - -SHOW WORKLOAD GROUPS - -## 描述 - -该语句用于展示当前用户具有usage_priv权限的资源组。 - -语法: - -```sql -SHOW WORKLOAD GROUPS [LIKE "pattern"]; -``` - -说明: - -该语句仅做资源组简单展示,更复杂的展示可参考 tvf workload_groups(). - -## 举例 - -1. 展示所有资源组: - - ```sql - mysql> show workload groups; - +----------+--------+--------------------------+---------+ - | Id | Name | Item | Value | - +----------+--------+--------------------------+---------+ - | 10343386 | normal | cpu_share | 10 | - | 10343386 | normal | memory_limit | 30% | - | 10343386 | normal | enable_memory_overcommit | true | - | 10352416 | g1 | memory_limit | 20% | - | 10352416 | g1 | cpu_share | 10 | - +----------+--------+--------------------------+---------+ - ``` - -2. 使用 LIKE 模糊匹配: - - ```sql - mysql> show workload groups like "normal%" - +----------+--------+--------------------------+---------+ - | Id | Name | Item | Value | - +----------+--------+--------------------------+---------+ - | 10343386 | normal | cpu_share | 10 | - | 10343386 | normal | memory_limit | 30% | - | 10343386 | normal | enable_memory_overcommit | true | - +----------+--------+--------------------------+---------+ - ``` - -### Keywords - - SHOW, WORKLOAD, GROUPS, GROUP - -### Best Practice diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/CANCEL-MATERIALIZED-VIEW-TASK.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/CANCEL-MATERIALIZED-VIEW-TASK.md deleted file mode 100644 index e4d831c0feee9..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/CANCEL-MATERIALIZED-VIEW-TASK.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "CANCEL-MATERIALIZED-VIEW-TASK", - "language": "zh-CN" -} ---- - - - -## CANCEL-MATERIALIZED-VIEW-TASK - -### Name - -CANCEL MATERIALIZED VIEW TASK - -## 描述 - -该语句用于取消物化视图的task - -语法: - -```sql -CANCEL MATERIALIZED VIEW TASK taskId=INTEGER_VALUE ON mvName=multipartIdentifier -``` - -## 举例 - -1. 取消物化视图mv1的id为1的task - - ```sql - CANCEL MATERIALIZED VIEW TASK 1 on mv1; - ``` - -### Keywords - - CANCEL, MATERIALIZED, VIEW, TASK - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/CLEAN-QUERY-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/CLEAN-QUERY-STATS.md deleted file mode 100644 index a4dfe0cc99e3b..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/CLEAN-QUERY-STATS.md +++ /dev/null @@ -1,73 +0,0 @@ ---- -{ - "title": "CLEAN-QUERY-STATS", - "language": "zh-CN" -} ---- - - - -## CLEAN-QUERY-STATS - -### Name - -CLEAN QUERY STATS - -## 描述 - -该语句用请空查询统计信息 - -语法: - -```sql -CLEAN [ALL| DATABASE | TABLE] QUERY STATS [[FOR db_name]|[FROM|IN] table_name]]; -``` - -说明: - -1. 如果指定 ALL,则清空所有查询统计信息,包括数据库和表的统计信息,需要 admin 权限 -2. 如果指定 DATABASE,则清空指定数据库的查询统计信息,需要对应 database 的 alter 权限 -3. 如果指定 TABLE,则清空指定表的查询统计信息,需要对应表的 alter 权限 - -## 举例 - -1. 清空所有统计信息 - - ```sql - clean all query stats; - ``` - -2. 清空指定数据库的统计信息 - - ```sql - clean database query stats for test_query_db; - ``` -3. 清空指定表的统计信息 - - ```sql - clean table query stats from test_query_db.baseall; - ``` - -### Keywords - - CLEAN, QUERY, STATS - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/DESCRIBE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/DESCRIBE.md deleted file mode 100644 index 59daf9036957f..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/DESCRIBE.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -{ - "title": "DESCRIBE", - "language": "zh-CN" -} ---- - - - -## DESCRIBE - -### Name - -DESCRIBE - -## 描述 - -该语句用于展示指定 table 的 schema 信息 - -语法: - -```sql -DESC[RIBE] [db_name.]table_name [ALL]; -``` - -说明: - -1. 如果指定 ALL,则显示该 table 的所有 index(rollup) 的 schema - -## 举例 - -1. 显示Base表Schema - - ```sql - DESC table_name; - ``` - -2. 显示表所有 index 的 schema - - ```sql - DESC db1.table_name ALL; - ``` - -### Keywords - - DESCRIBE, DESC - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/HELP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/HELP.md deleted file mode 100644 index a557e5f5f961e..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/HELP.md +++ /dev/null @@ -1,113 +0,0 @@ ---- -{ - "title": "HELP", - "language": "zh-CN" -} ---- - - - -## HELP - -### Name - -HELP - -## 描述 - -通过改命令可以查询到帮助的目录 - -语法: - -``` sql -HELP -``` - -可以通过 `help` 列出所有的 Doris 命令 - -```sql -List of all MySQL commands: -Note that all text commands must be first on line and end with ';' -? (\?) Synonym for `help'. -clear (\c) Clear the current input statement. -connect (\r) Reconnect to the server. Optional arguments are db and host. -delimiter (\d) Set statement delimiter. -edit (\e) Edit command with $EDITOR. -ego (\G) Send command to mysql server, display result vertically. -exit (\q) Exit mysql. Same as quit. -go (\g) Send command to mysql server. -help (\h) Display this help. -nopager (\n) Disable pager, print to stdout. -notee (\t) Don't write into outfile. -pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. -print (\p) Print current command. -prompt (\R) Change your mysql prompt. -quit (\q) Quit mysql. -rehash (\#) Rebuild completion hash. -source (\.) Execute an SQL script file. Takes a file name as an argument. -status (\s) Get status information from the server. -system (\!) Execute a system shell command. -tee (\T) Set outfile [to_outfile]. Append everything into given outfile. -use (\u) Use another database. Takes database name as argument. -charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. -warnings (\W) Show warnings after every statement. -nowarning (\w) Don't show warnings after every statement. -resetconnection(\x) Clean session context. - -For server side help, type 'help contents' -``` - -通过 `help contents` 获取 Doris SQL 帮助目录 - -```sql -Many help items for your request exist. -To make a more specific request, please type 'help ', -where is one of the following -categories: - sql-functions - sql-statements -``` - -## 举例 - -1. 列出 Doris 所有的 SQL 帮助目录 - - ```sql - help contents - ``` - -2. 列出 Doris 集群所有函数目录的命令 - - ```sql - help sql-functions - ``` - -3. 列出日期函数下的所有函数列表 - - ```sql - help date-time-functions - ``` - -### Keywords - - HELP - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/PAUSE-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/PAUSE-MATERIALIZED-VIEW.md deleted file mode 100644 index 800a5621a2d4b..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/PAUSE-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "PAUSE-MATERIALIZED-VIEW", - "language": "zh-CN" -} ---- - - - -## PAUSE-MATERIALIZED-VIEW - -### Name - -PAUSE MATERIALIZED VIEW - -## 描述 - -该语句用于暂停物化视图的定时调度 - -语法: - -```sql -PAUSE MATERIALIZED VIEW JOB ON mvName=multipartIdentifier -``` - -## 举例 - -1. 暂停物化视图mv1的定时调度 - - ```sql - PAUSE MATERIALIZED VIEW JOB ON mv1; - ``` - -### Keywords - - PAUSE, MATERIALIZED, VIEW - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/REFRESH-LDAP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/REFRESH-LDAP.md deleted file mode 100644 index ade1f595414a4..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/REFRESH-LDAP.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -{ - "title": "REFRESH-LDAP", - "language": "zh-CN" -} ---- - - - -## REFRESH-LDAP - -### Name - -REFRESH-LDAP - -## 描述 - -该语句用于刷新 Doris 中 LDAP 的缓存信息。修改 LDAP 服务中用户信息或者修改 Doris 中 LDAP 用户组对应的 role 权限,可能因为缓存的原因不会立即生效,可通过该语句刷新缓存。Doris 中 LDAP 信息缓存默认时间为 12 小时,可以通过 `SHOW FRONTEND CONFIG LIKE 'ldap_user_cache_timeout_s';` 查看。 - -语法: - -```sql -REFRESH LDAP ALL; -REFRESH LDAP [for user_name]; -``` - -## 举例 - -1. 刷新所有 LDAP 用户缓存信息 - - ```sql - REFRESH LDAP ALL; - ``` - -2. 刷新当前 LDAP 用户的缓存信息 - - ```sql - REFRESH LDAP; - ``` - -3. 刷新指定 LDAP 用户 user1 的缓存信息 - - ```sql - REFRESH LDAP for user1; - ``` - -### Keywords - -REFRESH, LDAP - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/REFRESH-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/REFRESH-MATERIALIZED-VIEW.md deleted file mode 100644 index 0695780968a5c..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/REFRESH-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -{ - "title": "REFRESH-MATERIALIZED-VIEW", - "language": "zh-CN" -} ---- - - - -## REFRESH-MATERIALIZED-VIEW - -### Name - -REFRESH MATERIALIZED VIEW - -## 描述 - -该语句用于手动刷新指定的异步物化视图 - -语法: - -```sql -REFRESH MATERIALIZED VIEW mvName=multipartIdentifier (partitionSpec | COMPLETE | AUTO) -``` - -说明: - -异步刷新某个物化视图的数据 - -- AUTO:会计算物化视图的哪些分区和基表不同步(目前,如果基表是外表,会被认为始终和物化视图同步,因此如果基表是外表,需要指定`COMPLETE`或指定要刷新的分区),然后刷新对应的分区 -- COMPLETE:会强制刷新物化视图的所有分区,不会判断分区是否和基表同步 -- partitionSpec:会强制刷新指定的分区,不会判断分区是否和基表同步 - -## 举例 - -1. 刷新物化视图mv1(自动计算要刷新的分区) - - ```sql - REFRESH MATERIALIZED VIEW mv1 AUTO; - ``` - -2. 刷新名字为p_19950801_19950901和p_19950901_19951001的分区 - - ```sql - REFRESH MATERIALIZED VIEW mv1 partitions(p_19950801_19950901,p_19950901_19951001); - ``` - -3. 强制刷新物化视图全部数据 - - ```sql - REFRESH MATERIALIZED VIEW mv1 complete; - ``` - -### Keywords - - REFRESH, MATERIALIZED, VIEW - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/REFRESH.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/REFRESH.md deleted file mode 100644 index 90e61a7481fb2..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/REFRESH.md +++ /dev/null @@ -1,78 +0,0 @@ ---- -{ - "title": "REFRESH", - "language": "zh-CN" -} ---- - - - -## REFRESH - -### Name - -REFRESH - - -## 描述 - -该语句用于刷新指定 Catalog/Database/Table 的元数据。 - -语法: - -```sql -REFRESH CATALOG catalog_name; -REFRESH DATABASE [catalog_name.]database_name; -REFRESH TABLE [catalog_name.][database_name.]table_name; -``` - -刷新Catalog的同时,会强制使对象相关的 Cache 失效。 - -包括Partition Cache、Schema Cache、File Cache等。 - -## 举例 - -1. 刷新 hive catalog - - ```sql - REFRESH CATALOG hive; - ``` - -2. 刷新 database1 - - ```sql - REFRESH DATABASE ctl.database1; - REFRESH DATABASE database1; - ``` - -3. 刷新 table1 - - ```sql - REFRESH TABLE ctl.db.table1; - REFRESH TABLE db.table1; - REFRESH TABLE table1; - ``` - -### Keywords - -REFRESH, CATALOG, DATABASE, TABLE - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/RESUME-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/RESUME-MATERIALIZED-VIEW.md deleted file mode 100644 index 7ff65d4eef3eb..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/RESUME-MATERIALIZED-VIEW.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "RESUME-MATERIALIZED-VIEW", - "language": "zh-CN" -} ---- - - - -## RESUME-MATERIALIZED-VIEW - -### Name - -RESUME MATERIALIZED VIEW - -## 描述 - -该语句用于暂恢复物化视图的定时调度 - -语法: - -```sql -RESUME MATERIALIZED VIEW JOB ON mvName=multipartIdentifier -``` - -## 举例 - -1. 恢复物化视图mv1的定时调度 - - ```sql - RESUME MATERIALIZED VIEW JOB ON mv1; - ``` - -### Keywords - - RESUME, MATERIALIZED, VIEW - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/SWITCH.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/SWITCH.md deleted file mode 100644 index 0f5cfed4b39ad..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/SWITCH.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "SWITCH", - "language": "zh-CN" -} ---- - - - -## SWITCH - -### Name -SWITCH - - -## 描述 - -该语句用于切换数据目录(catalog) - -语法: - -```sql -SWITCH catalog_name -``` - -## 举例 - -1. 切换到数据目录 hive - - ```sql - SWITCH hive; - ``` - -### Keywords - -SWITCH, CATALOG - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/SYNC.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/SYNC.md deleted file mode 100644 index f630f76076df8..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/SYNC.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -{ - "title": "SYNC", - "language": "zh-CN" -} ---- - - - -## SYNC - -### Name - -SYNC - -## 描述 - -用于fe非master节点同步元数据。doris只有master节点才能写fe元数据,其他fe节点写元数据的操作都会转发到master节点。在master完成元数据写入操作后,非master节点replay元数据会有短暂的延迟,可以使用该语句同步元数据。 - -语法: - -```sql -SYNC; -``` - -## 举例 - -1. 同步元数据 - - ```sql - SYNC; - ``` - -### Keywords - - SYNC - -### Best Practice - diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/USE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/USE.md deleted file mode 100644 index bd7e9aa735dbc..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Utility-Statements/USE.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -{ - "title": "USE", - "language": "zh-CN" -} ---- - - - -## 描述 - -USE 命令允许我们在 SQL 环境中切换到特定的数据库或计算组。 - -## 语法 - -```SQL -USE <[CATALOG_NAME].DATABASE_NAME> -``` - -## 示例 - -1. 如果 demo 数据库存在,尝试使用它: - - ```sql - mysql> use demo; - Database changed - ``` - -2. 如果 demo 数据库在hms_catalog的Catalog下存在,尝试切换到hms_catalog, 并使用它: - - ```sql - mysql> use hms_catalog.demo; - Database changed - ``` -3. 如果 demo 数据库在当前目录中存在,并且您想使用名为 'cg1' 的计算组,请尝试访问它: - - ```sql - mysql> use demo@cg1; - Database changed - ``` - -4. 如果您只想使用名为 'cg1' 的计算组,请尝试访问它: - - ```sql - mysql> use @cg1; - Database changed - ``` - -## Relate Commands - -## Keywords - - USE, DATABASE, USER, COMPUTE GROUP \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/ALTER-ROLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/ALTER-ROLE.md new file mode 100644 index 0000000000000..b48cb76b9e6ce --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/ALTER-ROLE.md @@ -0,0 +1,52 @@ +--- +{ + "title": "ALTER ROLE", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于修改一个角色 + +```sql + ALTER ROLE role_name comment; +``` + +## 示例 + +1. 修改一个角色的注释 + + ```sql + ALTER ROLE role1 COMMENT "this is my first role"; + ``` + +## 关键词 + + ALTER, ROLE + +## 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/ALTER-USER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/ALTER-USER.md new file mode 100644 index 0000000000000..c42810803f936 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/ALTER-USER.md @@ -0,0 +1,101 @@ +--- +{ + "title": "ALTER USER", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +ALTER USER 命令用于修改一个用户的账户属性,包括密码、和密码策略等 + +>注意: +> +>从 2.0 版本开始,此命令不再支持修改用户角色,相关操作请使用[GRANT](./GRANT.md)和[REVOKE](./REVOKE.md) + +```sql +ALTER USER [IF EXISTS] user_identity [IDENTIFIED BY 'password'] +[password_policy] +[comment] + +user_identity: + 'user_name'@'host' + +password_policy: + + 1. PASSWORD_HISTORY [n|DEFAULT] + 2. PASSWORD_EXPIRE [DEFAULT|NEVER|INTERVAL n DAY/HOUR/SECOND] + 3. FAILED_LOGIN_ATTEMPTS n + 4. PASSWORD_LOCK_TIME [n DAY/HOUR/SECOND|UNBOUNDED] + 5. ACCOUNT_UNLOCK +``` + +关于 `user_identity`, 和 `password_policy` 的说明,请参阅 `CREATE USER` 命令。 + +`ACCOUNT_UNLOCK` 命令用于解锁一个被锁定的用户。 + +在一个 ALTER USER 命令中,只能同时对以下账户属性中的一项进行修改: + +1. 修改密码 +2. 修改 `PASSWORD_HISTORY` +3. 修改 `PASSWORD_EXPIRE` +4. 修改 `FAILED_LOGIN_ATTEMPTS` 和 `PASSWORD_LOCK_TIME` +5. 解锁用户 + +## 示例 + +1. 修改用户的密码 + + ```sql + ALTER USER jack@'%' IDENTIFIED BY "12345"; + ``` + +2. 修改用户的密码策略 + + ```sql + ALTER USER jack@'%' FAILED_LOGIN_ATTEMPTS 3 PASSWORD_LOCK_TIME 1 DAY; + ``` + +3. 解锁一个用户 + + ```sql + ALTER USER jack@'%' ACCOUNT_UNLOCK + ``` + +4. 修改一个用户的注释 + + ```sql + ALTER USER jack@'%' COMMENT "this is my first user" + ``` + +## 关键词 + +ALTER, USER + +### 最佳实践 + +1. 修改密码策略 + - 修改 `PASSWORD_EXPIRE` 会重置密码过期时间的计时。 + - 修改 `FAILED_LOGIN_ATTEMPTS` 或 `PASSWORD_LOCK_TIME`,会解锁用户。 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/CREATE-ROLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/CREATE-ROLE.md new file mode 100644 index 0000000000000..295958c394287 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/CREATE-ROLE.md @@ -0,0 +1,59 @@ +--- +{ + "title": "CREATE ROLE", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用户创建一个角色 + +```sql + CREATE ROLE role_name [comment]; +``` + +该语句创建一个无权限的角色,可以后续通过 GRANT 命令赋予该角色权限。 + +## 示例 + +1. 创建一个角色 + + ```sql + CREATE ROLE role1; + ``` +2. 创建一个角色并添加注释 + + ```sql + CREATE ROLE role2 COMMENT "this is my first role"; + ``` + +## 关键词 + + CREATE, ROLE + +## 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/CREATE-USER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/CREATE-USER.md new file mode 100644 index 0000000000000..f518f32573497 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/CREATE-USER.md @@ -0,0 +1,136 @@ +--- +{ + "title": "CREATE USER", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +CREATE USER 命令用于创建一个 Doris 用户。 + +```sql +CREATE USER [IF EXISTS] user_identity [IDENTIFIED BY 'password'] +[DEFAULT ROLE 'role_name'] +[password_policy] +[comment] + +user_identity: + 'user_name'@'host' + +password_policy: + + 1. PASSWORD_HISTORY [n|DEFAULT] + 2. PASSWORD_EXPIRE [DEFAULT|NEVER|INTERVAL n DAY/HOUR/SECOND] + 3. FAILED_LOGIN_ATTEMPTS n + 4. PASSWORD_LOCK_TIME [n DAY/HOUR/SECOND|UNBOUNDED] +``` + +在 Doris 中,一个 user_identity 唯一标识一个用户。user_identity 由两部分组成,user_name 和 host,其中 username 为用户名。host 标识用户端连接所在的主机地址。host 部分可以使用 % 进行模糊匹配。如果不指定 host,默认为 '%',即表示该用户可以从任意 host 连接到 Doris。 + +host 部分也可指定为 domain,语法为:'user_name'@['domain'],即使用中括号包围,则 Doris 会认为这个是一个 domain,并尝试解析其 ip 地址。 + +如果指定了角色(ROLE),则会自动将该角色所拥有的权限赋予新创建的这个用户。如果不指定,则该用户默认没有任何权限。指定的 ROLE 必须已经存在。 + +password_policy 是用于指定密码认证登录相关策略的子句,目前支持以下策略: + +1. `PASSWORD_HISTORY` + + 是否允许当前用户重置密码时使用历史密码。如 `PASSWORD_HISTORY 10` 表示禁止使用过去 10 次设置过的密码为新密码。如果设置为 `PASSWORD_HISTORY DEFAULT`,则会使用全局变量 `password_history` 中的值。`0` 表示不启用这个功能。默认为 0。 + +2. `PASSWORD_EXPIRE` + + 设置当前用户密码的过期时间。如 `PASSWORD_EXPIRE INTERVAL 10 DAY` 表示密码会在 10 天后过期。`PASSWORD_EXPIRE NEVER` 表示密码不过期。如果设置为 `PASSWORD_EXPIRE DEFAULT`,则会使用全局变量 `default_password_lifetime` 中的值。默认为 NEVER(或 0),表示不会过期。 + +3. `FAILED_LOGIN_ATTEMPTS` 和 `PASSWORD_LOCK_TIME` + + 设置当前用户登录时,如果使用错误的密码登录 n 次后,账户将被锁定,并设置锁定时间。如 `FAILED_LOGIN_ATTEMPTS 3 PASSWORD_LOCK_TIME 1 DAY` 表示如果 3 次错误登录,则账户会被锁定一天。 + + 被锁定的账户可以通过 ALTER USER 语句主动解锁。 + +## 示例 + +1. 创建一个无密码用户(不指定 host,则等价于 jack@'%') + + ```sql + CREATE USER 'jack'; + ``` + +2. 创建一个有密码用户,允许从 '172.10.1.10' 登陆 + + ```sql + CREATE USER jack@'172.10.1.10' IDENTIFIED BY '123456'; + ``` + +3. 为了避免传递明文,用例 2 也可以使用下面的方式来创建 + + ```sql + CREATE USER jack@'172.10.1.10' IDENTIFIED BY PASSWORD '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9'; + 后面加密的内容可以通过 PASSWORD() 获得到,例如: + SELECT PASSWORD('123456'); + ``` + +4. 创建一个允许从 '192.168' 子网登陆的用户,同时指定其角色为 example_role + + ```sql + CREATE USER 'jack'@'192.168.%' DEFAULT ROLE 'example_role'; + ``` + +5. 创建一个允许从域名 'example_domain' 登陆的用户 + + ```sql + CREATE USER 'jack'@['example_domain'] IDENTIFIED BY '12345'; + ``` + +6. 创建一个用户,并指定一个角色 + + ```sql + CREATE USER 'jack'@'%' IDENTIFIED BY '12345' DEFAULT ROLE 'my_role'; + ``` + +7. 创建一个用户,设定密码 10 天后过期,并且设置如果 3 次错误登录则账户会被锁定一天。 + + ```sql + CREATE USER 'jack' IDENTIFIED BY '12345' PASSWORD_EXPIRE INTERVAL 10 DAY FAILED_LOGIN_ATTEMPTS 3 PASSWORD_LOCK_TIME 1 DAY; + ``` + +8. 创建一个用户,并限制不可重置密码为最近 8 次是用过的密码。 + + ```sql + CREATE USER 'jack' IDENTIFIED BY '12345' PASSWORD_HISTORY 8; + ``` + +9. 创建一个用户并添加注释 + + ```sql + CREATE USER 'jack' COMMENT "this is my first user"; + ``` + +## 关键词 + + CREATE, USER + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/DROP-ROLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/DROP-ROLE.md new file mode 100644 index 0000000000000..bb639a8c7baee --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/DROP-ROLE.md @@ -0,0 +1,53 @@ +--- +{ + "title": "DROP ROLE", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +语句用户删除角色 + +```sql + DROP ROLE [IF EXISTS] role1; +``` + +删除角色不会影响以前属于角色的用户的权限。它仅相当于解耦来自用户的角色。用户从角色获得的权限不会改变 + +## 示例 + +1. 删除一个角色 + +```sql +DROP ROLE role1; +``` + +## 关键词 + + DROP, ROLE + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/DROP-USER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/DROP-USER.md new file mode 100644 index 0000000000000..ae6cfa42b9235 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/DROP-USER.md @@ -0,0 +1,58 @@ +--- +{ + "title": "DROP USER", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +删除一个用户 + +```sql + DROP USER 'user_identity' + + `user_identity`: + + user@'host' + user@['domain'] +``` + + 删除指定的 user identity. + +## 示例 + +1. 删除用户 jack@'192.%' + + ```sql + DROP USER 'jack'@'192.%' + ``` + +## 关键词 + + DROP, USER + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/GRANT-TO.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/GRANT-TO.md new file mode 100644 index 0000000000000..33acc3ca6b8b8 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/GRANT-TO.md @@ -0,0 +1,187 @@ +--- +{ + "title": "GRANT", + "language": "zh-CN" +} +--- + + + +## 描述 + +GRANT 命令用于: + +1. 将指定的权限授予某用户或角色。 +2. 将指定角色授予某用户。 + +## 语法 + +GRANT privilege_list ON priv_level TO user_identity [ROLE role_name] + +GRANT privilege_list ON RESOURCE resource_name TO user_identity [ROLE role_name] + +GRANT privilege_list ON WORKLOAD GROUP workload_group_name TO user_identity [ROLE role_name] + +GRANT privilege_list ON COMPUTE GROUP compute_group_name TO user_identity [ROLE role_name] + +GRANT privilege_list ON STORAGE VAULT storage_vault_name TO user_identity [ROLE role_name] + +GRANT role_list TO user_identity + +## 参数 + +### privilege_list + +需要赋予的权限列表,以逗号分隔。当前支持如下权限: + +- NODE_PRIV:集群节点操作权限,包括节点上下线等操作。 +- ADMIN_PRIV:除 NODE_PRIV 以外的所有权限。 +- GRANT_PRIV:操作权限的权限,包括创建删除用户、角色,授权和撤权,设置密码等。 +- SELECT_PRIV:对指定的库或表的读取权限。 +- LOAD_PRIV:对指定的库或表的导入权限。 +- ALTER_PRIV:对指定的库或表的 schema 变更权限。 +- CREATE_PRIV:对指定的库或表的创建权限。 +- DROP_PRIV:对指定的库或表的删除权限。 +- USAGE_PRIV:对指定资源、Workload Group、Compute Group 的使用权限。 +- SHOW_VIEW_PRIV:查看 view 创建语句的权限。 + +旧版权限转换: +- ALL 和 READ_WRITE 会被转换成:SELECT_PRIV, LOAD_PRIV, ALTER_PRIV, CREATE_PRIV, DROP_PRIV。 +- READ_ONLY 会被转换为 SELECT_PRIV。 + +### priv_level + +支持以下四种形式: + +- *.*.*:权限可以应用于所有 catalog 及其中的所有库表。 +- catalog_name.*.*:权限可以应用于指定 catalog 中的所有库表。 +- catalog_name.db.*:权限可以应用于指定库下的所有表。 +- catalog_name.db.tbl:权限可以应用于指定库下的指定表。 + +### resource_name + +指定 resource 名,支持 % 和 * 匹配所有资源,不支持通配符,比如 res*。 + +### workload_group_name + +指定 workload group 名,支持 % 和 * 匹配所有 workload group,不支持通配符。 + +### compute_group_name + +指定 compute group 名称,支持 % 和 * 匹配所有 compute group,不支持通配符。 + +### storage_vault_name + +指定 storage vault 名称,支持 % 和 * 匹配所有 storage vault,不支持通配符。 + +### user_identity + +指定接收权限的用户。必须为使用 CREATE USER 创建过的 user_identity。user_identity 中的 host 可以是域名,如果是域名的话,权限的生效时间可能会有 1 分钟左右的延迟。 + +### role_name + +指定接收权限的角色。如果指定的角色不存在,则会自动创建。 + +### role_list + +需要赋予的角色列表,以逗号分隔,指定的角色必须存在。 + +## 示例 + +1. 授予所有 catalog 和库表的权限给用户: + + GRANT SELECT_PRIV ON *.*.* TO 'jack'@'%'; + +2. 授予指定库表的权限给用户: + + GRANT SELECT_PRIV,ALTER_PRIV,LOAD_PRIV ON ctl1.db1.tbl1 TO 'jack'@'192.8.%'; + +3. 授予指定库表的权限给角色: + + GRANT LOAD_PRIV ON ctl1.db1.* TO ROLE 'my_role'; + +4. 授予所有 resource 的使用权限给用户: + + GRANT USAGE_PRIV ON RESOURCE * TO 'jack'@'%'; + +5. 授予指定 resource 的使用权限给用户: + + GRANT USAGE_PRIV ON RESOURCE 'spark_resource' TO 'jack'@'%'; + +6. 授予指定 resource 的使用权限给角色: + + GRANT USAGE_PRIV ON RESOURCE 'spark_resource' TO ROLE 'my_role'; + +7. 将指定 role 授予某用户: + + GRANT 'role1','role2' TO 'jack'@'%'; + +8. 将指定 workload group 授予用户: + + GRANT USAGE_PRIV ON WORKLOAD GROUP 'g1' TO 'jack'@'%'; + +9. 匹配所有 workload group 授予用户: + + GRANT USAGE_PRIV ON WORKLOAD GROUP '%' TO 'jack'@'%'; + +10. 将指定 workload group 授予角色: + + GRANT USAGE_PRIV ON WORKLOAD GROUP 'g1' TO ROLE 'my_role'; + +11. 允许用户查看指定 view 的创建语句: + + GRANT SHOW_VIEW_PRIV ON db1.view1 TO 'jack'@'%'; + +12. 授予用户对指定 compute group 的使用权限: + + GRANT USAGE_PRIV ON COMPUTE GROUP 'group1' TO 'jack'@'%'; + +13. 授予角色对指定 compute group 的使用权限: + + GRANT USAGE_PRIV ON COMPUTE GROUP 'group1' TO ROLE 'my_role'; + +14. 授予用户对所有 compute group 的使用权限: + + GRANT USAGE_PRIV ON COMPUTE GROUP '*' TO 'jack'@'%'; + +15. 授予用户对指定 storage vault 的使用权限: + + GRANT USAGE_PRIV ON STORAGE VAULT 'vault1' TO 'jack'@'%'; + +16. 授予角色对指定 storage vault 的使用权限: + + GRANT USAGE_PRIV ON STORAGE VAULT 'vault1' TO ROLE 'my_role'; + +17. 授予用户对所有 storage vault 的使用权限: + + GRANT USAGE_PRIV ON STORAGE VAULT '*' TO 'jack'@'%'; + +## 相关命令 + +- [REVOKE](./REVOKE.md) +- [SHOW GRANTS](../../../sql-manual/sql-statements/account-management/SHOW-GRANTS.md) +- [CREATE ROLE](./CREATE-ROLE.md) +- [CREATE WORKLOAD GROUP](../cluster-management/compute-management/CREATE-WORKLOAD-GROUP.md) +- [CREATE RESOURCE](../cluster-management/compute-management/CREATE-RESOURCE.md) +- [CREATE STORAGE VAULT](../cluster-management/storage-management/CREATE-STORAGE-VAULT.md) + +### 关键词 + + GRANT, WORKLOAD GROUP, COMPUTE GROUP, STORAGE VAULT, RESOURCE \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/REFRESH-LDAP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/REFRESH-LDAP.md new file mode 100644 index 0000000000000..bb97462ffcb48 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/REFRESH-LDAP.md @@ -0,0 +1,66 @@ +--- +{ + "title": "REFRESH LDAP", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于刷新 Doris 中 LDAP 的缓存信息。修改 LDAP 服务中用户信息或者修改 Doris 中 LDAP 用户组对应的 role 权限,可能因为缓存的原因不会立即生效,可通过该语句刷新缓存。Doris 中 LDAP 信息缓存默认时间为 12 小时,可以通过 `SHOW FRONTEND CONFIG LIKE 'ldap_user_cache_timeout_s';` 查看。 + +语法: + +```sql +REFRESH LDAP ALL; +REFRESH LDAP [for user_name]; +``` + +## 示例 + +1. 刷新所有 LDAP 用户缓存信息 + + ```sql + REFRESH LDAP ALL; + ``` + +2. 刷新当前 LDAP 用户的缓存信息 + + ```sql + REFRESH LDAP; + ``` + +3. 刷新指定 LDAP 用户 user1 的缓存信息 + + ```sql + REFRESH LDAP for user1; + ``` + +## 关键词 + +REFRESH, LDAP + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/REVOKE-FROM.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/REVOKE-FROM.md new file mode 100644 index 0000000000000..c4262e83c4a4c --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/REVOKE-FROM.md @@ -0,0 +1,161 @@ +--- +{ + "title": "REVOKE FROM", + "language": "zh-CN" +} +--- + + + +## 描述 + +REVOKE 命令用于: + +1. 撤销某用户或某角色的指定权限。 +2. 撤销先前授予某用户的指定角色。 + +## 语法 + +REVOKE privilege_list ON priv_level FROM user_identity [ROLE role_name] + +REVOKE privilege_list ON RESOURCE resource_name FROM user_identity [ROLE role_name] + +REVOKE privilege_list ON WORKLOAD GROUP workload_group_name FROM user_identity [ROLE role_name] + +REVOKE privilege_list ON COMPUTE GROUP compute_group_name FROM user_identity [ROLE role_name] + +REVOKE privilege_list ON STORAGE VAULT storage_vault_name FROM user_identity [ROLE role_name] + +REVOKE role_list FROM user_identity + +## 参数 + +### privilege_list + +需要撤销的权限列表,以逗号分隔。支持的权限包括: + +- NODE_PRIV:集群节点操作权限 +- ADMIN_PRIV:管理员权限 +- GRANT_PRIV:授权权限 +- SELECT_PRIV:查询权限 +- LOAD_PRIV:数据导入权限 +- ALTER_PRIV:修改权限 +- CREATE_PRIV:创建权限 +- DROP_PRIV:删除权限 +- USAGE_PRIV:使用权限 +- SHOW_VIEW_PRIV:查看视图定义权限 + +### priv_level + +指定权限的作用范围。支持以下格式: + +- *.*.*:所有 catalog、数据库和表 +- catalog_name.*.*:指定 catalog 中的所有数据库和表 +- catalog_name.db.*:指定数据库中的所有表 +- catalog_name.db.tbl:指定数据库中的特定表 + +### resource_name + +指定 resource 名称。支持 % (匹配任意字符串)和 _(匹配任意单个字符)通配符。 + +### workload_group_name + +指定 workload group 名称。支持 % (匹配任意字符串)和 _(匹配任意单个字符)通配符。 + +### compute_group_name + +指定 compute group 名称。支持 % (匹配任意字符串)和 _(匹配任意单个字符)通配符。 + +### storage_vault_name + +指定 storage vault 名称。支持 % (匹配任意字符串)和 _(匹配任意单个字符)通配符。 + + +### user_identity + +指定要撤销权限的用户。必须是使用 CREATE USER 创建的用户。user_identity 中的 host 可以是域名,如果是域名,权限的撤销时间可能会有 1 分钟左右的延迟。 + +### role_name + +指定要撤销权限的角色。该角色必须存在。 + +### role_list + +需要撤销的角色列表,以逗号分隔。指定的所有角色必须存在。 + +## 示例 + +1. 撤销用户在特定数据库上的 SELECT 权限: + + REVOKE SELECT_PRIV ON db1.* FROM 'jack'@'192.%'; + +2. 撤销用户对资源的使用权限: + + REVOKE USAGE_PRIV ON RESOURCE 'spark_resource' FROM 'jack'@'192.%'; + +3. 撤销用户的角色: + + REVOKE 'role1','role2' FROM 'jack'@'192.%'; + +4. 撤销用户对 workload group 的使用权限: + + REVOKE USAGE_PRIV ON WORKLOAD GROUP 'g1' FROM 'jack'@'%'; + +5. 撤销用户对所有 workload group 的使用权限: + + REVOKE USAGE_PRIV ON WORKLOAD GROUP '%' FROM 'jack'@'%'; + +6. 撤销角色对 workload group 的使用权限: + + REVOKE USAGE_PRIV ON WORKLOAD GROUP 'g1' FROM ROLE 'test_role'; + +7. 撤销用户对 compute group 的使用权限: + + REVOKE USAGE_PRIV ON COMPUTE GROUP 'group1' FROM 'jack'@'%'; + +8. 撤销角色对 compute group 的使用权限: + + REVOKE USAGE_PRIV ON COMPUTE GROUP 'group1' FROM ROLE 'my_role'; + +9. 撤销用户对 storage vault 的使用权限: + + REVOKE USAGE_PRIV ON STORAGE VAULT 'vault1' FROM 'jack'@'%'; + +10. 撤销角色对 storage vault 的使用权限: + + REVOKE USAGE_PRIV ON STORAGE VAULT 'vault1' FROM ROLE 'my_role'; + +11. 撤销用户对所有 storage vault 的使用权限: + + REVOKE USAGE_PRIV ON STORAGE VAULT '%' FROM 'jack'@'%'; + +## 相关命令 + +- [GRANT](./GRANT.md) +- [SHOW GRANTS](../../../sql-manual/sql-statements/account-management/SHOW-GRANTS) +- [CREATE ROLE](./CREATE-ROLE.md) +- [CREATE WORKLOAD GROUP](../Administration-Statements/CREATE-WORKLOAD-GROUP.md) +- [CREATE COMPUTE GROUP](../Administration-Statements/CREATE-COMPUTE-GROUP.md) +- [CREATE RESOURCE](../Administration-Statements/CREATE-RESOURCE.md) +- [CREATE STORAGE VAULT](../Administration-Statements/CREATE-STORAGE-VAULT.md) + +## 关键词 + + REVOKE, WORKLOAD GROUP, COMPUTE GROUP, RESOURCE \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SET-LDAP_ADMIN_PASSWORD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SET-LDAP_ADMIN_PASSWORD.md new file mode 100644 index 0000000000000..31d44fb3d54bf --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SET-LDAP_ADMIN_PASSWORD.md @@ -0,0 +1,50 @@ +--- +{ + "title": "SET LDAP_ADMIN_PASSWORD", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +SET LDAP_ADMIN_PASSWORD + +```sql + SET LDAP_ADMIN_PASSWORD = PASSWORD('plain password') +``` + + SET LDAP_ADMIN_PASSWORD 命令用于设置 LDAP 管理员密码。使用 LDAP 认证时,doris 需使用管理员账户和密码来向 LDAP 服务查询登录用户的信息。 + +## 示例 + +1. 设置 LDAP 管理员密码 +```sql +SET LDAP_ADMIN_PASSWORD = PASSWORD('123456') +``` + +## 关键词 + + LDAP, PASSWORD, LDAP_ADMIN_PASSWORD + +### 最佳实践 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SET-PASSWORD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SET-PASSWORD.md new file mode 100644 index 0000000000000..14db5489afb3e --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SET-PASSWORD.md @@ -0,0 +1,63 @@ +--- +{ + "title": "SET PASSWORD", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +SET PASSWORD 命令可以用于修改一个用户的登录密码。如果 [FOR user_identity] 字段不存在,那么修改当前用户的密码 + +```sql +SET PASSWORD [FOR user_identity] = + [PASSWORD('plain password')]|['hashed password'] +``` + +注意这里的 user_identity 必须完全匹配在使用 CREATE USER 创建用户时指定的 user_identity,否则会报错用户不存在。如果不指定 user_identity,则当前用户为 'username'@'ip',这个当前用户,可能无法匹配任何 user_identity。可以通过 SHOW GRANTS 查看当前用户。 + +PASSWORD() 方式输入的是明文密码; 而直接使用字符串,需要传递的是已加密的密码。 +如果修改其他用户的密码,需要具有管理员权限。 + +## 示例 +1. 修改当前用户的密码 + + ```sql + SET PASSWORD = PASSWORD('123456') + SET PASSWORD = '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' + ``` + +2. 修改指定用户密码 + + ```sql + SET PASSWORD FOR 'jack'@'192.%' = PASSWORD('123456') + SET PASSWORD FOR 'jack'@['domain'] = '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' + ``` + +## 关键词 + + SET, PASSWORD + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SET-PROPERTY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SET-PROPERTY.md new file mode 100644 index 0000000000000..fa3bf13be33a9 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SET-PROPERTY.md @@ -0,0 +1,120 @@ +--- +{ + "title": "SET PROPERTY", + "language": "zh-CN" +} +--- + + + +## 描述 + +SET PROPERTY 语句用于设置用户属性,包括分配给用户的资源和导入集群设置。这里设置的用户属性是针对用户的,而不是针对 user_identity。例如,如果通过 CREATE USER 语句创建了两个用户 'jack'@'%' 和 'jack'@'192.%',则使用 SET PROPERTY 语句只能针对用户 'jack',而不是 'jack'@'%' 或 'jack'@'192.%'。 + +## 参数 + +### user + +要设置属性的用户名。如果省略,则为当前用户设置属性。 + +### key + +要设置的属性键。可用的键包括: + +- `max_user_connections`:最大连接数。 +- `max_query_instances`:用户同一时间点执行查询可以使用的 instance 个数。 +- `sql_block_rules`:设置 SQL 阻止规则。设置后,该用户发送的查询如果匹配规则,则会被拒绝。 +- `cpu_resource_limit`:限制查询的 CPU 资源。详见会话变量 `cpu_resource_limit` 的介绍。-1 表示未设置。 +- `exec_mem_limit`:限制查询的内存使用。详见会话变量 `exec_mem_limit` 的介绍。-1 表示未设置。 +- `resource_tags`:指定用户的资源标签权限。 +- `query_timeout`:指定用户的查询超时。 +- `default_workload_group`:指定用户的默认工作负载组。 +- `default_compute_group`:指定用户的默认计算组。 + +注:如果未设置 `cpu_resource_limit` 和 `exec_mem_limit`,则默认使用会话变量中的值。 + +### value + +为指定键设置的值。 + +## 示例 + +1. 设置用户 'jack' 的最大连接数为 1000: + + ```sql + SET PROPERTY FOR 'jack' 'max_user_connections' = '1000'; + ``` + +2. 设置用户 'jack' 的最大查询实例数为 3000: + + ```sql + SET PROPERTY FOR 'jack' 'max_query_instances' = '3000'; + ``` + +3. 为用户 'jack' 设置 SQL 阻止规则: + + ```sql + SET PROPERTY FOR 'jack' 'sql_block_rules' = 'rule1, rule2'; + ``` + +4. 设置用户 'jack' 的 CPU 资源限制: + + ```sql + SET PROPERTY FOR 'jack' 'cpu_resource_limit' = '2'; + ``` + +5. 设置用户 'jack' 的资源标签权限: + + ```sql + SET PROPERTY FOR 'jack' 'resource_tags.location' = 'group_a, group_b'; + ``` + +6. 设置用户 'jack' 的内存使用限制(以字节为单位): + + ```sql + SET PROPERTY FOR 'jack' 'exec_mem_limit' = '2147483648'; + ``` + +7. 设置用户 'jack' 的查询超时时间(以秒为单位): + + ```sql + SET PROPERTY FOR 'jack' 'query_timeout' = '500'; + ``` + +8. 设置用户 'jack' 的默认工作负载组: + + ```sql + SET PROPERTY FOR 'jack' 'default_workload_group' = 'group1'; + ``` + +9. 设置用户 'jack' 的默认计算组: + + ```sql + SET PROPERTY FOR 'jack' 'default_compute_group' = 'compute_group1'; + ``` + +## 相关命令 + +- [CREATE USER](./CREATE-USER.md) +- [SHOW PROPERTY](../../../sql-manual/sql-statements/account-management/SHOW-PROPERTY) + +## 关键词 + + SET, PROPERTY, WORKLOAD GROUP, COMPUTE GROUP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SHOW-GRANTS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SHOW-GRANTS.md new file mode 100644 index 0000000000000..3bb551d4099c5 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SHOW-GRANTS.md @@ -0,0 +1,71 @@ +--- +{ + "title": "SHOW GRANTS", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + + 该语句用于查看用户权限。 + +语法: + +```sql +SHOW [ALL] GRANTS [FOR user_identity]; +``` + +说明: + +1. SHOW ALL GRANTS 可以查看所有用户的权限。 +2. 如果指定 user_identity,则查看该指定用户的权限。且该 user_identity 必须为通过 CREATE USER 命令创建的。 +3. 如果不指定 user_identity,则查看当前用户的权限。 + +## 示例 + +1. 查看所有用户权限信息 + + ```sql + SHOW ALL GRANTS; + ``` + +2. 查看指定 user 的权限 + + ```sql + SHOW GRANTS FOR jack@'%'; + ``` + +3. 查看当前用户的权限 + + ```sql + SHOW GRANTS; + ``` + +## 关键词 + + SHOW, GRANTS + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SHOW-PRIVILEGES.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SHOW-PRIVILEGES.md new file mode 100644 index 0000000000000..29b68ee32629b --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SHOW-PRIVILEGES.md @@ -0,0 +1,52 @@ +--- +{ + "title": "SHOW PRIVILEGES", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于展示所有权限项。 + +语法: + +```SQL +SHOW PRIVILEGES +``` + +## 示例 + +1. 查看所有权限项 + + ```SQL + SHOW PRIVILEGES + ``` + +## 关键词 + + SHOW, PRIVILEGES + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SHOW-PROPERTY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SHOW-PROPERTY.md new file mode 100644 index 0000000000000..b1e7f1e721b36 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SHOW-PROPERTY.md @@ -0,0 +1,115 @@ +--- +{ + "title": "SHOW PROPERTY", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句用于查看用户的属性 + +语法: + +```sql +SHOW PROPERTY [FOR user] [LIKE key] +SHOW ALL PROPERTIES [LIKE key] +``` + +* `user` + + 查看指定用户的属性。如果未指定,请检查当前用户的。 + +* `LIKE` + + 模糊匹配可以通过属性名来完成。 + +* `ALL` + + 查看所有用户的属性 (从 2.0.3 版本开始支持) + +返回结果说明: + +```sql +mysql> show property like'%connection%'; ++----------------------+-------+ +| Key | Value | ++----------------------+-------+ +| max_user_connections | 100 | ++----------------------+-------+ +1 row in set (0.01 sec) +``` + +* `Key` + + 属性名。 + +* `Value` + + 属性值。 + + +```sql +mysql> show all properties like "%connection%"; ++-------------------+--------------------------------------+ +| User | Properties | ++-------------------+--------------------------------------+ +| root | {"max_user_connections": "100"} | +| admin | {"max_user_connections": "100"} | +| default_cluster:a | {"max_user_connections": "1000"} | ++-------------------+--------------------------------------+ +``` + +* `User` + + 用户名。 + +* `Properties` + + 对应用户各个 property 的 key:value. + +## 示例 + +1. 查看 jack 用户的属性 + + ```sql + SHOW PROPERTY FOR 'jack' + ``` + +2. 查看 jack 用户导入 cluster 相关属性 + + ```sql + SHOW PROPERTY FOR 'jack' LIKE '%load_cluster%' + ``` + +3. 查看所有用户导入 cluster 相关属性 + + ```sql + SHOW ALL PROPERTIES LIKE '%load_cluster%' + ``` + +## 关键词 + + SHOW, PROPERTY, ALL + +### 最佳实践 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SHOW-ROLES.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SHOW-ROLES.md new file mode 100644 index 0000000000000..8ffe680b9225f --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/account-management/SHOW-ROLES.md @@ -0,0 +1,53 @@ +--- +{ + "title": "SHOW ROLES", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于展示所有已创建的角色信息,包括角色名称,包含的用户以及权限。 + +语法: + +```SQL +SHOW ROLES +``` + +## 示例 + +1. 查看已创建的角色 + + ```SQL + SHOW ROLES + ``` + +## 关键词 + + SHOW, ROLES + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/catalog/ALTER-CATALOG.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/catalog/ALTER-CATALOG.md new file mode 100644 index 0000000000000..ec39807a32225 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/catalog/ALTER-CATALOG.md @@ -0,0 +1,89 @@ +--- +{ + "title": "ALTER CATALOG", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于设置指定数据目录的属性。(仅管理员使用) + +1) 重命名数据目录 + +```sql +ALTER CATALOG catalog_name RENAME new_catalog_name; +``` +注意: +- `internal` 是内置数据目录,不允许重命名 +- 对 `catalog_name` 拥有 Alter 权限才允许对其重命名 +- 重命名数据目录后,如需要,请使用 REVOKE 和 GRANT 命令修改相应的用户权限。 + +2) 设置数据目录属性 + +```sql +ALTER CATALOG catalog_name SET PROPERTIES ('key1' = 'value1' [, 'key' = 'value2']); +``` + +更新指定属性的值为指定的 value。如果 SET PROPERTIES 从句中的 key 在指定 catalog 属性中不存在,则新增此 key。 + +注意: +- 不可更改数据目录类型,即 `type` 属性 +- 不可更改内置数据目录 `internal` 的属性 + +3) 修改数据目录注释 + +```sql +ALTER CATALOG catalog_name MODIFY COMMENT "new catalog comment"; +``` + +注意: +- `internal` 是内置数据目录,不允许修改注释 + +## 示例 + +1. 将数据目录 ctlg_hive 重命名为 hive + +```sql +ALTER CATALOG ctlg_hive RENAME hive; +``` + +3. 更新名为 hive 数据目录的属性 `hive.metastore.uris` + +```sql +ALTER CATALOG hive SET PROPERTIES ('hive.metastore.uris'='thrift://172.21.0.1:9083'); +``` + +4. 更改名为 hive 数据目录的注释 + +```sql +ALTER CATALOG hive MODIFY COMMENT "new catalog comment"; +``` + +## 关键词 + +ALTER,CATALOG,RENAME,PROPERTY + +### 最佳实践 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/catalog/CREATE-CATALOG.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/catalog/CREATE-CATALOG.md new file mode 100644 index 0000000000000..e92035e4c6c43 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/catalog/CREATE-CATALOG.md @@ -0,0 +1,177 @@ +--- +{ + "title": "CREATE CATALOG", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于创建外部数据目录(catalog) + +语法: + +```sql +CREATE CATALOG [IF NOT EXISTS] catalog_name [comment] + PROPERTIES ("key"="value", ...); +``` + +* hms:Hive MetaStore +* es:Elasticsearch +* jdbc:数据库访问的标准接口 (JDBC), 当前支持 MySQL 和 PostgreSQL + +## 示例 + +1. 新建数据目录 hive + + ```sql + CREATE CATALOG hive comment 'hive catalog' PROPERTIES ( + 'type'='hms', + 'hive.metastore.uris' = 'thrift://127.0.0.1:7004', + 'dfs.nameservices'='HANN', + 'dfs.ha.namenodes.HANN'='nn1,nn2', + 'dfs.namenode.rpc-address.HANN.nn1'='nn1_host:rpc_port', + 'dfs.namenode.rpc-address.HANN.nn2'='nn2_host:rpc_port', + 'dfs.client.failover.proxy.provider.HANN'='org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider' + ); + ``` + +2. 新建数据目录 es + + ```sql + CREATE CATALOG es PROPERTIES ( + "type"="es", + "hosts"="http://127.0.0.1:9200" + ); + ``` + +3. 新建数据目录 jdbc + + **mysql** + + ```sql + CREATE CATALOG jdbc PROPERTIES ( + "type"="jdbc", + "user"="root", + "password"="123456", + "jdbc_url" = "jdbc:mysql://127.0.0.1:3316/doris_test?useSSL=false", + "driver_url" = "https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/jdbc_driver/mysql-connector-java-8.0.25.jar", + "driver_class" = "com.mysql.cj.jdbc.Driver" + ); + ``` + + **postgresql** + + ```sql + CREATE CATALOG jdbc PROPERTIES ( + "type"="jdbc", + "user"="postgres", + "password"="123456", + "jdbc_url" = "jdbc:postgresql://127.0.0.1:5432/demo", + "driver_url" = "file:///path/to/postgresql-42.5.1.jar", + "driver_class" = "org.postgresql.Driver" + ); + ``` + + **clickhouse** + + ```sql + CREATE CATALOG jdbc PROPERTIES ( + "type"="jdbc", + "user"="default", + "password"="123456", + "jdbc_url" = "jdbc:clickhouse://127.0.0.1:8123/demo", + "driver_url" = "file:///path/to/clickhouse-jdbc-0.3.2-patch11-all.jar", + "driver_class" = "com.clickhouse.jdbc.ClickHouseDriver" + ) + ``` + + **oracle** + ```sql + CREATE CATALOG jdbc PROPERTIES ( + "type"="jdbc", + "user"="doris", + "password"="123456", + "jdbc_url" = "jdbc:oracle:thin:@127.0.0.1:1521:helowin", + "driver_url" = "file:///path/to/ojdbc8.jar", + "driver_class" = "oracle.jdbc.driver.OracleDriver" + ); + ``` + + **SQLServer** + ```sql + CREATE CATALOG sqlserver_catalog PROPERTIES ( + "type"="jdbc", + "user"="SA", + "password"="Doris123456", + "jdbc_url" = "jdbc:sqlserver://localhost:1433;DataBaseName=doris_test", + "driver_url" = "file:///path/to/mssql-jdbc-11.2.3.jre8.jar", + "driver_class" = "com.microsoft.sqlserver.jdbc.SQLServerDriver" + ); + ``` + + **SAP HANA** + ```sql + CREATE CATALOG saphana_catalog PROPERTIES ( + "type"="jdbc", + "user"="SYSTEM", + "password"="SAPHANA", + "jdbc_url" = "jdbc:sap://localhost:31515/TEST", + "driver_url" = "file:///path/to/ngdbc.jar", + "driver_class" = "com.sap.db.jdbc.Driver" + ); + ``` + + **Trino** + ```sql + CREATE CATALOG trino_catalog PROPERTIES ( + "type"="jdbc", + "user"="hadoop", + "password"="", + "jdbc_url" = "jdbc:trino://localhost:8080/hive", + "driver_url" = "file:///path/to/trino-jdbc-389.jar", + "driver_class" = "io.trino.jdbc.TrinoDriver" + ); + ``` + + **OceanBase** + ```sql + CREATE CATALOG oceanbase_catalog PROPERTIES ( + "type"="jdbc", + "user"="root", + "password"="", + "jdbc_url" = "jdbc:oceanbase://localhost:2881/demo", + "driver_url" = "file:///path/to/oceanbase-client-2.4.2.jar", + "driver_class" = "com.oceanbase.jdbc.Driver" + ); + ``` + +## 关键词 + +CREATE, CATALOG + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/catalog/DROP-CATALOG.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/catalog/DROP-CATALOG.md new file mode 100644 index 0000000000000..2c82a15098546 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/catalog/DROP-CATALOG.md @@ -0,0 +1,52 @@ +--- +{ + "title": "DROP CATALOG", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于删除外部数据目录(catalog) + +语法: + +```sql +DROP CATALOG [IF EXISTS] catalog_name; +``` + +## 示例 + +1. 删除数据目录 hive + + ```sql + DROP CATALOG hive; + ``` + +## 关键词 + +DROP, CATALOG + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/catalog/REFRESH.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/catalog/REFRESH.md new file mode 100644 index 0000000000000..7ed3adcff6360 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/catalog/REFRESH.md @@ -0,0 +1,76 @@ +--- +{ + "title": "REFRESH", + "language": "zh-CN" +} +--- + + + + + + + + +## 描述 + +该语句用于刷新指定 Catalog/Database/Table 的元数据。 + +语法: + +```sql +REFRESH CATALOG catalog_name; +REFRESH DATABASE [catalog_name.]database_name; +REFRESH TABLE [catalog_name.][database_name.]table_name; +``` + +刷新 Catalog 的同时,会强制使对象相关的 Cache 失效。 + +包括 Partition Cache、Schema Cache、File Cache 等。 + +## 示例 + +1. 刷新 hive catalog + + ```sql + REFRESH CATALOG hive; + ``` + +2. 刷新 database1 + + ```sql + REFRESH DATABASE ctl.database1; + REFRESH DATABASE database1; + ``` + +3. 刷新 table1 + + ```sql + REFRESH TABLE ctl.db.table1; + REFRESH TABLE db.table1; + REFRESH TABLE table1; + ``` + +## 关键词 + +REFRESH, CATALOG, DATABASE, TABLE + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/catalog/SHOW-CATALOG.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/catalog/SHOW-CATALOG.md new file mode 100644 index 0000000000000..48d22f6ddeb62 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/catalog/SHOW-CATALOG.md @@ -0,0 +1,79 @@ +--- +{ + "title": "SHOW-CATALOGS", + "language": "zh-CN" +} +--- + + + + + +### 描述 + +该语句用于显示已存在是数据目录(catalog) + +语法: + +```sql +SHOW CATALOGS [LIKE] +``` + +说明: + +LIKE:可按照 CATALOG 名进行模糊查询 + +返回结果说明: + +* CatalogId:数据目录唯一 ID +* CatalogName:数据目录名称。其中 internal 是默认内置的 catalog,不可修改。 +* Type:数据目录类型。 +* IsCurrent: 是否为当前正在使用的数据目录。 + +### 示例 + +1. 查看当前已创建的数据目录 + + ```sql + SHOW CATALOGS; + +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ + | CatalogId | CatalogName | Type | IsCurrent | CreateTime | LastUpdateTime | Comment | + +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ + | 130100 | hive | hms | | 2023-12-25 16:11:41.687 | 2023-12-25 20:43:18 | NULL | + | 0 | internal | internal | yes | UNRECORDED | NULL | Doris internal catalog | + +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ + ``` + +2. 按照目录名进行模糊搜索 + + ```sql + SHOW CATALOGS LIKE 'hi%'; + +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ + | CatalogId | CatalogName | Type | IsCurrent | CreateTime | LastUpdateTime | Comment | + +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ + | 130100 | hive | hms | | 2023-12-25 16:11:41.687 | 2023-12-25 20:43:18 | NULL | + +-----------+-------------+----------+-----------+-------------------------+---------------------+------------------------+ + ``` + +### 关键词 + +SHOW, CATALOG, CATALOGS + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/catalog/SHOW-CREATE-CATALOG.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/catalog/SHOW-CREATE-CATALOG.md new file mode 100644 index 0000000000000..8c2e750b76783 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/catalog/SHOW-CREATE-CATALOG.md @@ -0,0 +1,59 @@ +--- +{ + "title": "SHOW CREATE CATALOG", + "language": "zh-CN" +} +--- + + + + + + + + +## 描述 + +该语句查看 doris 数据目录的创建语句。 + +语法: + +```sql +SHOW CREATE CATALOG catalog_name; +``` + +说明: + +- `catalog_name`: 为 doris 中存在的数据目录的名称。 + +## 示例 + +1. 查看 doris 中 hive 数据目录的创建语句 + + ```sql + SHOW CREATE CATALOG hive; + ``` + +## 关键词 + + SHOW, CREATE, CATALOG + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/character-set/SHOW-CHARSET.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/character-set/SHOW-CHARSET.md new file mode 100644 index 0000000000000..e40a76d453e5c --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/character-set/SHOW-CHARSET.md @@ -0,0 +1,57 @@ +--- +{ + "title": "SHOW CHARSET", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +"SHOW CHARACTER" 命令用于显示当前数据库管理系统中可用的字符集(character set)以及与每个字符集相关联的一些属性。这些属性可能包括字符集的名称、默认排序规则、最大字节长度等。通过运行 "SHOW CHARACTER" 命令,可以查看系统中支持的字符集列表及其详细信息。 + +SHOW CHARACTER 命令返回以下字段: + + +Charset:字符集 +Description:描述 +Default Collation:默认校对名称 +Maxlen:最大字节长度 + +## 示例 + +```sql +mysql> show charset; + +| Charset | Description | Default collation | Maxlen | +|-----------|-----------------|-------------------|--------| +| utf8mb4 | UTF-8 Unicode | utf8mb4_0900_bin | 4 | + +``` + +## 关键词 + + SHOW, CHARSET + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/character-set/SHOW-COLLATION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/character-set/SHOW-COLLATION.md new file mode 100644 index 0000000000000..f69ee45ad64c6 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/character-set/SHOW-COLLATION.md @@ -0,0 +1,66 @@ +--- +{ + "title": "SHOW COLLATION", + "language": "zh-CN" +} +--- + + + + +## 描述 + + +在 Doris 中,`SHOW COLLATION` 命令用于显示数据库中可用的字符集校对。校对是一组决定数据如何排序和比较的规则。这些规则会影响字符数据的存储和检索。Doris 目前主要支持 utf8mb4_0900_bin 这一种校对方式。 + +## 语法 + +``` +SHOW COLLATION +``` + +## 返回结果 + +`SHOW COLLATION` 命令返回以下字段: + +* Collation:校对名称 +* Charset:字符集 +* Id:校对的 ID +* Default:是否是该字符集的默认校对 +* Compiled:是否已编译 +* Sortlen:排序长度 + +## 示例 + +```sql +how collation; +``` + +``` ++------------------+---------+------+---------+----------+---------+ +| Collation | Charset | Id | Default | Compiled | Sortlen | ++------------------+---------+------+---------+----------+---------+ +| utf8mb4_0900_bin | utf8mb4 | 33 | Yes | Yes | 1 | ++------------------+---------+------+---------+----------+---------+ +``` + +## 注意事项 + +在 Doris 中,虽然兼容 MySQL 的设置 collation 的命令。但是实际并不会生效。执行时,永远会使用 utf8mb4_0900_bin 作为比较规则。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/ALTER-RESOURCE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/ALTER-RESOURCE.md new file mode 100644 index 0000000000000..171cfc7bef13e --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/ALTER-RESOURCE.md @@ -0,0 +1,72 @@ +--- +{ +"title": "ALTER RESOURCE", +"language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于修改一个已有的资源。仅 root 或 admin 用户可以修改资源。 +语法: +```sql +ALTER RESOURCE 'resource_name' +PROPERTIES ("key"="value", ...); +``` +注意:resource type 不支持修改。 + +## 示例 + +1. 修改名为 spark0 的 Spark 资源的工作目录: +```sql +ALTER RESOURCE 'spark0' PROPERTIES ("working_dir" = "hdfs://127.0.0.1:10000/tmp/doris_new"); +``` +2. 修改名为 remote_s3 的 S3 资源的最大连接数: +```sql +ALTER RESOURCE 'remote_s3' PROPERTIES ("s3.connection.maximum" = "100"); +``` +3. 修改冷热分层 S3 资源相关信息 +- 支持修改项 + - `s3.access_key` s3 的 ak 信息 + - `s3.secret_key` s3 的 sk 信息 + - `s3.session_token` s3 的 session token 信息 + - `s3.connection.maximum` s3 最大连接数,默认 50 + - `s3.connection.timeout` s3 连接超时时间,默认 1000ms + - `s3.connection.request.timeout` s3 请求超时时间,默认 3000ms +- 禁止修改项 + - `s3.region` + - `s3.bucket"` + - `s3.root.path` + - `s3.endpoint` + +```sql + ALTER RESOURCE "showPolicy_1_resource" PROPERTIES("s3.connection.maximum" = "1111"); +``` +## 关键词 + +```sql +ALTER, RESOURCE +``` + +### 最佳实践 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/ALTER-WORKLOAD-GROUP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/ALTER-WORKLOAD-GROUP.md new file mode 100644 index 0000000000000..3847033147b39 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/ALTER-WORKLOAD-GROUP.md @@ -0,0 +1,66 @@ +--- +{ +"title": "ALTER WORKLOAD GROUP", +"language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于修改资源组。 + +语法: + +```sql +ALTER WORKLOAD GROUP "rg_name" +PROPERTIES ( + property_list +); +``` + +注意: + +* 修改 memory_limit 属性时不可使所有 memory_limit 值的总和超过 100%; +* 支持修改部分属性,例如只修改 cpu_share 的话,properties 里只填 cpu_share 即可。 + +## 示例 + +1. 修改名为 g1 的资源组: + + ```sql + alter workload group g1 + properties ( + "cpu_share"="30", + "memory_limit"="30%" + ); + ``` + +## 关键词 + +```sql +ALTER, WORKLOAD , GROUP +``` + +### 最佳实践 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/ALTER-WORKLOAD-POLICY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/ALTER-WORKLOAD-POLICY.md new file mode 100644 index 0000000000000..f231737cd690e --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/ALTER-WORKLOAD-POLICY.md @@ -0,0 +1,59 @@ +--- +{ +"title": "ALTER WORKLOAD POLICY", +"language": "zh-CN" +} +--- + + + + + +## 描述 + +修改一个 Workload Group 的属性,目前只支持修改属性,不支持修改 action 和 condition。 + +## 语法 + +```sql +ALTER WORKLOAD POLICY PROPERTIES( ) +``` + +## 必选参数 + +1. ``: Workload Policy 的 Name + +2. ``: + + - enabled,取值为 true 或 false,默认值为 true,表示当前 Policy 处于启用状态,false 表示当前 Policy 处于禁用状态。 + - priority,取值范围为 0 到 100 的正整数,默认值为 0,代表 Policy 的优先级,该值越大,优先级越高。这个属性的主要作用是,当匹配到多个 Policy 时,选择优先级最高的 Policy。 + - workload_group,目前一个 Policy 可以绑定一个 Workload Group,代表这个 Policy 只对某个 Workload Group 生效。默认为空,代表对所有查询生效。 + +## 权限控制 + +至少具有`ADMIN_PRIV`权限 + +## 示例 + +1. 禁用一个 Workload Policy + + ```Java + alter workload policy cancel_big_query properties('enabled'='false') + ``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/CREATE-RESOURCE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/CREATE-RESOURCE.md new file mode 100644 index 0000000000000..d60b81026915c --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/CREATE-RESOURCE.md @@ -0,0 +1,245 @@ +--- +{ + "title": "CREATE RESOURCE", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于创建资源。仅 root 或 admin 用户可以创建资源。目前支持 Spark, ODBC, S3, JDBC, HDFS, HMS, ES 外部资源。 +将来其他外部资源可能会加入到 Doris 中使用,如 Spark/GPU 用于查询,HDFS/S3 用于外部存储,MapReduce 用于 ETL 等。 + +语法: + +```sql +CREATE [EXTERNAL] RESOURCE "resource_name" +PROPERTIES ("key"="value", ...); +``` + +说明: + +- PROPERTIES 中需要指定资源的类型 "type" = "[spark|odbc_catalog|s3|jdbc|hdfs|hms|es]"。 +- 根据资源类型的不同 PROPERTIES 有所不同,具体见示例。 + +## 示例 + +1. 创建 yarn cluster 模式,名为 spark0 的 Spark 资源。 + + ```sql + CREATE EXTERNAL RESOURCE "spark0" + PROPERTIES + ( + "type" = "spark", + "spark.master" = "yarn", + "spark.submit.deployMode" = "cluster", + "spark.jars" = "xxx.jar,yyy.jar", + "spark.files" = "/tmp/aaa,/tmp/bbb", + "spark.executor.memory" = "1g", + "spark.yarn.queue" = "queue0", + "spark.hadoop.yarn.resourcemanager.address" = "127.0.0.1:9999", + "spark.hadoop.fs.defaultFS" = "hdfs://127.0.0.1:10000", + "working_dir" = "hdfs://127.0.0.1:10000/tmp/doris", + "broker" = "broker0", + "broker.username" = "user0", + "broker.password" = "password0" + ); + ``` + + Spark 相关参数如下: + - spark.master: 必填,目前支持 yarn,spark://host:port。 + - spark.submit.deployMode: Spark 程序的部署模式,必填,支持 cluster,client 两种。 + - spark.hadoop.yarn.resourcemanager.address: master 为 yarn 时必填。 + - spark.hadoop.fs.defaultFS: master 为 yarn 时必填。 + - 其他参数为可选,参考[这里](http://spark.apache.org/docs/latest/configuration.html) + + + +Spark 用于 ETL 时需要指定 working_dir 和 broker。说明如下: + +- working_dir: ETL 使用的目录。spark 作为 ETL 资源使用时必填。例如:hdfs://host:port/tmp/doris。 +- broker: broker 名字。spark 作为 ETL 资源使用时必填。需要使用`ALTER SYSTEM ADD BROKER` 命令提前完成配置。 +- broker.property_key: broker 读取 ETL 生成的中间文件时需要指定的认证信息等。 + +2. 创建 ODBC resource + + ```sql + CREATE EXTERNAL RESOURCE `oracle_odbc` + PROPERTIES ( + "type" = "odbc_catalog", + "host" = "192.168.0.1", + "port" = "8086", + "user" = "test", + "password" = "test", + "database" = "test", + "odbc_type" = "oracle", + "driver" = "Oracle 19 ODBC driver" + ); + ``` + + ODBC 的相关参数如下: + - hosts:外表数据库的 IP 地址 + - driver:ODBC 外表的 Driver 名,该名字需要和 be/conf/odbcinst.ini 中的 Driver 名一致。 + - odbc_type:外表数据库的类型,当前支持 oracle, mysql, postgresql + - user:外表数据库的用户名 + - password:对应用户的密码信息 + - charset: 数据库链接的编码信息 + - 另外还支持每个 ODBC Driver 实现自定义的参数,参见对应 ODBC Driver 的说明 + +3. 创建 S3 resource + + ```sql + CREATE RESOURCE "remote_s3" + PROPERTIES + ( + "type" = "s3", + "s3.endpoint" = "bj.s3.com", + "s3.region" = "bj", + "s3.access_key" = "bbb", + "s3.secret_key" = "aaaa", + -- the followings are optional + "s3.connection.maximum" = "50", + "s3.connection.request.timeout" = "3000", + "s3.connection.timeout" = "1000" + ); + ``` + + 如果 s3 reource 在[冷热分层](../../../../../docs/advanced/cold_hot_separation.md)中使用,需要添加额外的字段。 + ```sql + CREATE RESOURCE "remote_s3" + PROPERTIES + ( + "type" = "s3", + "s3.endpoint" = "bj.s3.com", + "s3.region" = "bj", + "s3.access_key" = "bbb", + "s3.secret_key" = "aaaa", + -- required by cooldown + "s3.root.path" = "/path/to/root", + "s3.bucket" = "test-bucket" + ); + ``` + + S3 相关参数如下: + - 必需参数 + - `s3.endpoint`:s3 endpoint + - `s3.region`:s3 region + - `s3.root.path`:s3 根目录 + - `s3.access_key`:s3 access key + - `s3.secret_key`:s3 secret key + - `s3.bucket`:s3 的桶名 + - 可选参数 + - `s3.connection.maximum`:s3 最大连接数量,默认为 50 + - `s3.connection.request.timeout`:s3 请求超时时间,单位毫秒,默认为 3000 + - `s3.connection.timeout`:s3 连接超时时间,单位毫秒,默认为 1000 + +4. 创建 JDBC resource + + ```sql + CREATE RESOURCE mysql_resource PROPERTIES ( + "type"="jdbc", + "user"="root", + "password"="123456", + "jdbc_url" = "jdbc:mysql://127.0.0.1:3316/doris_test?useSSL=false", + "driver_url" = "https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/jdbc_driver/mysql-connector-java-8.0.25.jar", + "driver_class" = "com.mysql.cj.jdbc.Driver" + ); + ``` + + JDBC 的相关参数如下: + - user:连接数据库使用的用户名 + - password:连接数据库使用的密码 + - jdbc_url: 连接到指定数据库的标识符 + - driver_url: jdbc 驱动包的 url + - driver_class: jdbc 驱动类 + +5. 创建 HDFS resource + + ```sql + CREATE RESOURCE hdfs_resource PROPERTIES ( + "type"="hdfs", + "hadoop.username"="user", + "dfs.nameservices" = "my_ha", + "dfs.ha.namenodes.my_ha" = "my_namenode1, my_namenode2", + "dfs.namenode.rpc-address.my_ha.my_namenode1" = "nn1_host:rpc_port", + "dfs.namenode.rpc-address.my_ha.my_namenode2" = "nn2_host:rpc_port", + "dfs.client.failover.proxy.provider.my_ha" = "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider" + ); + ``` + + HDFS 相关参数如下: + - fs.defaultFS: namenode 地址和端口 + - hadoop.username: hdfs 用户名 + - dfs.nameservices: name service 名称,与 hdfs-site.xml 保持一致 + - dfs.ha.namenodes.[nameservice ID]: namenode 的 id 列表,与 hdfs-site.xml 保持一致 + - dfs.namenode.rpc-address.[nameservice ID].[name node ID]: Name node 的 rpc 地址,数量与 namenode 数量相同,与 hdfs-site.xml 保持一致 + +6. 创建 HMS resource + + HMS resource 用于 [hms catalog](../../../../lakehouse/datalake-analytics/hive) + ```sql + CREATE RESOURCE hms_resource PROPERTIES ( + 'type'='hms', + 'hive.metastore.uris' = 'thrift://127.0.0.1:7004', + 'dfs.nameservices'='HANN', + 'dfs.ha.namenodes.HANN'='nn1,nn2', + 'dfs.namenode.rpc-address.HANN.nn1'='nn1_host:rpc_port', + 'dfs.namenode.rpc-address.HANN.nn2'='nn2_host:rpc_port', + 'dfs.client.failover.proxy.provider.HANN'='org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider' + ); + ``` + + HMS 的相关参数如下: + - hive.metastore.uris: hive metastore server 地址 + 可选参数: + - dfs.*: 如果 hive 数据存放在 hdfs,需要添加类似 HDFS resource 的参数,也可以将 hive-site.xml 拷贝到 fe/conf 目录下 + - s3.*: 如果 hive 数据存放在 s3,需要添加类似 S3 resource 的参数。如果连接 [阿里云 Data Lake Formation](https://www.aliyun.com/product/bigdata/dlf),可以将 hive-site.xml 拷贝到 fe/conf 目录下 + +7. 创建 ES resource + + ```sql + CREATE RESOURCE es_resource PROPERTIES ( + "type"="es", + "hosts"="http://127.0.0.1:29200", + "nodes_discovery"="false", + "enable_keyword_sniff"="true" + ); + ``` + + ES 的相关参数如下: + - hosts: ES 地址,可以是一个或多个,也可以是 ES 的负载均衡地址 + - user: ES 用户名 + - password: 对应用户的密码信息 + - enable_docvalue_scan: 是否开启通过 ES/Lucene 列式存储获取查询字段的值,默认为 true + - enable_keyword_sniff: 是否对 ES 中字符串分词类型 text.fields 进行探测,通过 keyword 进行查询 (默认为 true,设置为 false 会按照分词后的内容匹配) + - nodes_discovery: 是否开启 ES 节点发现,默认为 true,在网络隔离环境下设置为 false,只连接指定节点 + - http_ssl_enabled: ES 是否开启 https 访问模式,目前在 fe/be 实现方式为信任所有 + +## 关键词 + + CREATE, RESOURCE + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-GROUP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-GROUP.md new file mode 100644 index 0000000000000..04cc28e2e1da2 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-GROUP.md @@ -0,0 +1,70 @@ +--- +{ + "title": "CREATE WORKLOAD GROUP", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于创建资源组。资源组可实现单个 be 上 cpu 资源和内存资源的隔离。 + +语法: + +```sql +CREATE WORKLOAD GROUP [IF NOT EXISTS] "rg_name" +PROPERTIES ( + property_list +); +``` + +说明: + +property_list 支持的属性: + +* cpu_share: 必选,用于设置资源组获取 cpu 时间的多少,可以实现 cpu 资源软隔离。cpu_share 是相对值,表示正在运行的资源组可获取 cpu 资源的权重。例如,用户创建了 3 个资源组 rg-a、rg-b 和 rg-c,cpu_share 分别为 10、30、40,某一时刻 rg-a 和 rg-b 正在跑任务,而 rg-c 没有任务,此时 rg-a 可获得 (10 / (10 + 30)) = 25% 的 cpu 资源,而资源组 rg-b 可获得 75% 的 cpu 资源。如果系统只有一个资源组正在运行,则不管其 cpu_share 的值为多少,它都可以获取全部的 cpu 资源。 + +* memory_limit: 必选,用于设置资源组可以使用 be 内存的百分比。资源组内存限制的绝对值为:`物理内存 * mem_limit * memory_limit`,其中 mem_limit 为 be 配置项。系统所有资源组的 memory_limit 总合不可超过 100%。资源组在绝大多数情况下保证组内任务可使用 memory_limit 的内存,当资源组内存使用超出该限制后,组内内存占用较大的任务可能会被 cancel 以释放超出的内存,参考 enable_memory_overcommit。 + +* enable_memory_overcommit: 可选,用于开启资源组内存软隔离,默认为 false。如果设置为 false,则该资源组为内存硬隔离,系统检测到资源组内存使用超出限制后将立即 cancel 组内内存占用最大的若干个任务,以释放超出的内存;如果设置为 true,则该资源组为内存软隔离,如果系统有空闲内存资源则该资源组在超出 memory_limit 的限制后可继续使用系统内存,在系统总内存紧张时会 cancel 组内内存占用最大的若干个任务,释放部分超出的内存以缓解系统内存压力。建议在有资源组开启该配置时,所有资源组的 memory_limit 总和低于 100%,剩余部分用于资源组内存超发。 + +## 示例 + +1. 创建名为 g1 的资源组: + + ```sql + create workload group if not exists g1 + properties ( + "cpu_share"="10", + "memory_limit"="30%", + "enable_memory_overcommit"="true" + ); + ``` + +## 关键词 + + CREATE, WORKLOAD, GROUP + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md new file mode 100644 index 0000000000000..d4aeb752fb544 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY.md @@ -0,0 +1,78 @@ +--- +{ +"title": "CREATE WORKLOAD POLICY", +"language": "zh-CN" +} +--- + + + + + +## 描述 + +创建一个 Workload Policy,用于当一个查询满足一些条件时,就对该查询执行相应的动作。 + +## 语法 + +```sql +CREATE WORKLOAD POLICY [ IF NOT EXISTS ] +CONDITIONS() ACTIONS() +[ PROPERTIES () ] +``` + +## 必选参数 + +1. ``: Workload Policy 的名字 + +2. `` + - be_scan_rows,一个 SQL 在单个 BE 进程内 Scan 的行数,如果这个 SQL 在 BE 上是多并发执行,那么就是多个并发的累加值。 + - be_scan_bytes,一个 SQL 在单个 BE 进程内 Scan 的字节数,如果这个 SQL 在 BE 上是多并发执行,那么就是多个并发的累加值,单位是字节。 + - query_time,一个 SQL 在单个 BE 进程上的运行时间,时间单位是毫秒。 + - query_be_memory_bytes,从 2.1.5 版本开始支持。一个 SQL 在单个 BE 进程内使用的内存用量,如果这个 SQL 在 BE 上是多并发执行,那么就是多个并发的累加值,单位是字节。 + +3. `` + - set_session_variable,这个 Action 可以执行一条 `set_session_variable` 的语句。同一个 Policy 可以有多个 `set_session_variable`,也就是说一个 Policy 可以执行多个修改 session 变量的语句。 + - cancel_query,取消查询。 + +## 可选参数 + +1. `` + - enabled,取值为 true 或 false,默认值为 true,表示当前 Policy 处于启用状态,false 表示当前 Policy 处于禁用状态。 + - priority,取值范围为 0 到 100 的正整数,默认值为 0,代表 Policy 的优先级,该值越大,优先级越高。这个属性的主要作用是,当匹配到多个 Policy 时,选择优先级最高的 Policy。 + - workload_group,目前一个 Policy 可以绑定一个 Workload Group,代表这个 Policy 只对某个 Workload Group 生效。默认为空,代表对所有查询生效。 + +## 权限控制 + +至少具备`ADMIN_PRIV`权限 + +## 示例 + +1. 新建一个 Workload Policy,作用是杀死所有查询时间超过 3s 的查询 + + ```Java + create workload policy kill_big_query conditions(query_time > 3000) actions(cancel_query) + ``` + +2. 新建一个 Workload Policy,默认不开启 + + ```Java + create workload policy kill_big_query conditions(query_time > 3000) actions(cancel_query) properties('enabled'='false') + ``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/DROP-RESOURCE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/DROP-RESOURCE.md new file mode 100644 index 0000000000000..1ac2ff3d10deb --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/DROP-RESOURCE.md @@ -0,0 +1,55 @@ +--- +{ + "title": "DROP RESOURCE", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于删除一个已有的资源。仅 root 或 admin 用户可以删除资源。 +语法: + +```sql +DROP RESOURCE 'resource_name' +``` + +注意:正在使用的 ODBC/S3 资源无法删除。 + +## 示例 + +1. 删除名为 spark0 的 Spark 资源: + + ```sql + DROP RESOURCE 'spark0'; + ``` + +## 关键词 + + DROP, RESOURCE + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/DROP-WORKLOAD-GROUP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/DROP-WORKLOAD-GROUP.md new file mode 100644 index 0000000000000..71d4b40433964 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/DROP-WORKLOAD-GROUP.md @@ -0,0 +1,51 @@ +--- +{ + "title": "DROP WORKLOAD GROUP", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于删除资源组。 + +```sql +DROP WORKLOAD GROUP [IF EXISTS] 'rg_name' +``` + +## 示例 + +1. 删除名为 g1 的资源组: + + ```sql + drop workload group if exists g1; + ``` + +## 关键词 + + DROP, WORKLOAD, GROUP + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/DROP-WORKLOAD-POLICY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/DROP-WORKLOAD-POLICY.md new file mode 100644 index 0000000000000..358e6f0621c87 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/DROP-WORKLOAD-POLICY.md @@ -0,0 +1,52 @@ +--- +{ + "title": "DROP WORKLOAD POLICY", + "language": "zh-CN" +} +--- + + + + +## 描述 + +删除一个 Workload Policy + +## 语法 + +```sql +DROP WORKLOAD POLICY [ IF EXISTS ] +``` + +## 必选参数 + +1. ``: Workload Policy 的 Name + +## 权限控制 + +至少具有`ADMIN_PRIV`权限 + +## 示例 + +1. 删除一个名为 `cancel_big_query` 的 Workload Policy + + ```sql + drop workload policy if exists cancel_big_query + ``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/SHOW-COMPUTE-GROUPS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/SHOW-COMPUTE-GROUPS.md new file mode 100644 index 0000000000000..b0cb39f8ebbec --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/SHOW-COMPUTE-GROUPS.md @@ -0,0 +1,66 @@ +--- +{ + "title": "SHOW COMPUTE GROUPS", + "language": "zh-CN" +} +--- + + + +## 描述 + +在存算分离模式中,显示当前用户有集群使用权限的计算集群列表 + +## 语法 + +```sql +SHOW COMPUTE GROUPS +``` + +## 返回值 + +返回当前拥有计算集群权限的集群列表 + +- Name - 计算集群 compute group 名字 +- IsCurrent 当前用户是否正在使用这个 compute group +- Users 将此项 compute group 设置为 default compute group 的用户名 +- BackendNum 此项 compute group 拥有的 backend 个数 + +## 示例 + +指定使用该计算集群 compute_cluster + +```sql + show compute groups; +``` + +结果为 + +```sql ++-----------------+-----------+-------+------------+ +| Name | IsCurrent | Users | BackendNum | ++-----------------+-----------+-------+------------+ +| compute_cluster | TRUE | | 3 | ++-----------------+-----------+-------+------------+ +``` + +## 注意事项(Usage Note) + +若当前用户无任何 compute group 权限,show compute group 将返回空列表 \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/SHOW-RESOURCES.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/SHOW-RESOURCES.md new file mode 100644 index 0000000000000..3da6c99c4905d --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/SHOW-RESOURCES.md @@ -0,0 +1,88 @@ +--- +{ + "title": "SHOW RESOURCES", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于展示用户有使用权限的资源。普通用户仅能展示有使用权限的资源,root 或 admin 用户会展示所有的资源。 + +语法: + +```sql +SHOW RESOURCES +[ + WHERE + [NAME [ = "your_resource_name" | LIKE "name_matcher"]] + [RESOURCETYPE = ["SPARK"]] +] | [LIKE "pattern"] +[ORDER BY ...] +[LIMIT limit][OFFSET offset]; +``` + +说明: + +1. 如果使用 NAME LIKE,则会匹配 RESOURCES 的 Name 包含 name_matcher 的 Resource +2. 如果使用 NAME = ,则精确匹配指定的 Name +3. 如果指定了 RESOURCETYPE,则匹配对应的 Resrouce 类型 +4. 可以使用 ORDER BY 对任意列组合进行排序 +5. 如果指定了 LIMIT,则显示 limit 条匹配记录。否则全部显示 +6. 如果指定了 OFFSET,则从偏移量 offset 开始显示查询结果。默认情况下偏移量为 0。 +7. 如果使用了 LIKE,则会忽略 WHERE 语句。 + +## 示例 + +1. 展示当前用户拥有权限的所有 Resource + + ```sql + SHOW RESOURCES; + ``` + +2. 展示指定 Resource,NAME 中包含字符串 "20140102",展示 10 个属性 + + ```sql + SHOW RESOURCES WHERE NAME LIKE "2014_01_02" LIMIT 10; + ``` + +3. 展示指定 Resource,指定 NAME 为 "20140102" 并按 KEY 降序排序 + + ```sql + SHOW RESOURCES WHERE NAME = "20140102" ORDER BY `KEY` DESC; + ``` + +4. 使用 LIKE 进行模糊匹配 + + ```sql + SHOW RESOURCES LIKE "jdbc%"; + ``` + +## 关键词 + + SHOW, RESOURCES + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/SHOW-WORKLOAD-GROUPS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/SHOW-WORKLOAD-GROUPS.md new file mode 100644 index 0000000000000..8f087efdceef5 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/compute-management/SHOW-WORKLOAD-GROUPS.md @@ -0,0 +1,78 @@ +--- +{ + "title": "SHOW WORKLOAD GROUPS", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于展示当前用户具有 usage_priv 权限的资源组。 + +语法: + +```sql +SHOW WORKLOAD GROUPS [LIKE "pattern"]; +``` + +说明: + +该语句仅做资源组简单展示,更复杂的展示可参考 tvf workload_groups(). + +## 示例 + +1. 展示所有资源组: + + ```sql + mysql> show workload groups; + +----------+--------+--------------------------+---------+ + | Id | Name | Item | Value | + +----------+--------+--------------------------+---------+ + | 10343386 | normal | cpu_share | 10 | + | 10343386 | normal | memory_limit | 30% | + | 10343386 | normal | enable_memory_overcommit | true | + | 10352416 | g1 | memory_limit | 20% | + | 10352416 | g1 | cpu_share | 10 | + +----------+--------+--------------------------+---------+ + ``` + +2. 使用 LIKE 模糊匹配: + + ```sql + mysql> show workload groups like "normal%" + +----------+--------+--------------------------+---------+ + | Id | Name | Item | Value | + +----------+--------+--------------------------+---------+ + | 10343386 | normal | cpu_share | 10 | + | 10343386 | normal | memory_limit | 30% | + | 10343386 | normal | enable_memory_overcommit | true | + +----------+--------+--------------------------+---------+ + ``` + +## 关键词 + + SHOW, WORKLOAD, GROUPS, GROUP + +### 最佳实践 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/ADD-BACKEND.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/ADD-BACKEND.md new file mode 100644 index 0000000000000..18f97acb989e9 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/ADD-BACKEND.md @@ -0,0 +1,84 @@ +--- +{ + "title": "ADD BACKEND", + "language": "zh-CN" +} +--- + + + +## 描述 + +ADD BACKEND 命令用于向 Doris OLAP 数据库集群添加一个或多个后端节点。此命令允许管理员指定新后端节点的主机和端口,以及可选的属性来配置它们的行为。 + +## 语法 + +```sql + ALTER SYSTEM ADD BACKEND "host:heartbeat_port"[,"host:heartbeat_port"...] [PROPERTIES ("key"="value", ...)]; +``` + +## 参数 + +* `host`:可以是后端节点的主机名或 IP 地址 +* `heartbeat_port`:节点的心跳端口 +* `PROPERTIES ("key"="value", ...)`:(可选)一组键值对,用于定义后端节点的附加属性。这些属性可用于自定义正在添加的后端的配置。可用属性包括: + + * tag.location:指定后端节点所属的资源组。例如,PROPERTIES ("tag.location" = "groupb")。 + * tag.compute_group_name:指定后端节点所属的计算组。例如,PROPERTIES ("tag.compute_group_name" = "groupb")。 + +## 示例 + +1. 不带附加属性添加后端 + + ```sql + ALTER SYSTEM ADD BACKEND "host1:9050,host2:9050"; + ``` + + 此命令向集群添加两个后端节点: + * host1,端口 9050 + * host2,端口 9050 + + 未指定附加属性,因此将应用默认设置。 + +2. 添加带有资源组的后端 + + ```sql + ALTER SYSTEM ADD BACKEND "host3:9050" PROPERTIES ("tag.location" = "groupb"); + ``` + + 此命令将单个后端节点(host3,端口 9050)添加到集群中的资源组 `groupb`。 + +## 关键词 + + ALTER, SYSTEM, ADD, BACKEND, PROPERTIES + +## 最佳实践 + +1. 在添加新的后端节点之前,确保节点已正确配置并运行。 + +2. 使用资源组可以帮助您更好地管理和组织集群中的后端节点。 + +3. 添加多个后端节点时,可以在一个命令中指定它们,以提高效率。 + +4. 添加后端节点后,使用 `SHOW BACKENDS` 命令验证它们是否已成功添加并处于正常状态。 + +5. 考虑在不同的物理位置或机架上添加后端节点,以提高集群的可用性和容错能力。 + +6. 定期检查和平衡集群中的负载,确保新添加的后端节点得到适当利用。 \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/ADD-BROKER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/ADD-BROKER.md new file mode 100644 index 0000000000000..bf2d9211ce527 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/ADD-BROKER.md @@ -0,0 +1,60 @@ +--- +{ + "title": "ADD BROKER", + "language": "zh-CN" +} + +--- + + + + + + +## 描述 + +该语句用于添加一个 BROKER 节点。(仅管理员使用!) + +语法: + +```sql +ALTER SYSTEM ADD BROKER broker_name "broker_host1:broker_ipc_port1","broker_host2:broker_ipc_port2",...; +``` + +## 示例 + +1. 增加两个 Broker + + ```sql + ALTER SYSTEM ADD BROKER "host1:port", "host2:port"; + ``` +2. fe 开启 fqdn([fqdn](../../../admin-manual/cluster-management/fqdn.md)) 时添加一个 Broker + + ```sql + ALTER SYSTEM ADD BROKER "broker_fqdn1:port"; + ``` + + +## 关键词 + + ALTER, SYSTEM, ADD, FOLLOWER, ALTER SYSTEM + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/ADD-FOLLOWER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/ADD-FOLLOWER.md new file mode 100644 index 0000000000000..5836ed12fd1c7 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/ADD-FOLLOWER.md @@ -0,0 +1,57 @@ +--- +{ + "title": "ADD FOLLOWER", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句是增加 FRONTEND 的 FOLLOWER 角色的节点,(仅管理员使用!) + +语法: + +```sql +ALTER SYSTEM ADD FOLLOWER "follower_host:edit_log_port" +``` + +说明: + +1. host 可以是主机名或者 ip 地址 +2. edit_log_port : edit_log_port 在其配置文件 fe.conf + +## 示例 + +1. 添加一个 FOLLOWER 节点 + + ```sql + ALTER SYSTEM ADD FOLLOWER "host_ip:9010" + ``` + +## 关键词 + + ALTER, SYSTEM, ADD, FOLLOWER, ALTER SYSTEM + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/ADD-OBSERVER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/ADD-OBSERVER.md new file mode 100644 index 0000000000000..32720212c7962 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/ADD-OBSERVER.md @@ -0,0 +1,56 @@ +--- +{ + "title": "ADD OBSERVER", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句是增加 FRONTEND 的 OBSERVER 角色的节点,(仅管理员使用!) + +语法: + +```sql +ALTER SYSTEM ADD OBSERVER "follower_host:edit_log_port" +``` + +说明: + +1. host 可以是主机名或者 ip 地址 +2. edit_log_port : edit_log_port 在其配置文件 fe.conf + +## 示例 + +1. 添加一个 OBSERVER 节点 + + ```sql + ALTER SYSTEM ADD OBSERVER "host_ip:9010" + ``` + +## 关键词 + + ALTER, SYSTEM, ADD, OBSERVER, ALTER SYSTEM + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/CANCEL-ALTER-SYSTEM.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/CANCEL-ALTER-SYSTEM.md new file mode 100644 index 0000000000000..e44fe06f58ff5 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/CANCEL-ALTER-SYSTEM.md @@ -0,0 +1,68 @@ +--- +{ + "title": "CANCEL ALTER SYSTEM", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于撤销一个节点下线操作。(仅管理员使用!) + +语法: + +- 通过 host 和 port 查找 backend + +```sql +CANCEL DECOMMISSION BACKEND "host:heartbeat_port"[,"host:heartbeat_port"...]; +``` + +- 通过 backend_id 查找 backend + +```sql +CANCEL DECOMMISSION BACKEND "id1","id2","id3..."; +``` + +## 示例 + + 1. 取消两个节点的下线操作: + + ```sql + CANCEL DECOMMISSION BACKEND "host1:port", "host2:port"; + ``` + + 2. 取消 backend_id 为 1 的节点的下线操作: + + ```sql + CANCEL DECOMMISSION BACKEND "1","2"; + ``` + +## 关键词 + + CANCEL, DECOMMISSION, CANCEL ALTER + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/DECOMMISSION-BACKEND.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/DECOMMISSION-BACKEND.md new file mode 100644 index 0000000000000..6c7da97a2efd1 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/DECOMMISSION-BACKEND.md @@ -0,0 +1,73 @@ +--- +{ + "title": "DECOMMISSION BACKEND", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +节点下线操作用于安全下线节点。该操作为异步操作。如果成功,节点最终会从元数据中删除。如果失败,则不会完成下线(仅管理员使用!) + +语法: + +- 通过 host 和 port 查找 backend + +```sql +ALTER SYSTEM DECOMMISSION BACKEND "host:heartbeat_port"[,"host:heartbeat_port"...]; +``` + +- 通过 backend_id 查找 backend + +```sql +ALTER SYSTEM DECOMMISSION BACKEND "id1","id2"...; +``` + + 说明: + +1. host 可以是主机名或者 ip 地址 +2. heartbeat_port 为该节点的心跳端口 +3. 节点下线操作用于安全下线节点。该操作为异步操作。如果成功,节点最终会从元数据中删除。如果失败,则不会完成下线。 +4. 可以手动取消节点下线操作。详见 CANCEL DECOMMISSION + +## 示例 + +1. 下线两个节点 + + ```sql + ALTER SYSTEM DECOMMISSION BACKEND "host1:port", "host2:port"; + ``` + + ```sql + ALTER SYSTEM DECOMMISSION BACKEND "id1", "id2"; + ``` + +## 关键词 + + ALTER, SYSTEM, DECOMMISSION, BACKEND, ALTER SYSTEM + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/DROP-BACKEND.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/DROP-BACKEND.md new file mode 100644 index 0000000000000..332deaa6817a1 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/DROP-BACKEND.md @@ -0,0 +1,70 @@ +--- +{ + "title": "DROP BACKEND", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于删除 BACKEND 节点(仅管理员使用!) + +语法: + +- 通过 host 和 port 查找 backend + +```sql +ALTER SYSTEM DROP BACKEND "host:heartbeat_port"[,"host:heartbeat_port"...] +``` + +- 通过 backend_id 查找 backend + +```sql +ALTER SYSTEM DROP BACKEND "id1","id2"...; +``` + +说明: + +1. host 可以是主机名或者 ip 地址 +2. heartbeat_port 为该节点的心跳端口 +3. 增加和删除节点为同步操作。这两种操作不考虑节点上已有的数据,节点直接从元数据中删除,请谨慎使用。 + +## 示例 + +1. 删除两个节点 + + ```sql + ALTER SYSTEM DROP BACKEND "host1:port", "host2:port"; + ``` + + ```sql + ALTER SYSTEM DROP BACKEND "id1", "id2"; + ``` + +## 关键词 + + ALTER, SYSTEM, DROP, BACKEND, ALTER SYSTEM + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/DROP-BROKER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/DROP-BROKER.md new file mode 100644 index 0000000000000..c219c9fb3eaa1 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/DROP-BROKER.md @@ -0,0 +1,62 @@ +--- +{ + "title": "DROP BROKER", + "language": "zh-CN" +} + +--- + + + + + +## 描述 + +该语句是删除 BROKER 节点,(仅限管理员使用) + +语法: + +```sql +删除所有 Broker +ALTER SYSTEM DROP ALL BROKER broker_name +删除某一个 Broker 节点 +ALTER SYSTEM DROP BROKER broker_name "host:port"[,"host:port"...]; +``` + +## 示例 + +1. 删除所有 Broker + + ```sql + ALTER SYSTEM DROP ALL BROKER broker_name + ``` + +2. 删除某一个 Broker 节点 + + ```sql + ALTER SYSTEM DROP BROKER broker_name "host:port"[,"host:port"...]; + ``` + +## 关键词 + + ALTER, SYSTEM, DROP, FOLLOWER, ALTER SYSTEM + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/DROP-FOLLOWER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/DROP-FOLLOWER.md new file mode 100644 index 0000000000000..de9a1ada9f861 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/DROP-FOLLOWER.md @@ -0,0 +1,60 @@ +--- +{ + "title": "DROP FOLLOWER", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句是删除 FRONTEND 的 FOLLOWER 角色的节点,(仅管理员使用!) + +语法: + +```sql +ALTER SYSTEM DROP FOLLOWER "follower_host:edit_log_port" +``` + +说明: + +1. host 可以是主机名或者 ip 地址 + +2. edit_log_port : edit_log_port 在其配置文件 fe.conf + +## 示例 + +1. 删除一个 FOLLOWER 节点 + + ```sql + ALTER SYSTEM DROP FOLLOWER "host_ip:9010" + ``` + +## 关键词 + +ALTER, SYSTEM, DROP, FOLLOWER, ALTER SYSTEM + + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/DROP-OBSERVER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/DROP-OBSERVER.md new file mode 100644 index 0000000000000..53fd878ffcadc --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/DROP-OBSERVER.md @@ -0,0 +1,59 @@ +--- +{ + "title": "DROP OBSERVER", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句是删除 FRONTEND 的 OBSERVER 角色的节点,(仅管理员使用!) + +语法: + +```sql +ALTER SYSTEM DROP OBSERVER "follower_host:edit_log_port" +``` + +说明: + +1. host 可以是主机名或者 ip 地址 +2. edit_log_port : edit_log_port 在其配置文件 fe.conf + +## 示例 + +1. 添加一个 FOLLOWER 节点 + + ```sql + ALTER SYSTEM DROP OBSERVER "host_ip:9010" + ``` + +## 关键词 + + ALTER, SYSTEM, DROP, OBSERVER, ALTER SYSTEM + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/MODIFY-BACKEND.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/MODIFY-BACKEND.md new file mode 100644 index 0000000000000..3ad924121b640 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/MODIFY-BACKEND.md @@ -0,0 +1,101 @@ +--- +{ + "title": "MODIFY BACKEND", + "language": "zh-CN" +} + +--- + + + + + + +## 描述 + +修改 BE 节点属性(仅管理员使用!) + +语法: + +- 通过 host 和 port 查找 backend + +```sql +ALTER SYSTEM MODIFY BACKEND "host:heartbeat_port" SET ("key" = "value"[, ...]); +``` + +- 通过 backend_id 查找 backend + +```sql +ALTER SYSTEM MODIFY BACKEND "id1" SET ("key" = "value"[, ...]); +``` + + 说明: + +1. host 可以是主机名或者 ip 地址 +2. heartbeat_port 为该节点的心跳端口 +3. 修改 BE 节点属性目前支持以下属性: + +- tag.xxx:资源标签 +- disable_query: 查询禁用属性 +- disable_load: 导入禁用属性 + +注: +1. 可以给一个 Backend 设置多种资源标签。但必须包含 "tag.location"。 + +## 示例 + +1. 修改 BE 的资源标签 + + ```sql + ALTER SYSTEM MODIFY BACKEND "host1:heartbeat_port" SET ("tag.location" = "group_a"); + ALTER SYSTEM MODIFY BACKEND "host1:heartbeat_port" SET ("tag.location" = "group_a", "tag.compute" = "c1"); + ``` + + ```sql + ALTER SYSTEM MODIFY BACKEND "id1" SET ("tag.location" = "group_a"); + ALTER SYSTEM MODIFY BACKEND "id1" SET ("tag.location" = "group_a", "tag.compute" = "c1"); + ``` + +2. 修改 BE 的查询禁用属性 + + ```sql + ALTER SYSTEM MODIFY BACKEND "host1:heartbeat_port" SET ("disable_query" = "true"); + ``` + + ```sql + ALTER SYSTEM MODIFY BACKEND "id1" SET ("disable_query" = "true"); + ``` + +3. 修改 BE 的导入禁用属性 + + ```sql + ALTER SYSTEM MODIFY BACKEND "host1:heartbeat_port" SET ("disable_load" = "true"); + ``` + + ```sql + ALTER SYSTEM MODIFY BACKEND "id1" SET ("disable_load" = "true"); + ``` + +## 关键词 + + ALTER, SYSTEM, ADD, BACKEND, ALTER SYSTEM + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/MODIFY-FRONTEND-HOSTNAME.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/MODIFY-FRONTEND-HOSTNAME.md new file mode 100644 index 0000000000000..ddac94d11f034 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/MODIFY-FRONTEND-HOSTNAME.md @@ -0,0 +1,59 @@ +--- +{ + "title": "MODIFY FRONTEND HOSTNAME", + "language": "zh-CN" +} + +--- + + + + +## 描述 + +修改 FRONTEND(后续使用简称 FE)的属性。当前,此命令仅能修改 FE 的主机名(HOSTNAME)。当集群中的某一个 FE 实例运行的主机需要变更主机名时,可以使用此命令更改此 FE 在集群中注册的主机名,使其可以继续正常运行。 + +此命令只用于将 DORIS 集群转变为 FQDN 方式部署。有关 FQDN 部署的细节,请参阅“FQDN”章节。 + +## 语法 + +```sql +ALTER SYSTEM MODIFY FRONTEND "" HOSTNAME "" +``` + +## 必选参数 + +1. ``: 需要变更主机名的 FE 注册的 hostname 和 edit log port。可以通过 SHOW FRONTENDS 命令查看集群中所有 FE 的相关信息。详细用法请参阅“SHOW FRONTENDS”章节。 + +2. ``: FE 的新主机名。 + +## 权限控制 + +执行此 SQL 命令的用户必须至少具有 NOD_PRIV 权限。 + +## 示例 + +将集群中的一个 FE 实例的 hostname,从 10.10.10.1 变为 172.22.0.1: + +```sql +ALTER SYSTEM +MODIFY FRONTEND "10.10.10.1:9010" +HOSTNAME "172.22.0.1" +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SET-FRONTEND-CONFIG.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SET-FRONTEND-CONFIG.md new file mode 100644 index 0000000000000..6136aa7dec9b2 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SET-FRONTEND-CONFIG.md @@ -0,0 +1,62 @@ +--- +{ + "title": "SET FRONTEND CONFIG", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于设置集群的配置项(当前仅支持设置 FE 的配置项)。 + +可设置的配置项,可以通过 `SHOW FRONTEND CONFIG;` 命令查看。 + +语法: + +```sql +ADMIN SET FRONTEND CONFIG ("key" = "value") [ALL]; +-- or +ADMIN SET ALL FRONTENDS CONFIG ("key" = "value"); +``` + +:::tip 提示 + +- 2.0.11 和 2.1.5 版本开始支持 `ALL` 关键词。使用 `ALL` 关键字后配置参数将应用于所有 FE(除 `master_only` 参数外)。 +- 该语法不会持久化修改的配置,FE 重启后,修改的配置失效。如需持久化,需要在 fe.conf 中同步添加配置项。 +- +::: + +## 示例 + +1. 设置 `disable_balance` 为 true + + `ADMIN SET FRONTEND CONFIG ("disable_balance" = "true");` + +## 关键词 + + ADMIN, SET, CONFIG + +### 最佳实践 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SHOW-BACKEND-CONFIG.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SHOW-BACKEND-CONFIG.md new file mode 100644 index 0000000000000..d2770dfb7f3b5 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SHOW-BACKEND-CONFIG.md @@ -0,0 +1,114 @@ +--- +{ + "title": "SHOW BACKEND CONFIG", + "language": "zh-CN" +} +--- + + + +## 描述 + +展示 BACKEND(即 BE)的配置项和其当前值。 + +## 语法 + +```sql +[ ADMIN ] SHOW BACKEND CONFIG [ LIKE ] [ FROM ] +``` + +## 可选参数 + +**** + +> 提供一个通配符模式,用于匹配 BE 配置项。匹配规则与 LIKE 表达式相同。书写规则请参考“匹配表达式”章节。 + +**** + +> BE 的 ID。用于查看指定 ID 的 BE 的配置。BE 的 ID 可以通过 SHOW BACKENDS 命令获得。具体请参阅“SHOW BACKENDS”命令 + +## 返回值(Return Value) + +- BackendId: BE 的 ID +- Host: BE 的主机地址 +- Key: 配置项的名称 +- Value: 配置项对应的值 +- Type: 配置值的类型 + +## 权限控制(Access Control Requirements) + +执行此 SQL 命令的用户必须至少具有 ADMIN_PRIV 权限。 + +## 示例(Examples) + +### 查询所有配置项 + +```sql +SHOW BACKEND CONFIG +``` + +结果为 + +```sql ++-----------+--------------+--------------------------------+-------+--------------------------+-----------+ +| BackendId | Host | Key | Value | Type | IsMutable | ++-----------+--------------+--------------------------------+-------+--------------------------+-----------+ +| 12793 | 172.16.123.1 | LZ4_HC_compression_level | 9 | int64_t | true | +| 12793 | 172.16.123.1 | agent_task_trace_threshold_sec | 2 | int32_t | true | +... +| 12794 | 172.16.123.2 | zone_map_row_num_threshold | 20 | int32_t | true | ++-----------+--------------+--------------------------------+-------+--------------------------+-----------+ +``` + +### 查询指定 ID 的 BE 的配置项 + +```sql +SHOW BACKEND CONFIG FROM 12793 +``` + +结果为 + +```sql ++-----------+--------------+--------------------------------+-------+--------------------------+-----------+ +| BackendId | Host | Key | Value | Type | IsMutable | ++-----------+--------------+--------------------------------+-------+--------------------------+-----------+ +| 12793 | 172.16.123.1 | LZ4_HC_compression_level | 9 | int64_t | true | +| 12793 | 172.16.123.1 | agent_task_trace_threshold_sec | 2 | int32_t | true | +... +| 12793 | 172.16.123.1 | zone_map_row_num_threshold | 20 | int32_t | true | ++-----------+--------------+--------------------------------+-------+--------------------------+-----------+ +``` + +### 查询符合指定模式的配置项 + +```sql +SHOW BACKEND CONFIG LIKE '%compression_level%' +``` + +结果为 + +```sql ++-----------+--------------+--------------------------+-------+---------+-----------+ +| BackendId | Host | Key | Value | Type | IsMutable | ++-----------+--------------+--------------------------+-------+---------+-----------+ +| 12793 | 172.16.123.1 | LZ4_HC_compression_level | 9 | int64_t | true | +| 12794 | 172.16.123.2 | LZ4_HC_compression_level | 9 | int64_t | true | ++-----------+--------------+--------------------------+-------+---------+-----------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SHOW-BACKENDS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SHOW-BACKENDS.md new file mode 100644 index 0000000000000..b07374d97933a --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SHOW-BACKENDS.md @@ -0,0 +1,63 @@ +--- +{ + "title": "SHOW BACKENDS", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于查看 cluster 内的 BE 节点 + +```sql + SHOW BACKENDS; +``` + +说明: + + 1. LastStartTime 表示最近一次 BE 启动时间。 + 2. LastHeartbeat 表示最近一次心跳。 + 3. Alive 表示节点是否存活。 + 4. SystemDecommissioned 为 true 表示节点正在安全下线中。 + 5. ClusterDecommissioned 为 true 表示节点正在冲当前 cluster 中下线。 + 6. TabletNum 表示该节点上分片数量。 + 7. DataUsedCapacity 表示实际用户数据所占用的空间。 + 8. AvailCapacity 表示磁盘的可使用空间。 + 9. TotalCapacity 表示总磁盘空间。TotalCapacity = AvailCapacity + DataUsedCapacity + 其他非用户数据文件占用空间。 + 10. UsedPct 表示磁盘已使用量百分比。 + 11. ErrMsg 用于显示心跳失败时的错误信息。 + 12. Status 用于以 JSON 格式显示 BE 的一些状态信息,目前包括最后一次 BE 汇报其 tablet 的时间信息。 + 13. HeartbeatFailureCounter:现在当前连续失败的心跳次数,如果次数超过 `max_backend_heartbeat_failure_tolerance_count` 配置,则 isAlive 字段会置为 false。 + 14. NodeRole 用于展示节点角色,现在有两种类型:Mix 代表原来的节点类型,computation 代表只做计算的节点类型。 + +## 示例 + +## 关键词 + + SHOW, BACKENDS + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SHOW-BROKER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SHOW-BROKER.md new file mode 100644 index 0000000000000..48cfab8ba5093 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SHOW-BROKER.md @@ -0,0 +1,54 @@ +--- +{ + "title": "SHOW BROKER", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于查看当前存在的 broker + +语法: + +```sql +SHOW BROKER; +``` + +说明: + + 1. LastStartTime 表示最近一次 BE 启动时间。 + 2. LastHeartbeat 表示最近一次心跳。 + 3. Alive 表示节点是否存活。 + 4. ErrMsg 用于显示心跳失败时的错误信息。 + +## 示例 + +## 关键词 + + SHOW, BROKER + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SHOW-CONFIG.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SHOW-CONFIG.md new file mode 100644 index 0000000000000..e7d0ef45a8b3a --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SHOW-CONFIG.md @@ -0,0 +1,74 @@ +--- +{ + "title": "SHOW CONFIG", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于展示当前集群的配置(当前仅支持展示 FE 的配置项) + +语法: + +```sql +SHOW FRONTEND CONFIG [LIKE "pattern"]; +``` + +结果中的各列含义如下: + +1. Key:配置项名称 +2. Value:配置项值 +3. Type:配置项类型 +4. IsMutable:是否可以通过 ADMIN SET CONFIG 命令设置 +5. MasterOnly:是否仅适用于 Master FE +6. Comment:配置项说明 + +## 示例 + +1. 查看当前 FE 节点的配置 + + ```sql + SHOW FRONTEND CONFIG; + ``` + +2. 使用 like 谓词搜索当前 Fe 节点的配置 + + ``` + mysql> SHOW FRONTEND CONFIG LIKE '%check_java_version%'; + +--------------------+-------+---------+-----------+------------+---------+ + | Key | Value | Type | IsMutable | MasterOnly | Comment | + +--------------------+-------+---------+-----------+------------+---------+ + | check_java_version | true | boolean | false | false | | + +--------------------+-------+---------+-----------+------------+---------+ + 1 row in set (0.01 sec) + ``` + +## 关键词 + + SHOW, CONFIG + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SHOW-FRONTENDS-DISKS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SHOW-FRONTENDS-DISKS.md new file mode 100644 index 0000000000000..fcda0d9043061 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SHOW-FRONTENDS-DISKS.md @@ -0,0 +1,70 @@ +--- +{ + "title": "SHOW-FRONTENDS-DISKS", + "language": "zh-CN" +} +--- + + + + +## 描述 + + 该语句用于查看 FE 节点的重要目录如:元数据、日志、审计日志、临时目录对应的磁盘信息 + + 语法: + +```sql +SHOW FRONTENDS DISKS; +``` + +说明: +1. Name 表示该 FE 节点在 bdbje 中的名称。 +2. Host 表示该 FE 节点的 IP。 +3. DirType 表示要展示的目录类型,分别有四种类型:meta、log、audit-log、temp、deploy。 +4. Dir 表示要展示的目录类型的目录。 +5. FileSystem 表示要展示的目录类型所在的 linux 系统的文件系统。 +6. Capacity 文件系统的容量。 +7. Used 文件系统已用大小。 +8. Available 文件系统剩余容量。 +9. UseRate 文件系统使用容量占比。 +10. MountOn 文件系统挂在目录。 + +### 示例 +` +mysql> show frontends disks; ++-----------------------------------------+-------------+-----------+---------------------------------+------------+----------+------+-----------+---------+------------+ +| Name | Host | DirType | Dir | Filesystem | Capacity | Used | Available | UseRate | MountOn | ++-----------------------------------------+-------------+-----------+---------------------------------+------------+----------+------+-----------+---------+------------+ +| fe_a1daac68_5ec0_477c_b5e8_f90a33cdc1bb | 10.xx.xx.90 | meta | /home/disk/output/fe/doris-meta | /dev/sdf1 | 7T | 2T | 4T | 36% | /home/disk | +| fe_a1daac68_5ec0_477c_b5e8_f90a33cdc1bb | 10.xx.xx.90 | log | /home/disk/output/fe/log | /dev/sdf1 | 7T | 2T | 4T | 36% | /home/disk | +| fe_a1daac68_5ec0_477c_b5e8_f90a33cdc1bb | 10.xx.xx.90 | audit-log | /home/disk/output/fe/log | /dev/sdf1 | 7T | 2T | 4T | 36% | /home/disk | +| fe_a1daac68_5ec0_477c_b5e8_f90a33cdc1bb | 10.xx.xx.90 | temp | /home/disk/output/fe/temp_dir | /dev/sdf1 | 7T | 2T | 4T | 36% | /home/disk | +| fe_a1daac68_5ec0_477c_b5e8_f90a33cdc1bb | 10.xx.xx.90 | deploy | /home/disk/output/fe | /dev/sdf1 | 7T | 2T | 4T | 36% | /home/disk | ++-----------------------------------------+-------------+-----------+---------------------------------+------------+----------+------+-----------+---------+------------+ +5 rows in set (0.00 sec) +` + +### 关键词 + + SHOW, FRONTENDS + +### Best Practice + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SHOW-FRONTENDS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SHOW-FRONTENDS.md new file mode 100644 index 0000000000000..2d5b9c46ca593 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/instance-management/SHOW-FRONTENDS.md @@ -0,0 +1,57 @@ +--- +{ + "title": "SHOW FRONTENDS", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + + 该语句用于查看 FE 节点 + + 语法: + +```sql +SHOW FRONTENDS; +``` + +说明: +1. name 表示该 FE 节点在 bdbje 中的名称。 +2. Join 为 true 表示该节点曾经加入过集群。但不代表当前还在集群内(可能已失联) +3. Alive 表示节点是否存活。 +4. ReplayedJournalId 表示该节点当前已经回放的最大元数据日志 id。 +5. LastHeartbeat 是最近一次心跳。 +6. IsHelper 表示该节点是否是 bdbje 中的 helper 节点。 +7. ErrMsg 用于显示心跳失败时的错误信息。 +8. CurrentConnected 表示是否是当前连接的 FE 节点 + +## 示例 + +## 关键词 + + SHOW, FRONTENDS + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/ALTER-STORAGE-POLICY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/ALTER-STORAGE-POLICY.md new file mode 100644 index 0000000000000..9e43eadfad035 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/ALTER-STORAGE-POLICY.md @@ -0,0 +1,56 @@ +--- +{ +"title": "ALTER STORAGE POLICY", +"language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于修改一个已有的冷热分层迁移策略。仅 root 或 admin 用户可以修改资源。 +语法: +```sql +ALTER STORAGE POLICY 'policy_name' +PROPERTIES ("key"="value", ...); +``` + +## 示例 + +1. 修改名为 cooldown_datetime 冷热分层数据迁移时间点: +```sql +ALTER STORAGE POLICY has_test_policy_to_alter PROPERTIES("cooldown_datetime" = "2023-06-08 00:00:00"); +``` +2. 修改名为 cooldown_ttl 的冷热分层数据迁移倒计时 +```sql +ALTER STORAGE POLICY has_test_policy_to_alter PROPERTIES ("cooldown_ttl" = "10000"); +ALTER STORAGE POLICY has_test_policy_to_alter PROPERTIES ("cooldown_ttl" = "1h"); +ALTER STORAGE POLICY has_test_policy_to_alter PROPERTIES ("cooldown_ttl" = "3d"); +``` +## 关键词 + +```sql +ALTER, STORAGE, POLICY +``` + +### 最佳实践 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/ALTER-STORAGE-VAULT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/ALTER-STORAGE-VAULT.md new file mode 100644 index 0000000000000..889bb331743bc --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/ALTER-STORAGE-VAULT.md @@ -0,0 +1,86 @@ +--- +{ +"title": "ALTER STORAGE VAULT", +"language": "zh-CN" +} +--- + + + +## 描述 + +更改 Storage Vault 的可修改属性值 + +## 语法 + +```sql +ALTER STORAGE VAULT +PROPERTIES () +``` + +## 必选参数 + +**** + +> - type:可选值为 s3, hdfs +> +> +> +> 当 type 为 s3 时,允许出现的属性字段如下: +> +> - s3.access_key:s3 vault 的 ak +> - s3.secret_key:s3 vault 的 sk +> - vault_name:vault 的 名字。 +> - use_path_style:是否允许 path style url,可选值为 true,false。默认值是 false。 +> +> +> +> 当 type 为 hdfs 时,禁止出现的字段: +> +> - path_prefix:存储路径前缀 +> - fs.defaultFS:hdfs name + +## 权限控制 + +执行此 SQL 命令的用户必须至少具有 ADMIN_PRIV 权限。 + +## 示例 + +修改 s3 storage vault ak + +```sql +ALTER STORAGE VAULT old_vault_name +PROPERTIES ( + "type"="S3", + "VAULT_NAME" = "new_vault_name", + "s3.access_key" = "new_ak" +); +``` + +修改 hdfs storage vault + +```sql +ALTER STORAGE VAULT old_vault_name +PROPERTIES ( + "type"="hdfs", + "VAULT_NAME" = "new_vault_name", + "hadoop.username" = "hdfs" +); +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/CANCEL-WARM-UP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/CANCEL-WARM-UP.md new file mode 100644 index 0000000000000..5cddcdd15f31c --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/CANCEL-WARM-UP.md @@ -0,0 +1,85 @@ +--- +{ +"title": "CANCEL WARM UP", +"language": "zh-CN" +} +--- + + + +## 描述 + +用于在 Doris 终止指定的预热作业。 + +## 语法 + +```sql +CANCEL WARM UP JOB WHERE id = ; +``` + +## 必选参数 + +`` + +> 想要终止的预热任务的 id,可以通过命令 `SHOW WARM UP JOB` 查询得到。 + +## 权限控制 + +执行此 SQL 命令的用户必须至少具有 ADMIN_PRIV 权限。 + +## 示例 + +通过 `SHOW WARM UP JOB` 查询得到当前系统中运行的预热任务: + +```sql +SHOW WARM UP JOB +``` + +其结果为: + +```C++ ++----------------+---------------+---------+-------+-------------------------+-------------+----------+------------+--------+ +| JobId | ClusterName | Status | Type | CreateTime | FinishBatch | AllBatch | FinishTime | ErrMsg | ++----------------+---------------+---------+-------+-------------------------+-------------+----------+------------+--------+ +| 90290165739458 | CloudCluster1 | RUNNING | TABLE | 2024-11-11 11:11:42.700 | 1 | 3 | NULL | | ++----------------+---------------+---------+-------+-------------------------+-------------+----------+------------+--------+ +``` + +然后通过 `CANCEL WARM UP` 进行终止: + +```C++ +CANCEL WARM UP WHERE id = 90290165739458; +``` + +若返回以下内容则表明指定 id 对应的预热任务不存在: + +```C++ +ERROR 1105 (HY000): errCode = 2, detailMessage = job id: 110 does not exist. +``` + +正确返回后再次 `SHOW WARM UP JOB` 可以看到任务状态从 RUNNING 变更为 CANCELLED: + +```C++ ++----------------+---------------+-----------+-------+-------------------------+-------------+----------+-------------------------+-------------+ +| JobId | ClusterName | Status | Type | CreateTime | FinishBatch | AllBatch | FinishTime | ErrMsg | ++----------------+---------------+-----------+-------+-------------------------+-------------+----------+-------------------------+-------------+ +| 90290165739458 | CloudCluster1 | CANCELLED | TABLE | 2024-11-11 11:11:42.700 | 1 | 3 | 2024-11-11 11:11:43.700 | user cancel | ++----------------+---------------+-----------+-------+-------------------------+-------------+----------+-------------------------+-------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-POLICY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-POLICY.md new file mode 100644 index 0000000000000..4cc5c4daf601e --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-POLICY.md @@ -0,0 +1,82 @@ +--- +{ +"title": "CREATE STORAGE POLICY", +"language": "zh-CN" +} +--- + + + + +## 描述 +创建一个存储策略,必须先创建存储资源,然后创建迁移策略时候关联创建的存储资源名,具体可参考 RESOURCE 章节。 + +## 语法 + +```sql +CREATE STORAGE POLICY +PROPERTIES( + "storage_resource" = "" + [{, "cooldown_datetime" = "" + | , "cooldown_ttl" = ""}] +); +``` + +## 必选参数 + +1. ``:待创建的存储策略名字 + +2. ``:关联的存储资源名字,具体如何创建可参考 RESOURCE 章节 + +## 可选参数 + +1. ``:指定创建数据迁移策略冷却的时间 + +2. ``: 指定创建数据迁移策略热数据持续时间 + +## 权限控制(Access Control Requirements) + +执行此 SQL 命令成功的前置条件是,拥有 ADMIN_PRIV 权限,参考权限文档。 + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +| :---------------- | :--------------- | :-------------------------- | +| ADMIN_PRIV | 整个集群管理权限 | 除 NODE_PRIV 以外的所有权限 | + +## 示例 + +1. 指定数据冷却时间创建数据迁移策略。 + + ```sql + CREATE STORAGE POLICY testPolicy + PROPERTIES( + "storage_resource" = "s3", + "cooldown_datetime" = "2022-06-08 00:00:00" + ); + ``` + +2. 指定热数据持续时间创建数据迁移策略 + + ```sql + CREATE STORAGE POLICY testPolicy + PROPERTIES( + "storage_resource" = "s3", + "cooldown_ttl" = "1d" + ); + ``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT.md new file mode 100644 index 0000000000000..5c432060aedab --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT.md @@ -0,0 +1,214 @@ +--- +{ + "title": "CREATE-STORAGE-VAULT", + "language": "zh-CN", + "toc_min_heading_level": 2, + "toc_max_heading_level": 4 +} +--- + + + +## CREATE-STORAGE-VAULT + +## 描述 + +该命令用于创建存储库。本文档的主题描述了创建 Doris 自管理存储库的语法。 + +```sql +CREATE STORAGE VAULT [IF NOT EXISTS] vault +[properties] +``` + +#### properties + +| 参数 | 是否必需 | 描述 | +|:-------|:-----|:-----------------------| +| `type` | 必需 | 只允许两种类型的存储库:S3 和 HDFS。 | + +##### S3 Vault + +| 参数 | 是否必需 | 描述 | +|:----------------|:-----|:--------------------------------------------------------------------------------------------------------| +| `s3.endpoint` | 必需 | 用于对象存储的端点。
注意,请不要提供带有 http:// 或 https:// 开头的链接。对于 Azure Blob 存储,endpoint是固定的blob.core.windows.net。 | +| `s3.region` | 必需 | 您的存储桶的区域。(如果您使用 GCP 或 AZURE,则不需要)。 | +| `s3.root.path` | 必需 | 存储数据的路径。 | +| `s3.bucket` | 必需 | 您的对象存储账户的存储桶。(如果您使用 Azure,则为 StorageAccount)。 | +| `s3.access_key` | 必需 | 您的对象存储账户的访问密钥。(如果您使用 Azure,则为 AccountName)。 | +| `s3.secret_key` | 必需 | 您的对象存储账户的秘密密钥。(如果您使用 Azure,则为 AccountKey)。 | +| `provider` | 必需 | 提供对象存储服务的云供应商。支持的值有`COS`,`OSS`,`S3`,`OBS`,`BOS`,`AZURE`,`GCP` | +| `use_path_style` | 可选 | 使用 `path-style URL`(私有化部署环境)或者`virtual-hosted-style URL`(公有云环境建议), 默认值 `true` (path-style) | + +##### HDFS vault + +| 参数 | 是否必需 | 描述 | +|:---------------------------------|:-----|:------------------------------------------------------| +| `fs.defaultFS` |必需| Hadoop 配置属性,指定要使用的默认文件系统。 | +| `path_prefix` |可选| 存储数据的路径前缀。如果没有指定则会使用 user 账户下的默认路径。 | +| `hadoop.username` |可选| Hadoop 配置属性,指定访问文件系统的用户。如果没有指定则会使用启动 hadoop 进程的 user。 | +| `hadoop.security.authentication` |可选| 用于 hadoop 的认证方式。如果希望使用 kerberos 则可以填写`kerberos`。 | +| `hadoop.kerberos.principal` |可选| 您的 kerberos 主体的路径。 | +| `hadoop.kerberos.keytab` |可选| 您的 kerberos keytab 的路径。 | + +### 示例 + +1. 创建 HDFS storage vault。 + ```sql + CREATE STORAGE VAULT IF NOT EXISTS hdfs_vault_demo + PROPERTIES ( + "type" = "hdfs", -- required + "fs.defaultFS" = "hdfs://127.0.0.1:8020", -- required + "path_prefix" = "big/data", -- optional, 一般按照业务名称填写 + "hadoop.username" = "user" -- optional + "hadoop.security.authentication" = "kerberos" -- optional + "hadoop.kerberos.principal" = "hadoop/127.0.0.1@XXX" -- optional + "hadoop.kerberos.keytab" = "/etc/emr.keytab" -- optional + ); + ``` + +2. 创建阿里云 OSS storage vault。 + ```sql + CREATE STORAGE VAULT IF NOT EXISTS oss_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "oss-cn-beijing.aliyuncs.com", -- required + "s3.access_key" = "xxxxxx", -- required, Your OSS access key + "s3.secret_key" = "xxxxxx", -- required, Your OSS secret key + "s3.region" = "cn-beijing", -- required + "s3.root.path" = "oss_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your OSS bucket name + "provider" = "OSS", -- required + "use_path_style" = "false" -- optional, OSS 建议设置false + ); + ``` + +3. 创建腾讯云 COS storage vault。 + ```sql + CREATE STORAGE VAULT IF NOT EXISTS cos_demo_vault + PROPERTIES ( + "type" = "S3", + "s3.endpoint" = "cos.ap-guangzhou.myqcloud.com", -- required + "s3.access_key" = "xxxxxx", -- required, Your COS access key + "s3.secret_key" = "xxxxxx", -- required, Your COS secret key + "s3.region" = "ap-guangzhou", -- required + "s3.root.path" = "cos_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your COS bucket name + "provider" = "COS", -- required + "use_path_style" = "false" -- optional, COS 建议设置false + ); + ``` + +4. 创建华为云 OBS storage vault。 + ```sql + CREATE STORAGE VAULT IF NOT EXISTS obs_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "obs.cn-north-4.myhuaweicloud.com", -- required + "s3.access_key" = "xxxxxx", -- required, Your OBS access key + "s3.secret_key" = "xxxxxx", -- required, Your OBS secret key + "s3.region" = "cn-north-4", -- required + "s3.root.path" = "obs_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your COS bucket name + "provider" = "OBS", -- required + "use_path_style" = "false" -- optional, OBS 建议设置false + ); + ``` + +5. 创建百度云 BOS storage vault。 + ```sql + CREATE STORAGE VAULT IF NOT EXISTS obs_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "s3.bj.bcebos.com", -- required + "s3.access_key" = "xxxxxx", -- required, Your BOS access key + "s3.secret_key" = "xxxxxx", -- required, Your BOS secret key + "s3.region" = "bj", -- required + "s3.root.path" = "bos_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your BOS bucket name + "provider" = "BOS", -- required + "use_path_style" = "false" -- optional, BOS 建议设置false + ); + ``` + +6. 创建亚马逊云 S3 storage vault。 + ```sql + CREATE STORAGE VAULT IF NOT EXISTS s3_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "s3.us-east-1.amazonaws.com", -- required + "s3.access_key" = "xxxxxx", -- required, Your S3 access key + "s3.secret_key" = "xxxxxx", -- required, Your OBS secret key + "s3.region" = "us-east-1", -- required + "s3.root.path" = "s3_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your s3 bucket name + "provider" = "S3", -- required + "use_path_style" = "false" -- optional, S3 建议设置false + ); + ``` + +7. 创建 MinIO storage vault。 + ```sql + CREATE STORAGE VAULT IF NOT EXISTS minio_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "127.0.0.1:9000", -- required + "s3.access_key" = "xxxxxx", -- required, Your minio access key + "s3.secret_key" = "xxxxxx", -- required, Your minio secret key + "s3.region" = "us-east-1", -- required + "s3.root.path" = "minio_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your minio bucket name + "provider" = "S3", -- required + "use_path_style" = "true" -- required, minio 建议设置true + ); + ``` + +8. 创建微软 AZURE storage vault。 + ```sql + CREATE STORAGE VAULT IF NOT EXISTS azure_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "blob.core.windows.net", -- required + "s3.access_key" = "xxxxxx", -- required, Your Azure AccountName + "s3.secret_key" = "xxxxxx", -- required, Your Azure AccountKey + "s3.region" = "us-east-1", -- required + "s3.root.path" = "azure_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your Azure StorageAccount + "provider" = "AZURE" -- required + ); + ``` + +9. 创建谷歌 GCP storage vault。 + ```sql + CREATE STORAGE VAULT IF NOT EXISTS gcp_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "storage.googleapis.com", -- required + "s3.access_key" = "xxxxxx", -- required + "s3.secret_key" = "xxxxxx", -- required + "s3.region" = "us-east-1", -- required + "s3.root.path" = "gcp_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required + "provider" = "GCP" -- required + ); + ``` + +### 关键词 + + CREATE, STORAGE VAULT diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/DROP-STORAGE-POLICY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/DROP-STORAGE-POLICY.md new file mode 100644 index 0000000000000..f4b063f3fb2cd --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/DROP-STORAGE-POLICY.md @@ -0,0 +1,58 @@ +--- +{ + "title": "DROP STORAGE POLICY", + "language": "zh-CN", + "toc_min_heading_level": 2, + "toc_max_heading_level": 4 +} +--- + + +## 描述 + +删除存储策略。存储策略的详细说明,请参阅“存储策略”章节。 + +## 语法 + +```sql +DROP STORAGE POLICY +``` + +## 必选参数 + +**** + +> 存储策略名称 + +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +| :---------------- | :------------- | :------------ | +| ADMIN_PRIV | 全局 | | + +## 示例 + +1. 删除名字为 policy1 的存储策略 + +```sql +DROP STORAGE POLICY policy1 +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/SET-DEFAULT-STORAGE-VAULT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/SET-DEFAULT-STORAGE-VAULT.md new file mode 100644 index 0000000000000..ffba9e2d56540 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/SET-DEFAULT-STORAGE-VAULT.md @@ -0,0 +1,53 @@ +--- +{ + "title": "SET DEFAULT STORAGE VAULT", + "language": "zh-CN" +} +--- + + + +## 描述 + +该语句用于在 Doris 中设置默认存储库。默认存储库用于存储内部或系统表的数据。如果未设置默认存储库,Doris 将无法正常运行。一旦设置了默认存储库,就无法移除它。 + +## 语法 + +```sql +SET vault_name DEFAULT STORAGE VAULT +``` + +> 注意: +> +> 1. 只有 ADMIN 用户可以设置默认存储库 + +## 示例 + +1. 将名为 s3_vault 的存储库设置为默认存储库 + + ```sql + SET s3_vault AS DEFAULT STORAGE VAULT; + ``` + +## 相关命令 + +## 关键词 + + SET, DEFAULT, STORAGE, VAULT \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/SHOW-CACHE-HOTSPOT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/SHOW-CACHE-HOTSPOT.md new file mode 100644 index 0000000000000..5425504e037b8 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/SHOW-CACHE-HOTSPOT.md @@ -0,0 +1,61 @@ +--- +{ + "title": "SHOW CACHE HOTSPOT", + "language": "zh-CN" +} +--- + + + +## 描述 + +该语句用于显示文件缓存的热点信息。 + +## 语法 + +```sql + SHOW CACHE HOTSPOT '/[compute_group_name/table_name]'; +``` + +## 参数 + +* compute_group_name : 计算组的名称。 +* table_name : 表的名称。 + +## 示例 + +1. 查看某个表的创建语句 + + ```sql + SHOW CACHE HOTSPOT '/'; + ``` + +## 相关命令 + + - [WARMUP CACHE](../Database-Administration-Statements/WARM-UP-COMPUTE-GROUP.md) + +## 参考 + + - [MANAGING FILE CACHE](../../../compute-storage-decoupled/file-cache.md) + +## 关键词 + + SHOW, CACHE, HOTSPOT + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-POLICY-USING.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-POLICY-USING.md new file mode 100644 index 0000000000000..374d738a14f9e --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-POLICY-USING.md @@ -0,0 +1,70 @@ +--- +{ + "title": "SHOW STORAGE POLICY USING", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +查看所有/指定存储策略关联的表和分区 + +语法: + +```sql +SHOW STORAGE POLICY USING [FOR some_policy] +``` + +## 示例 + +1. 查看所有启用了存储策略的对象 + ```sql + mysql> show storage policy using; + +-----------------------+-----------------------------------------+----------------------------------------+------------+ + | PolicyName | Database | Table | Partitions | + +-----------------------+-----------------------------------------+----------------------------------------+------------+ + | test_storage_policy | regression_test_cold_heat_separation_p2 | table_with_storage_policy_1 | ALL | + | test_storage_policy | regression_test_cold_heat_separation_p2 | partition_with_multiple_storage_policy | p201701 | + | test_storage_policy_2 | regression_test_cold_heat_separation_p2 | partition_with_multiple_storage_policy | p201702 | + | test_storage_policy_2 | regression_test_cold_heat_separation_p2 | table_with_storage_policy_2 | ALL | + | test_policy | db2 | db2_test_1 | ALL | + +-----------------------+-----------------------------------------+----------------------------------------+------------+ + ``` +2. 查看使用存储策略 test_storage_policy 的对象 + + ```sql + mysql> show storage policy using for test_storage_policy; + +---------------------+-----------+---------------------------------+------------+ + | PolicyName | Database | Table | Partitions | + +---------------------+-----------+---------------------------------+------------+ + | test_storage_policy | db_1 | partition_with_storage_policy_1 | p201701 | + | test_storage_policy | db_1 | table_with_storage_policy_1 | ALL | + +---------------------+-----------+---------------------------------+------------+ + ``` + +## 关键词 + + SHOW, STORAGE, POLICY, USING + +### 最佳实践 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-POLICY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-POLICY.md new file mode 100644 index 0000000000000..3251af26b4b46 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-POLICY.md @@ -0,0 +1,77 @@ +--- +{ + "title": "SHOW STORAGE POLICY", + "language": "zh-CN" +} +--- + + +## 描述 + +查看所有/指定存储策略关联的表和分区。 + +## 语法 + +```sql +SHOW STORAGE POLICY USING [FOR ] +``` + +## 必选参数 + + + +> 要查看的存储策略的名字。 + +## 权限控制 + +执行此 SQL 命令成功的前置条件是,拥有 ADMIN_PRIV 权限,参考权限文档。 + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +| :---------------- | :--------------- | :-------------------------- | +| ADMIN_PRIV | 整个集群管理权限 | 除 NODE_PRIV 以外的所有权限 | + +## 示例 + +1. 查看所有启用了存储策略的对象。 + + ```sql + mysql> show storage policy using; + +-----------------------+-----------------------------------------+----------------------------------------+------------+ + | PolicyName | Database | Table | Partitions | + +-----------------------+-----------------------------------------+----------------------------------------+------------+ + | test_storage_policy | regression_test_cold_heat_separation_p2 | table_with_storage_policy_1 | ALL | + | test_storage_policy | regression_test_cold_heat_separation_p2 | partition_with_multiple_storage_policy | p201701 | + | test_storage_policy_2 | regression_test_cold_heat_separation_p2 | partition_with_multiple_storage_policy | p201702 | + | test_storage_policy_2 | regression_test_cold_heat_separation_p2 | table_with_storage_policy_2 | ALL | + | test_policy | db2 | db2_test_1 | ALL | + +-----------------------+-----------------------------------------+----------------------------------------+------------+ + ``` + +1. 查看使用存储策略 test_storage_policy 的对象。 + + ```sql + mysql> show storage policy using for test_storage_policy; + +---------------------+-----------+---------------------------------+------------+ + | PolicyName | Database | Table | Partitions | + +---------------------+-----------+---------------------------------+------------+ + | test_storage_policy | db_1 | partition_with_storage_policy_1 | p201701 | + | test_storage_policy | db_1 | table_with_storage_policy_1 | ALL | + +---------------------+-----------+---------------------------------+------------+ + ``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-VAULTS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-VAULTS.md new file mode 100644 index 0000000000000..7855f83d13f73 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-VAULTS.md @@ -0,0 +1,55 @@ +--- +{ + "title": "SHOW STORAGE VAULTS", + "language": "zh-CN" +} +--- + + + +## 描述 + +SHOW STORAGE VAULTS 命令用于显示系统中配置的所有 storage vault 的信息。storage vault 用于管理数据外部存储位置。 + +## 语法 + +```sql + SHOW STORAGE VAULTS +``` + +## Return Values + +此命令返回一个结果集,包含以下列: + +- `StorageVaultName`: storage vault 的名称。 +- `StorageVaultId`: storage vault 的 ID。 +- `Properties`: 包含 storage vault 配置属性的 JSON 字符串。 +- `IsDefault`: 指示该 storage vault 是否设置为默认值(TRUE 或 FALSE)。 + +## 相关命令 + +- [CREATE STORAGE VAULT](../Data-Definition-Statements/CREATE-STORAGE-VAULT.md) +- [GRANT](../account-management/GRANT-TO.md) +- [REVOKE](../account-management/REVOKE-FROM.md) +- [SET DEFAULT STORAGE VAULT](../Data-Definition-Statements/SET-DEFAULT-STORAGE-VAULT.md) + +## 关键词 + + SHOW, STORAGE VAULTS diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/SHOW-WARM-UP-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/SHOW-WARM-UP-JOB.md new file mode 100644 index 0000000000000..82e032371352b --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/SHOW-WARM-UP-JOB.md @@ -0,0 +1,65 @@ +--- +{ + "title": "SHOW WARM UP JOB", + "language": "en" +} +--- + + + +## 描述 + +这些命令用于在 Doris 中显示预热作业。 + +## 语法 + +```sql + SHOW WARM UP JOB [ WHERE id = 'id' ] ; +``` + +## 参数 + +* id : 预热作业的 id。 + +## 示例 + +1. 查看所有预热作业 + + ```sql + SHOW WARM UP JOB; + ``` + +2. 查看 id 为 13418 的预热作业 + +```sql + SHOW WARM UP JOB WHERE id = 13418; +``` + +## 相关命令 + + - [WARMUP COMPUTE GROUP](../Database-Administration-Statements/WARM-UP-COMPUTE-GROUP.md) + +## 参考 + + - [管理文件缓存](../../../compute-storage-decoupled/file-cache.md) + +## 关键字 + + SHOW, CACHE, HOTSPOT, COMPUTE GROUP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/UNSET-DEFAULT-STORAGE-VAULT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/UNSET-DEFAULT-STORAGE-VAULT.md new file mode 100644 index 0000000000000..e181543a12b3e --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/UNSET-DEFAULT-STORAGE-VAULT.md @@ -0,0 +1,46 @@ +--- +{ + "title": "UNSET DEFAULT STORAGE VAULT", + "language": "zh-CN" +} +--- + + +## 描述 + +取消已指定的默认 Storage Vault + +## 语法 + +```sql +UNSET DEFAULT STORAGE VAULT +``` + +## 权限控制 + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +| :---------------- | :------------- | :------------------------------ | +| ADMIN_PRIV | Storage Vault | 只有 admin 用户有权限执行该语句 | + +## 示例 + +```sql +UNSET DEFAULT STORAGE VAULT +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/WARM-UP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/WARM-UP.md new file mode 100644 index 0000000000000..57cca2d84f0c9 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/cluster-management/storage-management/WARM-UP.md @@ -0,0 +1,82 @@ +--- +{ + "title": "WARM UP", + "language": "zh_CN" +} +--- + + + +## 描述 + +WARM UP COMPUTE GROUP 语句用于预热计算组中的数据,以提高查询性能。预热操作可以从另一个计算组中获取资源,也可以指定特定的表和分区进行预热。预热操作返回一个作业 ID,可以用于追踪预热作业的状态。 + +## 语法 + +```sql + +WARM UP COMPUTE GROUP WITH COMPUTE GROUP FORCE; + +WARM UP COMPUTE GROUP WITH ; + +warm_up_list ::= warm_up_item [AND warm_up_item...]; + +warm_up_item ::= TABLE [PARTITION ]; + +``` + +## 参数 + +* destination_compute_group_name: 要预热的目标计算组的名称。 + +* source_compute_group_name: 从中获取资源的源集群的名称。 + +* warm_up_list: 要预热的特定项目的列表,可以包括表和分区。 + +* table_name: 用于预热的表的名称。 + +* partition_name: 用于预热的分区的名称。 + +## 返回值 + +* JobId: 预热作业的 ID。 + +## 示例 + +1. 使用名为 source_group_name 的计算组预热名为 destination_group_name 的计算组。 + +```sql + WARM UP COMPUTE GROUP destination_group_name WITH COMPUTE GROUP source_group_name; + +``` + +2. 使用名为 destination_group 的计算组预热表 sales_data 和 customer_info 以及表 orders 的分区 q1_2024。 + +``` + WARM UP COMPUTE GROUP destination_group WITH + TABLE sales_data + AND TABLE customer_info + AND TABLE orders PARTITION q1_2024; + +``` + +## 关键字 + + WARM UP, COMPUTE GROUP, CACHE diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/ALTER-SQL_BLOCK_RULE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/ALTER-SQL_BLOCK_RULE.md new file mode 100644 index 0000000000000..25bf7fc29268f --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/ALTER-SQL_BLOCK_RULE.md @@ -0,0 +1,65 @@ +--- +{ + "title": "ALTER SQL_BLOCK_RULE", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +修改 SQL 阻止规则,允许对 sql/sqlHash/partition_num/tablet_num/cardinality/global/enable 等每一项进行修改。 + +语法: + +```sql +ALTER SQL_BLOCK_RULE rule_name +[PROPERTIES ("key"="value", ...)]; +``` + +说明: + +- sql 和 sqlHash 不能同时被设置。这意味着,如果一个 rule 设置了 sql 或者 sqlHash,则另一个属性将无法被修改; +- sql/sqlHash 和 partition_num/tablet_num/cardinality 不能同时被设置。举个例子,如果一个 rule 设置了 partition_num,那么 sql 或者 sqlHash 将无法被修改; + +## 示例 + +1. 根据 SQL 属性进行修改 + +```sql +ALTER SQL_BLOCK_RULE test_rule PROPERTIES("sql"="select \\* from test_table","enable"="true") +``` + +2. 如果一个 rule 设置了 partition_num,那么 sql 或者 sqlHash 将无法被修改 + +```sql +ALTER SQL_BLOCK_RULE test_rule2 PROPERTIES("partition_num" = "10","tablet_num"="300","enable"="true") +``` + +## 关键词 + +```text +ALTER,SQL_BLOCK_RULE +``` + +### 最佳实践 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/CREATE-ROW-POLICY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/CREATE-ROW-POLICY.md new file mode 100644 index 0000000000000..2ebccbd8a6209 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/CREATE-ROW-POLICY.md @@ -0,0 +1,85 @@ +--- +{ + "title": "CREATE ROW POLICY", + "language": "zh-CN" +} +--- + + + + +## 描述 + +创建行安全策略,Explain 可以查看改写后的执行计划。 + +## 语法 + +```sql +CREATE ROW POLICY [ IF NOT EXISTS ] +ON +AS { RESTRICTIVE | PERMISSIVE } +TO { | ROLE } +USING (); +``` + +## 必选参数 + +1. ``: 行安全策略名称 + +2. ``: 表名称 + +3. ``: RESTRICTIVE 将一组策略通过 AND 连接,PERMISSIVE 将一组策略通过 OR 连接 + +3. ``: 相当于查询语句的过滤条件,例如:id=1 + +## 可选参数 + +1. ``: 用户名称,不允许对 root 和 admin 用户创建 + +2. ``: 角色名称 + +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +| :------------------------- | :------------- | :------------ | +| ADMIN_PRIV 或 *GRANT_PRIV* | 全局 | | + +## 示例 + +1. 创建一组行安全策略 + + ```sql + CREATE ROW POLICY test_row_policy_1 ON test.table1 + AS RESTRICTIVE TO test USING (c1 = 'a'); + CREATE ROW POLICY test_row_policy_2 ON test.table1 + AS RESTRICTIVE TO test USING (c2 = 'b'); + CREATE ROW POLICY test_row_policy_3 ON test.table1 + AS PERMISSIVE TO test USING (c3 = 'c'); + CREATE ROW POLICY test_row_policy_3 ON test.table1 + AS PERMISSIVE TO test USING (c4 = 'd'); + ``` + + 当我们执行对 table1 的查询时被改写后的 sql 为 + + ```sql + SELECT * FROM (SELECT * FROM table1 WHERE c1 = 'a' AND c2 = 'b' OR c3 = 'c' OR c4 = 'd') + ``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/CREATE-SQL_BLOCK_RULE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/CREATE-SQL_BLOCK_RULE.md new file mode 100644 index 0000000000000..bc57f8d567acd --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/CREATE-SQL_BLOCK_RULE.md @@ -0,0 +1,156 @@ +--- +{ + "title": "CREATE SQL_BLOCK_RULE", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句创建 SQL 阻止规则,该功能可用于限制任何 sql 语句(包括 DDL 和 DML 语句)。 + +支持按用户配置 SQL 黑名单: + +- 通过正则匹配的方式拒绝指定 SQL +- 通过设置 partition_num, tablet_num, cardinality, 检查一个查询是否达到其中一个限制 + - partition_num, tablet_num, cardinality 可以一起设置,一旦一个查询达到其中一个限制,查询将会被拦截 + +语法: + +```sql +CREATE SQL_BLOCK_RULE rule_name +[PROPERTIES ("key"="value", ...)]; +``` + +参数说明: + +- sql:匹配规则 (基于正则匹配,特殊字符需要转译,如`select *`使用`select \\*`),可选,默认值为 "NULL", 最后不要带分号 +- sqlHash: sql hash 值,用于完全匹配,我们会在`fe.audit.log`打印这个值,可选,这个参数和 sql 只能二选一,默认值为 "NULL" +- partition_num: 一个扫描节点会扫描的最大 partition 数量,默认值为 0L +- tablet_num: 一个扫描节点会扫描的最大 tablet 数量,默认值为 0L +- cardinality: 一个扫描节点粗略的扫描行数,默认值为 0L +- global:是否全局 (所有用户) 生效,默认为 false +- enable:是否开启阻止规则,默认为 true + +## 示例 + +1. 创建一个名称为 test_rule 的阻止规则 + + ```sql + CREATE SQL_BLOCK_RULE test_rule + PROPERTIES( + "sql"="select \\* from order_analysis", + "global"="false", + "enable"="true" + ); + ``` + 当我们去执行刚才我们定义在规则里的 sql 时就会返回异常错误,示例如下: + + ```sql + mysql> select * from order_analysis; + ERROR 1064 (HY000): errCode = 2, detailMessage = sql match regex sql block rule: order_analysis_rule + ``` + +2. 创建 test_rule2,将最大扫描的分区数量限制在 30 个,最大扫描基数限制在 100 亿行,示例如下: + + ```sql + CREATE SQL_BLOCK_RULE test_rule2 + PROPERTIES + ( + "partition_num" = "30", + "cardinality" = "10000000000", + "global" = "false", + "enable" = "true" + ); + Query OK, 0 rows affected (0.01 sec) + ``` + +3. 创建包含特殊字符的 SQL BLOCK RULE,正则表达式中 ( 和 ) 符号是特殊符号,所以需要转义,示例如下: + + ```sql + CREATE SQL_BLOCK_RULE test_rule3 + PROPERTIES + ( + "sql" = "select count\\(1\\) from db1.tbl1" + ); + CREATE SQL_BLOCK_RULE test_rule4 + PROPERTIES + ( + "sql" = "select \\* from db1.tbl1" + ); + ``` + +4. SQL_BLCOK_RULE 中,SQL 的匹配是基于正则的,如果想匹配更多模式的 SQL 需要写相应的正则,比如忽略 SQL +中空格,还有 order_ 开头的表都不能查询,示例如下: + + ```sql + CREATE SQL_BLOCK_RULE test_rule4 + PROPERTIES( + "sql"="\\s*select\\s*\\*\\s*from order_\\w*\\s*", + "global"="false", + "enable"="true" + ); + ``` + +### 附录 +常用正则表达式如下: + +> . :匹配任何单个字符,除了换行符 `\n`。 +> +> * :匹配前面的元素零次或多次。例如,a* 匹配零个或多个 'a'。 +> +> + :匹配前面的元素一次或多次。例如,a+ 匹配一个或多个 'a'。 +> +> ? :匹配前面的元素零次或一次。例如,a? 匹配零个或一个 'a'。 +> +> [] :用于定义字符集合。例如,[aeiou] 匹配任何一个元音字母。 +> +> [^] :在字符集合中使用 ^ 表示否定,匹配不在集合内的字符。例如,[^0-9] 匹配任何非数字字符。 +> +> () :用于分组表达式,可以对其应用量词。例如,(ab)+ 匹配连续的 'ab'。 +> +> | :用于表示或逻辑。例如,a|b 匹配 'a' 或 'b'。 +> +> ^ :匹配字符串的开头。例如,^abc 匹配以 'abc' 开头的字符串。 +> +> $ :匹配字符串的结尾。例如,xyz$ 匹配以 'xyz' 结尾的字符串。 +> +> \ :用于转义特殊字符,使其变成普通字符。例如,\\. 匹配句点字符 '.'。 +> +> \s:匹配任何空白字符,包括空格、制表符、换行符等。 +> +> \d:匹配任何数字字符,相当于 [0-9]。 +> +> \w:匹配任何单词字符,包括字母、数字和下划线,相当于 [a-zA-Z0-9_]。 + +## 关键词 + +```text +CREATE, SQL_BLCOK_RULE +``` + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/DROP-ROW-POLICY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/DROP-ROW-POLICY.md new file mode 100644 index 0000000000000..fc698e9a0aac7 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/DROP-ROW-POLICY.md @@ -0,0 +1,76 @@ +--- +{ + "title": "DROP ROW POLICY", + "language": "zh-CN" +} +--- + + + + +## 描述 +删除行安全策略。 + +## 语法 + +```sql +DROP ROW POLICY on + [ FOR { | ROLE } ]; +``` + +## 必选参数 + +1. ``:行安全策略名称 + +2. ``:表名称 + +## 可选参数 + +1. ``:用户名称 + +2. ``:角色名称 + +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +| :------------------------- | :------------- | :------------ | +| ADMIN_PRIV 或 *GRANT_PRIV* | 全局 | | + +## 示例 + +1. 删除 *db1.table1* 的 *policy1 行安全策略* + + ```sql + DROP ROW POLICY policy1 ON db1.table1 + ``` + +2. 删除 db1.table1 作用于 user1 的 policy1 行安全策略 + + ```sql + DROP ROW POLICY policy1 ON db1.table1 FOR user1 + ``` + +3. 删除 db1.table1 作用于 role1 的 policy1 行安全策略 + + ```sql + DROP ROW POLICY policy1 ON db1.table1 FOR role role1 + ``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/DROP-SQL_BLOCK_RULE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/DROP-SQL_BLOCK_RULE.md new file mode 100644 index 0000000000000..801dcb362e891 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/DROP-SQL_BLOCK_RULE.md @@ -0,0 +1,57 @@ +--- +{ + "title": "DROP SQL_BLOCK_RULE", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +删除 SQL 阻止规则,支持多规则,以,隔开 + +语法: + +```sql +DROP SQL_BLOCK_RULE test_rule1,... +``` + +## 示例 + +1. 删除 test_rule1、test_rule2 阻止规则 + + ```sql + mysql> DROP SQL_BLOCK_RULE test_rule1,test_rule2; + Query OK, 0 rows affected (0.00 sec) + ``` + +## 关键词 + +```text +DROP, SQL_BLOCK_RULE +``` + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/SHOW-ROW-POLICY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/SHOW-ROW-POLICY.md new file mode 100644 index 0000000000000..730be027f1203 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/SHOW-ROW-POLICY.md @@ -0,0 +1,70 @@ +--- +{ + "title": "SHOW ROW POLICY", + "language": "zh-CN" +} +--- + + + + +## 描述 + +查看行安全策略。 + +## 语法 + +```sql +SHOW ROW POLICY [ FOR { | ROLE } ]; +``` + +## 可选参数 + +1. ``: 用户名称 + +2. ``:角色名称 + +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +| :---------------- | :------------- | :------------ | +| ADMIN_PRIV | 全局 | | + +## 示例 + +1. 查看所有安全策略 + + ```sql + SHOW ROW POLICY; + ``` + +2. 指定用户名查询 + + ```sql + SHOW ROW POLICY FOR user1; + ``` + +3. 指定角色名查询 + + ```sql + SHOW ROW POLICY for role role1; + ``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/SHOW-SQL_BLOCK_RULE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/SHOW-SQL_BLOCK_RULE.md new file mode 100644 index 0000000000000..1fe08dbe9e13a --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-governance/SHOW-SQL_BLOCK_RULE.md @@ -0,0 +1,74 @@ +--- +{ + "title": "SHOW SQL_BLOCK_RULE", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +查看已配置的 SQL 阻止规则,不指定规则名则为查看所有规则。 + +语法: + +```sql +SHOW SQL_BLOCK_RULE [FOR RULE_NAME]; +``` + +## 示例 + +1. 查看所有规则。 + + ```sql + mysql> SHOW SQL_BLOCK_RULE; + +------------+------------------------+---------+--------------+-----------+-------------+--------+--------+ + | Name | Sql | SqlHash | PartitionNum | TabletNum | Cardinality | Global | Enable | + +------------+------------------------+---------+--------------+-----------+-------------+--------+--------+ + | test_rule | select * from order_analysis | NULL | 0 | 0 | 0 | true | true | + | test_rule2 | NULL | NULL | 30 | 0 | 10000000000 | false | true | + +------------+------------------------+---------+--------------+-----------+-------------+--------+--------+ + 2 rows in set (0.01 sec) + ``` + +2. 指定规则名查询 + + ```sql + mysql> SHOW SQL_BLOCK_RULE FOR test_rule2; + +------------+------+---------+--------------+-----------+-------------+--------+--------+ + | Name | Sql | SqlHash | PartitionNum | TabletNum | Cardinality | Global | Enable | + +------------+------+---------+--------------+-----------+-------------+--------+--------+ + | test_rule2 | NULL | NULL | 30 | 0 | 10000000000 | false | true | + +------------+------+---------+--------------+-----------+-------------+--------+--------+ + 1 row in set (0.00 sec) + + ``` + + +## 关键词 + + SHOW, SQL_BLOCK_RULE + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/DELETE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/DELETE.md new file mode 100644 index 0000000000000..98ee646b70224 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/DELETE.md @@ -0,0 +1,200 @@ +--- +{ + "title": "DELETE", + "language": "zh-CN" +} +--- + + + +## 描述 + +该语句用于按条件删除指定 table(base index)partition 中的数据。 + +该操作会同时删除和此 base index 相关的 rollup index 的数据。 + +## 语法 + +语法一:该语法只能指定过滤谓词 + +```SQL +DELETE FROM table_name [table_alias] [PARTITION partition_name | PARTITIONS (partition_name [, partition_name])] +WHERE +column_name op { value | value_list } [ AND column_name op { value | value_list } ...]; +``` + +语法二:该语法只能在 UNIQUE KEY 模型表上使用 + +```sql +[cte] +DELETE FROM table_name [table_alias] + [PARTITION partition_name | PARTITIONS (partition_name [, partition_name])] + [USING additional_tables] + WHERE condition +``` + +#### Required Parameters + ++ table_name: 指定需要删除数据的表 ++ column_name: 属于 table_name 的列 ++ op: 逻辑比较操作符,可选类型包括:=, >, <, >=, <=, !=, in, not in ++ value | value_list: 做逻辑比较的值或值列表 ++ WHERE condition: 指定一个用于选择删除行的条件 + +#### Optional Parameters + ++ cte: 通用表达式。可以是 'WITH a AS SELECT * FROM tbl' 形式 ++ PARTITION partition_name | PARTITIONS (partition_name [, partition_name]): 指定执行删除数据的分区名,如果表不存在此分区,则报错 ++ table_alias: 表的别名 ++ USING additional_tables: 如果需要在 WHERE 语句中使用其他的表来帮助识别需要删除的行,则可以在 USING 中指定这些表或者查询。 + +#### Note + +1. 使用聚合类的表模型(AGGREGATE、UNIQUE)只能指定 key 列上的条件。 +2. 当选定的 key 列不存在于某个 rollup 中时,无法进行 delete。 +3. 语法一中,条件之间只能是“与”的关系。若希望达成“或”的关系,需要将条件分写在两个 DELETE 语句中。 +4. 语法一中,如果为分区表,需要指定分区,如果不指定,doris 会从条件中推断出分区。两种情况下,doris 无法从条件中推断出分区:1) 条件中不包含分区列;2) 分区列的 op 为 not in。当分区表未指定分区,或者无法从条件中推断分区的时候,需要设置会话变量 delete_without_partition 为 true,此时 delete 会应用到所有分区。 +5. 该语句可能会降低执行后一段时间内的查询效率。影响程度取决于语句中指定的删除条件的数量。指定的条件越多,影响越大。 + +## 示例 + +1. 删除 my_table partition p1 中 k1 列值为 3 的数据行 + + ```sql + DELETE FROM my_table PARTITION p1 + WHERE k1 = 3; + ``` + +2. 删除 my_table partition p1 中 k1 列值大于等于 3 且 k2 列值为 "abc" 的数据行 + + ```sql + DELETE FROM my_table PARTITION p1 + WHERE k1 >= 3 AND k2 = "abc"; + ``` + +3. 删除 my_table partition p1, p2 中 k1 列值大于等于 3 且 k2 列值为 "abc" 的数据行 + + ```sql + DELETE FROM my_table PARTITIONS (p1, p2) + WHERE k1 >= 3 AND k2 = "abc"; + ``` + +4. 使用`t2`和`t3`表连接的结果,删除`t1`中的数据,删除的表只支持 unique 模型 + + ```sql + -- 创建 t1, t2, t3 三张表 + CREATE TABLE t1 + (id INT, c1 BIGINT, c2 STRING, c3 DOUBLE, c4 DATE) + UNIQUE KEY (id) + DISTRIBUTED BY HASH (id) + PROPERTIES('replication_num'='1', "function_column.sequence_col" = "c4"); + + CREATE TABLE t2 + (id INT, c1 BIGINT, c2 STRING, c3 DOUBLE, c4 DATE) + DISTRIBUTED BY HASH (id) + PROPERTIES('replication_num'='1'); + + CREATE TABLE t3 + (id INT) + DISTRIBUTED BY HASH (id) + PROPERTIES('replication_num'='1'); + + -- 插入数据 + INSERT INTO t1 VALUES + (1, 1, '1', 1.0, '2000-01-01'), + (2, 2, '2', 2.0, '2000-01-02'), + (3, 3, '3', 3.0, '2000-01-03'); + + INSERT INTO t2 VALUES + (1, 10, '10', 10.0, '2000-01-10'), + (2, 20, '20', 20.0, '2000-01-20'), + (3, 30, '30', 30.0, '2000-01-30'), + (4, 4, '4', 4.0, '2000-01-04'), + (5, 5, '5', 5.0, '2000-01-05'); + + INSERT INTO t3 VALUES + (1), + (4), + (5); + + -- 删除 t1 中的数据 + DELETE FROM t1 + USING t2 INNER JOIN t3 ON t2.id = t3.id + WHERE t1.id = t2.id; + ``` + + 预期结果为,删除了`t1`表`id`为`1`的列 + + ``` + +----+----+----+--------+------------+ + | id | c1 | c2 | c3 | c4 | + +----+----+----+--------+------------+ + | 2 | 2 | 2 | 2.0 | 2000-01-02 | + | 3 | 3 | 3 | 3.0 | 2000-01-03 | + +----+----+----+--------+------------+ + ``` + +5. 使用 cte 关联删除 + + ```sql + create table orders( + o_orderkey bigint, + o_totalprice decimal(15, 2) + ) unique key(o_orderkey) + distributed by hash(o_orderkey) buckets 1 + properties ( + "replication_num" = "1" + ); + + insert into orders values + (1, 34.1), + (2, 432.8); + + create table lineitem( + l_linenumber int, + o_orderkey bigint, + l_discount decimal(15, 2) + ) unique key(l_linenumber) + distributed by hash(l_linenumber) buckets 1 + properties ( + "replication_num" = "1" + ); + + insert into lineitem values + (1, 1, 1.23), + (2, 1, 3.21), + (3, 2, 18.08), + (4, 2, 23.48); + + with discount_orders as ( + select * from orders + where o_totalprice > 100 + ) + delete from lineitem + using discount_orders + where lineitem.o_orderkey = discount_orders.o_orderkey; + ``` + +## 关键词 + + DELETE + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/INSERT-OVERWRITE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/INSERT-OVERWRITE.md new file mode 100644 index 0000000000000..5464ac8469a88 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/INSERT-OVERWRITE.md @@ -0,0 +1,294 @@ +--- +{ + "title": "INSERT OVERWRITE", + "language": "zh-CN" +} + +--- + + + + +## 描述 + +该语句的功能是重写表或表的某些分区 + +```sql +INSERT OVERWRITE table table_name + [ PARTITION (p1, ... | *) ] + [ WITH LABEL label] + [ (column [, ...]) ] + [ [ hint [, ...] ] ] + { VALUES ( { expression | DEFAULT } [, ...] ) [, ...] | query } +``` + + Parameters + +> table_name: 需要重写的目的表。这个表必须存在。可以是 `db_name.table_name` 形式 +> +> partitions: 需要重写的目标分区,支持两种形式: +> +>> 1. 分区名。必须是 `table_name` 中存在的分区,多个分区名称用逗号分隔。 +>> 2. 星号 (*)。开启[自动检测分区](#overwrite-auto-detect-partition)功能。写入操作将会自动检测数据所涉及的分区,并覆写这些分区。 +> +> label: 为 Insert 任务指定一个 label +> +> column_name: 指定的目的列,必须是 `table_name` 中存在的列 +> +> expression: 需要赋值给某个列的对应表达式 +> +> DEFAULT: 让对应列使用默认值 +> +> query: 一个普通查询,查询的结果会重写到目标中 +> +> hint: 用于指示 `INSERT` 执行行为的一些指示符。目前 hint 有三个可选值`/*+ STREAMING */`、`/*+ SHUFFLE */`或`/*+ NOSHUFFLE */` +> +> 1. STREAMING:目前无实际作用,只是为了兼容之前的版本,因此保留。(之前的版本加上这个 hint 会返回 label,现在默认都会返回 label) +> 2. SHUFFLE:当目标表是分区表,开启这个 hint 会进行 repartiiton。 +> 3. NOSHUFFLE:即使目标表是分区表,也不会进行 repartiiton,但会做一些其他操作以保证数据正确落到各个分区中。 + +注意: + +1. 在当前版本中,会话变量 `enable_insert_strict` 默认为 `true`,如果执行 `INSERT OVERWRITE` 语句时,对于有不符合目标表格式的数据被过滤掉的话会重写目标表失败(比如重写分区时,不满足所有分区条件的数据会被过滤)。 +2. INSERT OVERWRITE 语句会首先创建一个新表,将需要重写的数据插入到新表中,最后原子性的用新表替换旧表并修改名称。因此,在重写表的过程中,旧表中的数据在重写完毕之前仍然可以正常访问。 + +#### For Auto Partition Table + +如果 INSERT OVERWRITE 的目标表是自动分区表,那么行为受到 [Session Variable](../#变量) `enable_auto_create_when_overwrite` 的控制,具体行为如下: +1. 若未指定 PARTITION(覆写整表),当 `enable_auto_create_when_overwrite` 为 `true`,在覆写整表已有数据的同时,对于没有对应分区的数据,按照该表的自动分区规则创建分区,并容纳这些原本没有对应分区的数据。如果 `enable_auto_create_when_overwrite` 为 `false`,未找到分区的数据将累计错误行直到失败。 +2. 如果指定了覆写的 PARTITION,那么在此过程中,AUTO PARTITION 表表现得如同普通分区表一样,不满足现有分区条件的数据将被过滤,而非创建新的分区。 +3. 若指定 PARTITION 为 `partition(*)` (自动检测分区并覆写),当 `enable_auto_create_when_overwrite` 为 `true`,对于那些在表中有对应分区的数据,覆写它们对应的分区,其他已有分区不变。同时,对于没有对应分区的数据,按照该表的自动分区规则创建分区,并容纳这些原本没有对应分区的数据。如果 `enable_auto_create_when_overwrite` 为 `false`,未找到分区的数据将累计错误行直到失败。 + +`enable_auto_create_when_overwrite` 自 3.0.3 引入,在没有 `enable_auto_create_when_overwrite` 的版本,行为如同该变量值为 `false`。 + +示例如下: + +```sql +mysql> create table auto_list( + -> k0 varchar null + -> ) + -> auto partition by list (k0) + -> ( + -> PARTITION p1 values in (("Beijing"), ("BEIJING")), + -> PARTITION p2 values in (("Shanghai"), ("SHANGHAI")), + -> PARTITION p3 values in (("xxx"), ("XXX")), + -> PARTITION p4 values in (("list"), ("LIST")), + -> PARTITION p5 values in (("1234567"), ("7654321")) + -> ) + -> DISTRIBUTED BY HASH(`k0`) BUCKETS 1 + -> properties("replication_num" = "1"); +Query OK, 0 rows affected (0.14 sec) + +mysql> insert into auto_list values ("Beijing"),("Shanghai"),("xxx"),("list"),("1234567"); +Query OK, 5 rows affected (0.22 sec) + +mysql> insert overwrite table auto_list partition(*) values ("BEIJING"), ("new1"); +Query OK, 2 rows affected (0.28 sec) + +mysql> select * from auto_list; ++----------+ --- p1 被覆写,new1 得到了新分区,其他分区数据未变 +| k0 | ++----------+ +| 1234567 | +| BEIJING | +| list | +| xxx | +| new1 | +| Shanghai | ++----------+ +6 rows in set (0.48 sec) + +mysql> insert overwrite table auto_list values ("SHANGHAI"), ("new2"); +Query OK, 2 rows affected (0.17 sec) + +mysql> select * from auto_list; ++----------+ --- 整表原有数据被覆写,同时 new2 得到了新分区 +| k0 | ++----------+ +| new2 | +| SHANGHAI | ++----------+ +2 rows in set (0.15 sec) +``` + +## 示例 + +假设有`test` 表。该表包含两个列`c1`, `c2`,两个分区`p1`,`p2`。建表语句如下所示 + +```sql +CREATE TABLE IF NOT EXISTS test ( + `c1` int NOT NULL DEFAULT "1", + `c2` int NOT NULL DEFAULT "4" +) ENGINE=OLAP +UNIQUE KEY(`c1`) +PARTITION BY LIST (`c1`) +( +PARTITION p1 VALUES IN ("1","2","3"), +PARTITION p2 VALUES IN ("4","5","6") +) +DISTRIBUTED BY HASH(`c1`) BUCKETS 3 +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1", + "in_memory" = "false", + "storage_format" = "V2" +); +``` + +#### Overwrite Table + +1. VALUES 的形式重写`test`表 + + ```sql + # 单行重写 + INSERT OVERWRITE table test VALUES (1, 2); + INSERT OVERWRITE table test (c1, c2) VALUES (1, 2); + INSERT OVERWRITE table test (c1, c2) VALUES (1, DEFAULT); + INSERT OVERWRITE table test (c1) VALUES (1); + # 多行重写 + INSERT OVERWRITE table test VALUES (1, 2), (3, 2 + 2); + INSERT OVERWRITE table test (c1, c2) VALUES (1, 2), (3, 2 * 2); + INSERT OVERWRITE table test (c1, c2) VALUES (1, DEFAULT), (3, DEFAULT); + INSERT OVERWRITE table test (c1) VALUES (1), (3); + ``` + +- 第一条语句和第二条语句的效果一致,重写时如果不指定目标列,会使用表中的列顺序来作为默认的目标列。重写成功后表`test`中只有一行数据。 +- 第三条语句和第四条语句的效果一致,没有指定的列`c2`会使用默认值 4 来完成数据重写。重写成功后表`test`中只有一行数据。 +- 第五条语句和第六条语句的效果一致,在语句中可以使用表达式(如`2+2`,`2*2`),执行语句的时候会计算出表达式的结果再重写表`test`。重写成功后表`test`中有两行数据。 + +- 第七条语句和第八条语句的效果一致,没有指定的列`c2`会使用默认值 4 来完成数据重写。重写成功后表`test`中有两行数据。 + +2. 查询语句的形式重写`test`表,表`test2`和表`test`的数据格式需要保持一致,如果不一致会触发数据类型的隐式转换 + + ```sql + INSERT OVERWRITE table test SELECT * FROM test2; + INSERT OVERWRITE table test (c1, c2) SELECT * from test2; + ``` + +- 第一条语句和第二条语句的效果一致,该语句的作用是将数据从表`test2`中取出,使用取出的数据重写表`test`。重写成功后表`test`中的数据和表`test2`中的数据保持一致。 + +3. 重写 `test` 表并指定 label + + ```sql + INSERT OVERWRITE table test WITH LABEL `label1` SELECT * FROM test2; + INSERT OVERWRITE table test WITH LABEL `label2` (c1, c2) SELECT * from test2; + ``` + +- 使用 label 会将此任务封装成一个**异步任务**,执行语句之后,相关操作都会异步执行,用户可以通过`SHOW LOAD;`命令查看此`label`导入作业的状态。需要注意的是 label 具有唯一性。 + + +#### Overwrite Table Partition + +使用 INSERT OVERWRITE 重写分区时,实际我们是将如下三步操作封装为一个事务并执行,如果中途失败,已进行的操作将会回滚: +1. 假设指定重写分区 p1,首先创建一个与重写的目标分区结构相同的空临时分区 `pTMP` +2. 向 `pTMP` 中写入数据 +3. 使用 `pTMP` 原子替换 `p1` 分区 + +举例如下: + +1. VALUES 的形式重写`test`表分区`P1`和`p2` + + ```sql + # 单行重写 + INSERT OVERWRITE table test PARTITION(p1,p2) VALUES (1, 2); + INSERT OVERWRITE table test PARTITION(p1,p2) (c1, c2) VALUES (1, 2); + INSERT OVERWRITE table test PARTITION(p1,p2) (c1, c2) VALUES (1, DEFAULT); + INSERT OVERWRITE table test PARTITION(p1,p2) (c1) VALUES (1); + # 多行重写 + INSERT OVERWRITE table test PARTITION(p1,p2) VALUES (1, 2), (4, 2 + 2); + INSERT OVERWRITE table test PARTITION(p1,p2) (c1, c2) VALUES (1, 2), (4, 2 * 2); + INSERT OVERWRITE table test PARTITION(p1,p2) (c1, c2) VALUES (1, DEFAULT), (4, DEFAULT); + INSERT OVERWRITE table test PARTITION(p1,p2) (c1) VALUES (1), (4); + ``` + + 以上语句与重写表不同的是,它们都是重写表中的分区。分区可以一次重写一个分区也可以一次重写多个分区。需要注意的是,只有满足对应分区过滤条件的数据才能够重写成功。如果重写的数据中有数据不满足其中任意一个分区,那么本次重写会失败。一个失败的例子如下所示 + + ```sql + INSERT OVERWRITE table test PARTITION(p1,p2) VALUES (7, 2); + ``` + + 以上语句重写的数据`c1=7`分区`p1`和`p2`的条件都不满足,因此会重写失败。 + +2. 查询语句的形式重写`test`表分区`P1`和`p2`,表`test2`和表`test`的数据格式需要保持一致,如果不一致会触发数据类型的隐式转换 + + ```sql + INSERT OVERWRITE table test PARTITION(p1,p2) SELECT * FROM test2; + INSERT OVERWRITE table test PARTITION(p1,p2) (c1, c2) SELECT * from test2; + ``` + +3. 重写 `test` 表分区`P1`和`p2`并指定 label + + ```sql + INSERT OVERWRITE table test PARTITION(p1,p2) WITH LABEL `label3` SELECT * FROM test2; + INSERT OVERWRITE table test PARTITION(p1,p2) WITH LABEL `label4` (c1, c2) SELECT * from test2; + ``` + +#### Overwrite Auto Detect Partition + +当 INSERT OVERWRITE 命令指定的 PARTITION 子句为 `PARTITION(*)` 时,此次覆写将会自动检测分区数据所在的分区。例如: + +```sql +mysql> create table test( + -> k0 int null + -> ) + -> partition by range (k0) + -> ( + -> PARTITION p10 values less than (10), + -> PARTITION p100 values less than (100), + -> PARTITION pMAX values less than (maxvalue) + -> ) + -> DISTRIBUTED BY HASH(`k0`) BUCKETS 1 + -> properties("replication_num" = "1"); +Query OK, 0 rows affected (0.11 sec) + +mysql> insert into test values (1), (2), (15), (100), (200); +Query OK, 5 rows affected (0.29 sec) + +mysql> select * from test order by k0; ++------+ +| k0 | ++------+ +| 1 | +| 2 | +| 15 | +| 100 | +| 200 | ++------+ +5 rows in set (0.23 sec) + +mysql> insert overwrite table test partition(*) values (3), (1234); +Query OK, 2 rows affected (0.24 sec) + +mysql> select * from test order by k0; ++------+ +| k0 | ++------+ +| 3 | +| 15 | +| 1234 | ++------+ +3 rows in set (0.20 sec) +``` + +可以看到,数据 3、1234 所在的分区 `p10` 和 `pMAX` 中的全部数据均被覆写,而 `p100` 分区未发生变化。该操作可以理解为 INSERT OVERWRITE 操作时通过 PARTITION 子句指定覆写特定分区的语法糖,它的实现原理与[指定重写特定分区](#overwrite-table-partition)相同。通过 `PARTITION(*)` 的语法,在覆写大量分区数据时我们可以免于手动填写全部分区名的繁琐。 + +## 关键词 + + INSERT OVERWRITE, OVERWRITE, AUTO DETECT + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/INSERT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/INSERT.md new file mode 100644 index 0000000000000..3945ed2052402 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/INSERT.md @@ -0,0 +1,231 @@ +--- +{ + "title": "INSERT", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句是完成数据插入操作。 + +```sql +INSERT INTO table_name + [ PARTITION (p1, ...) ] + [ WITH LABEL label] + [ (column [, ...]) ] + [ [ hint [, ...] ] ] + { VALUES ( { expression | DEFAULT } [, ...] ) [, ...] | query } +``` + + Parameters + +> tablet_name: 导入数据的目的表。可以是 `db_name.table_name` 形式 +> +> partitions: 指定待导入的分区,必须是 `table_name` 中存在的分区,多个分区名称用逗号分隔 +> +> label: 为 Insert 任务指定一个 label +> +> column_name: 指定的目的列,必须是 `table_name` 中存在的列 +> +> expression: 需要赋值给某个列的对应表达式 +> +> DEFAULT: 让对应列使用默认值 +> +> query: 一个普通查询,查询的结果会写入到目标中 +> +> hint: 用于指示 `INSERT` 执行行为的一些指示符。目前 hint 有三个可选值`/*+ STREAMING */`、`/*+ SHUFFLE */`或`/*+ NOSHUFFLE */` +> 1. STREAMING:目前无实际作用,只是为了兼容之前的版本,因此保留。(之前的版本加上这个 hint 会返回 label,现在默认都会返回 label) +> 2. SHUFFLE:当目标表是分区表,开启这个 hint 会进行 repartiiton。 +> 3. NOSHUFFLE:即使目标表是分区表,也不会进行 repartiiton,但会做一些其他操作以保证数据正确落到各个分区中。 + +对于开启了 merge-on-write 的 Unique 表,还可以使用 insert 语句进行部分列更新的操作。要使用 insert 语句进行部分列更新,需要将会话变量 enable_unique_key_partial_update 的值设置为 true(该变量默认值为 false,即默认无法通过 insert 语句进行部分列更新)。进行部分列更新时,插入的列必须至少包含所有的 Key 列,同时指定需要更新的列。如果插入行 Key 列的值在原表中存在,则将更新具有相同 key 列值那一行的数据。如果插入行 Key 列的值在原表中不存在,则将向表中插入一条新的数据,此时 insert 语句中没有指定的列必须有默认值或可以为 null,这些缺失列会首先尝试用默认值填充,如果该列没有默认值,则尝试使用 null 值填充,如果该列不能为 null,则本次插入失败。 + +需要注意的是,控制 insert 语句是否开启严格模式的会话变量`enable_insert_strict`的默认值为 true,即 insert 语句默认开启严格模式,而在严格模式下进行部分列更新不允许更新不存在的 key。所以,在使用 insert 语句进行部分列更新的时候如果希望能插入不存在的 key,需要在`enable_unique_key_partial_update`设置为 true 的基础上同时将`enable_insert_strict`设置为 false。 + +注意: + +当前执行 `INSERT` 语句时,对于有不符合目标表格式的数据,默认的行为是过滤,比如字符串超长等。但是对于有要求数据不能够被过滤的业务场景,可以通过设置会话变量 `enable_insert_strict` 为 `true` 来确保当有数据被过滤掉的时候,`INSERT` 不会被执行成功。 + +## 示例 + +`test` 表包含两个列`c1`, `c2`。 + +1. 向`test`表中导入一行数据 + +```sql +INSERT INTO test VALUES (1, 2); +INSERT INTO test (c1, c2) VALUES (1, 2); +INSERT INTO test (c1, c2) VALUES (1, DEFAULT); +INSERT INTO test (c1) VALUES (1); +``` + +其中第一条、第二条语句是一样的效果。在不指定目标列时,使用表中的列顺序来作为默认的目标列。 +第三条、第四条语句表达的意思是一样的,使用`c2`列的默认值,来完成数据导入。 + +2. 向`test`表中一次性导入多行数据 + +```sql +INSERT INTO test VALUES (1, 2), (3, 2 + 2); +INSERT INTO test (c1, c2) VALUES (1, 2), (3, 2 * 2); +INSERT INTO test (c1) VALUES (1), (3); +INSERT INTO test (c1, c2) VALUES (1, DEFAULT), (3, DEFAULT); +``` + +其中第一条、第二条语句效果一样,向`test`表中一次性导入两条数据 +第三条、第四条语句效果已知,使用`c2`列的默认值向`test`表中导入两条数据 + +3. 向 `test` 表中导入一个查询语句结果 + +```sql +INSERT INTO test SELECT * FROM test2; +INSERT INTO test (c1, c2) SELECT * from test2; +``` + +4. 向 `test` 表中导入一个查询语句结果,并指定 partition 和 label + +```sql +INSERT INTO test PARTITION(p1, p2) WITH LABEL `label1` SELECT * FROM test2; +INSERT INTO test WITH LABEL `label1` (c1, c2) SELECT * from test2; +``` + + +## 关键词 + + INSERT + +### 最佳实践 + +1. 查看返回结果 + + INSERT 操作是一个同步操作,返回结果即表示操作结束。用户需要根据返回结果的不同,进行对应的处理。 + + 1. 执行成功,结果集为空 + + 如果 insert 对应 select 语句的结果集为空,则返回如下: + + ```sql + mysql> insert into tbl1 select * from empty_tbl; + Query OK, 0 rows affected (0.02 sec) + ``` + + `Query OK` 表示执行成功。`0 rows affected` 表示没有数据被导入。 + + 2. 执行成功,结果集不为空 + + 在结果集不为空的情况下。返回结果分为如下几种情况: + + 1. Insert 执行成功并可见: + + ```sql + mysql> insert into tbl1 select * from tbl2; + Query OK, 4 rows affected (0.38 sec) + {'label':'insert_8510c568-9eda-4173-9e36-6adc7d35291c', 'status':'visible', 'txnId':'4005'} + + mysql> insert into tbl1 with label my_label1 select * from tbl2; + Query OK, 4 rows affected (0.38 sec) + {'label':'my_label1', 'status':'visible', 'txnId':'4005'} + + mysql> insert into tbl1 select * from tbl2; + Query OK, 2 rows affected, 2 warnings (0.31 sec) + {'label':'insert_f0747f0e-7a35-46e2-affa-13a235f4020d', 'status':'visible', 'txnId':'4005'} + + mysql> insert into tbl1 select * from tbl2; + Query OK, 2 rows affected, 2 warnings (0.31 sec) + {'label':'insert_f0747f0e-7a35-46e2-affa-13a235f4020d', 'status':'committed', 'txnId':'4005'} + ``` + + `Query OK` 表示执行成功。`4 rows affected` 表示总共有 4 行数据被导入。`2 warnings` 表示被过滤的行数。 + + 同时会返回一个 json 串: + + ```json + {'label':'my_label1', 'status':'visible', 'txnId':'4005'} + {'label':'insert_f0747f0e-7a35-46e2-affa-13a235f4020d', 'status':'committed', 'txnId':'4005'} + {'label':'my_label1', 'status':'visible', 'txnId':'4005', 'err':'some other error'} + ``` + + `label` 为用户指定的 label 或自动生成的 label。Label 是该 Insert Into 导入作业的标识。每个导入作业,都有一个在单 database 内部唯一的 Label。 + + `status` 表示导入数据是否可见。如果可见,显示 `visible`,如果不可见,显示 `committed`。 + + `txnId` 为这个 insert 对应的导入事务的 id。 + + `err` 字段会显示一些其他非预期错误。 + + 当需要查看被过滤的行时,用户可以通过如下语句 + + ```sql + show load where label="xxx"; + ``` + + 返回结果中的 URL 可以用于查询错误的数据,具体见后面 **查看错误行** 小结。 + + **数据不可见是一个临时状态,这批数据最终是一定可见的** + + 可以通过如下语句查看这批数据的可见状态: + + ```sql + show transaction where id=4005; + ``` + + 返回结果中的 `TransactionStatus` 列如果为 `visible`,则表述数据可见。 + + 3. 执行失败 + + 执行失败表示没有任何数据被成功导入,并返回如下: + + ```sql + mysql> insert into tbl1 select * from tbl2 where k1 = "a"; + ERROR 1064 (HY000): all partitions have no load data. url: http://10.74.167.16:8042/api/_load_error_log?file=__shard_2/error_log_insert_stmt_ba8bb9e158e4879-ae8de8507c0bf8a2_ba8bb9e158e4879_ae8de8507c0bf8a2 + ``` + + 其中 `ERROR 1064 (HY000): all partitions have no load data` 显示失败原因。后面的 url 可以用于查询错误的数据: + + ```sql + show load warnings on "url"; + ``` + + 可以查看到具体错误行。 + +2. 超时时间 + + INSERT 操作的超时时间由 [会话变量](../../../../advanced/variables.md) `insert_timeout` 控制。默认为 4 小时。超时则作业会被取消。 + +3. Label 和原子性 + + INSERT 操作同样能够保证导入的原子性,可以参阅 [导入事务和原子性](../../../../data-operate/import/import-scenes/load-atomicity.md) 文档。 + + 当需要使用 `CTE(Common Table Expressions)` 作为 insert 操作中的查询部分时,必须指定 `WITH LABEL` 和 `column` 部分。 + +4. 过滤阈值 + + 与其他导入方式不同,INSERT 操作不能指定过滤阈值(`max_filter_ratio`)。默认的过滤阈值为 1,即素有错误行都可以被忽略。 + + 对于有要求数据不能够被过滤的业务场景,可以通过设置 [会话变量](../../../../advanced/variables.md) `enable_insert_strict` 为 `true` 来确保当有数据被过滤掉的时候,`INSERT` 不会被执行成功。 + +5. 性能问题 + + 不建议使用 `VALUES` 方式进行单行的插入。如果必须这样使用,请将多行数据合并到一个 INSERT 语句中进行批量提交。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/SHOW-DELETE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/SHOW-DELETE.md new file mode 100644 index 0000000000000..ca0f005d9284f --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/SHOW-DELETE.md @@ -0,0 +1,53 @@ +--- +{ + "title": "SHOW DELETE", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于展示已执行成功的历史 delete 任务 + +语法: + +```sql +SHOW DELETE [FROM db_name] +``` + +## 示例 + + 1. 展示数据库 database 的所有历史 delete 任务 + + ```sql + SHOW DELETE FROM database; + ``` + +## 关键词 + + SHOW, DELETE + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/SHOW-LAST-INSERT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/SHOW-LAST-INSERT.md new file mode 100644 index 0000000000000..4f91090a5c22a --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/SHOW-LAST-INSERT.md @@ -0,0 +1,74 @@ +--- +{ + "title": "SHOW LAST INSERT", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语法用于查看在当前 session 连接中,最近一次 insert 操作的结果 + +语法: + +```sql +SHOW LAST INSERT +``` + +返回结果示例: + +``` + TransactionId: 64067 + Label: insert_ba8f33aea9544866-8ed77e2844d0cc9b + Database: default_cluster:db1 + Table: t1 +TransactionStatus: VISIBLE + LoadedRows: 2 + FilteredRows: 0 +``` + +说明: + +* TransactionId:事务 id +* Label:insert 任务对应的 label +* Database:insert 对应的数据库 +* Table:insert 对应的表 +* TransactionStatus:事务状态 + * PREPARE:准备阶段 + * PRECOMMITTED:预提交阶段 + * COMMITTED:事务成功,但数据不可见 + * VISIBLE:事务成功且数据可见 + * ABORTED:事务失败 +* LoadedRows:导入的行数 +* FilteredRows:被过滤的行数 + +## 示例 + +## 关键词 + + SHOW, LAST, INSERT + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/UPDATE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/UPDATE.md new file mode 100644 index 0000000000000..b7ae77d6b1246 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/DML/UPDATE.md @@ -0,0 +1,177 @@ +--- +{ + "title": "UPDATE", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句是为进行对数据进行更新的操作,UPDATE 语句目前仅支持 UNIQUE KEY 模型。 + +UPDATE 操作目前只支持更新 Value 列,Key 列的更新可参考[使用 FlinkCDC 更新 Key 列](../../../../ecosystem/flink-doris-connector.md#使用flinkcdc更新key列)。 + +## 语法 + +```sql +[cte] +UPDATE target_table [table_alias] + SET assignment_list + [ FROM additional_tables] + WHERE condition +``` + +#### Required Parameters + ++ target_table: 待更新数据的目标表。可以是 'db_name.table_name' 形式 ++ assignment_list: 待更新的目标列,形如 'col_name = value, col_name = value' 格式 ++ WHERE condition: 期望更新的条件,一个返回 true 或者 false 的表达式即可 + +#### Optional Parameters + ++ cte: 通用表达式。可以是 'WITH a AS SELECT * FROM tbl' 形式 ++ table_alias: 表的别名 ++ FROM additional_tables: 指定一个或多个表,用于选中更新的行,或者获取更新的值。注意,如需要在此列表中再次使用目标表,需要为其显式指定别名。 + +#### Note + +当前 UPDATE 语句仅支持在 UNIQUE KEY 模型上的行更新。 + +## 示例 + +`test` 表是一个 unique 模型的表,包含:k1, k2, v1, v2 四个列。其中 k1, k2 是 key,v1, v2 是 value,聚合方式是 Replace。 + +1. 将 'test' 表中满足条件 k1 =1 , k2 =2 的 v1 列更新为 1 + +```sql +UPDATE test SET v1 = 1 WHERE k1=1 and k2=2; +``` + +2. 将 'test' 表中 k1=1 的列的 v1 列自增 1 + +```sql +UPDATE test SET v1 = v1+1 WHERE k1=1; +``` + +3. 使用`t2`和`t3`表连接的结果,更新`t1` + +```sql +-- 创建 t1, t2, t3 三张表 +CREATE TABLE t1 + (id INT, c1 BIGINT, c2 STRING, c3 DOUBLE, c4 DATE) +UNIQUE KEY (id) +DISTRIBUTED BY HASH (id) +PROPERTIES('replication_num'='1', "function_column.sequence_col" = "c4"); + +CREATE TABLE t2 + (id INT, c1 BIGINT, c2 STRING, c3 DOUBLE, c4 DATE) +DISTRIBUTED BY HASH (id) +PROPERTIES('replication_num'='1'); + +CREATE TABLE t3 + (id INT) +DISTRIBUTED BY HASH (id) +PROPERTIES('replication_num'='1'); + +-- 插入数据 +INSERT INTO t1 VALUES + (1, 1, '1', 1.0, '2000-01-01'), + (2, 2, '2', 2.0, '2000-01-02'), + (3, 3, '3', 3.0, '2000-01-03'); + +INSERT INTO t2 VALUES + (1, 10, '10', 10.0, '2000-01-10'), + (2, 20, '20', 20.0, '2000-01-20'), + (3, 30, '30', 30.0, '2000-01-30'), + (4, 4, '4', 4.0, '2000-01-04'), + (5, 5, '5', 5.0, '2000-01-05'); + +INSERT INTO t3 VALUES + (1), + (4), + (5); + +-- 更新 t1 +UPDATE t1 + SET t1.c1 = t2.c1, t1.c3 = t2.c3 * 100 + FROM t2 INNER JOIN t3 ON t2.id = t3.id + WHERE t1.id = t2.id; +``` + +预期结果为,更新了`t1`表`id`为`1`的列 + +``` ++----+----+----+--------+------------+ +| id | c1 | c2 | c3 | c4 | ++----+----+----+--------+------------+ +| 1 | 10 | 1 | 1000.0 | 2000-01-01 | +| 2 | 2 | 2 | 2.0 | 2000-01-02 | +| 3 | 3 | 3 | 3.0 | 2000-01-03 | ++----+----+----+--------+------------+ +``` + +4. 使用 cte 更新表 + +```sql +create table orders( + o_orderkey bigint, + o_totalprice decimal(15, 2) +) unique key(o_orderkey) +distributed by hash(o_orderkey) buckets 1 +properties ( + "replication_num" = "1" +); + +insert into orders values +(1, 34.1), +(2, 432.8); + +create table lineitem( + l_linenumber int, + o_orderkey bigint, + l_discount decimal(15, 2) +) unique key(l_linenumber) +distributed by hash(l_linenumber) buckets 1 +properties ( + "replication_num" = "1" +); + +insert into lineitem values +(1, 1, 1.23), +(2, 1, 3.21), +(3, 2, 18.08), +(4, 2, 23.48); + +with discount_orders as ( + select * from orders + where o_totalprice > 100 +) +update lineitem set l_discount = l_discount*0.9 +from discount_orders +where lineitem.o_orderkey = discount_orders.o_orderkey; +``` + +## 关键词 + + UPDATE diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/ALTER-REPOSITORY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/ALTER-REPOSITORY.md new file mode 100644 index 0000000000000..fb5e713630d63 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/ALTER-REPOSITORY.md @@ -0,0 +1,25 @@ +--- +{ + "title": "ALTER REPOSITORY", + "language": "zh-CN" +} +--- + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/BACKUP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/BACKUP.md new file mode 100644 index 0000000000000..ca62176f1986a --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/BACKUP.md @@ -0,0 +1,114 @@ +--- +{ + "title": "BACKUP", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于备份指定数据库下的数据。该命令为异步操作。 + +仅 root 或 superuser 用户可以创建仓库。 + +提交成功后,需通过 SHOW BACKUP 命令查看进度。仅支持备份 OLAP 类型的表。 + +语法: + +```sql +BACKUP SNAPSHOT [db_name].{snapshot_name} +TO `repository_name` +[ON|EXCLUDE] ( + `table_name` [PARTITION (`p1`, ...)], + ... +) +PROPERTIES ("key"="value", ...); +``` + +说明: + +- 同一数据库下只能有一个正在执行的 BACKUP 或 RESTORE 任务。 +- ON 子句中标识需要备份的表和分区。如果不指定分区,则默认备份该表的所有分区 +- EXCLUDE 子句中标识不需要备份的表和分区。备份除了指定的表或分区之外这个数据库中所有表的所有分区数据。 +- PROPERTIES 目前支持以下属性: + - "type" = "full":表示这是一次全量更新(默认) + - "timeout" = "3600":任务超时时间,默认为一天。单位秒。 + +## 示例 + +1. 全量备份 example_db 下的表 example_tbl 到仓库 example_repo 中: + +```sql +BACKUP SNAPSHOT example_db.snapshot_label1 +TO example_repo +ON (example_tbl) +PROPERTIES ("type" = "full"); +``` + +2. 全量备份 example_db 下,表 example_tbl 的 p1, p2 分区,以及表 example_tbl2 到仓库 example_repo 中: + +```sql +BACKUP SNAPSHOT example_db.snapshot_label2 +TO example_repo +ON +( + example_tbl PARTITION (p1,p2), + example_tbl2 +); +``` + +3. 全量备份 example_db 下除了表 example_tbl 的其他所有表到仓库 example_repo 中: + +```sql +BACKUP SNAPSHOT example_db.snapshot_label3 +TO example_repo +EXCLUDE (example_tbl); +``` + +4. 全量备份 example_db 下的表到仓库 example_repo 中: + +```sql +BACKUP SNAPSHOT example_db.snapshot_label3 +TO example_repo; +``` + +## 关键词 + +```text +BACKUP +``` + +### 最佳实践 + +1. 同一个数据库下只能进行一个备份操作。 + +2. 备份操作会备份指定表或分区的基础表及 [物化视图](../../../../query-acceleration/materialized-view.md),并且仅备份一副本。 + +3. 备份操作的效率 + + 备份操作的效率取决于数据量、Compute Node 节点数量以及文件数量。备份数据分片所在的每个 Compute Node 都会参与备份操作的上传阶段。节点数量越多,上传的效率越高。 + + 文件数据量只涉及到的分片数,以及每个分片中文件的数量。如果分片非常多,或者分片内的小文件较多,都可能增加备份操作的时间。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/CANCEL-BACKUP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/CANCEL-BACKUP.md new file mode 100644 index 0000000000000..c1d3d84ee5b44 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/CANCEL-BACKUP.md @@ -0,0 +1,54 @@ +--- +{ + "title": "CANCEL BACKUP", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于取消一个正在进行的 BACKUP 任务。 + +语法: + +```sql +CANCEL BACKUP FROM db_name; +``` + +## 示例 + +1. 取消 example_db 下的 BACKUP 任务。 + +```sql +CANCEL BACKUP FROM example_db; +``` + +## 关键词 + + CANCEL, BACKUP + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/CANCEL-RESTORE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/CANCEL-RESTORE.md new file mode 100644 index 0000000000000..a31b0088f5f72 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/CANCEL-RESTORE.md @@ -0,0 +1,58 @@ +--- +{ + "title": "CANCEL RESTORE", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于取消一个正在进行的 RESTORE 任务。 + +语法: + +```sql +CANCEL RESTORE FROM db_name; +``` + +注意: + +- 当取消处于 COMMIT 或之后阶段的恢复左右时,可能导致被恢复的表无法访问。此时只能通过再次执行恢复作业进行数据恢复。 + +## 示例 + +1. 取消 example_db 下的 RESTORE 任务。 + +```sql +CANCEL RESTORE FROM example_db; +``` + +## 关键词 + + CANCEL, RESTORE + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/CREATE-REPOSITORY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/CREATE-REPOSITORY.md new file mode 100644 index 0000000000000..e0ecacc1589d8 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/CREATE-REPOSITORY.md @@ -0,0 +1,176 @@ +--- +{ + "title": "CREATE REPOSITORY", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于创建仓库。仓库用于属于备份或恢复。仅 root 或 superuser 用户可以创建仓库。 + +语法: + +```sql +CREATE [READ ONLY] REPOSITORY `repo_name` +WITH [BROKER `broker_name`|S3|hdfs] +ON LOCATION `repo_location` +PROPERTIES ("key"="value", ...); +``` + +说明: + +- 仓库的创建,依赖于已存在的 broker 或者直接通过 AWS s3 协议访问云存储,或者直接访问 HDFS +- 如果是只读仓库,则只能在仓库上进行恢复。如果不是,则可以进行备份和恢复操作。 +- 根据 broker 或者 S3、hdfs 的不同类型,PROPERTIES 有所不同,具体见示例。 +- ON LOCATION ,如果是 S3 , 这里后面跟的是 Bucket Name。 + +## 示例 + +1. 创建名为 bos_repo 的仓库,依赖 BOS broker "bos_broker",数据根目录为:bos://palo_backup + +```sql +CREATE REPOSITORY `bos_repo` +WITH BROKER `bos_broker` +ON LOCATION "bos://palo_backup" +PROPERTIES +( + "bos_endpoint" = "http://gz.bcebos.com", + "bos_accesskey" = "bos_accesskey", + "bos_secret_accesskey"="bos_secret_accesskey" +); +``` + +2. 创建和示例 1 相同的仓库,但属性为只读: + +```sql +CREATE READ ONLY REPOSITORY `bos_repo` +WITH BROKER `bos_broker` +ON LOCATION "bos://palo_backup" +PROPERTIES +( + "bos_endpoint" = "http://gz.bcebos.com", + "bos_accesskey" = "bos_accesskey", + "bos_secret_accesskey"="bos_accesskey" +); +``` + +3. 创建名为 hdfs_repo 的仓库,依赖 Baidu hdfs broker "hdfs_broker",数据根目录为:hdfs://hadoop-name-node:54310/path/to/repo/ + +```sql +CREATE REPOSITORY `hdfs_repo` +WITH BROKER `hdfs_broker` +ON LOCATION "hdfs://hadoop-name-node:54310/path/to/repo/" +PROPERTIES +( + "username" = "user", + "password" = "password" +); +``` + +4. 创建名为 s3_repo 的仓库,直接链接云存储,而不通过 broker. + +```sql +CREATE REPOSITORY `s3_repo` +WITH S3 +ON LOCATION "s3://s3-repo" +PROPERTIES +( + "s3.endpoint" = "http://s3-REGION.amazonaws.com", + "s3.access_key" = "AWS_ACCESS_KEY", + "s3.secret_key"="AWS_SECRET_KEY", + "s3.region" = "REGION" +); +``` + +5. 创建名为 hdfs_repo 的仓库,直接链接 HDFS,而不通过 broker. + +```sql +CREATE REPOSITORY `hdfs_repo` +WITH hdfs +ON LOCATION "hdfs://hadoop-name-node:54310/path/to/repo/" +PROPERTIES +( + "fs.defaultFS"="hdfs://hadoop-name-node:54310", + "hadoop.username"="user" +); +``` + +6. 创建名为 minio_repo 的仓库,直接通过 s3 协议链接 minio. + +```sql +CREATE REPOSITORY `minio_repo` +WITH S3 +ON LOCATION "s3://minio_repo" +PROPERTIES +( + "s3.endpoint" = "http://minio.com", + "s3.access_key" = "MINIO_USER", + "s3.secret_key"="MINIO_PASSWORD", + "s3.region" = "REGION" + "use_path_style" = "true" +); +``` + +7. 使用临时秘钥创建名为 minio_repo 的仓库 + +```sql +CREATE REPOSITORY `minio_repo` +WITH S3 +ON LOCATION "s3://minio_repo" +PROPERTIES +( + "s3.endpoint" = "AWS_ENDPOINT", + "s3.access_key" = "AWS_TEMP_ACCESS_KEY", + "s3.secret_key" = "AWS_TEMP_SECRET_KEY", + "s3.session_token" = "AWS_TEMP_TOKEN", + "s3.region" = "AWS_REGION" +) +``` + +8. 使用腾讯云 COS 创建仓库 + +```sql +CREATE REPOSITORY `cos_repo` +WITH S3 +ON LOCATION "s3://backet1/" +PROPERTIES +( + "s3.access_key" = "ak", + "s3.secret_key" = "sk", + "s3.endpoint" = "http://cos.ap-beijing.myqcloud.com", + "s3.region" = "ap-beijing" +); +``` + +## 关键词 + + CREATE, REPOSITORY + +### 最佳实践 + +1. 一个集群可以创建过多个仓库。只有拥有 ADMIN 权限的用户才能创建仓库。 +2. 任何用户都可以通过 [SHOW REPOSITORIES](../../../../sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-REPOSITORIES) 命令查看已经创建的仓库。 +3. 在做数据迁移操作时,需要在源集群和目的集群创建完全相同的仓库,以便目的集群可以通过这个仓库,查看到源集群备份的数据快照。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/DROP-REPOSITORY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/DROP-REPOSITORY.md new file mode 100644 index 0000000000000..dffbe14e59727 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/DROP-REPOSITORY.md @@ -0,0 +1,55 @@ +--- +{ + "title": "DROP REPOSITORY", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句用于删除一个已创建的仓库。仅 root 或 superuser 用户可以删除仓库。 + +语法: + +```sql +DROP REPOSITORY `repo_name`; +``` + +说明: + +- 删除仓库,仅仅是删除该仓库在 Palo 中的映射,不会删除实际的仓库数据。删除后,可以再次通过指定相同的 broker 和 LOCATION 映射到该仓库。 + +## 示例 + +1. 删除名为 bos_repo 的仓库: + +```sql +DROP REPOSITORY `bos_repo`; +``` + +## 关键词 + + DROP, REPOSITORY + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/RESTORE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/RESTORE.md new file mode 100644 index 0000000000000..44801f0920cab --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/RESTORE.md @@ -0,0 +1,116 @@ +--- +{ + "title": "RESTORE", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句用于将之前通过 BACKUP 命令备份的数据,恢复到指定数据库下。该命令为异步操作。提交成功后,需通过 SHOW RESTORE 命令查看进度。仅支持恢复 OLAP 类型的表。 + +语法: + +```sql +RESTORE SNAPSHOT [db_name].{snapshot_name} +FROM `repository_name` +[ON|EXCLUDE] ( + `table_name` [PARTITION (`p1`, ...)] [AS `tbl_alias`], + ... +) +PROPERTIES ("key"="value", ...); +``` + +说明: +- 同一数据库下只能有一个正在执行的 BACKUP 或 RESTORE 任务。 +- ON 子句中标识需要恢复的表和分区。如果不指定分区,则默认恢复该表的所有分区。所指定的表和分区必须已存在于仓库备份中。 +- EXCLUDE 子句中标识不需要恢复的表和分区。除了所指定的表或分区之外仓库中所有其他表的所有分区将被恢复。 +- 可以通过 AS 语句将仓库中备份的表名恢复为新的表。但新表名不能已存在于数据库中。分区名称不能修改。 +- 可以将仓库中备份的表恢复替换数据库中已有的同名表,但须保证两张表的表结构完全一致。表结构包括:表名、列、分区、Rollup 等等。 +- 可以指定恢复表的部分分区,系统会检查分区 Range 或者 List 是否能够匹配。 +- PROPERTIES 目前支持以下属性: + - "backup_timestamp" = "2018-05-04-16-45-08":指定了恢复对应备份的哪个时间版本,必填。该信息可以通过 `SHOW SNAPSHOT ON repo;` 语句获得。 + - "replication_num" = "3":指定恢复的表或分区的副本数。默认为 3。若恢复已存在的表或分区,则副本数必须和已存在表或分区的副本数相同。同时,必须有足够的 host 容纳多个副本。 + - "reserve_replica" = "true":默认为 false。当该属性为 true 时,会忽略 replication_num 属性,恢复的表或分区的副本数将与备份之前一样。支持多个表或表内多个分区有不同的副本数。 + - "reserve_dynamic_partition_enable" = "true":默认为 false。当该属性为 true 时,恢复的表会保留该表备份之前的'dynamic_partition_enable'属性值。该值不为 true 时,则恢复出来的表的'dynamic_partition_enable'属性值会设置为 false。 + - "timeout" = "3600":任务超时时间,默认为一天。单位秒。 + - "meta_version" = 40:使用指定的 meta_version 来读取之前备份的元数据。注意,该参数作为临时方案,仅用于恢复老版本 Doris 备份的数据。最新版本的备份数据中已经包含 meta version,无需再指定。 + +## 示例 + +1. 从 example_repo 中恢复备份 snapshot_1 中的表 backup_tbl 到数据库 example_db1,时间版本为 "2018-05-04-16-45-08"。恢复为 1 个副本: + +```sql +RESTORE SNAPSHOT example_db1.`snapshot_1` +FROM `example_repo` +ON ( `backup_tbl` ) +PROPERTIES +( + "backup_timestamp"="2018-05-04-16-45-08", + "replication_num" = "1" +); +``` + +2. 从 example_repo 中恢复备份 snapshot_2 中的表 backup_tbl 的分区 p1,p2,以及表 backup_tbl2 到数据库 example_db1,并重命名为 new_tbl,时间版本为 "2018-05-04-17-11-01"。默认恢复为 3 个副本: + +```sql +RESTORE SNAPSHOT example_db1.`snapshot_2` +FROM `example_repo` +ON +( + `backup_tbl` PARTITION (`p1`, `p2`), + `backup_tbl2` AS `new_tbl` +) +PROPERTIES +( + "backup_timestamp"="2018-05-04-17-11-01" +); +``` + +3. 从 example_repo 中恢复备份 snapshot_3 中除了表 backup_tbl 的其他所有表到数据库 example_db1,时间版本为 "2018-05-04-18-12-18"。 + +```sql +RESTORE SNAPSHOT example_db1.`snapshot_3` +FROM `example_repo` +EXCLUDE ( `backup_tbl` ) +PROPERTIES +( + "backup_timestamp"="2018-05-04-18-12-18" +); +``` + +## 关键词 + + RESTORE + +### 最佳实践 + +1. 同一数据库下只能有一个正在执行的恢复操作。 + +2. 可以将仓库中备份的表恢复替换数据库中已有的同名表,但须保证两张表的表结构完全一致。表结构包括:表名、列、分区、物化视图等等。 + +3. 当指定恢复表的部分分区时,系统会检查分区范围是否能够匹配。 + +4. 恢复操作的效率: + + 在集群规模相同的情况下,恢复操作的耗时基本等同于备份操作的耗时。如果想加速恢复操作,可以先通过设置 `replication_num` 参数,仅恢复一个副本,之后在通过调整副本数 [ALTER TABLE PROPERTY](../../../../sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-PROPERTY),将副本补齐。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-BACKUP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-BACKUP.md new file mode 100644 index 0000000000000..0fc5861320fca --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-BACKUP.md @@ -0,0 +1,80 @@ +--- +{ + "title": "SHOW BACKUP", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于查看 BACKUP 任务 + +语法: + +```sql + SHOW BACKUP [FROM db_name] + [WHERE SnapshotName ( LIKE | = ) 'snapshot name' ] +``` + +说明: + + 1. Doris 中仅保存最近一次 BACKUP 任务。 + 2. 各列含义如下: + JobId:唯一作业 id + SnapshotName:备份的名称 + DbName:所属数据库 + State:当前阶段 + PENDING:提交作业后的初始状态 + SNAPSHOTING:执行快照中 + UPLOAD_SNAPSHOT:快照完成,准备上传 + UPLOADING:快照上传中 + SAVE_META:将作业元信息保存为本地文件 + UPLOAD_INFO:上传作业元信息 + FINISHED:作业成功 + CANCELLED:作业失败 + BackupObjs:备份的表和分区 + CreateTime:任务提交时间 + SnapshotFinishedTime:快照完成时间 + UploadFinishedTime:快照上传完成时间 + FinishedTime:作业结束时间 + UnfinishedTasks:在 SNAPSHOTING 和 UPLOADING 阶段会显示还未完成的子任务 id + Status:如果作业失败,显示失败信息 + Timeout:作业超时时间,单位秒 + +## 示例 + +1. 查看 example_db 下最后一次 BACKUP 任务。 + + ```sql + SHOW BACKUP FROM example_db; + ``` + +## 关键词 + + SHOW, BACKUP + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-CREATE-REPOSITORY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-CREATE-REPOSITORY.md new file mode 100644 index 0000000000000..67ae0228286e3 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-CREATE-REPOSITORY.md @@ -0,0 +1,57 @@ +--- +{ + "title": "SHOW CREATE REPOSITORY", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于展示仓库的创建语句。 + +语法: + +```sql +SHOW CREATE REPOSITORY for repository_name; +``` + +说明: +- `repository_name`: 仓库名称 + +## 示例 + +1. 展示指定仓库的创建语句 + + ```sql + SHOW CREATE REPOSITORY for test_repository + ``` + +## 关键词 + + SHOW, CREATE, REPOSITORY + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-REPOSITORIES.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-REPOSITORIES.md new file mode 100644 index 0000000000000..f70f9352aab7b --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-REPOSITORIES.md @@ -0,0 +1,65 @@ +--- +{ + "title": "SHOW REPOSITORIES", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于查看当前已创建的仓库 + +语法: + +```sql +SHOW REPOSITORIES; +``` + +说明: + +1. 各列含义如下: + RepoId:唯一的仓库 ID + RepoName:仓库名称 + CreateTime:第一次创建该仓库的时间 + IsReadOnly:是否为只读仓库 + Location:仓库中用于备份数据的根目录 + Broker:依赖的 Broker + ErrMsg:Doris 会定期检查仓库的连通性,如果出现问题,这里会显示错误信息 + +## 示例 + +1. 查看已创建的仓库: + +```sql + SHOW REPOSITORIES; +``` + +## 关键词 + + SHOW, REPOSITORIES + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-RESTORE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-RESTORE.md new file mode 100644 index 0000000000000..3f37391e005f8 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-RESTORE.md @@ -0,0 +1,83 @@ +--- +{ + "title": "SHOW RESTORE", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于查看 RESTORE 任务 + +语法: + +```SQL +SHOW [BRIEF] RESTORE [FROM DB_NAME] +``` + +说明: + 1. Doris 中仅保存最近一次 RESTORE 任务。 + 2. 各列含义如下: + JobId:唯一作业 id + Label:要恢复的备份的名称 + Timestamp:要恢复的备份的时间版本 + DbName:所属数据库 + State:当前阶段 + PENDING:提交作业后的初始状态 + SNAPSHOTING:执行快照中 + DOWNLOAD:快照完成,准备下载仓库中的快照 + DOWNLOADING:快照下载中 + COMMIT:快照下载完成,准备生效 + COMMITTING:生效中 + FINISHED:作业成功 + CANCELLED:作业失败 + AllowLoad:恢复时是否允许导入(当前不支持) + ReplicationNum:指定恢复的副本数 + RestoreJobs:要恢复的表和分区 + CreateTime:任务提交时间 + MetaPreparedTime:元数据准备完成时间 + SnapshotFinishedTime:快照完成时间 + DownloadFinishedTime:快照下载完成时间 + FinishedTime:作业结束时间 + UnfinishedTasks:在 SNAPSHOTING、DOWNLOADING 和 COMMITTING 阶段会显示还未完成的子任务 id + Status:如果作业失败,显示失败信息 + Timeout:作业超时时间,单位秒 + + 2. brief: 仅返回精简格式的 RESTORE 任务信息,不包含 RestoreObjs, Progress, TaskErrMsg 三列 + +## 示例 + +1. 查看 example_db 下最近一次 RESTORE 任务。 + + ```sql + SHOW RESTORE FROM example_db; + ``` + +## 关键词 + + SHOW, RESTORE + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-SNAPSHOT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-SNAPSHOT.md new file mode 100644 index 0000000000000..8331170d77bd2 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-SNAPSHOT.md @@ -0,0 +1,76 @@ +--- +{ + "title": "SHOW SNAPSHOT", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于查看仓库中已存在的备份。 + +语法: + +```sql +SHOW SNAPSHOT ON `repo_name` +[WHERE SNAPSHOT = "snapshot" [AND TIMESTAMP = "backup_timestamp"]]; +``` + +说明: + 1. 各列含义如下: + Snapshot:备份的名称 + Timestamp:对应备份的时间版本 + Status:如果备份正常,则显示 OK,否则显示错误信息 + 2. 如果指定了 TIMESTAMP,则会额外显示如下信息: + Database:备份数据原属的数据库名称 + Details:以 Json 的形式,展示整个备份的数据目录及文件结构 + +## 示例 + +1. 查看仓库 example_repo 中已有的备份 + + ```sql + SHOW SNAPSHOT ON example_repo; + ``` + +2. 仅查看仓库 example_repo 中名称为 backup1 的备份: + + ```sql + SHOW SNAPSHOT ON example_repo WHERE SNAPSHOT = "backup1"; + ``` + +3. 查看仓库 example_repo 中名称为 backup1 的备份,时间版本为 "2018-05-05-15-34-26" 的详细信息: + + ```sql + SHOW SNAPSHOT ON example_repo + WHERE SNAPSHOT = "backup1" AND TIMESTAMP = "2018-05-05-15-34-26"; + ``` + +## 关键词 + + SHOW, SNAPSHOT + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/ALTER-ROUTINE-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/ALTER-ROUTINE-LOAD.md new file mode 100644 index 0000000000000..3cb042cbb68c7 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/ALTER-ROUTINE-LOAD.md @@ -0,0 +1,124 @@ +--- +{ + "title": "ALTER ROUTINE LOAD", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语法用于修改已经创建的例行导入作业。 + +只能修改处于 PAUSED 状态的作业。 + +语法: + +```sql +ALTER ROUTINE LOAD FOR [db.]job_name +[job_properties] +FROM data_source +[data_source_properties] +``` + +1. `[db.]job_name` + + 指定要修改的作业名称。 + +2. `tbl_name` + + 指定需要导入的表的名称。 + +3. `job_properties` + + 指定需要修改的作业参数。目前仅支持如下参数的修改: + + 1. `desired_concurrent_number` + 2. `max_error_number` + 3. `max_batch_interval` + 4. `max_batch_rows` + 5. `max_batch_size` + 6. `jsonpaths` + 7. `json_root` + 8. `strip_outer_array` + 9. `strict_mode` + 10. `timezone` + 11. `num_as_string` + 12. `fuzzy_parse` + 13. `partial_columns` + 14. `max_filter_ratio` + + +4. `data_source` + + 数据源的类型。当前支持: + + KAFKA + +5. `data_source_properties` + + 数据源的相关属性。目前仅支持: + + 1. `kafka_partitions` + 2. `kafka_offsets` + 3. `kafka_broker_list` + 4. `kafka_topic` + 5. 自定义 property,如 `property.group.id` + + 注: + + 1. `kafka_partitions` 和 `kafka_offsets` 用于修改待消费的 kafka partition 的 offset,仅能修改当前已经消费的 partition。不能新增 partition。 + +## 示例 + +1. 将 `desired_concurrent_number` 修改为 1 + + ```sql + ALTER ROUTINE LOAD FOR db1.label1 + PROPERTIES + ( + "desired_concurrent_number" = "1" + ); + ``` + +2. 将 `desired_concurrent_number` 修改为 10,修改 partition 的 offset,修改 group id。 + + ```sql + ALTER ROUTINE LOAD FOR db1.label1 + PROPERTIES + ( + "desired_concurrent_number" = "10" + ) + FROM kafka + ( + "kafka_partitions" = "0, 1, 2", + "kafka_offsets" = "100, 200, 100", + "property.group.id" = "new_group" + ); + +## 关键词 + + ALTER, ROUTINE, LOAD + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/BROKER-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/BROKER-LOAD.md new file mode 100644 index 0000000000000..b486b8541e08e --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/BROKER-LOAD.md @@ -0,0 +1,568 @@ +--- +{ + "title": "BROKER LOAD", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该命令主要用于通过 Broker 服务进程读取远端存储(如 S3、HDFS)上的数据导入到 Doris 表里。 + +```sql +LOAD LABEL load_label +( +data_desc1[, data_desc2, ...] +) +WITH BROKER broker_name +[broker_properties] +[load_properties] +[COMMENT "comments"]; +``` + +- `load_label` + + 每个导入需要指定一个唯一的 Label。后续可以通过这个 label 来查看作业进度。 + + `[database.]label_name` + +- `data_desc1` + + 用于描述一组需要导入的文件。 + + ```sql + [MERGE|APPEND|DELETE] + DATA INFILE + ( + "file_path1"[, file_path2, ...] + ) + [NEGATIVE] + INTO TABLE `table_name` + [PARTITION (p1, p2, ...)] + [COLUMNS TERMINATED BY "column_separator"] + [LINES TERMINATED BY "line_delimiter"] + [FORMAT AS "file_type"] + [COMPRESS_TYPE AS "compress_type"] + [(column_list)] + [COLUMNS FROM PATH AS (c1, c2, ...)] + [SET (column_mapping)] + [PRECEDING FILTER predicate] + [WHERE predicate] + [DELETE ON expr] + [ORDER BY source_sequence] + [PROPERTIES ("key1"="value1", ...)] + ``` + + - `[MERGE|APPEND|DELETE]` + + 数据合并类型。默认为 APPEND,表示本次导入是普通的追加写操作。MERGE 和 DELETE 类型仅适用于 Unique Key 模型表。其中 MERGE 类型需要配合 `[DELETE ON]` 语句使用,以标注 Delete Flag 列。而 DELETE 类型则表示本次导入的所有数据皆为删除数据。 + + - `DATA INFILE` + + 指定需要导入的文件路径。可以是多个。可以使用通配符。路径最终必须匹配到文件,如果只匹配到目录则导入会失败。 + + - `NEGATIVE` + + 该关键词用于表示本次导入为一批”负“导入。这种方式仅针对具有整型 SUM 聚合类型的聚合数据表。该方式会将导入数据中,SUM 聚合列对应的整型数值取反。主要用于冲抵之前导入错误的数据。 + + - `PARTITION(p1, p2, ...)` + + 可以指定仅导入表的某些分区。不在分区范围内的数据将被忽略。 + + - `COLUMNS TERMINATED BY` + + 指定列分隔符。仅在 CSV 格式下有效。仅能指定单字节分隔符。 + + - `LINES TERMINATED BY` + + 指定行分隔符。仅在 CSV 格式下有效。仅能指定单字节分隔符。 + + - `FORMAT AS` + + 指定文件类型,支持 CSV、PARQUET 和 ORC 格式。默认为 CSV。 + + - `COMPRESS_TYPE AS` + 指定文件压缩类型,支持 GZ/BZ2/LZ4FRAME。 + + - `column list` + + 用于指定原始文件中的列顺序。关于这部分详细介绍,可以参阅 [列的映射,转换与过滤](../../../../data-operate/import/import-scenes/load-data-convert.md) 文档。 + + `(k1, k2, tmpk1)` + + - `COLUMNS FROM PATH AS` + + 指定从导入文件路径中抽取的列。 + + - `SET (column_mapping)` + + 指定列的转换函数。 + + - `PRECEDING FILTER predicate` + + 前置过滤条件。数据首先根据 `column list` 和 `COLUMNS FROM PATH AS` 按顺序拼接成原始数据行。然后按照前置过滤条件进行过滤。关于这部分详细介绍,可以参阅 [列的映射,转换与过滤](../../../../data-operate/import/import-scenes/load-data-convert.md) 文档。 + + - `WHERE predicate` + + 根据条件对导入的数据进行过滤。关于这部分详细介绍,可以参阅 [列的映射,转换与过滤](../../../../data-operate/import/import-scenes/load-data-convert.md) 文档。 + + - `DELETE ON expr` + + 需配合 MEREGE 导入模式一起使用,仅针对 Unique Key 模型的表。用于指定导入数据中表示 Delete Flag 的列和计算关系。 + + - `ORDER BY` + + 仅针对 Unique Key 模型的表。用于指定导入数据中表示 Sequence Col 的列。主要用于导入时保证数据顺序。 + + - `PROPERTIES ("key1"="value1", ...)` + + 指定导入的 format 的一些参数。如导入的文件是`json`格式,则可以在这里指定`json_root`、`jsonpaths`、`fuzzy_parse`等参数。 + + - enclose + + 包围符。当 csv 数据字段中含有行分隔符或列分隔符时,为防止意外截断,可指定单字节字符作为包围符起到保护作用。例如列分隔符为",",包围符为"'",数据为"a,'b,c'",则"b,c"会被解析为一个字段。 + 注意:当 enclose 设置为`"`时,trim_double_quotes 一定要设置为 true。 + + - escape + + 转义符。用于转义在字段中出现的与包围符相同的字符。例如数据为"a,'b,'c'",包围符为"'",希望"b,'c 被作为一个字段解析,则需要指定单字节转义符,例如"\",然后将数据修改为"a,'b,\'c'"。 + +- `WITH BROKER broker_name` + + 指定需要使用的 Broker 服务名称。在公有云 Doris 中。Broker 服务名称为 `bos` + +- `broker_properties` + + 指定 broker 所需的信息。这些信息通常被用于 Broker 能够访问远端存储系统。如 BOS 或 HDFS。关于具体信息,可参阅 [Broker Load](../../../../data-operate/import/broker-load-manual) 文档。 + + ```text + ( + "key1" = "val1", + "key2" = "val2", + ... + ) + ``` + + - `load_properties` + + 指定导入的相关参数。目前支持以下参数: + + - `timeout` + + 导入超时时间。默认为 4 小时。单位秒。 + + - `max_filter_ratio` + + 最大容忍可过滤(数据不规范等原因)的数据比例。默认零容忍。取值范围为 0 到 1。 + + - `exec_mem_limit` + + 导入内存限制。默认为 2GB。单位为字节。 + + - `strict_mode` + + 是否对数据进行严格限制。默认为 false。 + + - `partial_columns` + + 布尔类型,为 true 表示使用部分列更新,默认值为 false,该参数只允许在表模型为 Unique 且采用 Merge on Write 时设置。 + + - `timezone` + + 指定某些受时区影响的函数的时区,如 `strftime/alignment_timestamp/from_unixtime` 等等,具体请查阅 [时区](../../../../advanced/time-zone.md) 文档。如果不指定,则使用 "Asia/Shanghai" 时区 + + - `load_parallelism` + + 导入并发度,默认为 1。调大导入并发度会启动多个执行计划同时执行导入任务,加快导入速度。 + + - `send_batch_parallelism` + + 用于设置发送批处理数据的并行度,如果并行度的值超过 BE 配置中的 `max_send_batch_parallelism_per_job`,那么作为协调点的 BE 将使用 `max_send_batch_parallelism_per_job` 的值。 + + - `load_to_single_tablet` + + 布尔类型,为 true 表示支持一个任务只导入数据到对应分区的一个 tablet,默认值为 false,作业的任务数取决于整体并发度。该参数只允许在对带有 random 分桶的 olap 表导数的时候设置。 + + - priority + + 设置导入任务的优先级,可选 `HIGH/NORMAL/LOW` 三种优先级,默认为 `NORMAL`,对于处在 `PENDING` 状态的导入任务,更高优先级的任务将优先被执行进入 `LOADING` 状态。 + +- comment + + 指定导入任务的备注信息。可选参数。 + +## 示例 + +1. 从 HDFS 导入一批数据 + + ```sql + LOAD LABEL example_db.label1 + ( + DATA INFILE("hdfs://hdfs_host:hdfs_port/input/file.txt") + INTO TABLE `my_table` + COLUMNS TERMINATED BY "," + ) + WITH BROKER hdfs + ( + "username"="hdfs_user", + "password"="hdfs_password" + ); + ``` + + 导入文件 `file.txt`,按逗号分隔,导入到表 `my_table`。 + +2. 从 HDFS 导入数据,使用通配符匹配两批文件。分别导入到两个表中。 + + ```sql + LOAD LABEL example_db.label2 + ( + DATA INFILE("hdfs://hdfs_host:hdfs_port/input/file-10*") + INTO TABLE `my_table1` + PARTITION (p1) + COLUMNS TERMINATED BY "," + (k1, tmp_k2, tmp_k3) + SET ( + k2 = tmp_k2 + 1, + k3 = tmp_k3 + 1 + ), + DATA INFILE("hdfs://hdfs_host:hdfs_port/input/file-20*") + INTO TABLE `my_table2` + COLUMNS TERMINATED BY "," + (k1, k2, k3) + ) + WITH BROKER hdfs + ( + "username"="hdfs_user", + "password"="hdfs_password" + ); + ``` + + 使用通配符匹配导入两批文件 `file-10*` 和 `file-20*`。分别导入到 `my_table1` 和 `my_table2` 两张表中。其中 `my_table1` 指定导入到分区 `p1` 中,并且将导入源文件中第二列和第三列的值 +1 后导入。 + +3. 从 HDFS 导入一批数据。 + + ```sql + LOAD LABEL example_db.label3 + ( + DATA INFILE("hdfs://hdfs_host:hdfs_port/user/doris/data/*/*") + INTO TABLE `my_table` + COLUMNS TERMINATED BY "\\x01" + ) + WITH BROKER my_hdfs_broker + ( + "username" = "", + "password" = "", + "fs.defaultFS" = "hdfs://my_ha", + "dfs.nameservices" = "my_ha", + "dfs.ha.namenodes.my_ha" = "my_namenode1, my_namenode2", + "dfs.namenode.rpc-address.my_ha.my_namenode1" = "nn1_host:rpc_port", + "dfs.namenode.rpc-address.my_ha.my_namenode2" = "nn2_host:rpc_port", + "dfs.client.failover.proxy.provider.my_ha" = "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider" + ); + ``` + + 指定分隔符为 Hive 的默认分隔符 `\\x01`,并使用通配符 * 指定 `data` 目录下所有目录的所有文件。使用简单认证,同时配置 namenode HA。 + +4. 导入 Parquet 格式数据,指定 FORMAT 为 parquet。默认是通过文件后缀判断 + + ```sql + LOAD LABEL example_db.label4 + ( + DATA INFILE("hdfs://hdfs_host:hdfs_port/input/file") + INTO TABLE `my_table` + FORMAT AS "parquet" + (k1, k2, k3) + ) + WITH BROKER hdfs + ( + "username"="hdfs_user", + "password"="hdfs_password" + ); + ``` + +5. 导入数据,并提取文件路径中的分区字段 + + ```sql + LOAD LABEL example_db.label10 + ( + DATA INFILE("hdfs://hdfs_host:hdfs_port/input/city=beijing/*/*") + INTO TABLE `my_table` + FORMAT AS "csv" + (k1, k2, k3) + COLUMNS FROM PATH AS (city, utc_date) + ) + WITH BROKER hdfs + ( + "username"="hdfs_user", + "password"="hdfs_password" + ); + ``` + + `my_table` 表中的列为 `k1, k2, k3, city, utc_date`。 + + 其中 `hdfs://hdfs_host:hdfs_port/user/doris/data/input/dir/city=beijing` 目录下包括如下文件: + + ```text + hdfs://hdfs_host:hdfs_port/input/city=beijing/utc_date=2020-10-01/0000.csv + hdfs://hdfs_host:hdfs_port/input/city=beijing/utc_date=2020-10-02/0000.csv + hdfs://hdfs_host:hdfs_port/input/city=tianji/utc_date=2020-10-03/0000.csv + hdfs://hdfs_host:hdfs_port/input/city=tianji/utc_date=2020-10-04/0000.csv + ``` + + 文件中只包含 `k1, k2, k3` 三列数据,`city, utc_date` 这两列数据会从文件路径中提取。 + +6. 对待导入数据进行过滤。 + + ```sql + LOAD LABEL example_db.label6 + ( + DATA INFILE("hdfs://host:port/input/file") + INTO TABLE `my_table` + (k1, k2, k3) + SET ( + k2 = k2 + 1 + ) + PRECEDING FILTER k1 = 1 + WHERE k1 > k2 + ) + WITH BROKER hdfs + ( + "username"="user", + "password"="pass" + ); + ``` + + 只有原始数据中,k1 = 1,并且转换后,k1 > k2 的行才会被导入。 + +7. 导入数据,提取文件路径中的时间分区字段,并且时间包含 %3A (在 hdfs 路径中,不允许有 ':',所有 ':' 会由 %3A 替换) + + ```sql + LOAD LABEL example_db.label7 + ( + DATA INFILE("hdfs://host:port/user/data/*/test.txt") + INTO TABLE `tbl12` + COLUMNS TERMINATED BY "," + (k2,k3) + COLUMNS FROM PATH AS (data_time) + SET ( + data_time=str_to_date(data_time, '%Y-%m-%d %H%%3A%i%%3A%s') + ) + ) + WITH BROKER hdfs + ( + "username"="user", + "password"="pass" + ); + ``` + + 路径下有如下文件: + + ```text + /user/data/data_time=2020-02-17 00%3A00%3A00/test.txt + /user/data/data_time=2020-02-18 00%3A00%3A00/test.txt + ``` + + 表结构为: + + ```text + data_time DATETIME, + k2 INT, + k3 INT + ``` + +8. 从 HDFS 导入一批数据,指定超时时间和过滤比例。使用明文 my_hdfs_broker 的 broker。简单认证。并且将原有数据中与 导入数据中 v2 大于 100 的列相匹配的列删除,其他列正常导入 + + ```sql + LOAD LABEL example_db.label8 + ( + MERGE DATA INFILE("HDFS://test:802/input/file") + INTO TABLE `my_table` + (k1, k2, k3, v2, v1) + DELETE ON v2 > 100 + ) + WITH HDFS + ( + "hadoop.username"="user", + "password"="pass" + ) + PROPERTIES + ( + "timeout" = "3600", + "max_filter_ratio" = "0.1" + ); + ``` + + 使用 MERGE 方式导入。`my_table` 必须是一张 Unique Key 的表。当导入数据中的 v2 列的值大于 100 时,该行会被认为是一个删除行。 + + 导入任务的超时时间是 3600 秒,并且允许错误率在 10% 以内。 + +9. 导入时指定 source_sequence 列,保证 UNIQUE_KEYS 表中的替换顺序: + + ```sql + LOAD LABEL example_db.label9 + ( + DATA INFILE("HDFS://test:802/input/file") + INTO TABLE `my_table` + COLUMNS TERMINATED BY "," + (k1,k2,source_sequence,v1,v2) + ORDER BY source_sequence + ) + WITH HDFS + ( + "hadoop.username"="user", + "password"="pass" + ) + ``` + + `my_table` 必须是 Unique Key 模型表,并且指定了 Sequcence Col。数据会按照源数据中 `source_sequence` 列的值来保证顺序性。 + +10. 从 HDFS 导入一批数据,指定文件格式为 `json` 并指定 `json_root`、`jsonpaths` + + ```sql + LOAD LABEL example_db.label10 + ( + DATA INFILE("HDFS://test:port/input/file.json") + INTO TABLE `my_table` + FORMAT AS "json" + PROPERTIES( + "json_root" = "$.item", + "jsonpaths" = "[\"$.id\", \"$.city\", \"$.code\"]" + ) + ) + with HDFS ( + "hadoop.username" = "user" + "password" = "" + ) + PROPERTIES + ( + "timeout"="1200", + "max_filter_ratio"="0.1" + ); + ``` + + `jsonpaths` 可与 `column list` 及 `SET (column_mapping)`配合: + + ```sql + LOAD LABEL example_db.label10 + ( + DATA INFILE("HDFS://test:port/input/file.json") + INTO TABLE `my_table` + FORMAT AS "json" + (id, code, city) + SET (id = id * 10) + PROPERTIES( + "json_root" = "$.item", + "jsonpaths" = "[\"$.id\", \"$.code\", \"$.city\"]" + ) + ) + with HDFS ( + "hadoop.username" = "user" + "password" = "" + ) + PROPERTIES + ( + "timeout"="1200", + "max_filter_ratio"="0.1" + ); + +11. 从腾讯云 cos 中以 csv 格式导入数据。 + + ```SQL + LOAD LABEL example_db.label10 + ( + DATA INFILE("cosn://my_bucket/input/file.csv") + INTO TABLE `my_table` + (k1, k2, k3) + ) + WITH BROKER "broker_name" + ( + "fs.cosn.userinfo.secretId" = "xxx", + "fs.cosn.userinfo.secretKey" = "xxxx", + "fs.cosn.bucket.endpoint_suffix" = "cos.xxxxxxxxx.myqcloud.com" + ) + ``` + +12. 导入 CSV 数据时去掉双引号,并跳过前 5 行。 + + ```SQL + LOAD LABEL example_db.label12 + ( + DATA INFILE("cosn://my_bucket/input/file.csv") + INTO TABLE `my_table` + (k1, k2, k3) + PROPERTIES("trim_double_quotes" = "true", "skip_lines" = "5") + ) + WITH BROKER "broker_name" + ( + "fs.cosn.userinfo.secretId" = "xxx", + "fs.cosn.userinfo.secretKey" = "xxxx", + "fs.cosn.bucket.endpoint_suffix" = "cos.xxxxxxxxx.myqcloud.com" + ) + ``` + +## 关键词 + + BROKER, LOAD + +### 最佳实践 + +1. 查看导入任务状态 + + Broker Load 是一个异步导入过程,语句执行成功仅代表导入任务提交成功,并不代表数据导入成功。导入状态需要通过 [SHOW LOAD](../../../../sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD) 命令查看。 + +2. 取消导入任务 + + 已提交切尚未结束的导入任务可以通过 [CANCEL LOAD](./CANCEL-LOAD.md) 命令取消。取消后,已写入的数据也会回滚,不会生效。 + +3. Label、导入事务、多表原子性 + + Doris 中所有导入任务都是原子生效的。并且在同一个导入任务中对多张表的导入也能够保证原子性。同时,Doris 还可以通过 Label 的机制来保证数据导入的不丢不重。具体说明可以参阅 [导入事务和原子性](../../../../data-operate/import/import-scenes/load-atomicity.md) 文档。 + +4. 列映射、衍生列和过滤 + + Doris 可以在导入语句中支持非常丰富的列转换和过滤操作。支持绝大多数内置函数和 UDF。关于如何正确的使用这个功能,可参阅 [列的映射,转换与过滤](../../../../data-operate/import/import-scenes/load-data-convert.md) 文档。 + +5. 错误数据过滤 + + Doris 的导入任务可以容忍一部分格式错误的数据。容忍了通过 `max_filter_ratio` 设置。默认为 0,即表示当有一条错误数据时,整个导入任务将会失败。如果用户希望忽略部分有问题的数据行,可以将次参数设置为 0~1 之间的数值,Doris 会自动跳过哪些数据格式不正确的行。 + + 关于容忍率的一些计算方式,可以参阅 [列的映射,转换与过滤](../../../../data-operate/import/import-scenes/load-data-convert.md) 文档。 + +6. 严格模式 + + `strict_mode` 属性用于设置导入任务是否运行在严格模式下。该格式会对列映射、转换和过滤的结果产生影响。关于严格模式的具体说明,可参阅 [严格模式](../../../../data-operate/import/import-scenes/load-strict-mode.md) 文档。 + +7. 超时时间 + + Broker Load 的默认超时时间为 4 小时。从任务提交开始算起。如果在超时时间内没有完成,则任务会失败。 + +8. 数据量和任务数限制 + + Broker Load 适合在一个导入任务中导入 100GB 以内的数据。虽然理论上在一个导入任务中导入的数据量没有上限。但是提交过大的导入会导致运行时间较长,并且失败后重试的代价也会增加。 + + 同时受限于集群规模,我们限制了导入的最大数据量为 ComputeNode 节点数 * 3GB。以保证系统资源的合理利用。如果有大数据量需要导入,建议分成多个导入任务提交。 + + Doris 同时会限制集群内同时运行的导入任务数量,通常在 3-10 个不等。之后提交的导入作业会排队等待。队列最大长度为 100。之后的提交会直接拒绝。注意排队时间也被计算到了作业总时间中。如果超时,则作业会被取消。所以建议通过监控作业运行状态来合理控制作业提交频率。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/CANCEL-EXPORT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/CANCEL-EXPORT.md new file mode 100644 index 0000000000000..cfc1604ab7926 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/CANCEL-EXPORT.md @@ -0,0 +1,74 @@ +--- +{ + "title": "CANCEL EXPORT", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于撤销指定 label 的 EXPORT 作业,或者通过模糊匹配批量撤销 EXPORT 作业 + +```sql +CANCEL EXPORT +[FROM db_name] +WHERE [LABEL = "export_label" | LABEL like "label_pattern" | STATE = "PENDING/IN_QUEUE/EXPORTING"] +``` + +## 示例 + +1. 撤销数据库 example_db 上,label 为 `example_db_test_export_label` 的 EXPORT 作业 + + ```sql + CANCEL EXPORT + FROM example_db + WHERE LABEL = "example_db_test_export_label" and STATE = "EXPORTING"; + ``` + +2. 撤销数据库 example*db 上,所有包含 example* 的 EXPORT 作业。 + + ```sql + CANCEL EXPORT + FROM example_db + WHERE LABEL like "%example%"; + ``` + +3. 取消状态为 PENDING 的导入作业。 + + ```sql + CANCEL EXPORT + FROM example_db + WHERE STATE = "PENDING"; + ``` + +## 关键词 + + CANCEL, EXPORT + +### 最佳实践 + +1. 只能取消处于 PENDING、IN_QUEUE、EXPORTING 状态的未完成的导出作业。 +2. 当执行批量撤销时,Doris 不会保证所有对应的 EXPORT 作业原子的撤销。即有可能仅有部分 EXPORT 作业撤销成功。用户可以通过 SHOW EXPORT 语句查看作业状态,并尝试重复执行 CANCEL EXPORT 语句。 +3. 当撤销`EXPORTING`状态的作业时,有可能作业已经导出部分数据到存储系统上,用户需要自行处理 (删除) 该部分导出数据。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/CANCEL-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/CANCEL-LOAD.md new file mode 100644 index 0000000000000..b3aa16de643c2 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/CANCEL-LOAD.md @@ -0,0 +1,76 @@ +--- +{ + "title": "CANCEL LOAD", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于撤销指定 label 的导入作业。或者通过模糊匹配批量撤销导入作业 + +```sql +CANCEL LOAD +[FROM db_name] +WHERE [LABEL = "load_label" | LABEL like "label_pattern" | STATE = "PENDING/ETL/LOADING"] +``` + +注:1.2.0 版本之后支持根据 State 取消作业。 + +## 示例 + +1. 撤销数据库 example_db 上,label 为 `example_db_test_load_label` 的导入作业 + + ```sql + CANCEL LOAD + FROM example_db + WHERE LABEL = "example_db_test_load_label"; + ``` + +2. 撤销数据库 example*db 上,所有包含 example* 的导入作业。 + + ```sql + CANCEL LOAD + FROM example_db + WHERE LABEL like "example_"; + ``` + +3. 取消状态为 LOADING 的导入作业。 + + ```sql + CANCEL LOAD + FROM example_db + WHERE STATE = "loading"; + ``` + +## 关键词 + + CANCEL, LOAD + +### 最佳实践 + +1. 只能取消处于 PENDING、ETL、LOADING 状态的未完成的导入作业。 +2. 当执行批量撤销时,Doris 不会保证所有对应的导入作业原子的撤销。即有可能仅有部分导入作业撤销成功。用户可以通过 SHOW LOAD 语句查看作业状态,并尝试重复执行 CANCEL LOAD 语句。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/CLEAN-LABEL.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/CLEAN-LABEL.md new file mode 100644 index 0000000000000..9ab007d4e6034 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/CLEAN-LABEL.md @@ -0,0 +1,60 @@ +--- +{ + "title": "CLEAN LABEL", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +用于手动清理历史导入作业的 Label。清理后,Label 可以重复使用。 + +语法: + +```sql +CLEAN LABEL [label] FROM db; +``` + +## 示例 + +1. 清理 db1 中,Label 为 label1 的导入作业。 + + ```sql + CLEAN LABEL label1 FROM db1; + ``` + +2. 清理 db1 中所有历史 Label。 + + ```sql + CLEAN LABEL FROM db1; + ``` + +## 关键词 + + CLEAN, LABEL + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/CREATE-ROUTINE-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/CREATE-ROUTINE-LOAD.md new file mode 100644 index 0000000000000..4e343b1d485b8 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/CREATE-ROUTINE-LOAD.md @@ -0,0 +1,628 @@ +--- +{ + "title": "CREATE ROUTINE LOAD", + "language": "zh-CN" +} + +--- + + + + + + + +## 描述 + +例行导入(Routine Load)功能,支持用户提交一个常驻的导入任务,通过不断的从指定的数据源读取数据,将数据导入到 Doris 中。 + +目前仅支持通过无认证或者 SSL 认证方式,从 Kakfa 导入 CSV 或 Json 格式的数据。 [导入 Json 格式数据使用示例](../../../../data-operate/import/import-way/routine-load-manual.md#导入Json格式数据使用示例) + +语法: + +```sql +CREATE ROUTINE LOAD [db.]job_name [ON tbl_name] +[merge_type] +[load_properties] +[job_properties] +FROM data_source [data_source_properties] +[COMMENT "comment"] +``` +``` + +- `[db.]job_name` + + 导入作业的名称,在同一个 database 内,相同名称只能有一个 job 在运行。 + +- `tbl_name` + + 指定需要导入的表的名称,可选参数,如果不指定,则采用动态表的方式,这个时候需要 Kafka 中的数据包含表名的信息。 + 目前仅支持从 Kafka 的 Value 中获取表名,且需要符合这种格式:以 json 为例:`table_name|{"col1": "val1", "col2": "val2"}`, + 其中 `tbl_name` 为表名,以 `|` 作为表名和表数据的分隔符。csv 格式的数据也是类似的,如:`table_name|val1,val2,val3`。注意,这里的 + `table_name` 必须和 Doris 中的表名一致,否则会导致导入失败. + + tips: 动态表不支持 `columns_mapping` 参数。如果你的表结构和 Doris 中的表结构一致,且存在大量的表信息需要导入,那么这种方式将是不二选择。 + +- `merge_type` + + 数据合并类型。默认为 APPEND,表示导入的数据都是普通的追加写操作。MERGE 和 DELETE 类型仅适用于 Unique Key 模型表。其中 MERGE 类型需要配合 [DELETE ON] 语句使用,以标注 Delete Flag 列。而 DELETE 类型则表示导入的所有数据皆为删除数据。 + tips: 当使用动态多表的时候,请注意此参数应该符合每张动态表的类型,否则会导致导入失败。 + +- load_properties + + 用于描述导入数据。组成如下: + + ```SQL + [column_separator], + [columns_mapping], + [preceding_filter], + [where_predicates], + [partitions], + [DELETE ON], + [ORDER BY] + ``` + + - `column_separator` + + 指定列分隔符,默认为 `\t` + + `COLUMNS TERMINATED BY ","` + + - `columns_mapping` + + 用于指定文件列和表中列的映射关系,以及各种列转换等。关于这部分详细介绍,可以参阅 [列的映射,转换与过滤] 文档。 + + `(k1, k2, tmpk1, k3 = tmpk1 + 1)` + + tips: 动态表不支持此参数。 + + - `preceding_filter` + + 过滤原始数据。关于这部分详细介绍,可以参阅 [列的映射,转换与过滤] 文档。 + + tips: 动态表不支持此参数。 + + - `where_predicates` + + 根据条件对导入的数据进行过滤。关于这部分详细介绍,可以参阅 [列的映射,转换与过滤] 文档。 + + `WHERE k1 > 100 and k2 = 1000` + + tips: 当使用动态多表的时候,请注意此参数应该符合每张动态表的列,否则会导致导入失败。通常在使用动态多表的时候,我们仅建议通用公共列使用此参数。 + + - `partitions` + + 指定导入目的表的哪些 partition 中。如果不指定,则会自动导入到对应的 partition 中。 + + `PARTITION(p1, p2, p3)` + + tips: 当使用动态多表的时候,请注意此参数应该符合每张动态表,否则会导致导入失败。 + + - `DELETE ON` + + 需配合 MEREGE 导入模式一起使用,仅针对 Unique Key 模型的表。用于指定导入数据中表示 Delete Flag 的列和计算关系。 + + `DELETE ON v3 >100` + + tips: 当使用动态多表的时候,请注意此参数应该符合每张动态表,否则会导致导入失败。 + + - `ORDER BY` + + 仅针对 Unique Key 模型的表。用于指定导入数据中表示 Sequence Col 的列。主要用于导入时保证数据顺序。 + + tips: 当使用动态多表的时候,请注意此参数应该符合每张动态表,否则会导致导入失败。 + +- `job_properties` + + 用于指定例行导入作业的通用参数。 + + ```text + PROPERTIES ( + "key1" = "val1", + "key2" = "val2" + ) + ``` + + 目前我们支持以下参数: + + 1. `desired_concurrent_number` + + 期望的并发度。一个例行导入作业会被分成多个子任务执行。这个参数指定一个作业最多有多少任务可以同时执行。必须大于 0。默认为 5。 + + 这个并发度并不是实际的并发度,实际的并发度,会通过集群的节点数、负载情况,以及数据源的情况综合考虑。 + + `"desired_concurrent_number" = "3"` + + 2. `max_batch_interval/max_batch_rows/max_batch_size` + + 这三个参数分别表示: + + 1. 每个子任务最大执行时间,单位是秒。必须大于等于 1。默认为 10。 + 2. 每个子任务最多读取的行数。必须大于等于 200000。默认是 20000000。 + 3. 每个子任务最多读取的字节数。单位是字节,范围是 100MB 到 10GB。默认是 1G。 + + 这三个参数,用于控制一个子任务的执行时间和处理量。当任意一个达到阈值,则任务结束。 + + ```text + "max_batch_interval" = "20", + "max_batch_rows" = "300000", + "max_batch_size" = "209715200" + ``` + + 3. `max_error_number` + + 采样窗口内,允许的最大错误行数。必须大于等于 0。默认是 0,即不允许有错误行。 + + 采样窗口为 `max_batch_rows * 10`。即如果在采样窗口内,错误行数大于 `max_error_number`,则会导致例行作业被暂停,需要人工介入检查数据质量问题。 + + 被 where 条件过滤掉的行不算错误行。 + + 4. `strict_mode` + + 是否开启严格模式,默认为关闭。如果开启后,非空原始数据的列类型变换如果结果为 NULL,则会被过滤。指定方式为: + + `"strict_mode" = "true"` + + strict mode 模式的意思是:对于导入过程中的列类型转换进行严格过滤。严格过滤的策略如下: + + 1. 对于列类型转换来说,如果 strict mode 为 true,则错误的数据将被 filter。这里的错误数据是指:原始数据并不为空值,在参与列类型转换后结果为空值的这一类数据。 + 2. 对于导入的某列由函数变换生成时,strict mode 对其不产生影响。 + 3. 对于导入的某列类型包含范围限制的,如果原始数据能正常通过类型转换,但无法通过范围限制的,strict mode 对其也不产生影响。例如:如果类型是 decimal(1,0), 原始数据为 10,则属于可以通过类型转换但不在列声明的范围内。这种数据 strict 对其不产生影响。 + + **strict mode 与 source data 的导入关系** + + 这里以列类型为 TinyInt 来举例 + + > 注:当表中的列允许导入空值时 + + | source data | source data example | string to int | strict_mode | result | + | ----------- | ------------------- | ------------- | ------------- | ---------------------- | + | 空值 | `\N` | N/A | true or false | NULL | + | not null | aaa or 2000 | NULL | true | invalid data(filtered) | + | not null | aaa | NULL | false | NULL | + | not null | 1 | 1 | true or false | correct data | + + 这里以列类型为 Decimal(1,0) 举例 + + > 注:当表中的列允许导入空值时 + + | source data | source data example | string to int | strict_mode | result | + | ----------- | ------------------- | ------------- | ------------- | ---------------------- | + | 空值 | `\N` | N/A | true or false | NULL | + | not null | aaa | NULL | true | invalid data(filtered) | + | not null | aaa | NULL | false | NULL | + | not null | 1 or 10 | 1 | true or false | correct data | + + > 注意:10 虽然是一个超过范围的值,但是因为其类型符合 decimal 的要求,所以 strict mode 对其不产生影响。10 最后会在其他 ETL 处理流程中被过滤。但不会被 strict mode 过滤。 + + 5. `timezone` + + 指定导入作业所使用的时区。默认为使用 Session 的 timezone 参数。该参数会影响所有导入涉及的和时区有关的函数结果。 + + 6. `format` + + 指定导入数据格式,默认是 csv,支持 json 格式。 + + 7. `jsonpaths` + + 当导入数据格式为 json 时,可以通过 jsonpaths 指定抽取 Json 数据中的字段。 + + `-H "jsonpaths: [\"$.k2\", \"$.k1\"]"` + + 8. `strip_outer_array` + + 当导入数据格式为 json 时,strip_outer_array 为 true 表示 Json 数据以数组的形式展现,数据中的每一个元素将被视为一行数据。默认值是 false。 + + `-H "strip_outer_array: true"` + + 9. `json_root` + + 当导入数据格式为 json 时,可以通过 json_root 指定 Json 数据的根节点。Doris 将通过 json_root 抽取根节点的元素进行解析。默认为空。 + + `-H "json_root: $.RECORDS"` + + 10. `send_batch_parallelism` + + 整型,用于设置发送批处理数据的并行度,如果并行度的值超过 BE 配置中的 `max_send_batch_parallelism_per_job`,那么作为协调点的 BE 将使用 `max_send_batch_parallelism_per_job` 的值。 + + 11. `load_to_single_tablet` + + 布尔类型,为 true 表示支持一个任务只导入数据到对应分区的一个 tablet,默认值为 false,该参数只允许在对带有 random 分桶的 olap 表导数的时候设置。 + + 12. `partial_columns` + 布尔类型,为 true 表示使用部分列更新,默认值为 false,该参数只允许在表模型为 Unique 且采用 Merge on Write 时设置。一流多表不支持此参数。 + + 13. `max_filter_ratio` + + 采样窗口内,允许的最大过滤率。必须在大于等于0到小于等于1之间。默认值是 0。 + + 采样窗口为 `max_batch_rows * 10`。即如果在采样窗口内,错误行数/总行数大于 `max_filter_ratio`,则会导致例行作业被暂停,需要人工介入检查数据质量问题。 + + 被 where 条件过滤掉的行不算错误行。 + + 14. `enclose` + 包围符。当 csv 数据字段中含有行分隔符或列分隔符时,为防止意外截断,可指定单字节字符作为包围符起到保护作用。例如列分隔符为",",包围符为"'",数据为"a,'b,c'",则"b,c"会被解析为一个字段。 + 注意:当 enclose 设置为`"`时,trim_double_quotes 一定要设置为 true。 + + 15. `escape` + 转义符。用于转义在csv字段中出现的与包围符相同的字符。例如数据为"a,'b,'c'",包围符为"'",希望"b,'c被作为一个字段解析,则需要指定单字节转义符,例如 `\`,然后将数据修改为 `a,'b,\'c'`。 + +- `FROM data_source [data_source_properties]` + + 数据源的类型。当前支持: + + ```text + FROM KAFKA + ( + "key1" = "val1", + "key2" = "val2" + ) + ``` + + `data_source_properties` 支持如下数据源属性: + + 1. `kafka_broker_list` + + Kafka 的 broker 连接信息。格式为 ip:host。多个 broker 之间以逗号分隔。 + + `"kafka_broker_list" = "broker1:9092,broker2:9092"` + + 2. `kafka_topic` + + 指定要订阅的 Kafka 的 topic。 + + `"kafka_topic" = "my_topic"` + + 3. `kafka_partitions/kafka_offsets` + + 指定需要订阅的 kafka partition,以及对应的每个 partition 的起始 offset。如果指定时间,则会从大于等于该时间的最近一个 offset 处开始消费。 + + offset 可以指定从大于等于 0 的具体 offset,或者: + + - `OFFSET_BEGINNING`: 从有数据的位置开始订阅。 + - `OFFSET_END`: 从末尾开始订阅。 + - 时间格式,如:"2021-05-22 11:00:00" + + 如果没有指定,则默认从 `OFFSET_END` 开始订阅 topic 下的所有 partition。 + + ```text + "kafka_partitions" = "0,1,2,3", + "kafka_offsets" = "101,0,OFFSET_BEGINNING,OFFSET_END" + ``` + + ```text + "kafka_partitions" = "0,1,2,3", + "kafka_offsets" = "2021-05-22 11:00:00,2021-05-22 11:00:00,2021-05-22 11:00:00" + ``` + + 注意,时间格式不能和 OFFSET 格式混用。 + + 4. `property` + + 指定自定义 kafka 参数。功能等同于 kafka shell 中 "--property" 参数。 + + 当参数的 value 为一个文件时,需要在 value 前加上关键词:"FILE:"。 + + 关于如何创建文件,请参阅 [CREATE FILE](../../../Data-Definition-Statements/Create/CREATE-FILE) 命令文档。 + + 更多支持的自定义参数,请参阅 librdkafka 的官方 CONFIGURATION 文档中,client 端的配置项。如: + + ```text + "property.client.id" = "12345", + "property.ssl.ca.location" = "FILE:ca.pem" + ``` + + 1. 使用 SSL 连接 Kafka 时,需要指定以下参数: + + ```text + "property.security.protocol" = "ssl", + "property.ssl.ca.location" = "FILE:ca.pem", + "property.ssl.certificate.location" = "FILE:client.pem", + "property.ssl.key.location" = "FILE:client.key", + "property.ssl.key.password" = "abcdefg" + ``` + + 其中: + + `property.security.protocol` 和 `property.ssl.ca.location` 为必须,用于指明连接方式为 SSL,以及 CA 证书的位置。 + + 如果 Kafka server 端开启了 client 认证,则还需设置: + + ```text + "property.ssl.certificate.location" + "property.ssl.key.location" + "property.ssl.key.password" + ``` + + 分别用于指定 client 的 public key,private key 以及 private key 的密码。 + + 2. 指定 kafka partition 的默认起始 offset + + 如果没有指定 `kafka_partitions/kafka_offsets`,默认消费所有分区。 + + 此时可以指定 `kafka_default_offsets` 指定起始 offset。默认为 `OFFSET_END`,即从末尾开始订阅。 + + 示例: + + ```text + "property.kafka_default_offsets" = "OFFSET_BEGINNING" + ``` +- comment + - 例行导入任务的注释信息。 +## 示例 + +1. 为 example_db 的 example_tbl 创建一个名为 test1 的 Kafka 例行导入任务。指定列分隔符和 group.id 和 client.id,并且自动默认消费所有分区,且从有数据的位置(OFFSET_BEGINNING)开始订阅 + + + + ```sql + CREATE ROUTINE LOAD example_db.test1 ON example_tbl + COLUMNS TERMINATED BY ",", + COLUMNS(k1, k2, k3, v1, v2, v3 = k1 * 100) + PROPERTIES + ( + "desired_concurrent_number"="3", + "max_batch_interval" = "20", + "max_batch_rows" = "300000", + "max_batch_size" = "209715200", + "strict_mode" = "false" + ) + FROM KAFKA + ( + "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", + "kafka_topic" = "my_topic", + "property.group.id" = "xxx", + "property.client.id" = "xxx", + "property.kafka_default_offsets" = "OFFSET_BEGINNING" + ); + ``` + +2. 为 example_db 创建一个名为 test1 的 Kafka 例行动态多表导入任务。指定列分隔符和 group.id 和 client.id,并且自动默认消费所有分区, + 且从有数据的位置(OFFSET_BEGINNING)开始订阅 + + 我们假设需要将 Kafka 中的数据导入到 example_db 中的 test1 以及 test2 表中,我们创建了一个名为 test1 的例行导入任务,同时将 test1 和 + test2 中的数据写到一个名为 `my_topic` 的 Kafka 的 topic 中,这样就可以通过一个例行导入任务将 Kafka 中的数据导入到两个表中。 + + ```sql + CREATE ROUTINE LOAD example_db.test1 + PROPERTIES + ( + "desired_concurrent_number"="3", + "max_batch_interval" = "20", + "max_batch_rows" = "300000", + "max_batch_size" = "209715200", + "strict_mode" = "false" + ) + FROM KAFKA + ( + "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", + "kafka_topic" = "my_topic", + "property.group.id" = "xxx", + "property.client.id" = "xxx", + "property.kafka_default_offsets" = "OFFSET_BEGINNING" + ); + ``` + +3. 为 example_db 的 example_tbl 创建一个名为 test1 的 Kafka 例行导入任务。导入任务为严格模式。 + + + + ```sql + CREATE ROUTINE LOAD example_db.test1 ON example_tbl + COLUMNS(k1, k2, k3, v1, v2, v3 = k1 * 100), + PRECEDING FILTER k1 = 1, + WHERE k1 > 100 and k2 like "%doris%" + PROPERTIES + ( + "desired_concurrent_number"="3", + "max_batch_interval" = "20", + "max_batch_rows" = "300000", + "max_batch_size" = "209715200", + "strict_mode" = "true" + ) + FROM KAFKA + ( + "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", + "kafka_topic" = "my_topic", + "kafka_partitions" = "0,1,2,3", + "kafka_offsets" = "101,0,0,200" + ); + ``` + +4. 通过 SSL 认证方式,从 Kafka 集群导入数据。同时设置 client.id 参数。导入任务为非严格模式,时区为 Africa/Abidjan + + + + ```sql + CREATE ROUTINE LOAD example_db.test1 ON example_tbl + COLUMNS(k1, k2, k3, v1, v2, v3 = k1 * 100), + WHERE k1 > 100 and k2 like "%doris%" + PROPERTIES + ( + "desired_concurrent_number"="3", + "max_batch_interval" = "20", + "max_batch_rows" = "300000", + "max_batch_size" = "209715200", + "strict_mode" = "false", + "timezone" = "Africa/Abidjan" + ) + FROM KAFKA + ( + "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", + "kafka_topic" = "my_topic", + "property.security.protocol" = "ssl", + "property.ssl.ca.location" = "FILE:ca.pem", + "property.ssl.certificate.location" = "FILE:client.pem", + "property.ssl.key.location" = "FILE:client.key", + "property.ssl.key.password" = "abcdefg", + "property.client.id" = "my_client_id" + ); + ``` + +5. 导入 Json 格式数据。默认使用 Json 中的字段名作为列名映射。指定导入 0,1,2 三个分区,起始 offset 都为 0 + + + + ```sql + CREATE ROUTINE LOAD example_db.test_json_label_1 ON table1 + COLUMNS(category,price,author) + PROPERTIES + ( + "desired_concurrent_number"="3", + "max_batch_interval" = "20", + "max_batch_rows" = "300000", + "max_batch_size" = "209715200", + "strict_mode" = "false", + "format" = "json" + ) + FROM KAFKA + ( + "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", + "kafka_topic" = "my_topic", + "kafka_partitions" = "0,1,2", + "kafka_offsets" = "0,0,0" + ); + ``` + +6. 导入 Json 数据,并通过 Jsonpaths 抽取字段,并指定 Json 文档根节点 + + + + ```sql + CREATE ROUTINE LOAD example_db.test1 ON example_tbl + COLUMNS(category, author, price, timestamp, dt=from_unixtime(timestamp, '%Y%m%d')) + PROPERTIES + ( + "desired_concurrent_number"="3", + "max_batch_interval" = "20", + "max_batch_rows" = "300000", + "max_batch_size" = "209715200", + "strict_mode" = "false", + "format" = "json", + "jsonpaths" = "[\"$.category\",\"$.author\",\"$.price\",\"$.timestamp\"]", + "json_root" = "$.RECORDS" + "strip_outer_array" = "true" + ) + FROM KAFKA + ( + "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", + "kafka_topic" = "my_topic", + "kafka_partitions" = "0,1,2", + "kafka_offsets" = "0,0,0" + ); + ``` + +7. 为 example_db 的 example_tbl 创建一个名为 test1 的 Kafka 例行导入任务。并且使用条件过滤。 + + + + ```sql + CREATE ROUTINE LOAD example_db.test1 ON example_tbl + WITH MERGE + COLUMNS(k1, k2, k3, v1, v2, v3), + WHERE k1 > 100 and k2 like "%doris%", + DELETE ON v3 >100 + PROPERTIES + ( + "desired_concurrent_number"="3", + "max_batch_interval" = "20", + "max_batch_rows" = "300000", + "max_batch_size" = "209715200", + "strict_mode" = "false" + ) + FROM KAFKA + ( + "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", + "kafka_topic" = "my_topic", + "kafka_partitions" = "0,1,2,3", + "kafka_offsets" = "101,0,0,200" + ); + ``` + +8. 导入数据到含有 sequence 列的 Unique Key 模型表中 + + + + ```sql + CREATE ROUTINE LOAD example_db.test_job ON example_tbl + COLUMNS TERMINATED BY ",", + COLUMNS(k1,k2,source_sequence,v1,v2), + ORDER BY source_sequence + PROPERTIES + ( + "desired_concurrent_number"="3", + "max_batch_interval" = "30", + "max_batch_rows" = "300000", + "max_batch_size" = "209715200" + ) FROM KAFKA + ( + "kafka_broker_list" = "broker1:9092,broker2:9092,broker3:9092", + "kafka_topic" = "my_topic", + "kafka_partitions" = "0,1,2,3", + "kafka_offsets" = "101,0,0,200" + ); + ``` + +9. 从指定的时间点开始消费 + + + + ```sql + CREATE ROUTINE LOAD example_db.test_job ON example_tbl + PROPERTIES + ( + "desired_concurrent_number"="3", + "max_batch_interval" = "30", + "max_batch_rows" = "300000", + "max_batch_size" = "209715200" + ) FROM KAFKA + ( + "kafka_broker_list" = "broker1:9092,broker2:9092", + "kafka_topic" = "my_topic", + "kafka_default_offsets" = "2021-05-21 10:00:00" + ); + ``` + +## 关键词 + + CREATE, ROUTINE, LOAD, CREATE LOAD + +### 最佳实践 + +关于指定消费的 Partition 和 Offset + +Doris 支持指定 Partition 和 Offset 开始消费,还支持了指定时间点进行消费的功能。这里说明下对应参数的配置关系。 + +有三个相关参数: + +- `kafka_partitions`:指定待消费的 partition 列表,如:"0, 1, 2, 3"。 +- `kafka_offsets`:指定每个分区的起始 offset,必须和 `kafka_partitions` 列表个数对应。如:"1000, 1000, 2000, 2000" +- `property.kafka_default_offsets:指定分区默认的起始 offset。 + +在创建导入作业时,这三个参数可以有以下组合: + +| 组合 | `kafka_partitions` | `kafka_offsets` | `property.kafka_default_offsets` | 行为 | +| ---- | ------------------ | --------------- | ------------------------------- | ------------------------------------------------------------ | +| 1 | No | No | No | 系统会自动查找 topic 对应的所有分区并从 OFFSET_END 开始消费 | +| 2 | No | No | Yes | 系统会自动查找 topic 对应的所有分区并从 default offset 指定的位置开始消费 | +| 3 | Yes | No | No | 系统会从指定分区的 OFFSET_END 开始消费 | +| 4 | Yes | Yes | No | 系统会从指定分区的指定 offset 处开始消费 | +| 5 | Yes | No | Yes | 系统会从指定分区,default offset 指定的位置开始消费 | + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/CREATE-SYNC-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/CREATE-SYNC-JOB.md new file mode 100644 index 0000000000000..402381045961a --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/CREATE-SYNC-JOB.md @@ -0,0 +1,158 @@ +--- +{ + "title": "CREATE SYNC JOB", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +数据同步 (Sync Job) 功能,支持用户提交一个常驻的数据同步作业,通过从指定的远端地址读取 Binlog 日志,增量同步用户在 Mysql 数据库的对数据更新操作的 CDC(Change Data Capture) 功能。 + +目前数据同步作业只支持对接 Canal,从 Canal Server 上获取解析好的 Binlog 数据,导入到 Doris 内。 + +用户可通过 [SHOW SYNC JOB](../../../../sql-manual/sql-statements/data-modification/load-and-export/SHOW-SYNC-JOB) 查看数据同步作业状态。 + +语法: + +```sql +CREATE SYNC [db.]job_name + ( + channel_desc, + channel_desc + ... + ) +binlog_desc +``` + +1. `job_name` + + 同步作业名称,是作业在当前数据库内的唯一标识,相同`job_name`的作业只能有一个在运行。 + +2. `channel_desc` + + 作业下的数据通道,用来描述 mysql 源表到 doris 目标表的映射关系。 + + 语法: + + ```sql + FROM mysql_db.src_tbl INTO des_tbl + [columns_mapping] + ``` + + 1. `mysql_db.src_tbl` + + 指定 mysql 端的数据库和源表。 + + 2. `des_tbl` + + 指定 doris 端的目标表,只支持 Unique 表,且需开启表的 batch delete 功能 (开启方法请看 help alter table 的'批量删除功能')。 + + 4. `column_mapping` + + 指定 mysql 源表和 doris 目标表的列之间的映射关系。如果不指定,FE 会默认源表和目标表的列按顺序一一对应。 + + 不支持 col_name = expr 的形式表示列。 + + 示例: + + ``` + 假设目标表列为 (k1, k2, v1), + + 改变列 k1 和 k2 的顺序 + (k2, k1, v1) + + 忽略源数据的第四列 + (k2, k1, v1, dummy_column) + ``` + +3. `binlog_desc` + + 用来描述远端数据源,目前仅支持 canal 一种。 + + 语法: + + ```sql + FROM BINLOG + ( + "key1" = "value1", + "key2" = "value2" + ) + ``` + + 1. Canal 数据源对应的属性,以`canal.`为前缀 + + 1. canal.server.ip: canal server 的地址 + 2. canal.server.port: canal server 的端口 + 3. canal.destination: instance 的标识 + 4. canal.batchSize: 获取的 batch 大小的最大值,默认 8192 + 5. canal.username: instance 的用户名 + 6. canal.password: instance 的密码 + 7. canal.debug: 可选,设置为 true 时,会将 batch 和每一行数据的详细信息都打印出来 + +## 示例 + +1. 简单为 `test_db` 的 `test_tbl` 创建一个名为 `job1` 的数据同步作业,连接本地的 Canal 服务器,对应 Mysql 源表 `mysql_db1.tbl1`。 + + ```SQL + CREATE SYNC `test_db`.`job1` + ( + FROM `mysql_db1`.`tbl1` INTO `test_tbl ` + ) + FROM BINLOG + ( + "type" = "canal", + "canal.server.ip" = "127.0.0.1", + "canal.server.port" = "11111", + "canal.destination" = "example", + "canal.username" = "", + "canal.password" = "" + ); + ``` + +2. 为 `test_db` 的多张表创建一个名为 `job1` 的数据同步作业,一一对应多张 Mysql 源表,并显式的指定列映射。 + + ```SQL + CREATE SYNC `test_db`.`job1` + ( + FROM `mysql_db`.`t1` INTO `test1` (k1, k2, v1), + FROM `mysql_db`.`t2` INTO `test2` (k3, k4, v2) + ) + FROM BINLOG + ( + "type" = "canal", + "canal.server.ip" = "xx.xxx.xxx.xx", + "canal.server.port" = "12111", + "canal.destination" = "example", + "canal.username" = "username", + "canal.password" = "password" + ); + ``` + +## 关键词 + + CREATE, SYNC, JOB + +### 最佳实践 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/EXPORT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/EXPORT.md new file mode 100644 index 0000000000000..b2810d4031364 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/EXPORT.md @@ -0,0 +1,377 @@ +--- +{ + "title": "EXPORT", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + + `EXPORT` 命令用于将指定表的数据导出为文件到指定位置。目前支持通过 Broker 进程,S3 协议或 HDFS 协议,导出到远端存储,如 HDFS,S3,BOS,COS(腾讯云)上。 + +`EXPORT`是一个异步操作,该命令会提交一个`EXPORT JOB`到 Doris,任务提交成功立即返回。执行后可使用 [SHOW EXPORT](../../../../sql-manual/sql-statements/data-modification/load-and-export/SHOW-EXPORT) 命令查看进度。 + +语法: + + ```sql + EXPORT TABLE table_name + [PARTITION (p1[,p2])] + [WHERE] + TO export_path + [opt_properties] + WITH BROKER/S3/HDFS + [broker_properties]; + ``` + + + +**说明**: + +- `table_name` + + 当前要导出的表的表名。支持 Doris 本地表、视图 View、Catalog 外表数据的导出。 + +- `partition` + + 可以只导出指定表的某些指定分区,只对 Doris 本地表有效。 + +- `export_path` + + 导出的文件路径。可以是目录,也可以是文件目录加文件前缀,如`hdfs://path/to/my_file_` + +- `opt_properties` + + 用于指定一些导出参数。 + + ```sql + [PROPERTIES ("key"="value", ...)] + ``` + + 可以指定如下参数: + + - `label`: 可选参数,指定此次 Export 任务的 Label,当不指定时系统会随机生成一个 Label。 + + - `column_separator`:指定导出的列分隔符,默认为 `\t`,支持多字节。该参数只用于 CSV 文件格式。 + + - `line_delimiter`:指定导出的行分隔符,默认为 `\n`,支持多字节。该参数只用于 CSV 文件格式。 + + - `columns`:指定导出表的某些列。 + + - `format`:指定导出作业的文件格式,支持:parquet, orc, csv, csv_with_names、csv_with_names_and_types。默认为 CSV 格式。 + + - `max_file_size`:导出作业单个文件大小限制,如果结果超过这个值,将切割成多个文件。`max_file_size`取值范围是[5MB, 2GB], 默认为 1GB。(当指定导出为 orc 文件格式时,实际切分文件的大小将是 64MB 的倍数,如:指定 max_file_size = 5MB, 实际将以 64MB 为切分;指定 max_file_size = 65MB, 实际将以 128MB 为切分) + + - `parallelism`:导出作业的并发度,默认为`1`,导出作业会开启`parallelism`个数的线程去执行`select into outfile`语句。(如果 Parallelism 个数大于表的 Tablets 个数,系统将自动把 Parallelism 设置为 Tablets 个数大小,即每一个`select into outfile`语句负责一个 Tablets) + + - `delete_existing_files`: 默认为 `false`,若指定为 `true`,则会先删除`export_path`所指定目录下的所有文件,然后导出数据到该目录下。例如:"export_path" = "/user/tmp", 则会删除"/user/"下所有文件及目录;"file_path" = "/user/tmp/", 则会删除"/user/tmp/"下所有文件及目录。 + + - `with_bom`: 默认为 `false`,若指定为 `true`,则导出的文件编码为带有 BOM 的 UTF8 编码(只对 csv 相关的文件格式生效)。 + + - `data_consistency`: 可以设置为 `none` / `partition` ,默认为 `partition` 。指示以何种粒度切分导出表,`none` 代表 Tablets 级别,`partition`代表 Partition 级别。 + + - `timeout`:导出作业的超时时间,默认为 2 小时,单位是秒。 + + - `compress_type`:(自 2.1.5 支持) 当指定导出的文件格式为 Parquet / ORC 文件时,可以指定 Parquet / ORC 文件使用的压缩方式。Parquet 文件格式可指定压缩方式为 SNAPPY,GZIP,BROTLI,ZSTD,LZ4 及 PLAIN,默认值为 SNAPPY。ORC 文件格式可指定压缩方式为 PLAIN,SNAPPY,ZLIB 以及 ZSTD,默认值为 ZLIB。该参数自 2.1.5 版本开始支持。(PLAIN 就是不采用压缩) + + :::caution 注意 + 要使用 delete_existing_files 参数,还需要在 fe.conf 中添加配置`enable_delete_existing_files = true`并重启 fe,此时 delete_existing_files 才会生效。delete_existing_files = true 是一个危险的操作,建议只在测试环境中使用。 + ::: + + + +- `WITH BROKER` + + 可以通过 Broker 进程写数据到远端存储上。这里需要定义相关的连接信息供 Broker 使用。 + + ```sql + 语法: + WITH BROKER "broker_name" + ("key"="value"[,...]) + + Broker 相关属性: + username: 用户名 + password: 密码 + hadoop.security.authentication: 指定认证方式为 kerberos + kerberos_principal: 指定 kerberos 的 principal + kerberos_keytab: 指定 kerberos 的 keytab 文件路径。该文件必须为 Broker 进程所在服务器上的文件的绝对路径。并且可以被 Broker 进程访问 + ``` + + +- `WITH HDFS` + + 可以直接将数据写到远端 HDFS 上。 + + ```sql + 语法: + WITH HDFS ("key"="value"[,...]) + + HDFS 相关属性: + fs.defaultFS: namenode 地址和端口 + hadoop.username: hdfs 用户名 + dfs.nameservices: name service 名称,与 hdfs-site.xml 保持一致 + dfs.ha.namenodes.[nameservice ID]: namenode 的 id 列表,与 hdfs-site.xml 保持一致 + dfs.namenode.rpc-address.[nameservice ID].[name node ID]: Name node 的 rpc 地址,数量与 namenode 数量相同,与 hdfs-site.xml 保 + + 对于开启kerberos认证的Hadoop 集群,还需要额外设置如下 PROPERTIES 属性: + dfs.namenode.kerberos.principal: HDFS namenode 服务的 principal 名称 + hadoop.security.authentication: 认证方式设置为 kerberos + hadoop.kerberos.principal: 设置 Doris 连接 HDFS 时使用的 Kerberos 主体 + hadoop.kerberos.keytab: 设置 keytab 本地文件路径 + ``` + +- `WITH S3` + + 可以直接将数据写到远端 S3 对象存储上。 + + ```sql + 语法: + WITH S3 ("key"="value"[,...]) + + S3 相关属性: + AWS_ENDPOINT + AWS_ACCESS_KEY + AWS_SECRET_KEY + AWS_REGION + use_path_style: (选填) 默认为 `false`。S3 SDK 默认使用 Virtual-hosted Style 方式。但某些对象存储系统可能没开启或不支持 Virtual-hosted Style 方式的访问,此时可以添加 `use_path_style` 参数来强制使用 Path Style 访问方式。 + ``` + +## 示例 + +#### Export 数据到本地 +> Export 数据到本地文件系统,需要在 `fe.conf` 中添加 `enable_outfile_to_local=true` 并且重启 FE。 + +1. 将 Test 表中的所有数据导出到本地存储,默认导出 CSV 格式文件 +```sql +EXPORT TABLE test TO "file:///home/user/tmp/"; +``` + +2. 将 Test 表中的 k1,k2 列导出到本地存储,默认导出 CSV 文件格式,并设置 Label +```sql +EXPORT TABLE test TO "file:///home/user/tmp/" +PROPERTIES ( + "label" = "label1", + "columns" = "k1,k2" +); +``` + +3. 将 Test 表中的 `k1 < 50` 的行导出到本地存储,默认导出 CSV 格式文件,并以 `,` 作为列分割符 +```sql +EXPORT TABLE test WHERE k1 < 50 TO "file:///home/user/tmp/" +PROPERTIES ( + "columns" = "k1,k2", + "column_separator"="," +); +``` + +4. 将 Test 表中的分区 p1,p2 导出到本地存储,默认导出 csv 格式文件 +```sql +EXPORT TABLE test PARTITION (p1,p2) TO "file:///home/user/tmp/" +PROPERTIES ("columns" = "k1,k2"); +``` + +5. 将 Test 表中的所有数据导出到本地存储,导出其他格式的文件 +```sql +// parquet格式 +EXPORT TABLE test TO "file:///home/user/tmp/" +PROPERTIES ( + "columns" = "k1,k2", + "format" = "parquet" +); + +// orc格式 +EXPORT TABLE test TO "file:///home/user/tmp/" +PROPERTIES ( + "columns" = "k1,k2", + "format" = "orc" +); + +// csv_with_names格式, 以’AA‘为列分割符,‘zz’为行分割符 +EXPORT TABLE test TO "file:///home/user/tmp/" +PROPERTIES ( + "format" = "csv_with_names", + "column_separator"="AA", + "line_delimiter" = "zz" +); + +// csv_with_names_and_types格式 +EXPORT TABLE test TO "file:///home/user/tmp/" +PROPERTIES ( + "format" = "csv_with_names_and_types" +); +``` + +6. 设置 `max_file_sizes` 属性 +```sql +EXPORT TABLE test TO "file:///home/user/tmp/" +PROPERTIES ( + "format" = "parquet", + "max_file_size" = "5MB" +); +``` +当导出文件大于 5MB 时,将切割数据为多个文件,每个文件最大为 5MB。 + +7. 设置 `parallelism` 属性 +```sql +EXPORT TABLE test TO "file:///home/user/tmp/" +PROPERTIES ( + "format" = "parquet", + "max_file_size" = "5MB", + "parallelism" = "5" +); +``` + +8. 设置 `delete_existing_files` 属性 +```sql +EXPORT TABLE test TO "file:///home/user/tmp" +PROPERTIES ( + "format" = "parquet", + "max_file_size" = "5MB", + "delete_existing_files" = "true" +); +``` +Export 导出数据时会先将`/home/user/`目录下所有文件及目录删除,然后导出数据到该目录下。 + +#### export with S3 + +1. 将 s3_test 表中的所有数据导出到 S3 上,以不可见字符 `\x07` 作为列或者行分隔符。如果需要将数据导出到 minio,还需要指定 `use_path_style`=`true`。 + +```sql +EXPORT TABLE s3_test TO "s3://bucket/a/b/c" +PROPERTIES ( + "column_separator"="\\x07", + "line_delimiter" = "\\x07" +) WITH s3 ( + "s3.endpoint" = "xxxxx", + "s3.region" = "xxxxx", + "s3.secret_key"="xxxx", + "s3.access_key" = "xxxxx" +) +``` + +#### export with HDFS + +1. 将 Test 表中的所有数据导出到 HDFS 上,导出文件格式为 Parquet,导出作业单个文件大小限制为 512MB,保留所指定目录下的所有文件。 + +```sql +EXPORT TABLE test TO "hdfs://hdfs_host:port/a/b/c/" +PROPERTIES( + "format" = "parquet", + "max_file_size" = "512MB", + "delete_existing_files" = "false" +) +with HDFS ( +"fs.defaultFS"="hdfs://hdfs_host:port", +"hadoop.username" = "hadoop" +); +``` + +#### export with Broker +需要先启动 Broker 进程,并在 FE 中添加该 Broker。 +1. 将 Test 表中的所有数据导出到 hdfs 上 +```sql +EXPORT TABLE test TO "hdfs://hdfs_host:port/a/b/c" +WITH BROKER "broker_name" +( + "username"="xxx", + "password"="yyy" +); +``` + +2. 将 testTbl 表中的分区 p1,p2 导出到 hdfs 上,以","作为列分隔符,并指定 Label + +```sql +EXPORT TABLE testTbl PARTITION (p1,p2) TO "hdfs://hdfs_host:port/a/b/c" +PROPERTIES ( + "label" = "mylabel", + "column_separator"="," +) +WITH BROKER "broker_name" +( + "username"="xxx", + "password"="yyy" +); +``` + +3. 将 testTbl 表中的所有数据导出到 hdfs 上,以不可见字符 `\x07` 作为列或者行分隔符。 + +```sql +EXPORT TABLE testTbl TO "hdfs://hdfs_host:port/a/b/c" +PROPERTIES ( + "column_separator"="\\x07", + "line_delimiter" = "\\x07" +) +WITH BROKER "broker_name" +( + "username"="xxx", + "password"="yyy" +) +``` + +## 关键词 + + EXPORT + +### 最佳实践 + +#### 并发执行 + +一个 Export 作业可以设置`parallelism`参数来并发导出数据。`parallelism`参数实际就是指定执行 EXPORT 作业的线程数量。当设置`"data_consistency" = "none"`时,每一个线程会负责导出表的部分 Tablets。 + +一个 Export 作业的底层执行逻辑实际上是`SELECT INTO OUTFILE`语句,`parallelism`参数设置的每一个线程都会去执行独立的`SELECT INTO OUTFILE`语句。 + +Export 作业拆分成多个`SELECT INTO OUTFILE`的具体逻辑是:将该表的所有 tablets 平均的分给所有 parallel 线程,如: +- num(tablets) = 40, parallelism = 3,则这 3 个线程各自负责的 tablets 数量分别为 14,13,13 个。 +- num(tablets) = 2, parallelism = 3,则 Doris 会自动将 parallelism 设置为 2,每一个线程负责一个 tablets。 + +当一个线程负责的 tablest 超过 `maximum_tablets_of_outfile_in_export` 数值(默认为 10,可在 fe.conf 中添加`maximum_tablets_of_outfile_in_export`参数来修改该值)时,该线程就会拆分为多个`SELECT INTO OUTFILE`语句,如: +- 一个线程负责的 tablets 数量分别为 14,`maximum_tablets_of_outfile_in_export = 10`,则该线程负责两个`SELECT INTO OUTFILE`语句,第一个`SELECT INTO OUTFILE`语句导出 10 个 tablets,第二个`SELECT INTO OUTFILE`语句导出 4 个 tablets,两个`SELECT INTO OUTFILE`语句由该线程串行执行。 + + +当所要导出的数据量很大时,可以考虑适当调大`parallelism`参数来增加并发导出。若机器核数紧张,无法再增加`parallelism` 而导出表的 Tablets 又较多时,可以考虑调大`maximum_tablets_of_outfile_in_export`来增加一个`SELECT INTO OUTFILE`语句负责的 tablets 数量,也可以加快导出速度。 + +若希望以 Parition 粒度导出 Table,可以设置 Export 属性 `"data_consistency" = "partition"` ,此时 Export 任务并发的线程会以 Parition 粒度来划分为多个 Outfile 语句,不同的 Outfile 语句导出的 Parition 不同,而同一个 Outfile 语句导出的数据一定属于同一个 Partition。如:设置 `"data_consistency" = "partition"` 后 + +- num(partition) = 40, parallelism = 3,则这 3 个线程各自负责的 Partition 数量分别为 14,13,13 个。 +- num(partition) = 2, parallelism = 3,则 Doris 会自动将 Parallelism 设置为 2,每一个线程负责一个 Partition。 + + +#### 内存限制 + +通常一个 Export 作业的查询计划只有 `扫描-导出` 两部分,不涉及需要太多内存的计算逻辑。所以通常 2GB 的默认内存限制可以满足需求。 + +但在某些场景下,比如一个查询计划,在同一个 BE 上需要扫描的 Tablet 过多,或者 Tablet 的数据版本过多时,可能会导致内存不足。可以调整 Session 变量 `exec_mem_limit` 来调大内存使用限制。 + +#### 注意事项 + +- 不建议一次性导出大量数据。一个 Export 作业建议的导出数据量最大在几十 GB。过大的导出会导致更多的垃圾文件和更高的重试成本。如果表数据量过大,建议按照分区导出。 + +- 如果 Export 作业运行失败,已经生成的文件不会被删除,需要用户手动删除。 + +- Export 作业会扫描数据,占用 IO 资源,可能会影响系统的查询延迟。 + +- 目前在 Export 时只是简单检查 Tablets 版本是否一致,建议在执行 Export 过程中不要对该表进行导入数据操作。 + +- 一个 Export Job 允许导出的分区数量最大为 2000,可以在 `fe.conf` 中添加参数 `maximum_number_of_export_partitions` 并重启 FE 来修改该设置。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/MYSQL-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/MYSQL-LOAD.md new file mode 100644 index 0000000000000..76ebf00bef1c8 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/MYSQL-LOAD.md @@ -0,0 +1,170 @@ +--- +{ + "title": "MYSQL LOAD", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +mysql-load: 使用 MySql 客户端导入本地数据 + +``` +LOAD DATA +[LOCAL] +INFILE 'file_name' +INTO TABLE tbl_name +[PARTITION (partition_name [, partition_name] ...)] +[COLUMNS TERMINATED BY 'string'] +[LINES TERMINATED BY 'string'] +[IGNORE number {LINES | ROWS}] +[(col_name_or_user_var [, col_name_or_user_var] ...)] +[SET (col_name={expr | DEFAULT} [, col_name={expr | DEFAULT}] ...)] +[PROPERTIES (key1 = value1 [, key2=value2]) ] +``` + +该语句用于向指定的 table 导入数据,与普通 Load 区别是,这种导入方式是同步导入。 + +这种导入方式仍然能够保证一批导入任务的原子性,要么全部数据导入成功,要么全部失败。 + +1. MySQL Load 以语法`LOAD DATA`开头,无须指定 LABEL +2. 指定`LOCAL`表示读取客户端文件。不指定表示读取 FE 服务端本地文件。导入 FE 本地文件的功能默认是关闭的,需要在 FE 节点上设置`mysql_load_server_secure_path`来指定安全路径,才能打开该功能。 +3. `INFILE`内填写本地文件路径,可以是相对路径,也可以是绝对路径。目前只支持单个文件,不支持多个文件 +4. `INTO TABLE`的表名可以指定数据库名,如案例所示。也可以省略,则会使用当前用户所在的数据库。 +5. `PARTITION`语法支持指定分区导入 +6. `COLUMNS TERMINATED BY`指定列分隔符 +7. `LINES TERMINATED BY`指定行分隔符 +8. `IGNORE num LINES`用户跳过 CSV 的表头,可以跳过任意行数。该语法也可以用`IGNORE num ROWS`代替 +9. 列映射语法,具体参数详见[导入的数据转换](../../../../data-operate/import/import-way/mysql-load-manual.md) 的列映射章节 +10. `PROPERTIES`参数配置,详见下文 + +### PROPERTIES + +1. max_filter_ratio:最大容忍可过滤(数据不规范等原因)的数据比例。默认零容忍。 + +2. timeout: 指定导入的超时时间。单位秒。默认是 600 秒。可设置范围为 1 秒 ~ 259200 秒。 + +3. strict_mode: 用户指定此次导入是否开启严格模式,默认为关闭。 + +4. timezone: 指定本次导入所使用的时区。默认为东八区。该参数会影响所有导入涉及的和时区有关的函数结果。 + +5. exec_mem_limit: 导入内存限制。默认为 2GB。单位为字节。 + +6. trim_double_quotes: 布尔类型,默认值为 false,为 true 时表示裁剪掉导入文件每个字段最外层的双引号。 + +7. enclose: 包围符。当 csv 数据字段中含有行分隔符或列分隔符时,为防止意外截断,可指定单字节字符作为包围符起到保护作用。例如列分隔符为",",包围符为"'",数据为"a,'b,c'",则"b,c"会被解析为一个字段。注意:当 enclose 设置为`"`时,trim_double_quotes 一定要设置为 true。 + +8. escape: 转义符。用于转义在 csv 字段中出现的与包围符相同的字符。例如数据为"a,'b,'c'",包围符为"'",希望"b,'c 被作为一个字段解析,则需要指定单字节转义符,例如"\",然后将数据修改为"a,'b,\'c'"。 + +## 示例 + +1. 将客户端本地文件'testData'中的数据导入到数据库'testDb'中'testTbl'的表。指定超时时间为 100 秒 + + ```sql + LOAD DATA LOCAL + INFILE 'testData' + INTO TABLE testDb.testTbl + PROPERTIES ("timeout"="100") + ``` + +2. 将服务端本地文件'/root/testData'(需设置 FE 配置`mysql_load_server_secure_path`为`/root`) 中的数据导入到数据库'testDb'中'testTbl'的表。指定超时时间为 100 秒 + + ```sql + LOAD DATA + INFILE '/root/testData' + INTO TABLE testDb.testTbl + PROPERTIES ("timeout"="100") + ``` + +3. 将客户端本地文件'testData'中的数据导入到数据库'testDb'中'testTbl'的表,允许 20% 的错误率 + + ```sql + LOAD DATA LOCAL + INFILE 'testData' + INTO TABLE testDb.testTbl + PROPERTIES ("max_filter_ratio"="0.2") + ``` + +4. 将客户端本地文件'testData'中的数据导入到数据库'testDb'中'testTbl'的表,允许 20% 的错误率,并且指定文件的列名 + + ```sql + LOAD DATA LOCAL + INFILE 'testData' + INTO TABLE testDb.testTbl + (k2, k1, v1) + PROPERTIES ("max_filter_ratio"="0.2") + ``` + +5. 将本地文件'testData'中的数据导入到数据库'testDb'中'testTbl'的表中的 p1, p2 分区,允许 20% 的错误率。 + + ```sql + LOAD DATA LOCAL + INFILE 'testData' + INTO TABLE testDb.testTbl + PARTITION (p1, p2) + PROPERTIES ("max_filter_ratio"="0.2") + ``` + +6. 将本地行分隔符为`0102`,列分隔符为`0304`的 CSV 文件'testData'中的数据导入到数据库'testDb'中'testTbl'的表中。 + + ```sql + LOAD DATA LOCAL + INFILE 'testData' + INTO TABLE testDb.testTbl + COLUMNS TERMINATED BY '0304' + LINES TERMINATED BY '0102' + ``` + +7. 将本地文件'testData'中的数据导入到数据库'testDb'中'testTbl'的表中的 p1, p2 分区,并跳过前面 3 行。 + + ```sql + LOAD DATA LOCAL + INFILE 'testData' + INTO TABLE testDb.testTbl + PARTITION (p1, p2) + IGNORE 1 LINES + ``` + +8. 导入数据进行严格模式过滤,并设置时区为 Africa/Abidjan + + ```sql + LOAD DATA LOCAL + INFILE 'testData' + INTO TABLE testDb.testTbl + PROPERTIES ("strict_mode"="true", "timezone"="Africa/Abidjan") + ``` + +9. 导入数据进行限制导入内存为 10GB, 并在 10 分钟超时 + + ```sql + LOAD DATA LOCAL + INFILE 'testData' + INTO TABLE testDb.testTbl + PROPERTIES ("exec_mem_limit"="10737418240", "timeout"="600") + ``` + +## 关键词 + + MYSQL, LOAD diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/OUTFILE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/OUTFILE.md new file mode 100644 index 0000000000000..5204794f4c546 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/OUTFILE.md @@ -0,0 +1,415 @@ +--- +{ + "title": "OUTFILE", + "language": "zh-CN" +} +--- + + + + + +## 描述 + + `SELECT INTO OUTFILE` 命令用于将查询结果导出为文件。目前支持通过 Broker 进程,S3 协议或 HDFS 协议,导出到远端存储,如 HDFS,S3,BOS,COS(腾讯云)上。 + +#### 语法: + +``` +query_stmt +INTO OUTFILE "file_path" +[format_as] +[properties] +``` + +#### 说明: + +1. file_path + + 文件存储的路径及文件前缀。 + + ``` + file_path 指向文件存储的路径以及文件前缀。如 `hdfs://path/to/my_file_`。 + + 最终的文件名将由 `my_file_`、文件序号以及文件格式后缀组成。其中文件序号由 0 开始,数量为文件被分割的数量。如: + my_file_abcdefg_0.csv + my_file_abcdefg_1.csv + my_file_abcdegf_2.csv + ``` + + 也可以省略文件前缀,只指定文件目录,如`hdfs://path/to/` + +2. format_as + + ``` + FORMAT AS CSV + ``` + + 指定导出格式。支持 CSV、PARQUET、CSV_WITH_NAMES、CSV_WITH_NAMES_AND_TYPES、ORC. 默认为 CSV。 + + > 注:PARQUET、CSV_WITH_NAMES、CSV_WITH_NAMES_AND_TYPES、ORC 在 1.2 版本开始支持。 + +3. properties + + ``` + 指定相关属性。目前支持通过 Broker 进程,或通过 S3/HDFS 协议进行导出。 + + 语法: + [PROPERTIES ("key"="value", ...)] + 支持如下属性: + + 文件相关的属性: + `column_separator`: 列分隔符,只用于 CSV 相关格式。在 1.2 版本开始支持多字节分隔符,如:"\\x01", "abc"。 + `line_delimiter`: 行分隔符,只用于 CSV 相关格式。在 1.2 版本开始支持多字节分隔符,如:"\\x01", "abc"。 + `max_file_size`: 单个文件大小限制,如果结果超过这个值,将切割成多个文件,`max_file_size` 取值范围是[5MB, 2GB], 默认为 `1GB`。(当指定导出为 OCR 文件格式时,实际切分文件的大小将是 64MB 的倍数,如:指定 `max_file_size = 5MB`, 实际将以 64 MB 为切分;指定 `max_file_size = 65MB`, 实际将以 128 MB 为切分) + `delete_existing_files`: 默认为 `false`,若指定为 `true`,则会先删除 `file_path` 指定的目录下的所有文件,然后导出数据到该目录下。例如:"file_path" = "/user/tmp", 则会删除"/user/"下所有文件及目录;"file_path" = "/user/tmp/", 则会删除"/user/tmp/"下所有文件及目录。 + `file_suffix`: 指定导出文件的后缀,若不指定该参数,将使用文件格式的默认后缀。 + `compress_type`:当指定导出的文件格式为 Parquet / ORC 文件时,可以指定 Parquet / ORC 文件使用的压缩方式。Parquet 文件格式可指定压缩方式为 SNAPPY,GZIP,BROTLI,ZSTD,LZ4 及 PLAIN,默认值为 SNAPPY。ORC 文件格式可指定压缩方式为 PLAIN,SNAPPY,ZLIB 以及 ZSTD,默认值为 ZLIB。该参数自 2.1.5 版本开始支持。(PLAIN 就是不采用压缩) + + Broker 相关属性需加前缀 `broker.`: + broker.name: broker 名称 + broker.hadoop.security.authentication: 指定认证方式为 kerberos + broker.kerberos_principal: 指定 kerberos 的 principal + broker.kerberos_keytab: 指定 kerberos 的 keytab 文件路径。该文件必须为 Broker 进程所在服务器上的文件的绝对路径。并且可以被 Broker 进程访问 + + HDFS 相关属性: + fs.defaultFS: namenode 地址和端口 + hadoop.username: hdfs 用户名 + dfs.nameservices: name service 名称,与 hdfs-site.xml 保持一致 + dfs.ha.namenodes.[nameservice ID]: namenode 的 id 列表,与 hdfs-site.xml 保持一致 + dfs.namenode.rpc-address.[nameservice ID].[name node ID]: Name node 的 rpc 地址,数量与 namenode 数量相同,与 hdfs-site.xml 保持一致 + dfs.client.failover.proxy.provider.[nameservice ID]: HDFS 客户端连接活跃 namenode 的 java 类,通常是"org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider" + + 对于开启 kerberos 认证的 Hadoop 集群,还需要额外设置如下 PROPERTIES 属性: + dfs.namenode.kerberos.principal: HDFS namenode 服务的 principal 名称 + hadoop.security.authentication: 认证方式设置为 kerberos + hadoop.kerberos.principal: 设置 Doris 连接 HDFS 时使用的 Kerberos 主体 + hadoop.kerberos.keytab: 设置 keytab 本地文件路径 + + S3 协议则直接执行 S3 协议配置即可: + s3.endpoint + s3.access_key + s3.secret_key + s3.region + use_path_style: (选填) 默认为 `false` 。S3 SDK 默认使用 Virtual-hosted Style 方式。但某些对象存储系统可能没开启或不支持 Virtual-hosted Style 方式的访问,此时可以添加 `use_path_style` 参数来强制使用 Path Style 访问方式。 + ``` + + > 注意:若要使用 `delete_existing_files` 参数,还需要在 `fe.conf` 中添加配置`enable_delete_existing_files = true`并重启 fe,此时 delete_existing_files 才会生效。delete_existing_files = true 是一个危险的操作,建议只在测试环境中使用。 + +4. 导出的数据类型 + + 所有文件类型都支持导出基本数据类型,而对于复杂数据类型(ARRAY/MAP/STRUCT),当前只有 csv/orc/csv_with_names/csv_with_names_and_types 支持导出复杂类型,且不支持嵌套复杂类型。 + +5. 并发导出 + + 设置 Session 变量```set enable_parallel_outfile = true;```可开启 Outfile 并发导出,详细使用方法见[导出查询结果集](../../../data-operate/export/outfile.md) + +6. 导出到本地 + + 导出到本地文件时需要先在 `fe.conf` 中配置`enable_outfile_to_local=true` + + ```sql + select * from tbl1 limit 10 + INTO OUTFILE "file:///home/work/path/result_"; + ``` + +#### 返回结果说明 + +Outfile 语句返回的结果,各个列的含义如下: +* FileNumber:最终生成的文件个数。 +* TotalRows:结果集行数。 +* FileSize:导出文件总大小。单位字节。 +* URL:导出的文件路径的前缀,多个文件会以后缀 `_0`,`_1` 依次编号。 + +#### 数据类型映射 + +Parquet、ORC 文件格式拥有自己的数据类型,Doris 的导出功能能够自动将 Doris 的数据类型导出到 Parquet/ORC 文件格式的对应数据类型,以下是 Apache Doris 数据类型和 Parquet/ORC 文件格式的数据类型映射关系表: + +1. Doris 导出到 ORC 文件格式的数据类型映射表: + + | Doris Type | Orc Type | + | --- | --- | + | boolean | boolean | + | tinyint | tinyint | + | smallint | smallint | + | int | int | + | bigint | bigint | + | largeInt | string | + | date | string | + | datev2 | string | + | datetime | string | + | datetimev2 | timestamp | + | float | float | + | double | double | + | char / varchar / string | string | + | decimal | decimal | + | struct | struct | + | map | map | + | array | array | + + +2. Doris 导出到 Parquet 文件格式时,会先将 Doris 内存数据转换为 Arrow 内存数据格式,然后由 Arrow 写出到 Parquet 文件格式。Doris 数据类型到 Arrow 数据类的映射关系为: + + | Doris Type | Arrow Type | + | --- | --- | + | boolean | boolean | + | tinyint | int8 | + | smallint | int16 | + | int | int32 | + | bigint | int64 | + | largeInt | utf8 | + | date | utf8 | + | datev2 | utf8 | + | datetime | utf8 | + | datetimev2 | utf8 | + | float | float32 | + | double | float64 | + | char / varchar / string | utf8 | + | decimal | decimal128 | + | struct | struct | + | map | map | + | array | list | + +## 示例 + +1. 使用 Broker 方式导出,将简单查询结果导出到文件 `hdfs://path/to/result.txt`。指定导出格式为 CSV。使用 `my_broker` 并设置 kerberos 认证信息。指定列分隔符为 `,`,行分隔符为 `\n`。 + + ```sql + SELECT * FROM tbl + INTO OUTFILE "hdfs://path/to/result_" + FORMAT AS CSV + PROPERTIES + ( + "broker.name" = "my_broker", + "broker.hadoop.security.authentication" = "kerberos", + "broker.kerberos_principal" = "doris@YOUR.COM", + "broker.kerberos_keytab" = "/home/doris/my.keytab", + "column_separator" = ",", + "line_delimiter" = "\n", + "max_file_size" = "100MB" + ); + ``` + + 最终生成文件如如果不大于 100MB,则为:`result_0.csv`。 + 如果大于 100MB,则可能为 `result_0.csv, result_1.csv, ...`。 + +2. 将简单查询结果导出到文件 `hdfs://path/to/result.parquet`。指定导出格式为 PARQUET。使用 `my_broker` 并设置 kerberos 认证信息。 + + ```sql + SELECT c1, c2, c3 FROM tbl + INTO OUTFILE "hdfs://path/to/result_" + FORMAT AS PARQUET + PROPERTIES + ( + "broker.name" = "my_broker", + "broker.hadoop.security.authentication" = "kerberos", + "broker.kerberos_principal" = "doris@YOUR.COM", + "broker.kerberos_keytab" = "/home/doris/my.keytab" + ); + ``` + +3. 将 CTE 语句的查询结果导出到文件 `hdfs://path/to/result.txt`。默认导出格式为 CSV。使用 `my_broker` 并设置 HDFS 高可用信息。使用默认的行列分隔符。 + + ```sql + WITH + x1 AS + (SELECT k1, k2 FROM tbl1), + x2 AS + (SELECT k3 FROM tbl2) + SELEC k1 FROM x1 UNION SELECT k3 FROM x2 + INTO OUTFILE "hdfs://path/to/result_" + PROPERTIES + ( + "broker.name" = "my_broker", + "broker.username"="user", + "broker.password"="passwd", + "broker.dfs.nameservices" = "my_ha", + "broker.dfs.ha.namenodes.my_ha" = "my_namenode1, my_namenode2", + "broker.dfs.namenode.rpc-address.my_ha.my_namenode1" = "nn1_host:rpc_port", + "broker.dfs.namenode.rpc-address.my_ha.my_namenode2" = "nn2_host:rpc_port", + "broker.dfs.client.failover.proxy.provider" = "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider" + ); + ``` + + 最终生成文件如如果不大于 1GB,则为:`result_0.csv`。 + 如果大于 1GB,则可能为 `result_0.csv, result_1.csv, ...`。 + +4. 将 UNION 语句的查询结果导出到文件 `bos://bucket/result.txt`。指定导出格式为 PARQUET。使用 `my_broker` 并设置 HDFS 高可用信息。PARQUET 格式无需指定列分割符。 + 导出完成后,生成一个标识文件。 + + ```sql + SELECT k1 FROM tbl1 UNION SELECT k2 FROM tbl1 + INTO OUTFILE "bos://bucket/result_" + FORMAT AS PARQUET + PROPERTIES + ( + "broker.name" = "my_broker", + "broker.bos_endpoint" = "http://bj.bcebos.com", + "broker.bos_accesskey" = "xxxxxxxxxxxxxxxxxxxxxxxxxx", + "broker.bos_secret_accesskey" = "yyyyyyyyyyyyyyyyyyyyyyyyyy" + ); + ``` + +5. 将 Select 语句的查询结果导出到文件 `s3a://${bucket_name}/path/result.txt`。指定导出格式为 CSV。 + 导出完成后,生成一个标识文件。 + + ```sql + select k1,k2,v1 from tbl1 limit 100000 + into outfile "s3a://my_bucket/export/my_file_" + FORMAT AS CSV + PROPERTIES + ( + "broker.name" = "hdfs_broker", + "broker.fs.s3a.access.key" = "xxx", + "broker.fs.s3a.secret.key" = "xxxx", + "broker.fs.s3a.endpoint" = "https://cos.xxxxxx.myqcloud.com/", + "column_separator" = ",", + "line_delimiter" = "\n", + "max_file_size" = "1024MB", + "success_file_name" = "SUCCESS" + ) + ``` + + 最终生成文件如如果不大于 1GB,则为:`my_file_0.csv`。 + 如果大于 1GB,则可能为 `my_file_0.csv, result_1.csv, ...`。 + 在 cos 上验证 + + 1. 不存在的 path 会自动创建 + 2. access.key/secret.key/endpoint需要和cos的同学确认。尤其是endpoint的值,不需要填写bucket_name。 + +6. 使用 S3 协议导出到 bos,并且并发导出开启。 + + ```sql + set enable_parallel_outfile = true; + select k1 from tb1 limit 1000 + into outfile "s3://my_bucket/export/my_file_" + format as csv + properties + ( + "s3.endpoint" = "http://s3.bd.bcebos.com", + "s3.access_key" = "xxxx", + "s3.secret_key" = "xxx", + "s3.region" = "bd" + ) + ``` + + 最终生成的文件前缀为 `my_file_{fragment_instance_id}_`。 + +7. 使用 S3 协议导出到 bos,并且并发导出 Session 变量开启。 + 注意:但由于查询语句带了一个顶层的排序节点,所以这个查询即使开启并发导出的 Session 变量,也是无法并发导出的。 + + ```sql + set enable_parallel_outfile = true; + select k1 from tb1 order by k1 limit 1000 + into outfile "s3://my_bucket/export/my_file_" + format as csv + properties + ( + "s3.endpoint" = "http://s3.bd.bcebos.com", + "s3.access_key" = "xxxx", + "s3.secret_key" = "xxx", + "s3.region" = "bd" + ) + ``` + +8. 使用 HDFS 方式导出,将简单查询结果导出到文件 `hdfs://${host}:${fileSystem_port}/path/to/result.txt`。指定导出格式为 CSV,用户名为 work。指定列分隔符为 `,`,行分隔符为 `\n`。 + + ```sql + -- fileSystem_port 默认值为 9000 + SELECT * FROM tbl + INTO OUTFILE "hdfs://${host}:${fileSystem_port}/path/to/result_" + FORMAT AS CSV + PROPERTIES + ( + "fs.defaultFS" = "hdfs://ip:port", + "hadoop.username" = "work" + ); + ``` + + 如果 Hadoop 集群开启高可用并且启用 Kerberos 认证,可以参考如下 SQL 语句: + + ```sql + SELECT * FROM tbl + INTO OUTFILE "hdfs://path/to/result_" + FORMAT AS CSV + PROPERTIES + ( + 'fs.defaultFS'='hdfs://hacluster/', + 'dfs.nameservices'='hacluster', + 'dfs.ha.namenodes.hacluster'='n1,n2', + 'dfs.namenode.rpc-address.hacluster.n1'='192.168.0.1:8020', + 'dfs.namenode.rpc-address.hacluster.n2'='192.168.0.2:8020', + 'dfs.client.failover.proxy.provider.hacluster'='org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider', + 'dfs.namenode.kerberos.principal'='hadoop/_HOST@REALM.COM' + 'hadoop.security.authentication'='kerberos', + 'hadoop.kerberos.principal'='doris_test@REALM.COM', + 'hadoop.kerberos.keytab'='/path/to/doris_test.keytab' + ); + ``` + + 最终生成文件如如果不大于 100 MB,则为:`result_0.csv`。 + 如果大于 100 MB,则可能为 `result_0.csv, result_1.csv, ...`。 + +9. 将 Select 语句的查询结果导出到腾讯云 cos 的文件 `cosn://${bucket_name}/path/result.txt`。指定导出格式为 CSV。 + 导出完成后,生成一个标识文件。 + + ```sql + select k1,k2,v1 from tbl1 limit 100000 + into outfile "cosn://my_bucket/export/my_file_" + FORMAT AS CSV + PROPERTIES + ( + "broker.name" = "broker_name", + "broker.fs.cosn.userinfo.secretId" = "xxx", + "broker.fs.cosn.userinfo.secretKey" = "xxxx", + "broker.fs.cosn.bucket.endpoint_suffix" = "cos.xxxxxx.myqcloud.com", + "column_separator" = ",", + "line_delimiter" = "\n", + "max_file_size" = "1024MB", + "success_file_name" = "SUCCESS" + ) + ``` + +## 关键词 + SELECT, INTO, OUTFILE + +### 最佳实践 + +1. 导出数据量和导出效率 + + 该功能本质上是执行一个 SQL 查询命令。最终的结果是单线程输出的。所以整个导出的耗时包括查询本身的耗时,和最终结果集写出的耗时。如果查询较大,需要设置会话变量 `query_timeout` 适当的延长查询超时时间。 + +2. 导出文件的管理 + + Doris 不会管理导出的文件。包括导出成功的,或者导出失败后残留的文件,都需要用户自行处理。 + +3. 导出到本地文件 + + 导出到本地文件的功能不适用于公有云用户,仅适用于私有化部署的用户。并且默认用户对集群节点有完全的控制权限。Doris 对于用户填写的导出路径不会做合法性检查。如果 Doris 的进程用户对该路径无写权限,或路径不存在,则会报错。同时处于安全性考虑,如果该路径已存在同名的文件,则也会导出失败。 + + Doris 不会管理导出到本地的文件,也不会检查磁盘空间等。这些文件需要用户自行管理,如清理等。 + +4. 结果完整性保证 + + 该命令是一个同步命令,因此有可能在执行过程中任务连接断开了,从而无法获悉导出的数据是否正常结束,或是否完整。此时可以使用 `success_file_name` 参数要求任务成功后,在目录下生成一个成功文件标识。用户可以通过这个文件,来判断导出是否正常结束。 + +5. 其他注意事项 + + 见[导出查询结果集](../../../data-operate/export/outfile.md) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/PAUSE-ROUTINE-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/PAUSE-ROUTINE-LOAD.md new file mode 100644 index 0000000000000..20a9e5f8c187e --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/PAUSE-ROUTINE-LOAD.md @@ -0,0 +1,57 @@ +--- +{ + "title": "PAUSE ROUTINE LOAD", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +用于暂停一个 Routine Load 作业。被暂停的作业可以通过 RESUME 命令重新运行。 + +```sql +PAUSE [ALL] ROUTINE LOAD FOR job_name +``` + +## 示例 + +1. 暂停名称为 test1 的例行导入作业。 + + ```sql + PAUSE ROUTINE LOAD FOR test1; + ``` + +2. 暂停所有例行导入作业。 + + ```sql + PAUSE ALL ROUTINE LOAD; + ``` + +## 关键词 + + PAUSE, ROUTINE, LOAD + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/PAUSE-SYNC-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/PAUSE-SYNC-JOB.md new file mode 100644 index 0000000000000..a5e3169808cec --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/PAUSE-SYNC-JOB.md @@ -0,0 +1,53 @@ +--- +{ + "title": "PAUSE SYNC JOB", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +通过 `job_name` 暂停一个数据库内正在运行的常驻数据同步作业,被暂停的作业将停止同步数据,保持消费的最新位置,直到被用户恢复。 + +语法: + +```sql +PAUSE SYNC JOB [db.]job_name +``` + +## 示例 + +1. 暂停名称为 `job_name` 的数据同步作业。 + + ```sql + PAUSE SYNC JOB `job_name`; + ``` + +## 关键词 + + PAUSE, SYNC, JOB + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/RESUME-ROUTINE-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/RESUME-ROUTINE-LOAD.md new file mode 100644 index 0000000000000..d5d1d861f79c6 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/RESUME-ROUTINE-LOAD.md @@ -0,0 +1,57 @@ +--- +{ + "title": "RESUME ROUTINE LOAD", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +用于重启一个被暂停的 Routine Load 作业。重启的作业,将继续从之前已消费的 offset 继续消费。 + +```sql +RESUME [ALL] ROUTINE LOAD FOR job_name +``` + +## 示例 + +1. 重启名称为 test1 的例行导入作业。 + + ```sql + RESUME ROUTINE LOAD FOR test1; + ``` + +2. 重启所有例行导入作业。 + + ```sql + RESUME ALL ROUTINE LOAD; + ``` + +## 关键词 + + RESUME, ROUTINE, LOAD + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/RESUME-SYNC-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/RESUME-SYNC-JOB.md new file mode 100644 index 0000000000000..9584b171364f7 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/RESUME-SYNC-JOB.md @@ -0,0 +1,53 @@ +--- +{ + "title": "RESUME SYNC JOB", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +通过 `job_name`恢复一个当前数据库已被暂停的常驻数据同步作业,作业将从上一次被暂停前最新的位置继续同步数据。 + +语法: + +```sql +RESUME SYNC JOB [db.]job_name +``` + +## 示例 + +1. 恢复名称为 `job_name` 的数据同步作业 + + ```sql + RESUME SYNC JOB `job_name`; + ``` + +## 关键词 + + RESUME, SYNC, LOAD + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-CREATE-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-CREATE-LOAD.md new file mode 100644 index 0000000000000..0215dab1f7258 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-CREATE-LOAD.md @@ -0,0 +1,56 @@ +--- +{ + "title": "SHOW CREATE LOAD", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于展示导入作业的创建语句。 + +语法: + +```sql +SHOW CREATE LOAD for load_name; +``` + +说明: + 1. `load_name`: 例行导入作业名称 + +## 示例 + +1. 展示默认 db 下指定导入作业的创建语句 + + ```sql + SHOW CREATE LOAD for test_load + ``` + +## 关键词 + + SHOW, CREATE, LOAD + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-CREATE-ROUTINE-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-CREATE-ROUTINE-LOAD.md new file mode 100644 index 0000000000000..d7730520a3984 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-CREATE-ROUTINE-LOAD.md @@ -0,0 +1,59 @@ +--- +{ + "title": "SHOW CREATE ROUTINE LOAD", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于展示例行导入作业的创建语句。 + +结果中的 kafka partition 和 offset 展示的当前消费的 partition,以及对应的待消费的 offset。 + +语法: + +```sql +SHOW [ALL] CREATE ROUTINE LOAD for load_name; +``` + +说明: + 1. `ALL`: 可选参数,代表获取所有作业,包括历史作业 + 2. `load_name`: 例行导入作业名称 + +## 示例 + +1. 展示默认 db 下指定例行导入作业的创建语句 + + ```sql + SHOW CREATE ROUTINE LOAD for test_load + ``` + +## 关键词 + + SHOW, CREATE, ROUTINE, LOAD + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-EXPORT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-EXPORT.md new file mode 100644 index 0000000000000..a74e3c0bed78e --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-EXPORT.md @@ -0,0 +1,120 @@ +--- +{ + "title": "SHOW EXPORT", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于展示指定的导出任务的执行情况 + +语法: + +```sql +SHOW EXPORT +[FROM db_name] + [ + WHERE + [ID = your_job_id] + [STATE = ["PENDING"|"EXPORTING"|"FINISHED"|"CANCELLED"]] + [LABEL = your_label] + ] +[ORDER BY ...] +[LIMIT limit]; +``` +说明: + 1. 如果不指定 db_name,使用当前默认 db + 2. 如果指定了 STATE,则匹配 EXPORT 状态 + 3. 可以使用 ORDER BY 对任意列组合进行排序 + 4. 如果指定了 LIMIT,则显示 limit 条匹配记录。否则全部显示 + +`show export` 命令返回的结果各个列的含义如下: + +* JobId:作业的唯一 ID +* Label:该导出作业的标签,如果 Export 没有指定,则系统会默认生成一个。 +* State:作业状态: + * PENDING:作业待调度 + * EXPORTING:数据导出中 + * FINISHED:作业成功 + * CANCELLED:作业失败 +* Progress:作业进度。该进度以查询计划为单位。假设一共 10 个线程,当前已完成 3 个,则进度为 30%。 +* TaskInfo:以 Json 格式展示的作业信息: + * db:数据库名 + * tbl:表名 + * partitions:指定导出的分区。`空`列表 表示所有分区。 + * column\_separator:导出文件的列分隔符。 + * line\_delimiter:导出文件的行分隔符。 + * tablet num:涉及的总 Tablet 数量。 + * broker:使用的 broker 的名称。 + * coord num:查询计划的个数。 + * max\_file\_size:一个导出文件的最大大小。 + * delete\_existing\_files:是否删除导出目录下已存在的文件及目录。 + * columns:指定需要导出的列名,空值代表导出所有列。 + * format:导出的文件格式 +* Path:远端存储上的导出路径。 +* CreateTime/StartTime/FinishTime:作业的创建时间、开始调度时间和结束时间。 +* Timeout:作业超时时间。单位是秒。该时间从 CreateTime 开始计算。 +* ErrorMsg:如果作业出现错误,这里会显示错误原因。 +* OutfileInfo:如果作业导出成功,这里会显示具体的`SELECT INTO OUTFILE`结果信息。 + +## 示例 + +1. 展示默认 db 的所有导出任务 + + ```sql + SHOW EXPORT; + ``` + +2. 展示指定 db 的导出任务,按 StartTime 降序排序 + + ```sql + SHOW EXPORT FROM example_db ORDER BY StartTime DESC; + ``` + +3. 展示指定 db 的导出任务,state 为 "exporting", 并按 StartTime 降序排序 + + ```sql + SHOW EXPORT FROM example_db WHERE STATE = "exporting" ORDER BY StartTime DESC; + ``` + +4. 展示指定 db,指定 job_id 的导出任务 + + ```sql + SHOW EXPORT FROM example_db WHERE ID = job_id; + ``` + +5. 展示指定 db,指定 label 的导出任务 + + ```sql + SHOW EXPORT FROM example_db WHERE LABEL = "mylabel"; + ``` + +## 关键词 + + SHOW, EXPORT + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD-PROFILE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD-PROFILE.md new file mode 100644 index 0000000000000..b8f0e8247df1c --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD-PROFILE.md @@ -0,0 +1,230 @@ +--- +{ + "title": "SHOW LOAD PROFILE", + "language": "zh-CN" +} +--- + + + + + +:::caution +自 2.1.1 起,此语法被弃用。 +::: + +## 描述 + +该语句是用来查看导入操作的 Profile 信息,该功能需要用户打开 Profile 设置,0.15 之前版本执行下面的设置: + +```sql +SET is_report_success=true; +``` + +0.15 及之后的版本执行下面的设置: + +```sql +SET [GLOBAL] enable_profile=true; +``` + +语法: + +```sql +show load profile "/"; + +show load profile "/[queryId]" + +show load profile "/[queryId]/[TaskId]" + +show load profile "/[queryId]/[TaskId]/[FragmentId]/" + +show load profile "/[queryId]/[TaskId]/[FragmentId]/[InstanceId]" +``` + +这个命令会列出当前保存的所有导入 Profile。每行对应一个导入。其中 QueryId 列为导入作业的 ID。这个 ID 也可以通过 SHOW LOAD 语句查看拿到。我们可以选择我们想看的 Profile 对应的 QueryId,查看具体情况 + +## 示例 + +**1. 列出所有的 Load Profile** + +```sql +mysql> show load profile "/"\G +*************************** 1. row *************************** + JobId: 20010 + QueryId: 980014623046410a-af5d36f23381017f + User: root + DefaultDb: default_cluster:test + SQL: LOAD LABEL xxx + QueryType: Load + StartTime: 2023-03-07 19:48:24 + EndTime: 2023-03-07 19:50:45 + TotalTime: 2m21s + QueryState: N/A + TraceId: + AnalysisTime: NULL + PlanTime: NULL + ScheduleTime: NULL + FetchResultTime: NULL + WriteResultTime: NULL +WaitAndFetchResultTime: NULL +*************************** 2. row *************************** + JobId: N/A + QueryId: 7cc2d0282a7a4391-8dd75030185134d8 + User: root + DefaultDb: default_cluster:test + SQL: insert into xxx + QueryType: Load + StartTime: 2023-03-07 19:49:15 + EndTime: 2023-03-07 19:49:15 + TotalTime: 102ms + QueryState: OK + TraceId: + AnalysisTime: 825.277us + PlanTime: 4.126ms + ScheduleTime: N/A + FetchResultTime: 0ns + WriteResultTime: 0ns +WaitAndFetchResultTime: N/A +``` + +**2. 查看有导入作业的子任务概况:** + +```sql +mysql> show load profile "/980014623046410a-af5d36f23381017f"; ++-----------------------------------+------------+ +| TaskId | ActiveTime | ++-----------------------------------+------------+ +| 980014623046410a-af5d36f23381017f | 3m14s | ++-----------------------------------+------------+ +``` +**3. 查看子任务的执行树:** + +```sql +show load profile "/980014623046410a-af5d36f23381017f/980014623046410a-af5d36f23381017f"; + + ┌───────────────────────┐ + │[-1: OlapTableSink] │ + │Fragment: 0 │ + │MaxActiveTime: 86.541ms│ + └───────────────────────┘ + │ + │ + ┌───────────────────┐ + │[1: VEXCHANGE_NODE]│ + │Fragment: 0 │ + └───────────────────┘ + ┌─────────────────────────┴───────┐ + │ │ +┌─────────────┐ ┌───────────────────────┐ +│[MemoryUsage]│ │[1: VDataStreamSender] │ +│Fragment: 0 │ │Fragment: 1 │ +└─────────────┘ │MaxActiveTime: 34.882ms│ + └───────────────────────┘ + │ + │ + ┌───────────────────────────┐ + │[0: VNewOlapScanNode(tbl1)]│ + │Fragment: 1 │ + └───────────────────────────┘ + ┌─────────────────┴───────┐ + │ │ + ┌─────────────┐ ┌───────────┐ + │[MemoryUsage]│ │[VScanner] │ + │Fragment: 1 │ │Fragment: 1│ + └─────────────┘ └───────────┘ + ┌───────┴─────────┐ + │ │ + ┌─────────────────┐ ┌─────────────┐ + │[SegmentIterator]│ │[MemoryUsage]│ + │Fragment: 1 │ │Fragment: 1 │ + └─────────────────┘ └─────────────┘ + +``` + +这一层会显示子任务的查询树,其中标注了 Fragment id。 + +**4. 查看指定 Fragment 的 Instance 概况** + +```sql +mysql> show load profile "/980014623046410a-af5d36f23381017f/980014623046410a-af5d36f23381017f/1"; ++-----------------------------------+------------------+------------+ +| Instances | Host | ActiveTime | ++-----------------------------------+------------------+------------+ +| 980014623046410a-88e260f0c43031f2 | 10.81.85.89:9067 | 3m7s | +| 980014623046410a-88e260f0c43031f3 | 10.81.85.89:9067 | 3m6s | +| 980014623046410a-88e260f0c43031f4 | 10.81.85.89:9067 | 3m10s | +| 980014623046410a-88e260f0c43031f5 | 10.81.85.89:9067 | 3m14s | ++-----------------------------------+------------------+------------+ +``` + +**5. 继续查看某一个具体的 Instance 上各个算子的详细 Profile** + +```sql +mysql> show load profile "/980014623046410a-af5d36f23381017f/980014623046410a-af5d36f23381017f/1/980014623046410a-88e260f0c43031f5"\G + +*************************** 1. row *************************** + +Instance: + + ┌-----------------------------------------┐ + │[-1: OlapTableSink] │ + │(Active: 2m17s, non-child: 70.91) │ + │ - Counters: │ + │ - CloseWaitTime: 1m53s │ + │ - ConvertBatchTime: 0ns │ + │ - MaxAddBatchExecTime: 1m46s │ + │ - NonBlockingSendTime: 3m11s │ + │ - NumberBatchAdded: 782 │ + │ - NumberNodeChannels: 1 │ + │ - OpenTime: 743.822us │ + │ - RowsFiltered: 0 │ + │ - RowsRead: 1.599729M (1599729) │ + │ - RowsReturned: 1.599729M (1599729)│ + │ - SendDataTime: 11s761ms │ + │ - TotalAddBatchExecTime: 1m46s │ + │ - ValidateDataTime: 9s802ms │ + └-----------------------------------------┘ + │ +┌-----------------------------------------------------┐ +│[0: BROKER_SCAN_NODE] │ +│(Active: 56s537ms, non-child: 29.06) │ +│ - Counters: │ +│ - BytesDecompressed: 0.00 │ +│ - BytesRead: 5.77 GB │ +│ - DecompressTime: 0ns │ +│ - FileReadTime: 34s263ms │ +│ - MaterializeTupleTime(*): 45s54ms │ +│ - NumDiskAccess: 0 │ +│ - PeakMemoryUsage: 33.03 MB │ +│ - RowsRead: 1.599729M (1599729) │ +│ - RowsReturned: 1.599729M (1599729) │ +│ - RowsReturnedRate: 28.295K sec │ +│ - TotalRawReadTime(*): 1m20s │ +│ - TotalReadThroughput: 30.39858627319336 MB/sec│ +│ - WaitScannerTime: 56s528ms │ +└-----------------------------------------------------┘ +``` + +## 关键词 + +SHOW, LOAD, PROFILE + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD-WARNINGS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD-WARNINGS.md new file mode 100644 index 0000000000000..75d1667f05f8e --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD-WARNINGS.md @@ -0,0 +1,63 @@ +--- +{ + "title": "SHOW LOAD WARNINGS", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +如果导入任务失败且错误信息为 `ETL_QUALITY_UNSATISFIED`,则说明存在导入质量问题,如果想看到这些有质量问题的导入任务,该语句就是完成这个操作的。 + +语法: + +```sql +SHOW LOAD WARNINGS +[FROM db_name] +[ + WHERE + [LABEL [ = "your_label" ]] + [LOAD_JOB_ID = ["job id"]] +] +``` + +1. 如果不指定 db_name,使用当前默认 db +2. 如果使用 LABEL = ,则精确匹配指定的 label +3. 如果指定了 LOAD_JOB_ID,则精确匹配指定的 JOB ID + +## 示例 + +1. 展示指定 db 的导入任务中存在质量问题的数据,指定 label 为 "load_demo_20210112" + + ```sql + SHOW LOAD WARNINGS FROM demo WHERE LABEL = "load_demo_20210112" + ``` + +## 关键词 + + SHOW, LOAD, WARNINGS + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD.md new file mode 100644 index 0000000000000..63eb7d87060ed --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD.md @@ -0,0 +1,113 @@ +--- +{ + "title": "SHOW LOAD", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于展示指定的导入任务的执行情况 + +语法: + +```sql +SHOW LOAD +[FROM db_name] +[ + WHERE + [LABEL [ = "your_label" | LIKE "label_matcher"]] + [STATE = ["PENDING"|"ETL"|"LOADING"|"FINISHED"|"CANCELLED"|]] +] +[ORDER BY ...] +[LIMIT limit][OFFSET offset]; +``` + +说明: + +1) 如果不指定 db_name,使用当前默认 db + +2) 如果使用 LABEL LIKE,则会匹配导入任务的 label 包含 label_matcher 的导入任务 + +3) 如果使用 LABEL = ,则精确匹配指定的 label + +4) 如果指定了 STATE,则匹配 LOAD 状态 + +5) 可以使用 ORDER BY 对任意列组合进行排序 + +6) 如果指定了 LIMIT,则显示 limit 条匹配记录。否则全部显示 + +7) 如果指定了 OFFSET,则从偏移量 offset 开始显示查询结果。默认情况下偏移量为 0。 + +8) 如果是使用 broker/mini load,则 URL 列中的连接可以使用以下命令查看: + + ```sql + SHOW LOAD WARNINGS ON 'url' + ``` + +## 示例 + +1. 展示默认 db 的所有导入任务 + + ```sql + SHOW LOAD; + ``` + +2. 展示指定 db 的导入任务,label 中包含字符串 "2014_01_02",展示最老的 10 个 + + ```sql + SHOW LOAD FROM example_db WHERE LABEL LIKE "2014_01_02" LIMIT 10; + ``` + +3. 展示指定 db 的导入任务,指定 label 为 "load_example_db_20140102" 并按 LoadStartTime 降序排序 + + ```sql + SHOW LOAD FROM example_db WHERE LABEL = "load_example_db_20140102" ORDER BY LoadStartTime DESC; + ``` + +4. 展示指定 db 的导入任务,指定 label 为 "load_example_db_20140102" ,state 为 "loading", 并按 LoadStartTime 降序排序 + + ```sql + SHOW LOAD FROM example_db WHERE LABEL = "load_example_db_20140102" AND STATE = "loading" ORDER BY LoadStartTime DESC; + ``` + +5. 展示指定 db 的导入任务 并按 LoadStartTime 降序排序,并从偏移量 5 开始显示 10 条查询结果 + + ```sql + SHOW LOAD FROM example_db ORDER BY LoadStartTime DESC limit 5,10; + SHOW LOAD FROM example_db ORDER BY LoadStartTime DESC limit 10 offset 5; + ``` + +6. 小批量导入是查看导入状态的命令 + + ``` + curl --location-trusted -u {user}:{passwd} http://{hostname}:{port}/api/{database}/_load_info?label={labelname} + ``` + +## 关键词 + + SHOW, LOAD + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-ROUTINE-LOAD-TASK.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-ROUTINE-LOAD-TASK.md new file mode 100644 index 0000000000000..5fe3e02b87a32 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-ROUTINE-LOAD-TASK.md @@ -0,0 +1,77 @@ +--- +{ + "title": "SHOW ROUTINE LOAD TASK", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +查看一个指定的 Routine Load 作业的当前正在运行的子任务情况。 + +```sql +SHOW ROUTINE LOAD TASK +WHERE JobName = "job_name"; +``` + +返回结果如下: + +```text + TaskId: d67ce537f1be4b86-abf47530b79ab8e6 + TxnId: 4 + TxnStatus: UNKNOWN + JobId: 10280 + CreateTime: 2020-12-12 20:29:48 + ExecuteStartTime: 2020-12-12 20:29:48 + Timeout: 20 + BeId: 10002 +DataSourceProperties: {"0":19} +``` + +- `TaskId`:子任务的唯一 ID。 +- `TxnId`:子任务对应的导入事务 ID。 +- `TxnStatus`:子任务对应的导入事务状态。为 null 时表示子任务还未开始调度。 +- `JobId`:子任务对应的作业 ID。 +- `CreateTime`:子任务的创建时间。 +- `ExecuteStartTime`:子任务被调度执行的时间,通常晚于创建时间。 +- `Timeout`:子任务超时时间,通常是作业设置的 `max_batch_interval` 的两倍。 +- `BeId`:执行这个子任务的 BE 节点 ID。 +- `DataSourceProperties`:子任务准备消费的 Kafka Partition 的起始 offset。是一个 Json 格式字符串。Key 为 Partition Id。Value 为消费的起始 offset。 + +## 示例 + +1. 展示名为 test1 的例行导入任务的子任务信息。 + + ```sql + SHOW ROUTINE LOAD TASK WHERE JobName = "test1"; + ``` + +## 关键词 + + SHOW, ROUTINE, LOAD, TASK + +### 最佳实践 + +通过这个命令,可以查看一个 Routine Load 作业当前有多少子任务在运行,具体运行在哪个 BE 节点上。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-ROUTINE-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-ROUTINE-LOAD.md new file mode 100644 index 0000000000000..44d5a18b7d58b --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-ROUTINE-LOAD.md @@ -0,0 +1,128 @@ +--- +{ + "title": "SHOW ROUTINE LOAD", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于展示 Routine Load 作业运行状态 + +语法: + +```sql +SHOW [ALL] ROUTINE LOAD [FOR jobName]; +``` + +结果说明: + +``` + Id: 作业ID + Name: 作业名称 + CreateTime: 作业创建时间 + PauseTime: 最近一次作业暂停时间 + EndTime: 作业结束时间 + DbName: 对应数据库名称 + TableName: 对应表名称 (多表的情况下由于是动态表,因此不显示具体表名,我们统一显示 multi-table ) + IsMultiTbl: 是否为多表 + State: 作业运行状态 + DataSourceType: 数据源类型:KAFKA + CurrentTaskNum: 当前子任务数量 + JobProperties: 作业配置详情 +DataSourceProperties: 数据源配置详情 + CustomProperties: 自定义配置 + Statistic: 作业运行状态统计信息 + Progress: 作业运行进度 + Lag: 作业延迟状态 +ReasonOfStateChanged: 作业状态变更的原因 + ErrorLogUrls: 被过滤的质量不合格的数据的查看地址 + OtherMsg: 其他错误信息 +``` + +* State + + 有以下 5 种 State: + * NEED_SCHEDULE:作业等待被调度 + * RUNNING:作业运行中 + * PAUSED:作业被暂停 + * STOPPED:作业已结束 + * CANCELLED:作业已取消 + +* Progress + + 对于 Kafka 数据源,显示每个分区当前已消费的 offset。如 {"0":"2"} 表示 Kafka 分区 0 的消费进度为 2。 + +* Lag + + 对于 Kafka 数据源,显示每个分区的消费延迟。如{"0":10} 表示 Kafka 分区 0 的消费延迟为 10。 + +## 示例 + +1. 展示名称为 test1 的所有例行导入作业(包括已停止或取消的作业)。结果为一行或多行。 + + ```sql + SHOW ALL ROUTINE LOAD FOR test1; + ``` + +2. 展示名称为 test1 的当前正在运行的例行导入作业 + + ```sql + SHOW ROUTINE LOAD FOR test1; + ``` + +3. 显示 example_db 下,所有的例行导入作业(包括已停止或取消的作业)。结果为一行或多行。 + + ```sql + use example_db; + SHOW ALL ROUTINE LOAD; + ``` + +4. 显示 example_db 下,所有正在运行的例行导入作业 + + ```sql + use example_db; + SHOW ROUTINE LOAD; + ``` + +5. 显示 example_db 下,名称为 test1 的当前正在运行的例行导入作业 + + ```sql + SHOW ROUTINE LOAD FOR example_db.test1; + ``` + +6. 显示 example_db 下,名称为 test1 的所有例行导入作业(包括已停止或取消的作业)。结果为一行或多行。 + + ```sql + SHOW ALL ROUTINE LOAD FOR example_db.test1; + ``` + +## 关键词 + + SHOW, ROUTINE, LOAD + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-STREAM-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-STREAM-LOAD.md new file mode 100644 index 0000000000000..1518e07eb23c7 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-STREAM-LOAD.md @@ -0,0 +1,96 @@ +--- +{ + "title": "SHOW STREAM LOAD", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句用于展示指定的 Stream Load 任务的执行情况 + +语法: + +```sql +SHOW STREAM LOAD +[FROM db_name] +[ + WHERE + [LABEL [ = "your_label" | LIKE "label_matcher"]] + [STATUS = ["SUCCESS"|"FAIL"]] +] +[ORDER BY ...] +[LIMIT limit][OFFSET offset]; +``` + +说明: + +1. 默认 BE 是不记录 Stream Load 的记录,如果你要查看需要在 BE 上启用记录,配置参数是:`enable_stream_load_record=true` ,具体怎么配置请参照 [BE 配置项](../../../admin-manual/config/be-config.md) +2. 如果不指定 db_name,使用当前默认 db + +2. 如果使用 LABEL LIKE,则会匹配 Stream Load 任务的 label 包含 label_matcher 的任务 +3. 如果使用 LABEL = ,则精确匹配指定的 label +4. 如果指定了 STATUS,则匹配 STREAM LOAD 状态 +5. 可以使用 ORDER BY 对任意列组合进行排序 +6. 如果指定了 LIMIT,则显示 limit 条匹配记录。否则全部显示 +7. 如果指定了 OFFSET,则从偏移量 offset 开始显示查询结果。默认情况下偏移量为 0。 + +## 示例 + +1. 展示默认 db 的所有 Stream Load 任务 + + ```sql + SHOW STREAM LOAD; + ``` + +2. 展示指定 db 的 Stream Load 任务,label 中包含字符串 "2014_01_02",展示最老的 10 个 + + ```sql + SHOW STREAM LOAD FROM example_db WHERE LABEL LIKE "2014_01_02" LIMIT 10; + ``` + +2. 展示指定 db 的 Stream Load 任务,指定 label 为 "load_example_db_20140102" + + ```sql + SHOW STREAM LOAD FROM example_db WHERE LABEL = "load_example_db_20140102"; + ``` + +2. 展示指定 db 的 Stream Load 任务,指定 status 为 "success", 并按 StartTime 降序排序 + + ```sql + SHOW STREAM LOAD FROM example_db WHERE STATUS = "success" ORDER BY StartTime DESC; + ``` + +2. 展示指定 db 的导入任务 并按 StartTime 降序排序,并从偏移量 5 开始显示 10 条查询结果 + + ```sql + SHOW STREAM LOAD FROM example_db ORDER BY StartTime DESC limit 5,10; + SHOW STREAM LOAD FROM example_db ORDER BY StartTime DESC limit 10 offset 5; + ``` + +## 关键词 + +SHOW, STREAM, LOAD + + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-SYNC-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-SYNC-JOB.md new file mode 100644 index 0000000000000..6ff20e07cbb95 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SHOW-SYNC-JOB.md @@ -0,0 +1,61 @@ +--- +{ + "title": "SHOW SYNC JOB", + "language": "zh-CN" +} + +--- + + + + + + + +## 描述 + +此命令用于当前显示所有数据库内的常驻数据同步作业状态。 + +语法: + +```sql +SHOW SYNC JOB [FROM db_name] +``` + +## 示例 + +1. 展示当前数据库的所有数据同步作业状态。 + + ```sql + SHOW SYNC JOB; + ``` + +2. 展示数据库 `test_db` 下的所有数据同步作业状态。 + + ```sql + SHOW SYNC JOB FROM `test_db`; + ``` + +## 关键词 + + SHOW, SYNC, JOB + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/STOP-ROUTINE-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/STOP-ROUTINE-LOAD.md new file mode 100644 index 0000000000000..f5fe6269abd6a --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/STOP-ROUTINE-LOAD.md @@ -0,0 +1,51 @@ +--- +{ + "title": "STOP ROUTINE LOAD", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +用户停止一个 Routine Load 作业。被停止的作业无法再重新运行。 + +```sql +STOP ROUTINE LOAD FOR job_name; +``` + +## 示例 + +1. 停止名称为 test1 的例行导入作业。 + + ```sql + STOP ROUTINE LOAD FOR test1; + ``` + +## 关键词 + + STOP, ROUTINE, LOAD + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/STOP-SYNC-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/STOP-SYNC-JOB.md new file mode 100644 index 0000000000000..3edff22349919 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/STOP-SYNC-JOB.md @@ -0,0 +1,53 @@ +--- +{ + "title": "STOP SYNC JOB", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +通过 `job_name` 停止一个数据库内非停止状态的常驻数据同步作业。 + +语法: + +```sql +STOP SYNC JOB [db.]job_name +``` + +## 示例 + +1. 停止名称为 `job_name` 的数据同步作业 + + ```sql + STOP SYNC JOB `job_name`; + ``` + +## 关键词 + + STOP, SYNC, JOB + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SYNC.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SYNC.md new file mode 100644 index 0000000000000..0c24f1d90813b --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-modification/load-and-export/SYNC.md @@ -0,0 +1,53 @@ +--- +{ + "title": "SYNC", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +用于 fe 非 master 节点同步元数据。doris 只有 master 节点才能写 fe 元数据,其他 fe 节点写元数据的操作都会转发到 master 节点。在 master 完成元数据写入操作后,非 master 节点 replay 元数据会有短暂的延迟,可以使用该语句同步元数据。 + +语法: + +```sql +SYNC; +``` + +## 示例 + +1. 同步元数据 + + ```sql + SYNC; + ``` + +## 关键词 + + SYNC + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/EXPLAIN.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-query/EXPLAIN.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/EXPLAIN.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-query/EXPLAIN.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-query/SELECT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-query/SELECT.md new file mode 100644 index 0000000000000..a135662f3a3a7 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/data-query/SELECT.md @@ -0,0 +1,413 @@ +--- +{ + "title": "SELECT", + "language": "zh-CN" +} + +--- + + + + + + +## 描述 + +主要介绍 Select 语法使用 + +语法: + +```sql +SELECT + [hint_statement, ...] + [ALL | DISTINCT | DISTINCTROW | ALL EXCEPT ( col_name1 [, col_name2, col_name3, ...] )] + select_expr [, select_expr ...] + [FROM table_references + [PARTITION partition_list] + [TABLET tabletid_list] + [TABLESAMPLE sample_value [ROWS | PERCENT] + [REPEATABLE pos_seek]] + [WHERE where_condition] + [GROUP BY [GROUPING SETS | ROLLUP | CUBE] {col_name | expr | position}] + [HAVING where_condition] + [ORDER BY {col_name | expr | position} + [ASC | DESC], ...] + [LIMIT {[offset,] row_count | row_count OFFSET offset}] + [INTO OUTFILE 'file_name'] +``` + +**语法说明:** + +1. select_expr, ... 检索并在结果中显示的列,使用别名时,as 为自选。 + +2. select_expr, ... 检索的目标表(一个或者多个表(包括子查询产生的临时表) + +3. where_definition 检索条件(表达式),如果存在 WHERE 子句,其中的条件对行数据进行筛选。where_condition 是一个表达式,对于要选择的每一行,其计算结果为 true。如果没有 WHERE 子句,该语句将选择所有行。在 WHERE 表达式中,您可以使用除聚合函数之外的任何 MySQL 支持的函数和运算符 + +4. `ALL | DISTINCT ` :对结果集进行刷选,all 为全部,distinct/distinctrow 将刷选出重复列,默认为 all + +5. `ALL EXCEPT`:对全部(all)结果集进行筛选,except 指定要从全部结果集中排除的一个或多个列的名称。输出中将忽略所有匹配的列名称。 + +6. `INTO OUTFILE 'file_name' ` :保存结果至新文件(之前不存在)中,区别在于保存的格式。 + +7. `Group by having`:对结果集进行分组,having 出现则对 group by 的结果进行刷选。`Grouping Sets`、`Rollup`、`Cube` 为 group by 的扩展,详细可参考[GROUPING SETS 设计文档](https://doris.apache.org/zh-CN/community/design/grouping_sets_design)。 + +8. `Order by `: 对最后的结果进行排序,Order by 通过比较一列或者多列的大小来对结果集进行排序。 + + Order by 是比较耗时耗资源的操作,因为所有数据都需要发送到 1 个节点后才能排序,排序操作相比不排序操作需要更多的内存。 + + 如果需要返回前 N 个排序结果,需要使用 LIMIT 从句;为了限制内存的使用,如果用户没有指定 LIMIT 从句,则默认返回前 65535 个排序结果。 + +9. `Limit n`: 限制输出结果中的行数,`limit m,n` 表示从第 m 行开始输出 n 条记录,**使用 limit m,n 的时候要加上 order by 才有意义,否则每次执行的数据可能会不一致** + +10. `Having` 从句不是过滤表中的行数据,而是过滤聚合函数产出的结果。 + + 通常来说 `having` 要和聚合函数(例如 :`COUNT(), SUM(), AVG(), MIN(), MAX()`)以及 `group by` 从句一起使用。 + +11. SELECT 支持使用 PARTITION 显式分区选择,其中包含 `table_reference` 中表的名称后面的分区或子分区(或两者)列表。 + +12. `[TABLET tids] TABLESAMPLE n [ROWS | PERCENT] [REPEATABLE seek]`: 在 FROM 子句中限制表的读取行数,根据指定的行数或百分比从表中伪随机的选择数个 Tablet,REPEATABLE 指定种子数可使选择的样本再次返回,此外也可手动指定 TableID,注意这只能用于 OLAP 表。 + +13. `hint_statement`: 在 selectlist 前面使用 hint 表示可以通过 hint 去影响优化器的行为以期得到想要的执行计划,详情可参考[joinHint 使用文档](https://doris.apache.org/zh-CN/docs/2.0/query/join-optimization/join-hint)。 + +**语法约束:** + +1. SELECT 也可用于检索计算的行而不引用任何表。 +2. 所有的字句必须严格地按照上面格式排序,一个 HAVING 子句必须位于 GROUP BY 子句之后,并位于 ORDER BY 子句之前。 +3. 别名关键词 AS 自选。别名可用于 group by,order by 和 having +4. Where 子句:执行 WHERE 语句以确定哪些行应被包含在 GROUP BY 部分中,而 HAVING 用于确定应使用结果集中的哪些行。 +5. HAVING 子句可以引用总计函数,而 WHERE 子句不能引用,如 count,sum,max,min,avg,同时,where 子句可以引用除总计函数外的其他函数。Where 子句中不能使用列别名来定义条件。 +6. Group by 后跟 with rollup 可以对结果进行一次或者多次统计。 + +**联接查询:** + +Doris 支持以下 JOIN 语法 + +```sql +JOIN +table_references: + table_reference [, table_reference] … +table_reference: + table_factor + | join_table +table_factor: + tbl_name [[AS] alias] + [{USE|IGNORE|FORCE} INDEX (key_list)] + | ( table_references ) + | { OJ table_reference LEFT OUTER JOIN table_reference + ON conditional_expr } +join_table: + table_reference [INNER | CROSS] JOIN table_factor [join_condition] + | table_reference LEFT [OUTER] JOIN table_reference join_condition + | table_reference NATURAL [LEFT [OUTER]] JOIN table_factor + | table_reference RIGHT [OUTER] JOIN table_reference join_condition + | table_reference NATURAL [RIGHT [OUTER]] JOIN table_factor +join_condition: + ON conditional_expr +``` + +**UNION 语法:** + +```sql +SELECT ... +UNION [ALL| DISTINCT] SELECT ...... +[UNION [ALL| DISTINCT] SELECT ...] +``` + +`UNION` 用于将多个 `SELECT` 语句 的结果组合 到单个结果集中。 + +第一个 `SELECT` 语句中的列名称用作返回结果的列名称。在每个 `SELECT`语句的 相应位置列出的选定列 应具有相同的数据类型。 (例如,第一个语句选择的第一列应该与其他语句选择的第一列具有相同的类型。) + +默认行为 `UNION`是从结果中删除重复的行。可选 `DISTINCT` 关键字除了默认值之外没有任何效果,因为它还指定了重复行删除。使用可选 `ALL` 关键字,不会发生重复行删除,结果包括所有 `SELECT` 语句中的 所有匹配行 + +**WITH 语句**: + +要指定公用表表达式,请使用 `WITH` 具有一个或多个逗号分隔子句的子句。每个子条款都提供一个子查询,用于生成结果集,并将名称与子查询相关联。下面的示例定义名为的 CTE `cte1` 和 `cte2` 中 `WITH` 子句,并且是指在它们的顶层 `SELECT` 下面的 `WITH` 子句: + +```sql +WITH + cte1 AS (SELECT a,b FROM table1), + cte2 AS (SELECT c,d FROM table2) +SELECT b,d FROM cte1 JOIN cte2 +WHERE cte1.a = cte2.c; +``` + +在包含该 `WITH`子句 的语句中,可以引用每个 CTE 名称以访问相应的 CTE 结果集。 + +CTE 名称可以在其他 CTE 中引用,从而可以基于其他 CTE 定义 CTE。 + +目前不支持递归的 CTE。 + +## 示例 + +1. 查询年龄分别是 18,20,25 的学生姓名 + + ```sql + select Name from student where age in (18,20,25); + ``` + +2. ALL EXCEPT 示例 + ```sql + -- 查询除了学生年龄的所有信息 + select * except(age) from student; + ``` + +3. GROUP BY 示例 + + ```sql + --查询 tb_book 表,按照 type 分组,求每类图书的平均价格, + select type,avg(price) from tb_book group by type; + ``` + +4. DISTINCT 使用 + + ``` + --查询 tb_book 表,除去重复的 type 数据 + select distinct type from tb_book; + ``` + +5. ORDER BY 示例 + + 对查询结果进行升序(默认)或降序(DESC)排列。升序 NULL 在最前面,降序 NULL 在最后面 + + ```sql + --查询 tb_book 表中的所有记录,按照 id 降序排列,显示三条记录 + select * from tb_book order by id desc limit 3; + ``` + +6. LIKE 模糊查询 + + 可实现模糊查询,它有两种通配符:`%`和`_`,`%`可以匹配一个或多个字符,`_`可以匹配一个字符 + + ``` + --查找所有第二个字符是 h 的图书 + select * from tb_book where name like('_h%'); + ``` + +7. LIMIT 限定结果行数 + + ```sql + --1.降序显示 3 条记录 + select * from tb_book order by price desc limit 3; + + --2.从 id=1 显示 4 条记录 + select * from tb_book where id limit 1,4; + ``` + +8. CONCAT 联合多列 + + ```sql + --把 name 和 price 合并成一个新的字符串输出 + select id,concat(name,":",price) as info,type from tb_book; + ``` + +9. 使用函数和表达式 + + ```sql + --计算 tb_book 表中各类图书的总价格 + select sum(price) as total,type from tb_book group by type; + --price 打八折 + select *,(price * 0.8) as "八折" from tb_book; + ``` + +10. UNION 示例 + + ```sql + SELECT a FROM t1 WHERE a = 10 AND B = 1 ORDER by a LIMIT 10 + UNION + SELECT a FROM t2 WHERE a = 11 AND B = 2 ORDER by a LIMIT 10; + ``` + +11. WITH 子句示例 + + ```sql + WITH cte AS + ( + SELECT 1 AS col1, 2 AS col2 + UNION ALL + SELECT 3, 4 + ) + SELECT col1, col2 FROM cte; + ``` + +12. JOIN 示例 + + ```sql + SELECT * FROM t1 LEFT JOIN (t2, t3, t4) + ON (t2.a = t1.a AND t3.b = t1.b AND t4.c = t1.c) + ``` + + 等同于 + + ```sql + SELECT * FROM t1 LEFT JOIN (t2 CROSS JOIN t3 CROSS JOIN t4) + ON (t2.a = t1.a AND t3.b = t1.b AND t4.c = t1.c) + ``` + +13. INNER JOIN + + ```sql + SELECT t1.name, t2.salary + FROM employee AS t1 INNER JOIN info AS t2 ON t1.name = t2.name; + + SELECT t1.name, t2.salary + FROM employee t1 INNER JOIN info t2 ON t1.name = t2.name; + ``` + +14. LEFT JOIN + + ```sql + SELECT left_tbl.* + FROM left_tbl LEFT JOIN right_tbl ON left_tbl.id = right_tbl.id + WHERE right_tbl.id IS NULL; + ``` + +15. RIGHT JOIN + + ```sql + mysql> SELECT * FROM t1 RIGHT JOIN t2 ON (t1.a = t2.a); + +------+------+------+------+ + | a | b | a | c | + +------+------+------+------+ + | 2 | y | 2 | z | + | NULL | NULL | 3 | w | + +------+------+------+------+ + ``` + +16. TABLESAMPLE + + ```sql + --在t1中伪随机的抽样1000行。注意实际是根据表的统计信息选择若干Tablet,被选择的Tablet总行数可能大于1000,所以若想明确返回1000行需要加上Limit。 + SELECT * FROM t1 TABLET(10001) TABLESAMPLE(1000 ROWS) REPEATABLE 2 limit 1000; + ``` + +## 关键词 + + SELECT + +### 最佳实践 + +1. 关于 SELECT 子句的一些附加知识 + + - 可以使用 AS alias_name 为 select_expr 指定别名。别名用作表达式的列名,可用于 GROUP BY,ORDER BY 或 HAVING 子句。AS 关键字是在指定列的别名时养成使用 AS 是一种好习惯。 + + - FROM 后的 table_references 指示参与查询的一个或者多个表。如果列出了多个表,就会执行 JOIN 操作。而对于每一个指定表,都可以为其定义别名 + + - SELECT 后被选择的列,可以在 ORDER IN 和 GROUP BY 中,通过列名、列别名或者代表列位置的整数(从 1 开始)来引用 + + ```sql + SELECT college, region, seed FROM tournament + ORDER BY region, seed; + + SELECT college, region AS r, seed AS s FROM tournament + ORDER BY r, s; + + SELECT college, region, seed FROM tournament + ORDER BY 2, 3; + ``` + + - 如果 ORDER BY 出现在子查询中,并且也应用于外部查询,则最外层的 ORDER BY 优先。 + + - 如果使用了 GROUP BY,被分组的列会自动按升序排列(就好像有一个 ORDER BY 语句后面跟了同样的列)。如果要避免 GROUP BY 因为自动排序生成的开销,添加 ORDER BY NULL 可以解决: + + ```sql + SELECT a, COUNT(b) FROM test_table GROUP BY a ORDER BY NULL; + ``` + + + + - 当使用 ORDER BY 或 GROUP BY 对 SELECT 中的列进行排序时,服务器仅使用 max_sort_length 系统变量指示的初始字节数对值进行排序。 + + - Having 子句一般应用在最后,恰好在结果集被返回给 MySQL 客户端前,且没有进行优化。(而 LIMIT 应用在 HAVING 后) + + SQL 标准要求:HAVING 必须引用在 GROUP BY 列表中或者聚合函数使用的列。然而,MySQL 对此进行了扩展,它允许 HAVING 引用 Select 子句列表中的列,还有外部子查询的列。 + + 如果 HAVING 引用的列具有歧义,会有警告产生。下面的语句中,col2 具有歧义: + + ```sql + SELECT COUNT(col1) AS col2 FROM t GROUP BY col2 HAVING col2 = 2; + ``` + + - 切记不要在该使用 WHERE 的地方使用 HAVING。HAVING 是和 GROUP BY 搭配的。 + + - HAVING 子句可以引用聚合函数,而 WHERE 不能。 + + ```sql + SELECT user, MAX(salary) FROM users + GROUP BY user HAVING MAX(salary) > 10; + ``` + + - LIMIT 子句可用于约束 SELECT 语句返回的行数。LIMIT 可以有一个或者两个参数,都必须为非负整数。 + + ```sql + /*取回结果集中的 6~15 行*/ + SELECT * FROM tbl LIMIT 5,10; + /*那如果要取回一个设定某个偏移量之后的所有行,可以为第二参数设定一个非常大的常量。以下查询取回从第 96 行起的所有数据*/ + SELECT * FROM tbl LIMIT 95,18446744073709551615; + /*若 LIMIT 只有一个参数,则参数指定应该取回的行数,偏移量默认为 0,即从第一行起*/ + ``` + + - SELECT...INTO 可以让查询结果写入到文件中 + +2. SELECT 关键字的修饰符 + + - 去重 + + ALL 和 DISTINCT 修饰符指定是否对结果集中的行(应该不是某个列)去重。 + + ALL 是默认修饰符,即满足要求的所有行都要被取回来。 + + DISTINCT 删除重复的行。 + +3. 子查询的主要优势 + + - 子查询允许结构化的查询,这样就可以把一个语句的每个部分隔离开。 + - 有些操作需要复杂的联合和关联。子查询提供了其它的方法来执行这些操作 + +4. 加速查询 + + - 尽可能利用 Doris 的分区分桶作为数据过滤条件,减少数据扫描范围 + - 充分利用 Doris 的前缀索引字段作为数据过滤条件加速查询速度 + +4. UNION + + - 只使用 union 关键词和使用 union disitnct 的效果是相同的。由于去重工作是比较耗费内存的,因此使用 union all 操作查询速度会快些,耗费内存会少些。如果用户想对返回结果集进行 order by 和 limit 操作,需要将 union 操作放在子查询中,然后 select from subquery,最后把 subquery 和 order by 放在子查询外面。 + + ```sql + select * from (select age from student_01 union all select age from student_02) as t1 + order by age limit 4; + + +-------------+ + | age | + +-------------+ + | 18 | + | 19 | + | 20 | + | 21 | + +-------------+ + 4 rows in set (0.01 sec) + ``` + +4. JOIN + + - 在 inner join 条件里除了支持等值 join,还支持不等值 join,为了性能考虑,推荐使用等值 join。 + - 其它 join 只支持等值 join + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/database/ALTER-DATABASE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/database/ALTER-DATABASE.md new file mode 100644 index 0000000000000..2f9457ee2966d --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/database/ALTER-DATABASE.md @@ -0,0 +1,106 @@ +--- +{ + "title": "ALTER DATABASE", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于设置指定数据库的属性。(仅管理员使用) + +1) 设置数据库数据量配额,单位为 B/K/KB/M/MB/G/GB/T/TB/P/PB + +```sql +ALTER DATABASE db_name SET DATA QUOTA quota; +``` + +2) 重命名数据库 + +```sql +ALTER DATABASE db_name RENAME new_db_name; +``` + +3) 设置数据库的副本数量配额 + +```sql +ALTER DATABASE db_name SET REPLICA QUOTA quota; +``` + +说明: + 重命名数据库后,如需要,请使用 REVOKE 和 GRANT 命令修改相应的用户权限。 + 数据库的默认数据量配额为 1024GB,默认副本数量配额为 1073741824。 + +4) 对已有 database 的 property 进行修改操作 + +```sql +ALTER DATABASE db_name SET PROPERTIES ("key"="value", ...); +``` + +## 示例 + +1. 设置指定数据库数据量配额 + +```sql +ALTER DATABASE example_db SET DATA QUOTA 10995116277760; +上述单位为字节,等价于 +ALTER DATABASE example_db SET DATA QUOTA 10T; + +ALTER DATABASE example_db SET DATA QUOTA 100G; + +ALTER DATABASE example_db SET DATA QUOTA 200M; +``` + +2. 将数据库 example_db 重命名为 example_db2 + +```sql +ALTER DATABASE example_db RENAME example_db2; +``` + +3. 设定指定数据库副本数量配额 + +```sql +ALTER DATABASE example_db SET REPLICA QUOTA 102400; +``` + +4. 修改 db 下 table 的默认副本分布策略(该操作仅对新建的 table 生效,不会修改 db 下已存在的 table) + +```sql +ALTER DATABASE example_db SET PROPERTIES("replication_allocation" = "tag.location.default:2"); +``` + +5. 取消 db 下 table 的默认副本分布策略(该操作仅对新建的 table 生效,不会修改 db 下已存在的 table) + +```sql +ALTER DATABASE example_db SET PROPERTIES("replication_allocation" = ""); +``` + +## 关键词 + +```text +ALTER,DATABASE,RENAME +``` + +### 最佳实践 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/database/CREATE-DATABASE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/database/CREATE-DATABASE.md new file mode 100644 index 0000000000000..6199fdf7d428a --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/database/CREATE-DATABASE.md @@ -0,0 +1,81 @@ +--- +{ + "title": "CREATE DATABASE", + "language": "zh-CN" +} +--- + + + + + + + + +## 描述 + +该语句用于新建数据库(database) + +语法: + +```sql +CREATE DATABASE [IF NOT EXISTS] db_name + [PROPERTIES ("key"="value", ...)]; +``` + +`PROPERTIES` 该数据库的附加信息,可以缺省。 + +- 如果要为 db 下的 table 指定默认的副本分布策略,需要指定`replication_allocation`(table 的`replication_allocation`属性优先级会高于 db) + + ```sql + PROPERTIES ( + "replication_allocation" = "tag.location.default:3" + ) + ``` + +## 示例 + +1. 新建数据库 db_test + + ```sql + CREATE DATABASE db_test; + ``` + +2. 新建数据库并设置默认的副本分布: + + ```sql + CREATE DATABASE `db_test` + PROPERTIES ( + "replication_allocation" = "tag.location.group_1:3" + ); + ``` + +:::caution +若建表语句属性 key 带 replication_allocation 或 replication_num,则 db 的默认的副本分布策略不会生效 +::: + +## 关键词 + +```text +CREATE, DATABASE +``` + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/database/DROP-DATABASE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/database/DROP-DATABASE.md new file mode 100644 index 0000000000000..73026e3f259a3 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/database/DROP-DATABASE.md @@ -0,0 +1,58 @@ +--- +{ + "title": "DROP DATABASE", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于删除数据库(database) +语法: + +```sql +DROP DATABASE [IF EXISTS] db_name [FORCE]; +``` + +说明: + +- 执行 DROP DATABASE 一段时间内,可以通过 RECOVER 语句恢复被删除的数据库。详见 [RECOVER](../../Database-Administration-Statements/RECOVER.md) 语句 +- 如果执行 DROP DATABASE FORCE,则系统不会检查该数据库是否存在未完成的事务,数据库将直接被删除并且不能被恢复,一般不建议执行此操作 + +## 示例 + +1. 删除数据库 db_test + + ```sql + DROP DATABASE db_test; + ``` + + +## 关键词 + + DROP, DATABASE + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/database/SHOW-CREATE-DATABASE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/database/SHOW-CREATE-DATABASE.md new file mode 100644 index 0000000000000..959288a7d6ada --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/database/SHOW-CREATE-DATABASE.md @@ -0,0 +1,74 @@ +--- +{ + "title": "SHOW CREATE DATABASE", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句查看 doris 内置数据库和 hms catalog 数据库的创建信息。 + +语法: + +```sql +SHOW CREATE DATABASE db_name; +``` + +说明: + +- `db_name`: 为 内置数据库或 hms catalog 数据库的名称。 +- 如果查看 hms catalog 内数据库,返回信息和 hive 中同名命令结果一样。 + +## 示例 + +1. 查看 doris 中 test 数据库的创建情况 + + ```sql + mysql> SHOW CREATE DATABASE test; + +----------+------------------------+ + | Database | Create Database | + +----------+------------------------+ + | test | CREATE DATABASE `test` | + +----------+------------------------+ + 1 row in set (0.00 sec) + ``` +2. 查看 hive catalog 中数据库 hdfs_text 的创建信息 + + ```sql + mysql> show create database hdfs_text; + +-----------+------------------------------------------------------------------------------------+ + | Database | Create Database | + +-----------+------------------------------------------------------------------------------------+ + | hdfs_text | CREATE DATABASE `hdfs_text` LOCATION 'hdfs://HDFS1009138/hive/warehouse/hdfs_text' | + +-----------+------------------------------------------------------------------------------------+ + 1 row in set (0.01 sec) + ``` +## 关键词 + + SHOW, CREATE, DATABASE + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/database/SHOW-DATABASE-ID.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/database/SHOW-DATABASE-ID.md new file mode 100644 index 0000000000000..9657f3ea0ec7c --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/database/SHOW-DATABASE-ID.md @@ -0,0 +1,50 @@ +--- +{ + "title": "SHOW DATABASE ID", + "language": "zh-CN" +} +--- + + + +### 描述 + +该语句用于根据 database id 查找对应的 database name(仅管理员使用) + +语法: + +```sql +SHOW DATABASE [database_id] +``` + +### 示例 + +1. 根据 database id 查找对应的 database name + + ```sql + SHOW DATABASE 1001; + ``` + +### 关键词 + +SHOW, DATABASE, ID + + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/database/SHOW-DATABASES.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/database/SHOW-DATABASES.md new file mode 100644 index 0000000000000..cb1e77f5a531c --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/database/SHOW-DATABASES.md @@ -0,0 +1,97 @@ +--- +{ + "title": "SHOW DATABASES", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于展示当前可见的 db + +语法: + +```sql +SHOW DATABASES [FROM catalog] [filter expr]; +``` + +说明: +1. `SHOW DATABASES` 会展示当前所有的数据库名称。 +2. `SHOW DATABASES FROM catalog` 会展示`catalog`中所有的数据库名称。 +3. `SHOW DATABASES filter_expr` 会展示当前所有经过过滤后的数据库名称。 +4. `SHOW DATABASES FROM catalog filter_expr` 这种语法不支持。 + +## 示例 +1. 展示当前所有的数据库名称。 + + ```sql + SHOW DATABASES; + ``` + + ``` + +--------------------+ + | Database | + +--------------------+ + | test | + | information_schema | + +--------------------+ + ``` + +2. 会展示`hms_catalog`中所有的数据库名称。 + + ```sql + SHOW DATABASES from hms_catalog; + ``` + + ``` + +---------------+ + | Database | + +---------------+ + | default | + | tpch | + +---------------+ + ``` + +3. 展示当前所有经过表示式`like 'infor%'`过滤后的数据库名称。 + + ```sql + SHOW DATABASES like 'infor%'; + ``` + + ``` + +--------------------+ + | Database | + +--------------------+ + | information_schema | + +--------------------+ + ``` + +## 关键词 + + SHOW, DATABASES + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/function/CREATE-FUNCTION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/function/CREATE-FUNCTION.md new file mode 100644 index 0000000000000..ca83f4aa72401 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/function/CREATE-FUNCTION.md @@ -0,0 +1,130 @@ +--- +{ + "title": "CREATE FUNCTION", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +此语句创建一个自定义函数。执行此命令需要用户拥有 `ADMIN` 权限。 + +如果 `function_name` 中包含了数据库名字,那么这个自定义函数会创建在对应的数据库中,否则这个函数将会创建在当前会话所在的数据库。新函数的名字与参数不能够与当前命名空间中已存在的函数相同,否则会创建失败。但是只有名字相同,参数不同是能够创建成功的。 + +语法: + +```sql +CREATE [GLOBAL] [AGGREGATE] [ALIAS] FUNCTION function_name + (arg_type [, ...]) + [RETURNS ret_type] + [INTERMEDIATE inter_type] + [WITH PARAMETER(param [,...]) AS origin_function] + [PROPERTIES ("key" = "value" [, ...]) ] +``` + +参数说明: + +- `GLOBAL`: 如果有此项,表示的是创建的函数是全局范围内生效。 + +- `AGGREGATE`: 如果有此项,表示的是创建的函数是一个聚合函数。 + + +- `ALIAS`:如果有此项,表示的是创建的函数是一个别名函数。 + + + 如果没有上述两项,表示创建的函数是一个标量函数 + +- `function_name`: 要创建函数的名字,可以包含数据库的名字。比如:`db1.my_func`。 + + +- `arg_type`: 函数的参数类型,与建表时定义的类型一致。变长参数时可以使用`, ...`来表示,如果是变长类型,那么变长部分参数的类型与最后一个非变长参数类型一致。 + + **注意**:`ALIAS FUNCTION` 不支持变长参数,且至少有一个参数。 + +- `ret_type`: 对创建新的函数来说,是必填项。如果是给已有函数取别名则可不用填写该参数。 + + +- `inter_type`: 用于表示聚合函数中间阶段的数据类型。 + + +- `param`:用于表示别名函数的参数,至少包含一个。 + + +- `origin_function`:用于表示别名函数对应的原始函数。 + +- `properties`: 用于设定函数相关属性,能够设置的属性包括: + + - `file`: 表示的包含用户 UDF 的 jar 包,当在多机环境时,也可以使用 http 的方式下载 jar 包。这个参数是必须设定的。 + + - `symbol`: 表示的是包含 UDF 类的类名。这个参数是必须设定的 + + - `type`: 表示的 UDF 调用类型,默认为 Native,使用 Java UDF 时传 JAVA_UDF。 + + - `always_nullable`:表示的 UDF 返回结果中是否有可能出现 NULL 值,是可选参数,默认值为 true。 + + +## 示例 + +1. 创建一个自定义 UDF 函数 + + ```sql + CREATE FUNCTION java_udf_add_one(int) RETURNS int PROPERTIES ( + "file"="file:///path/to/java-udf-demo-jar-with-dependencies.jar", + "symbol"="org.apache.doris.udf.AddOne", + "always_nullable"="true", + "type"="JAVA_UDF" + ); + ``` + + +2. 创建一个自定义 UDAF 函数 + + ```sql + CREATE AGGREGATE FUNCTION simple_sum(INT) RETURNS INT PROPERTIES ( + "file"="file:///pathTo/java-udaf.jar", + "symbol"="org.apache.doris.udf.demo.SimpleDemo", + "always_nullable"="true", + "type"="JAVA_UDF" + ); + ``` + +3. 创建一个自定义别名函数 + + ```sql + CREATE ALIAS FUNCTION id_masking(INT) WITH PARAMETER(id) AS CONCAT(LEFT(id, 3), '****', RIGHT(id, 4)); + ``` + +4. 创建一个全局自定义别名函数 + + ```sql + CREATE GLOBAL ALIAS FUNCTION id_masking(INT) WITH PARAMETER(id) AS CONCAT(LEFT(id, 3), '****', RIGHT(id, 4)); + ``` + +## 关键词 + + CREATE, FUNCTION + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/function/DESC-FUNCTION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/function/DESC-FUNCTION.md new file mode 100644 index 0000000000000..0db9585f58806 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/function/DESC-FUNCTION.md @@ -0,0 +1,62 @@ +--- +{ + "title": "DESC FUNCTION", + "language": "zh-CN" +} +--- + + + + +## 描述 + +利用 `desc function table_valued_function` 获取对应表值函数的 Schema 信息。 + +## 语法 + +```sql +DESC FUNCTION +``` + +## 必选参数 + +1. ``: 表值函数的名字,如 CATALOGS。支持的表值函数列表,请参阅“[表值函数](../../../sql-manual/sql-functions/table-valued-functions/s3/)”章节 + +## 示例 + +查询表值函数 CATALOGS 的信息: + +```sql +DESC FUNCTION catalogs(); +``` + +结果如下: + +```sql ++-------------+--------+------+-------+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++-------------+--------+------+-------+---------+-------+ +| CatalogId | bigint | No | false | NULL | NONE | +| CatalogName | text | No | false | NULL | NONE | +| CatalogType | text | No | false | NULL | NONE | +| Property | text | No | false | NULL | NONE | +| Value | text | No | false | NULL | NONE | ++-------------+--------+------+-------+---------+-------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/function/DROP-FUNCTION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/function/DROP-FUNCTION.md new file mode 100644 index 0000000000000..eea27440c07aa --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/function/DROP-FUNCTION.md @@ -0,0 +1,64 @@ +--- +{ + "title": "DROP FUNCTION", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +删除一个自定义函数。函数的名字、参数类型完全一致才能够被删除 + +语法: + +```sql +DROP [GLOBAL] FUNCTION function_name + (arg_type [, ...]) +``` + +参数说明: + +- `function_name`: 要删除函数的名字 +- `arg_type`: 要删除函数的参数列表 + +## 示例 + +1. 删除掉一个函数 + + ```sql + DROP FUNCTION my_add(INT, INT) + ``` +2. 删除掉一个全局函数 + + ```sql + DROP GLOBAL FUNCTION my_add(INT, INT) + ``` + +## 关键词 + + DROP, FUNCTION + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/function/SHOW-CREATE-FUNCTION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/function/SHOW-CREATE-FUNCTION.md new file mode 100644 index 0000000000000..102e76f37f59a --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/function/SHOW-CREATE-FUNCTION.md @@ -0,0 +1,65 @@ +--- +{ + "title": "SHOW CREATE FUNCTION", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句用于展示用户自定义函数的创建语句 + +语法: + +```sql +SHOW CREATE [GLOBAL] FUNCTION function_name(arg_type [, ...]) [FROM db_name]]; +``` + +说明: + 1. `global`: 要展示的是全局函数 + 2. `function_name`: 要展示的函数名称 + 3. `arg_type`: 要展示的函数的参数列表 + 4. 如果不指定 db_name,使用当前默认 db + +**注意:"global"关键字在 v2.0 版本及以后才可用** + +## 示例 + +1. 展示默认 db 下指定函数的创建语句 + + ```sql + SHOW CREATE FUNCTION my_add(INT, INT) + ``` + +2. 展示指定的全局函数的创建语句 + + ```sql + SHOW CREATE GLOBAL FUNCTION my_add(INT, INT) + ``` + +## 关键词 + + SHOW, CREATE, FUNCTION + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/function/SHOW-FUNCTIONS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/function/SHOW-FUNCTIONS.md new file mode 100644 index 0000000000000..64da9fa16062a --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/function/SHOW-FUNCTIONS.md @@ -0,0 +1,128 @@ +--- +{ + "title": "SHOW FUNCTIONS", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +查看数据库下所有的自定义 (系统提供) 的函数。如果用户指定了数据库,那么查看对应数据库的,否则直接查询当前会话所在数据库 + +需要对这个数据库拥有 `SHOW` 权限 + +语法 + +```sql +SHOW [FULL] [BUILTIN] FUNCTIONS [IN|FROM db] [LIKE 'function_pattern'] +``` + +Parameters + +>`full`:表示显示函数的详细信息 +>`builtin`:表示显示系统提供的函数 +>`db`: 要查询的数据库名字 +>`function_pattern`: 用来过滤函数名称的参数 + +语法 + +```sql +SHOW GLOBAL [FULL] FUNCTIONS [LIKE 'function_pattern'] +``` + +Parameters + +>`global`:表示要展示的是全局函数 +>`full`:表示显示函数的详细信息 +>`function_pattern`: 用来过滤函数名称的参数 + +**注意:"global"关键字在 v2.0 版本及以后才可用** + +## 示例 + +```sql +mysql> show full functions in testDb\G +*************************** 1. row *************************** + Signature: my_add(INT,INT) + Return Type: INT + Function Type: Scalar +Intermediate Type: NULL + Properties: {"symbol":"_ZN9doris_udf6AddUdfEPNS_15FunctionContextERKNS_6IntValES4_","object_file":"http://host:port/libudfsample.so","md5":"cfe7a362d10f3aaf6c49974ee0f1f878"} +*************************** 2. row *************************** + Signature: my_count(BIGINT) + Return Type: BIGINT + Function Type: Aggregate +Intermediate Type: NULL + Properties: {"object_file":"http://host:port/libudasample.so","finalize_fn":"_ZN9doris_udf13CountFinalizeEPNS_15FunctionContextERKNS_9BigIntValE","init_fn":"_ZN9doris_udf9CountInitEPNS_15FunctionContextEPNS_9BigIntValE","merge_fn":"_ZN9doris_udf10CountMergeEPNS_15FunctionContextERKNS_9BigIntValEPS2_","md5":"37d185f80f95569e2676da3d5b5b9d2f","update_fn":"_ZN9doris_udf11CountUpdateEPNS_15FunctionContextERKNS_6IntValEPNS_9BigIntValE"} +*************************** 3. row *************************** + Signature: id_masking(BIGINT) + Return Type: VARCHAR + Function Type: Alias +Intermediate Type: NULL + Properties: {"parameter":"id","origin_function":"concat(left(`id`, 3), `****`, right(`id`, 4))"} + +3 rows in set (0.00 sec) +mysql> show builtin functions in testDb like 'year%'; ++---------------+ +| Function Name | ++---------------+ +| year | +| years_add | +| years_diff | +| years_sub | ++---------------+ +2 rows in set (0.00 sec) + +mysql> show global full functions\G; +*************************** 1. row *************************** + Signature: decimal(ALL, INT, INT) + Return Type: VARCHAR + Function Type: Alias +Intermediate Type: NULL + Properties: {"parameter":"col, precision, scale","origin_function":"CAST(`col` AS decimal(`precision`, `scale`))"} +*************************** 2. row *************************** + Signature: id_masking(BIGINT) + Return Type: VARCHAR + Function Type: Alias +Intermediate Type: NULL + Properties: {"parameter":"id","origin_function":"concat(left(`id`, 3), `****`, right(`id`, 4))"} +2 rows in set (0.00 sec) + +mysql> show global functions ; ++---------------+ +| Function Name | ++---------------+ +| decimal | +| id_masking | ++---------------+ +2 rows in set (0.00 sec) + +``` + +## 关键词 + + SHOW, FUNCTIONS + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/job/CANCEL-TASK.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/job/CANCEL-TASK.md new file mode 100644 index 0000000000000..133af231e3c1b --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/job/CANCEL-TASK.md @@ -0,0 +1,57 @@ +--- +{ +"title": "CANCEL TASK", +"language": "zh-CN" +} + +--- + + + +## 描述 +取消通过 [CREATE JOB](../../../sql-manual/sql-statements/job/CREATE-JOB) 语句创建生成的正在运行中任务 + +- 任务必须是通过 CREATE JOB 语句创建生成的任务 +- 必须是正在运行中的任务 +- 该函数自 2.1.0 版本支持。 + +## 语法 + +```sql +CANCEL TASK WHERE jobName = '' AND taskId = ''; +``` + +## 必选参数 + +1. ``:作业名称,字符串类型。 + +2. ``: 任务 ID,整型类型。可通过 tasks 表值函数查询。如:SELECT * FROM tasks('type'='insert')。详细信息请参阅“[task 表值函数](../../../sql-manual/sql-functions/table-valued-functions/tasks)”。 + +## 权限控制 + +执行此 SQL 命令的用户必须至少具有 ADMIN_PRIV 权限。 + +## 示例 + +取消一个 jobName 是 example,taskID 是 378912 的后台任务。 + +```sql +CANCEL TASK WHERE jobName='example' AND taskId=378912 +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/job/CREATE-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/job/CREATE-JOB.md new file mode 100644 index 0000000000000..bc07541fdb1a2 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/job/CREATE-JOB.md @@ -0,0 +1,172 @@ +--- +{ +"title": "CREATE JOB", +"language": "zh-CN" +} + +--- + + + + + + +## 描述 + +Doris Job 是根据既定计划运行的任务,用于在特定时间或指定时间间隔触发预定义的操作,从而帮助我们自动执行一些任务。从功能上来讲,它类似于操作系统上的 +定时任务(如:Linux 中的 cron、Windows 中的计划任务)。 + +Job 有两种类型:`ONE_TIME` 和 `RECURRING`。其中 `ONE_TIME` 类型的 Job 会在指定的时间点触发,它主要用于一次性任务,而 `RECURRING` 类型的 Job 会在指定的时间间隔内循环触发,此方式主要用于周期性执行的任务。 +`RECURRING` 类型的 Job 可指定开始时间,结束时间,即 `STARTS\ENDS`, 如果不指定开始时间,则默认首次执行时间为当前时间 + 一次调度周期。如果指定结束时间,则 task 执行完成如果达到结束时间(或超过,或下次执行周期会超过结束时间)则更新为 FINISHED 状态,此时不会再产生 Task。 + +JOB 共 4 种状态(`RUNNING`,`STOPPED`,`PAUSED`,`FINISHED`,),初始状态为 RUNNING,RUNNING 状态的 JOB 会根据既定的调度周期去生成 TASK 执行,Job 执行完成达到结束时间则状态变更为 `FINISHED`. + +RUNNING 状态的 JOB 可以被 pause,即暂停,此时不会再生成 Task。 + +PAUSE 状态的 JOB 可以通过 RESUME 操作来恢复运行,更改为 RUNNING 状态。 + +STOP 状态的 JOB 由用户主动触发,此时会 Cancel 正在运行中的作业,然后删除 JOB。 + +Finished 状态的 JOB 会保留在系统中 24 H,24H 后会被删除。 + +JOB 只描述作业信息,执行会生成 TASK,TASK 状态分为 PENDING,RUNNING,SUCCEESS,FAILED,CANCELED +PENDING 表示到达触发时间了但是等待资源 RUN,分配到资源后状态变更为 RUNNING,执行成功/失败即变更为 SUCCESS/FAILED. +CANCELED 即取消状态,TASK 持久化最终状态,即 SUCCESS/FAILED,其他状态运行中可以查到,但是如果重启则不可见。TASK 只保留最新的 100 条记录。 + +#### 权限 + +- 目前仅支持 ***ADMIN*** 权限执行此操作。 + +#### 相关文档 + + +- [暂停-JOB](../job/PAUSE-JOB.md) +- [恢复-JOB](../job/RESUME-JOB.md) +- [删除-JOB](../job/DROP-JOB.md) +- [查询-JOB](../../../sql-manual/sql-functions/table-valued-functions/jobs.md) +- [查询-TASKS](../../sql-functions/table-valued-functions/jobs.md) + +### 语法 + +```sql +CREATE + JOB + job_name + ON SCHEDULE schedule + [COMMENT 'string'] + DO sql_body; + +schedule: { + AT timestamp + | EVERY interval + [STARTS timestamp ] + [ENDS timestamp ] +} + +interval: + quantity { WEEK | DAY | HOUR | MINUTE } +``` + +一条有效的 Job 语句必须包含以下内容 + +- 关键字 CREATE JOB 加上作业名称,它在一个 db 中标识唯一事件。JOB 名称必须是全局唯一的,如果已经存在同名的 JOB,则会报错。我们保留了 ***inner_*** 前缀在系统内部使用,因此用户不能创建以 ***inner_*** 开头的名称。 +- ON SCHEDULE 子句,它指定了 Job 作业的类型和触发时间以及频率。 +- DO 子句,它指定了 Job 作业触发时需要执行的操作,即一条 SQL 语句。 + +这是一个最简单的例子: + +```sql +CREATE JOB my_job ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO db1.tbl1 SELECT * FROM db2.tbl2; +``` + +该语句表示创建一个名为 my_job 的作业,每分钟执行一次,执行的操作是将 db2.tbl2 中的数据导入到 db1.tbl1 中。 + +SCHEDULE 语句用于定义作业的执行时间,频率以及持续时间,它可以指定一次性作业或者周期性作业。 +- AT timestamp + +格式:'YYYY-MM-DD HH:MM:SS', 用于一次性事件,它指定事件仅在 给定的日期和时间执行一次 timestamp,当执行完成后,JOB 状态会变更为 FINISHED。 + +- EVERY + + 表示定期重复操作,它指定了作业的执行频率,关键字后面要指定一个时间间隔,该时间间隔可以是天、小时、分钟、秒、周。 + + - interval + + 用于指定作业执行频率,它可以是天、小时、分钟、周。例如:` 1 DAY` 表示每天执行一次,` 1 HOUR` 表示每小时执行一次,` 1 MINUTE` 表示每分钟执行一次,` 1 WEEK` 表示每周执行一次。 + + - STARTS timestamp(可选字段) + + 格式:'YYYY-MM-DD HH:MM:SS',用于指定作业的开始时间,如果没有指定,则从当前时间的下一个时间点开始执行。开始时间必须大于当前时间。 + + - ENDS timestamp(可选字段) + + 格式:'YYYY-MM-DD HH:MM:SS', 用于指定作业的结束时间,如果没有指定,则表示永久执行。该日期必须大于当前时间,如果指定了开始时间,即 `STARTS`,则结束时间必须大于开始时间。 + +- DO + + 用于指定作业触发时需要执行的操作,目前仅支持 ***INSERT 内表*** 操作。后续我们会支持更多的操作。 + +## 示例 + +创建一个一次性的 Job,它会在 2020-01-01 00:00:00 时执行一次,执行的操作是将 db2.tbl2 中的数据导入到 db1.tbl1 中。 + +```sql + +CREATE JOB my_job ON SCHEDULE AT '2020-01-01 00:00:00' DO INSERT INTO db1.tbl1 SELECT * FROM db2.tbl2; + +``` + +创建一个周期性的 Job,它会在 2020-01-01 00:00:00 时开始执行,每天执行一次,执行的操作是将 db2.tbl2 中的数据导入到 db1.tbl1 中。 + +```sql +CREATE JOB my_job ON SCHEDULE EVERY 1 DAY STARTS '2020-01-01 00:00:00' DO INSERT INTO db1.tbl1 SELECT * FROM db2.tbl2 WHERE create_time >= days_add(now(),-1); +``` + +创建一个周期性的 Job,它会在 2020-01-01 00:00:00 时开始执行,每天执行一次,执行的操作是将 db2.tbl2 中的数据导入到 db1.tbl1 中,该 Job 在 2020-01-01 00:10:00 时结束。 + +```sql +CREATE JOB my_job ON SCHEDULE EVERY 1 DAY STARTS '2020-01-01 00:00:00' ENDS '2020-01-01 00:10:00' DO INSERT INTO db1.tbl1 SELECT * FROM db2.tbl2 create_time >= days_add(now(),-1); +``` + +### INSERT JOB + +- 目前仅支持 ***INSERT 内表*** +- 当下一个计划任务时间到期,即需要调度任务执行时,如果当前 JOB 仍有历史任务正在执行,则会跳过当前任务调度。因此控制一个合理的执行间隔非常重要。 + +### CONFIG + +fe.conf + +- job_dispatch_timer_job_thread_num, 用于分发定时任务的线程数,默认值 2,如果含有大量周期执行任务,可以调大这个参数。 + +- job_dispatch_timer_job_queue_size, 任务堆积时用于存放定时任务的队列大小,默认值 1024. 如果有大量任务同一时间触发,可以调大这个参数。否则会导致队列满,提交任务会进入阻塞状态,从而导致后续任务无法提交。 + +- finished_job_cleanup_threshold_time_hour, 用于清理已完成的任务的时间阈值,单位为小时,默认值为 24 小时。 + +- job_insert_task_consumer_thread_num = 10;用于执行 Insert 任务的线程数,值应该大于 0,否则默认为 5. + +### 最佳实践 + +- 合理的进行 Job 的管理,避免大量的 Job 同时触发,导致任务堆积,从而影响系统的正常运行。 +- 任务的执行间隔应该设置在一个合理的范围,至少应该大于任务执行时间。 + +## 关键词 + + CREATE, JOB diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/job/DROP-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/job/DROP-JOB.md new file mode 100644 index 0000000000000..d32093f777692 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/job/DROP-JOB.md @@ -0,0 +1,51 @@ +--- +{ +"title": "DROP JOB", +"language": "zh-CN" +} +--- + + + + + + +## 描述 + +用户删除一个 JOB 作业。作业会被立即停止同时删除。 + +```sql +DROP JOB where jobName='jobname'; +``` + +## 示例 + +1. 停止名称为 example 的作业。 + + ```sql + DROP JOB where jobName='example'; + ``` + +## 关键词 + + STOP, JOB + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/job/PAUSE-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/job/PAUSE-JOB.md new file mode 100644 index 0000000000000..db331eb15ba7c --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/job/PAUSE-JOB.md @@ -0,0 +1,53 @@ +--- +{ +"title": "PAUSE JOB", +"language": "zh-CN" +} +--- + + + + + + +## 描述 + +用户暂停一个正在 RUNNING 状态的 JOB,正在运行的 TASK 会被中断,JOB 状态变更为 PAUSED。被停止的 JOB 可以通过 RESUME 操作恢复运行。 + +使用此命令需要 ADMIN 权限。 + +```sql +PAUSE JOB WHERE jobname= 'jobname'; +``` + +## 示例 + +1. 暂停名称为 example 的 JOB。 + +```sql + PAUSE JOB where jobname='example'; +``` + +## 关键词 + + PAUSE, JOB + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/job/RESUME-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/job/RESUME-JOB.md new file mode 100644 index 0000000000000..1b6ac6c4bc552 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/job/RESUME-JOB.md @@ -0,0 +1,52 @@ +--- +{ +"title": "RESUME JOB", +"language": "zh-CN" +} +--- + + + + + + + +## 描述 + +将处于 PAUSED 状态的 JOB 恢复为 RUNNING 状态。RUNNING 状态的 JOB 将会根据既定的调度周期去执行。 + +```sql +RESUME JOB where jobName = jobName; +``` + +## 示例 + +1. 恢复运行名称为 example 的 JOB。 + + ```sql + RESUME JOB where jobName= 'example'; + ``` + +## 关键词 + + RESUME, JOB + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/plugin/INSTALL-PLUGIN.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/plugin/INSTALL-PLUGIN.md new file mode 100644 index 0000000000000..823aa7b3c132c --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/plugin/INSTALL-PLUGIN.md @@ -0,0 +1,79 @@ +--- +{ + "title": "INSTALL PLUGIN", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于安装一个插件。 + +语法: + +```sql +INSTALL PLUGIN FROM [source] [PROPERTIES ("key"="value", ...)] +``` + +source 支持三种类型: + +1. 指向一个 zip 文件的绝对路径。 +2. 指向一个插件目录的绝对路径。 +3. 指向一个 http 或 https 协议的 zip 文件下载路径 + +## 示例 + +1. 安装一个本地 zip 文件插件: + + ```sql + INSTALL PLUGIN FROM "/home/users/doris/auditdemo.zip"; + ``` + +2. 安装一个本地目录中的插件: + + ```sql + INSTALL PLUGIN FROM "/home/users/doris/auditdemo/"; + ``` + +3. 下载并安装一个插件: + + ```sql + INSTALL PLUGIN FROM "http://mywebsite.com/plugin.zip"; + ``` + + 注意需要放置一个和 `.zip` 文件同名的 md5 文件,如 `http://mywebsite.com/plugin.zip.md5` 。其中内容为 .zip 文件的 MD5 值。 + +4. 下载并安装一个插件,同时设置了 zip 文件的 md5sum 的值: + + ```sql + INSTALL PLUGIN FROM "http://mywebsite.com/plugin.zip" PROPERTIES("md5sum" = "73877f6029216f4314d712086a146570"); + ``` + +## 关键词 + + INSTALL, PLUGIN + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/plugin/SHOW-PLUGINS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/plugin/SHOW-PLUGINS.md new file mode 100644 index 0000000000000..056172f715c79 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/plugin/SHOW-PLUGINS.md @@ -0,0 +1,56 @@ +--- +{ + "title": "SHOW PLUGINS", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于展示已安装的插件 + +语法: + +```SQL +SHOW PLUGINS +``` + +该命令会展示所有用户安装的和系统内置的插件 + +## 示例 + +1. 展示已安装的插件: + + ```SQL + SHOW PLUGINS; + ``` + +## 关键词 + + SHOW, PLUGINS + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/plugin/UNINSTALL-PLUGIN.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/plugin/UNINSTALL-PLUGIN.md new file mode 100644 index 0000000000000..9ddc26d552c56 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/plugin/UNINSTALL-PLUGIN.md @@ -0,0 +1,57 @@ +--- +{ + "title": "UNINSTALL PLUGIN", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于卸载一个插件。 + +语法: + +```sql +UNINSTALL PLUGIN plugin_name; +``` + + plugin_name 可以通过 `SHOW PLUGINS;` 命令查看。 + +只能卸载非 builtin 的插件。 + +## 示例 + +1. 卸载一个插件: + + ```sql + UNINSTALL PLUGIN auditdemo; + ``` + +## 关键词 + + UNINSTALL, PLUGIN + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/recycle/DROP-CATALOG-RECYCLE-BIN.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/recycle/DROP-CATALOG-RECYCLE-BIN.md new file mode 100644 index 0000000000000..60a06e0f0b79a --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/recycle/DROP-CATALOG-RECYCLE-BIN.md @@ -0,0 +1,87 @@ +--- +{ + "title": "DROP CATALOG RECYCLE BIN", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于立即删除回收站中的数据库、表 或者 分区。 + +可以通过 `SHOW CATALOG RECYCLE BIN` 来查询当前可删除的元信息。 + +语法: + +1. 根据 DbId 删除数据库 + + ```sql + DROP CATALOG RECYCLE BIN WHERE 'DbId' = db_id; + ``` + +2. 根据 TableId 删除表 + + ```sql + DROP CATALOG RECYCLE BIN WHERE 'TableId' = table_id; + ``` + +3. 根据 PartitionId 删除分区 + + ```sql + DROP CATALOG RECYCLE BIN WHERE 'PartitionId' = partition_id; + ``` + +说明: + +- 当删除数据库、表或者分区时,回收站会在 `catalog_trash_expire_second`秒后将其删除(在 `fe.conf` 中设置)。此语句将立即删除它们。 +- `'DbId'`、 `'TableId'` 和 `'PartitionId'` 大小写不敏感且不区分单引号和双引号。 +- 当删除不在回收站中的数据库时,也会删除回收站中具有相同 `DbId` 的所有表和分区。只有在没有删除任何内容(数据库、表或分区)的情况下,它才会报错。当删除不在回收站中的表时,处理方法类似。 + +## 示例 + +1. 删除 DbId 为 example_db_id 的数据库、表和分区 + + ```sql + DROP CATALOG RECYCLE BIN WHERE 'DbId' = example_db_id; + ``` + +2. 删除 TableId 为 example_tbl_id 的表和分区 + + ```sql + DROP CATALOG RECYCLE BIN WHERE 'TableId' = example_tbl_id; + ``` + +3. 删除 id 为 p1_id 的分区 + + ```sql + DROP CATALOG RECYCLE BIN WHERE 'PartitionId' = p1_id; + ``` + +## 关键词 + +DROP, CATALOG, RECYCLE, BIN + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/recycle/RECOVER.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/recycle/RECOVER.md new file mode 100644 index 0000000000000..000129481969d --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/recycle/RECOVER.md @@ -0,0 +1,161 @@ +--- +{ + "title": "RECOVER", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于恢复之前删除的 database、table 或者 partition。支持通过 name、id 来恢复指定的元信息,并且支持将恢复的元信息重命名。 + +可以通过 `SHOW CATALOG RECYCLE BIN` 来查询当前可恢复的元信息。 + +语法: + +1. 以 name 恢复 database + + ```sql + RECOVER DATABASE db_name; + ``` + +2. 以 name 恢复 table + + ```sql + RECOVER TABLE [db_name.]table_name; + ``` + +3. 以 name 恢复 partition + + ```sql + RECOVER PARTITION partition_name FROM [db_name.]table_name; + ``` + +4. 以 name 和 id 恢复 database + + ```sql + RECOVER DATABASE db_name db_id; + ``` + +5. 以 name 和 id 恢复 table + + ```sql + RECOVER TABLE [db_name.]table_name table_id; + ``` + +6. 以 name 和 id 恢复 partition + + ```sql + RECOVER PARTITION partition_name partition_id FROM [db_name.]table_name; + ``` + +7. 以 name 恢复 database 并设定新名字 + + ```sql + RECOVER DATABASE db_name AS new_db_name; + ``` + +8. 以 name 和 id 恢复 table 并设定新名字 + + ```sql + RECOVER TABLE [db_name.]table_name table_id AS new_table_name; + ``` + +9. 以 name 和 id 恢复 partition 并设定新名字 + + ```sql + RECOVER PARTITION partition_name partition_id AS new_partition_name FROM [db_name.]table_name; + ``` + +说明: + +- 该操作仅能恢复之前一段时间内删除的元信息。默认为 1 天。(可通过 fe.conf 中`catalog_trash_expire_second`参数配置) +- 如果恢复元信息时没有指定 id,则默认恢复最后一个删除的同名元数据。 +- 可以通过 `SHOW CATALOG RECYCLE BIN` 来查询当前可恢复的元信息。 + +## 示例 + +1. 恢复名为 example_db 的 database + +```sql +RECOVER DATABASE example_db; +``` + +2. 恢复名为 example_tbl 的 table + +```sql +RECOVER TABLE example_db.example_tbl; +``` + +3. 恢复表 example_tbl 中名为 p1 的 partition + +```sql +RECOVER PARTITION p1 FROM example_tbl; +``` + +4. 恢复 example_db_id 且名为 example_db 的 database + +```sql +RECOVER DATABASE example_db example_db_id; +``` + +5. 恢复 example_tbl_id 且名为 example_tbl 的 table + +```sql +RECOVER TABLE example_db.example_tbl example_tbl_id; +``` + +6. 恢复表 example_tbl 中 p1_id 且名为 p1 的 partition + +```sql +RECOVER PARTITION p1 p1_id FROM example_tbl; +``` + +7. 恢复 example_db_id 且名为 example_db 的 database,并设定新名字 new_example_db + +```sql +RECOVER DATABASE example_db example_db_id AS new_example_db; +``` + +8. 恢复名为 example_tbl 的 table,并设定新名字 new_example_tbl + +```sql +RECOVER TABLE example_db.example_tbl AS new_example_tbl; +``` + +9. 恢复表 example_tbl 中 p1_id 且名为 p1 的 partition,并设定新名字 new_p1 + +```sql +RECOVER PARTITION p1 p1_id AS new_p1 FROM example_tbl; +``` + +## 关键词 + + RECOVER + +### 最佳实践 + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/recycle/SHOW-CATALOG-RECYCLE-BIN.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/recycle/SHOW-CATALOG-RECYCLE-BIN.md new file mode 100644 index 0000000000000..137e27344062c --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/recycle/SHOW-CATALOG-RECYCLE-BIN.md @@ -0,0 +1,74 @@ +--- +{ + "title": "SHOW CATALOG RECYCLE BIN", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于展示回收站中可回收的库,表或分区元数据信息 + +语法: + +```sql +SHOW CATALOG RECYCLE BIN [ WHERE NAME [ = "name" | LIKE "name_matcher"] ] +``` + +说明: + +``` +各列含义如下: + Type: 元数据类型:Database、Table、Partition + Name: 元数据名称 + DbId: database对应的id + TableId: table对应的id + PartitionId: partition对应的id + DropTime: 元数据放入回收站的时间 + DataSize: 数据量. 如果元数据类型是database, 该值包含了database下在回收站中的所有table和partition的数据量 + RemoteDataSize: remote storage(hdfs或对象存储)的数据量. 如果元数据类型是database, 该值包含了database下在回收站中的所有table和partition的remote storage数据量 +``` + + +## 示例 + + 1. 展示所有回收站元数据 + + ```sql + SHOW CATALOG RECYCLE BIN; + ``` + + 2. 展示回收站中名称'test'的元数据 + + ```sql + SHOW CATALOG RECYCLE BIN WHERE NAME = 'test'; + ``` + +## 关键词 + + SHOW, CATALOG RECYCLE BIN + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/security/CREATE-ENCRYPTKEY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/security/CREATE-ENCRYPTKEY.md new file mode 100644 index 0000000000000..ecda825075cc9 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/security/CREATE-ENCRYPTKEY.md @@ -0,0 +1,83 @@ +--- +{ + "title": "CREATE ENCRYPTKEY", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +此语句创建一个自定义密钥。执行此命令需要用户拥有 `ADMIN` 权限。 + +语法: + +```sql +CREATE ENCRYPTKEY key_name AS "key_string" +``` + +说明: + +`key_name`: 要创建密钥的名字,可以包含数据库的名字。比如:`db1.my_key`。 + +`key_string`: 要创建密钥的字符串。 + +如果 `key_name` 中包含了数据库名字,那么这个自定义密钥会创建在对应的数据库中,否则这个函数将会创建在当前会话所在的数据库。新密钥的名字不能够与对应数据库中已存在的密钥相同,否则会创建失败。 + +## 示例 + +1. 创建一个自定义密钥 + + ```sql + CREATE ENCRYPTKEY my_key AS "ABCD123456789"; + ``` + +2. 使用自定义密钥 + + 使用自定义密钥需在密钥前添加关键字 `KEY`/`key`,与 `key_name` 空格隔开。 + + ```sql + mysql> SELECT HEX(AES_ENCRYPT("Doris is Great", KEY my_key)); + +------------------------------------------------+ + | hex(aes_encrypt('Doris is Great', key my_key)) | + +------------------------------------------------+ + | D26DB38579D6A343350EDDC6F2AD47C6 | + +------------------------------------------------+ + 1 row in set (0.02 sec) + + mysql> SELECT AES_DECRYPT(UNHEX('D26DB38579D6A343350EDDC6F2AD47C6'), KEY my_key); + +--------------------------------------------------------------------+ + | aes_decrypt(unhex('D26DB38579D6A343350EDDC6F2AD47C6'), key my_key) | + +--------------------------------------------------------------------+ + | Doris is Great | + +--------------------------------------------------------------------+ + 1 row in set (0.01 sec) + ``` + +## 关键词 + + CREATE, ENCRYPTKEY + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/security/CREATE-FILE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/security/CREATE-FILE.md new file mode 100644 index 0000000000000..7e510387a700d --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/security/CREATE-FILE.md @@ -0,0 +1,94 @@ +--- +{ + "title": "CREATE FILE", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句用于创建并上传一个文件到 Doris 集群。 +该功能通常用于管理一些其他命令中需要使用到的文件,如证书、公钥私钥等等。 + +该命令只用 `admin` 权限用户可以执行。 +某个文件都归属与某一个的 database。对 database 拥有访问权限的用户都可以使用该文件。 + +单个文件大小限制为 1MB。 +一个 Doris 集群最多上传 100 个文件。 + +语法: + +```sql +CREATE FILE "file_name" [IN database] +PROPERTIES("key"="value", ...) +``` + +说明: + +- file_name: 自定义文件名。 +- database: 文件归属于某一个 db,如果没有指定,则使用当前 session 的 db。 +- properties 支持以下参数: + - url:必须。指定一个文件的下载路径。当前仅支持无认证的 http 下载路径。命令执行成功后,文件将被保存在 doris 中,该 url 将不再需要。 + - catalog:必须。对文件的分类名,可以自定义。但在某些命令中,会查找指定 catalog 中的文件。比如例行导入中的,数据源为 kafka 时,会查找 catalog 名为 kafka 下的文件。 + - md5: 可选。文件的 md5。如果指定,会在下载文件后进行校验。 + +## 示例 + +1. 创建文件 ca.pem,分类为 kafka + + ```sql + CREATE FILE "ca.pem" + PROPERTIES + ( + "url" = "https://test.bj.bcebos.com/kafka-key/ca.pem", + "catalog" = "kafka" + ); + ``` + +2. 创建文件 client.key,分类为 my_catalog + + ```sql + CREATE FILE "client.key" + IN my_database + PROPERTIES + ( + "url" = "https://test.bj.bcebos.com/kafka-key/client.key", + "catalog" = "my_catalog", + "md5" = "b5bb901bf10f99205b39a46ac3557dd9" + ); + ``` + +## 关键词 + +```text +CREATE, FILE +``` + +### 最佳实践 + +1. 该命令只有 amdin 权限用户可以执行。某个文件都归属与某一个的 database。对 database 拥有访问权限的用户都可以使用该文件。 + +2. 文件大小和数量限制。 + + 这个功能主要用于管理一些证书等小文件。因此单个文件大小限制为 1MB。一个 Doris 集群最多上传 100 个文件。 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/security/DROP-ENCRYPTKEY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/security/DROP-ENCRYPTKEY.md new file mode 100644 index 0000000000000..4d6efc602d5e4 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/security/DROP-ENCRYPTKEY.md @@ -0,0 +1,59 @@ +--- +{ + "title": "DROP ENCRYPTKEY", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +语法: + +```sql +DROP ENCRYPTKEY key_name +``` + +参数说明: + +- `key_name`: 要删除密钥的名字,可以包含数据库的名字。比如:`db1.my_key`。 + +删除一个自定义密钥。密钥的名字完全一致才能够被删除。 + +执行此命令需要用户拥有 `ADMIN` 权限。 + +## 示例 + +1. 删除掉一个密钥 + + ```sql + DROP ENCRYPTKEY my_key; + ``` + +## 关键词 + + DROP, ENCRYPT, KEY + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/security/DROP-FILE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/security/DROP-FILE.md new file mode 100644 index 0000000000000..ff978a83f5cd7 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/security/DROP-FILE.md @@ -0,0 +1,60 @@ +--- +{ + "title": "DROP FILE", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于删除一个已上传的文件。 + +语法: + +```sql +DROP FILE "file_name" [FROM database] +[properties] +``` + +说明: + +- file_name: 文件名。 +- database: 文件归属的某一个 db,如果没有指定,则使用当前 session 的 db。 +- properties 支持以下参数: + - `catalog`: 必须。文件所属分类。 + +## 示例 + +1. 删除文件 ca.pem + + ```sql + DROP FILE "ca.pem" properties("catalog" = "kafka"); + ``` + +## 关键词 + + DROP, FILE + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/security/SHOW-ENCRYPTKEY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/security/SHOW-ENCRYPTKEY.md new file mode 100644 index 0000000000000..703b775d5ea68 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/security/SHOW-ENCRYPTKEY.md @@ -0,0 +1,72 @@ +--- +{ + "title": "SHOW ENCRYPTKEY", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +查看数据库下所有的自定义的密钥。如果用户指定了数据库,那么查看对应数据库的,否则直接查询当前会话所在数据库。 + +需要对这个数据库拥有 `ADMIN` 权限 + +语法: + +```sql +SHOW ENCRYPTKEYS [IN|FROM db] [LIKE 'key_pattern'] +``` + +参数 + +>`db`: 要查询的数据库名字 +>`key_pattern`: 用来过滤密钥名称的参数 + +## 示例 + + ```sql + mysql> SHOW ENCRYPTKEYS; + +-------------------+-------------------+ + | EncryptKey Name | EncryptKey String | + +-------------------+-------------------+ + | example_db.my_key | ABCD123456789 | + +-------------------+-------------------+ + 1 row in set (0.00 sec) + + mysql> SHOW ENCRYPTKEYS FROM example_db LIKE "%my%"; + +-------------------+-------------------+ + | EncryptKey Name | EncryptKey String | + +-------------------+-------------------+ + | example_db.my_key | ABCD123456789 | + +-------------------+-------------------+ + 1 row in set (0.00 sec) + ``` + +## 关键词 + + SHOW, ENCRYPT, KEY + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/security/SHOW-FILE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/security/SHOW-FILE.md new file mode 100644 index 0000000000000..627c91cc613be --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/security/SHOW-FILE.md @@ -0,0 +1,63 @@ +--- +{ + "title": "SHOW FILE", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于展示一个 database 内创建的文件 + +语法: + +```sql +SHOW FILE [FROM database]; +``` + +说明: + +```text +FileId: 文件 ID,全局唯一 +DbName: 所属数据库名称 +Catalog: 自定义分类 +FileName: 文件名 +FileSize: 文件大小,单位字节 +MD5: 文件的 MD5 +``` + +## 示例 + +1. 查看数据库 my_database 中已上传的文件 + + ```sql + SHOW FILE FROM my_database; + ``` + +## 关键词 + + SHOW, FILE + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/connection/KILL-CONNECTION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/connection/KILL-CONNECTION.md new file mode 100644 index 0000000000000..09357d109335f --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/connection/KILL-CONNECTION.md @@ -0,0 +1,70 @@ +--- +{ + "title": "KILL CONNECTION", + "language": "zh-CN" +} +--- + + + + +## 描述 + +杀死一个指定连接 ID 的连接。进而会杀死此连接对应的查询。 + +## 语法 + +```sql +KILL [ CONNECTION ] +``` + +## 必选参数 + +`` + +> 链接的 ID。可以通过 SHOW PROCESSLIST 语句查询。 + +## 权限控制 + +执行此 SQL 命令的用户必须是此连接所属的用户,或者至少具有`ADMIN_PRIV`权限 + +## 示例 + +查询 `connection_id`: + +```sql +show processlist; +``` + +结果如下: + +```sql ++------------------+----+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+------------------+--------------+--------------+ +| CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | FE | CloudCluster | ++------------------+----+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+------------------+--------------+--------------+ +| Yes | 16 | root | 127.0.0.1:63746 | 2024-11-04 20:18:07 | internal | test | Query | 0 | OK | e4d69a1cce81468d-91c9ae32b17540e9 | show processlist | 172.16.123.1 | NULL | ++------------------+----+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+------------------+--------------+--------------+ +``` + +发送 KILL 命令 + +```sql +KILL CONNECTION 16; +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/context/SWITCH.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/context/SWITCH.md new file mode 100644 index 0000000000000..e17b0c4cfd24c --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/context/SWITCH.md @@ -0,0 +1,51 @@ +--- +{ + "title": "SWITCH", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句用于切换数据目录(catalog) + +语法: + +```sql +SWITCH catalog_name +``` + +## 示例 + +1. 切换到数据目录 hive + + ```sql + SWITCH hive; + ``` + +## 关键词 + +SWITCH, CATALOG + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/context/USE-COMPUTE-GROUP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/context/USE-COMPUTE-GROUP.md new file mode 100644 index 0000000000000..b9131ff8350ad --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/context/USE-COMPUTE-GROUP.md @@ -0,0 +1,91 @@ +--- +{ + "title": "USE COMPUTE GROUP", + "language": "zh-CN" +} +--- + + + +## 描述 + +在存算分离版本中,指定使用计算集群 + +## 语法 + +```sql +USE { [ . ][ @ ] | @ } +``` + +## 必选参数 + +`` :计算集群名字 + +## 返回值 + +切换计算集群成功返回 "Database changed",切换失败返回相应错误提示信息 + +## 示例 + +1. 指定使用该计算集群 compute_cluster + + ```sql + use @compute_cluster; + Database changed + ``` + +2. 同时指定使用该数据库 mysql 和计算集群 compute_cluster + + ```sql + use mysql@compute_cluster + Database changed + ``` + +## 权限控制 + +执行此 SQL 命令成功的前置条件是,拥有 compute group 的使用权限 USAGE_PRIV,参考权限文档。 + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +| :---------------- | :------------- | :--------------- | +| USAGE_PRIV | Compute group | 计算集群使用权限 | + +若用户无 compute group 权限,而去指定 compute group 会报错,注 test 为普通用户无集群使用权限 + +```sql +mysql -utest -h175.40.1.1 -P9030 + +use @compute_cluster; +ERROR 5042 (42000): errCode = 2, detailMessage = USAGE denied to user test'@'127.0.0.1' for compute group 'compute_cluster' +``` + +## 注意事项 + +1. 如果 database 名字或者 compute group 名字是保留的关键字,需要用反引号,例如: + + ```sql + use @`create` + ``` + +2. 若 compute group 不存在,返回报错信息 + + ```sql + mysql> use @compute_group_not_exist; + ERROR 5098 (42000): errCode = 2, detailMessage = Compute Group compute_group_not_exist not exist + ``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/context/USE-DATABASE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/context/USE-DATABASE.md new file mode 100644 index 0000000000000..cd83dd69ba9f3 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/context/USE-DATABASE.md @@ -0,0 +1,70 @@ +--- +{ + "title": "USE", + "language": "zh-CN" +} +--- + + + +## 描述 + +USE 命令允许我们在 SQL 环境中切换到特定的数据库或计算组。 + +## 语法 + +```SQL +USE <[CATALOG_NAME].DATABASE_NAME> +``` + +## 示例 + +1. 如果 demo 数据库存在,尝试使用它: + + ```sql + mysql> use demo; + Database changed + ``` + +2. 如果 demo 数据库在 hms_catalog 的 Catalog 下存在,尝试切换到 hms_catalog, 并使用它: + + ```sql + mysql> use hms_catalog.demo; + Database changed + ``` +3. 如果 demo 数据库在当前目录中存在,并且您想使用名为 'cg1' 的计算组,请尝试访问它: + + ```sql + mysql> use demo@cg1; + Database changed + ``` + +4. 如果您只想使用名为 'cg1' 的计算组,请尝试访问它: + + ```sql + mysql> use @cg1; + Database changed + ``` + +## Relate Commands + +## 关键词 + + USE, DATABASE, USER, COMPUTE GROUP \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/CLEAN-ALL-PROFILE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/CLEAN-ALL-PROFILE.md new file mode 100644 index 0000000000000..0d3547b9bb2ef --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/CLEAN-ALL-PROFILE.md @@ -0,0 +1,53 @@ +--- +{ + "title": "CLEAN PROFILE", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +用于手动清理所有历史 query 或 load 的 profile 信息。 + +语法: + +```sql +CLEAN ALL PROFILE; +``` + +## 示例 + +1. 清理所有 profile 信息。 + + ```sql + CLEAN ALL PROFILE; + ``` + +## 关键词 + + CLEAN, PROFILE + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md new file mode 100644 index 0000000000000..f4abcd2ee3d1f --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md @@ -0,0 +1,70 @@ +--- +{ + "title": "CLEAN QUERY STATS", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用请空查询统计信息 + +语法: + +```sql +CLEAN [ALL| DATABASE | TABLE] QUERY STATS [[FOR db_name]|[FROM|IN] table_name]]; +``` + +说明: + +1. 如果指定 ALL,则清空所有查询统计信息,包括数据库和表的统计信息,需要 admin 权限 +2. 如果指定 DATABASE,则清空指定数据库的查询统计信息,需要对应 database 的 alter 权限 +3. 如果指定 TABLE,则清空指定表的查询统计信息,需要对应表的 alter 权限 + +## 示例 + +1. 清空所有统计信息 + + ```sql + clean all query stats; + ``` + +2. 清空指定数据库的统计信息 + + ```sql + clean database query stats for test_query_db; + ``` +3. 清空指定表的统计信息 + + ```sql + clean table query stats from test_query_db.baseall; + ``` + +## 关键词 + + CLEAN, QUERY, STATS + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/KILL-QUERY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/KILL-QUERY.md new file mode 100644 index 0000000000000..e2d092bbded0d --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/KILL-QUERY.md @@ -0,0 +1,83 @@ +--- +{ + "title": "KILL QUERY", + "language": "zh-CN" +} +--- + + + +## 描述 + +每个 Doris 的连接都在一个单独的线程中运行。您可以使用 KILL processlist_id 语句终止线程。 + +线程进程列表标识符可以从 SHOW PROCESSLIST 输出的 Id 列查询 或者 SELECT CONNECTION_ID() 来查询当前 Connection ID。 + +语法: + +```SQL +KILL [CONNECTION] processlist_id +``` + + +除此之外,您还可以使用 processlist_id 或者 query_id 终止正在执行的查询命令 + +语法: + +```SQL +KILL QUERY processlist_id | query_id +``` + +## 示例 + +**1. 查看当前连接的 Connection ID。** + +```sql +mysql select connection_id(); ++-----------------+ +| connection_id() | ++-----------------+ +| 48 | ++-----------------+ +1 row in set (0.00 sec) +``` + +**2. 查看所有连接的 Connection ID。** + +```sql +mysql SHOW PROCESSLIST; ++------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ +| CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | ++------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ +| Yes | 48 | root | 10.16.xx.xx:44834 | 2023-12-29 16:49:47 | internal | test | Query | 0 | OK | e6e4ce9567b04859-8eeab8d6b5513e38 | SHOW PROCESSLIST | +| | 50 | root | 192.168.xx.xx:52837 | 2023-12-29 16:51:34 | internal | | Sleep | 1837 | EOF | deaf13c52b3b4a3b-b25e8254b50ff8cb | SELECT @@session.transaction_isolation | +| | 51 | root | 192.168.xx.xx:52843 | 2023-12-29 16:51:35 | internal | | Sleep | 907 | EOF | 437f219addc0404f-9befe7f6acf9a700 | /* ApplicationName=DBeaver Ultimate 23.1.3 - Metadata */ SHOW STATUS | +| | 55 | root | 192.168.xx.xx:55533 | 2023-12-29 17:09:32 | internal | test | Sleep | 271 | EOF | f02603dc163a4da3-beebbb5d1ced760c | /* ApplicationName=DBeaver Ultimate 23.1.3 - SQLEditor */ SELECT DATABASE() | +| | 47 | root | 10.16.xx.xx:35678 | 2023-12-29 16:21:56 | internal | test | Sleep | 3528 | EOF | f4944c543dc34a99-b0d0f3986c8f1c98 | select * from test | ++------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ +5 rows in set (0.00 sec) +``` + +**3. 终止正在运行的查询,正在运行的查询会显示被取消。** + +```sql +mysql kill query 55; +Query OK, 0 rows affected (0.01 sec) +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/PLAN-REPLAYER-DUMP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/PLAN-REPLAYER-DUMP.md new file mode 100644 index 0000000000000..596b1b94c20e0 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/PLAN-REPLAYER-DUMP.md @@ -0,0 +1,98 @@ +--- +{ + "title": "PLAN REPLAYER DUMP", + "language": "zh-CN" +} +--- + + + + +## 描述 + +PLAN REPLAYER DUMP 是 Doris 用户用来生成执行规划诊断文件的工具。用于捕捉查询优化器的状态和输入数据,方便调试和分析查询优化问题。其输出为对应诊断文件的 http 地址。 + + +## 语法 + + +```sql +PLAN REPLAYER DUMP +``` + +## 必选参数 + +`` + +- 指的是对应的 DML 里面的 query 语句 +- 如果不是 query 语句则会报 parse 错误 +- 有关更多详细信息,请参阅[SELECT](https://doris.apache.org/zh-CN/docs/sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/SELECT/)语法 + +## 权限控制 + + +执行此 SQL 命令的用户必须至少具有以下权限: + + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +| :---------------- | :------------------------ | :----------------------------------------------------------- | +| SELECT_PRIV | 表(Table), 视图(View) | 当执行 时,需要拥有被查询的表,视图或物化视图的 SELECT_PRIV 权限 | + + +## 示例 + + +### 基础示例 + + +```sql +create database test_replayer; +use database test_replayer; +create table t1 (c1 int, c11 int) distributed by hash(c1) buckets 3 properties('replication_num' = '1'); +plan replayer dump select * from t1; +``` + +执行结果示例: + + +```sql ++-------------------------------------------------------------------------------+ +| Plan Replayer dump url | +| Plan Replayer dump url | ++-------------------------------------------------------------------------------+ +| http://127.0.0.1:8030/api/minidump?query_id=6e7441f741e94afd-ad3ba69429ad18ec | ++-------------------------------------------------------------------------------+ +``` + +可以使用 curl 或者 wget 获取对应的文件,例如: + + +```sql +wget http://127.0.0.1:8030/api/minidump?query_id=6e7441f741e94afd-ad3ba69429ad18ec +``` + +当需要权限的时候可以把用户名和密码包含在 + + +```sql +wget --header="Authorization: Basic $(echo -n 'root:' | base64)" http://127.0.0.1:8030/api/minidump?query_id=6e7441f741e94afd-ad3ba69429ad18ec +``` +``` + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/PLAN-REPLAYER-PLAY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/PLAN-REPLAYER-PLAY.md new file mode 100644 index 0000000000000..c445c1b5d9b34 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/PLAN-REPLAYER-PLAY.md @@ -0,0 +1,51 @@ +--- +{ + "title": "PLAN REPLAYER PLAY", + "language": "zh-CN" +} +--- + + + + +## 描述 + +PLAN REPLAYER PLAY 是 Doris 开发者用来分析优化器问题的工具。其根据[PLAN REPLAYER DUMP](https://selectdb.feishu.cn/wiki/VFEhwnJ9Bi0Si4kIebEcyzMXnNh?preview_comment_id=7434512678431211524)生成的诊断文件,在对应版本的 fe 下可以加载元数据和统计信息用于开发者复现和调试问题。 + +## 语法 + +```sql +PLAN REPLAYER PLAY ; +``` + +## 必选参数 + +`` + +- 指定对应 dump 文件的绝对路径的字符串。 +- 标识符必须以双引号围起来,而且是对应文件的绝对路径。 + +## 示例 + +当我们有一个 dumpfile: /home/wangwu/dumpfile.json 时,可以使用下面 sql 来复现场景 + +```sql +PLAN REPLAYER PLAY "/home/wangwu/dumpfile.json"; +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md new file mode 100644 index 0000000000000..9f8cae6a4d316 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md @@ -0,0 +1,88 @@ +--- +{ + "title": "SHOW PROCESSLIST", + "language": "zh-CN" +} +--- + + + + +### Name + +SHOW PROCESSLIST + +## 描述 + +显示用户正在运行的线程,需要注意的是,除了 root 用户能看到所有正在运行的线程外,其他用户都只能看到自己正在运行的线程,看不到其它用户正在运行的线程 + +语法: + +```sql +SHOW [FULL] PROCESSLIST +``` + +说明: + +- CurrentConnected: 是否为当前连接。 +- Id: 就是这个线程的唯一标识,当我们发现这个线程有问题的时候,可以通过 kill 命令,加上这个 Id 值将这个线程杀掉。 +- User: 就是指启动这个线程的用户。 +- Host: 记录了发送请求的客户端的 IP 和 端口号。通过这些信息在排查问题的时候,我们可以定位到是哪个客户端的哪个进程发送的请求。 +- LoginTime: 建立连接的时间。 +- Catalog: 当前执行的命令是在哪一个数据目录上。 +- Db: 当前执行的命令是在哪一个数据库上。如果没有指定数据库,则该值为 NULL。 +- Command: 是指此刻该线程正在执行的命令。 +- Time: 上一条命令提交到当前状态的时间,单位为秒。 +- State: 线程的状态,和 Command 对应。 +- QueryId: 当前查询语句的 ID。 +- Info: 一般记录的是线程执行的语句。默认只显示前 100 个字符,也就是你看到的语句可能是截断了的,要看全部信息,需要使用 show full processlist。 + +常见的 Command 类型如下: + +- Query: 该线程正在执行一个语句 +- Sleep: 正在等待客户端向它发送执行语句 +- Quit: 该线程正在退出 +- Kill : 正在执行 kill 语句,杀死指定线程 + +其他类型可以参考 [MySQL 官网解释](https://dev.mysql.com/doc/refman/5.6/en/thread-commands.html) + +## 示例 + +1. 查看当前用户正在运行的线程 + ```SQL + SHOW PROCESSLIST + ``` + 返回结果 + ``` + MySQL [test]> show full processlist; + +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ + | CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | + +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ + | Yes | 0 | root | 127.0.0.1:34650 | 2023-09-06 12:01:02 | internal | test | Query | 0 | OK | c84e397193a54fe7-bbe9bc219318b75e | select 1 | + | | 1 | root | 127.0.0.1:34776 | 2023-09-06 12:01:07 | internal | | Sleep | 29 | EOF | 886ffe2894314f50-8dd73a6ca06699e4 | show full processlist | + +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ + ``` + +## 关键词 + + SHOW, PROCESSLIST + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-QUERY-PROFILE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-QUERY-PROFILE.md new file mode 100644 index 0000000000000..5a7b406970478 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-QUERY-PROFILE.md @@ -0,0 +1,224 @@ +--- +{ + "title": "SHOW QUERY PROFILE", + "language": "zh-CN" +} +--- + + + + +### Name + +SHOW QUERY PROFILE + +:::caution +自 2.1.1 起,此语法被弃用。你仍然可以从 http://:/QueryProfile 上下载 profile 文件。 +::: + +## 描述 + +该语句是用来查看 QUERY 操作的树状 Profile 信息,该功能需要用户打开 Profile 设置,0.15 之前版本执行下面的设置: + +```sql +SET is_report_success=true; +``` + +0.15 及之后的版本执行下面的设置: + +```sql +SET [GLOBAL] enable_profile=true; +``` + +语法: + +```sql +show query profile "/"; +``` +这个命令会列出当前保存的所有 query 操作的 Profile。 + +```sql +show query profile "/queryId"\G; +show query profile "/queryId/fragment_id/instance_id"; +``` +获取指定 query id 树状 profile 信息,返回 profile 简易树形图。指定 fragment_id 和 instance_id 则返回对应的详细 profile 树形图。 + + +## 示例 + +1. 列出所有的 query Profile + + ```sql + mysql> show query profile "/"; + +-----------------------------------+------+-------------------------+--------------------+-----------+---------------------+---------------------+-----------+------------+ + | QueryId | User | DefaultDb | SQL | QueryType | StartTime | EndTime | TotalTime | QueryState | + +-----------------------------------+------+-------------------------+--------------------+-----------+---------------------+---------------------+-----------+------------+ + | 327167e0db4749a9-adce3b3d770b2bb1 | root | default_cluster:test_db | select * from test | Query | 2022-08-09 10:50:09 | 2022-08-09 10:50:09 | 19ms | EOF | + +-----------------------------------+------+-------------------------+--------------------+-----------+---------------------+---------------------+-----------+------------+ + 1 row in set (0.00 sec) + ``` + +2. 列出指定 QueryId 的 query Profile + + ```sql + mysql> show query profile "/327167e0db4749a9-adce3b3d770b2bb1"\G + *************************** 1. row *************************** + Fragments: ┌────────────────────────┐ + │[-1: VDataBufferSender] │ + │Fragment: 0 │ + │MaxActiveTime: 783.263us│ + └────────────────────────┘ + ┌┘ + │ + ┌───────────────────┐ + │[1: VEXCHANGE_NODE]│ + │Fragment: 0 │ + └───────────────────┘ + └┐ + │ + ┌────────────────────────┐ + │[1: VDataStreamSender] │ + │Fragment: 1 │ + │MaxActiveTime: 847.612us│ + └────────────────────────┘ + │ + │ + ┌────────────────────┐ + │[0: VOLAP_SCAN_NODE]│ + │Fragment: 1 │ + └────────────────────┘ + ┌┘ + │ + ┌─────────────┐ + │[OlapScanner]│ + │Fragment: 1 │ + └─────────────┘ + │ + │ + ┌─────────────────┐ + │[SegmentIterator]│ + │Fragment: 1 │ + └─────────────────┘ + 1 row in set (0.00 sec) + ``` +3. 列出指定 Fragment 的 Instance 概况 + + ```sql + mysql> show query profile "/327167e0db4749a9-adce3b3d770b2bb1/1/"\G + *************************** 1. row *************************** + Instances: 327167e0db4749a9-adce3b3d770b2bb2 + Host: 172.26.0.1:9111 + ActiveTime: 847.612us + 1 row in set (0.01 sec) + ``` + +4. 继续查看某一个具体的 Instance 上各个算子的详细 Profile + + ```sql + mysql> show query profile "/327167e0db4749a9-adce3b3d770b2bb1/1/327167e0db4749a9-adce3b3d770b2bb2"\G + *************************** 1. row *************************** + Instance: ┌───────────────────────────────────────┐ + │[1: VDataStreamSender] │ + │(Active: 36.944us, non-child: 0.20) │ + │ - Counters: │ + │ - BytesSent: 0.00 │ + │ - IgnoreRows: 0 │ + │ - LocalBytesSent: 20.00 B │ + │ - OverallThroughput: 0.0 /sec │ + │ - PeakMemoryUsage: 0.00 │ + │ - SerializeBatchTime: 0ns │ + │ - UncompressedRowBatchSize: 0.00 │ + └───────────────────────────────────────┘ + │ + │ + ┌───────────────────────────────────────┐ + │[0: VOLAP_SCAN_NODE] │ + │(Active: 563.241us, non-child: 3.00) │ + │ - Counters: │ + │ - BatchQueueWaitTime: 444.714us │ + │ - BytesRead: 37.00 B │ + │ - NumDiskAccess: 1 │ + │ - NumScanners: 2 │ + │ - PeakMemoryUsage: 320.00 KB │ + │ - RowsRead: 4 │ + │ - RowsReturned: 4 │ + │ - RowsReturnedRate: 7.101K /sec │ + │ - ScannerBatchWaitTime: 206.40us │ + │ - ScannerSchedCount : 2 │ + │ - ScannerWorkerWaitTime: 34.640us│ + │ - TabletCount : 2 │ + │ - TotalReadThroughput: 0.0 /sec │ + └───────────────────────────────────────┘ + │ + │ + ┌─────────────────────────────────┐ + │[OlapScanner] │ + │(Active: 0ns, non-child: 0.00) │ + │ - Counters: │ + │ - BlockConvertTime: 0ns │ + │ - BlockFetchTime: 183.741us│ + │ - ReaderInitTime: 180.741us│ + │ - RowsDelFiltered: 0 │ + │ - RowsPushedCondFiltered: 0│ + │ - ScanCpuTime: 388.576us │ + │ - ScanTime: 0ns │ + │ - ShowHintsTime_V1: 0ns │ + └─────────────────────────────────┘ + │ + │ + ┌─────────────────────────────────────┐ + │[SegmentIterator] │ + │(Active: 0ns, non-child: 0.00) │ + │ - Counters: │ + │ - BitmapIndexFilterTimer: 124ns│ + │ - BlockLoadTime: 179.202us │ + │ - BlockSeekCount: 5 │ + │ - BlockSeekTime: 18.792us │ + │ - BlocksLoad: 4 │ + │ - CachedPagesNum: 2 │ + │ - CompressedBytesRead: 0.00 │ + │ - DecompressorTimer: 0ns │ + │ - IOTimer: 0ns │ + │ - IndexLoadTime_V1: 0ns │ + │ - NumSegmentFiltered: 0 │ + │ - NumSegmentTotal: 2 │ + │ - RawRowsRead: 4 │ + │ - RowsBitmapIndexFiltered: 0 │ + │ - RowsBloomFilterFiltered: 0 │ + │ - RowsConditionsFiltered: 0 │ + │ - RowsKeyRangeFiltered: 0 │ + │ - RowsStatsFiltered: 0 │ + │ - RowsVectorPredFiltered: 0 │ + │ - TotalPagesNum: 2 │ + │ - UncompressedBytesRead: 0.00 │ + │ - VectorPredEvalTime: 0ns │ + └─────────────────────────────────────┘ + + 1 row in set (0.01 sec) + ``` + +## 关键词 + + SHOW, QUERY, PROFILE + +### 最佳实践 + + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md new file mode 100644 index 0000000000000..5ddda3bc2a84d --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md @@ -0,0 +1,194 @@ +--- +{ + "title": "SHOW QUERY STATS", + "language": "zh-CN" +} +--- + + + + + + +### Name + +SHOW QUERY STATS + +## 描述 + +该语句用于展示数据库中历史查询命中的库表列的情况 + +```sql +SHOW QUERY STATS [[FOR db_name]|[FROM table_name]] [ALL] [VERBOSE]]; +``` + +说明: + +1. 支持查询数据库和表的历史查询命中情况,重启 fe 后数据会重置,每个 fe 单独统计 +2. 通过 FOR DATABASE 和 FROM TABLE 可以指定查询数据库或者表的命中情况,后面分别接数据库名或者表名 +3. ALL 可以指定是否展示所有 index 的查询命中情况,VERBOSE 可以展示更详细的命中情况,这两个参数可以单独使用, + 也可以一起使用,但是必须放在最后 而且只能用在表的查询上 +4. 如果没有 use 任何数据库那么直接执行`SHOW QUERY STATS` 将展示所有数据库的命中情况 +5. 命中结果中可能有两列: + QueryCount:该列被查询次数 + FilterCount: 该列作为 where 条件被查询的次数 +## 示例 + +1. 展示表`baseall` 的查询命中情况 + + ```sql + MySQL [test_query_db]> show query stats from baseall; + +-------+------------+-------------+ + | Field | QueryCount | FilterCount | + +-------+------------+-------------+ + | k0 | 0 | 0 | + | k1 | 0 | 0 | + | k2 | 0 | 0 | + | k3 | 0 | 0 | + | k4 | 0 | 0 | + | k5 | 0 | 0 | + | k6 | 0 | 0 | + | k10 | 0 | 0 | + | k11 | 0 | 0 | + | k7 | 0 | 0 | + | k8 | 0 | 0 | + | k9 | 0 | 0 | + | k12 | 0 | 0 | + | k13 | 0 | 0 | + +-------+------------+-------------+ + 14 rows in set (0.002 sec) + + MySQL [test_query_db]> select k0, k1,k2, sum(k3) from baseall where k9 > 1 group by k0,k1,k2; + +------+------+--------+-------------+ + | k0 | k1 | k2 | sum(`k3`) | + +------+------+--------+-------------+ + | 0 | 6 | 32767 | 3021 | + | 1 | 12 | 32767 | -2147483647 | + | 0 | 3 | 1989 | 1002 | + | 0 | 7 | -32767 | 1002 | + | 1 | 8 | 255 | 2147483647 | + | 1 | 9 | 1991 | -2147483647 | + | 1 | 11 | 1989 | 25699 | + | 1 | 13 | -32767 | 2147483647 | + | 1 | 14 | 255 | 103 | + | 0 | 1 | 1989 | 1001 | + | 0 | 2 | 1986 | 1001 | + | 1 | 15 | 1992 | 3021 | + +------+------+--------+-------------+ + 12 rows in set (0.050 sec) + + MySQL [test_query_db]> show query stats from baseall; + +-------+------------+-------------+ + | Field | QueryCount | FilterCount | + +-------+------------+-------------+ + | k0 | 1 | 0 | + | k1 | 1 | 0 | + | k2 | 1 | 0 | + | k3 | 1 | 0 | + | k4 | 0 | 0 | + | k5 | 0 | 0 | + | k6 | 0 | 0 | + | k10 | 0 | 0 | + | k11 | 0 | 0 | + | k7 | 0 | 0 | + | k8 | 0 | 0 | + | k9 | 1 | 1 | + | k12 | 0 | 0 | + | k13 | 0 | 0 | + +-------+------------+-------------+ + 14 rows in set (0.001 sec) + ``` + +2. 展示表的所物化视图的的命中的汇总情况 + + ```sql + MySQL [test_query_db]> show query stats from baseall all; + +-----------+------------+ + | IndexName | QueryCount | + +-----------+------------+ + | baseall | 1 | + +-----------+------------+ + 1 row in set (0.005 sec) + ``` + +3. 展示表的所物化视图的的命中的详细情况 + + ```sql + MySQL [test_query_db]> show query stats from baseall all verbose; + +-----------+-------+------------+-------------+ + | IndexName | Field | QueryCount | FilterCount | + +-----------+-------+------------+-------------+ + | baseall | k0 | 1 | 0 | + | | k1 | 1 | 0 | + | | k2 | 1 | 0 | + | | k3 | 1 | 0 | + | | k4 | 0 | 0 | + | | k5 | 0 | 0 | + | | k6 | 0 | 0 | + | | k10 | 0 | 0 | + | | k11 | 0 | 0 | + | | k7 | 0 | 0 | + | | k8 | 0 | 0 | + | | k9 | 1 | 1 | + | | k12 | 0 | 0 | + | | k13 | 0 | 0 | + +-----------+-------+------------+-------------+ + 14 rows in set (0.017 sec) + ``` + +4. 展示数据库的命中情况 + + ```sql + MySQL [test_query_db]> show query stats for test_query_db; + +----------------------------+------------+ + | TableName | QueryCount | + +----------------------------+------------+ + | compaction_tbl | 0 | + | bigtable | 0 | + | empty | 0 | + | tempbaseall | 0 | + | test | 0 | + | test_data_type | 0 | + | test_string_function_field | 0 | + | baseall | 1 | + | nullable | 0 | + +----------------------------+------------+ + 9 rows in set (0.005 sec) + ``` + +5. 展示所有数据库的命中情况,这时不能 use 任何数据库 + + ```sql + MySQL [(none)]> show query stats; + +-----------------+------------+ + | Database | QueryCount | + +-----------------+------------+ + | test_query_db | 1 | + +-----------------+------------+ + 1 rows in set (0.005 sec) + ``` + SHOW QUERY STATS; + ``` + +## 关键词 + + SHOW, QUERY, STATS; + +### 最佳实践 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/variables/SET-VARIABLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/variables/SET-VARIABLE.md new file mode 100644 index 0000000000000..cf56f887d9f8a --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/variables/SET-VARIABLE.md @@ -0,0 +1,68 @@ +--- +{ + "title": "SET VARIABLE", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句主要是用来修改 Doris 系统变量,这些系统变量可以分为全局以及会话级别层面来修改,有些也可以进行动态修改。你也可以通过 `SHOW VARIABLE` 来查看这些系统变量。 + +语法: + +```sql +SET variable_assignment [, variable_assignment] ... +``` + +说明: + +1. variable_assignment: + user_var_name = expr + | [GLOBAL | SESSION] system_var_name = expr + +> 注意: +> +> 1. 只有 ADMIN 用户可以设置变量的全局生效 +> 2. 全局生效的变量影响当前会话和此后的新会话,不影响当前已经存在的其他会话。 + +## 示例 + +1. 设置时区为东八区 + + ``` + SET time_zone = "Asia/Shanghai"; + ``` + +2. 设置全局的执行内存大小 + + ``` + SET GLOBAL exec_mem_limit = 137438953472 + ``` + +## 关键词 + + SET, VARIABLE + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/variables/SHOW-VARIABLES.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/variables/SHOW-VARIABLES.md new file mode 100644 index 0000000000000..105034aa32151 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/variables/SHOW-VARIABLES.md @@ -0,0 +1,73 @@ +--- +{ + "title": "SHOW VARIABLES", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句是用来显示 Doris 系统变量,可以通过条件查询 + +语法: + +```sql +SHOW [GLOBAL | SESSION] VARIABLES + [LIKE 'pattern' | WHERE expr] +``` + +说明: + +- show variables 主要是用来查看系统变量的值。 +- 执行 SHOW VARIABLES 命令不需要任何权限,只要求能够连接到服务器就可以。 +- 使用 like 语句表示用 variable_name 进行匹配。 +- %百分号通配符可以用在匹配模式中的任何位置 + +## 示例 + +1. 这里默认的就是对 Variable_name 进行匹配,这里是准确匹配 + + ```sql + show variables like 'max_connections'; + ``` + +2. 通过百分号 (%) 这个通配符进行匹配,可以匹配多项 + + ```sql + show variables like '%connec%'; + ``` + +3. 使用 Where 子句进行匹配查询 + + ```sql + show variables where variable_name = 'version'; + ``` + +## 关键词 + + SHOW, VARIABLES + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/variables/UNSET-VARIABLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/variables/UNSET-VARIABLE.md new file mode 100644 index 0000000000000..8f6c7bae40d5f --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/variables/UNSET-VARIABLE.md @@ -0,0 +1,75 @@ +--- +{ + "title": "UNSET VARIABLE", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句主要是用来恢复 Doris 系统变量为默认值,可以是全局也可以是会话级别。 + +语法: + +```sql +UNSET [SESSION|GLOBAL] VARIABLE (variable_name | ALL) +``` + +说明: + +1. (variable_name | ALL) :必须指定变量名或使用 ALL , ALL 会恢复所有变量的值。 + +> 注意: +> +> 1. 只有 ADMIN 用户可以全局得恢复变量的值。 +> 2. 使用 `GLOBAL` 恢复变量值时仅在执行命令的当前会话和之后打开的会话中生效,不会恢复当前已有的其它会话中的值。 + + +## 示例 + +1. 恢复时区为默认值东八区 + + ``` + UNSET VARIABLE time_zone; + ``` + +2. 恢复全局的执行内存大小 + + ``` + UNSET GLOBAL VARIABLE exec_mem_limit; + ``` + +3. 从全局范围恢复所有变量的值 + + ``` + UNSET GLOBAL VARIABLE ALL; + ``` + +## 关键词 + + UNSET, VARIABLE + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/ALTER-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/ALTER-STATS.md new file mode 100644 index 0000000000000..022eadfb8c160 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/ALTER-STATS.md @@ -0,0 +1,106 @@ +--- +{ + "title": "ALTER STATS", + "language": "zh-CN" +} +--- + + + +## 描述 + +手动修改指定表中指定列的统计信息。请参阅[统计信息](../../../query-acceleration/optimization-technology-principle/statistics)章节 + +## 语法 + +```sql +ALTER TABLE + [ INDEX ] + MODIFY COLUMN + SET STATS () +``` + +其中: + +```sql +column_stats + : -- column stats value + ("key1" = "value1", "key2" = "value2" [...]) +``` + +## 必选参数 + +1. ``: 指定表的标识符(即名称) + +2. ``: 指定列标识符(即名称)。在不指定 index_name 的情况下,就是基表的列名称。 + +3. `` : + + 要设置的统计信息值,以 key = value 的形式给出,key 和 value 需要用引号包裹,kv 对之间用逗号分隔。可以设置的统计信息包括: + + - row_count,总行数 + + - ndv,列的基数 + + - num_nulls,列的空值数量 + + - data_size,列的总大小 + + - min_value,列的最小值 + + - max_value,列的最大值 + + 其中 row_count 是必须指定的,其他属性为可选项。如果不设置,该列的对应统计信息属性值就为空。 + +## 可选参数 + +1. ` `: 同步物化视图(请参阅“同步物化视图”章节)标识符(即名称)。一张表可以创建 0 到多个物化视图,如果需要设置某个物化视图中某一列的统计信息,需要使用 index_name 来制定物化视图的名称。不指定的情况下,设定的是基表中列的属性。 + +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +| :---------------- | :------------- | :------------ | +| ALTER_PRIV | 表(Table) | | + +## 注意事项 + +用户手动对某张表注入统计信息后,这张表就不再参与统计信息的自动收集(请参阅“统计信息自动收集”章节),以免覆盖用户手动注入的信息。如果不再使用注入的统计信息,可以使用 drop stats 语句删掉已经注入的信息,这样可以让该表重新开启自动收集。 + +## 示例 + +- 给 Part 表的 p_parkey 列(基表列,因为没有指定 index_name)注入统计信息。 + + ```sql + alter + table part + modify column p_partkey + set stats ('row_count'='2.0E7', 'ndv'='2.0252576E7', 'num_nulls'='0.0', 'data_size'='8.0E7', 'min_value'='1', 'max_value'='20000000'); + ``` + +- 给 Part 表的 index1 物化视图的 col1 列(物化视图列,因为指定了 index_name)注入统计信息。 + + ```sql + alter + table part index index1 + modify column col1 + set stats ('row_count'='2.0E7', 'ndv'='2.0252576E7', 'num_nulls'='0.0', 'data_size'='8.0E7', 'min_value'='1', 'max_value'='20000000'); + ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/ANALYZE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/ANALYZE.md new file mode 100644 index 0000000000000..b12f4c56a9136 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/ANALYZE.md @@ -0,0 +1,61 @@ +--- +{ + "title": "ANALYZE", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于收集各列的统计信息。 + +```sql +ANALYZE < TABLE | DATABASE table_name | db_name > + [ (column_name [, ...]) ] + [ [ WITH SYNC ] [ WITH SAMPLE PERCENT | ROWS ] ]; +``` + +- table_name: 指定的目标表。可以是  `db_name.table_name`  形式。 +- column_name: 指定的目标列。必须是  `table_name`  中存在的列,多个列名称用逗号分隔。 +- sync:同步收集统计信息。收集完后返回。若不指定则异步执行并返回 JOB ID。 +- sample percent | rows:抽样收集统计信息。可以指定抽样比例或者抽样行数。 + +## 示例 + +对一张表按照 10% 的比例采样收集统计数据: + +```sql +ANALYZE TABLE lineitem WITH SAMPLE PERCENT 10; +``` + +对一张表按采样 10 万行收集统计数据 + +```sql +ANALYZE TABLE lineitem WITH SAMPLE ROWS 100000; +``` + +## 关键词 + +ANALYZE diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/DROP-ANALYZE-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/DROP-ANALYZE-JOB.md new file mode 100644 index 0000000000000..b471c74a712f2 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/DROP-ANALYZE-JOB.md @@ -0,0 +1,55 @@ +--- +{ + "title": "DROP ANALYZE JOB", + "language": "zh-CN" +} +--- + + + +## 描述 + +删除指定的统计信息收集作业的历史记录。 + +## 语法 + +```sql +DROP ANALYZE JOB +``` + +## 必选参数 + +1. ``:指定作业的 id。可以通过 SHOW ANALYZE 获取作业的 job_id。详细用法,请参阅 [SHOW ANALYZE](./SHOW-ANALYZE) 章节 + +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +| :---------------- | :------------- | :------------ | +| SELECT_PRIV | 表(Table) | | + +## 示例 + +删除 id 为 10036 的统计信息作业记录 + +```sql +DROP ANALYZE JOB 10036 +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/DROP-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/DROP-STATS.md new file mode 100644 index 0000000000000..775f7c135cd18 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/DROP-STATS.md @@ -0,0 +1,73 @@ +--- +{ + "title": "DROP STATS", + "language": "zh-CN" +} +--- + + + +## 描述 + +删除指定表和列的统计信息。如果不指定列名,则删除所有列的统计信息。 + +## 语法 + +```sql +DROP STATS [ ] +``` + +其中: + +```sql +column_names + : + (, [ ... ]) +``` + +## 必选参数 + +``: 表的标识符(即名称) + +## 可选参数 + +``: 列标识符列表(即名称列表) + +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +| :---------------- | :------------- | :------------ | +| DROP_PRIV | 表(Table) | | + +## 示例 + +- 删除 table1 中所有列的统计信息 + + ```sql + DROP STATS table1 + ``` + +- 删除 table1 中 col1 和 col2 的统计信息 + + ```sql + DROP STATS table1 (col1, col2) + ``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/KILL-ANALYZE-JOB.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/KILL-ANALYZE-JOB.md new file mode 100644 index 0000000000000..a227286e71833 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/KILL-ANALYZE-JOB.md @@ -0,0 +1,64 @@ +--- +{ + "title": "KILL ANALYZE JOB", + "language": "zh-CN" +} +--- + + + + +## 描述 + +停止正在后台执行的统计信息收集作业。 + +## 语法 + +```sql +KILL ANALYZE +``` + +## 必选参数 + +``: 指定作业的 id。可以通过 SHOW ANALYZE 获取作业的 job_id。详细用法,请参阅“SHOW ANALYZE”章节 + +## 可选参数 + +无 + +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +| :---------------- | :------------- | :------------ | +| SELECT_PRIV | 表(Table) | | + +## 注意事项 + +已经执行完的作业无法停止 + +## 示例 + +停止 id 为 10036 的统计信息作业记录 + +```sql +kill analyze 10036 +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/SHOW-ANALYZE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/SHOW-ANALYZE.md new file mode 100644 index 0000000000000..be0c2af6f7c3d --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/SHOW-ANALYZE.md @@ -0,0 +1,106 @@ +--- +{ + "title": "SHOW ANALYZE", + "language": "zh-CN" +} +--- + + + + +## 描述 + +通过 `SHOW ANALYZE` 来查看统计信息收集作业的信息。 + +语法如下: + +```SQL +SHOW [AUTO] ANALYZE < table_name | job_id > + [ WHERE [ STATE = [ "PENDING" | "RUNNING" | "FINISHED" | "FAILED" ] ] ]; +``` + +- AUTO:仅仅展示自动收集历史作业信息。需要注意的是默认只保存过去 20000 个执行完毕的自动收集作业的状态。 +- table_name:表名,指定后可查看该表对应的统计作业信息。可以是  `db_name.table_name`  形式。不指定时返回所有统计作业信息。 +- job_id:统计信息作业 ID,执行 `ANALYZE` 异步收集时得到。不指定 id 时此命令返回所有统计作业信息。 + +输出: + +| 列名 | 说明 | +| :--------------------- | :----------- | +| `job_id` | 统计作业 ID | +| `catalog_name` | catalog 名称 | +| `db_name` | 数据库名称 | +| `tbl_name` | 表名称 | +| `col_name` | 列名称列表 | +| `job_type` | 作业类型 | +| `analysis_type` | 统计类型 | +| `message` | 作业信息 | +| `last_exec_time_in_ms` | 上次执行时间 | +| `state` | 作业状态 | +| `schedule_type` | 调度方式 | + +下面是一个例子: + +```sql +mysql> show analyze 245073\G; +*************************** 1. row *************************** + job_id: 245073 + catalog_name: internal + db_name: default_cluster:tpch + tbl_name: lineitem + col_name: [l_returnflag,l_receiptdate,l_tax,l_shipmode,l_suppkey,l_shipdate,l_commitdate,l_partkey,l_orderkey,l_quantity,l_linestatus,l_comment,l_extendedprice,l_linenumber,l_discount,l_shipinstruct] + job_type: MANUAL + analysis_type: FUNDAMENTALS + message: +last_exec_time_in_ms: 2023-11-07 11:00:52 + state: FINISHED + progress: 16 Finished | 0 Failed | 0 In Progress | 16 Total + schedule_type: ONCE +``` + +
+ +每个收集作业中可以包含一到多个任务,每个任务对应一列的收集。用户可通过如下命令查看具体每列的统计信息收集完成情况。 + +语法: + +```sql +SHOW ANALYZE TASK STATUS [job_id] +``` + +下面是一个例子: + +``` +mysql> show analyze task status 20038 ; ++---------+----------+---------+----------------------+----------+ +| task_id | col_name | message | last_exec_time_in_ms | state | ++---------+----------+---------+----------------------+----------+ +| 20039 | col4 | | 2023-06-01 17:22:15 | FINISHED | +| 20040 | col2 | | 2023-06-01 17:22:15 | FINISHED | +| 20041 | col3 | | 2023-06-01 17:22:15 | FINISHED | +| 20042 | col1 | | 2023-06-01 17:22:15 | FINISHED | ++---------+----------+---------+----------------------+----------+ + + +``` + +## 关键词 + +SHOW, ANALYZE diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/SHOW-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/SHOW-STATS.md new file mode 100644 index 0000000000000..604cd375aec3d --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/SHOW-STATS.md @@ -0,0 +1,66 @@ +--- +{ + "title": "SHOW STATS", + "language": "zh-CN" +} +--- + + + +## 描述 + +通过 `SHOW COLUMN STATS` 来查看列的各项统计数据。 + +语法如下: + +```SQL +SHOW COLUMN [cached] STATS table_name [ (column_name [, ...]) ]; +``` + +其中: + +- cached: 展示当前 FE 内存缓存中的统计信息。 +- table_name: 收集统计信息的目标表。可以是  `db_name.table_name`  形式。 +- column_name: 指定的目标列,必须是  `table_name`  中存在的列,多个列名称用逗号分隔。 + +下面是一个例子: + +```sql +mysql> show column stats lineitem(l_tax)\G; +*************************** 1. row *************************** + column_name: l_tax + count: 6001215.0 + ndv: 9.0 + num_null: 0.0 + data_size: 4.800972E7 +avg_size_byte: 8.0 + min: 0.00 + max: 0.08 + method: FULL + type: FUNDAMENTALS + trigger: MANUAL + query_times: 0 + updated_time: 2023-11-07 11:00:46 + +``` + +## 关键词 + +SHOW, COLUMN, STATS diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/SHOW-TABLE-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/SHOW-TABLE-STATS.md new file mode 100644 index 0000000000000..22779d9da485c --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/statistics/SHOW-TABLE-STATS.md @@ -0,0 +1,72 @@ +--- +{ + "title": "SHOW TABLE STATS", + "language": "zh-CN" +} +--- + + + + +### 描述 + +通过 `SHOW TABLE STATS` 查看表的统计信息收集概况。 + +语法如下: + +```SQL +SHOW TABLE STATS table_name; +``` + +其中: + +- table_name: 目标表表名。可以是  `db_name.table_name`  形式。 + +输出: + +| 列名 | 说明 | +| :------------------ | :--------------------- | +|`updated_rows`|自上次 ANALYZE 以来该表的更新行数| +|`query_times`|保留列,后续版本用以记录该表查询次数| +|`row_count`| 行数(不反映命令执行时的准确行数)| +|`updated_time`| 上次更新时间| +|`columns`| 收集过统计信息的列| +|`trigger`|触发方式| + +下面是一个例子: + +```sql +mysql> show table stats lineitem \G; +*************************** 1. row *************************** +updated_rows: 0 + query_times: 0 + row_count: 6001215 +updated_time: 2023-11-07 + columns: [l_returnflag, l_receiptdate, l_tax, l_shipmode, l_suppkey, l_shipdate, l_commitdate, l_partkey, l_orderkey, l_quantity, l_linestatus, l_comment, l_extendedprice, l_linenumber, l_discount, l_shipinstruct] + trigger: MANUAL +``` + +
+ +
+ +### 关键词 + +SHOW, TABLE, STATS diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/system-info-and-help/HELP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/system-info-and-help/HELP.md new file mode 100644 index 0000000000000..284dea62b7754 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/system-info-and-help/HELP.md @@ -0,0 +1,108 @@ +--- +{ + "title": "HELP", + "language": "zh-CN" +} +--- + + + + +## 描述 + +通过改命令可以查询到帮助的目录 + +语法: + +``` sql +HELP +``` + +可以通过 `help` 列出所有的 Doris 命令 + +```sql +List of all MySQL commands: +Note that all text commands must be first on line and end with ';' +? (\?) Synonym for `help'. +clear (\c) Clear the current input statement. +connect (\r) Reconnect to the server. Optional arguments are db and host. +delimiter (\d) Set statement delimiter. +edit (\e) Edit command with $EDITOR. +ego (\G) Send command to mysql server, display result vertically. +exit (\q) Exit mysql. Same as quit. +go (\g) Send command to mysql server. +help (\h) Display this help. +nopager (\n) Disable pager, print to stdout. +notee (\t) Don't write into outfile. +pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. +print (\p) Print current command. +prompt (\R) Change your mysql prompt. +quit (\q) Quit mysql. +rehash (\#) Rebuild completion hash. +source (\.) Execute an SQL script file. Takes a file name as an argument. +status (\s) Get status information from the server. +system (\!) Execute a system shell command. +tee (\T) Set outfile [to_outfile]. Append everything into given outfile. +use (\u) Use another database. Takes database name as argument. +charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. +warnings (\W) Show warnings after every statement. +nowarning (\w) Don't show warnings after every statement. +resetconnection(\x) Clean session context. + +For server side help, type 'help contents' +``` + +通过 `help contents` 获取 Doris SQL 帮助目录 + +```sql +Many help items for your request exist. +To make a more specific request, please type 'help ', +where is one of the following +categories: + sql-functions + sql-statements +``` + +## 示例 + +1. 列出 Doris 所有的 SQL 帮助目录 + + ```sql + help contents + ``` + +2. 列出 Doris 集群所有函数目录的命令 + + ```sql + help sql-functions + ``` + +3. 列出日期函数下的所有函数列表 + + ```sql + help date-time-functions + ``` + +## 关键词 + + HELP + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/system-info-and-help/SHOW-PROC.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/system-info-and-help/SHOW-PROC.md new file mode 100644 index 0000000000000..b17224ca13c93 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/system-info-and-help/SHOW-PROC.md @@ -0,0 +1,274 @@ +--- +{ + "title": "SHOW PROC", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +Proc 系统是 Doris 的一个比较有特色的功能。使用过 Linux 的同学可能比较了解这个概念。在 Linux 系统中,proc 是一个虚拟的文件系统,通常挂载在 /proc 目录下。用户可以通过这个文件系统来查看系统内部的数据结构。比如可以通过 /proc/pid 查看指定 pid 进程的详细情况。 + +和 Linux 中的 proc 系统类似,Doris 中的 proc 系统也被组织成一个类似目录的结构,根据用户指定的“目录路径(proc 路径)”,来查看不同的系统信息。 + +proc 系统被设计为主要面向系统管理人员,方便其查看系统内部的一些运行状态。如表的 tablet 状态、集群均衡状态、各种作业的状态等等。是一个非常实用的功能 + +Doris 中有两种方式可以查看 proc 系统。 + +1. 通过 Doris 提供的 WEB UI 界面查看,访问地址:`http://FE_IP:FE_HTTP_PORT` +2. 另外一种方式是通过命令 + +通过 ` SHOW PROC "/";` 可看到 Doris PROC 支持的所有命令 + +通过 MySQL 客户端连接 Doris 后,可以执行 SHOW PROC 语句查看指定 proc 目录的信息。proc 目录是以 "/" 开头的绝对路径。 + +show proc 语句的结果以二维表的形式展现。而通常结果表的第一列的值为 proc 的下一级子目录。 + +```sql +mysql> show proc "/"; ++---------------------------+ +| name | ++---------------------------+ +| auth | +| backends | +| bdbje | +| brokers | +| catalogs | +| cluster_balance | +| cluster_health | +| colocation_group | +| current_backend_instances | +| current_queries | +| current_query_stmts | +| dbs | +| diagnose | +| frontends | +| jobs | +| load_error_hub | +| monitor | +| resources | +| routine_loads | +| statistic | +| stream_loads | +| tasks | +| transactions | +| trash | ++---------------------------+ +23 rows in set (0.00 sec) +``` + +说明: + +1. auth:用户名称及对应的权限信息 +2. backends:显示集群中 BE 的节点列表,等同于 [SHOW BACKENDS](./SHOW-BACKENDS.md) +3. bdbje:查看 bdbje 数据库列表,需要修改 `fe.conf` 文件增加 `enable_bdbje_debug_mode=true` , 然后通过 `sh start_fe.sh --daemon` 启动 `FE` 即可进入 `debug` 模式。进入 `debug` 模式之后,仅会启动 `http server` 和 `MySQLServer` 并打开 `BDBJE` 实例,但不会进入任何元数据的加载及后续其他启动流程, +4. brokers : 查看集群 Broker 节点信息,等同于 [SHOW BROKER](./SHOW-BROKER.md) +5. catalogs : 查看当前已创建的数据目录,等同于 [SHOW CATALOGS](./SHOW-CATALOGS.md) +6. cluster_balance:查看集群均衡情况,具体参照 [数据副本管理](../../../admin-manual/maint-monitor/tablet-repair-and-balance.md) +7. cluster_health : 通过 SHOW PROC '/cluster_health/tablet_health'; 命令可以查看整个集群的副本状态。 +8. colocation_group : 该命令可以查看集群内已存在的 Group 信息,具体可以查看 [Colocation Join](../../../query-acceleration/join-optimization/colocation-join.md) 章节 +9. current_backend_instances:显示当前正在执行作业的 be 节点列表 +10. current_queries : 查看正在执行的查询列表,当前正在运行的 SQL 语句。 +11. current_query_stmts : 返回当前正在执行的 query。 +12. dbs:主要用于查看 Doris 集群中各个数据库以及其中的表的元数据信息。这些信息包括表结构、分区、物化视图、数据分片和副本等等。通过这个目录和其子目录,可以清楚的展示集群中的表元数据情况,以及定位一些如数据倾斜、副本故障等问题 +13. diagnose : 报告和诊断集群中的常见管控问题,主要包括副本均衡和迁移、事务异常等 +14. frontends:显示集群中所有的 FE 节点信息,包括 IP 地址、角色、状态、是否是 master 等,等同于 [SHOW FRONTENDS](./SHOW-FRONTENDS.md) +15. jobs:各类任务的统计信息,可查看指定数据库的 Job 的统计信息,如果 `dbId` = -1, 则返回所有库的汇总信息 +16. load_error_hub:Doris 支持将 load 作业产生的错误信息集中存储到一个 error hub 中。然后直接通过 SHOW LOAD WARNINGS; 语句查看错误信息。这里展示的就是 error hub 的配置信息。 +17. monitor : 显示的是 FE JVM 的资源使用情况 +18. resources : 查看系统资源,普通账户只能看到自己有 USAGE_PRIV 使用权限的资源。只有 root 和 admin 账户可以看到所有的资源。等同于 [SHOW RESOURCES](./SHOW-RESOURCES.md) +19. routine_loads:显示所有的 routine load 作业信息,包括作业名称、状态等 +20. statistics:主要用于汇总查看 Doris 集群中数据库、表、分区、分片、副本的数量。以及不健康副本的数量。这个信息有助于我们总体把控集群元信息的规模。帮助我们从整体视角查看集群分片情况,能够快速查看集群分片的健康情况。从而进一步定位有问题的数据分片。 +21. stream_loads : 返回当前正在执行的 stream load 任务。 +22. tasks : 显示现在各种作业的任务总量,及失败的数量。 +23. transactions:用于查看指定 transaction id 的事务详情,等同于 [SHOW TRANSACTION](./SHOW-TRANSACTION.md) +24. trash:该语句用于查看 backend 内的垃圾数据占用空间。等同于 [SHOW TRASH](./SHOW-TRASH.md) + +## 示例 + +1. 如 "/dbs" 展示所有数据库,而 "/dbs/10002" 展示 id 为 10002 的数据库下的所有表 + + ```sql + mysql> show proc "/dbs/10002"; + +---------+----------------------+----------+---------------------+--------------+--------+------+--------------------------+--------------+ + | TableId | TableName | IndexNum | PartitionColumnName | PartitionNum | State | Type | LastConsistencyCheckTime | ReplicaCount | + +---------+----------------------+----------+---------------------+--------------+--------+------+--------------------------+--------------+ + | 10065 | dwd_product_live | 1 | dt | 9 | NORMAL | OLAP | NULL | 18 | + | 10109 | ODS_MR_BILL_COSTS_DO | 1 | NULL | 1 | NORMAL | OLAP | NULL | 1 | + | 10119 | test | 1 | NULL | 1 | NORMAL | OLAP | NULL | 1 | + | 10124 | test_parquet_import | 1 | NULL | 1 | NORMAL | OLAP | NULL | 1 | + +---------+----------------------+----------+---------------------+--------------+--------+------+--------------------------+--------------+ + 4 rows in set (0.00 sec) + ``` + +2. 展示集群中所有库表个数相关的信息。 + + ```sql + mysql> show proc '/statistic'; + +-------+----------------------+----------+--------------+----------+-----------+------------+ + | DbId | DbName | TableNum | PartitionNum | IndexNum | TabletNum | ReplicaNum | + +-------+----------------------+----------+--------------+----------+-----------+------------+ + | 10002 | default_cluster:test | 4 | 12 | 12 | 21 | 21 | + | Total | 1 | 4 | 12 | 12 | 21 | 21 | + +-------+----------------------+----------+--------------+----------+-----------+------------+ + 2 rows in set (0.00 sec) + ``` + +3. 以下命令可以查看集群内已存在的 Group 信息。 + + ```sql + SHOW PROC '/colocation_group'; + + +-------------+--------------+--------------+------------+----------------+----------+----------+ + | GroupId | GroupName | TableIds | BucketsNum | ReplicationNum | DistCols | IsStable | + +-------------+--------------+--------------+------------+----------------+----------+----------+ + | 10005.10008 | 10005_group1 | 10007, 10040 | 10 | 3 | int(11) | true | + +-------------+--------------+--------------+------------+----------------+----------+----------+ + ``` + + - GroupId:一个 Group 的全集群唯一标识,前半部分为 db id,后半部分为 group id。 + - GroupName:Group 的全名。 + - TabletIds:该 Group 包含的 Table 的 id 列表。 + - BucketsNum:分桶数。 + - ReplicationNum:副本数。 + - DistCols:Distribution columns,即分桶列类型。 + - IsStable:该 Group 是否稳定(稳定的定义,见 `Colocation 副本均衡和修复` 一节)。 + +4. 通过以下命令可以进一步查看一个 Group 的数据分布情况: + + ```sql + SHOW PROC '/colocation_group/10005.10008'; + + +-------------+---------------------+ + | BucketIndex | BackendIds | + +-------------+---------------------+ + | 0 | 10004, 10002, 10001 | + | 1 | 10003, 10002, 10004 | + | 2 | 10002, 10004, 10001 | + | 3 | 10003, 10002, 10004 | + | 4 | 10002, 10004, 10003 | + | 5 | 10003, 10002, 10001 | + | 6 | 10003, 10004, 10001 | + | 7 | 10003, 10004, 10002 | + +-------------+---------------------+ + ``` + + - BucketIndex:分桶序列的下标。 + - BackendIds:分桶中数据分片所在的 BE 节点 id 列表。 + +5. 显示现在各种作业的任务总量,及失败的数量。 + + ```sql + mysql> show proc '/tasks'; + +-------------------------+-----------+----------+ + | TaskType | FailedNum | TotalNum | + +-------------------------+-----------+----------+ + | CREATE | 0 | 0 | + | DROP | 0 | 0 | + | PUSH | 0 | 0 | + | CLONE | 0 | 0 | + | STORAGE_MEDIUM_MIGRATE | 0 | 0 | + | ROLLUP | 0 | 0 | + | SCHEMA_CHANGE | 0 | 0 | + | CANCEL_DELETE | 0 | 0 | + | MAKE_SNAPSHOT | 0 | 0 | + | RELEASE_SNAPSHOT | 0 | 0 | + | CHECK_CONSISTENCY | 0 | 0 | + | UPLOAD | 0 | 0 | + | DOWNLOAD | 0 | 0 | + | CLEAR_REMOTE_FILE | 0 | 0 | + | MOVE | 0 | 0 | + | REALTIME_PUSH | 0 | 0 | + | PUBLISH_VERSION | 0 | 0 | + | CLEAR_ALTER_TASK | 0 | 0 | + | CLEAR_TRANSACTION_TASK | 0 | 0 | + | RECOVER_TABLET | 0 | 0 | + | STREAM_LOAD | 0 | 0 | + | UPDATE_TABLET_META_INFO | 0 | 0 | + | ALTER | 0 | 0 | + | INSTALL_PLUGIN | 0 | 0 | + | UNINSTALL_PLUGIN | 0 | 0 | + | Total | 0 | 0 | + +-------------------------+-----------+----------+ + 26 rows in set (0.01 sec) + ``` + +6. 显示整个集群的副本状态。 + + ```sql + mysql> show proc '/cluster_health/tablet_health'; + +----------+---------------------------+-----------+------------+-------------------+----------------------+----------------------+--------------+----------------------------+-------------------------+-------------------+---------------------+----------------------+----------------------+------------------+-----------------------------+-----------------+-------------+------------+ + | DbId | DbName | TabletNum | HealthyNum | ReplicaMissingNum | VersionIncompleteNum | ReplicaRelocatingNum | RedundantNum | ReplicaMissingInClusterNum | ReplicaMissingForTagNum | ForceRedundantNum | ColocateMismatchNum | ColocateRedundantNum | NeedFurtherRepairNum | UnrecoverableNum | ReplicaCompactionTooSlowNum | InconsistentNum | OversizeNum | CloningNum | + +----------+---------------------------+-----------+------------+-------------------+----------------------+----------------------+--------------+----------------------------+-------------------------+-------------------+---------------------+----------------------+----------------------+------------------+-----------------------------+-----------------+-------------+------------+ + | 25852112 | default_cluster:bowen | 1920 | 1920 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | + | 25342914 | default_cluster:bw | 128 | 128 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | + | 2575532 | default_cluster:cps | 1440 | 1440 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 16 | 0 | + | 26150325 | default_cluster:db | 38374 | 38374 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 453 | 0 | + +----------+---------------------------+-----------+------------+-------------------+----------------------+----------------------+--------------+----------------------------+-------------------------+-------------------+---------------------+----------------------+----------------------+------------------+-----------------------------+-----------------+-------------+------------+ + 4 rows in set (0.01 sec) + ``` + + 查看某个数据库下面的副本状态,如 DbId 为 25852112 的数据库。 + + ```sql + mysql> show proc '/cluster_health/tablet_health/25852112'; + ``` + +7. 报告和诊断集群管控问题 + + ``` + MySQL > show proc "/diagnose"; + +-----------------+----------+------------+ + | Item | ErrorNum | WarningNum | + +-----------------+----------+------------+ + | cluster_balance | 2 | 0 | + | Total | 2 | 0 | + +-----------------+----------+------------+ + + 2 rows in set + ``` + + 查看副本均衡迁移问题 + + ```sql + MySQL > show proc "/diagnose/cluster_balance"; + +-----------------------+--------+-------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+------------+ + | Item | Status | Content | Detail Cmd | Suggestion | + +-----------------------+--------+-------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+------------+ + | Tablet Health | ERROR | healthy tablet num 691 < total tablet num 1014 | show proc "/cluster_health/tablet_health"; | | + | BeLoad Balance | ERROR | backend load not balance for tag {"location" : "default"}, low load backends [], high load backends [10009] | show proc "/cluster_balance/cluster_load_stat/location_default/HDD" | | + | Disk Balance | OK | | | | + | Colocate Group Stable | OK | | | | + | History Tablet Sched | OK | | | | + +-----------------------+--------+-------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+------------+ + + 5 rows in set + ``` + +## 关键词 + + SHOW, PROC + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/CANCEL-REBALANCE-DISK.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/CANCEL-REBALANCE-DISK.md new file mode 100644 index 0000000000000..6e0e49f043da1 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/CANCEL-REBALANCE-DISK.md @@ -0,0 +1,56 @@ +--- +{ + "title": "CANCEL REBALANCE DISK", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于取消优先均衡 BE 的磁盘 + +语法: + +ADMIN CANCEL REBALANCE DISK [ON ("BackendHost1:BackendHeartBeatPort1", "BackendHost2:BackendHeartBeatPort2", ...)]; + +说明: + +1. 该语句仅表示系统不再优先均衡指定 BE 的磁盘数据。系统仍会以默认调度方式均衡 BE 的磁盘数据。 + +## 示例 + +1. 取消集群所有 BE 的优先磁盘均衡 + + ADMIN CANCEL REBALANCE DISK; + +2. 取消指定 BE 的优先磁盘均衡 + + ADMIN CANCEL REBALANCE DISK ON ("192.168.1.1:1234", "192.168.1.2:1234"); + +## 关键词 + + ADMIN,CANCEL,REBALANCE,DISK + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/CANCEL-REPAIR.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/CANCEL-REPAIR.md new file mode 100644 index 0000000000000..436ee2a115bc5 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/CANCEL-REPAIR.md @@ -0,0 +1,58 @@ +--- +{ + "title": "CANCEL REPAIR", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于取消以高优先级修复指定表或分区 + +语法: + +```sql +ADMIN CANCEL REPAIR TABLE table_name[ PARTITION (p1,...)]; +``` + +说明: + +1. 该语句仅表示系统不再以高优先级修复指定表或分区的分片副本。系统仍会以默认调度方式修复副本。 + +## 示例 + + 1. 取消高优先级修复 + + ```sql + ADMIN CANCEL REPAIR TABLE tbl PARTITION(p1); + ``` + +## 关键词 + + ADMIN, CANCEL, REPAIR + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/CHECK-TABLET.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/CHECK-TABLET.md new file mode 100644 index 0000000000000..2e83e63e2e45d --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/CHECK-TABLET.md @@ -0,0 +1,61 @@ +--- +{ + "title": "CHECK TABLET", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于对一组 tablet 执行指定的检查操作 + +语法: + +```sql +ADMIN CHECK TABLET (tablet_id1, tablet_id2, ...) +PROPERTIES("type" = "..."); +``` + +说明: + +1. 必须指定 tablet id 列表以及 PROPERTIES 中的 type 属性。 +2. 目前 type 仅支持: + + * consistency: 对 tablet 的副本数据一致性进行检查。该命令为异步命令,发送后,Doris 会开始执行对应 tablet 的一致性检查作业。最终的结果,将体现在 `SHOW PROC "/cluster_health/tablet_health";` 结果中的 InconsistentTabletNum 列。 + +## 示例 + +1. 对指定的一组 tablet 进行副本数据一致性检查 + + ``` + ADMIN CHECK TABLET (10000, 10001) + PROPERTIES("type" = "consistency"); + +## 关键词 + + ADMIN, CHECK, TABLET + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/CLEAN-TRASH.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/CLEAN-TRASH.md new file mode 100644 index 0000000000000..1a7d4aafe4169 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/CLEAN-TRASH.md @@ -0,0 +1,61 @@ +--- +{ + "title": "CLEAN TRASH", + "language": "zh-CN" +} + +--- + + + + + + + +## 描述 + +该语句用于清理 backend 内的垃圾数据 + +语法: + +```sql +ADMIN CLEAN TRASH [ON ("BackendHost1:BackendHeartBeatPort1", "BackendHost2:BackendHeartBeatPort2", ...)]; +``` + +说明: + +1. 以 BackendHost:BackendHeartBeatPort 表示需要清理的 backend,不添加 on 限定则清理所有 backend。 + +## 示例 + +1. 清理所有 be 节点的垃圾数据。 + + ADMIN CLEAN TRASH; + +2. 清理'192.168.0.1:9050'和'192.168.0.2:9050'的垃圾数据。 + + ADMIN CLEAN TRASH ON ("192.168.0.1:9050","192.168.0.2:9050"); + +## 关键词 + + ADMIN, CLEAN, TRASH + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/COMPACT-TABLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/COMPACT-TABLE.md new file mode 100644 index 0000000000000..4278e646b1283 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/COMPACT-TABLE.md @@ -0,0 +1,79 @@ +--- +{ + "title": "COMPACT TABLE", + "language": "zh-CN" +} + +--- + + + + +## 描述 + +存算一体模式中,用于对指定表分区下的所有副本触发一次 Compaction。 + +存算分离模式不支持这个命令。 + +## 语法 + +```sql +ADMIN COMPACT TABLE +PARTITION +WHERE TYPE={ BASE | CUMULATIVE } +``` + +## 必选参数 + +1. `` :待触发 Compaction 的表名 + +2. ``:待触发 Compaction 的表名 + +3. `TYPE={ BASE | CUMULATIVE }` : 其中 BASE 是指触发 Base Compaction,CUMULATIVE 是指触发 Cumulative Compaction,具体可以参考 COMPACTION 章节 + +## 权限控制 + +执行此 SQL 命令成功的前置条件是,拥有 ADMIN_PRIV 权限,参考权限文档。 + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +| :---------------- | :--------------- | :-------------------------- | +| ADMIN_PRIV | 整个集群管理权限 | 除 NODE_PRIV 以外的所有权限 | + +## 示例 + +1. 触发表 tbl 分区 par01 的 cumulative compaction。 + + ```sql + ADMIN COMPACT TABLE tbl PARTITION par01 WHERE TYPE='CUMULATIVE'; + ``` + +## 注意事项(Usage Note) + +1. 存算分离模式不支持这个命令,在此模式下执行会报错,例如: + + ```sql + ADMIN COMPACT TABLE tbl PARTITION par01 WHERE TYPE='CUMULATIVE'; + ``` + + 报错信息如下: + + ```sql + ERROR 1105 (HY000): errCode = 2, detailMessage = Unsupported operation + ``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/COPY-TABLET.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/COPY-TABLET.md new file mode 100644 index 0000000000000..9070d06b420dd --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/COPY-TABLET.md @@ -0,0 +1,97 @@ +--- +{ + "title": "COPY TABLET", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于为指定的 tablet 制作快照,主要用于本地加载 tablet 来复现问题。 + +语法: + +```sql +ADMIN COPY TABLET tablet_id PROPERTIES("xxx"); +``` + +说明: + +该命令需要 ROOT 权限。 + +PROPERTIES 支持如下属性: + +1. backend_id:指定副本所在的 BE 节点的 id。如果不指定,则随机选择一个副本。 + +2. version:指定快照的版本。该版本需小于等于副本的最大版本。如不指定,则使用最大版本。 + +3. expiration_minutes:快照保留时长。默认为 1 小时。超时后会自动清理。单位分钟。 + +结果展示如下: + +``` + TabletId: 10020 + BackendId: 10003 + Ip: 192.168.10.1 + Path: /path/to/be/storage/snapshot/20220830101353.2.3600 +ExpirationMinutes: 60 + CreateTableStmt: CREATE TABLE `tbl1` ( + `k1` int(11) NULL, + `k2` int(11) NULL +) ENGINE=OLAP +DUPLICATE KEY(`k1`, `k2`) +DISTRIBUTED BY HASH(k1) BUCKETS 1 +PROPERTIES ( +"replication_num" = "1", +"version_info" = "2" +); +``` + +* TabletId: tablet id +* BackendId: BE 节点 id +* Ip: BE 节点 ip +* Path: 快照所在目录 +* ExpirationMinutes: 快照过期时间 +* CreateTableStmt: tablet 对应的表的建表语句。该语句不是原始的建表语句,而是用于之后本地加载 tablet 的简化后的建表语句。 + +## 示例 + +1. 对指定 BE 节点上的副本做快照 + + ```sql + ADMIN COPY TABLET 10010 PROPERTIES("backend_id" = "10001"); + ``` + +2. 对指定 BE 节点上的副本,做指定版本的快照 + + ```sql + ADMIN COPY TABLET 10010 PROPERTIES("backend_id" = "10001", "version" = "10"); + ``` + +## 关键词 + + ADMIN, COPY, TABLET + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/DIAGNOSE-TABLET.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/DIAGNOSE-TABLET.md new file mode 100644 index 0000000000000..73251788d8618 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/DIAGNOSE-TABLET.md @@ -0,0 +1,115 @@ +--- +{ + "title": "DIAGNOSE TABLET", + "language": "zh-CN" +} +--- + + + +## 描述 + +存算一体模式中,该语句用于诊断指定 tablet。结果中将显示这个 tablet 的信息和一些潜在的问题。 + +存算分离模式不支持这个命令。 + +## 语法 + +```sql +SHOW TABLET DIAGNOSIS ; +``` + +## 必选参数 + +1. ``: 待诊断 tablet 的 id + +## 返回值 + +返回 tablet 相关信息 + +- `TabletExist`: Tablet 是否存在 + +- `TabletId` : Tablet ID + +- `Database`: Tablet 所属 DB 和其 ID + +- `Table`: Tablet 所属 Table 和其 ID + +- `Partition`: Tablet 所属 Partition 和其 ID + +- `MaterializedIndex`: Tablet 所属物化视图和其 ID + +- `Replicas`: Tablet 各副本和其所在 BE + +- `ReplicasNum`: 副本数量是否正确 + +- `ReplicaBackendStatus`: 副本所在 BE 节点是否正常 + +- `ReplicaVersionStatus`: 副本的版本号是否正常 + +- `ReplicaStatus`: 副本状态是否正常 + +- `ReplicaCompactionStatus`: 副本 Compaction 状态是否正常 + +## 示例 + +1. 诊断指定 tablet id 为 10078 的 tablet 信息 + + ```sql + show tablet diagnosis 10078; + +----------------------------------+---------------------------------------------+------------+ + | Item | Info | Suggestion | + +----------------------------------+---------------------------------------------+------------+ + | TabletExist | Yes | | + | TabletId | 10078 | | + | Database | __internal_schema: 10005 | | + | Table | audit_log: 10058 | | + | Partition | p20241109: 10075 | | + | MaterializedIndex | audit_log: 10059 | | + | Replicas(ReplicaId -> BackendId) | {"10099":10003,"10116":10002,"10079":10004} | | + | ReplicasNum | OK | | + | ReplicaBackendStatus | OK | | + | ReplicaVersionStatus | OK | | + | ReplicaStatus | OK | | + | ReplicaCompactionStatus | OK | | + +----------------------------------+---------------------------------------------+------------+ + ``` + +## 权限控制 + +执行此 SQL 命令成功的前置条件是,拥有 ADMIN_PRIV 权限,参考权限文档。 + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +| :---------------- | :--------------- | :-------------------------- | +| ADMIN_PRIV | 整个集群管理权限 | 除 NODE_PRIV 以外的所有权限 | + +## 注意事项 + +1. 存算分离模式不支持这个命令,在此模式下执行会报错,例如: + + ```sql + show tablet diagnosis 15177; + ``` + + 报错信息如下: + + ```sql + ERROR 1105 (HY000): errCode = 2, detailMessage = Unsupported operation + ``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/REBALANCE-DISK.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/REBALANCE-DISK.md new file mode 100644 index 0000000000000..96ffdb2d4b0f0 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/REBALANCE-DISK.md @@ -0,0 +1,62 @@ +--- +{ + "title": "REBALANCE DISK", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于尝试优先均衡指定的 BE 磁盘数据 + +语法: + + ``` + ADMIN REBALANCE DISK [ON ("BackendHost1:BackendHeartBeatPort1", "BackendHost2:BackendHeartBeatPort2", ...)]; + ``` + +说明: + + 1. 该语句表示让系统尝试优先均衡指定 BE 的磁盘数据,不受限于集群是否均衡。 + 2. 默认的 timeout 是 24 小时。超时意味着系统将不再优先均衡指定的 BE 磁盘数据。需要重新使用该命令设置。 + 3. 指定 BE 的磁盘数据均衡后,该 BE 的优先级将会失效。 + +## 示例 + +1. 尝试优先均衡集群内的所有 BE + + ``` + ADMIN REBALANCE DISK; + ``` + +2. 尝试优先均衡指定 BE + + ``` + ADMIN REBALANCE DISK ON ("192.168.1.1:1234", "192.168.1.2:1234"); + ``` + +## 关键词 + + ADMIN,REBALANCE,DISK + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/REPAIR-TABLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/REPAIR-TABLE.md new file mode 100644 index 0000000000000..1bcde56584a2c --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/REPAIR-TABLE.md @@ -0,0 +1,59 @@ +--- +{ + "title": "REPAIR TABLE", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +语句用于尝试优先修复指定的表或分区 + +语法: + +```sql +ADMIN REPAIR TABLE table_name[ PARTITION (p1,...)] +``` + +说明: + +1. 该语句仅表示让系统尝试以高优先级修复指定表或分区的分片副本,并不保证能够修复成功。用户可以通过 `SHOW REPLICA STATUS` 命令查看修复情况。 +2. 默认的 timeout 是 14400 秒 (4 小时)。超时意味着系统将不再以高优先级修复指定表或分区的分片副本。需要重新使用该命令设置 + +## 示例 + +1. 尝试修复指定表 + + ADMIN REPAIR TABLE tbl1; + +2. 尝试修复指定分区 + + ADMIN REPAIR TABLE tbl1 PARTITION (p1, p2); + +## 关键词 + + ADMIN, REPAIR, TABLE + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-REPLICA-STATUS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-REPLICA-STATUS.md new file mode 100644 index 0000000000000..c7292061e9219 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-REPLICA-STATUS.md @@ -0,0 +1,81 @@ +--- +{ + "title": "SET REPLICA STATUS", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于设置指定副本的状态。 + +该命令目前仅用于手动将某些副本状态设置为 BAD、DROP 和 OK,从而使得系统能够自动修复这些副本 + +语法: + +```sql +ADMIN SET REPLICA STATUS + PROPERTIES ("key" = "value", ...); +``` + + 目前支持如下属性: + +1. "tablet_id":必需。指定一个 Tablet Id. +2. "backend_id":必需。指定 Backend Id. +3. "status":必需。指定状态。当前仅支持 "drop"、"bad"、 "ok" + +如果指定的副本不存在,或状态已经是 bad,则会被忽略。 + +> 注意: +> +> 设置为 Bad 状态的副本,它将不能读写。另外,设置 Bad 有时是不生效的。如果该副本实际数据是正确的,当 BE 上报该副本状态是 ok 的,fe 将把副本自动恢复回 ok 状态。操作可能立刻删除该副本,请谨慎操作。 +> +> 设置为 Drop 状态的副本,它仍然可以读写。会在其他机器先增加一个健康副本,再删除该副本。相比设置 Bad,设置 Drop 的操作是安全的。 + +## 示例 + + 1. 设置 tablet 10003 在 BE 10001 上的副本状态为 bad。 + +```sql +ADMIN SET REPLICA STATUS PROPERTIES("tablet_id" = "10003", "backend_id" = "10001", "status" = "bad"); +``` + + 2. 设置 tablet 10003 在 BE 10001 上的副本状态为 drop。 + +```sql +ADMIN SET REPLICA STATUS PROPERTIES("tablet_id" = "10003", "backend_id" = "10001", "status" = "drop"); +``` + + 3. 设置 tablet 10003 在 BE 10001 上的副本状态为 ok。 + +```sql +ADMIN SET REPLICA STATUS PROPERTIES("tablet_id" = "10003", "backend_id" = "10001", "status" = "ok"); +``` + +## 关键词 + + ADMIN, SET, REPLICA, STATUS + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-REPLICA-VERSION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-REPLICA-VERSION.md new file mode 100644 index 0000000000000..374abf3934ef0 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-REPLICA-VERSION.md @@ -0,0 +1,80 @@ +--- +{ + "title": "SET REPLICA VERSION", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句用于设置指定副本的版本、最大成功版本、最大失败版本。 + +该命令目前仅用于在程序异常情况下,手动修复副本的版本,从而使得副本从异常状态恢复过来。 + +语法: + +```sql +ADMIN SET REPLICA VERSION + PROPERTIES ("key" = "value", ...); +``` + + 目前支持如下属性: + +1. `tablet_id`:必需。指定一个 Tablet Id. +2. `backend_id`:必需。指定 Backend Id. +3. `version`:可选。设置副本的版本。 +4. `last_success_version`:可选。设置副本的最大成功版本。 +5. `last_failed_version`:可选。设置副本的最大失败版本。 + + +如果指定的副本不存在,则会被忽略。 + +> 注意: +> +> 修改这几个数值,可能会导致后面数据读写失败,造成数据不一致,请谨慎操作! +> +> 修改之前先记录原来的值。修改完毕之后,对表进行读写验证,如果读写失败,请恢复原来的值!但可能会恢复失败! +> +> 严禁对正在写入数据的 tablet 进行操作! + + +## 示例 + + 1. 清除 tablet 10003 在 BE 10001 上的副本状态失败标志。 + +```sql +ADMIN SET REPLICA VERSION PROPERTIES("tablet_id" = "10003", "backend_id" = "10001", "last_failed_version" = "-1"); +``` + +2. 设置 tablet 10003 在 BE 10001 上的副本版本号为 1004。 + +```sql +ADMIN SET REPLICA VERSION PROPERTIES("tablet_id" = "10003", "backend_id" = "10001", "version" = "1004"); +``` + +## 关键词 + + ADMIN, SET, REPLICA, VERSION + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-TABLE-PARTITION-VERSION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-TABLE-PARTITION-VERSION.md new file mode 100644 index 0000000000000..1f659023b11d6 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-TABLE-PARTITION-VERSION.md @@ -0,0 +1,58 @@ +--- +{ + "title": "SET TABLE PARTITION VERSION", + "language": "zh-CN" +} +--- + + + + +## 描述 + +存算一体模式,该语句用于手动改变指定分区的可见版本。在某些特殊情况下,元数据中分区的版本有可能和实际副本的版本不一致。该命令可手动改变元数据中分区的版本。此命令一般只用于紧急故障修复,请谨慎操作。 + +## 语法 + +```sql +ADMIN SET TABLE PARTITION VERSION PROPERTIES ("" = "visible_version>"); +``` + +## 必选参数 + +1. ``: 待设置的表名 + +2. ``: 指定一个 Partition Id + +3. ``: 指定 Version + +## 示例 + +1. 设置 partition_id 为 10075 的分区在 FE 元数据上的版本为 100 + + ```sql + ADMIN SET TABLE __internal_schema.audit_log PARTITION VERSION PROPERTIES("partition_id" = "10075", "visible_version" = "100"); + ``` + +## 注意事项 + +1. 设置分区的版本需要先确认 BE 机器上实际副本的版本,此命令一般只用于紧急故障修复,请谨慎操作。 + +2. 存算分离模式不支持这个命令,设置了不会生效 \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-TABLE-STATUS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-TABLE-STATUS.md new file mode 100644 index 0000000000000..ef911204cbd6c --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SET-TABLE-STATUS.md @@ -0,0 +1,82 @@ +--- +{ + "title": "SET TABLE STATUS", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于设置指定表的状态,仅支持 OLAP 表。 + +该命令目前仅用于手动将 OLAP 表状态设置为指定状态,从而使得某些由于表状态被阻碍的任务能够继续运行。 + +语法: + +```sql +ADMIN SET TABLE table_name STATUS + PROPERTIES ("key" = "value", ...); +``` + +目前支持以下属性: + +1. "state":必需。指定一个目标状态,将会修改 OLAP 表的状态至此状态。 + +> 当前可修改的目标状态包括: +> +> 1. NORMAL +> 2. ROLLUP +> 3. SCHEMA_CHANGE +> 4. BACKUP +> 5. RESTORE +> 6. WAITING_STABLE +> +> 如果表的状态已经是指定的状态,则会被忽略。 + +**注意:此命令一般只用于紧急故障修复,请谨慎操作。** + +## 示例 + +1. 设置表 tbl1 的状态为 NORMAL。 + +```sql +admin set table tbl1 status properties("state" = "NORMAL"); +``` + +2. 设置表 tbl2 的状态为 SCHEMA_CHANGE。 + +```sql +admin set table test_set_table_status status properties("state" = "SCHEMA_CHANGE"); +``` + +## 关键词 + + ADMIN, SET, TABLE, STATUS + +### 最佳实践 + + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-DATA-SKEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-DATA-SKEW.md new file mode 100644 index 0000000000000..8f29d62f21396 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-DATA-SKEW.md @@ -0,0 +1,158 @@ +--- +{ +"title": "SHOW DATA SKEW", +"language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于查看表或某个分区的数据倾斜情况。 + +语法: + +SHOW DATA SKEW FROM [db_name.]tbl_name [PARTITION (partition_name, ...)]; + +说明: + +1. 结果将展示指定分区下,各个分桶的数据行数,数据量,以及每个分桶数据量在总数据量中的占比。 +2. 对于非分区表,查询结果中分区名称同表名。 + +## 示例 + +1. 分区表场景 + +* 建表语句 + ```sql + CREATE TABLE test_show_data_skew + ( + id int, + name string, + pdate date + ) + PARTITION BY RANGE(pdate) + ( + FROM ("2023-04-16") TO ("2023-04-20") INTERVAL 1 DAY + ) + DISTRIBUTED BY HASH(id) BUCKETS 5 + PROPERTIES ( + "replication_num" = "1" + ); + ``` +* 查询整表的数据倾斜情况 + ```sql + mysql> SHOW DATA SKEW FROM test_show_data_skew; + +---------------+-----------+-------------+-------------+------------------------------------------------------------------------------------------------------+---------+ + | PartitionName | BucketIdx | AvgRowCount | AvgDataSize | Graph | Percent | + +---------------+-----------+-------------+-------------+------------------------------------------------------------------------------------------------------+---------+ + | p_20230416 | 0 | 1 | 648 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 49.77 % | + | p_20230416 | 1 | 2 | 654 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 50.23 % | + | p_20230416 | 2 | 0 | 0 | | 00.00 % | + | p_20230416 | 3 | 0 | 0 | | 00.00 % | + | p_20230416 | 4 | 0 | 0 | | 00.00 % | + | p_20230417 | 0 | 0 | 0 | | 00.00 % | + | p_20230417 | 1 | 0 | 0 | | 00.00 % | + | p_20230417 | 2 | 0 | 0 | | 00.00 % | + | p_20230417 | 3 | 0 | 0 | | 00.00 % | + | p_20230417 | 4 | 2 | 656 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 100.00% | + | p_20230418 | 0 | 0 | 0 | | 00.00 % | + | p_20230418 | 1 | 1 | 648 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 100.00% | + | p_20230418 | 2 | 0 | 0 | | 00.00 % | + | p_20230418 | 3 | 0 | 0 | | 00.00 % | + | p_20230418 | 4 | 0 | 0 | | 00.00 % | + | p_20230419 | 0 | 0 | 0 | | 00.00 % | + | p_20230419 | 1 | 1 | 648 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 49.96 % | + | p_20230419 | 2 | 0 | 0 | | 00.00 % | + | p_20230419 | 3 | 1 | 649 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 50.04 % | + | p_20230419 | 4 | 0 | 0 | | 00.00 % | + +---------------+-----------+-------------+-------------+------------------------------------------------------------------------------------------------------+---------+ + ``` +* 查询指定分区的数据倾斜情况 + ```sql + mysql> SHOW DATA SKEW FROM test_show_data_skew PARTITION(p_20230416, p_20230418); + +---------------+-----------+-------------+-------------+------------------------------------------------------------------------------------------------------+---------+ + | PartitionName | BucketIdx | AvgRowCount | AvgDataSize | Graph | Percent | + +---------------+-----------+-------------+-------------+------------------------------------------------------------------------------------------------------+---------+ + | p_20230416 | 0 | 1 | 648 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 49.77 % | + | p_20230416 | 1 | 2 | 654 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 50.23 % | + | p_20230416 | 2 | 0 | 0 | | 00.00 % | + | p_20230416 | 3 | 0 | 0 | | 00.00 % | + | p_20230416 | 4 | 0 | 0 | | 00.00 % | + | p_20230418 | 0 | 0 | 0 | | 00.00 % | + | p_20230418 | 1 | 1 | 648 | >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | 100.00% | + | p_20230418 | 2 | 0 | 0 | | 00.00 % | + | p_20230418 | 3 | 0 | 0 | | 00.00 % | + | p_20230418 | 4 | 0 | 0 | | 00.00 % | + +---------------+-----------+-------------+-------------+------------------------------------------------------------------------------------------------------+---------+ + ``` + +2. 非分区表场景 + +* 建表语句 + ```sql + CREATE TABLE test_show_data_skew2 + ( + id int, + name string, + pdate date + ) + DISTRIBUTED BY HASH(id) BUCKETS 5 + PROPERTIES ( + "replication_num" = "1" + ); + ``` +* 查询整表的数据倾斜情况 + ```sql + mysql> SHOW DATA SKEW FROM test_show_data_skew2; + +----------------------+-----------+-------------+-------------+---------------------------+---------+ + | PartitionName | BucketIdx | AvgRowCount | AvgDataSize | Graph | Percent | + +----------------------+-----------+-------------+-------------+---------------------------+---------+ + | test_show_data_skew2 | 0 | 1 | 648 | >>>>>>>>>>>>>>>>>>>>>>>> | 24.73 % | + | test_show_data_skew2 | 1 | 4 | 667 | >>>>>>>>>>>>>>>>>>>>>>>>> | 25.46 % | + | test_show_data_skew2 | 2 | 0 | 0 | | 00.00 % | + | test_show_data_skew2 | 3 | 1 | 649 | >>>>>>>>>>>>>>>>>>>>>>>> | 24.77 % | + | test_show_data_skew2 | 4 | 2 | 656 | >>>>>>>>>>>>>>>>>>>>>>>>> | 25.04 % | + +----------------------+-----------+-------------+-------------+---------------------------+---------+ + + + + mysql> SHOW DATA SKEW FROM test_show_data_skew2 PARTITION(test_show_data_skew2); + +----------------------+-----------+-------------+-------------+---------------------------+---------+ + | PartitionName | BucketIdx | AvgRowCount | AvgDataSize | Graph | Percent | + +----------------------+-----------+-------------+-------------+---------------------------+---------+ + | test_show_data_skew2 | 0 | 1 | 648 | >>>>>>>>>>>>>>>>>>>>>>>> | 24.73 % | + | test_show_data_skew2 | 1 | 4 | 667 | >>>>>>>>>>>>>>>>>>>>>>>>> | 25.46 % | + | test_show_data_skew2 | 2 | 0 | 0 | | 00.00 % | + | test_show_data_skew2 | 3 | 1 | 649 | >>>>>>>>>>>>>>>>>>>>>>>> | 24.77 % | + | test_show_data_skew2 | 4 | 2 | 656 | >>>>>>>>>>>>>>>>>>>>>>>>> | 25.04 % | + +----------------------+-----------+-------------+-------------+---------------------------+---------+ + ``` + +## 关键词 + + SHOW,DATA,SKEW + +### 最佳实践 \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-DATA.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-DATA.md new file mode 100644 index 0000000000000..1a46dfef222ec --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-DATA.md @@ -0,0 +1,138 @@ +--- +{ + "title": "SHOW DATA", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于展示数据量、副本数量以及统计行数。 + +语法: + +```sql +SHOW DATA [FROM [db_name.]table_name] [ORDER BY ...]; +``` + +说明: + +1. 如果不指定 FROM 子句,则展示当前 db 下细分到各个 table 的数据量和副本数量。其中数据量为所有副本的总数据量。而副本数量为表的所有分区以及所有物化视图的副本数量。 + +2. 如果指定 FROM 子句,则展示 table 下细分到各个物化视图的数据量、副本数量和统计行数。其中数据量为所有副本的总数据量。副本数量为对应物化视图的所有分区的副本数量。统计行数为对应物化视图的所有分区统计行数。 + +3. 统计行数时,以多个副本中,行数最大的那个副本为准。 + +4. 结果集中的 `Total` 行表示汇总行。`Quota` 行表示当前数据库设置的配额。`Left` 行表示剩余配额。 + +5. 如果想查看各个 Partition 的大小,请参阅 `help show partitions`。 + +6. 可以使用 ORDER BY 对任意列组合进行排序。 + +## 示例 + +1. 默认展示各个 db 的汇总数据量,RecycleBin 中的数据量 + + ``` + SHOW DATA; + ``` + + ``` + +-------+-----------------------------------+--------+------------+-------------+-------------------+ + | DbId | DbName | Size | RemoteSize | RecycleSize | RecycleRemoteSize | + +-------+-----------------------------------+--------+------------+-------------+-------------------+ + | 21009 | db1 | 0 | 0 | 0 | 0 | + | 22011 | regression_test_inverted_index_p0 | 72764 | 0 | 0 | 0 | + | 0 | information_schema | 0 | 0 | 0 | 0 | + | 22010 | regression_test | 0 | 0 | 0 | 0 | + | 1 | mysql | 0 | 0 | 0 | 0 | + | 22017 | regression_test_show_p0 | 0 | 0 | 0 | 0 | + | 10002 | __internal_schema | 46182 | 0 | 0 | 0 | + | Total | NULL | 118946 | 0 | 0 | 0 | + +-------+-----------------------------------+--------+------------+-------------+-------------------+ + ``` + +2. 展示特定 db 的各个 table 的数据量,副本数量,汇总数据量和汇总副本数量。 + + ```sql + USE db1; + SHOW DATA; + ``` + + ``` + +-----------+-------------+--------------+ + | TableName | Size | ReplicaCount | + +-----------+-------------+--------------+ + | tbl1 | 900.000 B | 6 | + | tbl2 | 500.000 B | 3 | + | Total | 1.400 KB | 9 | + | Quota | 1024.000 GB | 1073741824 | + | Left | 1021.921 GB | 1073741815 | + +-----------+-------------+--------------+ + ``` + +3. 展示指定 db 的下指定表的细分数据量、副本数量和统计行数 + + ```sql + SHOW DATA FROM example_db.test; + ``` + + ``` + +-----------+-----------+-----------+--------------+----------+ + | TableName | IndexName | Size | ReplicaCount | RowCount | + +-----------+-----------+-----------+--------------+----------+ + | test | r1 | 10.000MB | 30 | 10000 | + | | r2 | 20.000MB | 30 | 20000 | + | | test2 | 50.000MB | 30 | 50000 | + | | Total | 80.000 | 90 | | + +-----------+-----------+-----------+--------------+----------+ + ``` + +4. 可以按照数据量、副本数量、统计行数等进行组合排序 + + ```sql + SHOW DATA ORDER BY ReplicaCount desc,Size asc; + ``` + + ``` + +-----------+-------------+--------------+ + | TableName | Size | ReplicaCount | + +-----------+-------------+--------------+ + | table_c | 3.102 KB | 40 | + | table_d | .000 | 20 | + | table_b | 324.000 B | 20 | + | table_a | 1.266 KB | 10 | + | Total | 4.684 KB | 90 | + | Quota | 1024.000 GB | 1073741824 | + | Left | 1024.000 GB | 1073741734 | + +-----------+-------------+--------------+ + ``` + +## 关键词 + + SHOW, DATA + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-REPLICA-DISTRIBUTION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-REPLICA-DISTRIBUTION.md new file mode 100644 index 0000000000000..9d9ae063a8ad2 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-REPLICA-DISTRIBUTION.md @@ -0,0 +1,64 @@ +--- +{ + "title": "SHOW REPLICA DISTRIBUTION", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于展示一个表或分区副本分布状态 + +语法: + +```sql +SHOW REPLICA DISTRIBUTION FROM [db_name.]tbl_name [PARTITION (p1, ...)]; +``` + +说明: + +1. 结果中的 Graph 列以图形的形式展示副本分布比例 + +## 示例 + +1. 查看表的副本分布 + + ```sql + SHOW REPLICA DISTRIBUTION FROM tbl1; + ``` + + 2. 查看表的分区的副本分布 + + ```sql + SHOW REPLICA DISTRIBUTION FROM db1.tbl1 PARTITION(p1, p2); + ``` + +## 关键词 + + SHOW, REPLICA, DISTRIBUTION + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-REPLICA-STATUS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-REPLICA-STATUS.md new file mode 100644 index 0000000000000..5a57ed9e64896 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-REPLICA-STATUS.md @@ -0,0 +1,80 @@ +--- +{ + "title": "SHOW REPLICA STATUS", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于展示一个表或分区的副本状态信息。 + +语法: + +```sql +SHOW REPLICA STATUS FROM [db_name.]tbl_name [PARTITION (p1, ...)] +[where_clause]; +``` + +说明 + +1. where_clause: + WHERE STATUS [!]= "replica_status" + +2. replica_status: + OK: replica 处于健康状态 + DEAD: replica 所在 Backend 不可用 + VERSION_ERROR: replica 数据版本有缺失 + SCHEMA_ERROR: replica 的 schema hash 不正确 + MISSING: replica 不存在 + +## 示例 + +1. 查看表全部的副本状态 + + ```sql + SHOW REPLICA STATUS FROM db1.tbl1; + ``` + +2. 查看表某个分区状态为 VERSION_ERROR 的副本 + + ```sql + SHOW REPLICA STATUS FROM tbl1 PARTITION (p1, p2) + WHERE STATUS = "VERSION_ERROR"; + ``` + +3. 查看表所有状态不健康的副本 + + ```sql + SHOW REPLICA STATUS FROM tbl1 + WHERE STATUS != "OK"; + ``` + +## 关键词 + + SHOW, REPLICA, STATUS + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET-DIAGNOSIS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET-DIAGNOSIS.md new file mode 100644 index 0000000000000..aad34251bd05e --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET-DIAGNOSIS.md @@ -0,0 +1,58 @@ +--- +{ + "title": "SHOW TABLET DIAGNOSIS", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句用于诊断指定 tablet。结果中将显示这个 tablet 的信息和一些潜在的问题。 + +语法: + +SHOW TABLET DIAGNOSIS tablet_id + +说明: + +结果中的各行信息如下: +1. TabletExist: Tablet 是否存在 +2. TabletId: Tablet ID +3. Database: Tablet 所属 DB 和其 ID +4. Table: Tablet 所属 Table 和其 ID +5. Partition: Tablet 所属 Partition 和其 ID +6. MaterializedIndex: Tablet 所属物化视图和其 ID +7. Replicas(ReplicaId -> BackendId): Tablet 各副本和其所在 BE。 +8. ReplicasNum: 副本数量是否正确。 +9. ReplicaBackendStatus: 副本所在 BE 节点是否正常。 +10.ReplicaVersionStatus: 副本的版本号是否正常。 +11.ReplicaStatus: 副本状态是否正常。 +12.ReplicaCompactionStatus: 副本 Compaction 状态是否正常。 + +## 示例 + +1. 查看 Tablet 10001 的诊断结果 + + SHOW TABLET DIAGNOSIS 10001; + +## 关键词 + + SHOW, DIAGNOSIS, TABLET diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET-STORAGE-FORMAT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET-STORAGE-FORMAT.md new file mode 100644 index 0000000000000..b2c030165165e --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET-STORAGE-FORMAT.md @@ -0,0 +1,62 @@ +--- +{ + "title": "SHOW TABLET STORAGE FORMAT", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句用于显示 Backend 上的存储格式信息(仅管理员使用) + +### 语法 + +SHOW TABLET STORAGE FORMAT [VERBOSE] + +## 示例 + + ```sql + MySQL [(none)]> show tablet storage format; + +-----------+---------+---------+ + | BackendId | V1Count | V2Count | + +-----------+---------+---------+ + | 10002 | 0 | 2867 | + +-----------+---------+---------+ + 1 row in set (0.003 sec) + + MySQL [test_query_qa]> show tablet storage format verbose; + +-----------+----------+---------------+ + | BackendId | TabletId | StorageFormat | + +-----------+----------+---------------+ + | 10002 | 39227 | V2 | + | 10002 | 39221 | V2 | + | 10002 | 39215 | V2 | + | 10002 | 39199 | V2 | + +-----------+----------+---------------+ + 4 rows in set (0.034 sec) + ``` + +### 关键字 + +SHOW, TABLET, STORAGE, FORMAT + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET.md new file mode 100644 index 0000000000000..239b57f430705 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET.md @@ -0,0 +1,51 @@ +--- +{ + "title": "SHOW TABLET", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句用于显示指定 tablet id 信息(仅管理员使用) + +语法: + +```sql +SHOW TABLET tablet_id +``` + +## 示例 + +1. 显示指定 tablet id 为 10000 的 tablet 的父层级 id 信息 + + ```sql + SHOW TABLET 10000; + ``` + +## 关键词 + + SHOW, TABLET + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLETS-BELONG.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLETS-BELONG.md new file mode 100644 index 0000000000000..1c8f2a7e0b12e --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLETS-BELONG.md @@ -0,0 +1,65 @@ +--- +{ + "title": "SHOW TABLETS BELONG", + "language": "en" +} +--- + + + + + +## 描述 + +Used to show tablets and information of their belonging table + +grammar: + +```sql +SHOW TABLETS BELONG tablet-ids; +``` + +illustrate: + +1. tablet-ids: one or more tablet-ids, with comma separated +2. Columns of result keep same with result of `SHOW-DATA` for the same table + +## 示例 + +1. show information of four tablet-ids (actually, three tablet-ids. Result will be deduplicated) + + ```sql + SHOW TABLETS BELONG 27028,78880,78382,27028; + ``` + + ```sql + +---------------------+-----------+-----------+--------------+-----------+--------------+----------------+ + | DbName | TableName | TableSize | PartitionNum | BucketNum | ReplicaCount | TabletIds | + +---------------------+-----------+-----------+--------------+-----------+--------------+----------------+ + | default_cluster:db1 | kec | 613.000 B | 379 | 604 | 604 | [78880, 78382] | + | default_cluster:db1 | test | 1.874 KB | 1 | 1 | 1 | [27028] | + +---------------------+-----------+-----------+--------------+-----------+--------------+----------------+ + ``` + +## 关键词 + + SHOW, TABLETS, BELONG + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TRASH.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TRASH.md new file mode 100644 index 0000000000000..e84f30cfbda80 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TRASH.md @@ -0,0 +1,65 @@ +--- +{ + "title": "SHOW TRASH", + "language": "zh-CN" +} + +--- + + + + + + +## 描述 + +该语句用于查看 backend 内的垃圾数据占用空间。 + +语法: + +```sql +SHOW TRASH [ON BackendHost:BackendHeartBeatPort]; +``` + +说明: + +1. Backend 格式为该节点的 BackendHost:BackendHeartBeatPort +2. TrashUsedCapacity 表示该节点垃圾数据占用空间。 + +## 示例 + +1. 查看所有 be 节点的垃圾数据占用空间。 + + ```sql + SHOW TRASH; + ``` + +2. 查看'192.168.0.1:9050'的垃圾数据占用空间 (会显示具体磁盘信息)。 + + ```sql + SHOW TRASH ON "192.168.0.1:9050"; + ``` + +## 关键词 + + SHOW, TRASH + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/BUILD-INDEX.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/BUILD-INDEX.md new file mode 100644 index 0000000000000..4eddf642e064b --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/BUILD-INDEX.md @@ -0,0 +1,112 @@ +--- +{ + "title": "BUILD INDEX", + "language": "zh-CN" +} + +--- + + + + + + + +## 描述 + +为整个表或者表的分区构建索引,必须指定表名和索引名,可选指定分区列表。 + +## 语法 + +```sql +BUILD INDEX ON [partition_list] +``` + +其中: + +```sql +partition_list + : PARTITION ([ , parition_name2 ][ ... ]) +``` + +## 必选参数 + +**1. ``** + +> 指定索引的标识符(即名称),在其所在的表(Table)中必须唯一。 +> +> 标识符必须以字母字符(如果开启 unicode 名字支持,则可以是任意语言文字的字符)开头,并且不能包含空格或特殊字符,除非整个标识符字符串用反引号括起来(例如`My Object`)。 +> +> 标识符不能使用保留关键字。 +> +> 有关更多详细信息,请参阅标识符要求和保留关键字。 + +**2. ``** + +> 指定表的标识符(即名称),在其所在的数据库(Database)中必须唯一。 +> +> 标识符必须以字母字符(如果开启 unicode 名字支持,则可以是任意语言文字的字符)开头,并且不能包含空格或特殊字符,除非整个标识符字符串用反引号括起来(例如`My Object`)。 +> +> 标识符不能使用保留关键字。 +> +> 有关更多详细信息,请参阅标识符要求和保留关键字。 + +## 可选参数 + +**1.``** + +> 指定分区的标识符(即名称)列表,以逗号分割,在其所在的表(Table)中必须唯一。 +> +> 标识符必须以字母字符(如果开启 unicode 名字支持,则可以是任意语言文字的字符)开头,并且不能包含空格或特殊字符,除非整个标识符字符串用反引号括起来(例如`My Object`)。 +> +> 标识符不能使用保留关键字。 +> +> 有关更多详细信息,请参阅标识符要求和保留关键字。 + +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +| :---------------- | :------------- | :---------------------------- | +| ALTER_PRIV | 表(Table) | BUILD INDEX 属于表 ALTER 操作 | + +## 注意事项 + +- 目前只对倒排索引生效,其他索引如 bloomfilter index 不生效。 + +- 目前只对存算一体模式生效,存算分离模式不生效。 + +- BUILD INDEX 的进度可以通过 SHOW BUILD INDEX 查看 + +## 示例 + +- 在 table1 整个表上构建索引 index1 + + ```sql + BUILD INDEX index1 ON TABLE table1 + ``` + +- 在 table1 的分区 p1 和 p2 上构建索引 index1 + + ```sql + BUILD INDEX index1 ON TABLE table1 PARTITION(p1, p2) + ``` + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/CANCEL-BUILD-INDEX.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/CANCEL-BUILD-INDEX.md new file mode 100644 index 0000000000000..14f69612aa9c1 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/CANCEL-BUILD-INDEX.md @@ -0,0 +1,94 @@ +--- +{ + "title": "CANCEL BUILD INDEX", + "language": "zh-CN" +} + +--- + + + + + + +## 描述 + +取消索引构建的后台任务。 + +## 语法 + +```sql +CANCEL BUILD INDEX ON [ job_list ] +``` + +其中: + +```sql +job_list + : ([ , job_id2 ][ ... ]) +``` + +## 必选参数 + +**1. ``** + +> 指定表的标识符(即名称),在其所在的数据库(Database)中必须唯一。 +> +> 标识符必须以字母字符(如果开启 unicode 名字支持,则可以是任意语言文字的字符)开头,并且不能包含空格或特殊字符,除非整个标识符字符串用反引号括起来(例如`My Object`)。 +> +> 标识符不能使用保留关键字。 +> +> 有关更多详细信息,请参阅标识符要求和保留关键字。 + +## 可选参数 + +**1. ``** + +> 指定索引构建任务的标识符列表,以括号包围的逗号分割。 +> +> 标识符必须是数字,可以通过 SHOW BUILD INDEX 查看。 + +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +| :---------------- | :------------- | :----------------------------------- | +| ALTER_PRIV | 表(Table) | CANCEL BUILD INDEX 属于表 ALTER 操作 | + +## 注意事项 + +- 目前只对倒排索引生效,其他索引如 bloomfilter index 不生效。 +- 目前只对存算一体模式生效,存算分离模式不生效。 +- BUILD INDEX 的进度和索引构建任务可以通过 SHOW BUILD INDEX 查看 + +## 示例 + +- 取消表 table1 上的所有索引构建任务 + + ```sql + CANCEL BUILD INDEX ON TABLE table1 + ``` + +- 取消表 table1 上的索引构建任务 jobid1 和 jobid2 + + ```sql + CANCEL BUILD INDEX ON TABLE table1(jobid1, jobid2) + ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md new file mode 100644 index 0000000000000..375e7bf140e2b --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/CREATE-INDEX.md @@ -0,0 +1,59 @@ +--- +{ + "title": "CREATE INDEX", + "language": "zh-CN" +} +--- + + + + + + + + +## 描述 + +该语句用于创建索引 +语法: + +```sql +CREATE INDEX [IF NOT EXISTS] index_name ON table_name (column [, ...],) [USING INVERTED] [COMMENT'balabala']; +``` +注意: +- 倒排索引仅在单列上创建 + +## 示例 + +1. 在 table1 上为 siteid 创建倒排索引 + + ```sql + CREATE INDEX [IF NOT EXISTS] index_name ON table1 (siteid) USING INVERTED COMMENT 'balabala'; + ``` + + +## 关键词 + +```text +CREATE, INDEX +``` + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/DROP-INDEX.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/DROP-INDEX.md new file mode 100644 index 0000000000000..1b0f004daa38f --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/DROP-INDEX.md @@ -0,0 +1,53 @@ +--- +{ + "title": "DROP INDEX", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于从一个表中删除指定名称的索引,目前仅支持 bitmap 索引 +语法: + +```sql +DROP INDEX [IF EXISTS] index_name ON [db_name.]table_name; +``` + +## 示例 + +1. 删除索引 + + ```sql + DROP INDEX [IF NOT EXISTS] index_name ON table1 ; + ``` + +## 关键词 + + DROP, INDEX + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/SHOW-BUILD-INDEX.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/SHOW-BUILD-INDEX.md new file mode 100644 index 0000000000000..5af378dd646a6 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/SHOW-BUILD-INDEX.md @@ -0,0 +1,127 @@ +--- +{ + "title": "SHOW BUILD INDEX", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +查看索引构建任务的状态。 + +## 语法 + +```sql +SHOW BUILD INDEX [ (FROM | IN) +[ where_clause ] [ sort_clause ] [ limit_clause ] ] +``` + +其中: + +```sql +where_clause + : WHERE +``` + +其中: + +```sql +sort_clause + : + ORDER BY +``` + +其中: + +```sql +limit_clause + : + LIMIT +``` + +## 可选参数(Optional Parameters) + +1. `` + + > 指定数据库的标识符(即名称),在其所在的集群(Cluster)中必须唯一。 + > + > 标识符必须以字母字符(如果开启 unicode 名字支持,则可以是任意语言文字的字符)开头,并且不能包含空格或特殊字符,除非整个标识符字符串用反引号括起来(例如`My Object`)。 + > + > 标识符不能使用保留关键字。 + > + > 有关更多详细信息,请参阅标识符要求和保留关键字。 + +2. `` + + > 指定输出过滤条件,output_column_name 必须在输出的字段列表中。 + +3. `` + + > 指定输出排序列,output_column_name 必须在输出的字段列表中。 + +4. `LIMIT ` + + > 指定输出行数限制,n 必须是数字。 + +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +| :---------------- | :----------------- | :------------ | +| SHOW_PRIV | 数据库(Database) | | + +## 注意事项 + +- 目前只对倒排索引生效,其他索引如 bloomfilter index 不生效。 + +- 目前只对存算一体模式生效,存算分离模式不生效。 + +## 示例(Examples) + +- 查看所有索引构建任务 + + ```sql + SHOW BUILD INDEX + ``` + +- 查看数据库 database1 的索引构建任务 + + ```sql + SHOW BUILD INDEX FROM database1 + ``` + +- 查看数据库 table1 的索引构建任务 + + ```sql + SHOW BUILD INDEX WHERE TableName = 'table1' + ``` + +- 查看数据库 table1 的索引构建任务,并按照输出的 JobId 排序取前 10 行 + + ```sql + SHOW BUILD INDEX WHERE TableName = 'table1' ORDER BY JobId LIMIT 10 + ``` + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/SHOW-INDEX.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/SHOW-INDEX.md new file mode 100644 index 0000000000000..0580d1cd8a8b9 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/index/SHOW-INDEX.md @@ -0,0 +1,56 @@ +--- +{ + "title": "SHOW INDEX", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + + 该语句用于展示一个表中索引的相关信息,目前只支持 bitmap 索引 + +语法: + +```SQL +SHOW INDEX[ES] FROM [db_name.]table_name [FROM database]; +或者 +SHOW KEY[S] FROM [db_name.]table_name [FROM database]; +``` + +## 示例 + + 1. 展示指定 table_name 的下索引 + + ```SQL + SHOW INDEX FROM example_db.table_name; + ``` + +## 关键词 + + SHOW, INDEX + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/CANCEL-MATERIALIZED-VIEW-TASK.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/CANCEL-MATERIALIZED-VIEW-TASK.md new file mode 100644 index 0000000000000..ad5008e8a79f9 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/CANCEL-MATERIALIZED-VIEW-TASK.md @@ -0,0 +1,52 @@ +--- +{ + "title": "CANCEL MATERIALIZED VIEW TASK", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于取消物化视图的 task + +语法: + +```sql +CANCEL MATERIALIZED VIEW TASK taskId=INTEGER_VALUE ON mvName=multipartIdentifier +``` + +## 示例 + +1. 取消物化视图 mv1 的 id 为 1 的 task + + ```sql + CANCEL MATERIALIZED VIEW TASK 1 on mv1; + ``` + +## 关键词 + + CANCEL, MATERIALIZED, VIEW, TASK + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/CREATE-ASYNC-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/CREATE-ASYNC-MATERIALIZED-VIEW.md new file mode 100644 index 0000000000000..8fc95eb7e5241 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/CREATE-ASYNC-MATERIALIZED-VIEW.md @@ -0,0 +1,252 @@ +--- +{ + "title": "CREATE ASYNC MATERIALIZED VIEW", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于创建异步物化视图。 + +#### 语法 + +```sql +CREATE MATERIALIZED VIEW (IF NOT EXISTS)? mvName=multipartIdentifier + (LEFT_PAREN cols=simpleColumnDefs RIGHT_PAREN)? buildMode? + (REFRESH refreshMethod? refreshTrigger?)? + ((DUPLICATE)? KEY keys=identifierList)? + (COMMENT STRING_LITERAL)? + (PARTITION BY LEFT_PAREN mvPartition RIGHT_PAREN)? + (DISTRIBUTED BY (HASH hashKeys=identifierList | RANDOM) (BUCKETS (INTEGER_VALUE | AUTO))?)? + PropertyClause? + AS query +``` + +#### 说明 + +`simpleColumnDefs` + +用来定义物化视图 Column 信息,如果不定义,将自动推导。 + +```sql +simpleColumnDefs +: cols+=simpleColumnDef (COMMA cols+=simpleColumnDef)* + ; + +simpleColumnDef +: colName=identifier (COMMENT comment=STRING_LITERAL)? + ; +``` + +例如:定义两列 aa 和 bb,其中 aa 的注释为"name" +```sql +CREATE MATERIALIZED VIEW mv1 +(aa comment "name",bb) +``` + +`buildMode` + +用来定义物化视图是否创建完成立即刷新,默认 IMMEDIATE + +IMMEDIATE:立即刷新 + +DEFERRED:延迟刷新 + +```sql +buildMode +: BUILD (IMMEDIATE | DEFERRED) +; +``` + +例如:指定物化视图立即刷新 + +```sql +CREATE MATERIALIZED VIEW mv1 +BUILD IMMEDIATE +``` + +`refreshMethod` + +用来定义物化视图刷新方式,默认 AUTO + +COMPLETE:全量刷新 + +AUTO:尽量增量刷新,如果不能分区增量刷新,就全量刷新 + +物化视图的 SQL 定义和分区字段需要满足如下条件,才可以进行分区增量更新: + +- 物化视图使用的 Base Table 中至少有一个是分区表。 +- 物化视图使用的 Base Table 分区表,必须使用 List 或者 Range 分区策略。 +- 物化视图定义 SQL 中 Partition By 分区列只能有一个分区字段。 +- 物化视图的 SQL 中 Partition By 的分区列,要在 Select 后。 +- 物化视图定义 SQL,如果使用了 Group By,分区列的字段一定要在 Group By 后。 +- 物化视图定义 SQL,如果使用了 Window 函数,分区列的字段一定要在 Partition By 后。 +- 数据变更应发生在分区表上,如果发生在非分区表,物化视图需要全量构建。 +- 物化视图使用 Join 的 NULL 产生端的字段作为分区字段,不能分区增量更新,例如对于 LEFT OUTER JOIN 分区字段需要在左侧,在右侧则不行。 + + +```sql +refreshMethod +: COMPLETE | AUTO +; +``` + +例如:指定物化视图全量刷新 +```sql +CREATE MATERIALIZED VIEW mv1 +REFRESH COMPLETE +``` + +`refreshTrigger` + +物化视图刷新数据的触发方式,默认 MANUAL + +MANUAL:手动刷新 + +SCHEDULE:定时刷新 + +COMMIT:触发式刷新,基表数据变更时,自动生成刷新物化视图的任务 + +```sql +refreshTrigger +: ON MANUAL +| ON SCHEDULE refreshSchedule +| ON COMMIT +; + +refreshSchedule +: EVERY INTEGER_VALUE mvRefreshUnit (STARTS STRING_LITERAL)? +; + +mvRefreshUnit +: MINUTE | HOUR | DAY | WEEK +; +``` + +例如:每 2 小时执行一次,从 2023-12-13 21:07:09 开始 +```sql +CREATE MATERIALIZED VIEW mv1 +REFRESH ON SCHEDULE EVERY 2 HOUR STARTS "2023-12-13 21:07:09" +``` + +`key` +物化视图为 Duplicate Key 模型,因此指定的列为排序列 + +```sql +identifierList +: LEFT_PAREN identifierSeq RIGHT_PAREN + ; + +identifierSeq +: ident+=errorCapturingIdentifier (COMMA ident+=errorCapturingIdentifier)* +; +``` + +例如:指定 k1,k2 为排序列 +```sql +CREATE MATERIALIZED VIEW mv1 +KEY(k1,k2) +``` + +`partition` +物化视图有两种分区方式,如果不指定分区,默认只有一个分区,如果指定分区字段,会自动推导出字段来自哪个基表并同步基表 (当前支持 `OlapTable` 和 `hive`) 的所有分区(限制条件:基表如果是 `OlapTable`,那么只能有一个分区字段)。 + +例如:基表是 Range 分区,分区字段为 `create_time` 并按天分区,创建物化视图时指定 `partition by(ct) as select create_time as ct from t1`,那么物化视图也会是 Range 分区,分区字段为 `ct`,并且按天分区。 + +物化视图也可以通过分区上卷的方式减少物化视图的分区数量,目前分区上卷函数支持 `date_trunc`,上卷的单位支持 `year`, `month`, `day` + +分区字段的选择和物化视图的定义需要满足分区增量更新的条件,物化视图才可以创建成功,否则会报错 `Unable to find a suitable base table for partitioning` + +```sql +mvPartition + : partitionKey = identifier + | partitionExpr = functionCallExpression + ; +``` + +例如基表按天分区,物化视图同样按天分区 +```sql +partition by (`k2`) +``` + +例如基表按天分区,物化视图按月分区 +```sql +partition by (date_trunc(`k2`,'month')) +``` + +#### Property +物化视图既可以指定 Table 的 Property,也可以指定物化视图特有的 Property。 + +物化视图特有的 Property 包括: + +`grace_period`:查询改写时允许物化视图数据的最大延迟时间(单位:秒)。如果分区 A 和基表的数据不一致,物化视图的分区 A 上次刷新时间为 1,系统当前时间为 2,那么该分区不会被透明改写。但是如果 `grace_period` 大于等于 1,该分区就会被用于透明改写。 + +`excluded_trigger_tables`:数据刷新时忽略的表名,逗号分割。例如`table1,table2` + +`refresh_partition_num`:单次 Insert 语句刷新的分区数量,默认为 1。物化视图刷新时会先计算要刷新的分区列表,然后根据该配置拆分成多个 Insert 语句顺序执行。遇到失败的 Insert 语句,整个任务将停止执行。物化视图保证单个 Insert 语句的事务性,失败的 Insert 语句不会影响到已经刷新成功的分区。 + +`workload_group`:物化视图执行刷新任务时使用的 `workload_group` 名称。用来限制物化视图刷新数据使用的资源,避免影响到其它业务的运行。关于 `workload_group` 的创建及使用,可参考 [Workload Group](../../../../admin-manual/workload-group.md) 文档。 + +`partition_sync_limit`:当基表的分区字段为时间时(如果是字符串类型的时间,可以设置 `partition_date_format`),可以用此属性配置同步基表的分区范围,配合 `partition_sync_time_unit` 一起使用。 +例如设置为 2,`partition_sync_time_unit` 设置为 `MONTH`,代表仅同步基表近 2 个月的分区和数据。最小值为 `1`。 +随着时间的变化物化视图每次刷新时都会自动增删分区,例如物化视图现在有 2,3 两个月的数据,下个月的时候,会自动删除 2 月的数据,增加 4 月的数据。 + +`partition_sync_time_unit`:时间单位,支持 DAY/MONTH/YEAR(默认DAY) + +`partition_date_format`:分区字段的时间格式,例如"%Y-%m-%d" + +`enable_nondeterministic_function`:物化视图定义 SQL 是否允许包含 nondeterministic 函数,比如 current_date(), now(), random() 等,如果 +是 true, 允许包含,否则不允许包含,默认不允许包含。 + +`query`:创建物化视图的查询语句,其结果即为物化视图中的数据 + + +### 示例 + +1. 创建一个立即刷新,之后每周刷新一次的物化视图 `mv1`,数据源为 Hive Catalog + + ```sql + CREATE MATERIALIZED VIEW mv1 BUILD IMMEDIATE REFRESH COMPLETE ON SCHEDULE EVERY 1 WEEK + DISTRIBUTED BY RANDOM BUCKETS 2 + PROPERTIES ( + "replication_num" = "1" + ) + AS SELECT * FROM hive_catalog.db1.user; + ``` + +2. 创建一个多表 Join 的物化视图 + + ```sql + CREATE MATERIALIZED VIEW mv1 BUILD IMMEDIATE REFRESH COMPLETE ON SCHEDULE EVERY 1 WEEK + DISTRIBUTED BY RANDOM BUCKETS 2 + PROPERTIES ( + "replication_num" = "1" + ) + AS select user.k1,user.k3,com.k4 from user join com on user.k1=com.k1; + ``` + +## 关键词 + + CREATE, ASYNC, MATERIALIZED, VIEW diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/CREATE-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/CREATE-MATERIALIZED-VIEW.md new file mode 100644 index 0000000000000..03eeb0c23a278 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/CREATE-MATERIALIZED-VIEW.md @@ -0,0 +1,233 @@ +--- +{ + "title": "CREATE MATERIALIZED VIEW", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于创建物化视图。 + +该操作为异步操作,提交成功后,需通过 [SHOW ALTER TABLE MATERIALIZED VIEW](./SHOW-ALTER-TABLE-MATERIALIZED-VIEW) 查看作业进度。在显示 FINISHED 后既可通过 `desc [table_name] all` 命令来查看物化视图的 schema 了。 + +语法: + +```sql +CREATE MATERIALIZED VIEW < MV name > as < query > +[PROPERTIES ("key" = "value")] +``` + +说明: + +- `MV name`:物化视图的名称,必填项。相同表的物化视图名称不可重复。 + +- `query`:用于构建物化视图的查询语句,查询语句的结果既物化视图的数据。目前支持的 query 格式为: + + ```sql + SELECT select_expr[, select_expr ...] + FROM [Base view name] + GROUP BY column_name[, column_name ...] + ORDER BY column_name[, column_name ...] + ``` + + 语法和查询语句语法一致。 + + - `select_expr`:物化视图的 schema 中所有的列。 + - 至少包含一个单列。 + - `base view name`:物化视图的原始表名,必填项。 + - 必须是单表,且非子查询 + - `group by`:物化视图的分组列,选填项。 + - 不填则数据不进行分组。 + - `order by`:物化视图的排序列,选填项。 + - 排序列的声明顺序必须和 select_expr 中列声明顺序一致。 + - 如果不声明 order by,则根据规则自动补充排序列。如果物化视图是聚合类型,则所有的分组列自动补充为排序列。如果物化视图是非聚合类型,则前 36 个字节自动补充为排序列。 + - 如果自动补充的排序个数小于 3 个,则前三个作为排序列。如果 query 中包含分组列的话,则排序列必须和分组列一致。 + +- properties + + 声明物化视图的一些配置,选填项。 + + ```text + PROPERTIES ("key" = "value", "key" = "value" ...) + ``` + + 以下几个配置,均可声明在此处: + + ```text + short_key: 排序列的个数。 + timeout: 物化视图构建的超时时间。 + ``` + +## 示例 + +Base 表结构为 + +```sql +mysql> desc duplicate_table; ++-------+--------+------+------+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++-------+--------+------+------+---------+-------+ +| k1 | INT | Yes | true | N/A | | +| k2 | INT | Yes | true | N/A | | +| k3 | BIGINT | Yes | true | N/A | | +| k4 | BIGINT | Yes | true | N/A | | ++-------+--------+------+------+---------+-------+ +``` +```sql +create table duplicate_table( + k1 int null, + k2 int null, + k3 bigint null, + k4 bigint null +) +duplicate key (k1,k2,k3,k4) +distributed BY hash(k4) buckets 3 +properties("replication_num" = "1"); +``` +注意:如果物化视图包含了 base 表的分区列和分桶列,那么这些列必须作为物化视图中的 key 列 + +1. 创建一个仅包含原始表(k1, k2)列的物化视图 + + ```sql + create materialized view k1_k2 as + select k2, k1 from duplicate_table; + ``` + + 物化视图的 schema 如下图,物化视图仅包含两列 k1, k2 且不带任何聚合 + + ```text + +-----------------+-------+--------+------+------+---------+-------+ + | IndexName | Field | Type | Null | Key | Default | Extra | + +-----------------+-------+--------+------+------+---------+-------+ + | k2_k1 | k2 | INT | Yes | true | N/A | | + | | k1 | INT | Yes | true | N/A | | + +-----------------+-------+--------+------+------+---------+-------+ + ``` + +2. 创建一个以 k2 为排序列的物化视图 + + ```sql + create materialized view k2_order as + select k2, k1 from duplicate_table order by k2; + ``` + + 物化视图的 schema 如下图,物化视图仅包含两列 k2, k1,其中 k2 列为排序列,不带任何聚合。 + + ```text + +-----------------+-------+--------+------+-------+---------+-------+ + | IndexName | Field | Type | Null | Key | Default | Extra | + +-----------------+-------+--------+------+-------+---------+-------+ + | k2_order | k2 | INT | Yes | true | N/A | | + | | k1 | INT | Yes | false | N/A | NONE | + +-----------------+-------+--------+------+-------+---------+-------+ + ``` + +3. 创建一个以 k1, k2 分组,k3 列为 SUM 聚合的物化视图 + + ```sql + create materialized view k1_k2_sumk3 as + select k1, k2, sum(k3) from duplicate_table group by k1, k2; + ``` + + 物化视图的 schema 如下图,物化视图包含两列 k1, k2,sum(k3) 其中 k1, k2 为分组列,sum(k3) 为根据 k1, k2 分组后的 k3 列的求和值。 + + 由于物化视图没有声明排序列,且物化视图带聚合数据,系统默认补充分组列 k1, k2 为排序列。 + + ```text + +-----------------+-------+--------+------+-------+---------+-------+ + | IndexName | Field | Type | Null | Key | Default | Extra | + +-----------------+-------+--------+------+-------+---------+-------+ + | k1_k2_sumk3 | k1 | INT | Yes | true | N/A | | + | | k2 | INT | Yes | true | N/A | | + | | k3 | BIGINT | Yes | false | N/A | SUM | + +-----------------+-------+--------+------+-------+---------+-------+ + ``` + +4. 创建一个去除重复行的物化视图 + + ```sql + create materialized view deduplicate as + select k1, k2, k3, k4 from duplicate_table group by k1, k2, k3, k4; + ``` + + 物化视图 schema 如下图,物化视图包含 k1, k2, k3, k4 列,且不存在重复行。 + + ```text + +-----------------+-------+--------+------+-------+---------+-------+ + | IndexName | Field | Type | Null | Key | Default | Extra | + +-----------------+-------+--------+------+-------+---------+-------+ + | deduplicate | k1 | INT | Yes | true | N/A | | + | | k2 | INT | Yes | true | N/A | | + | | k3 | BIGINT | Yes | true | N/A | | + | | k4 | BIGINT | Yes | true | N/A | | + +-----------------+-------+--------+------+-------+---------+-------+ + ``` + +5. 创建一个不声明排序列的非聚合型物化视图 + + all_type_table 的 schema 如下 + + ``` + +-------+--------------+------+-------+---------+-------+ + | Field | Type | Null | Key | Default | Extra | + +-------+--------------+------+-------+---------+-------+ + | k1 | TINYINT | Yes | true | N/A | | + | k2 | SMALLINT | Yes | true | N/A | | + | k3 | INT | Yes | true | N/A | | + | k4 | BIGINT | Yes | true | N/A | | + | k5 | DECIMAL(9,0) | Yes | true | N/A | | + | k6 | DOUBLE | Yes | false | N/A | NONE | + | k7 | VARCHAR(20) | Yes | false | N/A | NONE | + +-------+--------------+------+-------+---------+-------+ + ``` + + 物化视图包含 k3, k4, k5, k6, k7 列,且不声明排序列,则创建语句如下: + + ```sql + create materialized view mv_1 as + select k3, k4, k5, k6, k7 from all_type_table; + ``` + + 系统默认补充的排序列为 k3, k4, k5 三列。这三列类型的字节数之和为 4(INT) + 8(BIGINT) + 16(DECIMAL) = 28 < 36。所以补充的是这三列作为排序列。物化视图的 schema 如下,可以看到其中 k3, k4, k5 列的 key 字段为 true,也就是排序列。k6, k7 列的 key 字段为 false,也就是非排序列。 + + ```sql + +----------------+-------+--------------+------+-------+---------+-------+ + | IndexName | Field | Type | Null | Key | Default | Extra | + +----------------+-------+--------------+------+-------+---------+-------+ + | mv_1 | k3 | INT | Yes | true | N/A | | + | | k4 | BIGINT | Yes | true | N/A | | + | | k5 | DECIMAL(9,0) | Yes | true | N/A | | + | | k6 | DOUBLE | Yes | false | N/A | NONE | + | | k7 | VARCHAR(20) | Yes | false | N/A | NONE | + +----------------+-------+--------------+------+-------+---------+-------+ + ``` + +## 关键词 + + CREATE, MATERIALIZED, VIEW + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/DROP-ASYNC-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/DROP-ASYNC-MATERIALIZED-VIEW.md new file mode 100644 index 0000000000000..a594c10d05334 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/DROP-ASYNC-MATERIALIZED-VIEW.md @@ -0,0 +1,64 @@ +--- +{ + "title": "DROP ASYNC MATERIALIZED VIEW", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于删除异步物化视图。 + +语法: + +```sql +DROP MATERIALIZED VIEW (IF EXISTS)? mvName=multipartIdentifier +``` + + +1. IF EXISTS: + 如果物化视图不存在,不要抛出错误。如果不声明此关键字,物化视图不存在则报错。 + +2. mv_name: + 待删除的物化视图的名称。必填项。 + +## 示例 + +1. 删除表物化视图 mv1 + +```sql +DROP MATERIALIZED VIEW mv1; +``` +2.如果存在,删除指定 database 的物化视图 + +```sql +DROP MATERIALIZED VIEW IF EXISTS db1.mv1; +``` + +## 关键词 + + DROP, ASYNC, MATERIALIZED, VIEW + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/DROP-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/DROP-MATERIALIZED-VIEW.md new file mode 100644 index 0000000000000..f8c9f14032a4d --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/DROP-MATERIALIZED-VIEW.md @@ -0,0 +1,114 @@ +--- +{ + "title": "DROP MATERIALIZED VIEW", + "language": "zh-CN" +} +--- + + + +## 描述 + +该语句用于删除物化视图。同步语法 + +语法: + +```sql +DROP MATERIALIZED VIEW [IF EXISTS] mv_name ON table_name; +``` + + +1. IF EXISTS: + 如果物化视图不存在,不要抛出错误。如果不声明此关键字,物化视图不存在则报错。 + +2. mv_name: + 待删除的物化视图的名称。必填项。 + +3. table_name: + 待删除的物化视图所属的表名。必填项。 + +## 示例 + +表结构为 + +```sql +mysql> desc all_type_table all; ++----------------+-------+----------+------+-------+---------+-------+ +| IndexName | Field | Type | Null | Key | Default | Extra | ++----------------+-------+----------+------+-------+---------+-------+ +| all_type_table | k1 | TINYINT | Yes | true | N/A | | +| | k2 | SMALLINT | Yes | false | N/A | NONE | +| | k3 | INT | Yes | false | N/A | NONE | +| | k4 | BIGINT | Yes | false | N/A | NONE | +| | k5 | LARGEINT | Yes | false | N/A | NONE | +| | k6 | FLOAT | Yes | false | N/A | NONE | +| | k7 | DOUBLE | Yes | false | N/A | NONE | +| | | | | | | | +| k1_sumk2 | k1 | TINYINT | Yes | true | N/A | | +| | k2 | SMALLINT | Yes | false | N/A | SUM | ++----------------+-------+----------+------+-------+---------+-------+ +``` + +1. 删除表 all_type_table 的名为 k1_sumk2 的物化视图 + + ```sql + drop materialized view k1_sumk2 on all_type_table; + ``` + + 物化视图被删除后的表结构 + + ```text + +----------------+-------+----------+------+-------+---------+-------+ + | IndexName | Field | Type | Null | Key | Default | Extra | + +----------------+-------+----------+------+-------+---------+-------+ + | all_type_table | k1 | TINYINT | Yes | true | N/A | | + | | k2 | SMALLINT | Yes | false | N/A | NONE | + | | k3 | INT | Yes | false | N/A | NONE | + | | k4 | BIGINT | Yes | false | N/A | NONE | + | | k5 | LARGEINT | Yes | false | N/A | NONE | + | | k6 | FLOAT | Yes | false | N/A | NONE | + | | k7 | DOUBLE | Yes | false | N/A | NONE | + +----------------+-------+----------+------+-------+---------+-------+ + ``` + +2. 删除表 all_type_table 中一个不存在的物化视图 + + ```sql + drop materialized view k1_k2 on all_type_table; + ERROR 1064 (HY000): errCode = 2, detailMessage = Materialized view [k1_k2] does not exist in table [all_type_table] + ``` + + 删除请求直接报错 + +3. 删除表 all_type_table 中的物化视图 k1_k2,不存在不报错。 + + ```sql + drop materialized view if exists k1_k2 on all_type_table; + Query OK, 0 rows affected (0.00 sec) + ``` + + 存在则删除,不存在则不报错。 + +## 关键词 + + DROP, MATERIALIZED, VIEW + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/PAUSE-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/PAUSE-MATERIALIZED-VIEW.md new file mode 100644 index 0000000000000..56c475ff34818 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/PAUSE-MATERIALIZED-VIEW.md @@ -0,0 +1,54 @@ +--- +{ + "title": "PAUSE MATERIALIZED VIEW", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于暂停物化视图的定时调度 + +语法: + +```sql +PAUSE MATERIALIZED VIEW JOB ON mvName=multipartIdentifier +``` + +## 示例 + +1. 暂停物化视图 mv1 的定时调度 + + ```sql + PAUSE MATERIALIZED VIEW JOB ON mv1; + ``` + +## 关键词 + + PAUSE, MATERIALIZED, VIEW + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/REFRESH-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/REFRESH-MATERIALIZED-VIEW.md new file mode 100644 index 0000000000000..64c32700129ee --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/REFRESH-MATERIALIZED-VIEW.md @@ -0,0 +1,72 @@ +--- +{ + "title": "REFRESH MATERIALIZED VIEW", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于手动刷新指定的异步物化视图 + +语法: + +```sql +REFRESH MATERIALIZED VIEW mvName=multipartIdentifier (partitionSpec | COMPLETE | AUTO) +``` + +说明: + +异步刷新某个物化视图的数据 + +- AUTO:会计算物化视图的哪些分区和基表不同步(目前,如果基表是外表,会被认为始终和物化视图同步,因此如果基表是外表,需要指定`COMPLETE`或指定要刷新的分区),然后刷新对应的分区 +- COMPLETE:会强制刷新物化视图的所有分区,不会判断分区是否和基表同步 +- partitionSpec:会强制刷新指定的分区,不会判断分区是否和基表同步 + +## 示例 + +1. 刷新物化视图 mv1(自动计算要刷新的分区) + + ```sql + REFRESH MATERIALIZED VIEW mv1 AUTO; + ``` + +2. 刷新名字为 p_19950801_19950901 和 p_19950901_19951001 的分区 + + ```sql + REFRESH MATERIALIZED VIEW mv1 partitions(p_19950801_19950901,p_19950901_19951001); + ``` + +3. 强制刷新物化视图全部数据 + + ```sql + REFRESH MATERIALIZED VIEW mv1 complete; + ``` + +## 关键词 + + REFRESH, MATERIALIZED, VIEW + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/RESUME-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/RESUME-MATERIALIZED-VIEW.md new file mode 100644 index 0000000000000..beb2f28a649b0 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/RESUME-MATERIALIZED-VIEW.md @@ -0,0 +1,52 @@ +--- +{ + "title": "RESUME MATERIALIZED VIEW", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于暂恢复物化视图的定时调度 + +语法: + +```sql +RESUME MATERIALIZED VIEW JOB ON mvName=multipartIdentifier +``` + +## 示例 + +1. 恢复物化视图 mv1 的定时调度 + + ```sql + RESUME MATERIALIZED VIEW JOB ON mv1; + ``` + +## 关键词 + + RESUME, MATERIALIZED, VIEW + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/SHOW-ALTER-TABLE-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/SHOW-ALTER-TABLE-MATERIALIZED-VIEW.md new file mode 100644 index 0000000000000..70696266aeccb --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/SHOW-ALTER-TABLE-MATERIALIZED-VIEW.md @@ -0,0 +1,113 @@ +--- +{ + "title": "SHOW ALTER TABLE MATERIALIZED VIEW", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该命令用于查看通过 [CREATE-MATERIALIZED-VIEW](../../../sql-statements/table-and-view/materialized-view/CREATE-MATERIALIZED-VIEW.md) 语句提交的创建物化视图作业的执行情况。 + +> 该语句等同于 `SHOW ALTER TABLE ROLLUP`; + +```sql +SHOW ALTER TABLE MATERIALIZED VIEW +[FROM database] +[WHERE] +[ORDER BY] +[LIMIT OFFSET] +``` + +- database:查看指定数据库下的作业。如不指定,使用当前数据库。 +- WHERE:可以对结果列进行筛选,目前仅支持对以下列进行筛选: + - TableName:仅支持等值筛选。 + - State:仅支持等值筛选。 + - Createtime/FinishTime:支持 =,>=,<=,>,<,!= +- ORDER BY:可以对结果集按任意列进行排序。 +- LIMIT:配合 ORDER BY 进行翻页查询。 + +返回结果说明: + +```sql +mysql> show alter table materialized view\G +*************************** 1. row *************************** + JobId: 11001 + TableName: tbl1 + CreateTime: 2020-12-23 10:41:00 + FinishTime: NULL + BaseIndexName: tbl1 +RollupIndexName: r1 + RollupId: 11002 + TransactionId: 5070 + State: WAITING_TXN + Msg: + Progress: NULL + Timeout: 86400 +1 row in set (0.00 sec) +``` + +- `JobId`:作业唯一 ID。 + +- `TableName`:基表名称 + +- `CreateTime/FinishTime`:作业创建时间和结束时间。 + +- `BaseIndexName/RollupIndexName`:基表名称和物化视图名称。 + +- `RollupId`:物化视图的唯一 ID。 + +- `TransactionId`:见 State 字段说明。 + +- `State`:作业状态。 + + - PENDING:作业准备中。 + + - WAITING_TXN: + + 在正式开始产生物化视图数据前,会等待当前这个表上的正在运行的导入事务完成。而 `TransactionId` 字段就是当前正在等待的事务 ID。当这个 ID 之前的导入都完成后,就会实际开始作业。 + + - RUNNING:作业运行中。 + + - FINISHED:作业运行成功。 + + - CANCELLED:作业运行失败。 + +- `Msg`:错误信息 + +- `Progress`:作业进度。这里的进度表示 `已完成的tablet数量/总tablet数量`。创建物化视图是按 tablet 粒度进行的。 + +- `Timeout`:作业超时时间,单位秒。 + +## 示例 + +1. 查看数据库 example_db 下的物化视图作业 + + ```sql + SHOW ALTER TABLE MATERIALIZED VIEW FROM example_db; + ``` + + + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/SHOW-CREATE-ASYNC-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/SHOW-CREATE-ASYNC-MATERIALIZED-VIEW.md new file mode 100644 index 0000000000000..0b6f5d4f4a967 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/SHOW-CREATE-ASYNC-MATERIALIZED-VIEW.md @@ -0,0 +1,56 @@ +--- +{ + "title": "SHOW CREATE ASYNC MATERIALIZED VIEW", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句用于展示异步物化视图的创建语句。 + +语法: + +```sql +SHOW CREATE MATERIALIZED VIEW [DBNAME.]MV_NAME +``` + +说明: + +1. `DBNAMNE` : 数据库名称 +2. `MV_NAME` : 异步物化视图的名称 + +## 示例 + +1. 查看 mv1 的创建语句 + + ```sql + SHOW CREATE MATERIALIZED VIEW mv1; + ``` + +## 关键词 + + SHOW, CREATE, MATERIALIZED, VIEW, ASYNC + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/SHOW-CREATE-MATERIALIZED-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/SHOW-CREATE-MATERIALIZED-VIEW.md new file mode 100644 index 0000000000000..bfa5fcd4c9b8d --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/materialized-view/SHOW-CREATE-MATERIALIZED-VIEW.md @@ -0,0 +1,70 @@ +--- +{ + "title": "SHOW CREATE MATERIALIZED VIEW", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于查询创建物化视图的语句。 + +语法: + +```sql +SHOW CREATE MATERIALIZED VIEW mv_name ON table_name +``` + +1. mv_name: + 物化视图的名称。必填项。 + +2. table_name: + 物化视图所属的表名。必填项。 + +## 示例 + +创建物化视图的语句为 + +```sql +create materialized view id_col1 as select id,col1 from table3; +``` + +查询后返回 + +```sql +mysql> show create materialized view id_col1 on table3; ++-----------+----------+----------------------------------------------------------------+ +| TableName | ViewName | CreateStmt | ++-----------+----------+----------------------------------------------------------------+ +| table3 | id_col1 | create materialized view id_col1 as select id,col1 from table3 | ++-----------+----------+----------------------------------------------------------------+ +1 row in set (0.00 sec) +``` + +## 关键词 + + SHOW, MATERIALIZED, VIEW + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-COLOCATE-GROUP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-COLOCATE-GROUP.md new file mode 100644 index 0000000000000..5f9130eedd17c --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-COLOCATE-GROUP.md @@ -0,0 +1,82 @@ +--- +{ +"title": "ALTER COLOCATE GROUP", +"language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于修改 Colocation Group 的属性。 + +语法: + +```sql +ALTER COLOCATE GROUP [database.]group +SET ( + property_list +); +``` + +注意: + +1. 如果 colocate group 是全局的,即它的名称是以 `__global__` 开头的,那它不属于任何一个 Database; + +2. property_list 是 colocation group 属性,目前只支持修改`replication_num` 和 `replication_allocation`。 + 修改 colocation group 的这两个属性修改之后,同时把该 group 的表的属性`default.replication_allocation` 、 + 属性`dynamic.replication_allocation `、以及已有分区的`replication_allocation`改成跟它一样。 + + + +## 示例 + +1. 修改一个全局 group 的副本数 + + ```sql + # 建表时设置 "colocate_with" = "__global__foo" + + ALTER COLOCATE GROUP __global__foo + SET ( + "replication_num"="1" + ); + ``` + +2. 修改一个非全局 group 的副本数 + + ```sql + # 建表时设置 "colocate_with" = "bar",且表属于 Database example_db + + ALTER COLOCATE GROUP example_db.bar + SET ( + "replication_num"="1" + ); + ``` + +## 关键词 + +```sql +ALTER, COLOCATE , GROUP +``` + +### 最佳实践 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-AND-GENERATED-COLUMN.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-AND-GENERATED-COLUMN.md new file mode 100644 index 0000000000000..0012db8663694 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-AND-GENERATED-COLUMN.md @@ -0,0 +1,64 @@ +--- +{ + "title": "ALTER TABLE AND GENERATED COLUMN", + "language": "zh-CN" +} +--- + + + + +## ALTER TABLE 和生成列 + +不支持使用 ALTER TABLE ADD COLUMN 增加一个生成列,不支持使用 ALTER TABLE MODIFY COLUMN 修改生成列信息。支持使用 ALTER TABLE 对生成列顺序进行修改,修改生成列名称和删除生成列。 + +不支持的场景报错如下: + +```sql +mysql> CREATE TABLE test_alter_add_column(a int, b int) properties("replication_num"="1"); +Query OK, 0 rows affected (0.14 sec) +mysql> ALTER TABLE test_alter_add_column ADD COLUMN c int AS (a+b); +ERROR 1105 (HY000): errCode = 2, detailMessage = Not supporting alter table add generated columns. +mysql> ALTER TABLE test_alter MODIFY COLUMN c int KEY AS (a+b+1); +ERROR 1105 (HY000): errCode = 2, detailMessage = Not supporting alter table modify generated columns. +``` + +### REORDER COLUMN + +```sql +ALTER TABLE products ORDER BY (product_id, total_value, price, quantity); +``` + +注意: +修改后的列顺序仍然需要满足生成列建表时的顺序限制。 +### RENAME COLUMN + +```sql +ALTER TABLE products RENAME COLUMN total_value new_name; +``` + +注意: +如果表中某列(生成列或者普通列)被其它生成列引用,需要先删除其它生成列后,才能修改此生成列的名称。 +### DROP COLUMN + +```sql +ALTER TABLE products DROP COLUMN total_value; +``` + +注意: +如果表中某列(生成列或者普通列)被其它生成列引用,需要先删除其它生成列后,才能删除此被引用的生成列或者普通列。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-COLUMN.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-COLUMN.md new file mode 100644 index 0000000000000..3ea53094f4a52 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-COLUMN.md @@ -0,0 +1,306 @@ +--- +{ + "title": "ALTER TABLE COLUMN", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于对已有 table 进行 Schema change 操作。schema change 是异步的,任务提交成功则返回,之后可使用[SHOW ALTER TABLE COLUMN](../../../../sql-manual/sql-statements/table-and-view/table/SHOW-ALTER-TABLE) 命令查看进度。 + +:::tip +Doris 在建表之后有物化索引的概念,在建表成功后为 base 表,物化索引为 base index,基于 base 表可以创建 rollup index。其中 base index 和 rollup index 都是物化索引,在进行 schema change 操作时如果不指定 rollup_index_name 默认基于 base 表进行操作。 +Doris 在 1.2.0 支持了 light schema change 轻量表结构变更,对于值列的加减操作,可以更快地,同步地完成。可以在建表时手动指定 "light_schema_change" = 'true',2.0.0 及之后版本该参数默认开启。 +::: + +### 语法: + +```sql +ALTER TABLE [database.]table alter_clause; +``` + +schema change 的 alter_clause 支持如下几种修改方式: + +**1. 添加列,向指定的 index 位置进行列添加** + +**语法** + +```sql +ALTER TABLE [database.]table table_name ADD COLUMN column_name column_type [KEY | agg_type] [DEFAULT "default_value"] +[AFTER column_name|FIRST] +[TO rollup_index_name] +[PROPERTIES ("key"="value", ...)] +``` + +**Example** + +1. 向 example_db.my_table 的 key_1 后添加一个 key 列 new_col (非聚合模型) + + ```sql + ALTER TABLE example_db.my_table + ADD COLUMN new_col INT KEY DEFAULT "0" AFTER key_1; + ``` + +2. 向 example_db.my_table 的 value_1 后添加一个 value 列 new_col (非聚合模型) + + ```sql + ALTER TABLE example_db.my_table + ADD COLUMN new_col INT DEFAULT "0" AFTER value_1; + ``` + +3. 向 example_db.my_table 的 key_1 后添加一个 key 列 new_col (聚合模型) + + ```sql + ALTER TABLE example_db.my_table + ADD COLUMN new_col INT KEY DEFAULT "0" AFTER key_1; + ``` + +4. 向 example_db.my_table 的 value_1 后添加一个 value 列 new_col SUM 聚合类型 (聚合模型) + + ```sql + ALTER TABLE example_db.my_table + ADD COLUMN new_col INT SUM DEFAULT "0" AFTER value_1; + ``` + +5. 将 new_col 添加到 example_db.my_table 表的首列位置 (非聚合模型) + + ```sql + ALTER TABLE example_db.my_table + ADD COLUMN new_col INT KEY DEFAULT "0" FIRST; + ``` + +:::tip + - 聚合模型如果增加 value 列,需要指定 agg_type + - 非聚合模型(如 DUPLICATE KEY)如果增加 key 列,需要指定 KEY 关键字 + - 不能在 rollup index 中增加 base index 中已经存在的列(如有需要,可以重新创建一个 rollup index) +::: + +**2. 添加多列,向指定的 index 位置进行多列添加** + +**语法** + + ```sql + ALTER TABLE [database.]table table_name ADD COLUMN (column_name1 column_type [KEY | agg_type] DEFAULT "default_value", ...) + [TO rollup_index_name] + [PROPERTIES ("key"="value", ...)] + ``` + +**Example** + +1. 向 example_db.my_table 中添加多列,new_col 和 new_col2 都是 SUM 聚合类型 (聚合模型) + + ```sql + ALTER TABLE example_db.my_table + ADD COLUMN (new_col1 INT SUM DEFAULT "0" ,new_col2 INT SUM DEFAULT "0"); + ``` + +2. 向 example_db.my_table 中添加多列 (非聚合模型),其中 new_col1 为 KEY 列,new_col2 为 value 列 + + ```sql + ALTER TABLE example_db.my_table + ADD COLUMN (new_col1 INT key DEFAULT "0" , new_col2 INT DEFAULT "0"); + ``` + +:::tip + + - 聚合模型如果增加 value 列,需要指定 agg_type + - 聚合模型如果增加 key 列,需要指定 KEY 关键字 + - 不能在 rollup index 中增加 base index 中已经存在的列(如有需要,可以重新创建一个 rollup index) +::: + +**3. 删除列,从指定 index 中删除一列** + +**语法** + + ```sql + ALTER TABLE [database.]table table_name DROP COLUMN column_name + [FROM rollup_index_name] + ``` + +**Example** + +1. 从 example_db.my_table 中删除 col1 列 + + ```sql + ALTER TABLE example_db.my_table DROP COLUMN col1; + ``` + +:::tip + - 不能删除分区列 + - 聚合模型不能删除 KEY 列 + - 如果是从 base index 中删除列,则如果 rollup index 中包含该列,也会被删除 +::: + +**4. 修改指定列类型以及列位置** + +**语法** + +```sql +ALTER TABLE [database.]table table_name MODIFY COLUMN column_name column_type [KEY | agg_type] [NULL | NOT NULL] [DEFAULT "default_value"] +[AFTER column_name|FIRST] +[FROM rollup_index_name] +[PROPERTIES ("key"="value", ...)] +``` + +**Example** + +1. 修改 example_db.my_table 的 key 列 col1 的类型为 BIGINT,并移动到 col2 列后面。 + + ```sql + ALTER TABLE example_db.my_table + MODIFY COLUMN col1 BIGINT KEY DEFAULT "1" AFTER col2; + ``` + + :::tip + 无论是修改 key 列还是 value 列都需要声明完整的 column 信息 + ::: + +2. 修改 example_db.my_table 的 val1 列最大长度。原 val1 为 (val1 VARCHAR(32) REPLACE DEFAULT "abc") + + ```sql + ALTER TABLE example_db.my_table + MODIFY COLUMN val1 VARCHAR(64) REPLACE DEFAULT "abc"; + ``` + + :::tip + 只能修改列的类型,列的其他属性维持原样 + ::: + +3. 修改 Duplicate key 表 Key 列的某个字段的长度 + + ```sql + ALTER TABLE example_db.my_table + MODIFY COLUMN k3 VARCHAR(50) KEY NULL COMMENT 'to 50'; + ``` + +:::tip + - 聚合模型如果修改 value 列,需要指定 agg_type + - 非聚合类型如果修改 key 列,需要指定 KEY 关键字 + - 只能修改列的类型,列的其他属性维持原样(即其他属性需在语句中按照原属性显式的写出,参见 example 8) + - 分区列和分桶列不能做任何修改 + - 目前支持以下类型的转换(精度损失由用户保证) + - TINYINT/SMALLINT/INT/BIGINT/LARGEINT/FLOAT/DOUBLE 类型向范围更大的数字类型转换 + - TINTINT/SMALLINT/INT/BIGINT/LARGEINT/FLOAT/DOUBLE/DECIMAL 转换成 VARCHAR + - VARCHAR 支持修改最大长度 + - VARCHAR/CHAR 转换成 TINTINT/SMALLINT/INT/BIGINT/LARGEINT/FLOAT/DOUBLE + - VARCHAR/CHAR 转换成 DATE (目前支持"%Y-%m-%d", "%y-%m-%d", "%Y%m%d", "%y%m%d", "%Y/%m/%d, "%y/%m/%d"六种格式化格式) + - DATETIME 转换成 DATE(仅保留年 - 月 - 日信息,例如:`2019-12-09 21:47:05` <--> `2019-12-09`) + - DATE 转换成 DATETIME(时分秒自动补零,例如:`2019-12-09` <--> `2019-12-09 00:00:00`) + - FLOAT 转换成 DOUBLE + - INT 转换成 DATE (如果 INT 类型数据不合法则转换失败,原始数据不变) + - 除 DATE 与 DATETIME 以外都可以转换成 STRING,但是 STRING 不能转换任何其他类型 +::: + +**5. 对指定表的列进行重新排序** + +**语法** + + ```sql + ALTER TABLE [database.]table table_name ORDER BY (column_name1, column_name2, ...) + [FROM rollup_index_name] + [PROPERTIES ("key"="value", ...)] + ``` + +**Example** + +1. 调整 example_db.my_table 的 key 列 和 value 列的顺序(非聚合模型) + + ```sql + CREATE TABLE `my_table`( + `k_1` INT NULL, + `k_2` INT NULL, + `v_1` INT NULL, + `v_2` varchar NULL, + `v_3` varchar NULL + ) ENGINE=OLAP + DUPLICATE KEY(`k_1`, `k_2`) + COMMENT 'OLAP' + DISTRIBUTED BY HASH(`k_1`) BUCKETS 5 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + ); + + ALTER TABLE example_db.my_table ORDER BY (k_2,k_1,v_3,v_2,v_1); + + mysql> desc my_table; + +-------+------------+------+-------+---------+-------+ + | Field | Type | Null | Key | Default | Extra | + +-------+------------+------+-------+---------+-------+ + | k_2 | INT | Yes | true | NULL | | + | k_1 | INT | Yes | true | NULL | | + | v_3 | VARCHAR(*) | Yes | false | NULL | NONE | + | v_2 | VARCHAR(*) | Yes | false | NULL | NONE | + | v_1 | INT | Yes | false | NULL | NONE | + +-------+------------+------+-------+---------+-------+ + ``` + +2. 同时执行添加列和列排序操作 + + ```sql + CREATE TABLE `my_table` ( + `k_1` INT NULL, + `k_2` INT NULL, + `v_1` INT NULL, + `v_2` varchar NULL, + `v_3` varchar NULL + ) ENGINE=OLAP + DUPLICATE KEY(`k_1`, `k_2`) + COMMENT 'OLAP' + DISTRIBUTED BY HASH(`k_1`) BUCKETS 5 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + ); + + ALTER TABLE example_db.my_table + ADD COLUMN col INT DEFAULT "0" AFTER v_1, + ORDER BY (k_2,k_1,v_3,v_2,v_1,col); + + mysql> desc my_table; + +-------+------------+------+-------+---------+-------+ + | Field | Type | Null | Key | Default | Extra | + +-------+------------+------+-------+---------+-------+ + | k_2 | INT | Yes | true | NULL | | + | k_1 | INT | Yes | true | NULL | | + | v_3 | VARCHAR(*) | Yes | false | NULL | NONE | + | v_2 | VARCHAR(*) | Yes | false | NULL | NONE | + | v_1 | INT | Yes | false | NULL | NONE | + | col | INT | Yes | false | 0 | NONE | + +-------+------------+------+-------+---------+-------+ + ``` + +:::tip + - index 中的所有列都要写出来 + - value 列在 key 列之后 + - key 列只能调整 key 列的范围内进行调整,value 列同理 +::: + +## 关键词 + +```text +ALTER, TABLE, COLUMN, ALTER TABLE +``` + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-COMMENT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-COMMENT.md new file mode 100644 index 0000000000000..c5d74d9e1b55d --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-COMMENT.md @@ -0,0 +1,77 @@ +--- +{ + "title": "ALTER TABLE COMMENT", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +该语句用于对已有 table 的 comment 进行修改。这个操作是同步的,命令返回表示执行完毕。 + +语法: + +```sql +ALTER TABLE [database.]table alter_clause; +``` + +1. 修改表注释 + +语法: + +```sql +MODIFY COMMENT "new table comment"; +``` + +2. 修改列注释 + + 语法: + +```sql +MODIFY COLUMN col1 COMMENT "new column comment"; +``` + +## 示例 + +1. 将名为 table1 的 comment 修改为 table1_comment + +```sql +ALTER TABLE table1 MODIFY COMMENT "table1_comment"; +``` + +2. 将名为 table1 的 col1 列的 comment 修改为 table1_col1_comment + +```sql +ALTER TABLE table1 MODIFY COLUMN col1 COMMENT "table1_col1_comment"; +``` + +## 关键词 + +```text +ALTER, TABLE, COMMENT, ALTER TABLE +``` + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-PARTITION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-PARTITION.md new file mode 100644 index 0000000000000..67172cb6db727 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-PARTITION.md @@ -0,0 +1,182 @@ +--- +{ + "title": "ALTER TABLE PARTITION", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句用于对有 partition 的 table 进行修改操作。 + +这个操作是同步的,命令返回表示执行完毕。 + +语法: + +```sql +ALTER TABLE [database.]table alter_clause; +``` + +partition 的 alter_clause 支持如下几种修改方式 + +1. 增加分区 + +语法: + +```sql +ADD PARTITION [IF NOT EXISTS] partition_name +partition_desc ["key"="value"] +[DISTRIBUTED BY HASH (k1[,k2 ...]) [BUCKETS num]] +``` + +注意: + +- partition_desc 支持以下两种写法 + - VALUES LESS THAN [MAXVALUE|("value1", ...)] + - VALUES [("value1", ...), ("value1", ...)) +- 分区为左闭右开区间,如果用户仅指定右边界,系统会自动确定左边界 +- 如果没有指定分桶方式,则自动使用建表使用的分桶方式和分桶数。 +- 如指定分桶方式,只能修改分桶数,不可修改分桶方式或分桶列。如果指定了分桶方式,但是没有指定分桶数,则分桶数会使用默认值 10,不会使用建表时指定的分桶数。如果要指定分桶数,则必须指定分桶方式。 +- ["key"="value"] 部分可以设置分区的一些属性,具体说明见 [CREATE TABLE](../Create/CREATE-TABLE.md) +- 如果建表时用户未显式创建 Partition,则不支持通过 ALTER 的方式增加分区 +- 如果用户使用的是 List Partition 则可以增加 default partition,default partition 将会存储所有不满足其他分区键要求的数据。 + - ALTER TABLE table_name ADD PARTITION partition_name + +2. 删除分区 + +语法: + +```sql +DROP PARTITION [IF EXISTS] partition_name [FORCE] +``` + + 注意: + +- 使用分区方式的表至少要保留一个分区。 +- 执行 DROP PARTITION 一段时间内,可以通过 RECOVER 语句恢复被删除的分区。详见 SQL 手册 - 数据库管理-RECOVER 语句 +- 如果执行 DROP PARTITION FORCE,则系统不会检查该分区是否存在未完成的事务,分区将直接被删除并且不能被恢复,一般不建议执行此操作 + +3. 修改分区属性 + + 语法: + +```sql +MODIFY PARTITION p1|(p1[, p2, ...]) SET ("key" = "value", ...) +``` + +说明: + +- 当前支持修改分区的下列属性: + - storage_medium + - storage_cooldown_time + - replication_num + - in_memory +- 对于单分区表,partition_name 同表名。 + +## 示例 + +1. 增加分区,现有分区 [MIN, 2013-01-01),增加分区 [2013-01-01, 2014-01-01),使用默认分桶方式 + +```sql +ALTER TABLE example_db.my_table +ADD PARTITION p1 VALUES LESS THAN ("2014-01-01"); +``` + +2. 增加分区,使用新的分桶数 + +```sql +ALTER TABLE example_db.my_table +ADD PARTITION p1 VALUES LESS THAN ("2015-01-01") +DISTRIBUTED BY HASH(k1) BUCKETS 20; +``` + +3. 增加分区,使用新的副本数 + +```sql +ALTER TABLE example_db.my_table +ADD PARTITION p1 VALUES LESS THAN ("2015-01-01") +("replication_num"="1"); +``` + +4. 修改分区副本数 + +```sql +ALTER TABLE example_db.my_table +MODIFY PARTITION p1 SET("replication_num"="1"); +``` + +5. 批量修改指定分区 + +```sql +ALTER TABLE example_db.my_table +MODIFY PARTITION (p1, p2, p4) SET("replication_num"="1"); +``` + +6. 批量修改所有分区 + +```sql +ALTER TABLE example_db.my_table +MODIFY PARTITION (*) SET("storage_medium"="HDD"); +``` + +7. 删除分区 + +```sql +ALTER TABLE example_db.my_table +DROP PARTITION p1; +``` + +8. 批量删除分区 + +```sql +ALTER TABLE example_db.my_table +DROP PARTITION p1, +DROP PARTITION p2, +DROP PARTITION p3; +``` + +9. 增加一个指定上下界的分区 + +```sql +ALTER TABLE example_db.my_table +ADD PARTITION p1 VALUES [("2014-01-01"), ("2014-02-01")); +``` + +10. 批量增加数字类型和时间类型的分区 + +```sql +ALTER TABLE example_db.my_table ADD PARTITIONS FROM (1) TO (100) INTERVAL 10; +ALTER TABLE example_db.my_table ADD PARTITIONS FROM ("2023-01-01") TO ("2025-01-01") INTERVAL 1 YEAR; +ALTER TABLE example_db.my_table ADD PARTITIONS FROM ("2023-01-01") TO ("2025-01-01") INTERVAL 1 MONTH; +ALTER TABLE example_db.my_table ADD PARTITIONS FROM ("2023-01-01") TO ("2025-01-01") INTERVAL 1 WEEK; +ALTER TABLE example_db.my_table ADD PARTITIONS FROM ("2023-01-01") TO ("2025-01-01") INTERVAL 1 DAY; +``` + +## 关键词 + +```text +ALTER, TABLE, PARTITION, ALTER TABLE +``` + + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-PROPERTY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-PROPERTY.md new file mode 100644 index 0000000000000..efd98cfa99665 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-PROPERTY.md @@ -0,0 +1,300 @@ +--- +{ + "title": "ALTER TABLE PROPERTY", + "language": "zh-CN" +} +--- + + + + + + + +:::caution +分区属性与表属性的一些区别 +- 分区属性一般主要关注分桶数 (buckets)、存储介质 (storage_medium)、副本数 (replication)、冷热分离存储策略 (storage_policy); + - 对于已经创建的分区,可以使用 alter table {tableName} modify partition({partitionName}) set ({key}={value}) 来修改,但是分桶数 (buckets) 不能修改; + - 对于未创建的动态分区 (dynamic partition),可以使用 alter table {tableName} set (dynamic_partition.{key} = {value}) 来修改其属性; + - 对于未创建的自动分区 (auto partition),可以使用 alter table {tableName} set ({key} = {value}) 来修改其属性; + - 若用户想修改分区的属性,需要修改已经创建分区的属性,同时也要修改未创建分区的属性 +- 除了上面几个属性,其他均为表级别属性 +- 具体属性可以参考[建表属性](../../../../sql-manual/sql-statements/table-and-view/table/CREATE-TABLE) +::: + +## 描述 + +该语句用于对已有 table 的 property 进行修改操作。这个操作是同步的,命令返回表示执行完毕。 + +语法: + +```sql +ALTER TABLE [database.]table alter_clause; +``` + +property 的 alter_clause 支持如下几种修改方式 + +1. 修改表的 bloom filter 列 + +```sql +ALTER TABLE example_db.my_table SET ("bloom_filter_columns"="k1,k2,k3"); +``` + +也可以合并到上面的 schema change 操作中(注意多子句的语法有少许区别) + +```sql +ALTER TABLE example_db.my_table +DROP COLUMN col2 +PROPERTIES ("bloom_filter_columns"="k1,k2,k3"); +``` + +2. 修改表的 Colocate 属性 + +```sql +ALTER TABLE example_db.my_table set ("colocate_with" = "t1"); +``` + +3. 将表的分桶方式由 Hash Distribution 改为 Random Distribution + +```sql +ALTER TABLE example_db.my_table set ("distribution_type" = "random"); +``` + +4. 修改表的动态分区属性 (支持未添加动态分区属性的表添加动态分区属性) + +```sql +ALTER TABLE example_db.my_table set ("dynamic_partition.enable" = "false"); +``` + +如果需要在未添加动态分区属性的表中添加动态分区属性,则需要指定所有的动态分区属性 + (注:非分区表不支持添加动态分区属性) + +```sql +ALTER TABLE example_db.my_table set ( + "dynamic_partition.enable" = "true", + "dynamic_partition.time_unit" = "DAY", + "dynamic_partition.end" = "3", + "dynamic_partition.prefix" = "p", + "dynamic_partition.buckets" = "32" +); +``` + +5. 修改表的 in_memory 属性,只支持修改为'false' + +```sql +ALTER TABLE example_db.my_table set ("in_memory" = "false"); +``` + +6. 启用 批量删除功能 + +```sql +ALTER TABLE example_db.my_table ENABLE FEATURE "BATCH_DELETE"; +``` + +注意: + +- 只能用在 unique 表 +- 用于旧表支持批量删除功能,新表创建时已经支持 + +7. 启用按照 sequence column 的值来保证导入顺序的功能 + +```sql +ALTER TABLE example_db.my_table ENABLE FEATURE "SEQUENCE_LOAD" WITH PROPERTIES ( + "function_column.sequence_type" = "Date" +); +``` + +注意: + +- 只能用在 unique 表 +- sequence_type 用来指定 sequence 列的类型,可以为整型和时间类型 +- 只支持新导入数据的有序性,历史数据无法更改 + +8. 将表的默认分桶数改为 50 + +```sql +ALTER TABLE example_db.my_table MODIFY DISTRIBUTION DISTRIBUTED BY HASH(k1) BUCKETS 50; +``` + +注意: + +- 只能用在分区类型为 RANGE,采用哈希分桶的非 colocate 表 + +9. 修改表注释 + +```sql +ALTER TABLE example_db.my_table MODIFY COMMENT "new comment"; +``` + +10. 修改列注释 + +```sql +ALTER TABLE example_db.my_table MODIFY COLUMN k1 COMMENT "k1", MODIFY COLUMN k2 COMMENT "k2"; +``` + +11. 修改引擎类型 + + 仅支持将 MySQL 类型修改为 ODBC 类型。driver 的值为 odbc.init 配置中的 driver 名称。 + +```sql +ALTER TABLE example_db.mysql_table MODIFY ENGINE TO odbc PROPERTIES("driver" = "MySQL"); +``` + +12. 修改副本数 + +```sql +ALTER TABLE example_db.mysql_table SET ("replication_num" = "2"); +ALTER TABLE example_db.mysql_table SET ("default.replication_num" = "2"); +ALTER TABLE example_db.mysql_table SET ("replication_allocation" = "tag.location.default: 1"); +ALTER TABLE example_db.mysql_table SET ("default.replication_allocation" = "tag.location.default: 1"); +``` + +注: +1. default 前缀的属性表示修改表的默认副本分布。这种修改不会修改表的当前实际副本分布,而只影响分区表上新建分区的副本分布。 +2. 对于非分区表,修改不带 default 前缀的副本分布属性,会同时修改表的默认副本分布和实际副本分布。即修改后,通过 `show create table` 和 `show partitions from tbl` 语句可以看到副本分布数据都被修改了。 +3. 对于分区表,表的实际副本分布是分区级别的,即每个分区有自己的副本分布,可以通过 `show partitions from tbl` 语句查看。如果想修改实际副本分布,请参阅 `ALTER TABLE PARTITION`。 + +13\. **[Experimental]** 打开`light_schema_change` + + 对于建表时未开启 light_schema_change 的表,可以通过如下方式打开。 + +```sql +ALTER TABLE example_db.mysql_table SET ("light_schema_change" = "true"); +``` + +## 示例 + +1. 修改表的 bloom filter 列 + +```sql +ALTER TABLE example_db.my_table SET ( + "bloom_filter_columns"="k1,k2,k3" +); +``` + +也可以合并到上面的 schema change 操作中(注意多子句的语法有少许区别) + +```sql +ALTER TABLE example_db.my_table +DROP COLUMN col2 +PROPERTIES ( + "bloom_filter_columns"="k1,k2,k3" +); +``` + +2. 修改表的 Colocate 属性 + +```sql +ALTER TABLE example_db.my_table set ("colocate_with" = "t1"); +``` + +3. 将表的分桶方式由 Hash Distribution 改为 Random Distribution + +```sql +ALTER TABLE example_db.my_table set ( + "distribution_type" = "random" +); +``` + +4. 修改表的动态分区属性 (支持未添加动态分区属性的表添加动态分区属性) + +```sql +ALTER TABLE example_db.my_table set ( + "dynamic_partition.enable" = "false" +); +``` + +如果需要在未添加动态分区属性的表中添加动态分区属性,则需要指定所有的动态分区属性 + (注:非分区表不支持添加动态分区属性) + +```sql +ALTER TABLE example_db.my_table set ( + "dynamic_partition.enable" = "true", + "dynamic_partition.time_unit" = "DAY", + "dynamic_partition.end" = "3", + "dynamic_partition.prefix" = "p", + "dynamic_partition.buckets" = "32" +); +``` + +5. 修改表的 in_memory 属性,只支持修改为'false' + +```sql +ALTER TABLE example_db.my_table set ("in_memory" = "false"); +``` + +6. 启用 批量删除功能 + +```sql +ALTER TABLE example_db.my_table ENABLE FEATURE "BATCH_DELETE"; +``` + +7. 启用按照 sequence column 的值来保证导入顺序的功能 + +```sql +ALTER TABLE example_db.my_table ENABLE FEATURE "SEQUENCE_LOAD" WITH PROPERTIES ( + "function_column.sequence_type" = "Date" +); +``` + +8. 将表的默认分桶数改为 50 + +```sql +ALTER TABLE example_db.my_table MODIFY DISTRIBUTION DISTRIBUTED BY HASH(k1) BUCKETS 50; +``` + +9. 修改表注释 + +```sql +ALTER TABLE example_db.my_table MODIFY COMMENT "new comment"; +``` + +10. 修改列注释 + +```sql +ALTER TABLE example_db.my_table MODIFY COLUMN k1 COMMENT "k1", MODIFY COLUMN k2 COMMENT "k2"; +``` + +11. 修改引擎类型 + +```sql +ALTER TABLE example_db.mysql_table MODIFY ENGINE TO odbc PROPERTIES("driver" = "MySQL"); +``` + +12. 给表添加冷热分层数据迁移策略 +```sql + ALTER TABLE create_table_not_have_policy set ("storage_policy" = "created_create_table_alter_policy"); +``` +注:表没有关联过 storage policy,才能被添加成功,一个表只能添加一个 storage policy + +13. 给表的 partition 添加冷热分层数据迁移策略 +```sql +ALTER TABLE create_table_partition MODIFY PARTITION (*) SET("storage_policy"="created_create_table_partition_alter_policy"); +``` +注:表的 partition 没有关联过 storage policy,才能被添加成功,一个表只能添加一个 storage policy + +## 关键词 + +```text +ALTER, TABLE, PROPERTY, ALTER TABLE +``` + + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-RENAME.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-RENAME.md new file mode 100644 index 0000000000000..b98bc12e9a1b7 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-RENAME.md @@ -0,0 +1,112 @@ +--- +{ + "title": "ALTER TABLE RENAME", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于对已有 table 属性的某些名称进行重命名操作。这个操作是同步的,命令返回表示执行完毕。 + +语法: + +```sql +ALTER TABLE [database.]table alter_clause; +``` + +rename 的 alter_clause 支持对以下名称进行修改 + +1. 修改表名 + +语法: + +```sql +RENAME new_table_name; +``` + +2. 修改 rollup index 名称 + + 语法: + +```sql +RENAME ROLLUP old_rollup_name new_rollup_name; +``` + +3. 修改 partition 名称 + +语法: + +```sql +RENAME PARTITION old_partition_name new_partition_name; +``` + +4. 修改 column 名称 + +修改 column 名称 + +语法: + +```sql +RENAME COLUMN old_column_name new_column_name; +``` + +注意: +- 建表时需要在 property 中设置 light_schema_change=true + + +## 示例 + +1. 将名为 table1 的表修改为 table2 + +```sql +ALTER TABLE table1 RENAME table2; +``` + +2. 将表 example_table 中名为 rollup1 的 rollup index 修改为 rollup2 + +```sql +ALTER TABLE example_table RENAME ROLLUP rollup1 rollup2; +``` + +3. 将表 example_table 中名为 p1 的 partition 修改为 p2 + +```sql +ALTER TABLE example_table RENAME PARTITION p1 p2; +``` + +4. 将表 example_table 中名为 c1 的 column 修改为 c2 + +```sql +ALTER TABLE example_table RENAME COLUMN c1 c2; +``` + +## 关键词 + +```text +ALTER, TABLE, RENAME, ALTER TABLE +``` + + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-REPLACE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-REPLACE.md new file mode 100644 index 0000000000000..87ce04d56b939 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-REPLACE.md @@ -0,0 +1,91 @@ +--- +{ + "title": "ALTER TABLE REPLACE", + "language": "zh-CN" +} +--- + + + + +## 描述 + +对两个表进行原子的替换操作。该操作仅适用于 OLAP 表。 + +```sql +ALTER TABLE [db.]tbl1 REPLACE WITH TABLE tbl2 +[PROPERTIES('swap' = 'true')]; +``` + +将表 tbl1 替换为表 tbl2。 + +如果 `swap` 参数为 `true`,则替换后,名称为 `tbl1` 表中的数据为原 `tbl2` 表中的数据。而名称为 `tbl2` 表中的数据为原 `tbl1` 表中的数据。即两张表数据发生了互换。 + +如果 `swap` 参数为 `false`,则替换后,名称为 `tbl1` 表中的数据为原 `tbl2` 表中的数据。而名称为 `tbl2` 表被删除。 + +### 原理 + +替换表功能,实际上是将以下操作集合变成一个原子操作。 + +假设要将表 A 替换为表 B,且 `swap` 为 `true`,则操作如下: + +1. 将表 B 重名为表 A。 +2. 将表 A 重名为表 B。 + +如果 `swap` 为 `false`,则操作如下: + +1. 删除表 A。 +2. 将表 B 重名为表 A。 + +### 注意事项 +1. `swap` 参数默认为 `true`。即替换表操作相当于将两张表数据进行交换。 +2. 如果设置 `swap` 参数为 `false`,则被替换的表(表 A)将被删除,且无法恢复。 +3. 替换操作仅能发生在两张 OLAP 表之间,且不会检查两张表的表结构是否一致。 +4. 替换操作不会改变原有的权限设置。因为权限检查以表名称为准。 + +## 示例 + +1. 将 `tbl1` 与 `tbl2` 进行原子交换,不删除任何表(注:如果删除的话,实际上删除的是 tbl1,只是将 tbl2 重命名为 tbl1。) + +```sql +ALTER TABLE tbl1 REPLACE WITH TABLE tbl2; +``` +或 +```sql +ALTER TABLE tbl1 REPLACE WITH TABLE tbl2 PROPERTIES('swap' = 'true') ; +``` + +2. 将 `tbl1` 与 `tbl2` 进行交换,删除 `tbl2` 表(保留名为`tbl1`,数据为`tbl2`的表) + +```sql +ALTER TABLE tbl1 REPLACE WITH TABLE tbl2 PROPERTIES('swap' = 'false') ; +``` + +## 关键词 + +```text +ALTER, TABLE, REPLACE, ALTER TABLE +``` + +## 最佳实践 + +1. 原子的覆盖写操作 + + 某些情况下,用户希望能够重写某张表的数据,但如果采用先删除再导入的方式进行,在中间会有一段时间无法查看数据。这时,用户可以先使用 `CREATE TABLE LIKE` 语句创建一个相同结构的新表,将新的数据导入到新表后,通过替换操作,原子的替换旧表,以达到目的。分区级别的原子覆盖写操作,请参阅 [临时分区文档](../../../../advanced/partition/table-temp-partition.md)。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-ROLLUP.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-ROLLUP.md new file mode 100644 index 0000000000000..aad7a96c08e37 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-ROLLUP.md @@ -0,0 +1,135 @@ +--- +{ + "title": "ALTER TABLE ROLLUP", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于对已有 table 进行 rollup 进行修改操作。rollup 是异步操作,任务提交成功则返回,之后可使用[SHOW ALTER](../../../../sql-manual/sql-statements/table-and-view/table/SHOW-ALTER-TABLE) 命令查看进度。 + +语法: + +```sql +ALTER TABLE [database.]table alter_clause; +``` + +rollup 的 alter_clause 支持如下几种创建方式 + +1. 创建 rollup index + +语法: + +```sql +ADD ROLLUP rollup_name (column_name1, column_name2, ...) +[FROM from_index_name] +[PROPERTIES ("key"="value", ...)] +``` + + properties: 支持设置超时时间,默认超时时间为 1 天。 + +2. 批量创建 rollup index + +语法: + +```sql +ADD ROLLUP [rollup_name (column_name1, column_name2, ...) + [FROM from_index_name] + [PROPERTIES ("key"="value", ...)],...] +``` + +注意: + +- 如果没有指定 from_index_name,则默认从 base index 创建 +- rollup 表中的列必须是 from_index 中已有的列 +- 在 properties 中,可以指定存储格式。具体请参阅 [CREATE TABLE](../Create/CREATE-TABLE.md) + +3. 删除 rollup index + + 语法: + +```sql +DROP ROLLUP rollup_name [PROPERTIES ("key"="value", ...)] +``` + +4. 批量删除 rollup index + +语法: + +```sql +DROP ROLLUP [rollup_name [PROPERTIES ("key"="value", ...)],...] +``` + +注意: + +- 不能删除 base index + +## 示例 + +1. 创建 index: example_rollup_index,基于 base index(k1,k2,k3,v1,v2)。列式存储。 + +```sql +ALTER TABLE example_db.my_table +ADD ROLLUP example_rollup_index(k1, k3, v1, v2); +``` + +2. 创建 index: example_rollup_index2,基于 example_rollup_index(k1,k3,v1,v2) + +```sql +ALTER TABLE example_db.my_table +ADD ROLLUP example_rollup_index2 (k1, v1) +FROM example_rollup_index; +``` + +3. 创建 index: example_rollup_index3, 基于 base index (k1,k2,k3,v1), 自定义 rollup 超时时间一小时。 + +```sql +ALTER TABLE example_db.my_table +ADD ROLLUP example_rollup_index(k1, k3, v1) +PROPERTIES("timeout" = "3600"); +``` + +4. 删除 index: example_rollup_index2 + +```sql +ALTER TABLE example_db.my_table +DROP ROLLUP example_rollup_index2; +``` + +5. 批量删除 Rollup + +```sql +ALTER TABLE example_db.my_table +DROP ROLLUP example_rollup_index2,example_rollup_index3; +``` + +## 关键词 + +```text +ALTER, TABLE, ROLLUP, ALTER TABLE +``` + + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/CANCEL-ALTER-TABLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/CANCEL-ALTER-TABLE.md new file mode 100644 index 0000000000000..1630fe7877874 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/CANCEL-ALTER-TABLE.md @@ -0,0 +1,106 @@ +--- +{ + "title": "CANCEL ALTER TABLE", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于撤销一个 ALTER 操作。 + +1. 撤销 ALTER TABLE COLUMN 操作 + +语法: + +```sql +CANCEL ALTER TABLE COLUMN +FROM db_name.table_name +``` + +2. 撤销 ALTER TABLE ROLLUP 操作 + +语法: + +```sql +CANCEL ALTER TABLE ROLLUP +FROM db_name.table_name +``` + +3. 根据 job id 批量撤销 rollup 操作 + +语法: + +```sql +CANCEL ALTER TABLE ROLLUP +FROM db_name.table_name (jobid,...) +``` + +注意: + +- 该命令为异步操作,具体是否执行成功需要使用`show alter table rollup`查看任务状态确认 + +4. 撤销 ALTER CLUSTER 操作 + +语法: + +``` +(待实现...) +``` + +## 示例 + +1. 撤销针对 my_table 的 ALTER COLUMN 操作。 + + [CANCEL ALTER TABLE COLUMN] + +```sql +CANCEL ALTER TABLE COLUMN +FROM example_db.my_table; +``` + +1. 撤销 my_table 下的 ADD ROLLUP 操作。 + + [CANCEL ALTER TABLE ROLLUP] + +```sql +CANCEL ALTER TABLE ROLLUP +FROM example_db.my_table; +``` + +1. 根据 job id 撤销 my_table 下的 ADD ROLLUP 操作。 + + [CANCEL ALTER TABLE ROLLUP] + +```sql +CANCEL ALTER TABLE ROLLUP +FROM example_db.my_table (12801,12802); +``` + +## 关键词 + +CANCEL, ALTER, TABLE, CANCEL ALTER + + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/CREATE-TABLE-AS-SELECT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/CREATE-TABLE-AS-SELECT.md new file mode 100644 index 0000000000000..84af2872a29eb --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/CREATE-TABLE-AS-SELECT.md @@ -0,0 +1,93 @@ +--- +{ + "title": "CREATE TABLE AS SELECT", + "language": "zh-CN" +} +--- + + + +## 描述 + +该语句通过 Select 语句返回结果创建表结构,同时导入数据 + +语法: + +```sql +CREATE TABLE table_name [( column_name_list )] + opt_engine:engineName + opt_keys:keys + opt_comment:tableComment + opt_partition:partition + opt_distribution:distribution + opt_rollup:index + opt_properties:tblProperties + opt_ext_properties:extProperties + KW_AS query_stmt:query_def + ``` + +说明: + +- 用户需要拥有来源表的`SELECT`权限和目标库的`CREATE`权限 +- 创建表成功后,会进行数据导入,如果导入失败,将会删除表 +- 可以自行指定 key type,默认为`Duplicate Key` +- 所有字符串类型的列 (varchar/var/string) 都会被创建为 string 类型。 +- 如果创建的来源为外部表,并且第一列为 String 类型,则会自动将第一列设置为 VARCHAR(65533)。因为 Doris 内部表,不允许 String 列作为第一列。 + +## 示例 + +1. 使用 select 语句中的字段名 + + ```sql + create table `test`.`select_varchar` + PROPERTIES("replication_num" = "1") + as select * from `test`.`varchar_table` + ``` + +2. 自定义字段名 (需要与返回结果字段数量一致) + ```sql + create table `test`.`select_name`(user, testname, userstatus) + PROPERTIES("replication_num" = "1") + as select vt.userId, vt.username, jt.status + from `test`.`varchar_table` vt join + `test`.`join_table` jt on vt.userId=jt.userId + ``` + +3. 指定表模型、分区、分桶 + ```sql + CREATE TABLE t_user(dt, id, name) + ENGINE=OLAP + UNIQUE KEY(dt, id) + COMMENT "OLAP" + PARTITION BY RANGE(dt) + ( + FROM ("2020-01-01") TO ("2021-12-31") INTERVAL 1 YEAR + ) + DISTRIBUTED BY HASH(id) BUCKETS 1 + PROPERTIES("replication_num"="1") + AS SELECT cast('2020-05-20' as date) as dt, 1 as id, 'Tom' as name; + ``` + +## 关键词 + +CREATE, TABLE, AS, SELECT + + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/CREATE-TABLE-LIKE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/CREATE-TABLE-LIKE.md new file mode 100644 index 0000000000000..f43001de0e4b2 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/CREATE-TABLE-LIKE.md @@ -0,0 +1,95 @@ +--- +{ + "title": "CREATE TABLE LIKE", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于创建一个表结构和另一张表完全相同的空表,同时也能够可选复制一些 rollup。 + +语法: + +```sql +CREATE [EXTERNAL] TABLE [IF NOT EXISTS] [database.]table_name LIKE [database.]table_name [WITH ROLLUP (r1,r2,r3,...)] +``` + +说明: + +- 复制的表结构包括 Column Definition、Partitions、Table Properties 等 +- 用户需要对复制的原表有`SELECT`权限 +- 支持复制 MySQL 等外表 +- 支持复制 OLAP Table 的 rollup + +## 示例 + +1. 在 test1 库下创建一张表结构和 table1 相同的空表,表名为 table2 + + ```sql + CREATE TABLE test1.table2 LIKE test1.table1 + ``` + +2. 在 test2 库下创建一张表结构和 test1.table1 相同的空表,表名为 table2 + + ```sql + CREATE TABLE test2.table2 LIKE test1.table1 + ``` + +3. 在 test1 库下创建一张表结构和 table1 相同的空表,表名为 table2,同时复制 table1 的 r1,r2 两个 rollup + + ```sql + CREATE TABLE test1.table2 LIKE test1.table1 WITH ROLLUP (r1,r2) + ``` + +4. 在 test1 库下创建一张表结构和 table1 相同的空表,表名为 table2,同时复制 table1 的所有 rollup + + ```sql + CREATE TABLE test1.table2 LIKE test1.table1 WITH ROLLUP + ``` + +5. 在 test2 库下创建一张表结构和 test1.table1 相同的空表,表名为 table2,同时复制 table1 的 r1,r2 两个 rollup + + ```sql + CREATE TABLE test2.table2 LIKE test1.table1 WITH ROLLUP (r1,r2) + ``` + +6. 在 test2 库下创建一张表结构和 test1.table1 相同的空表,表名为 table2,同时复制 table1 的所有 rollup + + ```sql + CREATE TABLE test2.table2 LIKE test1.table1 WITH ROLLUP + ``` + +7. 在 test1 库下创建一张表结构和 MySQL 外表 table1 相同的空表,表名为 table2 + + ```sql + CREATE TABLE test1.table2 LIKE test1.table1 + ``` + +## 关键词 + +CREATE, TABLE, LIKE + + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/CREATE-TABLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/CREATE-TABLE.md new file mode 100644 index 0000000000000..03e9ad50dbba4 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/CREATE-TABLE.md @@ -0,0 +1,856 @@ +--- +{ + "title": "CREATE TABLE", + "language": "zh-CN", + "toc_min_heading_level": 2, + "toc_max_heading_level": 4 +} +--- + + + + + +## 描述 + +该命令用于创建一张表。本文档主要介绍创建 Doris 自维护的表的语法 + +```sql +CREATE TABLE [IF NOT EXISTS] [database.]table +( + column_definition_list + [, index_definition_list] +) +[engine_type] +[keys_type] +[table_comment] +[partition_info] +distribution_desc +[rollup_list] +[properties] +[extra_properties] +``` + +#### column_definition_list + +列定义列表: + +`column_definition[, column_definition]` +* `column_definition` + 列定义: + + `column_name column_type [KEY] [aggr_type] [NULL] [AUTO_INCREMENT(auto_inc_start_value)] [default_value] [on update current_timestamp] [column_comment]` + * `column_type` + 列类型,支持以下类型: + ``` + TINYINT(1 字节) + 范围:-2^7 + 1 ~ 2^7 - 1 + SMALLINT(2 字节) + 范围:-2^15 + 1 ~ 2^15 - 1 + INT(4 字节) + 范围:-2^31 + 1 ~ 2^31 - 1 + BIGINT(8 字节) + 范围:-2^63 + 1 ~ 2^63 - 1 + LARGEINT(16 字节) + 范围:-2^127 + 1 ~ 2^127 - 1 + FLOAT(4 字节) + 支持科学计数法 + DOUBLE(12 字节) + 支持科学计数法 + DECIMAL[(PRECISION, SCALE)] (16 字节) + 保证精度的小数类型。默认是 DECIMAL(9, 0) + PRECISION: 1 ~ 27 + SCALE: 0 ~ 9 + 其中整数部分为 1 ~ 18 + 不支持科学计数法 + DATE(3 字节) + 范围:0000-01-01 ~ 9999-12-31 + DATETIME(8 字节) + 范围:0000-01-01 00:00:00 ~ 9999-12-31 23:59:59 + CHAR[(length)] + 定长字符串。长度范围:1 ~ 255。默认为 1 + VARCHAR[(length)] + 变长字符串。长度范围:1 ~ 65533。默认为 65533 + HLL (1~16385 个字节) + HyperLogLog 列类型,不需要指定长度和默认值。长度根据数据的聚合程度系统内控制。 + 必须配合 HLL_UNION 聚合类型使用。 + BITMAP + bitmap 列类型,不需要指定长度和默认值。表示整型的集合,元素最大支持到 2^64 - 1。 + 必须配合 BITMAP_UNION 聚合类型使用。 + ``` + * `aggr_type` + 聚合类型,支持以下聚合类型: + ``` + SUM:求和。适用数值类型。 + MIN:求最小值。适合数值类型。 + MAX:求最大值。适合数值类型。 + REPLACE:替换。对于维度列相同的行,指标列会按照导入的先后顺序,后导入的替换先导入的。 + REPLACE_IF_NOT_NULL:非空值替换。和 REPLACE 的区别在于对于 NULL 值,不做替换。这里要注意的是字段默认值要给 NULL,而不能是空字符串,如果是空字符串,会给你替换成空字符串。 + HLL_UNION:HLL 类型的列的聚合方式,通过 HyperLogLog 算法聚合。 + BITMAP_UNION:BIMTAP 类型的列的聚合方式,进行位图的并集聚合。 + ``` + * `AUTO_INCREMENT(auto_inc_start_value)` + + 是否为自增列,自增列可以用来为新插入的行生成一个唯一标识。在插入表数据时如果没有指定自增列的值,则会自动生成一个合法的值。当自增列被显示地插入 NULL 时,其值也会被替换为生成的合法值。需要注意的是,处于性能考虑,BE 会在内存中缓存部分自增列的值,所以自增列自动生成的值只能保证单调性和唯一性,无法保证严格的连续性。 + 一张表中至多有一个列是自增列,自增列必须是 BIGINT 类型,且必须为 NOT NULL。 + Duplicate 模型表和 Unique 模型表均支持自增列。 + 可以通过给定`auto_inc_start_value`的方式指定自增列的起始值,如果不指定,则默认起始值为 1。 + + * `default_value` + 列默认值,当导入数据未指定该列的值时,系统将赋予该列 `default_value`。 + + 语法为`default default_value`。 + + 当前 `default_value` 支持两种形式: + 1. 用户指定固定值,如: + ```SQL + k1 INT DEFAULT '1', + k2 CHAR(10) DEFAULT 'aaaa' + ``` + 2. 系统提供的关键字,目前支持以下关键字: + + ```SQL + // 只用于 DATETIME 类型,导入数据缺失该值时系统将赋予当前时间 + dt DATETIME DEFAULT CURRENT_TIMESTAMP + // 只用于 DATE 类型,导入数据缺失该值时系统将赋予当前日期 + dt DATE DEFAULT CURRENT_DATE + ``` + * `on update current_timestamp` + + 是否在该行有列更新时将该列的值更新为当前时间 (`current_timestamp`)。该特性只能在开启了 Merge-on-Write 的 Unique 表上使用,开启了这个特性的列必须声明默认值,且默认值必须为`current_timestamp`。如果此处声明了时间戳的精度,则该列默认值中的时间戳精度必须与该处的时间戳精度相同。 + + + 示例: + + ```text + k1 TINYINT, + k2 DECIMAL(10,2) DEFAULT "10.5", + k4 BIGINT NULL DEFAULT "1000" COMMENT "This is column k4", + v1 VARCHAR(10) REPLACE NOT NULL, + v2 BITMAP BITMAP_UNION, + v3 HLL HLL_UNION, + v4 INT SUM NOT NULL DEFAULT "1" COMMENT "This is column v4" + dt datetime(6) default current_timestamp(6) on update current_timestamp(6) + ``` + +#### index_definition_list + +索引列表定义: + +`index_definition[, index_definition]` + +* `index_definition` + + 索引定义: + + ```sql + INDEX index_name (col_name) [USING INVERTED] COMMENT 'xxxxxx' + ``` + + 示例: + + ```sql + INDEX idx1 (k1) USING INVERTED COMMENT "This is a inverted index1", + INDEX idx2 (k2) USING INVERTED COMMENT "This is a inverted index2", + ... + ``` + +#### engine_type + +表引擎类型。本文档中类型皆为 OLAP。示例: + + `ENGINE=olap` + +#### keys_type + +数据模型。 + +`key_type(col1, col2, ...)` + +`key_type` 支持以下模型: + +* DUPLICATE KEY(默认):其后指定的列为排序列。 +* AGGREGATE KEY:其后指定的列为维度列。 +* UNIQUE KEY:其后指定的列为主键列。 + +:::info 备注 +注:当表属性`enable_duplicate_without_keys_by_default = true`时,默认创建没有排序列的 Duplicate 表。 +::: + +示例: + +``` +DUPLICATE KEY(col1, col2), +AGGREGATE KEY(k1, k2, k3), +UNIQUE KEY(k1, k2) +``` + +#### table_comment + +表注释。示例: + + ``` + COMMENT "This is my first DORIS table" + ``` + +#### partition_info + +分区信息,支持三种写法: + +1. LESS THAN:仅定义分区上界。下界由上一个分区的上界决定。 + + ``` + PARTITION BY RANGE(col1[, col2, ...]) + ( + PARTITION partition_name1 VALUES LESS THAN MAXVALUE|("value1", "value2", ...), + PARTITION partition_name2 VALUES LESS THAN MAXVALUE|("value1", "value2", ...) + ) + ``` + +2. FIXED RANGE:定义分区的左闭右开区间。 + + ``` + PARTITION BY RANGE(col1[, col2, ...]) + ( + PARTITION partition_name1 VALUES [("k1-lower1", "k2-lower1", "k3-lower1",...), ("k1-upper1", "k2-upper1", "k3-upper1", ...)), + PARTITION partition_name2 VALUES [("k1-lower1-2", "k2-lower1-2", ...), ("k1-upper1-2", MAXVALUE, )) + ) + ``` + +3. MULTI RANGE:批量创建 RANGE 分区,定义分区的左闭右开区间,设定时间单位和步长,时间单位支持年、月、日、周和小时。 + + ``` + PARTITION BY RANGE(col) + ( + FROM ("2000-11-14") TO ("2021-11-14") INTERVAL 1 YEAR, + FROM ("2021-11-14") TO ("2022-11-14") INTERVAL 1 MONTH, + FROM ("2022-11-14") TO ("2023-01-03") INTERVAL 1 WEEK, + FROM ("2023-01-03") TO ("2023-01-14") INTERVAL 1 DAY + ) + ``` + +4. MULTI RANGE:批量创建数字类型的 RANGE 分区,定义分区的左闭右开区间,设定步长。 + + ``` + PARTITION BY RANGE(int_col) + ( + FROM (1) TO (100) INTERVAL 10 + ) + ``` + + +#### distribution_desc + +定义数据分桶方式。 + +1. Hash 分桶 + 语法: + `DISTRIBUTED BY HASH (k1[,k2 ...]) [BUCKETS num|auto]` + 说明: + 使用指定的 Key 列进行哈希分桶。 +2. Random 分桶 + 语法: + `DISTRIBUTED BY RANDOM [BUCKETS num|auto]` + 说明: + 使用随机数进行分桶。 + +#### rollup_list + +建表的同时可以创建多个物化视图(ROLLUP)。 + +`ROLLUP (rollup_definition[, rollup_definition, ...])` + +* `rollup_definition` + + `rollup_name (col1[, col2, ...]) [DUPLICATE KEY(col1[, col2, ...])] [PROPERTIES("key" = "value")]` + + 示例: + + ``` + ROLLUP ( + r1 (k1, k3, v1, v2), + r2 (k1, v1) + ) + ``` + +#### properties + +设置表属性。目前支持以下属性: + +* `replication_num` + + 副本数。默认副本数为 3。如果 BE 节点数量小于 3,则需指定副本数小于等于 BE 节点数量。 + + 在 0.15 版本后,该属性将自动转换成 `replication_allocation` 属性,如: + + `"replication_num" = "3"` 会自动转换成 `"replication_allocation" = "tag.location.default:3"` + +* `replication_allocation` + + 根据 Tag 设置副本分布情况。该属性可以完全覆盖 `replication_num` 属性的功能。 + +* `min_load_replica_num` + + 设定数据导入成功所需的最小副本数,默认值为 -1。当该属性小于等于 0 时,表示导入数据仍需多数派副本成功。 + +* `is_being_synced` + + 用于标识此表是否是被 CCR 复制而来并且正在被 Syncer 同步,默认为 `false`。 + + 如果设置为 `true`: + `colocate_with`,`storage_policy`属性将被擦除 + `dynamic partition`,`auto bucket`功能将会失效,即在`show create table`中显示开启状态,但不会实际生效。当`is_being_synced`被设置为 `false` 时,这些功能将会恢复生效。 + + 这个属性仅供 CCR 外围模块使用,在 CCR 同步的过程中不要手动设置。 + +* `storage_medium/storage_cooldown_time` + + 数据存储介质。`storage_medium` 用于声明表数据的初始存储介质,而 `storage_cooldown_time` 用于设定到期时间。示例: + + ``` + "storage_medium" = "SSD", + "storage_cooldown_time" = "2020-11-20 00:00:00" + ``` + + 这个示例表示数据存放在 SSD 中,并且在 2020-11-20 00:00:00 到期后,会自动迁移到 HDD 存储上。 + +* `colocate_with` + + 当需要使用 Colocation Join 功能时,使用这个参数设置 Colocation Group。 + + `"colocate_with" = "group1"` + +* `bloom_filter_columns` + + 用户指定需要添加 Bloom Filter 索引的列名称列表。各个列的 Bloom Filter 索引是独立的,并不是组合索引。 + + `"bloom_filter_columns" = "k1, k2, k3"` + +* `in_memory` + + 已弃用。只支持设置为'false'。 + +* `compression` + + Doris 表的默认压缩方式是 LZ4。1.1 版本后,支持将压缩方式指定为 ZSTD 以获得更高的压缩比。 + + `"compression"="zstd"` + +* `function_column.Sequence_col` + + 当使用 Unique Key 模型时,可以指定一个 Sequence 列,当 Key 列相同时,将按照 Sequence 列进行 REPLACE(较大值替换较小值,否则无法替换) + + `function_column.sequence_col`用来指定 Sequence 列到表中某一列的映射,该列可以为整型和时间类型(DATE、DATETIME),创建后不能更改该列的类型。如果设置了`function_column.sequence_col`, `function_column.sequence_type`将被忽略。 + + `"function_column.sequence_col" = 'column_name'` + +* `function_column.sequence_type` + + 当使用 Unique Key 模型时,可以指定一个 Sequence 列,当 Key 列相同时,将按照 Sequence 列进行 REPLACE (较大值替换较小值,否则无法替换) + + 这里我们仅需指定顺序列的类型,支持时间类型或整型。Doris 会创建一个隐藏的顺序列。 + + `"function_column.sequence_type" = 'Date'` + +* `enable_unique_key_merge_on_write` + + Unique 表是否使用 Merge-on-Write 实现。 + + 该属性在 2.1 版本之前默认关闭,从 2.1 版本开始默认开启。 + +* `light_schema_change` + + 是否使用 Light Schema Change 优化。 + + 如果设置成 `true`, 对于值列的加减操作,可以更快地,同步地完成。 + + `"light_schema_change" = 'true'` + + 该功能在 2.0.0 及之后版本默认开启。 + +* `disable_auto_compaction` + + 是否对这个表禁用自动 Compaction。 + + 如果这个属性设置成 `true`, 后台的自动 Compaction 进程会跳过这个表的所有 Tablet。 + + `"disable_auto_compaction" = "false"` + +* `enable_single_replica_compaction` + + 是否对这个表开启单副本 compaction。 + + 如果这个属性设置成 `true`, 这个表的 tablet 的所有副本只有一个 do compaction,其他的从该副本拉取 rowset + + `"enable_single_replica_compaction" = "false"` + +* `enable_duplicate_without_keys_by_default` + + 当配置为`true`时,如果创建表的时候没有指定 Unique、Aggregate 或 Duplicate 模型,会默认创建一个没有排序列和前缀索引的 Duplicate 模型的表。 + + `"enable_duplicate_without_keys_by_default" = "false"` + +* `skip_write_index_on_load` + + 是否对这个表开启数据导入时不写索引。 + + 如果这个属性设置成 `true`, 数据导入的时候不写索引(目前仅对倒排索引生效),而是在 Compaction 的时候延迟写索引。这样可以避免首次写入和 Compaction + 重复写索引的 CPU 和 IO 资源消耗,提升高吞吐导入的性能。 + + `"skip_write_index_on_load" = "false"` + +* `compaction_policy` + + 配置这个表的 Compaction 的合并策略,仅支持配置为 time_series 或者 size_based + + time_series: 当 rowset 的磁盘体积积攒到一定大小时进行版本合并。合并后的 rowset 直接晋升到 base compaction 阶段。在时序场景持续导入的情况下有效降低 compact 的写入放大率 + + 此策略将使用 time_series_compaction 为前缀的参数调整 Compaction 的执行 + + `"compaction_policy" = ""` + +* `group_commit_interval_ms` + + 配置这个表的 Group Commit 攒批间隔。单位为 ms,默认值为 10000ms,即 10s。 + + Group Commit 的下刷时机取决于 `group_commit_interval_ms`以及`group_commit_data_bytes`哪个先到设置的值。 + + `"group_commit_interval_ms" = "10000"` + +* `group_commit_data_bytes` + + 配置这个表的 Group Commit 攒批数据大小。单位为 bytes,默认值为 134217728 bytes,即 128MB。 + + Group Commit 的下刷时机取决于 `group_commit_interval_ms`以及`group_commit_data_bytes` 哪个先到设置的值。 + + `"group_commit_data_bytes" = "134217728"` + +* `time_series_compaction_goal_size_mbytes` + + Compaction 的合并策略为 time_series 时,将使用此参数来调整每次 Compaction 输入的文件的大小,输出的文件大小和输入相当 + + `"time_series_compaction_goal_size_mbytes" = "1024"` + +* `time_series_compaction_file_count_threshold` + + compaction 的合并策略为 time_series 时,将使用此参数来调整每次 Compaction 输入的文件数量的最小值 + + 一个 tablet 中,文件数超过该配置,就会触发 compaction + + `"time_series_compaction_file_count_threshold" = "2000"` + +* `time_series_compaction_time_threshold_seconds` + + Compaction 的合并策略为 time_series 时,将使用此参数来调整 Compaction 的最长时间间隔,即长时间未执行过 Compaction 时,就会触发一次 Compaction,单位为秒 + + `"time_series_compaction_time_threshold_seconds" = "3600"` + +* `time_series_compaction_level_threshold` + + Compaction 的合并策略为 `time_series` 时,此参数默认为 1,当设置为 2 时用来控住对于合并过一次的段再合并一层,保证段大小达到 `time_series_compaction_goal_size_mbytes`, + + 能达到段数量减少的效果。 + + `"time_series_compaction_level_threshold" = "2"` + +* `enable_mow_light_delete` + + 是否在 Unique 表 Mow 上开启 Delete 语句写 Delete predicate。若开启,会提升 Delete 语句的性能,但 Delete 后进行部分列更新可能会出现部分数据错误的情况。若关闭,会降低 Delete 语句的性能来保证正确性。 + + 此属性的默认值为 `false`。 + + 此属性只能在 Unique Merge-on-Write 表上开启。 + + `"enable_mow_light_delete" = "true"` + +* 动态分区相关 + + 动态分区相关参考[数据划分 - 动态分区](../../../../table-design/data-partitioning/auto-partitioning) + +* `file_cache_ttl_seconds`: + + TTL 在计算存储分离模式下的过期时间。 + +## 示例 + +1. 创建一个明细模型的表 + + ```sql + CREATE TABLE example_db.table_hash + ( + k1 TINYINT, + k2 DECIMAL(10, 2) DEFAULT "10.5", + k3 CHAR(10) COMMENT "string column", + k4 INT NOT NULL DEFAULT "1" COMMENT "int column" + ) + COMMENT "my first table" + DISTRIBUTED BY HASH(k1) BUCKETS 32 + ``` + +2. 创建一个明细模型的表,分区,指定排序列,设置副本数为 1 + + ```sql + CREATE TABLE example_db.table_hash + ( + k1 DATE, + k2 DECIMAL(10, 2) DEFAULT "10.5", + k3 CHAR(10) COMMENT "string column", + k4 INT NOT NULL DEFAULT "1" COMMENT "int column" + ) + DUPLICATE KEY(k1, k2) + COMMENT "my first table" + PARTITION BY RANGE(k1) + ( + PARTITION p1 VALUES LESS THAN ("2020-02-01"), + PARTITION p2 VALUES LESS THAN ("2020-03-01"), + PARTITION p3 VALUES LESS THAN ("2020-04-01") + ) + DISTRIBUTED BY HASH(k1) BUCKETS 32 + PROPERTIES ( + "replication_num" = "1" + ); + ``` + +3. 创建一个主键唯一模型的表,设置初始存储介质和冷却时间 + + ```sql + CREATE TABLE example_db.table_hash + ( + k1 BIGINT, + k2 LARGEINT, + v1 VARCHAR(2048), + v2 SMALLINT DEFAULT "10" + ) + UNIQUE KEY(k1, k2) + DISTRIBUTED BY HASH (k1, k2) BUCKETS 32 + PROPERTIES( + "storage_medium" = "SSD", + "storage_cooldown_time" = "2015-06-04 00:00:00" + ); + ``` + +4. 创建一个聚合模型表,使用固定范围分区描述 + + ```sql + CREATE TABLE table_range + ( + k1 DATE, + k2 INT, + k3 SMALLINT, + v1 VARCHAR(2048) REPLACE, + v2 INT SUM DEFAULT "1" + ) + AGGREGATE KEY(k1, k2, k3) + PARTITION BY RANGE (k1, k2, k3) + ( + PARTITION p1 VALUES [("2014-01-01", "10", "200"), ("2014-01-01", "20", "300")), + PARTITION p2 VALUES [("2014-06-01", "100", "200"), ("2014-07-01", "100", "300")) + ) + DISTRIBUTED BY HASH(k2) BUCKETS 32 + ``` + +5. 创建一个包含 HLL 和 BITMAP 列类型的聚合模型表 + + ```sql + CREATE TABLE example_db.example_table + ( + k1 TINYINT, + k2 DECIMAL(10, 2) DEFAULT "10.5", + v1 HLL HLL_UNION, + v2 BITMAP BITMAP_UNION + ) + ENGINE=olap + AGGREGATE KEY(k1, k2) + DISTRIBUTED BY HASH(k1) BUCKETS 32 + ``` + +6. 创建两张同一个 Colocation Group 自维护的表。 + + ```sql + CREATE TABLE t1 ( + id int(11) COMMENT "", + value varchar(8) COMMENT "" + ) + DUPLICATE KEY(id) + DISTRIBUTED BY HASH(id) BUCKETS 10 + PROPERTIES ( + "colocate_with" = "group1" + ); + + CREATE TABLE t2 ( + id int(11) COMMENT "", + value1 varchar(8) COMMENT "", + value2 varchar(8) COMMENT "" + ) + DUPLICATE KEY(`id`) + DISTRIBUTED BY HASH(`id`) BUCKETS 10 + PROPERTIES ( + "colocate_with" = "group1" + ); + ``` + +7. 创建一个带有倒排索引以及 bloom filter 索引的表 + + ```sql + CREATE TABLE example_db.table_hash + ( + k1 TINYINT, + k2 DECIMAL(10, 2) DEFAULT "10.5", + v1 CHAR(10) REPLACE, + v2 INT SUM, + INDEX k1_idx (k1) USING INVERTED COMMENT 'my first index' + ) + AGGREGATE KEY(k1, k2) + DISTRIBUTED BY HASH(k1) BUCKETS 32 + PROPERTIES ( + "bloom_filter_columns" = "k2" + ); + ``` + +8. 创建一个动态分区表。 + + 该表每天提前创建 3 天的分区,并删除 3 天前的分区。例如今天为`2020-01-08`,则会创建分区名为`p20200108`, `p20200109`, `p20200110`, `p20200111`的分区。分区范围分别为: + + ``` + [types: [DATE]; keys: [2020-01-08]; ‥types: [DATE]; keys: [2020-01-09]; ) + [types: [DATE]; keys: [2020-01-09]; ‥types: [DATE]; keys: [2020-01-10]; ) + [types: [DATE]; keys: [2020-01-10]; ‥types: [DATE]; keys: [2020-01-11]; ) + [types: [DATE]; keys: [2020-01-11]; ‥types: [DATE]; keys: [2020-01-12]; ) + ``` + + ```sql + CREATE TABLE example_db.dynamic_partition + ( + k1 DATE, + k2 INT, + k3 SMALLINT, + v1 VARCHAR(2048), + v2 DATETIME DEFAULT "2014-02-04 15:36:00" + ) + DUPLICATE KEY(k1, k2, k3) + PARTITION BY RANGE (k1) () + DISTRIBUTED BY HASH(k2) BUCKETS 32 + PROPERTIES( + "dynamic_partition.time_unit" = "DAY", + "dynamic_partition.start" = "-3", + "dynamic_partition.end" = "3", + "dynamic_partition.prefix" = "p", + "dynamic_partition.buckets" = "32" + ); + ``` + +9. 创建一个带有物化视图(ROLLUP)的表。 + + ```sql + CREATE TABLE example_db.rolup_index_table + ( + event_day DATE, + siteid INT DEFAULT '10', + citycode SMALLINT, + username VARCHAR(32) DEFAULT '', + pv BIGINT SUM DEFAULT '0' + ) + AGGREGATE KEY(event_day, siteid, citycode, username) + DISTRIBUTED BY HASH(siteid) BUCKETS 10 + ROLLUP ( + r1(event_day,siteid), + r2(event_day,citycode), + r3(event_day) + ) + PROPERTIES("replication_num" = "3"); + ``` + +10. 通过 `replication_allocation` 属性设置表的副本。 + + ```sql + CREATE TABLE example_db.table_hash + ( + k1 TINYINT, + k2 DECIMAL(10, 2) DEFAULT "10.5" + ) + DISTRIBUTED BY HASH(k1) BUCKETS 32 + PROPERTIES ( + "replication_allocation"="tag.location.group_a:1, tag.location.group_b:2" + ); + ``` + ```sql + CREATE TABLE example_db.dynamic_partition + ( + k1 DATE, + k2 INT, + k3 SMALLINT, + v1 VARCHAR(2048), + v2 DATETIME DEFAULT "2014-02-04 15:36:00" + ) + PARTITION BY RANGE (k1) () + DISTRIBUTED BY HASH(k2) BUCKETS 32 + PROPERTIES( + "dynamic_partition.time_unit" = "DAY", + "dynamic_partition.start" = "-3", + "dynamic_partition.end" = "3", + "dynamic_partition.prefix" = "p", + "dynamic_partition.buckets" = "32", + "dynamic_partition.replication_allocation" = "tag.location.group_a:3" + ); + ``` + +11. 通过`storage_policy`属性设置表的冷热分层数据迁移策略 + ```sql + CREATE TABLE IF NOT EXISTS create_table_use_created_policy + ( + k1 BIGINT, + k2 LARGEINT, + v1 VARCHAR(2048) + ) + UNIQUE KEY(k1) + DISTRIBUTED BY HASH (k1) BUCKETS 3 + PROPERTIES( + "storage_policy" = "test_create_table_use_policy", + "replication_num" = "1" + ); + ``` +注:需要先创建 S3 Resource 和 Storage Policy,表才能关联迁移策略成功 + +12. 为表的分区添加冷热分层数据迁移策略 + ```sql + CREATE TABLE create_table_partion_use_created_policy + ( + k1 DATE, + k2 INT, + V1 VARCHAR(2048) REPLACE + ) PARTITION BY RANGE (k1) ( + PARTITION p1 VALUES LESS THAN ("2022-01-01") ("storage_policy" = "test_create_table_partition_use_policy_1" ,"replication_num"="1"), + PARTITION p2 VALUES LESS THAN ("2022-02-01") ("storage_policy" = "test_create_table_partition_use_policy_2" ,"replication_num"="1") + ) DISTRIBUTED BY HASH(k2) BUCKETS 1; + ``` +注:需要先创建 S3 Resource 和 Storage Policy,表才能关联迁移策略成功 + +1. 批量创建分区 + ```sql + CREATE TABLE create_table_multi_partion_date + ( + k1 DATE, + k2 INT, + V1 VARCHAR(20) + ) PARTITION BY RANGE (k1) ( + FROM ("2000-11-14") TO ("2021-11-14") INTERVAL 1 YEAR, + FROM ("2021-11-14") TO ("2022-11-14") INTERVAL 1 MONTH, + FROM ("2022-11-14") TO ("2023-01-03") INTERVAL 1 WEEK, + FROM ("2023-01-03") TO ("2023-01-14") INTERVAL 1 DAY, + PARTITION p_20230114 VALUES [('2023-01-14'), ('2023-01-15')) + ) DISTRIBUTED BY HASH(k2) BUCKETS 1 + PROPERTIES( + "replication_num" = "1" + ); + ``` + ```sql + CREATE TABLE create_table_multi_partion_date_hour + ( + k1 DATETIME, + k2 INT, + V1 VARCHAR(20) + ) PARTITION BY RANGE (k1) ( + FROM ("2023-01-03 12") TO ("2023-01-14 22") INTERVAL 1 HOUR + ) DISTRIBUTED BY HASH(k2) BUCKETS 1 + PROPERTIES( + "replication_num" = "1" + ); + ``` + ```sql + CREATE TABLE create_table_multi_partion_integer + ( + k1 BIGINT, + k2 INT, + V1 VARCHAR(20) + ) PARTITION BY RANGE (k1) ( + FROM (1) TO (100) INTERVAL 10 + ) DISTRIBUTED BY HASH(k2) BUCKETS 1 + PROPERTIES( + "replication_num" = "1" + ); + ``` +:::info 备注 +注:批量创建分区可以和常规手动创建分区混用,使用时需要限制分区列只能有一个,批量创建分区实际创建默认最大数量为 4096,这个参数可以在 FE 配置项 `max_multi_partition_num` 调整。 +::: + +1. 批量无排序列 Duplicate 表 + + ```sql + CREATE TABLE example_db.table_hash + ( + k1 DATE, + k2 DECIMAL(10, 2) DEFAULT "10.5", + k3 CHAR(10) COMMENT "string column", + k4 INT NOT NULL DEFAULT "1" COMMENT "int column" + ) + COMMENT "duplicate without keys" + PARTITION BY RANGE(k1) + ( + PARTITION p1 VALUES LESS THAN ("2020-02-01"), + PARTITION p2 VALUES LESS THAN ("2020-03-01"), + PARTITION p3 VALUES LESS THAN ("2020-04-01") + ) + DISTRIBUTED BY HASH(k1) BUCKETS 32 + PROPERTIES ( + "replication_num" = "1", + "enable_duplicate_without_keys_by_default" = "true" + ); + ``` + +## 关键词 + + CREATE, TABLE + +### 最佳实践 + +#### 分区和分桶 + +一个表必须指定分桶列,但可以不指定分区。关于分区和分桶的具体介绍,可参阅 [数据划分](../../../../table-design/data-partitioning/basic-concepts) 文档。 + +Doris 中的表可以分为分区表和无分区的表。这个属性在建表时确定,之后不可更改。即对于分区表,可以在之后的使用过程中对分区进行增删操作,而对于无分区的表,之后不能再进行增加分区等操作。 + +同时,分区列和分桶列在表创建之后不可更改,既不能更改分区和分桶列的类型,也不能对这些列进行任何增删操作。 + +所以建议在建表前,先确认使用方式来进行合理的建表。 + +#### 动态分区 + +动态分区功能主要用于帮助用户自动的管理分区。通过设定一定的规则,Doris 系统定期增加新的分区或删除历史分区。可参阅 [动态分区](../../../../table-design/data-partitioning/dynamic-partitioning) 文档查看更多帮助。 + +#### 自动分区 + +自动分区功能文档参见 [自动分区](../../../../table-design/data-partitioning/auto-partitioning)。 + +#### 物化视图 + +用户可以在建表的同时创建多个物化视图(ROLLUP)。物化视图也可以在建表之后添加。写在建表语句中可以方便用户一次性创建所有物化视图。 + +如果在建表时创建好物化视图,则后续的所有数据导入操作都会同步生成物化视图的数据。物化视图的数量可能会影响数据导入的效率。 + +如果在之后的使用过程中添加物化视图,如果表中已有数据,则物化视图的创建时间取决于当前数据量大小。 + +关于物化视图的介绍,请参阅文档 [同步物化视图](../../../../query/view-materialized-view/materialized-view)。 + +#### 索引 + +用户可以在建表的同时创建多个列的索引。索引也可以在建表之后再添加。 + +如果在之后的使用过程中添加索引,如果表中已有数据,则需要重写所有数据,因此索引的创建时间取决于当前数据量。 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/DESC-TABLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/DESC-TABLE.md new file mode 100644 index 0000000000000..6b1d8c3ae9eb6 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/DESC-TABLE.md @@ -0,0 +1,61 @@ +--- +{ + "title": "DESCRIBE", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句用于展示指定 table 的 schema 信息 + +语法: + +```sql +DESC[RIBE] [db_name.]table_name [ALL]; +``` + +说明: + +1. 如果指定 ALL,则显示该 table 的所有 index(rollup) 的 schema + +## 示例 + +1. 显示 Base 表 Schema + + ```sql + DESC table_name; + ``` + +2. 显示表所有 index 的 schema + + ```sql + DESC db1.table_name ALL; + ``` + +## 关键词 + +DESCRIBE, DESC + + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/DROP-TABLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/DROP-TABLE.md new file mode 100644 index 0000000000000..6d84cdbd4a5cb --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/DROP-TABLE.md @@ -0,0 +1,64 @@ +--- +{ + "title": "DROP TABLE", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句用于删除 Table。 + +语法: + +```sql +DROP TABLE [IF EXISTS] [db_name.]table_name [FORCE]; +``` + + +说明: + +- 执行 `DROP TABLE` 一段时间内,可以通过 RECOVER 语句恢复被删除的表。详见 [RECOVER](../../../../sql-manual/sql-statements/recycle/RECOVER) 语句。 +- 如果执行 `DROP TABLE FORCE`,则系统不会检查该表是否存在未完成的事务,表将直接被删除并且不能被恢复,一般不建议执行此操作。 + +## 示例 + +1. 删除一个 Table + + ```sql + DROP TABLE my_table; + ``` + +2. 如果存在,删除指定 Database 的 Table + + ```sql + DROP TABLE IF EXISTS example_db.my_table; + ``` + + +## 关键词 + +DROP, TABLE + + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-ALTER-TABLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-ALTER-TABLE.md new file mode 100644 index 0000000000000..b6d0d0773133f --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-ALTER-TABLE.md @@ -0,0 +1,93 @@ +--- +{ + "title": "SHOW ALTER TABLE", + "language": "zh-CN" +} + +--- + + + +## 描述 + +该语句用于展示当前正在进行的各类修改任务的执行情况 + +```sql +SHOW ALTER [TABLE [COLUMN | ROLLUP] [FROM db_name]]; +``` + +说明: + +1. TABLE COLUMN:展示修改列的 ALTER 任务 +2. 支持语法[WHERE TableName|CreateTime|FinishTime|State] [ORDER BY] [LIMIT] +3. TABLE ROLLUP:展示创建或删除 ROLLUP 的任务 +4. 如果不指定 db_name,使用当前默认 db + +## Result + +*SHOW ALTER TABLE COLUMN* + +| 字段名 | 描述 | +|-----------------------|------------------------------------------------------------------| +| JobId | 每个 Schema Change 作业的唯一 ID。 | +| TableName | 对应 Schema Change 的基表的表名。 | +| CreateTime | 作业创建时间。 | +| FinishedTime | 作业完成时间。如果未完成,显示 "N/A"。 | +| IndexName | 此修改中涉及的一个基表/同步物化视图的名称。 | +| IndexId | 新基表/同步物化视图的 ID。 | +| OriginIndexId | 此修改中涉及的一个基表/同步物化视图的 ID。 | +| SchemaVersion | 以 M:N 的格式显示。M 代表 Schema Change 的版本,N 代表对应的 Hash 值。每次 Schema Change 都会增加版本。 | +| TransactionId | 用于转换历史数据的事务 ID。 | +| State | 作业的阶段。 | +| | - PENDING: 作业正在等待在队列中调度。 | +| | - WAITING_TXN: 等待分界事务 ID 前的导入任务完成。 | +| | - RUNNING: 正在进行历史数据转换。 | +| | - FINISHED: 作业成功完成。 | +| | - CANCELLED: 作业失败。 | +| Msg | 如果作业失败,显示失败信息。 | +| Progress | 作业进度。仅在 RUNNING 状态下显示。进度以 M/N 的形式显示。N 是 Schema Change 中涉及的副本的总数。M 是已完成历史数据转换的副本数。 | +| Timeout | 作业超时时间,以秒为单位。 | + + +## 示例 + +1. 展示默认 db 的所有修改列的任务执行情况 + + ```sql + SHOW ALTER TABLE COLUMN; + ``` + +2. 展示某个表最近一次修改列的任务执行情况 + + ```sql + SHOW ALTER TABLE COLUMN WHERE TableName = "table1" ORDER BY CreateTime DESC LIMIT 1; + ``` + +3. 展示指定 db 的创建或删除 ROLLUP 的任务执行情况 + + ```sql + SHOW ALTER TABLE ROLLUP FROM example_db; + ``` + +## 关键词 + + SHOW, ALTER + +## 最佳实践 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-COLUMNS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-COLUMNS.md new file mode 100644 index 0000000000000..ababe0a7a3651 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-COLUMNS.md @@ -0,0 +1,50 @@ +--- +{ + "title": "SHOW COLUMNS", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句用于指定表的列信息 + +语法: + +```sql +SHOW [FULL] COLUMNS FROM tbl; +``` + +## 示例 + +1. 查看指定表的列信息 + + ```sql + SHOW FULL COLUMNS FROM tbl; + ``` + +## 关键词 + +SHOW, FULL, COLUMNS + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-CONVERT-LIGHT-SCHEMA-CHANGE-PROCESS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-CONVERT-LIGHT-SCHEMA-CHANGE-PROCESS.md new file mode 100644 index 0000000000000..9bfcf8122f3fa --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-CONVERT-LIGHT-SCHEMA-CHANGE-PROCESS.md @@ -0,0 +1,59 @@ +--- +{ + "title": "SHOW CONVERT LIGHT SCHEMA CHANGE PROCESS", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +用来查看将非 light schema change 的 olpa 表转换为 light schema change 表的情况,需要开启配置`enable_convert_light_weight_schema_change` + +语法: + +```sql +SHOW CONVERT_LIGHT_SCHEMA_CHANGE_PROCESS [FROM db] +``` + +## 示例 + +1. 查看在 database test 上的转换情况 + + ```sql + SHOW CONVERT_LIGHT_SCHEMA_CHANGE_PROCESS FROM test; + ``` + +2. 查看全局的转换情况 + + ```sql + SHOW CONVERT_LIGHT_SCHEMA_CHANGE_PROCESS; + ``` + + +## 关键词 + +SHOW, CONVERT_LIGHT_SCHEMA_CHANGE_PROCESS + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-CREATE-TABLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-CREATE-TABLE.md new file mode 100644 index 0000000000000..6649f6c6c9961 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-CREATE-TABLE.md @@ -0,0 +1,59 @@ +--- +{ + "title": "SHOW CREATE TABLE", + "language": "zh-CN" +} +--- + + + + + + + +## 描述 + +该语句用于展示数据表的创建语句。 + +语法: + +```sql +SHOW [BRIEF] CREATE TABLE [DBNAME.]TABLE_NAME +``` + +说明: + +1. `BRIEF` : 返回结果中不展示分区信息 +2. `DBNAMNE` : 数据库名称 +3. `TABLE_NAME` : 表名 + +## 示例 + +1. 查看某个表的建表语句 + + ```sql + SHOW CREATE TABLE demo.tb1 + ``` + +## 关键词 + +SHOW, CREATE, TABLE + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-DYNAMIC-PARTITION-TABLES.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-DYNAMIC-PARTITION-TABLES.md new file mode 100644 index 0000000000000..25e94ad70230a --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-DYNAMIC-PARTITION-TABLES.md @@ -0,0 +1,52 @@ +--- +{ + "title": "SHOW DYNAMIC PARTITION TABLES", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于展示当前 db 下所有的动态分区表状态 + +语法: + +```sql +SHOW DYNAMIC PARTITION TABLES [FROM db_name]; +``` + +## 示例 + + 1. 展示数据库 database 的所有动态分区表状态 + + ```sql + SHOW DYNAMIC PARTITION TABLES FROM database; + ``` + +## 关键词 + +SHOW, DYNAMIC, PARTITION + + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PARTITION-ID.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-PARTITION-ID.md similarity index 90% rename from i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PARTITION-ID.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-PARTITION-ID.md index 9032905f808ef..a029d180f1e30 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/Show-Statements/SHOW-PARTITION-ID.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-PARTITION-ID.md @@ -1,6 +1,6 @@ --- { - "title": "SHOW-PARTITION-ID", + "title": "SHOW PARTITION ID", "language": "zh-CN" } --- @@ -24,11 +24,6 @@ specific language governing permissions and limitations under the License. --> -## SHOW-PARTITION-ID - -### Name - -SHOW PARTITION ID ## 描述 @@ -40,7 +35,7 @@ SHOW PARTITION ID SHOW PARTITION [partition_id] ``` -## 举例 +## 示例 1. 根据 partition id 查找对应的 database name, table name, partition name @@ -48,9 +43,9 @@ SHOW PARTITION ID SHOW PARTITION 10002; ``` -### Keywords +## 关键词 SHOW, PARTITION, ID -### Best Practice + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-PARTITION.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-PARTITION.md new file mode 100644 index 0000000000000..9e98f934fa473 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-PARTITION.md @@ -0,0 +1,64 @@ +--- +{ + "title": "SHOW PARTITION", + "language": "zh-CN" +} +--- + + + + +## 描述 + +SHOW PARTITION 用于展示指定分区的详细信息。包括所属数据库名字和 ID,所属表名字和 ID 以及分区名字。 + +## 语法 + +```sql +SHOW PARTITION +``` + +## 必选参数 + +`` + +> 分区的 ID。分区 ID 可以通过 SHOW PARTITIONS 等方式获得。更多信息请参阅“SHOW PARTITIONS”章节 + +## 权限控制 + +执行此 SQL 命令的用户至少具有`ADMIN_PRIV`权限 + +## 示例 + +查询分区 ID 为 13004 的分区信息: + +```sql +SHOW PARTITION 13004; +``` + +结果如下: + +```sql ++--------+-----------+---------------+-------+---------+ +| DbName | TableName | PartitionName | DbId | TableId | ++--------+-----------+---------------+-------+---------+ +| ods | sales | sales | 13003 | 13005 | ++--------+-----------+---------------+-------+---------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-PARTITIONS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-PARTITIONS.md new file mode 100644 index 0000000000000..9a9d477007adf --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-PARTITIONS.md @@ -0,0 +1,78 @@ +--- +{ + "title": "SHOW PARTITIONS", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句用于展示分区信息。支持 Internal catalog 和 Hive Catalog + +语法: + +```sql +SHOW [TEMPORARY] PARTITIONS FROM [db_name.]table_name [WHERE] [ORDER BY] [LIMIT]; +``` + +说明: + +对于 Internal catalog: +1. 支持 PartitionId,PartitionName,State,Buckets,ReplicationNum,LastConsistencyCheckTime 等列的过滤 +2. TEMPORARY 指定列出临时分区 + +对于 Hive Catalog: +支持返回所有分区,包括多级分区 + +## 示例 + +1. 展示指定 db 下指定表的所有非临时分区信息 + + ```sql + SHOW PARTITIONS FROM example_db.table_name; + ``` + +2. 展示指定 db 下指定表的所有临时分区信 + + ```sql + SHOW TEMPORARY PARTITIONS FROM example_db.table_name; + ``` + +3. 展示指定 db 下指定表的指定非临时分区的信息 + + ```sql + SHOW PARTITIONS FROM example_db.table_name WHERE PartitionName = "p1"; + ``` + +4. 展示指定 db 下指定表的最新非临时分区的信息 + + ```sql + SHOW PARTITIONS FROM example_db.table_name ORDER BY PartitionId DESC LIMIT 1; + ``` + +## 关键词 + +SHOW, PARTITIONS + +### 最佳实践 + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-TABLE-ID.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-TABLE-ID.md new file mode 100644 index 0000000000000..0729467951293 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-TABLE-ID.md @@ -0,0 +1,50 @@ +--- +{ + "title": "SHOW TABLE ID", + "language": "zh-CN" +} +--- + + + + +### 描述 + +该语句用于根据 table id 查找对应的 database name, table name(仅管理员使用) + +语法: + +```sql +SHOW TABLE [table_id] +``` + +### 示例 + + 1. 根据 table id 查找对应的 database name, table name + + ```sql + SHOW TABLE 10001; + ``` + +### 关键词 + + SHOW, TABLE, ID + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-TABLE-STATUS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-TABLE-STATUS.md new file mode 100644 index 0000000000000..54d8b2462b75c --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-TABLE-STATUS.md @@ -0,0 +1,62 @@ +--- +{ + "title": "SHOW TABLE STATUS", + "language": "zh-CN" +} +--- + + + + + +## 描述 + +该语句用于查看 Table 的一些信息。 + +语法: + +```sql +SHOW TABLE STATUS +[FROM db] [LIKE "pattern"] +``` + +说明: + +1. 该语句主要用于兼容 MySQL 语法,目前仅显示 Comment 等少量信息 + +## 示例 + + 1. 查看当前数据库下所有表的信息 + + ```sql + SHOW TABLE STATUS; + ``` + + 1. 查看指定数据库下,名称包含 example 的表的信息 + + ```sql + SHOW TABLE STATUS FROM db LIKE "%example%"; + ``` + +## 关键词 + +SHOW, TABLE, STATUS + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-TABLES.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-TABLES.md new file mode 100644 index 0000000000000..b3fdf03f9493c --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/SHOW-TABLES.md @@ -0,0 +1,77 @@ +--- +{ + "title": "SHOW TABLES", + "language": "zh-CN" +} +--- + + + +## 描述 + +该语句用于展示当前 db 下所有的 table + +语法: + +```sql +SHOW [FULL] TABLES [LIKE] +``` + +说明: + +1. LIKE:可按照表名进行模糊查询 + +## 示例 + + 1. 查看 DB 下所有表 + + ```sql + mysql> show tables; + +---------------------------------+ + | Tables_in_demo | + +---------------------------------+ + | ads_client_biz_aggr_di_20220419 | + | cmy1 | + | cmy2 | + | intern_theme | + | left_table | + +---------------------------------+ + 5 rows in set (0.00 sec) + ``` + +2. 按照表名进行模糊查询 + + ```sql + mysql> show tables like '%cm%'; + +----------------+ + | Tables_in_demo | + +----------------+ + | cmy1 | + | cmy2 | + +----------------+ + 2 rows in set (0.00 sec) + ``` + +## 关键词 + +SHOW, TABLES + + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/TRUNCATE-TABLE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/TRUNCATE-TABLE.md new file mode 100644 index 0000000000000..49afdef2f2972 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/table/TRUNCATE-TABLE.md @@ -0,0 +1,65 @@ +--- +{ + "title": "TRUNCATE TABLE", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句用于清空指定表和分区的数据 +语法: + +```sql +TRUNCATE TABLE [db.]tbl[ PARTITION(p1, p2, ...)]; +``` + +说明: + +- 该语句清空数据,但保留表或分区。 +- 不同于 DELETE,该语句只能整体清空指定的表或分区,不能添加过滤条件。 +- 不同于 DELETE,使用该方式清空数据不会对查询性能造成影响。 +- 该操作删除的数据不可恢复。 +- 使用该命令时,表状态需为 NORMAL,即不允许正在进行 SCHEMA CHANGE 等操作。 +- 该命令可能会导致正在进行的导入失败。 + +## 示例 + +1. 清空 example_db 下的表 tbl + + ```sql + TRUNCATE TABLE example_db.tbl; + ``` + +2. 清空表 tbl 的 p1 和 p2 分区 + + ```sql + TRUNCATE TABLE tbl PARTITION(p1, p2); + ``` + +## 关键词 + +TRUNCATE, TABLE + + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/view/ALTER-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/view/ALTER-VIEW.md new file mode 100644 index 0000000000000..72751a1a17079 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/view/ALTER-VIEW.md @@ -0,0 +1,66 @@ +--- +{ + "title": "ALTER VIEW", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句用于修改一个 view 的定义 + +语法: + +```sql +ALTER VIEW +[db_name.]view_name +(column1[ COMMENT "col comment"][, column2, ...]) +AS query_stmt +``` + +说明: + +- 视图都是逻辑上的,其中的数据不会存储在物理介质上,在查询时视图将作为语句中的子查询,因此,修改视图的定义等价于修改 query_stmt。 +- query_stmt 为任意支持的 SQL + +## 示例 + +1、修改 example_db 上的视图 example_view + + ```sql + ALTER VIEW example_db.example_view + ( + c1 COMMENT "column 1", + c2 COMMENT "column 2", + c3 COMMENT "column 3" + ) + AS SELECT k1, k2, SUM(v1) FROM example_table + GROUP BY k1, k2 + ``` + +## 关键词 + +```text +ALTER, VIEW +``` + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/view/CREATE-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/view/CREATE-VIEW.md new file mode 100644 index 0000000000000..d5df2899e6112 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/view/CREATE-VIEW.md @@ -0,0 +1,77 @@ +--- +{ + "title": "CREATE VIEW", + "language": "zh-CN" +} +--- + + + + +## 描述 + +该语句用于创建一个逻辑视图 +语法: + +```sql +CREATE VIEW [IF NOT EXISTS] + [db_name.]view_name + (column1[ COMMENT "col comment"][, column2, ...]) +AS query_stmt +``` + + +说明: + +- 视图为逻辑视图,没有物理存储。所有在视图上的查询相当于在视图对应的子查询上进行。 +- query_stmt 为任意支持的 SQL + +## 示例 + +1. 在 example_db 上创建视图 example_view + + ```sql + CREATE VIEW example_db.example_view (k1, k2, k3, v1) + AS + SELECT c1 as k1, k2, k3, SUM(v1) FROM example_table + WHERE k1 = 20160112 GROUP BY k1,k2,k3; + ``` + +2. 创建一个包含 comment 的 view + + ```sql + CREATE VIEW example_db.example_view + ( + k1 COMMENT "first key", + k2 COMMENT "second key", + k3 COMMENT "third key", + v1 COMMENT "first value" + ) + COMMENT "my first view" + AS + SELECT c1 as k1, k2, k3, SUM(v1) FROM example_table + WHERE k1 = 20160112 GROUP BY k1,k2,k3; + ``` + +## 关键词 + +CREATE, VIEW + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/view/DROP-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/view/DROP-VIEW.md new file mode 100644 index 0000000000000..e11173644cdf6 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/view/DROP-VIEW.md @@ -0,0 +1,66 @@ +--- +{ + "title": "DROP VIEW", + "language": "zh-CN" +} +--- + + + +## 描述 + +在当前或指定的数据库中删除一个视图。 + +## 语法 + +```sql +DROP VIEW [ IF EXISTS ] +``` + +## 必选参数 + +`` : 要删除的视图名称。 + +## 可选参数 + +`[IF EXISTS]` + +如果指定此参数,当视图不存在时不会抛出错误,而是直接跳过删除操作。 + +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +| :---------------- | :------------- | :------------ | +| DROP_PRIV | 表(Table) | | + +## 注意事项 + +已删除的视图无法恢复,必须重新创建。 + +## 示例 + +```sql +CREATE VIEW vtest AS SELECT 1, 'test'; +DROP VIEW IF EXISTS vtest; +``` + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/view/SHOW-CREATE-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/view/SHOW-CREATE-VIEW.md new file mode 100644 index 0000000000000..86e38c3d5b4ad --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/view/SHOW-CREATE-VIEW.md @@ -0,0 +1,76 @@ +--- +{ + "title": "SHOW CREATE VIEW", + "language": "zh-CN" +} +--- + + + +## 描述 + +显示指定视图创建时的 CREATE VIEW 语句。 + +## 语法 + +```sql +SHOW CREATE VIEW +``` + +## 必选参数 + +``:要查看的视图名称。 + +## 返回结果 + +- View: 查询的视图名称。 +- Create View: 数据库中持久化的 SQL 语句。 +- character_set_client: 表示创建视图时会话中 character_set_client 系统变量的值。 +- collation_connection: 表示创建视图时会话中 collation_connection 系统变量的值。 + +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +| :---------------- | :------------- | :------------ | +| SHOW_VIEW_PRIV | 表(Table) | | + +视图信息还可以通过 INFORMATION_SCHEMA.VIEWS 表查询。 + +## 示例 + +```sql +CREATE VIEW vtest AS SELECT 1, 'test'; +SHOW CREATE VIEW vtest; +``` + +查询结果: + +```sql ++-------+------------------------------------------+----------------------+----------------------+ +| View | Create View | character_set_client | collation_connection | ++-------+------------------------------------------+----------------------+----------------------+ +| vtest | CREATE VIEW `vtest` AS SELECT 1, 'test'; | utf8mb4 | utf8mb4_0900_bin | ++-------+------------------------------------------+----------------------+----------------------+ + +``` + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/view/SHOW-VIEW.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/view/SHOW-VIEW.md new file mode 100644 index 0000000000000..ec7054988d97f --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/table-and-view/view/SHOW-VIEW.md @@ -0,0 +1,49 @@ +--- +{ + "title": "SHOW VIEW", + "language": "zh-CN" +} +--- + + + +## 描述 + +该语句用于展示基于给定表建立的所有视图 + +语法: + +```sql + SHOW VIEW { FROM | IN } table [ FROM db ] +``` + +## 示例 + +1. 展示基于表 testTbl 建立的所有视图 view + + ```sql + SHOW VIEW FROM testTbl; + ``` + +## 关键词 + +SHOW, VIEW + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/transaction/BEGIN.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/transaction/BEGIN.md new file mode 100644 index 0000000000000..9a9da0b9dacf1 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/transaction/BEGIN.md @@ -0,0 +1,64 @@ +--- +{ + "title": "BEGIN", + "language": "zh-CN" +} +--- + + + + + + +## 描述 + +开启一个显式事务。用户可以指定 Label,如未指定,系统自动生成 Label。 + +## 语法 + +```sql +BEGIN [ WITH LABEL

是否对导入数据的编码进行检查:

1)false,那么不做检查直接将原始数据导入; 2)true,那么对数据中非 utf-8 编码的字符用 � 进行替代

| true |保持默认| -|--debug |打印 Debug 日志 | false | 保持默认| -|--auto_retry| 自动重传失败的 worker 序号和 task 序号的列表 | 空字符串 | 仅导入失败时重传使用,正常导入无需关心。失败时会提示具体参数内容,复制执行即可。例:如果 --auto_retry="1,1,2,1" 则表示:需要重传的 task 为:第一个 worker 的第一个 task,第二个 worker 的第一个 task。 | -|--auto_retry_times | 自动重传的次数 | 3 | 保持默认,如果不想重传需要把这个值设置为 0 | -|--auto_retry_interval | 自动重传的间隔 | 60 | 保持默认,如果 Doris 因宕机导致失败,建议根据实际 Doris 重启的时间间隔来设置该值 | -|--log_filename | 日志存储的位置 | "" | 默认将日志打印到控制台上,如果要打印到日志文件中,可以设置存储日志文件的路径,如--log_filename = "/var/log" | +| --max_byte_per_task | 每个导入任务数据量的最大大小,超过这个值剩下的数据会被拆分到一个新的导入任务中。 | 107374182400 (100G) | 建议设置一个很大的值来减少导入的版本数。但如果遇到 body exceed max size 错误且不想调整 streaming_load_max_mb 参数(需重启 be),又或是遇到 -238 TOO MANY SEGMENT 错误,可以临时调小这个配置 | +| --check_utf8 |

是否对导入数据的编码进行检查:

1)false,那么不做检查直接将原始数据导入; 2)true,那么对数据中非 utf-8 编码的字符用 � 进行替代

| true |保持默认| +|--debug |打印 Debug 日志 | false | 保持默认| +|--auto_retry | 自动重传失败的 worker 序号和 task 序号的列表 | 空字符串 | 仅导入失败时重传使用,正常导入无需关心。失败时会提示具体参数内容,复制执行即可。例:如果 --auto_retry="1,1,2,1" 则表示:需要重传的 task 为:第一个 worker 的第一个 task,第二个 worker 的第一个 task。 | +|--auto_retry_times | 自动重传的次数 | 3 | 保持默认,如果不想重传需要把这个值设置为 0 | +|--auto_retry_interval | 自动重传的间隔 | 60 | 保持默认,如果 Doris 因宕机导致失败,建议根据实际 Doris 重启的时间间隔来设置该值 | +|--log_filename | 日志存储的位置 | "" | 默认将日志打印到控制台上,如果要打印到日志文件中,可以设置存储日志文件的路径,如--log_filename = "/var/log" | @@ -129,17 +129,17 @@ doris-streamloader --source_file="data.csv" --url="http://localhost:8330" --head 无论成功与失败,都会显示最终的结果,结果参数说明: -|参数名 | 描述 | -|---|---| -| Status | 导入成功(Success)与否(Failed)| -| TotalRows | 想要导入文件中所有的行数 | -| FailLoadRows | 想要导入文件中没有导入的行数 | -| LoadedRows | 实际导入 Doris 的行数 | -| FilteredRows | 实际导入过程中被 Doris 过滤的行数 | -| UnselectedRows | 实际导入过程中被 Doris 忽略的行数 | -| LoadBytes | 实际导入的 byte 大小 | -| LoadTimeMs | 实际导入的时间 | -| LoadFiles | 实际导入的文件列表| +|参数名 | 描述 | +|-----------------|-------------------------------| +| Status | 导入成功(Success)与否(Failed)| +| TotalRows | 想要导入文件中所有的行数 | +| FailLoadRows | 想要导入文件中没有导入的行数 | +| LoadedRows | 实际导入 Doris 的行数 | +| FilteredRows | 实际导入过程中被 Doris 过滤的行数 | +| UnselectedRows | 实际导入过程中被 Doris 忽略的行数 | +| LoadBytes | 实际导入的 byte 大小 | +| LoadTimeMs | 实际导入的时间 | +| LoadFiles | 实际导入的文件列表 | @@ -147,7 +147,7 @@ doris-streamloader --source_file="data.csv" --url="http://localhost:8330" --head - 导入成功,成功信息如下: - ```Go +```Go Load Result: { "Status": "Success", "TotalRows": 120, @@ -166,14 +166,14 @@ doris-streamloader --source_file="data.csv" --url="http://localhost:8330" --head "dir1/basic_data1.csv" ] } - ``` +``` - 导入失败:如果导入过程中部分数据没有导入失败了,会给出重传信息,如: - ```Go +```Go load has some error, and auto retry failed, you can retry by : ./doris-streamloader --source_file /mnt/disk1/laihui/doris/tools/tpch-tools/bin/tpch-data/lineitem.tbl.1 --url="http://127.0.0.1:8239" --header="column_separator:|?columns: l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag,l_linestatus, l_shipdate,l_commitdate,l_receiptdate,l_shipinstruct,l_shipmode,l_comment,temp" --db="db" --table="lineitem1" -u root -p "" --compress=false --timeout=36000 --workers=3 --batch=4096 --batch_byte=943718400 --max_byte_per_task=1073741824 --check_utf8=true --report_duration=1 --auto_retry="2,1;1,1;0,1" --auto_retry_times=0 --auto_retry_interval=60 - ``` +``` 只需复制运行该命令即可,`auto_retry` 说明可参考,并给出失败的结果信息: @@ -228,8 +228,8 @@ Load Result: { 查看 `streaming_load_max_mb` 大小的方法: - ```Go +```Go -curl "http://127.0.0.1:8040/api/show_config" - ``` +``` - 导入过程如果遇到 `-238 TOO MANY SEGMENT` 的问题,可以减少 `max_byte_per_task` 的大小。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/ecosystem/fluentbit.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/ecosystem/fluentbit.md index c110f5fcf170b..e19fdedd26c1f 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/ecosystem/fluentbit.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/ecosystem/fluentbit.md @@ -54,21 +54,21 @@ make Fluent Bit Doris output plugin 的配置如下: -配置 | 说明 ---- | --- -`host` | Stream Load HTTP host -`port` | Stream Load HTTP port -`user` | Doris 用户名,该用户需要有doris对应库表的导入权限 -`password` | Doris 用户的密码 -`database` | 要写入的 Doris 库名 -`table` | 要写入的 Doris 表名 -`label_prefix` | Doris Stream Load Label 前缀,最终生成的 Label 为 *{label_prefix}\_{timestamp}\_{uuid}* ,默认值是 fluentbit, 如果设置为 false 则不会添加 Label - `time_key` | 数据中要添加的时间戳列的名称,默认值是 date, 如果设置为 false 则不会添加该列 -`header` | Doris Stream Load 的 header 参数,可以设置多个 -`log_request` | 日志中是否输出 Doris Stream Load 请求和响应元数据,用于排查问题,默认为 true +配置 | 说明 +----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- +`host` | Stream Load HTTP host +`port` | Stream Load HTTP port +`user` | Doris 用户名,该用户需要有doris对应库表的导入权限 +`password` | Doris 用户的密码 +`database` | 要写入的 Doris 库名 +`table` | 要写入的 Doris 表名 +`label_prefix` | Doris Stream Load Label 前缀,最终生成的 Label 为 *{label_prefix}\_{timestamp}\_{uuid}* ,默认值是 fluentbit, 如果设置为 false 则不会添加 Label +`time_key` | 数据中要添加的时间戳列的名称,默认值是 date, 如果设置为 false 则不会添加该列 +`header` | Doris Stream Load 的 header 参数,可以设置多个 +`log_request` | 日志中是否输出 Doris Stream Load 请求和响应元数据,用于排查问题,默认为 true `log_progress_interval` | 日志中输出速度的时间间隔,单位是秒,默认为 10,设置为 0 可以关闭这种日志 -`retry_limit` | Doris Stream Load 请求失败重试次数,默认为 1, 如果设置为 false 则不限制重试次数 -`workers` | 执行 Doris Stream Load 的 worker 数量,默认为 2 +`retry_limit` | Doris Stream Load 请求失败重试次数,默认为 1, 如果设置为 false 则不限制重试次数 +`workers` | 执行 Doris Stream Load 的 worker 数量,默认为 2 ## 使用示例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/ecosystem/kettle.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/ecosystem/kettle.md index a1cb7febb829a..ce1d936e42ea4 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/ecosystem/kettle.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/ecosystem/kettle.md @@ -58,10 +58,12 @@ mvn clean package -DskipTests ``` ### 构建作业 在Kettle中的批量加载中找到Doris Stream Loader,构建作业 + ![create_zh.png](https://raw.githubusercontent.com/apache/doris/refs/heads/master/extension/kettle/images/create_zh.png) 点击开始运行作业即可完成数据同步 + ![running_zh.png](https://raw.githubusercontent.com/apache/doris/refs/heads/master/extension/kettle/images/running_zh.png) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/ecosystem/kyuubi.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/ecosystem/kyuubi.md index f364eedd55564..8cefec58b043a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/ecosystem/kyuubi.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/ecosystem/kyuubi.md @@ -98,15 +98,15 @@ $ $KYUUBI_HOME/bin/beeline -u "jdbc:hive2://xxxx:10009/" select * from demo.example_tbl 2023-03-07 09:29:14.786 INFO org.apache.kyuubi.operation.ExecuteStatement: Query[bdc59dd0-ceea-4c02-8c3a-23424323f5db] in FINISHED_STATE 2023-03-07 09:29:14.787 INFO org.apache.kyuubi.operation.ExecuteStatement: Processing anonymous's query[bdc59dd0-ceea-4c02-8c3a-23424323f5db]: RUNNING_STATE -> FINISHED_STATE, time taken: 0.015 seconds -+----------+-------------+-------+------+------+------------------------+-------+-----------------+-----------------+ ++----------+-------------+-------+------+------+------------------------+-------+ | user_id | date | city | age | sex | last_visit_date | cost | max_dwell_time | min_dwell_time | -+----------+-------------+-------+------+------+------------------------+-------+-----------------+-----------------+ ++----------+-------------+-------+------+------+------------------------+-------+ | 10000 | 2017-10-01 | 北京 | 20 | 0 | 2017-10-01 07:00:00.0 | 70 | 10 | 2 | | 10001 | 2017-10-01 | 北京 | 30 | 1 | 2017-10-01 17:05:45.0 | 4 | 22 | 22 | | 10002 | 2017-10-02 | 上海 | 20 | 1 | 2017-10-02 12:59:12.0 | 400 | 5 | 5 | | 10003 | 2017-10-02 | 广州 | 32 | 0 | 2017-10-02 11:20:00.0 | 60 | 11 | 11 | | 10004 | 2017-10-01 | 深圳 | 35 | 0 | 2017-10-01 10:00:15.0 | 200 | 3 | 3 | | 10004 | 2017-10-03 | 深圳 | 35 | 0 | 2017-10-03 10:20:22.0 | 22 | 6 | 6 | -+----------+-------------+-------+------+------+------------------------+-------+-----------------+-----------------+ ++----------+-------------+-------+------+------+------------------------+-------+ 6 rows selected (0.068 seconds) ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/ecosystem/logstash.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/ecosystem/logstash.md index 07c135b160360..1033e17768a93 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/ecosystem/logstash.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/ecosystem/logstash.md @@ -86,20 +86,20 @@ Install successful Logstash Doris output plugin 的配置如下: -配置 | 说明 ---- | --- -`http_hosts` | Stream Load HTTP 地址,格式是字符串数组,可以有一个或者多个元素,每个元素是 host:port。 例如:["http://fe1:8030", "http://fe2:8030"] -`user` | Doris 用户名,该用户需要有doris对应库表的导入权限 -`password` | Doris 用户的密码 -`db` | 要写入的 Doris 库名 -`table` | 要写入的 Doris 表名 -`label_prefix` | Doris Stream Load Label 前缀,最终生成的 Label 为 *{label_prefix}_{db}_{table}_{yyyymmdd_hhmmss}_{uuid}* ,默认值是 logstash -`headers` | Doris Stream Load 的 headers 参数,语法格式为 ruby map,例如:headers => { "format" => "json" "read_json_by_line" => "true" } -`mapping` | Logstash 字段到 Doris 表字段的映射, 参考后续章节的使用示例 -`message_only` | 一种特殊的 mapping 形式,只将 Logstash 的 @message 字段输出到 Doris,默认为 false -`max_retries` | Doris Stream Load 请求失败重试次数,默认为 -1 无限重试保证数据可靠性 -`log_request` | 日志中是否输出 Doris Stream Load 请求和响应元数据,用于排查问题,默认为 false -`log_speed_interval` | 日志中输出速度的时间间隔,单位是秒,默认为 10,设置为 0 可以关闭这种日志 +配置 | 说明 +----------------------- | ------------------------------------------------------------------------------------------------------------------------- +`http_hosts` | Stream Load HTTP 地址,格式是字符串数组,可以有一个或者多个元素,每个元素是 host:port。 例如:["http://fe1:8030", "http://fe2:8030"] +`user` | Doris 用户名,该用户需要有doris对应库表的导入权限 +`password` | Doris 用户的密码 +`db` | 要写入的 Doris 库名 +`table` | 要写入的 Doris 表名 +`label_prefix` | Doris Stream Load Label 前缀,最终生成的 Label 为 *{label_prefix}_{db}_{table}_{yyyymmdd_hhmmss}_{uuid}* ,默认值是 logstash +`headers` | Doris Stream Load 的 headers 参数,语法格式为 ruby map,例如:headers => { "format" => "json" "read_json_by_line" => "true" } +`mapping` | Logstash 字段到 Doris 表字段的映射, 参考后续章节的使用示例 +`message_only` | 一种特殊的 mapping 形式,只将 Logstash 的 @message 字段输出到 Doris,默认为 false +`max_retries` | Doris Stream Load 请求失败重试次数,默认为 -1 无限重试保证数据可靠性 +`log_request` | 日志中是否输出 Doris Stream Load 请求和响应元数据,用于排查问题,默认为 false +`log_speed_interval` | 日志中输出速度的时间间隔,单位是秒,默认为 10,设置为 0 可以关闭这种日志 ## 使用示例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/ecosystem/spark-doris-connector.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/ecosystem/spark-doris-connector.md index 29d69d7daf980..b70e611064c3d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/ecosystem/spark-doris-connector.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/ecosystem/spark-doris-connector.md @@ -256,30 +256,30 @@ kafkaSource.selectExpr("CAST(value as STRING)") ### 通用配置项 -| Key | Default Value | Comment | -|----------------------------------|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| doris.fenodes | -- | Doris FE http 地址,支持多个地址,使用逗号分隔 | -| doris.table.identifier | -- | Doris 表名,如:db1.tbl1 | -| doris.request.retries | 3 | 向 Doris 发送请求的重试次数 | -| doris.request.connect.timeout.ms | 30000 | 向 Doris 发送请求的连接超时时间 | -| doris.request.read.timeout.ms | 30000 | 向 Doris 发送请求的读取超时时间 | -| doris.request.query.timeout.s | 3600 | 查询 doris 的超时时间,默认值为 1 小时,-1 表示无超时限制 | -| doris.request.tablet.size | Integer.MAX_VALUE | 一个 RDD Partition 对应的 Doris Tablet 个数。
此数值设置越小,则会生成越多的 Partition。从而提升 Spark 侧的并行度,但同时会对 Doris 造成更大的压力。 | -| doris.read.field | -- | 读取 Doris 表的列名列表,多列之间使用逗号分隔 | -| doris.batch.size | 4064 | 一次从 BE 读取数据的最大行数。增大此数值可减少 Spark 与 Doris 之间建立连接的次数。
从而减轻网络延迟所带来的额外时间开销。 | -| doris.exec.mem.limit | 2147483648 | 单个查询的内存限制。默认为 2GB,单位为字节 | -| doris.deserialize.arrow.async | false | 是否支持异步转换 Arrow 格式到 spark-doris-connector 迭代所需的 RowBatch | -| doris.deserialize.queue.size | 64 | 异步转换 Arrow 格式的内部处理队列,当 doris.deserialize.arrow.async 为 true 时生效 | -| doris.write.fields | -- | 指定写入 Doris 表的字段或者字段顺序,多列之间使用逗号分隔。
默认写入时要按照 Doris 表字段顺序写入全部字段。 | -| doris.sink.batch.size | 100000 | 单次写 BE 的最大行数 | -| doris.sink.max-retries | 0 | 写 BE 失败之后的重试次数,从 1.3.0 版本开始, 默认值为 0,即默认不进行重试。当设置该参数大于 0 时,会进行批次级别的失败重试,会在 Spark Executor 内存中缓存 `doris.sink.batch.size` 所配置大小的数据,可能需要适当增大内存分配。 | -| doris.sink.properties.format | csv | Stream Load 的数据格式。
共支持 3 种格式:csv,json,arrow
[更多参数详情](https://doris.apache.org/zh-CN/docs/data-operate/import/stream-load-manual/) | -| doris.sink.properties.* | -- | Stream Load 的导入参数。
例如:
指定列分隔符:`'doris.sink.properties.column_separator' = ','`等
[更多参数详情](https://doris.apache.org/zh-CN/docs/data-operate/import/stream-load-manual/) | -| doris.sink.task.partition.size | -- | Doris 写入任务对应的 Partition 个数。Spark RDD 经过过滤等操作,最后写入的 Partition 数可能会比较大,但每个 Partition 对应的记录数比较少,导致写入频率增加和计算资源浪费。
此数值设置越小,可以降低 Doris 写入频率,减少 Doris 合并压力。该参数配合 doris.sink.task.use.repartition 使用。 | -| doris.sink.task.use.repartition | false | 是否采用 repartition 方式控制 Doris 写入 Partition 数。默认值为 false,采用 coalesce 方式控制(注意:如果在写入之前没有 Spark action 算子,可能会导致整个计算并行度降低)。
如果设置为 true,则采用 repartition 方式(注意:可设置最后 Partition 数,但会额外增加 shuffle 开销)。 | -| doris.sink.batch.interval.ms | 50 | 每个批次 sink 的间隔时间,单位 ms。 | -| doris.sink.enable-2pc | false | 是否开启两阶段提交。开启后将会在作业结束时提交事务,而部分任务失败时会将所有预提交状态的事务会滚。 | -| doris.sink.auto-redirect | true | 是否重定向 StreamLoad 请求。开启后 StreamLoad 将通过 FE 写入,不再显式获取 BE 信息。 | +| Key | Default Value | Comment | +|---------------------------------------|-------------------------|-----------------------------------------------------------------------------------------------------| +| doris.fenodes | -- | Doris FE http 地址,支持多个地址,使用逗号分隔 | +| doris.table.identifier | -- | Doris 表名,如:db1.tbl1 | +| doris.request.retries | 3 | 向 Doris 发送请求的重试次数 | +| doris.request.connect.timeout.ms | 30000 | 向 Doris 发送请求的连接超时时间 | +| doris.request.read.timeout.ms | 30000 | 向 Doris 发送请求的读取超时时间 | +| doris.request.query.timeout.s | 3600 | 查询 doris 的超时时间,默认值为 1 小时,-1 表示无超时限制 | +| doris.request.tablet.size | Integer.MAX_VALUE | 一个 RDD Partition 对应的 Doris Tablet 个数。
此数值设置越小,则会生成越多的 Partition。从而提升 Spark 侧的并行度,但同时会对 Doris 造成更大的压力。 | +| doris.read.field | -- | 读取 Doris 表的列名列表,多列之间使用逗号分隔 | +| doris.batch.size | 4064 | 一次从 BE 读取数据的最大行数。增大此数值可减少 Spark 与 Doris 之间建立连接的次数。
从而减轻网络延迟所带来的额外时间开销。 | +| doris.exec.mem.limit | 2147483648 | 单个查询的内存限制。默认为 2GB,单位为字节 | +| doris.deserialize.arrow.async | false | 是否支持异步转换 Arrow 格式到 spark-doris-connector 迭代所需的 RowBatch | +| doris.deserialize.queue.size | 64 | 异步转换 Arrow 格式的内部处理队列,当 doris.deserialize.arrow.async 为 true 时生效 | +| doris.write.fields | -- | 指定写入 Doris 表的字段或者字段顺序,多列之间使用逗号分隔。
默认写入时要按照 Doris 表字段顺序写入全部字段。 | +| doris.sink.batch.size | 100000 | 单次写 BE 的最大行数 | +| doris.sink.max-retries | 0 | 写 BE 失败之后的重试次数,从 1.3.0 版本开始, 默认值为 0,即默认不进行重试。当设置该参数大于 0 时,会进行批次级别的失败重试,会在 Spark Executor 内存中缓存 `doris.sink.batch.size` 所配置大小的数据,可能需要适当增大内存分配。 | +| doris.sink.properties.format | csv | Stream Load 的数据格式。
共支持 3 种格式:csv,json,arrow
[更多参数详情](https://doris.apache.org/zh-CN/docs/data-operate/import/stream-load-manual/) | +| doris.sink.properties.* | -- | Stream Load 的导入参数。
例如:
指定列分隔符:`'doris.sink.properties.column_separator' = ','`等
[更多参数详情](https://doris.apache.org/zh-CN/docs/data-operate/import/stream-load-manual/) | +| doris.sink.task.partition.size | -- | Doris 写入任务对应的 Partition 个数。Spark RDD 经过过滤等操作,最后写入的 Partition 数可能会比较大,但每个 Partition 对应的记录数比较少,导致写入频率增加和计算资源浪费。
此数值设置越小,可以降低 Doris 写入频率,减少 Doris 合并压力。该参数配合 doris.sink.task.use.repartition 使用。 | +| doris.sink.task.use.repartition | false | 是否采用 repartition 方式控制 Doris 写入 Partition 数。默认值为 false,采用 coalesce 方式控制(注意:如果在写入之前没有 Spark action 算子,可能会导致整个计算并行度降低)。
如果设置为 true,则采用 repartition 方式(注意:可设置最后 Partition 数,但会额外增加 shuffle 开销)。 | +| doris.sink.batch.interval.ms | 50 | 每个批次 sink 的间隔时间,单位 ms。 | +| doris.sink.enable-2pc | false | 是否开启两阶段提交。开启后将会在作业结束时提交事务,而部分任务失败时会将所有预提交状态的事务会滚。 | +| doris.sink.auto-redirect | true | 是否重定向 StreamLoad 请求。开启后 StreamLoad 将通过 FE 写入,不再显式获取 BE 信息。 | ### SQL 和 Dataframe 专有配置 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/gettingStarted/what-is-apache-doris.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/gettingStarted/what-is-apache-doris.md index 6a8d89c14e980..64cc7cd026fd4 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/gettingStarted/what-is-apache-doris.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/gettingStarted/what-is-apache-doris.md @@ -36,6 +36,7 @@ Apache Doris 如今在中国乃至全球范围内都拥有着广泛的用户群 如下图所示,数据源经过各种数据集成和加工处理后,通常会入库到实时数据仓库 Apache Doris 和离线湖仓(Hive, Iceberg, Hudi 中),Apache Doris 被广泛应用在以下场景中。 + ![Apache Doris 的使用场景](/images/getting-started/apache-doris-usage-scenarios-pipeline.png) - 报表分析 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/install/construct-docker/construct-docker-image.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/install/construct-docker/construct-docker-image.md index f6b3e0f182458..0f8ddb6982b86 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/install/construct-docker/construct-docker-image.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/install/construct-docker/construct-docker-image.md @@ -95,9 +95,9 @@ Dockerfile 脚本编写需要注意以下几点: 1. 创建构建环境目录 - ```shell +```shell mkdir -p ./docker-build/fe/resource - ``` +``` 2. 下载[官方二进制包](https://doris.apache.org/zh-CN/download)/编译的二进制包 @@ -105,7 +105,7 @@ Dockerfile 脚本编写需要注意以下几点: 3. 编写 FE 的 Dockerfile 脚本 - ```powershell +```powershell # 选择基础镜像 FROM openjdk:8u342-jdk @@ -127,7 +127,7 @@ Dockerfile 脚本编写需要注意以下几点: RUN chmod 755 /opt/apache-doris/fe/bin/init_fe.sh ENTRYPOINT ["/opt/apache-doris/fe/bin/init_fe.sh"] - ``` +``` 编写后命名为 `Dockerfile` 并保存至 `./docker-build/fe` 目录下 @@ -143,10 +143,10 @@ Dockerfile 脚本编写需要注意以下几点: 构建 FE: - ```shell +```shell cd ./docker-build/fe docker build . -t ${fe-tagName} - ``` +``` #### 构建 BE @@ -158,18 +158,18 @@ mkdir -p ./docker-build/be/resource ``` 2. 构建环境目录如下: - ```sql +```sql └── docker-build // 构建根目录 └── be // BE 构建目录 ├── dockerfile // dockerfile 脚本 └── resource // 资源目录 ├── init_be.sh // 启动及注册脚本 └── apache-doris-x.x.x-bin-x86_64/arm-be.tar.gz // 二进制程序包 - ``` +``` 3. 编写 BE 的 Dockerfile 脚本 - ```powershell +```powershell # 选择基础镜像 FROM openjdk:8u342-jdk @@ -191,7 +191,7 @@ mkdir -p ./docker-build/be/resource RUN chmod 755 /opt/apache-doris/be/bin/init_be.sh ENTRYPOINT ["/opt/apache-doris/be/bin/init_be.sh"] - ``` +``` 编写后命名为 `Dockerfile` 并保存至 `./docker-build/be` 目录下 @@ -207,16 +207,16 @@ mkdir -p ./docker-build/be/resource 构建 BE: - ```shell +```shell cd ./docker-build/be docker build . -t ${be-tagName} - ``` +``` 构建完成后,会有 `Success` 字样提示,这时候通过以下命令可查看刚构建完成的 Image 镜像 - ```shell +```shell docker images - ``` +``` #### 构建 Broker @@ -228,18 +228,18 @@ mkdir -p ./docker-build/broker/resource 2. 构建环境目录如下: - ```sql +```sql └── docker-build // 构建根目录 └── broker // BROKER 构建目录 ├── dockerfile // dockerfile 脚本 └── resource // 资源目录 ├── init_broker.sh // 启动及注册脚本 └── apache-doris-x.x.x-bin-broker.tar.gz // 二进制程序包 - ``` +``` 3. 编写 Broker 的 Dockerfile 脚本 - ```powershell +```powershell # 选择基础镜像 FROM openjdk:8u342-jdk @@ -261,7 +261,7 @@ mkdir -p ./docker-build/broker/resource RUN chmod 755 /opt/apache-doris/broker/bin/init_broker.sh ENTRYPOINT ["/opt/apache-doris/broker/bin/init_broker.sh"] - ``` +``` 编写后命名为 `Dockerfile` 并保存至 `./docker-build/broker` 目录下 @@ -277,16 +277,16 @@ mkdir -p ./docker-build/broker/resource 构建 Broker: - ```shell +```shell cd ./docker-build/broker docker build . -t ${broker-tagName} - ``` +``` 构建完成后,会有 `Success` 字样提示,这时候通过以下命令可查看刚构建完成的 Image 镜像 - ```shell +```shell docker images - ``` +``` ## 推送镜像至 DockerHub 或私有仓库 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/install/standard-deployment.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/install/standard-deployment.md index 66686ad3973b5..b6a0e6758395c 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/install/standard-deployment.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/install/standard-deployment.md @@ -110,17 +110,17 @@ Broker 是用于访问外部数据源(如 hdfs)的进程。通常,在每 Doris 各个实例直接通过网络进行通讯。以下表格展示了所有需要的端口 -| 实例名称 | 端口名称 | 默认端口 | 通讯方向 | 说明 | -|---|---|---|---| ---| -| BE | be_port | 9060 | FE --> BE | BE 上 thrift server 的端口,用于接收来自 FE 的请求 | -| BE | webserver_port | 8040 | BE <--> BE, Client <--> FE | BE 上的 http server 的端口 | -| BE | heartbeat\_service_port | 9050 | FE --> BE | BE 上心跳服务端口(thrift),用于接收来自 FE 的心跳 | -| BE | brpc\_port | 8060 | FE <--> BE, BE <--> BE | BE 上的 brpc 端口,用于 BE 之间通讯 | -| FE | http_port | 8030 | FE <--> FE,用户 <--> FE |FE 上的 http server 端口 | -| FE | rpc_port | 9020 | BE --> FE, FE <--> FE | FE 上的 thrift server 端口,每个fe的配置需要保持一致| -| FE | query_port | 9030 | 用户 <--> FE | FE 上的 mysql server 端口 | -| FE | edit\_log_port | 9010 | FE <--> FE | FE 上的 bdbje 之间通信用的端口 | -| Broker | broker\_ipc_port | 8000 | FE --> Broker, BE --> Broker | Broker 上的 thrift server,用于接收请求 | +| 实例名称 | 端口名称 | 默认端口 | 通讯方向 | 说明 | +|------------|-------------------------|------------|------------------------------| ----------------------------------------------| +| BE | be_port | 9060 | FE --> BE | BE 上 thrift server 的端口,用于接收来自 FE 的请求 | +| BE | webserver_port | 8040 | BE <--> BE, Client <--> FE | BE 上的 http server 的端口 | +| BE | heartbeat\_service_port | 9050 | FE --> BE | BE 上心跳服务端口(thrift),用于接收来自 FE 的心跳 | +| BE | brpc\_port | 8060 | FE <--> BE, BE <--> BE | BE 上的 brpc 端口,用于 BE 之间通讯 | +| FE | http_port | 8030 | FE <--> FE,用户 <--> FE |FE 上的 http server 端口 | +| FE | rpc_port | 9020 | BE --> FE, FE <--> FE | FE 上的 thrift server 端口,每个fe的配置需要保持一致| +| FE | query_port | 9030 | 用户 <--> FE | FE 上的 mysql server 端口 | +| FE | edit\_log_port | 9010 | FE <--> FE | FE 上的 bdbje 之间通信用的端口 | +| Broker | broker\_ipc_port | 8000 | FE --> Broker, BE --> Broker | Broker 上的 thrift server,用于接收请求 | > 注: > 1. 当部署多个 FE 实例时,要保证 FE 的 http\_port 配置相同。 @@ -225,11 +225,13 @@ doris默认为表名大小写敏感,如有表名大小写不敏感的需求需 * 配置 JAVA_HOME 环境变量 + 由于从 1.2 版本开始支持 Java UDF 函数,BE 依赖于 Java 环境。所以要预先配置 `JAVA_HOME` 环境变量,也可以在 `start_be.sh` 启动脚本第一行添加 `export JAVA_HOME=your_java_home_path` 来添加环境变量。 * 安装 Java UDF 函数 安装Java UDF 函数 + 因为从 1.2 版本开始支持 Java UDF 函数,需要从官网下载 Java UDF 函数的 JAR 包放到 BE 的 lib 目录下,否则可能会启动失败。 * 在 FE 中添加所有 BE 节点 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/external-table/es.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/external-table/es.md index 950c59136d863..bb837ca7aa57f 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/external-table/es.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/external-table/es.md @@ -142,12 +142,12 @@ PROPERTIES ( 参数说明: -参数 | 说明 ----|--- -**hosts** | ES集群地址,可以是一个或多个,也可以是ES前端的负载均衡地址 -**index** | 对应的ES的index名字,支持alias,如果使用doc_value,需要使用真实的名称 -**type** | index的type,ES 7.x及以后的版本不传此参数 -**user** | ES集群用户名 +参数 | 说明 +-------------|-------------------------------------------------------------- +**hosts** | ES集群地址,可以是一个或多个,也可以是ES前端的负载均衡地址 +**index** | 对应的ES的index名字,支持alias,如果使用doc_value,需要使用真实的名称 +**type** | index的type,ES 7.x及以后的版本不传此参数 +**user** | ES集群用户名 **password** | 对应用户的密码信息 * ES 7.x之前的集群请注意在建表的时候选择正确的**索引类型type** @@ -160,22 +160,22 @@ PROPERTIES ( 下面的操作符(Operators)会被优化成如下ES Query: -| SQL syntax | ES 5.x+ syntax | -|-------|:---:| -| = | term query| -| in | terms query | -| > , < , >= , ⇐ | range query | -| and | bool.filter | -| or | bool.should | -| not | bool.must_not | -| not in | bool.must_not + terms query | -| is\_not\_null | exists query | -| is\_null | bool.must_not + exists query | -| esquery | ES原生json形式的QueryDSL | +| SQL syntax | ES 5.x+ syntax | +|----------------|:----------------------------:| +| = | term query | +| in | terms query | +| > , < , >= , ⇐ | range query | +| and | bool.filter | +| or | bool.should | +| not | bool.must_not | +| not in | bool.must_not + terms query | +| is\_not\_null | exists query | +| is\_null | bool.must_not + exists query | +| esquery | ES原生json形式的QueryDSL | ##### 数据类型映射 -Doris\ES | byte | short | integer | long | float | double| keyword | text | date +Doris vs ES | byte | short | integer | long | float | double| keyword | text | date ------------- | ------------- | ------ | ---- | ----- | ---- | ------ | ----| --- | --- | tinyint | √ | | | | | | | | smallint | √ | √ | | | | | | | @@ -249,8 +249,8 @@ PROPERTIES ( 参数说明: -参数 | 说明 ----|--- +参数 | 说明 +---------------------------|------------------------------------------------------------------------------------------------------ **enable\_keyword\_sniff** | 是否对ES中字符串类型分词类型(**text**) `fields` 进行探测,获取额外的未分词(**keyword**)字段名(multi-fields机制) 在ES中可以不建立index直接进行数据导入,这时候ES会自动创建一个新的索引,针对字符串类型的字段ES会创建一个既有`text`类型的字段又有`keyword`类型的字段,这就是ES的multi fields特性,mapping如下: diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/external-table/jdbc.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/external-table/jdbc.md index 12440276c7d31..99166c172489a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/external-table/jdbc.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/external-table/jdbc.md @@ -76,17 +76,17 @@ PROPERTIES ( 参数说明: -| 参数 | 说明| -| ---------------- | ------------ | -| **type** | "jdbc", 必填项标志资源类型 | -| **user** | 访问外表数据库所使的用户名 | -| **password** | 该用户对应的密码信息 | +| 参数 | 说明 | +| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | +| **type** | "jdbc", 必填项标志资源类型 | +| **user** | 访问外表数据库所使的用户名 | +| **password** | 该用户对应的密码信息 | | **jdbc_url** | JDBC 的 URL 协议,包括数据库类型,IP 地址,端口号和数据库名,不同数据库协议格式不一样。例如 mysql: "jdbc:mysql://127.0.0.1:3306/test?useCursorFetch=true"。| -| **driver_class** | 访问外表数据库的驱动包类名,例如 mysql 是:com.mysql.jdbc.Driver. | +| **driver_class** | 访问外表数据库的驱动包类名,例如 mysql 是:com.mysql.jdbc.Driver. | | **driver_url** | 用于下载访问外部数据库的 jar 包驱动 URL。`http://IP:port/mysql-connector-java-5.1.47.jar`。本地单机测试时,可将 jar 包放在本地路径下,"driver_url"="file:///home/disk1/pathTo/mysql-connector-java-5.1.47.jar",多机时需保证具有完全相同的路径信息。 | -| **resource** | 在 Doris 中建立外表时依赖的资源名,对应上步创建资源时的名字。| -| **table** | 在 Doris 中建立外表时,与外部数据库相映射的表名。| -| **table_type** | 在 Doris 中建立外表时,该表来自那个数据库。例如 mysql,postgresql,sqlserver,oracle| +| **resource** | 在 Doris 中建立外表时依赖的资源名,对应上步创建资源时的名字。 | +| **table** | 在 Doris 中建立外表时,与外部数据库相映射的表名。 | +| **table_type** | 在 Doris 中建立外表时,该表来自那个数据库。例如 mysql,postgresql,sqlserver,oracle | > **注意:** > diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/filecache.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/filecache.md index f8ad2b3fdea56..936f7ea5906bc 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/filecache.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/filecache.md @@ -57,13 +57,13 @@ SET GLOBAL enable_file_cache = true; ### BE 配置 添加参数到 BE 节点的配置文件 conf/be.conf 中,并重启 BE 节点让配置生效。 -| 参数 | 说明 | -| --- | --- | -| `enable_file_cache` | 是否启用 File Cache,默认 false | +| 参数 | 说明 | +| -------------------------------- | ----------------------------------------- | +| `enable_file_cache` | 是否启用 File Cache,默认 false | | `file_cache_max_file_segment_size` | 单个 Block 的大小上限,默认 4MB,需要大于 4096 | -| `file_cache_path` | 缓存目录的相关配置,json格式,例子: `[{"path": "/path/to/file_cache1", "total_size":53687091200,"query_limit": "10737418240"},{"path": "/path/to/file_cache2", "total_size":53687091200,"query_limit": "10737418240"},{"path": "/path/to/file_cache3", "total_size":53687091200,"query_limit": "10737418240"}]`。`path` 是缓存的保存路径,`total_size` 是缓存的大小上限,`query_limit` 是单个查询能够使用的最大缓存大小。 | -| `enable_file_cache_query_limit` | 是否限制单个 query 使用的缓存大小,默认 false | -| `clear_file_cache` | BE 重启时是否删除之前的缓存数据,默认 false | +| `file_cache_path` | 缓存目录的相关配置,json格式,例子: `[{"path": "/path/to/file_cache1", "total_size":53687091200,"query_limit": "10737418240"},{"path": "/path/to/file_cache2", "total_size":53687091200,"query_limit": "10737418240"},{"path": "/path/to/file_cache3", "total_size":53687091200,"query_limit": "10737418240"}]`。`path` 是缓存的保存路径,`total_size` 是缓存的大小上限,`query_limit` 是单个查询能够使用的最大缓存大小。 | +| `enable_file_cache_query_limit` | 是否限制单个 query 使用的缓存大小,默认 false | +| `clear_file_cache` | BE 重启时是否删除之前的缓存数据,默认 false | ### 查看 File Cache 命中情况 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/multi-catalog/es.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/multi-catalog/es.md index 57a893dcfcb13..73c844a1ec8c1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/multi-catalog/es.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/multi-catalog/es.md @@ -50,17 +50,17 @@ CREATE CATALOG es PROPERTIES ( ### 参数说明 -参数 | 是否必须 | 默认值 | 说明 ---- | --- | --- |------------------------------------------------------------------------ -`hosts` | 是 | | ES 地址,可以是一个或多个,也可以是 ES 的负载均衡地址 | -`user` | 否 | 空 | ES 用户名 | -`password` | 否 | 空 | 对应用户的密码信息 | -`doc_value_scan` | 否 | true | 是否开启通过 ES/Lucene 列式存储获取查询字段的值 | -`keyword_sniff` | 否 | true | 是否对 ES 中字符串分词类型 text.fields 进行探测,通过 keyword 进行查询。设置为 false 会按照分词后的内容匹配 | -`nodes_discovery` | 否 | true | 是否开启 ES 节点发现,默认为 true,在网络隔离环境下设置为 false,只连接指定节点 | -`ssl` | 否 | false | ES 是否开启 https 访问模式,目前在 fe/be 实现方式为信任所有 | -`mapping_es_id` | 否 | false | 是否映射 ES 索引中的 `_id` 字段 | -`like_push_down` | 否 | true | 是否将 like 转化为 wildchard 下推到 ES,会增加 ES cpu 消耗 | +参数 | 是否必须 | 默认值 | 说明 | +----------------- | ------- | ----- |-------------------------------------------------------------------------------------------------| +`hosts` | 是 | | ES 地址,可以是一个或多个,也可以是 ES 的负载均衡地址 | +`user` | 否 | 空 | ES 用户名 | +`password` | 否 | 空 | 对应用户的密码信息 | +`doc_value_scan` | 否 | true | 是否开启通过 ES/Lucene 列式存储获取查询字段的值 | +`keyword_sniff` | 否 | true | 是否对 ES 中字符串分词类型 text.fields 进行探测,通过 keyword 进行查询。设置为 false 会按照分词后的内容匹配 | +`nodes_discovery` | 否 | true | 是否开启 ES 节点发现,默认为 true,在网络隔离环境下设置为 false,只连接指定节点 | +`ssl` | 否 | false | ES 是否开启 https 访问模式,目前在 fe/be 实现方式为信任所有 | +`mapping_es_id` | 否 | false | 是否映射 ES 索引中的 `_id` 字段 | +`like_push_down` | 否 | true | 是否将 like 转化为 wildchard 下推到 ES,会增加 ES cpu 消耗 | > 1. 认证方式目前仅支持 Http Basic 认证,并且需要确保该用户有访问: `/_cluster/state/、_nodes/http` 等路径和 index 的读权限; 集群未开启安全认证,用户名和密码不需要设置。 > @@ -68,26 +68,26 @@ CREATE CATALOG es PROPERTIES ( ## 列类型映射 -| ES Type | Doris Type | Comment | -|---|---|------------------------------------------------------------| -|null| null|| -| boolean | boolean | | -| byte| tinyint| | -| short| smallint| | -| integer| int| | -| long| bigint| | -| unsigned_long| largeint | | -| float| float| | -| half_float| float| | -| double | double | | -| scaled_float| double | | -| date | date | 仅支持 default/yyyy-MM-dd HH:mm:ss/yyyy-MM-dd/epoch_millis 格式 | -| keyword | string | | -| text |string | | -| ip |string | | -| nested |string | | -| object |string | | -|other| unsupported || +| ES Type | Doris Type | Comment | +|---------------|-------------|---------------------------------------------------------------| +| null | null | | +| boolean | boolean | | +| byte | tinyint | | +| short | smallint | | +| integer | int | | +| long | bigint | | +| unsigned_long | largeint | | +| float | float | | +| half_float | float | | +| double | double | | +| scaled_float | double | | +| date | date | 仅支持 default/yyyy-MM-dd HH:mm:ss/yyyy-MM-dd/epoch_millis 格式 | +| keyword | string | | +| text | string | | +| ip | string | | +| nested | string | | +| object | string | | +| other | unsupported | | @@ -160,18 +160,18 @@ ES Catalog 支持过滤条件的下推: 过滤条件下推给ES,这样只有 下面的操作符(Operators)会被优化成如下ES Query: -| SQL syntax | ES 5.x+ syntax | -|-------|:---:| -| = | term query| -| in | terms query | -| > , < , >= , ⇐ | range query | -| and | bool.filter | -| or | bool.should | -| not | bool.must_not | -| not in | bool.must_not + terms query | -| is\_not\_null | exists query | -| is\_null | bool.must_not + exists query | -| esquery | ES原生json形式的QueryDSL | +| SQL syntax | ES 5.x+ syntax | +|-----------------| :---------------------------:| +| = | term query | +| in | terms query | +| > , < , >= , ⇐ | range query | +| and | bool.filter | +| or | bool.should | +| not | bool.must_not | +| not in | bool.must_not + terms query | +| is\_not\_null | exists query | +| is\_null | bool.must_not + exists query | +| esquery | ES原生json形式的QueryDSL | ### 启用列式扫描优化查询速度(enable\_docvalue\_scan=true) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/multi-catalog/hive.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/multi-catalog/hive.md index 112c708a473e5..a543c67a30cfe 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/multi-catalog/hive.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/multi-catalog/hive.md @@ -204,24 +204,24 @@ CREATE CATALOG hive PROPERTIES ( 适用于 Hive/Iceberge/Hudi -| HMS Type | Doris Type | Comment | -|---|---|---| -| boolean| boolean | | -| tinyint|tinyint | | -| smallint| smallint| | -| int| int | | -| bigint| bigint | | -| date| date| | -| timestamp| datetime| | -| float| float| | -| double| double| | -| char| char | | -| varchar| varchar| | -| decimal| decimal | | -| `array` | `array`| 支持array嵌套,如 `array>` | -| `map` | `map` | 暂不支持嵌套,KeyType 和 ValueType 需要为基础类型 | -| `struct` | `struct` | 暂不支持嵌套,Type1, Type2, ... 需要为基础类型 | -| other | unsupported | | +| HMS Type | Doris Type | Comment | +|-----------------------------------------|-----------------------------------------|----------------------------------------------| +| boolean | boolean | | +| tinyint | tinyint | | +| smallint | smallint | | +| int | int | | +| bigint | bigint | | +| date | date | | +| timestamp | datetime | | +| float | float | | +| double | double | | +| char | char | | +| varchar | varchar | | +| decimal | decimal | | +| `array` | `array` | 支持array嵌套,如 `array>` | +| `map` | `map` | 暂不支持嵌套,KeyType 和 ValueType 需要为基础类型 | +| `struct` | `struct` | 暂不支持嵌套,Type1, Type2, ... 需要为基础类型 | +| other | unsupported | | ## 使用Ranger进行权限校验 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/multi-catalog/iceberg.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/multi-catalog/iceberg.md index 28ac001f47bc0..1c14a6a9dca00 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/multi-catalog/iceberg.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/multi-catalog/iceberg.md @@ -168,4 +168,4 @@ CREATE CATALOG iceberg PROPERTIES ( `SELECT * FROM iceberg_tbl FOR VERSION AS OF 868895038966572;` -另外,可以使用 [iceberg_meta](../../sql-manual/sql-functions/table-functions/iceberg_meta.md) 表函数查询指定表的 snapshot 信息。 +另外,可以使用 [iceberg_meta](../../sql-manual/sql-functions/table-functions/iceberg-meta.md) 表函数查询指定表的 snapshot 信息。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/multi-catalog/jdbc.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/multi-catalog/jdbc.md index 88d2b60ae8900..a0cf0cd60c765 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/multi-catalog/jdbc.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/multi-catalog/jdbc.md @@ -320,140 +320,140 @@ set enable_odbc_transcation = true; ### MySQL -| MYSQL Type | Doris Type | Comment | -|---|---|---| -| BOOLEAN | BOOLEAN | | -| TINYINT | TINYINT | | -| SMALLINT | SMALLINT | | -| MEDIUMINT | INT | | -| INT | INT | | -| BIGINT | BIGINT | | -| UNSIGNED TINYINT | SMALLINT | Doris 没有 UNSIGNED 数据类型,所以扩大一个数量级| -| UNSIGNED MEDIUMINT | INT | Doris 没有 UNSIGNED 数据类型,所以扩大一个数量级| -| UNSIGNED INT | BIGINT |Doris 没有 UNSIGNED 数据类型,所以扩大一个数量级 | -| UNSIGNED BIGINT | LARGEINT | | -| FLOAT | FLOAT | | -| DOUBLE | DOUBLE | | -| DECIMAL | DECIMAL | | -| DATE | DATE | | -| TIMESTAMP | DATETIME | | -| DATETIME | DATETIME | | -| YEAR | SMALLINT | | -| TIME | STRING | | -| CHAR | CHAR | | -| VARCHAR | VARCHAR | | -| TINYTEXT、TEXT、MEDIUMTEXT、LONGTEXT、TINYBLOB、BLOB、MEDIUMBLOB、LONGBLOB、TINYSTRING、STRING、MEDIUMSTRING、LONGSTRING、BINARY、VARBINARY、JSON、SET、BIT | STRING | | -|Other| UNSUPPORTED | +| MYSQL Type | Doris Type | Comment | +|-------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|---------------------------------------------| +| BOOLEAN | BOOLEAN | | +| TINYINT | TINYINT | | +| SMALLINT | SMALLINT | | +| MEDIUMINT | INT | | +| INT | INT | | +| BIGINT | BIGINT | | +| UNSIGNED TINYINT | SMALLINT | Doris 没有 UNSIGNED 数据类型,所以扩大一个数量级 | +| UNSIGNED MEDIUMINT | INT | Doris 没有 UNSIGNED 数据类型,所以扩大一个数量级 | +| UNSIGNED INT | BIGINT | Doris 没有 UNSIGNED 数据类型,所以扩大一个数量级 | +| UNSIGNED BIGINT | LARGEINT | | +| FLOAT | FLOAT | | +| DOUBLE | DOUBLE | | +| DECIMAL | DECIMAL | | +| DATE | DATE | | +| TIMESTAMP | DATETIME | | +| DATETIME | DATETIME | | +| YEAR | SMALLINT | | +| TIME | STRING | | +| CHAR | CHAR | | +| VARCHAR | VARCHAR | | +| TINYTEXT、TEXT、MEDIUMTEXT、LONGTEXT、TINYBLOB、BLOB、MEDIUMBLOB、LONGBLOB、TINYSTRING、STRING、MEDIUMSTRING、LONGSTRING、BINARY、VARBINARY、JSON、SET、BIT | STRING | | +| Other | UNSUPPORTED | | ### PostgreSQL - POSTGRESQL Type | Doris Type | Comment | -|---|---|---| -| boolean | BOOLEAN | | -| smallint/int2 | SMALLINT | | -| integer/int4 | INT | | -| bigint/int8 | BIGINT | | -| decimal/numeric | DECIMAL | | -| real/float4 | FLOAT | | -| double precision | DOUBLE | | -| smallserial | SMALLINT | | -| serial | INT | | -| bigserial | BIGINT | | -| char | CHAR | | -| varchar/text | STRING | | -| timestamp | DATETIME | | -| date | DATE | | -| time | STRING | | -| interval | STRING | | -| point/line/lseg/box/path/polygon/circle | STRING | | -| cidr/inet/macaddr | STRING | | -| bit/bit(n)/bit varying(n) | STRING | `bit`类型映射为 doris 的`STRING`类型,读出的数据是`true/false`, 而不是`1/0` | -| uuid/josnb | STRING | | -|Other| UNSUPPORTED | + POSTGRESQL Type | Doris Type | Comment | +|-----------------------------------------|-------------|-----------------------------------------------------------------------| +| boolean | BOOLEAN | | +| smallint/int2 | SMALLINT | | +| integer/int4 | INT | | +| bigint/int8 | BIGINT | | +| decimal/numeric | DECIMAL | | +| real/float4 | FLOAT | | +| double precision | DOUBLE | | +| smallserial | SMALLINT | | +| serial | INT | | +| bigserial | BIGINT | | +| char | CHAR | | +| varchar/text | STRING | | +| timestamp | DATETIME | | +| date | DATE | | +| time | STRING | | +| interval | STRING | | +| point/line/lseg/box/path/polygon/circle | STRING | | +| cidr/inet/macaddr | STRING | | +| bit/bit(n)/bit varying(n) | STRING | `bit`类型映射为 doris 的`STRING`类型,读出的数据是`true/false`, 而不是`1/0` | +| uuid/josnb | STRING | | +| Other | UNSUPPORTED | | ### Oracle -| ORACLE Type | Doris Type | Comment | -|---|---|---| -| number(p) / number(p,0) | TINYINT/SMALLINT/INT/BIGINT/LARGEINT | Doris 会根据 p 的大小来选择对应的类型:`p < 3` -> `TINYINT`; `p < 5` -> `SMALLINT`; `p < 10` -> `INT`; `p < 19` -> `BIGINT`; `p > 19` -> `LARGEINT` | -| number(p,s), [ if(s>0 && p>s) ] | DECIMAL(p,s) | | -| number(p,s), [ if(s>0 && p < s) ] | DECIMAL(s,s) | | -| number(p,s), [ if(s<0) ] | TINYINT/SMALLINT/INT/BIGINT/LARGEINT | s<0 的情况下,Doris 会将 p 设置为 p+\|s\|,并进行和 number(p) / number(p,0) 一样的映射 | -| number | | Doris 目前不支持未指定 p 和 s 的 oracle 类型 | -| decimal | DECIMAL | | -| float/real | DOUBLE | | -| DATE | DATETIME | | -| TIMESTAMP | DATETIME | | -| CHAR/NCHAR | STRING | | -| VARCHAR2/NVARCHAR2 | STRING | | -| LONG/ RAW/ LONG RAW/ INTERVAL | STRING | | -|Other| UNSUPPORTED | +| ORACLE Type | Doris Type | Comment | +|-----------------------------------|--------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------—| +| number(p) / number(p,0) | TINYINT/SMALLINT/INT/BIGINT/LARGEINT | Doris 会根据 p 的大小来选择对应的类型:`p < 3` -> `TINYINT`; `p < 5` -> `SMALLINT`; `p < 10` -> `INT`; `p < 19` -> `BIGINT`; `p > 19` -> `LARGEINT` | +| number(p,s), [ if(s>0 && p>s) ] | DECIMAL(p,s) | | +| number(p,s), [ if(s>0 && p < s) ] | DECIMAL(s,s) | | +| number(p,s), [ if(s<0) ] | TINYINT/SMALLINT/INT/BIGINT/LARGEINT | s<0 的情况下,Doris 会将 p 设置为 p+\|s\|,并进行和 number(p) / number(p,0) 一样的映射 | +| number | | Doris 目前不支持未指定 p 和 s 的 oracle 类型 | +| decimal | DECIMAL | | +| float/real | DOUBLE | | +| DATE | DATETIME | | +| TIMESTAMP | DATETIME | | +| CHAR/NCHAR | STRING | | +| VARCHAR2/NVARCHAR2 | STRING | | +| LONG/ RAW/ LONG RAW/ INTERVAL | STRING | | +| Other | UNSUPPORTED | | ### SQLServer -| SQLServer Type | Doris Type | Comment | -|---|---|---| -| bit | BOOLEAN | | -| tinyint | SMALLINT | SQLServer 的 tinyint 是无符号数,所以映射为 Doris 的 SMALLINT | -| smallint | SMALLINT | | -| int | INT | | -| bigint | BIGINT | | -| real | FLOAT | | -| float | DOUBLE | | -| money | DECIMAL(19,4) | | -| smallmoney | DECIMAL(10,4) | | -| decimal/numeric | DECIMAL | | -| date | DATE | | -| datetime/datetime2/smalldatetime | DATETIMEV2 | | -| char/varchar/text/nchar/nvarchar/ntext | STRING | | -| binary/varbinary | STRING | | -| time/datetimeoffset | STRING | | -|Other| UNSUPPORTED | | +| SQLServer Type | Doris Type | Comment | +|----------------------------------------|---------------|----------------------------------------------------------| +| bit | BOOLEAN | | +| tinyint | SMALLINT | SQLServer 的 tinyint 是无符号数,所以映射为 Doris 的 SMALLINT | +| smallint | SMALLINT | | +| int | INT | | +| bigint | BIGINT | | +| real | FLOAT | | +| float | DOUBLE | | +| money | DECIMAL(19,4) | | +| smallmoney | DECIMAL(10,4) | | +| decimal/numeric | DECIMAL | | +| date | DATE | | +| datetime/datetime2/smalldatetime | DATETIMEV2 | | +| char/varchar/text/nchar/nvarchar/ntext | STRING | | +| binary/varbinary | STRING | | +| time/datetimeoffset | STRING | | +| Other | UNSUPPORTED | | ### Clickhouse -| ClickHouse Type | Doris Type | Comment | -|------------------------------------------------------|--------------------------|----------------------------------------------------------------------------| -| Bool | BOOLEAN | | -| String | STRING | | -| Date/Date32 | DATEV2 | Jdbc Catlog 连接 ClickHouse 时默认使用 DATEV2 类型 | -| DateTime/DateTime64 | DATETIMEV2 | Jdbc Catlog 连接 ClickHouse 时默认使用 DATETIMEV2 类型 | -| Float32 | FLOAT | | -| Float64 | DOUBLE | | -| Int8 | TINYINT | | -| Int16/UInt8 | SMALLINT | Doris 没有 UNSIGNED 数据类型,所以扩大一个数量级 | -| Int32/UInt16 | INT | Doris 没有 UNSIGNED 数据类型,所以扩大一个数量级 | -| Int64/Uint32 | BIGINT | Doris 没有 UNSIGNED 数据类型,所以扩大一个数量级 | -| Int128/UInt64 | LARGEINT | Doris 没有 UNSIGNED 数据类型,所以扩大一个数量级 | -| Int256/UInt128/UInt256 | STRING | Doris 没有这个数量级的数据类型,采用 STRING 处理 | -| DECIMAL | DECIMAL/DECIMALV3/STRING | 将根据 Doris DECIMAL 字段的(precision, scale)和`enable_decimal_conversion`开关选择用何种类型 | -| Enum/IPv4/IPv6/UUID | STRING | 在显示上 IPv4,IPv6 会额外在数据最前面显示一个`/`,需要自己用`split_part`函数处理 | -| Array | ARRAY | Array 内部类型适配逻辑参考上述类型,不支持嵌套类型 | -| Other | UNSUPPORTED | | +| ClickHouse Type | Doris Type | Comment | +|------------------------------------------------------|-----------------------------|------------------------------------------------------------------------------------------| +| Bool | BOOLEAN | | +| String | STRING | | +| Date/Date32 | DATEV2 | Jdbc Catlog 连接 ClickHouse 时默认使用 DATEV2 类型 | +| DateTime/DateTime64 | DATETIMEV2 | Jdbc Catlog 连接 ClickHouse 时默认使用 DATETIMEV2 类型 | +| Float32 | FLOAT | | +| Float64 | DOUBLE | | +| Int8 | TINYINT | | +| Int16/UInt8 | SMALLINT | Doris 没有 UNSIGNED 数据类型,所以扩大一个数量级 | +| Int32/UInt16 | INT | Doris 没有 UNSIGNED 数据类型,所以扩大一个数量级 | +| Int64/Uint32 | BIGINT | Doris 没有 UNSIGNED 数据类型,所以扩大一个数量级 | +| Int128/UInt64 | LARGEINT | Doris 没有 UNSIGNED 数据类型,所以扩大一个数量级 | +| Int256/UInt128/UInt256 | STRING | Doris 没有这个数量级的数据类型,采用 STRING 处理 | +| DECIMAL | DECIMAL/DECIMALV3/STRING | 将根据 Doris DECIMAL 字段的(precision, scale)和`enable_decimal_conversion`开关选择用何种类型 | +| Enum/IPv4/IPv6/UUID | STRING | 在显示上 IPv4,IPv6 会额外在数据最前面显示一个`/`,需要自己用`split_part`函数处理 | +| Array | ARRAY | Array 内部类型适配逻辑参考上述类型,不支持嵌套类型 | +| Other | UNSUPPORTED | | ### Doris -| Doris Type | Jdbc Catlog Doris Type | Comment | -|---|---|---| -| BOOLEAN | BOOLEAN | | -| TINYINT | TINYINT | | -| SMALLINT | SMALLINT | | -| INT | INT | | -| BIGINT | BIGINT | | -| LARGEINT | LARGEINT | | -| FLOAT | FLOAT | | -| DOUBLE | DOUBLE | | -| DECIMAL / DECIMALV3 | DECIMAL/DECIMALV3/STRING | 将根据 Doris DECIMAL 字段的(precision, scale)和`enable_decimal_conversion`开关选择用何种类型 | -| DATE | DATEV2 | Jdbc Catlog 连接 Doris 时默认使用 DATEV2 类型 | -| DATEV2 | DATEV2 | | -| DATETIME | DATETIMEV2 | Jdbc Catlog 连接 Doris 时默认使用 DATETIMEV2 类型 | -| DATETIMEV2 | DATETIMEV2 | | -| CHAR | CHAR | | -| VARCHAR | VARCHAR | | -| STRING | STRING | | -| TEXT | STRING | | -|Other| UNSUPPORTED | +| Doris Type | Jdbc Catlog Doris Type | Comment | +|-----------------------|---------------------------|-----------------------------------------------------------------------------------------| +| BOOLEAN | BOOLEAN | | +| TINYINT | TINYINT | | +| SMALLINT | SMALLINT | | +| INT | INT | | +| BIGINT | BIGINT | | +| LARGEINT | LARGEINT | | +| FLOAT | FLOAT | | +| DOUBLE | DOUBLE | | +| DECIMAL / DECIMALV3 | DECIMAL/DECIMALV3/STRING | 将根据 Doris DECIMAL 字段的(precision, scale)和`enable_decimal_conversion`开关选择用何种类型 | +| DATE | DATEV2 | Jdbc Catlog 连接 Doris 时默认使用 DATEV2 类型 | +| DATEV2 | DATEV2 | | +| DATETIME | DATETIMEV2 | Jdbc Catlog 连接 Doris 时默认使用 DATETIMEV2 类型 | +| DATETIMEV2 | DATETIMEV2 | | +| CHAR | CHAR | | +| VARCHAR | VARCHAR | | +| STRING | STRING | | +| TEXT | STRING | | +| Other | UNSUPPORTED | ### SAP HANA @@ -481,22 +481,22 @@ set enable_odbc_transcation = true; ### Trino -| Trino Type | Doris Type | Comment | -|------------------------------------------------------|--------------------------|---------------------------------------------------------------------------| -| boolean | BOOLEAN | | -| tinyint | TINYINT | | -| smallint | SMALLINT | | -| integer | INT | | -| bigint | BIGINT | | -| decimal | DECIMAL/DECIMALV3/STRING | 将根据 Doris DECIMAL 字段的(precision, scale)和`enable_decimal_conversion`开关选择用何种类型| -| real | FLOAT | | -| double | DOUBLE | | -| date | DATE/DATEV2 | Jdbc Catlog 连接 Trino 时默认使用 DATEV2 类型 | -| timestamp | DATETIME/DATETIMEV2 | Jdbc Catlog 连接 Trino 时默认使用 DATETIMEV2 类型 | -| varchar | TEXT | | -| char | CHAR | | -| array | ARRAY | Array 内部类型适配逻辑参考上述类型,不支持嵌套类型 | -| others | UNSUPPORTED | | +| Trino Type | Doris Type | Comment | +|------------------------------------------------------|-------------------------------|---------------------------------------------------------------------------| +| boolean | BOOLEAN | | +| tinyint | TINYINT | | +| smallint | SMALLINT | | +| integer | INT | | +| bigint | BIGINT | | +| decimal | DECIMAL/DECIMALV3/STRING | 将根据 Doris DECIMAL 字段的(precision, scale)和`enable_decimal_conversion`开关选择用何种类型| +| real | FLOAT | | +| double | DOUBLE | | +| date | DATE/DATEV2 | Jdbc Catlog 连接 Trino 时默认使用 DATEV2 类型 | +| timestamp | DATETIME/DATETIMEV2 | Jdbc Catlog 连接 Trino 时默认使用 DATETIMEV2 类型 | +| varchar | TEXT | | +| char | CHAR | | +| array | ARRAY | Array 内部类型适配逻辑参考上述类型,不支持嵌套类型 | +| others | UNSUPPORTED | | **Note:** 目前仅针对 Trino 连接的 Hive 做了测试,其他的 Trino 连接的数据源暂时未测试。 @@ -518,7 +518,7 @@ Oracle 模式请参考 [Oracle 类型映射](#Oracle) 可全局修改配置项 - ``` +``` 修改 mysql 目录下的 my.ini 文件(linux 系统为 etc 目录下的 my.cnf 文件) [client] default-character-set=utf8mb4 @@ -537,7 +537,7 @@ Oracle 模式请参考 [Oracle 类型映射](#Oracle) ALTER TABLE table_name MODIFY colum_name VARCHAR(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ALTER TABLE table_name CHARSET=utf8mb4; SET NAMES utf8mb4 - ``` +``` 3. 读 MySQL 外表时,DateTime="0000:00:00 00:00:00"异常报错:"CAUSED BY: DataReadException: Zero date value prohibited" @@ -551,9 +551,9 @@ Oracle 模式请参考 [Oracle 类型映射](#Oracle) 如以下异常: - ``` +``` failed to load driver class com.mysql.jdbc.driver in either of hikariconfig class loader - ``` +``` 这是因为在创建 resource 时,填写的 driver_class 不正确,需要正确填写,如上方例子为大小写问题,应填写为 `"driver_class" = "com.mysql.jdbc.Driver"` @@ -561,7 +561,7 @@ Oracle 模式请参考 [Oracle 类型映射](#Oracle) 如果出现如下报错: - ``` +``` ERROR 1105 (HY000): errCode = 2, detailMessage = PoolInitializationException: Failed to initialize pool: Communications link failure The last packet successfully received from the server was 7 milliseconds ago. The last packet sent successfully to the server was 4 milliseconds ago. @@ -569,18 +569,18 @@ Oracle 模式请参考 [Oracle 类型映射](#Oracle) The last packet successfully received from the server was 7 milliseconds ago. The last packet sent successfully to the server was 4 milliseconds ago. CAUSED BY: SSLHandshakeExcepti - ``` +``` 可查看 be 的 be.out 日志 如果包含以下信息: - ``` +``` WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. - ``` +``` 可在创建 Catalog 的 `jdbc_url` 把 JDBC 连接串最后增加 `?useSSL=false` ,如 `"jdbc_url" = "jdbc:mysql://127.0.0.1:3306/test?useSSL=false"` @@ -595,11 +595,11 @@ Oracle 模式请参考 [Oracle 类型映射](#Oracle) 8. 使用 JDBC 查询 MYSQL 大数据量时,如果查询偶尔能够成功,偶尔会报如下错误,且出现该错误时 MYSQL 的连接被全部断开,无法连接到 MYSQL SERVER,过段时间后 mysql 又恢复正常,但是之前的连接都没了: - ``` +``` ERROR 1105 (HY000): errCode = 2, detailMessage = [INTERNAL_ERROR]UdfRuntimeException: JDBC executor sql has error: CAUSED BY: CommunicationsException: Communications link failure The last packet successfully received from the server was 4,446 milliseconds ago. The last packet sent successfully to the server was 4,446 milliseconds ago. - ``` +``` 出现上述现象时,可能是 Mysql Server 自身的内存或 CPU 资源被耗尽导致 Mysql 服务不可用,可以尝试增大 Mysql Server 的内存或 CPU 配置。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/multi-catalog/multi-catalog.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/multi-catalog/multi-catalog.md index adb1b6fd1c3d3..7c34133826151 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/multi-catalog/multi-catalog.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/lakehouse/multi-catalog/multi-catalog.md @@ -331,17 +331,17 @@ Doris 的权限管理功能提供了对 Catalog 层级的扩展,具体可参 自动刷新目前仅支持 Hive Metastore 元数据服务。通过让 FE 节点定时读取 HMS 的 notification event 来感知 Hive 表元数据的变更情况,目前支持处理如下 event: -|事件 | 事件行为和对应的动作 | -|---|---| -| CREATE DATABASE | 在对应数据目录下创建数据库。 | -| DROP DATABASE | 在对应数据目录下删除数据库。 | -| ALTER DATABASE | 此事件的影响主要有更改数据库的属性信息,注释及默认存储位置等,这些改变不影响 doris 对外部数据目录的查询操作,因此目前会忽略此 event。 | -| CREATE TABLE | 在对应数据库下创建表。 | -| DROP TABLE | 在对应数据库下删除表,并失效表的缓存。 | -| ALTER TABLE | 如果是重命名,先删除旧名字的表,再用新名字创建表,否则失效该表的缓存。 | -| ADD PARTITION | 在对应表缓存的分区列表里添加分区。 | -| DROP PARTITION | 在对应表缓存的分区列表里删除分区,并失效该分区的缓存。 | -| ALTER PARTITION | 如果是重命名,先删除旧名字的分区,再用新名字创建分区,否则失效该分区的缓存。 | +| 事件 | 事件行为和对应的动作 | +|-----------------|-------------------------------------------------------------------------------------------------------------------| +| CREATE DATABASE | 在对应数据目录下创建数据库。 | +| DROP DATABASE | 在对应数据目录下删除数据库。 | +| ALTER DATABASE | 此事件的影响主要有更改数据库的属性信息,注释及默认存储位置等,这些改变不影响 doris 对外部数据目录的查询操作,因此目前会忽略此 event。 | +| CREATE TABLE | 在对应数据库下创建表。 | +| DROP TABLE | 在对应数据库下删除表,并失效表的缓存。 | +| ALTER TABLE | 如果是重命名,先删除旧名字的表,再用新名字创建表,否则失效该表的缓存。 | +| ADD PARTITION | 在对应表缓存的分区列表里添加分区。 | +| DROP PARTITION | 在对应表缓存的分区列表里删除分区,并失效该分区的缓存。 | +| ALTER PARTITION | 如果是重命名,先删除旧名字的分区,再用新名字创建分区,否则失效该分区的缓存。 | > 当导入数据导致文件变更,分区表会走 ALTER PARTITION event 逻辑,不分区表会走 ALTER TABLE event 逻辑。 > diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/query-acceleration/materialized-view.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/query-acceleration/materialized-view.md index b8739061a0825..2600cd6927831 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/query-acceleration/materialized-view.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/query-acceleration/materialized-view.md @@ -123,26 +123,27 @@ Doris 系统提供了一整套对物化视图的 DDL 语法,包括创建,查 ```sql MySQL [test]> desc mv_test all; -+-----------+---------------+-----------------+----------+------+-------+---------+--------------+ -| IndexName | IndexKeysType | Field | Type | Null | Key | Default | Extra | -+-----------+---------------+-----------------+----------+------+-------+---------+--------------+ -| mv_test | DUP_KEYS | k1 | INT | Yes | true | NULL | | -| | | k2 | BIGINT | Yes | true | NULL | | -| | | k3 | LARGEINT | Yes | true | NULL | | -| | | k4 | SMALLINT | Yes | false | NULL | NONE | -| | | | | | | | | -| mv_2 | AGG_KEYS | k2 | BIGINT | Yes | true | NULL | | -| | | k4 | SMALLINT | Yes | false | NULL | MIN | -| | | k1 | INT | Yes | false | NULL | MAX | -| | | | | | | | | -| mv_3 | AGG_KEYS | k1 | INT | Yes | true | NULL | | -| | | to_bitmap(`k2`) | BITMAP | No | false | | BITMAP_UNION | -| | | | | | | | | -| mv_1 | AGG_KEYS | k4 | SMALLINT | Yes | true | NULL | | -| | | k1 | BIGINT | Yes | false | NULL | SUM | -| | | k3 | LARGEINT | Yes | false | NULL | SUM | -| | | k2 | BIGINT | Yes | false | NULL | MIN | -+-----------+---------------+-----------------+----------+------+-------+---------+--------------+ + ++-----------+---------------+-----------------+----------+------+-------+---------+------------+ +| IndexName | IndexKeysType | Field | Type | Null | Key | Default | Extra ++-----------+---------------+-----------------+----------+------+-------+---------+------------+ +| mv_test | DUP_KEYS | k1 | INT | Yes | true | NULL | +| | | k2 | BIGINT | Yes | true | NULL | +| | | k3 | LARGEINT | Yes | true | NULL | +| | | k4 | SMALLINT | Yes | false | NULL | NONE +| | | | | | | | +| mv_2 | AGG_KEYS | k2 | BIGINT | Yes | true | NULL | +| | | k4 | SMALLINT | Yes | false | NULL | MIN +| | | k1 | INT | Yes | false | NULL | MAX +| | | | | | | | +| mv_3 | AGG_KEYS | k1 | INT | Yes | true | NULL | +| | | to_bitmap(`k2`) | BITMAP | No | false | | BITMAP_UNION +| | | | | | | | +| mv_1 | AGG_KEYS | k4 | SMALLINT | Yes | true | NULL | +| | | k1 | BIGINT | Yes | false | NULL | SUM +| | | k3 | LARGEINT | Yes | false | NULL | SUM +| | | k2 | BIGINT | Yes | false | NULL | MIN ++-----------+---------------+-----------------+----------+------+-------+---------+------------+ ``` 可以看到当前 `mv_test` 表一共有三张物化视图:mv_1, mv_2 和 mv_3,以及他们的表结构。 @@ -223,11 +224,10 @@ SHOW ALTER TABLE MATERIALIZED VIEW FROM db_name; (Version 0.13) ```sql ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | JobId | TableName | CreateTime | FinishedTime | BaseIndexName | RollupIndexName | RollupId | TransactionId | State | Msg | Progress | Timeout | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ + + | 22036 | sales_records | 2020-07-30 20:04:28 | 2020-07-30 20:04:57 | sales_records | store_amt | 22037 | 5008 | FINISHED | | NULL | 86400 | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ ``` 其中 TableName 指的是物化视图的数据来自于哪个表,RollupIndexName 指的是物化视图的名称叫什么。其中比较重要的指标是 State。 @@ -351,91 +351,99 @@ MySQL [test]> desc advertiser_view_record; 创建完成后,广告点击明细表和物化视图表的表结构如下: - ```sql - MySQL [test]> desc advertiser_view_record all; - +------------------------+---------------+----------------------+-------------+------+-------+---------+--------------+ - | IndexName | IndexKeysType | Field | Type | Null | Key | Default | Extra | - +------------------------+---------------+----------------------+-------------+------+-------+---------+--------------+ - | advertiser_view_record | DUP_KEYS | time | DATE | Yes | true | NULL | | - | | | advertiser | VARCHAR(10) | Yes | true | NULL | | - | | | channel | VARCHAR(10) | Yes | false | NULL | NONE | - | | | user_id | INT | Yes | false | NULL | NONE | - | | | | | | | | | - | advertiser_uv | AGG_KEYS | advertiser | VARCHAR(10) | Yes | true | NULL | | - | | | channel | VARCHAR(10) | Yes | true | NULL | | - | | | to_bitmap(`user_id`) | BITMAP | No | false | | BITMAP_UNION | - +------------------------+---------------+----------------------+-------------+------+-------+---------+--------------+ - ``` +``` + MySQL [test]> desc advertiser_view_record all; + +------------------------+---------------+----------------------+-------------+------+-----+ + | IndexName | IndexKeysType | Field | Type | Null | Key | Default | Extra | + +------------------------+---------------+----------------------+-------------+------+-----+ + | advertiser_view_record | DUP_KEYS | time | DATE | Yes | true | NULL | | + | | | advertiser | VARCHAR(10) | Yes | true | NULL | | + | | | channel | VARCHAR(10) | Yes | false | NULL | NONE | + | | | user_id | INT | Yes | false | NULL | NONE | + | | | | | | | | | + | advertiser_uv | AGG_KEYS | advertiser | VARCHAR(10) | Yes | true | NULL | | + | | | channel | VARCHAR(10) | Yes | true | NULL | | + | | | to_bitmap(`user_id`) | BITMAP | No | false | | BITMAP_UNION | + +------------------------+---------------+----------------------+-------------+------+-----+ +``` 2. 查询自动匹配 当物化视图表创建完成后,查询广告 UV 时,Doris 就会自动从刚才创建好的物化视图 `advertiser_uv` 中查询数据。比如原始的查询语句如下: - ```sql +```sql SELECT advertiser, channel, count(distinct user_id) FROM advertiser_view_record GROUP BY advertiser, channel; - ``` +``` 在选中物化视图后,实际的查询会转化为: - ```sql +```sql SELECT advertiser, channel, bitmap_union_count(to_bitmap(user_id)) FROM advertiser_uv GROUP BY advertiser, channel; - ``` +``` 通过 EXPLAIN 命令可以检验到 Doris 是否匹配到了物化视图: - ```sql - mysql [test]>explain SELECT advertiser, channel, count(distinct user_id) FROM advertiser_view_record GROUP BY advertiser, channel; - +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | Explain String | - +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | PLAN FRAGMENT 0 | - | OUTPUT EXPRS: | - | `default_cluster:test`.`advertiser_view_record`.`mv_advertiser` | - | `default_cluster:test`.`advertiser_view_record`.`mv_channel` | - | bitmap_union_count(`default_cluster:test`.`advertiser_view_record`.`mva_BITMAP_UNION__to_bitmap_with_check(`user_id`)`) | - | PARTITION: UNPARTITIONED | - | | - | VRESULT SINK | - | | - | 4:VEXCHANGE | - | offset: 0 | - | | - | PLAN FRAGMENT 1 | - | | - | PARTITION: HASH_PARTITIONED: `default_cluster:test`.`advertiser_view_record`.`mv_advertiser`, `default_cluster:test`.`advertiser_view_record`.`mv_channel` | - | | - | STREAM DATA SINK | - | EXCHANGE ID: 04 | - | UNPARTITIONED | - | | - | 3:VAGGREGATE (merge finalize) | - | | output: bitmap_union_count( bitmap_union_count(`default_cluster:test`.`advertiser_view_record`.`mva_BITMAP_UNION__to_bitmap_with_check(`user_id`)`)) | - | | group by: `default_cluster:test`.`advertiser_view_record`.`mv_advertiser`, `default_cluster:test`.`advertiser_view_record`.`mv_channel` | - | | cardinality=-1 | - | | | - | 2:VEXCHANGE | - | offset: 0 | - | | - | PLAN FRAGMENT 2 | - | | - | PARTITION: HASH_PARTITIONED: `default_cluster:test`.`advertiser_view_record`.`time` | - | | - | STREAM DATA SINK | - | EXCHANGE ID: 02 | - | HASH_PARTITIONED: `default_cluster:test`.`advertiser_view_record`.`mv_advertiser`, `default_cluster:test`.`advertiser_view_record`.`mv_channel` | - | | - | 1:VAGGREGATE (update serialize) | - | | STREAMING | - | | output: bitmap_union_count(`default_cluster:test`.`advertiser_view_record`.`mva_BITMAP_UNION__to_bitmap_with_check(`user_id`)`) | - | | group by: `default_cluster:test`.`advertiser_view_record`.`mv_advertiser`, `default_cluster:test`.`advertiser_view_record`.`mv_channel` | - | | cardinality=-1 | - | | | - | 0:VOlapScanNode | - | TABLE: default_cluster:test.advertiser_view_record(advertiser_uv), PREAGGREGATION: ON | - | partitions=1/1, tablets=10/10, tabletList=50075,50077,50079 ... | - | cardinality=0, avgRowSize=48.0, numNodes=1 | - +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - ``` +```sql + mysql [test]>explain SELECT advertiser, channel, count(distinct user_id) + FROM advertiser_view_record GROUP BY advertiser, channel; + +------------------------------------------------------------------------------------------+ + | Explain String | + +------------------------------------------------------------------------------------------+ + | PLAN FRAGMENT 0 | + | OUTPUT EXPRS: | + | `default_cluster:test`.`advertiser_view_record`.`mv_advertiser` | + | `default_cluster:test`.`advertiser_view_record`.`mv_channel` | + | bitmap_union_count(`default_cluster:test`.`advertiser_view_record` | + | .`mva_BITMAP_UNION__to_bitmap_with_check(`user_id`)`) | + | PARTITION: UNPARTITIONED | + | | + | VRESULT SINK | + | | + | 4:VEXCHANGE | + | offset: 0 | + | | + | PLAN FRAGMENT 1 | + | | + | PARTITION: HASH_PARTITIONED: `default_cluster:test`.`advertiser_view_record` | + | .`mv_advertiser`, `default_cluster:test`.`advertiser_view_record`.`mv_channel`| + | | + | STREAM DATA SINK | + | EXCHANGE ID: 04 | + | UNPARTITIONED | + | | + | 3:VAGGREGATE (merge finalize) | + | output: bitmap_union_count( bitmap_union_count(`default_cluster:test` | + | .`advertiser_view_record`.`mva_BITMAP_UNION__to_bitmap_with_check(`user_id`)`)) | + | group by: `default_cluster:test`.`advertiser_view_record`.`mv_advertiser`, | + | `default_cluster:test`.`advertiser_view_record`.`mv_channel` | + | | cardinality=-1 | + | | | + | 2:VEXCHANGE | + | offset: 0 | + | | + | PLAN FRAGMENT 2 | + | | + | PARTITION: HASH_PARTITIONED: `default_cluster:test`.`advertiser_view_record`.`time` | + | | + | STREAM DATA SINK | + | EXCHANGE ID: 02 | + | HASH_PARTITIONED: `default_cluster:test`.`advertiser_view_record` | + | .`mv_advertiser`, `default_cluster:test`.`advertiser_view_record`.`mv_channel` | + | | + | 1:VAGGREGATE (update serialize) | + | | STREAMING | + | | output: bitmap_union_count(`default_cluster:test`.`advertiser_view_record` | + | .`mva_BITMAP_UNION__to_bitmap_with_check(`user_id`)`) | + | | group by: `default_cluster:test`.`advertiser_view_record`.`mv_advertiser`, | + | `default_cluster:test` .`advertiser_view_record`.`mv_channel` | + | | cardinality=-1 | + | | | + | 0:VOlapScanNode | + | TABLE: default_cluster:test.advertiser_view_record(advertiser_uv), PREAGGREGATION: ON + | partitions=1/1, tablets=10/10, tabletList=50075,50077,50079 ... | + | cardinality=0, avgRowSize=48.0, numNodes=1 | + +------------------------------------------------------------------------------------------+ +``` 在 EXPLAIN 的结果中,首先可以看到`VOlapScanNode`命中了`advertiser_uv`。也就是说,查询会直接扫描物化视图的数据。说明匹配成功。 @@ -453,13 +461,13 @@ MySQL [test]> desc advertiser_view_record; 1. 创建物化视图 - ```sql +```sql CREATE MATERIALIZED VIEW mv_1 as SELECT k3, k2, k1 FROM tableA ORDER BY k3; - ``` +``` 通过上面语法创建完成后,物化视图中既保留了完整的明细数据,且物化视图的前缀索引为 k3 列。表结构如下: - ```sql +```sql MySQL [test]> desc tableA all; +-----------+---------------+-------+------+------+-------+---------+-------+ | IndexName | IndexKeysType | Field | Type | Null | Key | Default | Extra | @@ -472,15 +480,15 @@ MySQL [test]> desc advertiser_view_record; | | | k2 | INT | Yes | false | NULL | NONE | | | | k1 | INT | Yes | false | NULL | NONE | +-----------+---------------+-------+------+------+-------+---------+-------+ - ``` +``` 2. 查询匹配 这时候如果用户的查询存在 k3 列的过滤条件是,比如: - ```sql +```sql select k1, k2, k3 from table A where k3=3; - ``` +``` 这时候查询就会直接从刚才创建的 mv_1 物化视图中读取数据。物化视图对 k3 是存在前缀索引的,查询效率也会提升。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/query-acceleration/slow-query-analysis/get-profile.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/query-acceleration/slow-query-analysis/get-profile.md index cb980072389e4..33a7cd1a63070 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/query-acceleration/slow-query-analysis/get-profile.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/query-acceleration/slow-query-analysis/get-profile.md @@ -40,7 +40,7 @@ under the License. 该参数开启的是 session 变量,此变量不建议全局开启。 - ``` +``` --开启变量 mysql> set enable_profile=true; Query OK, 0 rows affected (0.00 sec) @@ -53,13 +53,13 @@ under the License. | enable_profile | true | false | 1 | +----------------+-------+---------------+---------+ 1 row in set (0.00 sec) - ``` +``` 2. 执行对应 Query 集群在多个 FE 的情况下,需要到开启 Profile 上报参数的 FE 上执行对应 Query, 参数并没有全局生效。 - ``` +``` --开启变量 mysql> set enable_profile=true; Query OK, 0 rows affected (0.00 sec) @@ -74,13 +74,14 @@ under the License. --执行对应 Query mysql> select id,name from test.test where name like "%RuO%"; - +---------------------------+-----------------------------------------------------------------------------------------------------------------------------+ - | id | name | - +---------------------------+-----------------------------------------------------------------------------------------------------------------------------+ - | 1ZWXYGbb8nr5Pi29J4cEMyEMb | ZN1nqzBRSl1rTrr99rnX1aplxhRuOUTLw6so7rzjlRQ317gTPxh0dHljmrARDJjH7FjRkJW9c7YuUBmWikq7eNgmFKJPreWirDrGrFzUYH4eP6kDtSA3UTnNIIj | - +---------------------------+-----------------------------------------------------------------------------------------------------------------------------+ + +---------------------------+--------------------------------------------------------------+ + | id | name | + +---------------------------+--------------------------------------------------------------+ + | 1ZWXYGbb8nr5Pi29J4cEMyEMb | ZN1nqzBRSl1rTrr99rnX1aplxhRuOUTLw6so7rzjlRQ317gTPxh0dHljmrARD + JjH7FjRkJW9c7YuUBmWikq7eNgmFKJPreWirDrGrFzUYH4eP6kDtSA3UTnNIIj | + +---------------------------+--------------------------------------------------------------+ 1 row in set (0.01 sec) - ``` +``` 3. 获取 Profile @@ -97,32 +98,32 @@ under the License. - 找到对应 Query ID - ``` +``` --根据对应 Query 找到 Profile ID mysql> show query profile "/"; - +-----------------------------------+-----------+---------------------+---------------------+-------+------------+------+------------+-------------------------------------------------------+ - | Profile ID | Task Type | Start Time | End Time | Total | Task State | User | Default Db | Sql Statement | - +-----------------------------------+-----------+---------------------+---------------------+-------+------------+------+------------+-------------------------------------------------------+ + +-----------------------------------+-------------------------------------------------------+ + | Profile ID | Task Type | Start Time | End Time | Total | Task State | User | Default Db | Sql Statement | + +-----------------------------------+-------------------------------------------------------+ | 1b0bb22689734d30-bbe56e17c2ff21dc | QUERY | 2024-02-28 11:00:17 | 2024-02-28 11:00:17 | 7ms | EOF | root | | select id,name from test.test where name like "%RuO%" | | 202fb174510c4772-965289e8f7f0cf10 | QUERY | 2024-02-25 19:39:20 | 2024-02-25 19:39:20 | 19ms | EOF | root | | select id,name from test.test where name like "%KJ%" | - +-----------------------------------+-----------+---------------------+---------------------+-------+------------+------+------------+-------------------------------------------------------+ + +-------------------------------------------------------------------------------------------+ 2 rows in set (0.00 sec) - ``` +``` - 查询 Profile 并将 Profile 重定向到一个文本中 - ``` +``` 模板:CURL -X GET -u user:password http://fe_ip:http_port/api/profile?query_id=1b0bb22689734d30-bbe56e17c2ff21dc > test.profile [user@VM-10-6-centos profile]$ curl -X GET -u root:root http://127.0.0.1:8030/api/profile?query_id=1b0bb22689734d30-bbe56e17c2ff21dc > test.profile % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1211 0 1211 0 0 168k 0 --:--:-- --:--:-- --:--:-- 168k - ``` +``` -- 返回的 Profile 换行符为 \ \n 分析起来很不方便,可以在文本编辑工具中将 \ \n 替换为 \n +- 返回的 Profile 换行符为 `\ \n` 分析起来很不方便,可以在文本编辑工具中将 `\ \n` 替换为 `\n` - ``` +``` [user@VM-10-6-centos profile]$ cat test.profile {"msg":"success","code":0,"data":{"profile":"Query:\n Summary:\n - Profile ID: 1b0bb22689734d30-bbe56e17c2ff21dc\n - Task Type: QUERY\n @@ -140,10 +141,10 @@ under the License. - Is Nereids: Yes\n - Is Pipeline: Yes\n - Is Cached: Yes\n - Total Instances Num: 0\n - Instances Num Per BE: \n - Parallel Fragment Exec Instance Num: 48\n - Trace ID: \n"},"count":0} - ``` +``` - 替换后的效果如下 - ``` +``` {"msg":"success","code":0,"data":{"profile":"Query: Summary: - Profile ID: 1b0bb22689734d30-bbe56e17c2ff21dc @@ -181,4 +182,4 @@ under the License. - Parallel Fragment Exec Instance Num: 48 - Trace ID: "},"count":0} - ``` \ No newline at end of file +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/releasenotes/v1.1/release-1.1.0.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/releasenotes/v1.1/release-1.1.0.md index ff7cca49b1302..981c270f932ce 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/releasenotes/v1.1/release-1.1.0.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/releasenotes/v1.1/release-1.1.0.md @@ -89,11 +89,11 @@ Iceberg 外部表为 Apache Doris 提供了直接访问存储在 Iceberg 数据 - 在 TPC-H 测试数据集的全部 22 个 SQL 上,1.1 版本均优于 0.15 版本,整体性能约提升了 4.5 倍,部分场景性能达到了十余倍的提升; -![](/images/release-note-1.1.0-SSB.png) +![release-note-1.1.0-SSB](/images/release-note-1.1.0-SSB.png)

SSB 测试数据集

-![](/images/release-note-1.1.0-TPC-H.png) +![release-note-1.1.0-TPC-H](/images/release-note-1.1.0-TPC-H.png)

TPC-H 测试数据集

diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/releasenotes/v2.1/release-2.1.0.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/releasenotes/v2.1/release-2.1.0.md index d14aec8a307e5..ba0cb1694515d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/releasenotes/v2.1/release-2.1.0.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/releasenotes/v2.1/release-2.1.0.md @@ -658,17 +658,21 @@ IN 谓词的左参数支持 `struct() function` 构建的 Struct 类型的数据 ```SQL mysql> select struct(1,"2") in (struct(1,3), struct(1,"2"), struct(1,1), null); -+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| cast(struct(1, '2') as STRUCT) IN (NULL, cast(struct(1, '2') as STRUCT), cast(struct(1, 1) as STRUCT), cast(struct(1, 3) as STRUCT)) | -+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ++-------------------------------------------------------------------------------------------+ +| cast(struct(1, '2') as STRUCT) IN (NULL, cast(struct(1, '2') | +| as STRUCT), cast(struct(1, 1) as STRUCT), cast(struct(1, 3) as STRUCT)) | ++-------------------------------------------------------------------------------------------+ +| 1 | ++-------------------------------------------------------------------------------------------+ mysql> select struct(1,"2") not in (struct(1,3), struct(1,"2"), struct(1,1), null); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| ( not cast(struct(1, '2') as STRUCT) IN (NULL, cast(struct(1, '2') as STRUCT), cast(struct(1, 1) as STRUCT), cast(struct(1, 3) as STRUCT))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ++-------------------------------------------------------------------------------------------+ +| ( not cast(struct(1, '2') as STRUCT) IN (NULL, cast(struct(1, '2')| +| as STRUCT), cast(struct(1, 1) as STRUCT), | +| cast(struct(1, 3) as STRUCT))) | ++-------------------------------------------------------------------------------------------+ +| 0 | ++-------------------------------------------------------------------------------------------+ ``` - `MAP_AGG`:接收 expr1 作为键,expr2 作为对应的值,返回一个 MAP @@ -789,13 +793,11 @@ insert into test_arithmetic_expressions_256 values ```SQL select k1, k2, k1 + k2 a from test_arithmetic_expressions_256 order by 1, 2; -+----------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+ -| k1 | k2 | a | -+----------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+ +| k1 | k2 | a | +| --------------|-------------------------|--------------------| | 1.000000000000000000000000000001 | 9999999999999999999999999999999999999999999998.999999999999999999999999999998 | 9999999999999999999999999999999999999999999999.999999999999999999999999999999 | | 2.100000000000000000000000000001 | 4999999999999999999999999999999999999999999999.899999999999999999999999999998 | 5000000000000000000000000000000000000000000001.999999999999999999999999999999 | | 3.666666666666666666666666666666 | 3333333333333333333333333333333333333333333333.333333333333333333333333333333 | 3333333333333333333333333333333333333333333336.999999999999999999999999999999 | -+----------------------------------+-------------------------------------------------------------------------------+-------------------------------------------------------------------------------+ 3 rows in set (0.09 sec) ``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/any_value.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/any-value.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/any_value.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/any-value.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/approx_count_distinct.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/approx-count-distinct.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/approx_count_distinct.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/approx-count-distinct.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/avg_weighted.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/avg-weighted.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/avg_weighted.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/avg-weighted.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/bitmap_union.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/bitmap-union.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/bitmap_union.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/bitmap-union.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/collect_list.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/collect-list.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/collect_list.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/collect-list.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/collect_set.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/collect-set.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/collect_set.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/collect-set.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group_bit_and.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group-bit-and.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group_bit_and.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group-bit-and.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group_bit_or.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group-bit-or.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group_bit_or.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group-bit-or.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group_bit_xor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group-bit-xor.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group_bit_xor.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group-bit-xor.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group_bitmap_xor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group-bitmap-xor.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group_bitmap_xor.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group-bitmap-xor.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group_concat.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group-concat.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group_concat.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group-concat.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/grouping_id.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/grouping-id.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/grouping_id.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/grouping-id.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/grouping.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/grouping.md index 3acb117e86408..e40ff2d6bd43b 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/grouping.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/grouping.md @@ -104,4 +104,4 @@ GROUPING ### Best Practice -还可参阅 [GROUPING_ID](./grouping_id.md) +还可参阅 [GROUPING_ID](./grouping-id.md) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/hll_union_agg.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/hll_union_agg.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/max_by.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/max-by.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/max_by.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/max-by.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/min_by.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/min-by.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/min_by.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/min-by.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/percentile_approx.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/percentile-approx.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/percentile_approx.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/percentile-approx.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/percentile_array.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/percentile-array.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/percentile_array.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/percentile-array.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/sequence_count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/sequence-count.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/sequence_count.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/sequence-count.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/sequence_match.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/sequence-match.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/sequence_match.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/sequence-match.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/stddev_samp.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/stddev-samp.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/stddev_samp.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/stddev-samp.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/topn_array.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/topn-array.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/topn_array.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/topn-array.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/topn_weighted.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/topn-weighted.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/topn_weighted.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/topn-weighted.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/var_samp.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/var-samp.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/var_samp.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/aggregate-functions/var-samp.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_apply.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-apply.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_apply.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-apply.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_avg.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-avg.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_avg.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-avg.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-compact.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-compact.md new file mode 100644 index 0000000000000..85987146d9436 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-compact.md @@ -0,0 +1,81 @@ +--- +{ + "title": "array_compact", + "language": "zh-CN" +} +--- + + + +## array_compact + +array_compact + +## 描述 + +从数组中删除连续的重复元素,结果值的顺序由源数组中的顺序决定。 + +## 语法 + +`Array array_compact(arr)` + +## 参数 + +`arr` — 需要处理的数组. + +## 返回值 + +不存在连续重复元素的数组. + +Type: Array. + +## 注意事项 + +`只支持在向量化引擎中使用。` + +## 举例 + +``` +select array_compact([1, 2, 3, 3, null, null, 4, 4]); + ++----------------------------------------------------+ +| array_compact(ARRAY(1, 2, 3, 3, NULL, NULL, 4, 4)) | ++----------------------------------------------------+ +| [1, 2, 3, NULL, 4] | ++----------------------------------------------------+ + +select array_compact(['aaa','aaa','bbb','ccc','ccccc',null, null,'dddd']); + ++-------------------------------------------------------------------------------+ +| array_compact(ARRAY('aaa', 'aaa', 'bbb', 'ccc', 'ccccc', NULL, NULL, 'dddd')) | ++-------------------------------------------------------------------------------+ +| ['aaa', 'bbb', 'ccc', 'ccccc', NULL, 'dddd'] | ++-------------------------------------------------------------------------------+ + +select array_compact(['2015-03-13','2015-03-13']); + ++--------------------------------------------------+ +| array_compact(ARRAY('2015-03-13', '2015-03-13')) | ++--------------------------------------------------+ +| ['2015-03-13'] | ++--------------------------------------------------+ +``` + +### keywords + +ARRAY,COMPACT,ARRAY_COMPACT \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_concat.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-concat.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_concat.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-concat.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_contains.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-contains.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_contains.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-contains.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_cum_sum.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-cum-sum.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_cum_sum.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-cum-sum.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_difference.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-difference.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_difference.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-difference.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_distinct.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-distinct.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_distinct.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-distinct.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_enumerate_uniq.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-enumerate-uniq.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_enumerate_uniq.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-enumerate-uniq.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_enumerate.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-enumerate.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_enumerate.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-enumerate.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_except.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-except.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_except.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-except.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_exists.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-exists.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_exists.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-exists.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_filter.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-filter.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_filter.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-filter.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_first_index.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-first-index.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_first_index.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-first-index.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_intersect.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-intersect.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_intersect.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-intersect.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_join.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-join.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_join.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-join.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_map.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-map.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_map.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-map.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_max.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-max.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_max.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-max.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_min.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-min.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_min.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-min.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_popback.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-popback.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_popback.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-popback.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_popfront.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-popfront.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_popfront.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-popfront.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_position.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-position.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_position.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-position.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_product.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-product.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_product.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-product.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_pushfront.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-pushfront.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_pushfront.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-pushfront.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_range.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-range.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_range.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-range.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_remove.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-remove.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_remove.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-remove.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_reverse_sort.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-reverse-sort.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_reverse_sort.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-reverse-sort.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_shuffle.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-shuffle.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_shuffle.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-shuffle.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_size.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-size.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_size.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-size.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_slice.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-slice.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_slice.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-slice.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_sort.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-sort.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_sort.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-sort.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_sortby.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-sortby.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_sortby.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-sortby.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_sum.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-sum.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_sum.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-sum.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_union.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-union.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_union.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-union.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_with_constant.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-with-constant.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_with_constant.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array-with-constant.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_compact.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_compact.md deleted file mode 100644 index 619e30690fdf3..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/array_compact.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -{ - "title": "array_compact", - "language": "zh-CN", -} ---- - - - -## array_compact - -array_compact - -## 描述 - -从数组中删除连续的重复元素,结果值的顺序由源数组中的顺序决定。 - -## 语法 - -`Array array_compact(arr)` - -## 参数 - -`arr` — 需要处理的数组. - -## 返回值 - -不存在连续重复元素的数组. - -Type: Array. - -## 注意事项 - -`只支持在向量化引擎中使用。` - -## 举例 - -``` -select array_compact([1, 2, 3, 3, null, null, 4, 4]); - -+----------------------------------------------------+ -| array_compact(ARRAY(1, 2, 3, 3, NULL, NULL, 4, 4)) | -+----------------------------------------------------+ -| [1, 2, 3, NULL, 4] | -+----------------------------------------------------+ - -select array_compact(['aaa','aaa','bbb','ccc','ccccc',null, null,'dddd']); - -+-------------------------------------------------------------------------------+ -| array_compact(ARRAY('aaa', 'aaa', 'bbb', 'ccc', 'ccccc', NULL, NULL, 'dddd')) | -+-------------------------------------------------------------------------------+ -| ['aaa', 'bbb', 'ccc', 'ccccc', NULL, 'dddd'] | -+-------------------------------------------------------------------------------+ - -select array_compact(['2015-03-13','2015-03-13']); - -+--------------------------------------------------+ -| array_compact(ARRAY('2015-03-13', '2015-03-13')) | -+--------------------------------------------------+ -| ['2015-03-13'] | -+--------------------------------------------------+ -``` - -### keywords - -ARRAY,COMPACT,ARRAY_COMPACT \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/arrays_overlap.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/arrays-overlap.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/arrays_overlap.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/arrays-overlap.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/element_at.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/element-at.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/element_at.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/array-functions/element-at.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_and_count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-and-count.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_and_count.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-and-count.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_and_not_count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-and-not-count.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_and_not_count.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-and-not-count.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_and_not.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-and-not.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_and_not.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-and-not.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_and.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-and.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_and.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-and.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_contains.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-contains.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_contains.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-contains.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-count.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_count.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-count.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_empty.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-empty.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_empty.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-empty.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_from_array.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-from-array.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_from_array.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-from-array.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_from_string.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-from-string.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_from_string.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-from-string.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_has_all.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-has-all.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_has_all.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-has-all.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_has_any.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-has-any.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_has_any.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-has-any.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-hash.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-hash.md new file mode 100644 index 0000000000000..63ca8d3bf1efd --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-hash.md @@ -0,0 +1,112 @@ +--- +{ + "title": "bitmap_hash", + "language": "zh-CN" +} +--- + + + +## bitmap_hash + +### Name + +BITMAP_HASH + +## 描述 + +对任意类型的输入,计算其 32 位的哈希值,并返回包含该哈希值的 bitmap。该函数使用的哈希算法为 MurMur3。MurMur3 算法是一种高性能的、低碰撞率的散列算法,其计算出来的值接近于随机分布,并且能通过卡方分布测试。需要注意的是,不同硬件平台、不同 Seed 值计算出来的散列值可能不同。关于此算法的性能可以参考 [Smhasher](http://rurban.github.io/smhasher/) 排行榜。 + +## 语法 + +`BITMAP BITMAP_HASH()` + +## 参数 + +`` +任何值或字段表达式。 + +#### Return Type + +BITMAP + +#### Remarks + +一般来说,MurMur 32 位算法对于完全随机的、较短的字符串的散列效果较好,碰撞率能达到几十亿分之一,但对于较长的字符串,比如你的操作系统路径,碰撞率会比较高。如果你扫描你系统里的路径,就会发现碰撞率仅仅只能达到百万分之一甚至是十万分之一。 + +下面两个字符串的 MurMur3 散列值是一样的: + +```sql +SELECT bitmap_to_string(bitmap_hash('/System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/KernelManagement.framework/KernelManagement.tbd')) AS a , + bitmap_to_string(bitmap_hash('/System/Library/PrivateFrameworks/Install.framework/Versions/Current/Resources/es_419.lproj/Architectures.strings')) AS b; +``` + +结果如下: + +```text ++-----------+-----------+ +| a | b | ++-----------+-----------+ +| 282251871 | 282251871 | ++-----------+-----------+ +``` + +## 举例 + +如果你想计算某个值的 MurMur3,你可以: + +``` +select bitmap_to_array(bitmap_hash('hello'))[1]; +``` + +结果如下: + +```text ++-------------------------------------------------------------+ +| %element_extract%(bitmap_to_array(bitmap_hash('hello')), 1) | ++-------------------------------------------------------------+ +| 1321743225 | ++-------------------------------------------------------------+ +``` + +如果你想统计某一列去重后的个数,可以使用位图的方式,某些场景下性能比 `count distinct` 好很多: + +```sql +select bitmap_count(bitmap_union(bitmap_hash(`word`))) from `words`; +``` + +结果如下: + +```text ++-------------------------------------------------+ +| bitmap_count(bitmap_union(bitmap_hash(`word`))) | ++-------------------------------------------------+ +| 33263478 | ++-------------------------------------------------+ +``` + +### Keywords + + BITMAP_HASH,BITMAP + +### Best Practice + +还可参见 +- [BITMAP_HASH64](./bitmap-hash64.md) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_hash64.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-hash64.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_hash64.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-hash64.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_intersect.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-intersect.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_intersect.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-intersect.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_max.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-max.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_max.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-max.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_min.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-min.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_min.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-min.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_not.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-not.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_not.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-not.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_or_count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-or-count.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_or_count.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-or-count.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_or.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-or.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_or.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-or.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_subset_in_range.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-subset-in-range.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_subset_in_range.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-subset-in-range.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_subset_limit.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-subset-limit.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_subset_limit.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-subset-limit.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_to_array.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-to-array.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_to_array.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-to-array.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_to_string.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-to-string.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_to_string.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-to-string.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_union.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-union.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_union.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-union.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_xor_count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-xor-count.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_xor_count.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-xor-count.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_xor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-xor.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_xor.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-xor.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_hash.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_hash.md deleted file mode 100644 index dbcd355481757..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_hash.md +++ /dev/null @@ -1,112 +0,0 @@ ---- -{ - "title": "bitmap_hash", - "language": "zh-CN" -} ---- - - - -## bitmap_hash - -### Name - -BITMAP_HASH - -## 描述 - -对任意类型的输入,计算其 32 位的哈希值,并返回包含该哈希值的 bitmap。该函数使用的哈希算法为 MurMur3。MurMur3 算法是一种高性能的、低碰撞率的散列算法,其计算出来的值接近于随机分布,并且能通过卡方分布测试。需要注意的是,不同硬件平台、不同 Seed 值计算出来的散列值可能不同。关于此算法的性能可以参考 [Smhasher](http://rurban.github.io/smhasher/) 排行榜。 - -## 语法 - -`BITMAP BITMAP_HASH()` - -## 参数 - -`` -任何值或字段表达式。 - -#### Return Type - -BITMAP - -#### Remarks - -一般来说,MurMur 32 位算法对于完全随机的、较短的字符串的散列效果较好,碰撞率能达到几十亿分之一,但对于较长的字符串,比如你的操作系统路径,碰撞率会比较高。如果你扫描你系统里的路径,就会发现碰撞率仅仅只能达到百万分之一甚至是十万分之一。 - -下面两个字符串的 MurMur3 散列值是一样的: - -```sql -SELECT bitmap_to_string(bitmap_hash('/System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/KernelManagement.framework/KernelManagement.tbd')) AS a , - bitmap_to_string(bitmap_hash('/System/Library/PrivateFrameworks/Install.framework/Versions/Current/Resources/es_419.lproj/Architectures.strings')) AS b; -``` - -结果如下: - -```text -+-----------+-----------+ -| a | b | -+-----------+-----------+ -| 282251871 | 282251871 | -+-----------+-----------+ -``` - -## 举例 - -如果你想计算某个值的 MurMur3,你可以: - -``` -select bitmap_to_array(bitmap_hash('hello'))[1]; -``` - -结果如下: - -```text -+-------------------------------------------------------------+ -| %element_extract%(bitmap_to_array(bitmap_hash('hello')), 1) | -+-------------------------------------------------------------+ -| 1321743225 | -+-------------------------------------------------------------+ -``` - -如果你想统计某一列去重后的个数,可以使用位图的方式,某些场景下性能比 `count distinct` 好很多: - -```sql -select bitmap_count(bitmap_union(bitmap_hash(`word`))) from `words`; -``` - -结果如下: - -```text -+-------------------------------------------------+ -| bitmap_count(bitmap_union(bitmap_hash(`word`))) | -+-------------------------------------------------+ -| 33263478 | -+-------------------------------------------------+ -``` - -### Keywords - - BITMAP_HASH,BITMAP - -### Best Practice - -还可参见 -- [BITMAP_HASH64](./bitmap_hash64.md) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/intersect_count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/intersect-count.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/intersect_count.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/intersect-count.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal_bitmap_intersect_count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal-bitmap-intersect-count.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal_bitmap_intersect_count.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal-bitmap-intersect-count.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal_bitmap_intersect.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal-bitmap-intersect.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal_bitmap_intersect.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal-bitmap-intersect.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal_bitmap_union_count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal-bitmap-union-count.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal_bitmap_union_count.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal-bitmap-union-count.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/sub_bitmap.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/sub-bitmap.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/sub_bitmap.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/sub-bitmap.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/to_bitmap.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/to-bitmap.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/to_bitmap.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/bitmap-functions/to-bitmap.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/convert_tz.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/convert-tz.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/convert_tz.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/convert-tz.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/current_timestamp.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/current-timestamp.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/current_timestamp.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/current-timestamp.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/date_add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/date-add.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/date_add.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/date-add.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/date_format.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/date-format.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/date_format.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/date-format.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/date_sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/date-sub.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/date_sub.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/date-sub.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/date_trunc.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/date-trunc.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/date_trunc.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/date-trunc.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/day_ceil.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/day-ceil.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/day_ceil.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/day-ceil.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/day_floor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/day-floor.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/day_floor.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/day-floor.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/days_add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/days-add.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/days_add.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/days-add.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/days_diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/days-diff.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/days_diff.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/days-diff.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/days_sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/days-sub.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/days_sub.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/days-sub.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/from_days.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/from-days.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/from_days.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/from-days.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/from_unixtime.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/from-unixtime.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/from_unixtime.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/from-unixtime.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/hour_ceil.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/hour-ceil.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/hour_ceil.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/hour-ceil.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/hour_floor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/hour-floor.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/hour_floor.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/hour-floor.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours_add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours-add.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours_add.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours-add.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours_diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours-diff.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours_diff.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours-diff.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours_sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours-sub.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours_sub.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours-sub.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/last_day.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/last-day.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/last_day.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/last-day.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/microseconds_add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/microseconds-add.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/microseconds_add.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/microseconds-add.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/microseconds_sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/microseconds-sub.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/microseconds_sub.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/microseconds-sub.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/minute_ceil.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/minute-ceil.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/minute_ceil.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/minute-ceil.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/minute_floor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/minute-floor.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/minute_floor.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/minute-floor.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes_add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes-add.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes_add.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes-add.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes_diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes-diff.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes_diff.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes-diff.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes_sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes-sub.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes_sub.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes-sub.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/month_ceil.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/month-ceil.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/month_ceil.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/month-ceil.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/month_floor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/month-floor.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/month_floor.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/month-floor.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/months_add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/months-add.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/months_add.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/months-add.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/months_diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/months-diff.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/months_diff.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/months-diff.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/months_sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/months-sub.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/months_sub.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/months-sub.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/second_ceil.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/second-ceil.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/second_ceil.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/second-ceil.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/second_floor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/second-floor.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/second_floor.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/second-floor.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds_add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds-add.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds_add.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds-add.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds_diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds-diff.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds_diff.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds-diff.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds_sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds-sub.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds_sub.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds-sub.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/str-to-date.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/str-to-date.md new file mode 100644 index 0000000000000..b8ca55ecc19a0 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/str-to-date.md @@ -0,0 +1,72 @@ +--- +{ + "title": "str_to_date", + "language": "zh-CN" +} +--- + + + +## str_to_date +## 描述 +## 语法 + +`DATETIME STR_TO_DATE(VARCHAR str, VARCHAR format)` + +通过format指定的方式将str转化为DATE类型,如果转化结果不对返回NULL。注意format指定的是第一个参数的格式。 + +支持的format格式与[date_format](date-format.md)一致 + +## 举例 + +``` +mysql> select str_to_date('2014-12-21 12:34:56', '%Y-%m-%d %H:%i:%s'); ++---------------------------------------------------------+ +| str_to_date('2014-12-21 12:34:56', '%Y-%m-%d %H:%i:%s') | ++---------------------------------------------------------+ +| 2014-12-21 12:34:56 | ++---------------------------------------------------------+ + +mysql> select str_to_date('2014-12-21 12:34%3A56', '%Y-%m-%d %H:%i%%3A%s'); ++--------------------------------------------------------------+ +| str_to_date('2014-12-21 12:34%3A56', '%Y-%m-%d %H:%i%%3A%s') | ++--------------------------------------------------------------+ +| 2014-12-21 12:34:56 | ++--------------------------------------------------------------+ + +mysql> select str_to_date('200442 Monday', '%X%V %W'); ++-----------------------------------------+ +| str_to_date('200442 Monday', '%X%V %W') | ++-----------------------------------------+ +| 2004-10-18 | ++-----------------------------------------+ + +mysql> select str_to_date("2020-09-01", "%Y-%m-%d %H:%i:%s"); ++------------------------------------------------+ +| str_to_date('2020-09-01', '%Y-%m-%d %H:%i:%s') | ++------------------------------------------------+ +| 2020-09-01 00:00:00 | ++------------------------------------------------+ +1 row in set (0.01 sec) +``` + +### keywords + + STR_TO_DATE,STR,TO,DATE diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/str_to_date.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/str_to_date.md deleted file mode 100644 index 3e4de026bf821..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/str_to_date.md +++ /dev/null @@ -1,72 +0,0 @@ ---- -{ - "title": "str_to_date", - "language": "zh-CN" -} ---- - - - -## str_to_date -## 描述 -## 语法 - -`DATETIME STR_TO_DATE(VARCHAR str, VARCHAR format)` - -通过format指定的方式将str转化为DATE类型,如果转化结果不对返回NULL。注意format指定的是第一个参数的格式。 - -支持的format格式与[date_format](date_format.md)一致 - -## 举例 - -``` -mysql> select str_to_date('2014-12-21 12:34:56', '%Y-%m-%d %H:%i:%s'); -+---------------------------------------------------------+ -| str_to_date('2014-12-21 12:34:56', '%Y-%m-%d %H:%i:%s') | -+---------------------------------------------------------+ -| 2014-12-21 12:34:56 | -+---------------------------------------------------------+ - -mysql> select str_to_date('2014-12-21 12:34%3A56', '%Y-%m-%d %H:%i%%3A%s'); -+--------------------------------------------------------------+ -| str_to_date('2014-12-21 12:34%3A56', '%Y-%m-%d %H:%i%%3A%s') | -+--------------------------------------------------------------+ -| 2014-12-21 12:34:56 | -+--------------------------------------------------------------+ - -mysql> select str_to_date('200442 Monday', '%X%V %W'); -+-----------------------------------------+ -| str_to_date('200442 Monday', '%X%V %W') | -+-----------------------------------------+ -| 2004-10-18 | -+-----------------------------------------+ - -mysql> select str_to_date("2020-09-01", "%Y-%m-%d %H:%i:%s"); -+------------------------------------------------+ -| str_to_date('2020-09-01', '%Y-%m-%d %H:%i:%s') | -+------------------------------------------------+ -| 2020-09-01 00:00:00 | -+------------------------------------------------+ -1 row in set (0.01 sec) -``` - -### keywords - - STR_TO_DATE,STR,TO,DATE diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/time_round.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/time-round.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/time_round.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/time-round.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/time_to_sec.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/time-to-sec.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/time_to_sec.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/time-to-sec.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/to_date.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/to-date.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/to_date.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/to-date.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/to_days.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/to-days.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/to_days.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/to-days.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/to_monday.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/to-monday.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/to_monday.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/to-monday.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/unix_timestamp.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/unix-timestamp.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/unix_timestamp.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/unix-timestamp.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/utc_timestamp.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/utc-timestamp.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/utc_timestamp.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/utc-timestamp.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks_add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks-add.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks_add.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks-add.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks_diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks-diff.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks_diff.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks-diff.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks_sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks-sub.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks_sub.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks-sub.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/year_ceil.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/year-ceil.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/year_ceil.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/year-ceil.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/year_floor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/year-floor.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/year_floor.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/year-floor.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/years_add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/years-add.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/years_add.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/years-add.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/years_diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/years-diff.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/years_diff.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/years-diff.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/years_sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/years-sub.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/years_sub.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/date-time-functions/years-sub.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hash-functions/murmur_hash3_32.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hash-functions/murmur-hash3-32.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hash-functions/murmur_hash3_32.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hash-functions/murmur-hash3-32.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hash-functions/murmur_hash3_64.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hash-functions/murmur-hash3-64.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hash-functions/murmur_hash3_64.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hash-functions/murmur-hash3-64.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hll-functions/hll_cardinality.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-cardinality.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hll-functions/hll_cardinality.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-cardinality.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hll-functions/hll_empty.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-empty.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hll-functions/hll_empty.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-empty.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hll-functions/hll_hash.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-hash.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hll-functions/hll_hash.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-hash.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/get_json_bigint.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/get-json-bigint.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/get_json_bigint.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/get-json-bigint.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/get_json_double.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/get-json-double.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/get_json_double.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/get-json-double.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/get_json_int.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/get-json-int.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/get_json_int.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/get-json-int.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/get_json_string.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/get-json-string.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/get_json_string.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/get-json-string.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json_array.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json-array.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json_array.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json-array.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json_extract.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json-extract.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json_extract.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json-extract.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json_object.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json-object.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json_object.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json-object.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json_quote.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json-quote.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json_quote.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json-quote.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json-unquote.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json-unquote.md new file mode 100644 index 0000000000000..904268b337084 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json-unquote.md @@ -0,0 +1,83 @@ +--- +{ + "title": "json_unquote", + "language": "zh-CN" +} +--- + + + +## json_unquote +## 描述 +## 语法 + +`VARCHAR json_ununquote(VARCHAR)` + +这个函数将去掉JSON值中的引号,并将结果作为utf8mb4字符串返回。如果参数为NULL,则返回NULL。 + +在字符串中显示的如下转义序列将被识别,对于所有其他转义序列,反斜杠将被忽略。 + +| 转义序列 | 序列表示的字符 | +|------------|------------------------------| +| `\"` | 双引号 " | +| `\b` | 退格字符 | +| `\f` | 换页符 | +| `\n` | 换行符 | +| `\r` | 回车符 | +| `\t` | 制表符 | +| `\\` | 反斜杠 \ | +| `\uxxxx` | Unicode 值 XXXX 的 UTF-8 字节 | + + + +## 举例 + +``` +mysql> SELECT json_unquote('"doris"'); ++-------------------------+ +| json_unquote('"doris"') | ++-------------------------+ +| doris | ++-------------------------+ + +mysql> SELECT json_unquote('[1, 2, 3]'); ++---------------------------+ +| json_unquote('[1, 2, 3]') | ++---------------------------+ +| [1, 2, 3] | ++---------------------------+ + + +mysql> SELECT json_unquote(null); ++--------------------+ +| json_unquote(NULL) | ++--------------------+ +| NULL | ++--------------------+ + +mysql> SELECT json_unquote('"\\ttest"'); ++--------------------------+ +| json_unquote('"\ttest"') | ++--------------------------+ +| test | ++--------------------------+ +``` +### keywords +json,unquote,json_unquote diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json_valid.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json-valid.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json_valid.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json-valid.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json_unquote.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json_unquote.md deleted file mode 100644 index 5b0d057716e61..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/json_unquote.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -{ - "title": "json_unquote", - "language": "zh-CN" -} ---- - - - -## json_unquote -## 描述 -## 语法 - -`VARCHAR json_ununquote(VARCHAR)` - -这个函数将去掉JSON值中的引号,并将结果作为utf8mb4字符串返回。如果参数为NULL,则返回NULL。 - -在字符串中显示的如下转义序列将被识别,对于所有其他转义序列,反斜杠将被忽略。 - -| 转义序列 | 序列表示的字符 | -|----------|-------------------------------| -| \" | 双引号 " | -| \b | 退格字符 | -| \f | 换页符 | -| \n | 换行符 | -| \r | 回车符 | -| \t | 制表符 | -| \\ | 反斜杠 \ | -| \uxxxx | Unicode 值 XXXX 的 UTF-8 字节 | - - - -## 举例 - -``` -mysql> SELECT json_unquote('"doris"'); -+-------------------------+ -| json_unquote('"doris"') | -+-------------------------+ -| doris | -+-------------------------+ - -mysql> SELECT json_unquote('[1, 2, 3]'); -+---------------------------+ -| json_unquote('[1, 2, 3]') | -+---------------------------+ -| [1, 2, 3] | -+---------------------------+ - - -mysql> SELECT json_unquote(null); -+--------------------+ -| json_unquote(NULL) | -+--------------------+ -| NULL | -+--------------------+ - -mysql> SELECT json_unquote('"\\ttest"'); -+--------------------------+ -| json_unquote('"\ttest"') | -+--------------------------+ -| test | -+--------------------------+ -``` -### keywords -json,unquote,json_unquote diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb_exists_path.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb-exists-path.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb_exists_path.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb-exists-path.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb_extract.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb-extract.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb_extract.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb-extract.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb_parse.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb-parse.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb_parse.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb-parse.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb_type.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb-type.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb_type.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb-type.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/math-functions/round_bankers.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/math-functions/round-bankers.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/math-functions/round_bankers.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/math-functions/round-bankers.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/math-functions/running_difference.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/math-functions/running-difference.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/math-functions/running_difference.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/math-functions/running-difference.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_angle_sphere.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-angle-sphere.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_angle_sphere.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-angle-sphere.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_angle.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-angle.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_angle.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-angle.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_area.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-area.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_area.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-area.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_asbinary.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-asbinary.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_asbinary.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-asbinary.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_astext.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-astext.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_astext.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-astext.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_azimuth.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-azimuth.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_azimuth.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-azimuth.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_circle.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-circle.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_circle.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-circle.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_contains.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-contains.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_contains.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-contains.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_distance_sphere.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-distance-sphere.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_distance_sphere.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-distance-sphere.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_geometryfromtext.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-geometryfromtext.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_geometryfromtext.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-geometryfromtext.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_geometryfromwkb.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-geometryfromwkb.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_geometryfromwkb.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-geometryfromwkb.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_linefromtext.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-linefromtext.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_linefromtext.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-linefromtext.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_point.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-point.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_point.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-point.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_polygon.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-polygon.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_polygon.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-polygon.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_x.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-x.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_x.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-x.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_y.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-y.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_y.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-y.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/append_trailing_char_if_absent.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/append-trailing-char-if-absent.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/append_trailing_char_if_absent.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/append-trailing-char-if-absent.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/bit_length.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/bit-length.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/bit_length.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/bit-length.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/char_length.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/char-length.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/char_length.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/char-length.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/concat_ws.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/concat-ws.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/concat_ws.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/concat-ws.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/convert_to.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/convert-to.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/convert_to.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/convert-to.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/ends_with.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/ends-with.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/ends_with.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/ends-with.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/extract-url-parameter.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/extract-url-parameter.md new file mode 100644 index 0000000000000..b17cd7b2e7b41 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/extract-url-parameter.md @@ -0,0 +1,52 @@ +--- +{ +"title": "extract_url_parameter", +"language": "zh-CN" +} +--- + + + +## extract_url_parameter +## 描述 +## 语法 + +`VARCHAR extract_url_parameter(VARCHAR url, VARCHAR name)` + + +返回 URL 中“name”参数的值(如果存在)。否则为空字符串。 +如果有许多具有此名称的参数,则返回第一个出现的参数。 +此函数的工作假设参数名称在 URL 中的编码方式与在传递参数中的编码方式完全相同。 + +``` +mysql> SELECT extract_url_parameter ("http://doris.apache.org?k1=aa&k2=bb&test=cc#999", "k2"); ++--------------------------------------------------------------------------------+ +| extract_url_parameter('http://doris.apache.org?k1=aa&k2=bb&test=cc#999', 'k2') | ++--------------------------------------------------------------------------------+ +| bb | ++--------------------------------------------------------------------------------+ +``` + +如果想获取 URL 中的其他部分,可以使用[parse_url](./parse-url.md)。 + +### keywords + EXTRACT URL PARAMETER diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/extract_url_parameter.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/extract_url_parameter.md deleted file mode 100644 index 73085afbe7fa8..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/extract_url_parameter.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -{ -"title": "extract_url_parameter", -"language": "zh-CN" -} ---- - - - -## extract_url_parameter -## 描述 -## 语法 - -`VARCHAR extract_url_parameter(VARCHAR url, VARCHAR name)` - - -返回 URL 中“name”参数的值(如果存在)。否则为空字符串。 -如果有许多具有此名称的参数,则返回第一个出现的参数。 -此函数的工作假设参数名称在 URL 中的编码方式与在传递参数中的编码方式完全相同。 - -``` -mysql> SELECT extract_url_parameter ("http://doris.apache.org?k1=aa&k2=bb&test=cc#999", "k2"); -+--------------------------------------------------------------------------------+ -| extract_url_parameter('http://doris.apache.org?k1=aa&k2=bb&test=cc#999', 'k2') | -+--------------------------------------------------------------------------------+ -| bb | -+--------------------------------------------------------------------------------+ -``` - -如果想获取 URL 中的其他部分,可以使用[parse_url](./parse_url.md)。 - -### keywords - EXTRACT URL PARAMETER diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/find_in_set.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/find-in-set.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/find_in_set.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/find-in-set.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/from_base64.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/from-base64.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/from_base64.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/from-base64.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/like/not_like.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/like/not-like.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/like/not_like.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/like/not-like.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/mask/mask_first_n.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/mask/mask-first-n.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/mask/mask_first_n.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/mask/mask-first-n.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/mask/mask_last_n.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/mask/mask-last-n.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/mask/mask_last_n.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/mask/mask-last-n.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/money_format.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/money-format.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/money_format.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/money-format.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/not_null_or_empty.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/not-null-or-empty.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/not_null_or_empty.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/not-null-or-empty.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/null_or_empty.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/null-or-empty.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/null_or_empty.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/null-or-empty.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/parse-url.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/parse-url.md new file mode 100644 index 0000000000000..46c678f3c118f --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/parse-url.md @@ -0,0 +1,48 @@ +--- +{ + "title": "parse_url", + "language": "zh-CN" +} +--- + + + +## parse_url +## 描述 +## 语法 + +`VARCHAR parse_url(VARCHAR url, VARCHAR name)` + + +在url解析出name对应的字段,name可选项为:'PROTOCOL', 'HOST', 'PATH', 'REF', 'AUTHORITY', 'FILE', 'USERINFO', 'PORT', 'QUERY',将结果返回。 + +``` +mysql> SELECT parse_url ('https://doris.apache.org/', 'HOST'); ++------------------------------------------------+ +| parse_url('https://doris.apache.org/', 'HOST') | ++------------------------------------------------+ +| doris.apache.org | ++------------------------------------------------+ +``` + +如果想获取 QUERY 中的特定参数,可使用[extract_url_parameter](./extract-url-parameter.md)。 + +### keywords + PARSE URL diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/parse_url.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/parse_url.md deleted file mode 100644 index f9c174a0f91f5..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/parse_url.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -{ - "title": "parse_url", - "language": "zh-CN" -} ---- - - - -## parse_url -## 描述 -## 语法 - -`VARCHAR parse_url(VARCHAR url, VARCHAR name)` - - -在url解析出name对应的字段,name可选项为:'PROTOCOL', 'HOST', 'PATH', 'REF', 'AUTHORITY', 'FILE', 'USERINFO', 'PORT', 'QUERY',将结果返回。 - -``` -mysql> SELECT parse_url ('https://doris.apache.org/', 'HOST'); -+------------------------------------------------+ -| parse_url('https://doris.apache.org/', 'HOST') | -+------------------------------------------------+ -| doris.apache.org | -+------------------------------------------------+ -``` - -如果想获取 QUERY 中的特定参数,可使用[extract_url_parameter](./extract_url_parameter.md)。 - -### keywords - PARSE URL diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp_extract_all.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp-extract-all.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp_extract_all.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp-extract-all.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp_extract.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp-extract.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp_extract.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp-extract.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp_replace_one.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp-replace-one.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp_replace_one.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp-replace-one.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp_replace.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp-replace.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp_replace.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp-replace.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/search/multi_match_any.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/search/multi-match-any.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/search/multi_match_any.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/search/multi-match-any.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/search/multi_search_all_positions.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/search/multi-search-all-positions.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/search/multi_search_all_positions.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/search/multi-search-all-positions.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/split_by_string.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/split-by-string.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/split_by_string.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/split-by-string.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/split_part.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/split-part.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/split_part.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/split-part.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/starts_with.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/starts-with.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/starts_with.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/starts-with.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/sub_replace.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/sub-replace.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/sub_replace.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/sub-replace.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/substring_index.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/substring-index.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/substring_index.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/substring-index.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/to_base64.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/to-base64.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/to_base64.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/string-functions/to-base64.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/table-functions/iceberg_meta.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/table-functions/iceberg-meta.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/table-functions/iceberg_meta.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-functions/table-functions/iceberg-meta.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Load/CREATE-ROUTINE-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Load/CREATE-ROUTINE-LOAD.md index bf750f1e4c852..9a433bd831fb3 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Load/CREATE-ROUTINE-LOAD.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Load/CREATE-ROUTINE-LOAD.md @@ -178,7 +178,7 @@ FROM data_source [data_source_properties] | source data | source data example | string to int | strict_mode | result | | ----------- | ------------------- | ------------- | ------------- | ---------------------- | - | 空值 | \N | N/A | true or false | NULL | + | 空值 | `\N` | N/A | true or false | NULL | | not null | aaa or 2000 | NULL | true | invalid data(filtered) | | not null | aaa | NULL | false | NULL | | not null | 1 | 1 | true or false | correct data | @@ -189,7 +189,7 @@ FROM data_source [data_source_properties] | source data | source data example | string to int | strict_mode | result | | ----------- | ------------------- | ------------- | ------------- | ---------------------- | - | 空值 | \N | N/A | true or false | NULL | + | 空值 |` \N` | N/A | true or false | NULL | | not null | aaa | NULL | true | invalid data(filtered) | | not null | aaa | NULL | false | NULL | | not null | 1 or 10 | 1 | true or false | correct data | @@ -558,11 +558,11 @@ Doris 支持指定 Partition 和 Offset 开始消费,还支持了指定时间 在创建导入作业时,这三个参数可以有以下组合: -| 组合 | `kafka_partitions` | `kafka_offsets` | `property.kafka_default_offset` | 行为 | -| ---- | ------------------ | --------------- | ------------------------------- | ------------------------------------------------------------ | -| 1 | No | No | No | 系统会自动查找topic对应的所有分区并从 OFFSET_END 开始消费 | -| 2 | No | No | Yes | 系统会自动查找topic对应的所有分区并从 default offset 指定的位置开始消费 | -| 3 | Yes | No | No | 系统会从指定分区的 OFFSET_END 开始消费 | -| 4 | Yes | Yes | No | 系统会从指定分区的指定offset 处开始消费 | -| 5 | Yes | No | Yes | 系统会从指定分区,default offset 指定的位置开始消费 | +| 组合 | kafka_partitions | kafka_offsets | property.kafka_default_offset | 行为 | +|-----------------|------------------------------|---------------------|-----------------------------------------------------------| ---------------------------------------------------------------------------------------------------------------------------------------| +| 1 | No | No | No | 系统会自动查找topic对应的所有分区并从 OFFSET_END 开始消费 | +| 2 | No | No | Yes | 系统会自动查找topic对应的所有分区并从 default offset 指定的位置开始消费                                   | +| 3 | Yes | No | No | 系统会从指定分区的 OFFSET_END 开始消费 | +| 4 | Yes | Yes | No | 系统会从指定分区的指定offset 处开始消费 | +| 5 | Yes | No | Yes | 系统会从指定分区,default offset 指定的位置开始消费 | diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Load/STREAM-LOAD.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Load/STREAM-LOAD.md index e9c534a2fbd9a..72aa1d09cef17 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Load/STREAM-LOAD.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Load/STREAM-LOAD.md @@ -57,13 +57,13 @@ curl --location-trusted -u user:passwd [-H ""...] -T data.file -XPUT http://fe_h 当前 Doris 内部保留 30 分钟内最近成功的 label。 -2. column_separator:用于指定导入文件中的列分隔符,默认为\t。如果是不可见字符,则需要加\x作为前缀,使用十六进制来表示分隔符。 +2. column_separator:用于指定导入文件中的列分隔符,默认为`\t`。如果是不可见字符,则需要加\x作为前缀,使用十六进制来表示分隔符。 如 hive 文件的分隔符\x01,需要指定为-H "column_separator:\x01"。 可以使用多个字符的组合作为列分隔符。 -3. line_delimiter:用于指定导入文件中的换行符,默认为\n。可以使用做多个字符的组合作为换行符。 +3. line_delimiter:用于指定导入文件中的换行符,默认为`\n`。可以使用做多个字符的组合作为换行符。 4. columns:用于指定导入文件中的列和 table 中的列的对应关系。如果源文件中的列正好对应表中的内容,那么是不需要指定这个字段的内容的。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/EXPORT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/EXPORT.md index f051c992f2a52..9ee73fa02b924 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/EXPORT.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/EXPORT.md @@ -69,8 +69,8 @@ WITH BROKER 可以指定如下参数: - - `column_separator`:指定导出的列分隔符,默认为\t。仅支持单字节。 - - `line_delimiter`:指定导出的行分隔符,默认为\n。仅支持单字节。 + - `column_separator`:指定导出的列分隔符,默认为`\t`。仅支持单字节。 + - `line_delimiter`:指定导出的行分隔符,默认为`\n`。仅支持单字节。 - `exec_mem_limit`:导出在单个 BE 节点的内存使用上限,默认为 2GB,单位为字节。 - `timeout`:导出作业的超时时间,默认为2小时,单位是秒。 - `tablet_num_per_task`:每个子任务能分配扫描的最大 Tablet 数量。 @@ -153,7 +153,7 @@ WITH BROKER "broker_name" EXPORT TABLE testTbl TO "file:///home/data/a"; ``` -6. 将 testTbl 表中的所有数据导出到 hdfs 上,以不可见字符 "\x07" 作为列或者行分隔符。 +6. 将 testTbl 表中的所有数据导出到 hdfs 上,以不可见字符 `"\x07"` 作为列或者行分隔符。 ```sql EXPORT TABLE testTbl TO "hdfs://hdfs_host:port/a/b/c" @@ -174,7 +174,7 @@ WITH BROKER "broker_name" EXPORT TABLE testTbl TO "file:///home/data/a" PROPERTIES ("columns" = "k1,v1"); ``` -8. 将 testTbl 表中的所有数据导出到 s3 上,以不可见字符 "\x07" 作为列或者行分隔符。 +8. 将 testTbl 表中的所有数据导出到 s3 上,以不可见字符 `"\x07"` 作为列或者行分隔符。 ```sql EXPORT TABLE testTbl TO "s3://hdfs_host:port/a/b/c" diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-reference/Data-Types/QUANTILE_STATE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-reference/Data-Types/QUANTILE-STATE.md similarity index 100% rename from i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-reference/Data-Types/QUANTILE_STATE.md rename to i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-reference/Data-Types/QUANTILE-STATE.md diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-reference/Show-Statements/SHOW-LOAD-PROFILE.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-reference/Show-Statements/SHOW-LOAD-PROFILE.md index 96960ab421dbe..e255d1c1b2dba 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-reference/Show-Statements/SHOW-LOAD-PROFILE.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/sql-manual/sql-reference/Show-Statements/SHOW-LOAD-PROFILE.md @@ -227,5 +227,4 @@ WaitAndFetchResultTime: N/A SHOW, LOAD, PROFILE -### Best Practice diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/summary/basic-summary.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/summary/basic-summary.md index 0cc35d2885da9..0e69882dd991b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/summary/basic-summary.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2/summary/basic-summary.md @@ -35,6 +35,7 @@ Apache Doris 如今在中国乃至全球范围内都拥有着广泛的用户群 # 使用场景 如下图所示,数据源经过各种数据集成和加工处理后,通常会入库到实时数仓 Doris 和离线湖仓(Hive, Iceberg, Hudi 中),Apache Doris 被广泛应用在以下场景中。 + ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sekvbs5ih5rb16wz6n9k.png) - 报表分析 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/ecosystem/doris-kafka-connector.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/ecosystem/doris-kafka-connector.md index a024eda851bf7..1dc66b0df4fa4 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/ecosystem/doris-kafka-connector.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/ecosystem/doris-kafka-connector.md @@ -48,7 +48,7 @@ maven 依赖 配置 config/connect-standalone.properties ```properties -# 修改 broker 地址 +# 修改 kafka server 地址 bootstrap.servers=127.0.0.1:9092 # 修改为创建的 plugins 目录 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/releasenotes/v1.1/release-1.1.0.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/releasenotes/v1.1/release-1.1.0.md index 0e4f3961e3c31..ff11843f2b632 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/releasenotes/v1.1/release-1.1.0.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/releasenotes/v1.1/release-1.1.0.md @@ -89,11 +89,11 @@ Iceberg 外部表为 Apache Doris 提供了直接访问存储在 Iceberg 数据 - 在 TPC-H 测试数据集的全部 22 个 SQL 上,1.1 版本均优于 0.15 版本,整体性能约提升了 4.5 倍,部分场景性能达到了十余倍的提升; -![](/images/release-note-1.1.0-SSB.png) +![release-note-1.1.0-SSB](/images/release-note-1.1.0-SSB.png)

SSB 测试数据集

-![](/images/release-note-1.1.0-TPC-H.png) +![release-note-1.1.0-TPC-H](/images/release-note-1.1.0-TPC-H.png)

TPC-H 测试数据集

diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-angle-sphere.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-angle-sphere.md index 2220defaba4de..6bac0360a12b1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-angle-sphere.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-angle-sphere.md @@ -24,38 +24,52 @@ specific language governing permissions and limitations under the License. --> -## ST_Angle_Sphere +## 描述 -### Syntax +计算地球表面两点之间的圆心角,单位为 度。传入的参数分别为 X 点的经度,X 点的纬度,Y 点的经度,Y 点的纬度。 -`DOUBLE ST_Angle_Sphere(DOUBLE x_lng, DOUBLE x_lat, DOUBLE y_lng, DOUBLE y_lat)` +## 语法 -## 描述 +```sql +ST_Angle_Sphere( , , , ) +``` -计算地球表面两点之间的圆心角,单位为 度。传入的参数分别为X点的经度,X点的纬度,Y点的经度,Y点的纬度。 +## 参数 -x_lng 和 y_lng 都是经度数据,合理的取值范围是 [-180, 180]。 +| 参数 | 说明 | +| -- | -- | +| `` | 经度数据,合理的取值范围是 [-180, 180] | +| `` | 经度数据,合理的取值范围是 [-180, 180] | +| `` | 纬度数据,合理的取值范围是 [-90, 90] | +| `` | 纬度数据,合理的取值范围是 [-90, 90] | -x_lat 和 y_lat 都是纬度数据,合理的取值范围是 [-90, 90]。 +## 返回值 + +两点之间的圆心角角度 ## 举例 +```sql +select ST_Angle_Sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); ``` -mysql> select ST_Angle_Sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); + +```text +---------------------------------------------------------------------------+ | st_angle_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219) | +---------------------------------------------------------------------------+ | 0.0659823452409903 | +---------------------------------------------------------------------------+ -1 row in set (0.06 sec) +``` + +```sql +select ST_Angle_Sphere(0, 0, 45, 0); +``` -mysql> select ST_Angle_Sphere(0, 0, 45, 0); +```text +----------------------------------------+ | st_angle_sphere(0.0, 0.0, 45.0, 0.0) | +----------------------------------------+ | 45 | +----------------------------------------+ -1 row in set (0.06 sec) ``` -### keywords -ST_ANGLE_SPHERE,ST,ANGLE,SPHERE + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-angle.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-angle.md index d43d4f73410e3..7d18f1b8204bf 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-angle.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-angle.md @@ -24,66 +24,94 @@ specific language governing permissions and limitations under the License. --> -## ST_Angle +## 描述 -### Syntax +输入三个点,它们表示两条相交的线。返回这些线之间的夹角。 -`DOUBLE ST_Angle(GEOPOINT point1, GEOPOINT point2, GEOPOINT point3)` +## 语法 -## 描述 +```sql +ST_Angle( , , ) +``` + +## 参数 + +| 参数 | 说明 | +|----------|--------------------------| +| `` | 第一条直线的第一个端点 | +| `` | 第一条直线的第二个端点且是第二条直线的第一个端点 | +| `` | 第二条直线的第二个端点 | -输入三个点,它们表示两条相交的线。返回这些线之间的夹角。点 2 和点 1 表示第一条线,点 2 和点 3 表示第二条线。这些线之间的夹角以弧度表示,范围为 [0, 2pi)。夹角按顺时针方向从第一条线开始测量,直至第二条线。 +## 返回值 + +这些线之间的夹角以弧度表示,范围为 [0, 2pi)。夹角按顺时针方向从第一条线开始测量,直至第二条线。 ST_ANGLE 存在以下边缘情况: -* 如果点 2 和点 3 相同,则返回 NULL。 -* 如果点 2 和点 1 相同,则返回 NULL。 -* 如果点 2 和点 3 是完全对映点,则返回 NULL。 -* 如果点 2 和点 1 是完全对映点,则返回 NULL。 -* 如果任何输入地理位置不是单点或为空地理位置,则会抛出错误。 +- 如果点 2 和点 3 相同,则返回 NULL。 +- 如果点 2 和点 1 相同,则返回 NULL。 +- 如果点 2 和点 3 是完全对映点,则返回 NULL。 +- 如果点 2 和点 1 是完全对映点,则返回 NULL。 +- 如果任何输入地理位置不是单点或为空地理位置,则会抛出错误。 ## 举例 +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1)); ``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1)); + +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------------------------+ | 4.71238898038469 | +----------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1)); +``` -mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1)); +```text +----------------------------------------------------------------------+ | st_angle(st_point(0.0, 0.0), st_point(1.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------------------------+ | 0.78547432161873854 | +----------------------------------------------------------------------+ -1 row in set (0.02 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0)); +``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0)); +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(1.0, 0.0)) | +----------------------------------------------------------------------+ | 0 | +----------------------------------------------------------------------+ -1 row in set (0.02 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 0)); +``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 0)); +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 0.0)) | +----------------------------------------------------------------------+ | NULL | +----------------------------------------------------------------------+ -1 row in set (0.03 sec) +``` -mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(-30, 0),ST_Point(150, 0)); +```sql +SELECT ST_Angle(ST_Point(0, 0),ST_Point(-30, 0),ST_Point(150, 0)); +``` + +```text +--------------------------------------------------------------------------+ | st_angle(st_point(0.0, 0.0), st_point(-30.0, 0.0), st_point(150.0, 0.0)) | +--------------------------------------------------------------------------+ | NULL | +--------------------------------------------------------------------------+ -1 row in set (0.02 sec) -``` -### keywords -ST_ANGLE,ST,ANGLE +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-area.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-area.md index 72524658fd3de..68beb924e9c2a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-area.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-area.md @@ -24,57 +24,75 @@ specific language governing permissions and limitations under the License. --> -## ST_Area_Square_Meters,ST_Area_Square_Km +## 描述 + +计算地球球面上区域的面积 -### Syntax +## 语法 ```sql -DOUBLE ST_Area_Square_Meters(GEOMETRY geo) -DOUBLE ST_Area_Square_Km(GEOMETRY geo) +ST_Area_Square_Meters( ) +ST_Area_Square_Km( ) ``` +## 参数 -## 描述 +| 参数 | 说明 | +| -- |--------| +| `` | 地球球面位置 | -计算地球球面上区域的面积,目前参数geo支持St_Point,St_LineString,St_Circle和St_Polygon。 +## 返回值 -如果输入的是St_Point,St_LineString,则返回零。 +ST_Area_Square_Meters( ) 返回的单位是平方米 -其中,ST_Area_Square_Meters(GEOMETRY geo)返回的单位是平方米,ST_Area_Square_Km(GEOMETRY geo)返回的单位是平方千米。 +ST_Area_Square_Km( ) 返回的单位是平方千米。 ## 举例 +```sql +SELECT ST_Area_Square_Meters(ST_Circle(0, 0, 1)); ``` -mysql> SELECT ST_Area_Square_Meters(ST_Circle(0, 0, 1)); + +```text +-------------------------------------------------+ | st_area_square_meters(st_circle(0.0, 0.0, 1.0)) | +-------------------------------------------------+ | 3.1415926535897869 | +-------------------------------------------------+ -1 row in set (0.04 sec) +``` + +```sql +SELECT ST_Area_Square_Km(ST_Polygon("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))")); +``` -mysql> SELECT ST_Area_Square_Km(ST_Polygon("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))")); +```text +----------------------------------------------------------------------+ | st_area_square_km(st_polygon('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))')) | +----------------------------------------------------------------------+ | 12364.036567076409 | +----------------------------------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> SELECT ST_Area_Square_Meters(ST_Point(0, 1)); +```sql +SELECT ST_Area_Square_Meters(ST_Point(0, 1)); +``` + +```text +-------------------------------------------+ | st_area_square_meters(st_point(0.0, 1.0)) | +-------------------------------------------+ | 0 | +-------------------------------------------+ -1 row in set (0.05 sec) +``` -mysql> SELECT ST_Area_Square_Meters(ST_LineFromText("LINESTRING (1 1, 2 2)")); +```sql +SELECT ST_Area_Square_Meters(ST_LineFromText("LINESTRING (1 1, 2 2)")); +``` + +```text +-----------------------------------------------------------------+ | st_area_square_meters(st_linefromtext('LINESTRING (1 1, 2 2)')) | +-----------------------------------------------------------------+ | 0 | +-----------------------------------------------------------------+ -1 row in set (0.03 sec) ``` -### keywords -ST_Area_Square_Meters,ST_Area_Square_Km,ST_Area,ST,Area + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-asbinary.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-asbinary.md index 7f3b0da7f28e4..ebb22dd79b48e 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-asbinary.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-asbinary.md @@ -24,45 +24,63 @@ specific language governing permissions and limitations under the License. --> -## ST_AsBinary - -### Syntax - -`VARCHAR ST_AsBinary(GEOMETRY geo)` - ## 描述 将一个几何图形转化为一个标准 WKB(Well-known binary)的表示形式。 目前支持对几何图形是:Point, LineString, Polygon。 +## 语法 + +```sql +ST_AsBinary( ) +``` + +## 参数 + +| 参数 | 说明 | +| -- |----------| +| `` | 需要被转换的图形 | + +## 返回值 + +该几何图形的 WKB 表示形式: + ## 举例 +```sql +select ST_AsBinary(st_point(24.7, 56.7)); ``` -mysql> select ST_AsBinary(st_point(24.7, 56.7)); + +```text +----------------------------------------------+ | st_asbinary(st_point(24.7, 56.7)) | +----------------------------------------------+ | \x01010000003333333333b338409a99999999594c40 | +----------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> select ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); +```sql +select ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); +``` + +```text +--------------------------------------------------------------------------------------+ | st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +--------------------------------------------------------------------------------------+ | \x010200000002000000000000000000f03f000000000000f03f00000000000000400000000000000040 | +--------------------------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` -mysql> select ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")); +```sql +select ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")); +``` + +```text +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')) | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | \x01030000000100000006000000f3380ce6af865c402d05a4fd0f8c364041ef8d2100865c403049658a398c3640b9fb1c1f2d865c409d9b36e334883640de921cb0ab865c40cf876709328a36402cefaa07cc865c407b319413ed8a3640f3380ce6af865c402d05a4fd0f8c3640 | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.02 sec) - ``` -### keywords -ST_ASBINARY,ST,ASBINARY + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-astext.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-astext.md index f86ba99a2846c..9346e7acf70df 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-astext.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-astext.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_AsText,ST_AsWKT ## 描述 + +将一个几何图形转化为 WKT(Well Known Text)的表示形式 + ## 语法 -`VARCHAR ST_AsText(GEOMETRY geo)` +```sql +ST_AsText( ) +``` + +# 参数 + +| 参数 | 说明 | +| -- |----------| +| `` | 待转换的几何图形 | +## 返回值 -将一个几何图形转化为WKT(Well Known Text)的表示形式 +该几何图形的 WKT 表示形式 ## 举例 +```sql +SELECT ST_AsText(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_AsText(ST_Point(24.7, 56.7)); + +```text +---------------------------------+ | st_astext(st_point(24.7, 56.7)) | +---------------------------------+ | POINT (24.7 56.7) | +---------------------------------+ ``` -### keywords -ST_ASTEXT,ST_ASWKT,ST,ASTEXT,ASWKT diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-azimuth.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-azimuth.md index c04d57a205ae3..da2a98caa76d7 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-azimuth.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-azimuth.md @@ -24,64 +24,84 @@ specific language governing permissions and limitations under the License. --> -## ST_Azimuth +## 描述 -### Syntax +输入两个点,并返回由点 1 和点 2 形成的线段的方位角。方位角是点 1 的真北方向线与点 1 和点 2 形成的线段之间的角的弧度。 -`DOUBLE ST_Azimuth(GEOPOINT point1, GEOPOINT point2)` +## 语法 -## 描述 +```sql +ST_Azimuth( , ) +``` +## 参数 -输入两个点,并返回由点 1 和点 2 形成的线段的方位角。方位角是点 1 的真北方向线与点 1 和点 2 形成的线段之间的角的弧度。 +| 参数 | 说明 | +|----------|--------------| +| `` | 用于计算方位角的第一个点 | +| `` | 用于计算方位角的第二个点 | -正角在球面上按顺时针方向测量。 例如,线段的方位角: +## 返回值 -* 指北是 0 -* 指东是 PI/2 -* 指南是 PI -* 指西是 3PI/2 +正角在球面上按顺时针方向测量。例如,线段的方位角: + +- 指北是 0 +- 指东是 PI/2 +- 指南是 PI +- 指西是 3PI/2 ST_Azimuth 存在以下边缘情况: -* 如果两个输入点相同,则返回 NULL。 -* 如果两个输入点是完全对映点,则返回 NULL。 -* 如果任一输入地理位置不是单点或为空地理位置,则会抛出错误。 +- 如果两个输入点相同,则返回 NULL。 +- 如果两个输入点是完全对映点,则返回 NULL。 +- 如果任一输入地理位置不是单点或为空地理位置,则会抛出错误。 ## 举例 +```sql +SELECT st_azimuth(ST_Point(1, 0),ST_Point(0, 0)); ``` -mysql> SELECT st_azimuth(ST_Point(1, 0),ST_Point(0, 0)); + +```text +----------------------------------------------------+ | st_azimuth(st_point(1.0, 0.0), st_point(0.0, 0.0)) | +----------------------------------------------------+ | 4.71238898038469 | +----------------------------------------------------+ -1 row in set (0.03 sec) +``` + +```sql +SELECT st_azimuth(ST_Point(0, 0),ST_Point(1, 0)); +``` -mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(1, 0)); +```text +----------------------------------------------------+ | st_azimuth(st_point(0.0, 0.0), st_point(1.0, 0.0)) | +----------------------------------------------------+ | 1.5707963267948966 | +----------------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(0, 1)); +```sql +SELECT st_azimuth(ST_Point(0, 0),ST_Point(0, 1)); +``` + +```text +----------------------------------------------------+ | st_azimuth(st_point(0.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------+ | 0 | +----------------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> SELECT st_azimuth(ST_Point(-30, 0),ST_Point(150, 0)); +```sql +SELECT st_azimuth(ST_Point(-30, 0),ST_Point(150, 0)); +``` + +```text +--------------------------------------------------------+ | st_azimuth(st_point(-30.0, 0.0), st_point(150.0, 0.0)) | +--------------------------------------------------------+ | NULL | +--------------------------------------------------------+ -1 row in set (0.02 sec) - ``` -### keywords -ST_AZIMUTH,ST,AZIMUTH + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-circle.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-circle.md index 3ce013929a449..ff8ae0d148635 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-circle.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-circle.md @@ -24,25 +24,40 @@ specific language governing permissions and limitations under the License. --> -## ST_Circle ## 描述 + +将一个 WKT(Well Known Text)转化为地球球面上的一个圆。 + ## 语法 -`GEOMETRY ST_Circle(DOUBLE center_lng, DOUBLE center_lat, DOUBLE radius)` +```sql +ST_Circle( , , ) +``` +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 圆心的经度 | +| `` | 圆心的纬度 | +| `` | 圆的半径 | +- radius 单位是米,最大支持 9999999 -将一个WKT(Well Known Text)转化为地球球面上的一个圆。其中`center_lng`表示的圆心的经度, -`center_lat`表示的是圆心的纬度,`radius`表示的是圆的半径,单位是米,最大支持9999999 +## 返回值 + +根据圆的基本信息得到的球面上的一个圆 ## 举例 +```sql +SELECT ST_AsText(ST_Circle(111, 64, 10000)); ``` -mysql> SELECT ST_AsText(ST_Circle(111, 64, 10000)); + +```text +--------------------------------------------+ | st_astext(st_circle(111.0, 64.0, 10000.0)) | +--------------------------------------------+ | CIRCLE ((111 64), 10000) | +--------------------------------------------+ ``` -### keywords -ST_CIRCLE,ST,CIRCLE + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-contains.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-contains.md index a13d683fbb3ac..f299982b3ab6e 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-contains.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-contains.md @@ -24,31 +24,51 @@ specific language governing permissions and limitations under the License. --> -## ST_Contains ## 描述 + +判断几何图形 shape1 是否完全能够包含几何图形 shape2 + ## 语法 +```sql +ST_Contains( , ) +``` + +## 参数 + +| 参数 | 说明 | +|----------|------------------------| +| `` | 传入的几何图形,用于判断是否包含 shape2 | +| `` | 传入的几何图形,用于判断是被 shape1 包含 | -`BOOL ST_Contains(GEOMETRY shape1, GEOMETRY shape2)` +## 返回值 +返回 1:shape1 图形可包含图形 shape2 + +返回 0:shape1 图形不可包含图形 shape2 -判断几何图形shape1是否完全能够包含几何图形shape2 ## 举例 +```sql +SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(5, 5)); ``` -mysql> SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(5, 5)); + +```text +----------------------------------------------------------------------------------------+ | st_contains(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'), st_point(5.0, 5.0)) | +----------------------------------------------------------------------------------------+ | 1 | +----------------------------------------------------------------------------------------+ +``` + +```sql +SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(50, 50)); +``` -mysql> SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(50, 50)); +```text +------------------------------------------------------------------------------------------+ | st_contains(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'), st_point(50.0, 50.0)) | +------------------------------------------------------------------------------------------+ | 0 | +------------------------------------------------------------------------------------------+ ``` -### keywords -ST_CONTAINS,ST,CONTAINS diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-distance-sphere.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-distance-sphere.md index 98b520c066986..a1b787cd00a83 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-distance-sphere.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-distance-sphere.md @@ -24,27 +24,40 @@ specific language governing permissions and limitations under the License. --> -## ST_Distance_Sphere ## 描述 + +计算地球两点之间的球面距离,单位为 米。传入的参数分别为 X 点的经度,X 点的纬度,Y 点的经度,Y 点的纬度。 + ## 语法 -`DOUBLE ST_Distance_Sphere(DOUBLE x_lng, DOUBLE x_lat, DOUBLE y_lng, DOUBLE y_lat)` +```sql +ST_Distance_Sphere( , , , ) +``` + +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 经度数据,合理的取值范围是 [-180, 180] | +| `` | 经度数据,合理的取值范围是 [-180, 180] | +| `` | 纬度数据,合理的取值范围是 [-90, 90] | +| `` | 纬度数据,合理的取值范围是 [-90, 90] | -计算地球两点之间的球面距离,单位为 米。传入的参数分别为X点的经度,X点的纬度,Y点的经度,Y点的纬度。 +## 返回值 -x_lng 和 y_lng 都是经度数据,合理的取值范围是 [-180, 180]。 -x_lat 和 y_lat 都是纬度数据,合理的取值范围是 [-90, 90]。 +两点之间的球面距离 ## 举例 +```sql +select st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); ``` -mysql> select st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); + +```text +----------------------------------------------------------------------------+ | st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219) | +----------------------------------------------------------------------------+ | 7336.9135549995917 | +----------------------------------------------------------------------------+ ``` -### keywords -ST_DISTANCE_SPHERE,ST,DISTANCE,SPHERE + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-geometryfromtext.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-geometryfromtext.md index 81678f1834136..ebff5294e0161 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-geometryfromtext.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-geometryfromtext.md @@ -24,24 +24,35 @@ specific language governing permissions and limitations under the License. --> -## ST_GeometryFromText,ST_GeomFromText ## 描述 + +将一个线型 WKT(Well Known Text)转化为对应的内存的几何形式 + ## 语法 -`GEOMETRY ST_GeometryFromText(VARCHAR wkt)` +```sql +ST_GeometryFromText( ) +``` +## 参数 + +| 参数 | 说明 | +|---------|---------| +| `` | 图形的内存形式 | +## 返回值 -将一个WKT(Well Known Text)转化为对应的内存的几何形式 +WKB 的对应的几何存储形式 ## 举例 +```sql +SELECT ST_AsText(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); ``` -mysql> SELECT ST_AsText(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); + +```text +---------------------------------------------------------+ | st_astext(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +---------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +---------------------------------------------------------+ -``` -### keywords -ST_GEOMETRYFROMTEXT,ST_GEOMFROMTEXT,ST,GEOMETRYFROMTEXT,GEOMFROMTEXT +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-geometryfromwkb.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-geometryfromwkb.md index 5ddf12fe985bb..9ad6400852b9c 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-geometryfromwkb.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-geometryfromwkb.md @@ -24,59 +24,83 @@ specific language governing permissions and limitations under the License. --> -## ST_GeometryFromWKB,ST_GeomFromWKB +## 描述 -### Syntax +将一个标准图形 WKB(Well-known binary)转化为对应的内存的几何形式 -`GEOMETRY ST_GeometryFromWKB(VARCHAR WKB)` +## 语法 -## 描述 +```sql +ST_GeometryFromWKB( ) +``` +## 参数 + +| 参数 | 说明 | +| -- |---------| +| `` | 图形的内存形式 | + +## 返回值 -将一个标准 WKB(Well-known binary)转化为对应的内存的几何形式 +WKB 的对应的几何存储形式 ## 举例 +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); ``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); + +```text +------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_point(24.7, 56.7)))) | +------------------------------------------------------------------+ | POINT (24.7 56.7) | +------------------------------------------------------------------+ -1 row in set (0.05 sec) +``` -mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); +```sql +select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); +``` + +```text +--------------------------------------------------------------+ | st_astext(st_geomfromwkb(st_asbinary(st_point(24.7, 56.7)))) | +--------------------------------------------------------------+ | POINT (24.7 56.7) | +--------------------------------------------------------------+ -1 row in set (0.03 sec) +``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")))); +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")))); +``` + +```text +------------------------------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')))) | +------------------------------------------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +------------------------------------------------------------------------------------------+ -1 row in set (0.06 sec) +``` + +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +```text +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) +``` + +```sql +select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +``` -mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +```text +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_astext(st_geomfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) | +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) | +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) - -``` -### keywords -ST_GEOMETRYFROMWKB,ST_GEOMFROMWKB,ST,GEOMETRYFROMWKB,GEOMFROMWKB,WKB +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-linefromtext.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-linefromtext.md index 2a41e25f2641c..74b3cba1b711c 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-linefromtext.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-linefromtext.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_LineFromText,ST_LineStringFromText ## 描述 + +将一个 WKT(Well Known Text)转化为一个 Line 形式的内存表现形式 + ## 语法 -`GEOMETRY ST_LineFromText(VARCHAR wkt)` +```sql +ST_LineFromText( ) +``` + +## 参数 +| 参数 | 说明 | +|-----|------------| +| `` | 由两个坐标组成的线段 | -将一个WKT(Well Known Text)转化为一个Line形式的内存表现形式 +## 返回值 + +线段的内存形式。 ## 举例 +```sql +SELECT ST_AsText(ST_LineFromText("LINESTRING (1 1, 2 2)")); ``` -mysql> SELECT ST_AsText(ST_LineFromText("LINESTRING (1 1, 2 2)")); + +```text +---------------------------------------------------------+ | st_astext(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +---------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +---------------------------------------------------------+ -``` -### keywords -ST_LINEFROMTEXT,ST_LINESTRINGFROMTEXT,ST,LINEFROMTEXT,LINESTRINGFROMTEXT +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-point.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-point.md index c33eb4b733648..6cd9f9676b45d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-point.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-point.md @@ -24,25 +24,38 @@ specific language governing permissions and limitations under the License. --> -## ST_Point ## 描述 + +通过给定的 X 坐标值,Y 坐标值返回对应的 Point。 + +当前这个值只是在球面集合上有意义,X/Y 对应的是经度/纬度 (longitude/latitude); + ## 语法 -`POINT ST_Point(DOUBLE x, DOUBLE y)` +```sql +ST_Point( , ) +``` +## 参数 +| 参数 | 说明 | +|-------|-----| +| `` | 横坐标 | +| `` | 纵坐标 | -通过给定的X坐标值,Y坐标值返回对应的Point。 -当前这个值只是在球面集合上有意义,X/Y对应的是经度/纬度(longitude/latitude); +## 返回值 + +给定横坐标以及纵坐标对应的位置信息 ## 举例 +```sql +SELECT ST_AsText(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_AsText(ST_Point(24.7, 56.7)); + +```text +---------------------------------+ | st_astext(st_point(24.7, 56.7)) | +---------------------------------+ | POINT (24.7 56.7) | +---------------------------------+ -``` -### keywords -ST_POINT,ST,POINT +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-polygon.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-polygon.md index bac2ef264de1e..50c9a24800fc7 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-polygon.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-polygon.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_Polygon,ST_PolyFromText,ST_PolygonFromText ## 描述 + +将一个 WKT(Well Known Text)转化为对应的多边形内存形式 + ## 语法 -`GEOMETRY ST_Polygon(VARCHAR wkt)` +```sql +ST_Polygon( ) +``` + +## 参数 +| 参数 | 说明 | +|------|--------------------| +| `` | 由 POLYGON 函数生成的一个多边形 | -将一个WKT(Well Known Text)转化为对应的多边形内存形式 +## 返回值 + +多边形的内存形式。 ## 举例 +```sql +SELECT ST_AsText(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))")); ``` -mysql> SELECT ST_AsText(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))")); + +```text +------------------------------------------------------------------+ | st_astext(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))')) | +------------------------------------------------------------------+ | POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0)) | +------------------------------------------------------------------+ -``` -### keywords -ST_POLYGON,ST_POLYFROMTEXT,ST_POLYGONFROMTEXT,ST,POLYGON,POLYFROMTEXT,POLYGONFROMTEXT +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-x.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-x.md index de572bdb3dc12..ec80338d05e14 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-x.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-x.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_X ## 描述 + +当 point 是一个合法的 POINT 类型时,返回对应的 X 坐标值 + ## 语法 -`DOUBLE ST_X(POINT point)` +```sql +ST_X( ) +``` + +## 参数 +| 参数 | 说明 | +|------|----------| +| `` | 二维点的几何坐标 | -当point是一个合法的POINT类型时,返回对应的X坐标值 +## 返回值 + +几何坐标中的 X 值 ## 举例 +```sql +SELECT ST_X(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_X(ST_Point(24.7, 56.7)); + +```text +----------------------------+ | st_x(st_point(24.7, 56.7)) | +----------------------------+ | 24.7 | +----------------------------+ -``` -### keywords -ST_X,ST,X +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-y.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-y.md index c452a7a1464e7..d1db322e49379 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-y.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-y.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_Y ## 描述 + +当 point 是一个合法的 POINT 类型时,返回对应的 Y 坐标值 + ## 语法 -`DOUBLE ST_Y(POINT point)` +```sql +ST_Y( ) +``` + +## 参数 + +| 参数 | 说明 | +|------|----------| +| `` | 二维点的几何坐标 | +## 返回值 -当point是一个合法的POINT类型时,返回对应的Y坐标值 +几何坐标中的 Y 值 ## 举例 +```sql +SELECT ST_Y(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_Y(ST_Point(24.7, 56.7)); + +```text +----------------------------+ -| st_y(st_point(24.7, 56.7)) | +| st_x(st_point(24.7, 56.7)) | +----------------------------+ -| 56.7 | +| 24.7 | +----------------------------+ ``` -### keywords -ST_Y,ST,Y diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/data-operate/import/data-source/kafka.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/data-operate/import/data-source/kafka.md index cb1b29c1a4725..091e577fa4c43 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/data-operate/import/data-source/kafka.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/data-operate/import/data-source/kafka.md @@ -191,7 +191,7 @@ Doris Kafka Connector 是将 Kafka 数据流导入 Doris 数据库的工具。 2. 配置 `config/connect-distributed.properties`: ```Bash -# 修改 broker 地址 +# 修改 kafka server 地址 bootstrap.servers=127.0.0.1:9092 # 修改 group.id,同一集群的需要一致 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/ecosystem/doris-kafka-connector.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/ecosystem/doris-kafka-connector.md index 5f2ebe3a5b0bc..70cfc40eb43f9 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/ecosystem/doris-kafka-connector.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/ecosystem/doris-kafka-connector.md @@ -99,7 +99,7 @@ $KAFKA_HOME/bin/connect-standalone.sh -daemon $KAFKA_HOME/config/connect-standal 配置 config/connect-distributed.properties ```properties -# 修改 broker 地址 +# 修改 kafka server 地址 bootstrap.servers=127.0.0.1:9092 # 修改 group.id,同一集群的需要一致 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/releasenotes/v1.1/release-1.1.0.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/releasenotes/v1.1/release-1.1.0.md index 0e4f3961e3c31..ff11843f2b632 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/releasenotes/v1.1/release-1.1.0.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/releasenotes/v1.1/release-1.1.0.md @@ -89,11 +89,11 @@ Iceberg 外部表为 Apache Doris 提供了直接访问存储在 Iceberg 数据 - 在 TPC-H 测试数据集的全部 22 个 SQL 上,1.1 版本均优于 0.15 版本,整体性能约提升了 4.5 倍,部分场景性能达到了十余倍的提升; -![](/images/release-note-1.1.0-SSB.png) +![release-note-1.1.0-SSB](/images/release-note-1.1.0-SSB.png)

SSB 测试数据集

-![](/images/release-note-1.1.0-TPC-H.png) +![release-note-1.1.0-TPC-H](/images/release-note-1.1.0-TPC-H.png)

TPC-H 测试数据集

diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/group-concat.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/group-concat.md index 0fd25a72e2dba..ff40fa49751ff 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/group-concat.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/group-concat.md @@ -24,25 +24,37 @@ specific language governing permissions and limitations under the License. --> -## group_concat + ## 描述 + +GROUP_CONCAT 函数将结果集中的多行结果连接成一个字符串 + ## 语法 -`VARCHAR GROUP_CONCAT([DISTINCT] VARCHAR str[, VARCHAR sep] [ORDER BY { col_name | expr} [ASC | DESC]])` +```sql +GROUP_CONCAT([DISTINCT] [, ] [ORDER BY { | } [ASC | DESC]]) +``` +## 参数 -该函数是类似于 sum() 的聚合函数,group_concat 将结果集中的多行结果连接成一个字符串。第二个参数 sep 为字符串之间的连接符号,该参数可以省略。该函数通常需要和 group by 语句一起使用。 +| 参数 | 说明 | +| -- | -- | +| `` | 必选。需要连接值的表达式 | +| `` | 可选。字符串之间的连接符号 | +| `` | 可选。用于指定排序的列 | +| `` | 可选。用于指定排序的表达式 | -支持Order By进行多行结果的排序,排序和聚合列可不同。 +## 返回值 -:::caution -`group_concat`暂不支持`distinct`和`order by`一起用。 -::: +返回 VARCHAR 类型的数值。 ## 举例 +```sql +select value from test; ``` -mysql> select value from test; + +```text +-------+ | value | +-------+ @@ -51,35 +63,52 @@ mysql> select value from test; | c | | c | +-------+ +``` + +```sql +select GROUP_CONCAT(value) from test; +``` -mysql> select GROUP_CONCAT(value) from test; +```text +-----------------------+ | GROUP_CONCAT(`value`) | +-----------------------+ -| a, b, c, c | +| a, b, c, c | +-----------------------+ +``` -mysql> select GROUP_CONCAT(DISTINCT value) from test; +```sql +select GROUP_CONCAT(DISTINCT value) from test; +``` + +```text +-----------------------+ | GROUP_CONCAT(`value`) | +-----------------------+ | a, b, c | +-----------------------+ +``` + +```sql +select GROUP_CONCAT(value, " ") from test; +``` -mysql> select GROUP_CONCAT(value, " ") from test; +```text +----------------------------+ | GROUP_CONCAT(`value`, ' ') | +----------------------------+ | a b c c | +----------------------------+ +``` + +```sql +select GROUP_CONCAT(value, NULL) from test; +``` -mysql> select GROUP_CONCAT(value, NULL) from test; +```text +----------------------------+ | GROUP_CONCAT(`value`, NULL)| +----------------------------+ | NULL | +----------------------------+ ``` - -### keywords -GROUP_CONCAT,GROUP,CONCAT diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/histogram.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/histogram.md index e02ef61b695e6..6a7303152c8ee 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/histogram.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/histogram.md @@ -24,31 +24,53 @@ specific language governing permissions and limitations under the License. --> -## HISTOGRAM + ## 描述 + +HISTOGRAM(直方图)函数用于描述数据分布情况,它使用“等高”的分桶策略,并按照数据的值大小进行分桶,并用一些简单的数据来描述每个桶,比如落在桶里的值的个数。 + +## 别名 + +HIST + ## 语法 -`histogram(expr[, INT num_buckets])` +```sql +HISTOGRAM([, ]) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `expr` | 需要获取第一个值的表达式 | +| `num_buckets` | 可选。用于限制直方图桶(bucket)的数量,默认值 128 | -histogram(直方图)函数用于描述数据分布情况,它使用“等高”的分桶策略,并按照数据的值大小进行分桶,并用一些简单的数据来描述每个桶,比如落在桶里的值的个数。主要用于优化器进行区间查询的估算。 -函数结果返回空或者 Json 字符串。 +## 返回值 -参数说明: -- num_buckets:可选项。用于限制直方图桶(bucket)的数量,默认值 128。 +返回直方图估算后的 JSON 类型的值。特殊情况: +- 当参数为NULL时,返回 NULL。 -别名函数:`hist(expr[, INT num_buckets])` ## 举例 +```sql +SELECT histogram(c_float) FROM histogram_test; ``` -MySQL [test]> SELECT histogram(c_float) FROM histogram_test; + +```text +-------------------------------------------------------------------------------------------------------------------------------------+ | histogram(`c_float`) | +-------------------------------------------------------------------------------------------------------------------------------------+ | {"num_buckets":3,"buckets":[{"lower":"0.1","upper":"0.1","count":1,"pre_sum":0,"ndv":1},...]} | +-------------------------------------------------------------------------------------------------------------------------------------+ +``` + +```sql +SELECT histogram(c_string, 2) FROM histogram_test; +``` -MySQL [test]> SELECT histogram(c_string, 2) FROM histogram_test; +```text +-------------------------------------------------------------------------------------------------------------------------------------+ | histogram(`c_string`) | +-------------------------------------------------------------------------------------------------------------------------------------+ @@ -58,7 +80,7 @@ MySQL [test]> SELECT histogram(c_string, 2) FROM histogram_test; 查询结果说明: -``` +```json { "num_buckets": 3, "buckets": [ @@ -87,6 +109,7 @@ MySQL [test]> SELECT histogram(c_string, 2) FROM histogram_test; } ``` +```text 字段说明: - num_buckets:桶的数量 - buckets:直方图所包含的桶 @@ -97,7 +120,4 @@ MySQL [test]> SELECT histogram(c_string, 2) FROM histogram_test; - ndv:桶内不同值的个数 > 直方图总的元素数量 = 最后一个桶的元素数量(count)+ 前面桶的元素总量(pre_sum)。 - -### keywords - -HISTOGRAM, HIST +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md index 1826b413075ec..2d06c5a0f2d5b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md @@ -24,29 +24,36 @@ specific language governing permissions and limitations under the License. --> -## HLL_UNION_AGG ## 描述 -## 语法 -`HLL_UNION_AGG(hll)` +HLL_UNION_AGG 函数是一种聚合函数,主要用于将多个 HyperLogLog 数据结构合并,估算合并后基数的近似值。 + + +## 语法 +```sql +hll_union_agg() +``` -HLL是基于HyperLogLog算法的工程实现,用于保存HyperLogLog计算过程的中间结果 +## 参数 -它只能作为表的value列类型、通过聚合来不断的减少数据量,以此来实现加快查询的目的 +| 参数 | 说明 | +| -- | -- | +| `` | 需要被计算HyperLogLog类型表达式 | -基于它得到的是一个估算结果,误差大概在1%左右,hll列是通过其它列或者导入数据里面的数据生成的 +## 返回值 -导入的时候通过hll_hash函数来指定数据中哪一列用于生成hll列,它常用于替代count distinct,通过结合rollup在业务上用于快速计算uv等 +返回 BIGINT 类型的基数值。 ## 举例 +```sql +select HLL_UNION_AGG(uv_set) from test_uv; ``` -MySQL > select HLL_UNION_AGG(uv_set) from test_uv;; + +```text +-------------------------+ | HLL_UNION_AGG(`uv_set`) | +-------------------------+ | 17721 | +-------------------------+ ``` -### keywords -HLL_UNION_AGG,HLL,UNION,AGG diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/intersect-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/intersect-count.md index 5d3b8b939f532..c054e126f6dda 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/intersect-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/intersect-count.md @@ -22,35 +22,52 @@ specific language governing permissions and limitations under the License. --> -## intersect_count + ## 描述 + +INTERSECT_COUNT 函数用于计算 Bitmap 数据结构的交集元素的数量。 + ## 语法 -`BITMAP INTERSECT_COUNT(bitmap_column, column_to_filter, filter_values)` -聚合函数,求bitmap交集大小的函数, 不要求数据分布正交 -第一个参数是Bitmap列,第二个参数是用来过滤的维度列,第三个参数是变长参数,含义是过滤维度列的不同取值 +```sql +INTERSECT_COUNT(, , ) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 需要获取第一个值的表达式 | +| `` | 可选。需要进行过滤的维度列 | +| `` | 可选。过滤维度列的不同取值 | + +## 返回值 + +返回 BIGINT 类型的值。 ## 举例 +```sql +select dt,bitmap_to_string(user_id) from pv_bitmap where dt in (3,4); ``` -MySQL [test_query_qa]> select dt,bitmap_to_string(user_id) from pv_bitmap where dt in (3,4); + +```text +------+-----------------------------+ | dt | bitmap_to_string(`user_id`) | +------+-----------------------------+ -| 4 | 1,2,3 | -| 3 | 1,2,3,4,5 | +| 4 | 1,2,3 | +| 3 | 1,2,3,4,5 | +------+-----------------------------+ -2 rows in set (0.012 sec) +``` -MySQL [test_query_qa]> select intersect_count(user_id,dt,3,4) from pv_bitmap; +```sql +select intersect_count(user_id,dt,3,4) from pv_bitmap; +``` + +```text +----------------------------------------+ | intersect_count(`user_id`, `dt`, 3, 4) | +----------------------------------------+ | 3 | +----------------------------------------+ -1 row in set (0.014 sec) ``` - -### keywords - - INTERSECT_COUNT,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/map-agg.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/map-agg.md index 8327da387592b..a5ce0daf7d28f 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/map-agg.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/map-agg.md @@ -24,17 +24,32 @@ specific language governing permissions and limitations under the License. --> -## MAP_AGG ## 描述 + +MAP_AGG 函数用于根据多行数据中的键值对形成一个映射结构。 + ## 语法 -`MAP_AGG(expr1, expr2)` +`MAP_AGG(, )` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `` | 用于指定作为键的表达式。 | +| `` | 用于指定作为对应的值的表达式。 | -返回一个 map, 由 expr1 作为键,expr2 作为对应的值。 +## 返回值 + +返回映射后的 MAP 类型的值。 ## 举例 + +```sql +select `n_nationkey`, `n_name`, `n_regionkey` from `nation`; ``` -MySQL > select `n_nationkey`, `n_name`, `n_regionkey` from `nation`; + +```text +-------------+----------------+-------------+ | n_nationkey | n_name | n_regionkey | +-------------+----------------+-------------+ @@ -64,8 +79,13 @@ MySQL > select `n_nationkey`, `n_name`, `n_regionkey` from `nation`; | 23 | UNITED KINGDOM | 3 | | 24 | UNITED STATES | 1 | +-------------+----------------+-------------+ +``` + +```sql +select `n_regionkey`, map_agg(`n_nationkey`, `n_name`) from `nation` group by `n_regionkey`; +``` -MySQL > select `n_regionkey`, map_agg(`n_nationkey`, `n_name`) from `nation` group by `n_regionkey`; +```text +-------------+---------------------------------------------------------------------------+ | n_regionkey | map_agg(`n_nationkey`, `n_name`) | +-------------+---------------------------------------------------------------------------+ @@ -75,8 +95,13 @@ MySQL > select `n_regionkey`, map_agg(`n_nationkey`, `n_name`) from `nation` gro | 4 | {4:"EGYPT", 10:"IRAN", 11:"IRAQ", 13:"JORDAN", 20:"SAUDI ARABIA"} | | 2 | {8:"INDIA", 9:"INDONESIA", 12:"JAPAN", 18:"CHINA", 21:"VIETNAM"} | +-------------+---------------------------------------------------------------------------+ +``` + +```sql +select n_regionkey, map_agg(`n_name`, `n_nationkey` % 5) from `nation` group by `n_regionkey`; +``` -MySQL > select n_regionkey, map_agg(`n_name`, `n_nationkey` % 5) from `nation` group by `n_regionkey`; +```text +-------------+------------------------------------------------------------------------+ | n_regionkey | map_agg(`n_name`, (`n_nationkey` % 5)) | +-------------+------------------------------------------------------------------------+ @@ -87,5 +112,3 @@ MySQL > select n_regionkey, map_agg(`n_name`, `n_nationkey` % 5) from `nation` g | 4 | {"EGYPT":4, "IRAN":0, "IRAQ":1, "JORDAN":3, "SAUDI ARABIA":0} | +-------------+------------------------------------------------------------------------+ ``` -### keywords -MAP_AGG diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/max-by.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/max-by.md index 7c412ebfc0449..41bfcd7756d81 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/max-by.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/max-by.md @@ -24,18 +24,35 @@ specific language governing permissions and limitations under the License. --> -## MAX_BY + ## 描述 + +MAX_BY 函数用于根据指定列的最大值,返回对应的的关联值。 + ## 语法 -`MAX_BY(expr1, expr2)` +```sql +MAX_BY(, ) +``` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `` | 用于指定对应关联的表达式。 | +| `` | 用于指定最大值统计的表达式。 | +## 返回值 -返回与 expr2 的最大值关联的 expr1 的值。 +返回与输入表达式 相同的数据类型。 ## 举例 + +```sql +select * from tbl; ``` -MySQL > select * from tbl; + +```text +------+------+------+------+ | k1 | k2 | k3 | k4 | +------+------+------+------+ @@ -44,13 +61,16 @@ MySQL > select * from tbl; | 4 | 3 | 2 | 1 | | 3 | 4 | 2 | 1 | +------+------+------+------+ +``` + +```sql +select max_by(k1, k4) from tbl; +``` -MySQL > select max_by(k1, k4) from tbl; +```text +--------------------+ | max_by(`k1`, `k4`) | +--------------------+ | 0 | +--------------------+ ``` -### keywords -MAX_BY diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/max.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/max.md index 16bdd21bfd58b..ecf254d4c524e 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/max.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/max.md @@ -24,23 +24,37 @@ specific language governing permissions and limitations under the License. --> -## MAX + ## 描述 + +MAX 函数返回表达式的最大值。 + ## 语法 -`MAX(expr)` +```sql +MAX() +``` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `expr` | 需要获取值的表达式 | +## 返回值 -返回expr表达式的最大值 +返回与输入表达式相同的数据类型。 ## 举例 + +```sql +select max(scan_rows) from log_statis group by datetime; ``` -MySQL > select max(scan_rows) from log_statis group by datetime; + +```text +------------------+ | max(`scan_rows`) | +------------------+ | 4671587 | +------------------+ ``` -### keywords -MAX diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/min-by.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/min-by.md index eceeb6427307f..3ccfa4f885696 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/min-by.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/min-by.md @@ -24,18 +24,34 @@ specific language governing permissions and limitations under the License. --> -## MIN_BY + ## 描述 + +MIN_BY 函数用于根据指定列的最小值,返回对应的的关联值。 + ## 语法 -`MIN_BY(expr1, expr2)` +```sql +MIN_BY(, ) +``` + +## 参数说明 +| 参数 | 说明 | +| -- | -- | +| `` | 用于指定对应关联的表达式。 | +| `` | 用于指定最小值统计的表达式。 | -返回与 expr2 的最小值关联的 expr1 的值。 +## 返回值 + +返回与输入表达式 相同的数据类型。 ## 举例 +```sql +select * from tbl; ``` -MySQL > select * from tbl; + +```text +------+------+------+------+ | k1 | k2 | k3 | k4 | +------+------+------+------+ @@ -44,13 +60,16 @@ MySQL > select * from tbl; | 4 | 3 | 2 | 1 | | 3 | 4 | 2 | 1 | +------+------+------+------+ +``` + +```sql +select min_by(k1, k4) from tbl; +``` -MySQL > select min_by(k1, k4) from tbl; +```text +--------------------+ | min_by(`k1`, `k4`) | +--------------------+ | 4 | +--------------------+ ``` -### keywords -MIN_BY diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/min.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/min.md index b765ab423683b..d4392753fe612 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/min.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/min.md @@ -24,23 +24,36 @@ specific language governing permissions and limitations under the License. --> -## MIN ## 描述 + +MIN 函数返回表达式的最小值。 + ## 语法 -`MIN(expr)` +```sql +MIN(expr) +``` + +## 参数说明 +| 参数 | 说明 | +| -- | -- | +| `expr` | 需要获取值的表达式 | -返回expr表达式的最小值 +## 返回值 + +返回与输入表达式相同的数据类型。 ## 举例 + +```sql +select MIN(scan_rows) from log_statis group by datetime; ``` -MySQL > select min(scan_rows) from log_statis group by datetime; + +```text +------------------+ -| min(`scan_rows`) | +| MIN(`scan_rows`) | +------------------+ | 0 | +------------------+ ``` -### keywords -MIN diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md index 4e3ae39dbbee3..27b5ea423724a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md @@ -1,7 +1,7 @@ --- { -"title": "ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT", -"language": "zh-CN" + "title": "ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT", + "language": "zh-CN" } --- @@ -13,7 +13,9 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -22,19 +24,40 @@ specific language governing permissions and limitations under the License. --> -## orthogonal_bitmap_expr_calculate_count ## 描述 + +ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT 函数返回对 Bitmap 表达式进行交并差计算后集合中的元素数量 + ## 语法 -`BITMAP ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT(bitmap_column, column_to_filter, input_string)` -求表达式bitmap交并差集合计算count函数, 第一个参数是Bitmap列,第二个参数是用来过滤的维度列,即计算的key列,第三个参数是计算表达式字符串,含义是依据key列进行bitmap交并差集表达式计算 -表达式支持的计算符:& 代表交集计算,| 代表并集计算,- 代表差集计算, ^ 代表异或计算,\ 代表转义字符 +```sql +ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT(, , ) +``` -## 举例 +## 参数说明 +| 参数 | 说明 | +| -- | -- | +| `bitmap_column` | 需要获取值的 Bitmap 类型表达式 | +| `column_to_filter` | 过滤的维度列,即计算的 Key 列 | +| `input_string` | 计算表达式字符串,含义是依据 Key 列进行 Bitmap 交并差集表达式计算,表达式支持的计算符:& 代表交集计算,\| 代表并集计算,- 代表差集计算, ^ 代表异或计算,\ 代表转义字符 | + +## 返回值 + +返回 BIGINT 类型的值。 + +## 举例 ```sql select orthogonal_bitmap_expr_calculate_count(user_id, tag, '(833736|999777)&(1308083|231207)&(1000|20000-30000)') from user_tag_bitmap where tag in (833736,999777,130808,231207,1000,20000,30000); -注:1000、20000、30000等整形tag,代表用户不同标签 +注:1000、20000、30000 等整形tag,代表用户不同标签 +``` + +```text ++-----------------------------------------------------------------------------------------------------------------+ +| orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(833736|999777)&(1308083|231207)&(1000|20000-30000)') | ++-----------------------------------------------------------------------------------------------------------------+ +| 1000 | ++-----------------------------------------------------------------------------------------------------------------+ ``` ```sql @@ -42,6 +65,10 @@ select orthogonal_bitmap_expr_calculate_count(user_id, tag, '(A:a/b|B:2\\-4)&(C: 注:'A:a/b', 'B:2-4'等是字符串类型tag,代表用户不同标签, 其中'B:2-4'需要转义成'B:2\\-4' ``` -### keywords - - ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT,BITMAP +```text ++---------------------------------------------------------------------------------------------+ +| orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23') | ++---------------------------------------------------------------------------------------------+ +| 30 | ++---------------------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md index e7405e82e79f4..f3b457bf09e51 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md @@ -1,7 +1,7 @@ --- { -"title": "ORTHOGONAL_BITMAP_EXPR_CALCULATE", -"language": "zh-CN" + "title": "ORTHOGONAL_BITMAP_EXPR_CALCULATE", + "language": "zh-CN" } --- @@ -13,7 +13,9 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -22,26 +24,51 @@ specific language governing permissions and limitations under the License. --> -## orthogonal_bitmap_expr_calculate ## 描述 + +ORTHOGONAL_BITMAP_EXPR_CALCULATE 函数返回对 Bitmap 表达式进行交并差计算后的集合 + ## 语法 -`BITMAP ORTHOGONAL_BITMAP_EXPR_CALCULATE(bitmap_column, column_to_filter, input_string)` -求表达式bitmap交并差集合计算函数, 第一个参数是Bitmap列,第二个参数是用来过滤的维度列,即计算的key列,第三个参数是计算表达式字符串,含义是依据key列进行bitmap交并差集表达式计算 -表达式支持的计算符:& 代表交集计算,| 代表并集计算,- 代表差集计算, ^ 代表异或计算,\ 代表转义字符 +```sql +ORTHOGONAL_BITMAP_EXPR_CALCULATE(, , ) +``` -## 举例 +## 参数说明 +| 参数 | 说明 | +| -- | -- | +| `bitmap_column` | 需要获取值的 Bitmap 类型表达式 | +| `column_to_filter` | 过滤的维度列,即计算的 Key 列 | +| `input_string` | 计算表达式字符串,含义是依据 Key 列进行 Bitmap 交并差集表达式计算,表达式支持的计算符:& 代表交集计算,\| 代表并集计算,- 代表差集计算, ^ 代表异或计算,\ 代表转义字符 | + +## 返回值 + +返回 BITMAP 类型的集合。 + +## 举例 ```sql -select orthogonal_bitmap_expr_calculate(user_id, tag, '(833736|999777)&(1308083|231207)&(1000|20000-30000)') from user_tag_bitmap where tag in (833736,999777,130808,231207,1000,20000,30000); +select bitmap_count(orthogonal_bitmap_expr_calculate(user_id, tag, '(833736|999777)&(1308083|231207)&(1000|20000-30000)')) from user_tag_bitmap where tag in (833736,999777,130808,231207,1000,20000,30000); 注:1000、20000、30000等整形tag,代表用户不同标签 ``` +```text ++-------------------------------------------------------------------------------------------------------------------------------+ +| bitmap_count(orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(833736|999777)&(1308083|231207)&(1000|20000-30000)')) | ++-------------------------------------------------------------------------------------------------------------------------------+ +| 1000 | ++-------------------------------------------------------------------------------------------------------------------------------+ +``` + ```sql -select orthogonal_bitmap_expr_calculate(user_id, tag, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23') from user_str_tag_bitmap where tag in ('A:a/b', 'B:2-4', 'C:1', 'D:12', 'E:23'); +select bitmap_count(orthogonal_bitmap_expr_calculate(user_id, tag, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23')) from user_str_tag_bitmap where tag in ('A:a/b', 'B:2-4', 'C:1', 'D:12', 'E:23'); 注:'A:a/b', 'B:2-4'等是字符串类型tag,代表用户不同标签, 其中'B:2-4'需要转义成'B:2\\-4' ``` -### keywords - - ORTHOGONAL_BITMAP_EXPR_CALCULATE,BITMAP +```text ++-----------------------------------------------------------------------------------------------------------+ +| bitmap_count(orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23')) | ++-----------------------------------------------------------------------------------------------------------+ +| 30 | ++-----------------------------------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md index 7eebc3aa700bc..fac7fbfeb7c9b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md @@ -1,7 +1,7 @@ --- { -"title": "ORTHOGONAL_BITMAP_INTERSECT_COUNT", -"language": "zh-CN" + "title": "ORTHOGONAL_BITMAP_INTERSECT_COUNT", + "language": "zh-CN" } --- @@ -13,7 +13,9 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -21,26 +23,39 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - -## orthogonal_bitmap_intersect_count ## 描述 + +ORTHOGONAL_BITMAP_INTERSECT_COUNT 函数返回对 Bitmap 表达式进行交集计算后集合中的元素数量 + ## 语法 -`BITMAP ORTHOGONAL_BITMAP_INTERSECT_COUNT(bitmap_column, column_to_filter, filter_values)` -求bitmap交集大小的函数, 第一个参数是Bitmap列,第二个参数是用来过滤的维度列,第三个参数是变长参数,含义是过滤维度列的不同取值 +```sql +ORTHOGONAL_BITMAP_INTERSECT_COUNT(, , ) +``` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `bitmap_column` | 需要获取值的 Bitmap 类型表达式 | +| `column_to_filter` | 可选。需要进行过滤的维度列 | +| `filter_values` | 可选。变长参数,用于过滤维度列的不同取值 | + + +## 返回值 + +返回 BIGINT 类型的值。 ## 举例 +```sql +select orthogonal_bitmap_intersect_count(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); ``` -mysql> select orthogonal_bitmap_intersect_count(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); + +```text +-------------------------------------------------------------------------------------+ | orthogonal_bitmap_intersect_count(`members`, `tag_group`, 1150000, 1150001, 390006) | +-------------------------------------------------------------------------------------+ | 0 | +-------------------------------------------------------------------------------------+ -1 row in set (3.382 sec) -``` - -### keywords - - ORTHOGONAL_BITMAP_INTERSECT_COUNT,BITMAP +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md index e6b65df82d2e8..2460c03a4a600 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md @@ -1,7 +1,7 @@ --- { -"title": "ORTHOGONAL_BITMAP_INTERSECT", -"language": "zh-CN" + "title": "ORTHOGONAL_BITMAP_INTERSECT", + "language": "zh-CN" } --- @@ -13,7 +13,9 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -21,27 +23,39 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - -## orthogonal_bitmap_intersect ## 描述 + +ORTHOGONAL_BITMAP_INTERSECT 函数返回对 Bitmap 表达式进行交集集合 + ## 语法 -`BITMAP ORTHOGONAL_BITMAP_INTERSECT(bitmap_column, column_to_filter, filter_values)` -求bitmap交集函数, 第一个参数是Bitmap列,第二个参数是用来过滤的维度列,第三个参数是变长参数,含义是过滤维度列的不同取值 +```sql +ORTHOGONAL_BITMAP_INTERSECT(, , ) +``` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `bitmap_column` | 需要获取值的 Bitmap 类型表达式 | +| `column_to_filter` | 可选。需要进行过滤的维度列 | +| `filter_values` | 可选。变长参数,用于过滤维度列的不同取值 | + +## 返回值 + +返回 BITMAP 类型的集合。 ## 举例 +```sql +select orthogonal_bitmap_intersect(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); + ``` -mysql> select orthogonal_bitmap_intersect(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); + +```text +-------------------------------------------------------------------------------+ | orthogonal_bitmap_intersect(`members`, `tag_group`, 1150000, 1150001, 390006) | +-------------------------------------------------------------------------------+ | NULL | +-------------------------------------------------------------------------------+ -1 row in set (3.505 sec) - -``` - -### keywords - - ORTHOGONAL_BITMAP_INTERSECT,BITMAP +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md index 2131b91d7419b..2460c03a4a600 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md @@ -1,7 +1,7 @@ --- { -"title": "ORTHOGONAL_BITMAP_UNION_COUNT", -"language": "zh-CN" + "title": "ORTHOGONAL_BITMAP_INTERSECT", + "language": "zh-CN" } --- @@ -13,7 +13,9 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -21,27 +23,39 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - -## orthogonal_bitmap_union_count ## 描述 + +ORTHOGONAL_BITMAP_INTERSECT 函数返回对 Bitmap 表达式进行交集集合 + ## 语法 -`BITMAP ORTHOGONAL_BITMAP_UNION_COUNT(bitmap_column, column_to_filter, filter_values)` -求bitmap并集大小的函数, 参数类型是bitmap,是待求并集count的列 +```sql +ORTHOGONAL_BITMAP_INTERSECT(, , ) +``` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `bitmap_column` | 需要获取值的 Bitmap 类型表达式 | +| `column_to_filter` | 可选。需要进行过滤的维度列 | +| `filter_values` | 可选。变长参数,用于过滤维度列的不同取值 | + +## 返回值 +返回 BITMAP 类型的集合。 ## 举例 -``` -mysql> select orthogonal_bitmap_union_count(members) from tag_map where tag_group in ( 1150000, 1150001, 390006); -+------------------------------------------+ -| orthogonal_bitmap_union_count(`members`) | -+------------------------------------------+ -| 286957811 | -+------------------------------------------+ -1 row in set (2.645 sec) -``` +```sql +select orthogonal_bitmap_intersect(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); -### keywords +``` - ORTHOGONAL_BITMAP_UNION_COUNT,BITMAP +```text ++-------------------------------------------------------------------------------+ +| orthogonal_bitmap_intersect(`members`, `tag_group`, 1150000, 1150001, 390006) | ++-------------------------------------------------------------------------------+ +| NULL | ++-------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile-approx.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile-approx.md index 573dbcf572bea..091f30c0729b4 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile-approx.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile-approx.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,36 +22,72 @@ specific language governing permissions and limitations under the License. --> -## PERCENTILE_APPROX ## 描述 + +`PERCENTILE_APPROX` 函数用于计算近似百分位数,主要用于大数据集的场景。与 `PERCENTILE` 函数相比,它具有以下特点: + +1. 内存效率:使用固定大小的内存,即使在处理高基数列(数据量很大)时也能保持较低的内存消耗 +2. 性能优势:适合处理大规模数据集,计算速度快 +3. 精度可调:通过 compression 参数可以在精度和性能之间做平衡 + ## 语法 -`PERCENTILE_APPROX(expr, DOUBLE p[, DOUBLE compression])` +```sql +PERCENTILE_APPROX(,

[, ]) +``` +## 参数 -返回第p个百分位点的近似值,p的值介于0到1之间 +| 参数 | 说明 | +| -- | -- | +| `` | 需要计算百分位数的列 | +| `

` | 百分位数值,取值范围 `[0.0, 1.0]`,例如 `0.99` 表示 `99` 分位数 | +| `` | 可选参数,压缩度,取值范围 `[2048, 10000]`。值越大,精度越高,但内存消耗也越大。如果不指定或超出范围,则使用 `10000`。 | -compression参数是可选项,可设置范围是[2048, 10000],值越大,精度越高,内存消耗越大,计算耗时越长。 -compression参数未指定或设置的值在[2048, 10000]范围外,以10000的默认值运行 +## 返回值 -该函数使用固定大小的内存,因此对于高基数的列可以使用更少的内存,可用于计算tp99等统计值 +返回一个 `DOUBLE` 类型的值,表示计算得到的近似百分位数。 ## 举例 + +```sql +-- 创建示例表 +CREATE TABLE response_times ( + request_id INT, + response_time DECIMAL(10, 2) +) DUPLICATE KEY(`request_id`) +DISTRIBUTED BY HASH(`request_id`) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- 插入示例数据 +INSERT INTO response_times VALUES +(1, 10.5), +(2, 15.2), +(3, 20.1), +(4, 25.8), +(5, 30.3), +(6, 35.7), +(7, 40.2), +(8, 45.9), +(9, 50.4), +(10, 100.6); + +-- 使用不同压缩度计算 99 分位数 +SELECT + percentile_approx(response_time, 0.99) as p99_default, -- 默认压缩度 + percentile_approx(response_time, 0.99, 2048) as p99_fast, -- 低压缩度,更快 + percentile_approx(response_time, 0.99, 10000) as p99_accurate -- 高压缩度,更精确 +FROM response_times; ``` -MySQL > select `table`, percentile_approx(cost_time,0.99) from log_statis group by `table`; -+---------------------+---------------------------+ -| table | percentile_approx(`cost_time`, 0.99) | -+----------+--------------------------------------+ -| test | 54.22 | -+----------+--------------------------------------+ - -MySQL > select `table`, percentile_approx(cost_time,0.99, 4096) from log_statis group by `table`; -+---------------------+---------------------------+ -| table | percentile_approx(`cost_time`, 0.99, 4096.0) | -+----------+--------------------------------------+ -| test | 54.21 | -+----------+--------------------------------------+ + +```text ++-------------------+-------------------+-------------------+ +| p99_default | p99_fast | p99_accurate | ++-------------------+-------------------+-------------------+ +| 100.5999984741211 | 100.5999984741211 | 100.5999984741211 | ++-------------------+-------------------+-------------------+ ``` -### keywords -PERCENTILE_APPROX,PERCENTILE,APPROX + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile-array.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile-array.md index 9f33f295d7c1c..4a141e5157457 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile-array.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile-array.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,29 +22,67 @@ specific language governing permissions and limitations under the License. --> -## PERCENTILE_ARRAY ## 描述 + +`PERCENTILE_ARRAY` 函数用于计算精确的百分位数数组,允许一次性计算多个百分位数值。这个函数主要适用于小数据量。 + +主要特点: +1. 精确计算:提供精确的百分位数结果,而不是近似值 +2. 批量处理:可以一次计算多个百分位数 +3. 适用范围:最适合处理数据量较小的场景 + ## 语法 -`ARRAY_DOUBLE PERCENTILE_ARRAY(expr, ARRAY_DOUBLE p)` +```sql +PERCENTILE_ARRAY(, ) +``` + +## 参数 -计算精确的百分位数,适用于小数据量。先对指定列降序排列,然后取精确的第 p 位百分数。 -返回值为依次取数组p中指定的百分数组成的结果。 -参数说明: -expr: 必填。值为整数(最大为bigint) 类型的列。 -p: 需要精确的百分位数, 由常量组成的数组, 取值为 [0.0,1.0]。 +| 参数 | 说明 | +| -- | -- | +| `` | 需要计算百分位数的列 | +| `` | 百分位数数组,数组中的每个元素必须在 `[0.0, 1.0]` 范围内,例如 `[0.5, 0.95, 0.99]` | + +## 返回值 + +返回一个 `DOUBLE` 类型的数组,包含了对应于输入百分位数数组的计算结果。 ## 举例 -``` -mysql> select percentile_array(k1,[0.3,0.5,0.9]) from baseall; -+----------------------------------------------+ -| percentile_array(`k1`, ARRAY(0.3, 0.5, 0.9)) | -+----------------------------------------------+ -| [5.2, 8, 13.6] | -+----------------------------------------------+ -1 row in set (0.02 sec) +```sql +-- 创建示例表 +CREATE TABLE sales_data ( + id INT, + amount DECIMAL(10, 2) +) DUPLICATE KEY(`id`) +DISTRIBUTED BY HASH(`id`) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- 插入示例数据 +INSERT INTO sales_data VALUES +(1, 10.5), +(2, 15.2), +(3, 20.1), +(4, 25.8), +(5, 30.3), +(6, 35.7), +(7, 40.2), +(8, 45.9), +(9, 50.4), +(10, 100.6); + +-- 计算多个百分位数 +SELECT percentile_array(amount, [0.25, 0.5, 0.75, 0.9]) as percentiles +FROM sales_data; ``` -### keywords -PERCENTILE_ARRAY +```text ++-----------------------------------------+ +| percentiles | ++-----------------------------------------+ +| [21.25, 32.5, 43.75, 54.99999999999998] | ++-----------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md deleted file mode 100755 index 07857cfe22ea4..0000000000000 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -{ - "title": "PERCENTILE_APPROX_WEIGHTED", - "language": "zh-CN" -} ---- - - - -## PERCENTILE_APPROX_WEIGHTED -## 描述 -## 语法 - -`PERCENTILE_APPROX_WEIGHTED(expr, w ,DOUBLE p [, DOUBLE compression])` - - -该函数和 PERCENTILE_APPROX 类似,唯一的区别是多了一个参数 w,用来表示 expr 出现的次数。 -注意参数 W 的取值需要大于0,如果计算过程中某一行的取值小于等于0时,则会跳过当前行。 - -## 举例 -``` -mysql >select * from quantile_weighted_table order by k; -+------+------+ -| k | w | -+------+------+ -| 1 | 2 | -| 3 | 1 | -| 5 | 2 | -+------+------+ - - -mysql >select percentile_approx_weighted(k,w,0.55) from quantile_weighted_table; -+----------------------------------------------------------------------------------------+ -| percentile_approx_weighted(cast(k as DOUBLE), cast(w as DOUBLE), cast(0.55 as DOUBLE)) | -+----------------------------------------------------------------------------------------+ -| 3.3333332538604736 | -+----------------------------------------------------------------------------------------+ - -``` - -### keywords -PERCENTILE_APPROX,PERCENTILE,APPROX,PERCENTILE_APPROX_WEIGHTED diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/quantile-union.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/quantile-union.md index 6bb8e3e6d5265..4c899d578b3c1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/quantile-union.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/quantile-union.md @@ -1,6 +1,6 @@ --- { - "title": "quantile_union", + "title": "QUANTILE_UNION", "language": "zh-CN" } --- @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -23,3 +21,73 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## 描述 + +`QUANTILE_UNION` 函数用于合并多个分位数计算的中间结果。这个函数通常与 `QUANTILE_STATE` 配合使用,特别适用于需要分阶段计算分位数的场景。 + +## 语法 + +```sql +QUANTILE_UNION() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 由 `TO_QUANTILE_STATE` 函数生成的中间状态 | + +## 返回值 + +返回一个可以用于进一步分位数计算的聚合状态。此函数返回的结果仍是 `QUANTILE_STATE`。 + +## 举例 + +```sql +-- 创建示例表 +CREATE TABLE response_times ( + request_id INT, + response_time DOUBLE, + region STRING +) DUPLICATE KEY(request_id) +DISTRIBUTED BY HASH(request_id) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- 插入示例数据 +INSERT INTO response_times VALUES +(1, 10.5, 'east'), +(2, 15.2, 'east'), +(3, 20.1, 'west'), +(4, 25.8, 'east'), +(5, 30.3, 'west'), +(6, 35.7, 'east'), +(7, 40.2, 'west'), +(8, 45.9, 'east'), +(9, 50.4, 'west'), +(10, 100.6, 'east'); + +-- 按区域计算响应时间的50%分位数 +SELECT + region, + QUANTILE_PERCENT( + QUANTILE_UNION( + TO_QUANTILE_STATE(response_time, 2048) + ), + 0.5 + ) AS median_response_time +FROM response_times +GROUP BY region; + +``` + +```text ++--------+----------------------+ +| region | median_response_time | ++--------+----------------------+ +| west | 35.25 | +| east | 30.75 | ++--------+----------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/retention.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/retention.md index d23fb985ec208..6f6be9a736e8a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/retention.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/retention.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,118 +22,73 @@ specific language governing permissions and limitations under the License. --> -## RETENTION - -RETENTION - ## 描述 -## 语法 - -`retention(event1, event2, ... , eventN);` -留存函数将一组条件作为参数,类型为1到32个`UInt8`类型的参数,用来表示事件是否满足特定条件。 任何条件都可以指定为参数. +留存函数将一组条件作为参数,类型为1到32个`UInt8`类型的参数,用来表示事件是否满足特定条件。 任何条件都可以指定为参数。 除了第一个以外,条件成对适用:如果第一个和第二个是真的,第二个结果将是真的,如果第一个和第三个是真的,第三个结果将是真的,等等。 -简单来讲,返回值数组第1位表示`event1`的真假,第二位表示`event1`真假与`event2`真假相与,第三位表示`event1`真假与`event3`真假相与,等等。如果`event1`为假,则返回全是0的数组。 +简单来讲,返回值数组第1位表示`event_1`的真假,第二位表示`event_1`真假与`event_2`真假相与,第三位表示`event_1`真假与`event_3`真假相与,等等。如果`event_1`为假,则返回全是0的数组。 + +## 语法 + +```sql +RETENTION( [, , ... , ]); +``` ## 参数 -`event` — 返回`UInt8`结果(1或0)的表达式. +| 参数 | 说明 | +| -- | -- | +| `` | 第`n`个事件条件,类型为`UInt8`,取值为1或0 | ## 返回值 由1和0组成的最大长度为32位的数组,最终输出数组的长度与输入参数长度相同。 -1 — 条件满足。 +- 1: 条件满足。 -0 — 条件不满足 +- 0: 条件不满足。 ## 举例 ```sql -DROP TABLE IF EXISTS retention_test; - +-- 创建示例表 CREATE TABLE retention_test( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( - "replication_num" = "1" -); - -INSERT into retention_test (uid, date) values (0, '2022-10-12'), - (0, '2022-10-13'), - (0, '2022-10-14'), - (1, '2022-10-12'), - (1, '2022-10-13'), - (2, '2022-10-12'); - -SELECT * from retention_test; - -+------+---------------------+ -| uid | date | -+------+---------------------+ -| 0 | 2022-10-14 00:00:00 | -| 0 | 2022-10-13 00:00:00 | -| 0 | 2022-10-12 00:00:00 | -| 1 | 2022-10-13 00:00:00 | -| 1 | 2022-10-12 00:00:00 | -| 2 | 2022-10-12 00:00:00 | -+------+---------------------+ - -SELECT - uid, - retention(date = '2022-10-12') - AS r - FROM retention_test - GROUP BY uid - ORDER BY uid ASC; - -+------+------+ -| uid | r | -+------+------+ -| 0 | [1] | -| 1 | [1] | -| 2 | [1] | -+------+------+ - + "replication_allocation" = "tag.location.default: 1" +); + +-- 插入示例数据 +INSERT into retention_test values +(0, '2022-10-12'), +(0, '2022-10-13'), +(0, '2022-10-14'), +(1, '2022-10-12'), +(1, '2022-10-13'), +(2, '2022-10-12'); + +-- 计算用户留存 SELECT uid, - retention(date = '2022-10-12', date = '2022-10-13') - AS r - FROM retention_test - GROUP BY uid - ORDER BY uid ASC; - -+------+--------+ -| uid | r | -+------+--------+ -| 0 | [1, 1] | -| 1 | [1, 1] | -| 2 | [1, 0] | -+------+--------+ - -SELECT - uid, - retention(date = '2022-10-12', date = '2022-10-13', date = '2022-10-14') - AS r - FROM retention_test - GROUP BY uid - ORDER BY uid ASC; - -+------+-----------+ -| uid | r | -+------+-----------+ -| 0 | [1, 1, 1] | -| 1 | [1, 1, 0] | -| 2 | [1, 0, 0] | -+------+-----------+ - + RETENTION(date = '2022-10-12') AS r, + RETENTION(date = '2022-10-12', date = '2022-10-13') AS r2, + RETENTION(date = '2022-10-12', date = '2022-10-13', date = '2022-10-14') AS r3 +FROM retention_test +GROUP BY uid +ORDER BY uid ASC; ``` -### keywords - -RETENTION +```text ++------+------+--------+-----------+ +| uid | r | r2 | r3 | ++------+------+--------+-----------+ +| 0 | [1] | [1, 1] | [1, 1, 1] | +| 1 | [1] | [1, 1] | [1, 1, 0] | +| 2 | [1] | [1, 0] | [1, 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/aggregate-functions/sequence-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sequence-count.md index b2e312eb6f7c6..dff1be7e0b230 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sequence-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sequence-count.md @@ -22,11 +22,7 @@ specific language governing permissions and limitations under the License. --> -## SEQUENCE-COUNT ## 描述 -## 语法 - -`sequence_count(pattern, timestamp, cond1, cond2, ...);` 计算与模式匹配的事件链的数量。该函数搜索不重叠的事件链。当前链匹配后,它开始搜索下一个链。 @@ -34,23 +30,29 @@ under the License. 在同一秒钟发生的事件可能以未定义的顺序排列在序列中,会影响最终结果。 -## 参数 +## 语法 -`pattern` — 模式字符串. +```sql +SEQUENCE_COUNT(, , [, , ..., ]); +``` -**模式语法** +## 参数 -`(?N)` — 在位置N匹配条件参数。 条件在编号 `[1, 32]` 范围。 例如, `(?1)` 匹配传递给 `cond1` 参数。 +| 参数 | 说明 | +| -- | -- | +| `` | 模式字符串,可参考下面的**模式语法** | +| `` | 包含时间的列。典型的时间类型是: `Date` 和 `DateTime`。也可以使用任何支持的 `UInt` 数据类型。 | +| `` | 事件链的约束条件。 数据类型是: `UInt8`。 最多可以传递32个条件参数。 该函数只考虑这些条件中描述的事件。 如果序列包含未在条件中描述的数据,则函数将跳过这些数据 | -`.*` — 匹配任何事件的数字。 不需要条件参数来匹配这个模式。 +**模式语法** -`(?t operator value)` — 分开两个事件的时间。 单位为秒。 +- `(?N)` — 在位置N匹配条件参数。 条件在编号 `[1, 32]` 范围。 例如, `(?1)` 匹配传递给 `cond_1` 参数。 -`t`表示为两个时间的差值,单位为秒。 例如: `(?1)(?t>1800)(?2)` 匹配彼此发生超过1800秒的事件, `(?1)(?t>10000)(?2)`匹配彼此发生超过10000秒的事件。 这些事件之间可以存在任意数量的任何事件。 您可以使用 `>=`, `>`, `<`, `<=`, `==` 运算符。 +- `.*` — 匹配任何事件的数字。 不需要条件参数来匹配这个模式。 -`timestamp` — 包含时间的列。典型的时间类型是: `Date` 和 `DateTime`。也可以使用任何支持的 `UInt` 数据类型。 +- `(?t operator value)` — 分开两个事件的时间。 单位为秒。 -`cond1`, `cond2` — 事件链的约束条件。 数据类型是: `UInt8`。 最多可以传递32个条件参数。 该函数只考虑这些条件中描述的事件。 如果序列包含未在条件中描述的数据,则函数将跳过这些数据。 +- `t`表示为两个时间的差值,单位为秒。 例如: `(?1)(?t>1800)(?2)` 匹配彼此发生超过1800秒的事件, `(?1)(?t>10000)(?2)`匹配彼此发生超过10000秒的事件。 这些事件之间可以存在任意数量的任何事件。 您可以使用 `>=`, `>`, `<`, `<=`, `==` 运算符。 ## 返回值 @@ -61,161 +63,106 @@ under the License. **匹配例子** ```sql -DROP TABLE IF EXISTS sequence_count_test1; - +-- 创建示例表 CREATE TABLE sequence_count_test1( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_count_test1(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 13:28:02', 2), - (3, '2022-11-02 16:15:01', 1), - (4, '2022-11-02 19:05:04', 2), - (5, '2022-11-02 20:08:44', 3); - -SELECT * FROM sequence_count_test1 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 13:28:02 | 2 | -| 3 | 2022-11-02 16:15:01 | 1 | -| 4 | 2022-11-02 19:05:04 | 2 | -| 5 | 2022-11-02 20:08:44 | 3 | -+------+---------------------+--------+ - -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 3) FROM sequence_count_test1; - -+----------------------------------------------------------------+ -| sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 3) | -+----------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 2) FROM sequence_count_test1; - -+----------------------------------------------------------------+ -| sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 2 | -+----------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) FROM sequence_count_test1; +-- 插入示例数据 +INSERT INTO sequence_count_test1(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 13:28:02', 2), +(3, '2022-11-02 16:15:01', 1), +(4, '2022-11-02 19:05:04', 2), +(5, '2022-11-02 20:08:44', 3); + +-- 查询示例 +SELECT + SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 3) as c1, + SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 2) as c2, + SEQUENCE_COUNT('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) as c3 +FROM sequence_count_test1; +``` -+---------------------------------------------------------------------------+ -| sequence_count('(?1)(?t>=3600)(?2)', `date`, `number` = 1, `number` = 2) | -+---------------------------------------------------------------------------+ -| 2 | -+---------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 1 | 2 | 2 | ++------+------+------+ ``` **不匹配例子** ```sql -DROP TABLE IF EXISTS sequence_count_test2; - +-- 创建示例表 CREATE TABLE sequence_count_test2( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_count_test2(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_count_test2 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ - -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 2) FROM sequence_count_test2; - -+----------------------------------------------------------------+ -| sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 0 | -+----------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?2).*', date, number = 1, number = 2) FROM sequence_count_test2; - -+------------------------------------------------------------------+ -| sequence_count('(?1)(?2).*', `date`, `number` = 1, `number` = 2) | -+------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?t>3600)(?2)', date, number = 1, number = 7) FROM sequence_count_test2; +-- 插入示例数据 +INSERT INTO sequence_count_test2(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); + +-- 查询示例 +SELECT + SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 2) as c1, + SEQUENCE_COUNT('(?1)(?2).*', date, number = 1, number = 2) as c2, + SEQUENCE_COUNT('(?1)(?t>3600)(?2)', date, number = 1, number = 7) as c3 +FROM sequence_count_test2; +``` -+--------------------------------------------------------------------------+ -| sequence_count('(?1)(?t>3600)(?2)', `date`, `number` = 1, `number` = 7) | -+--------------------------------------------------------------------------+ -| 0 | -+--------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 0 | 0 | 0 | ++------+------+------+ ``` **特殊例子** ```sql -DROP TABLE IF EXISTS sequence_count_test3; - +-- 创建示例表 CREATE TABLE sequence_count_test3( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_count_test3(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_count_test3 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ -``` - -Perform the query: +-- 插入示例数据 +INSERT INTO sequence_count_test3(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); -```sql -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5) FROM sequence_count_test3; +-- 查询示例 +SELECT SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 5) FROM sequence_count_test3; +``` +```text +----------------------------------------------------------------+ | sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 5) | +----------------------------------------------------------------+ @@ -228,8 +175,10 @@ SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5) FROM sequence_co 现在,考虑如下执行语句: ```sql -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM sequence_count_test3; +SELECT SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM sequence_count_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 4) | +------------------------------------------------------------------------------+ @@ -240,15 +189,13 @@ SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM 您可能对这个结果有些许疑惑,在这种情况下,函数找不到与模式匹配的事件链,因为数字4的事件发生在1和5之间。 如果在相同的情况下,我们检查了数字6的条件,则序列将与模式匹配。 ```sql -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5, number = 6) FROM sequence_count_test3; +SELECT SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 5, number = 6) FROM sequence_count_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 6) | +------------------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------------------+ ``` - -### keywords - -SEQUENCE_COUNT \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sequence-match.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sequence-match.md index c07318fc990e1..7491cd0fcfa73 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sequence-match.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sequence-match.md @@ -22,11 +22,7 @@ specific language governing permissions and limitations under the License. --> -## SEQUENCE-MATCH ## 描述 -## 语法 - -`sequence_match(pattern, timestamp, cond1, cond2, ...);` 检查序列是否包含与模式匹配的事件链。 @@ -34,190 +30,135 @@ under the License. 在同一秒钟发生的事件可能以未定义的顺序排列在序列中,会影响最终结果。 +## 语法 +```sql +SEQUENCE_MATCH(, , [, , ..., ]) +``` + ## 参数 -`pattern` — 模式字符串. +| 参数 | 说明 | +| -- | -- | +| `` | 模式字符串,可参考下面的**模式语法** | +| `` | 包含时间的列。典型的时间类型是: `Date` 和 `DateTime`。也可以使用任何支持的 `UInt` 数据类型。 | +| `` | 事件链的约束条件。 数据类型是: `UInt8`。最多可以传递32个条件参数。该函数只考虑这些条件中描述的事件。如果序列包含未在条件中描述的数据,则函数将跳过这些数据。 | -**模式语法** -`(?N)` — 在位置N匹配条件参数。 条件在编号 `[1, 32]` 范围。 例如, `(?1)` 匹配传递给 `cond1` 参数。 +**模式语法** -`.*` — 匹配任何事件的数字。 不需要条件参数来匹配这个模式。 +- `(?N)` — 在位置N匹配条件参数。 条件在编号 `[1, 32]` 范围。 例如, `(?1)` 匹配传递给 `cond1` 参数。 -`(?t operator value)` — 分开两个事件的时间。 单位为秒。 +- `.*` — 匹配任何事件的数字。 不需要条件参数来匹配这个模式。 -`t`表示为两个时间的差值,单位为秒。 例如: `(?1)(?t>1800)(?2)` 匹配彼此发生超过1800秒的事件, `(?1)(?t>10000)(?2)`匹配彼此发生超过10000秒的事件。 这些事件之间可以存在任意数量的任何事件。 您可以使用 `>=`, `>`, `<`, `<=`, `==` 运算符。 +- `(?t operator value)` — 分开两个事件的时间。 单位为秒。 -`timestamp` — 包含时间的列。典型的时间类型是: `Date` 和 `DateTime`。也可以使用任何支持的 `UInt` 数据类型。 +- `t`表示为两个时间的差值,单位为秒。 例如: `(?1)(?t>1800)(?2)` 匹配彼此发生超过1800秒的事件, `(?1)(?t>10000)(?2)`匹配彼此发生超过10000秒的事件。 这些事件之间可以存在任意数量的任何事件。 您可以使用 `>=`, `>`, `<`, `<=`, `==` 运算符。 -`cond1`, `cond2` — 事件链的约束条件。 数据类型是: `UInt8`。 最多可以传递32个条件参数。 该函数只考虑这些条件中描述的事件。 如果序列包含未在条件中描述的数据,则函数将跳过这些数据。 ## 返回值 -1,如果模式匹配。 +1:模式匹配。 -0,如果模式不匹配。 +0:模式不匹配。 ## 举例 **匹配例子** ```sql -DROP TABLE IF EXISTS sequence_match_test1; - CREATE TABLE sequence_match_test1( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_match_test1(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 13:28:02', 2), - (3, '2022-11-02 16:15:01', 1), - (4, '2022-11-02 19:05:04', 2), - (5, '2022-11-02 20:08:44', 3); - -SELECT * FROM sequence_match_test1 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 13:28:02 | 2 | -| 3 | 2022-11-02 16:15:01 | 1 | -| 4 | 2022-11-02 19:05:04 | 2 | -| 5 | 2022-11-02 20:08:44 | 3 | -+------+---------------------+--------+ +INSERT INTO sequence_match_test1(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 13:28:02', 2), +(3, '2022-11-02 16:15:01', 1), +(4, '2022-11-02 19:05:04', 2), +(5, '2022-11-02 20:08:44', 3); -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 3) FROM sequence_match_test1; - -+----------------------------------------------------------------+ -| sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 3) | -+----------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 2) FROM sequence_match_test1; - -+----------------------------------------------------------------+ -| sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------+ -SELECT sequence_match('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) FROM sequence_match_test1; +SELECT +sequence_match('(?1)(?2)', date, number = 1, number = 3) as c1, +sequence_match('(?1)(?2)', date, number = 1, number = 2) as c2, +sequence_match('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) as c3 +FROM sequence_match_test1; +``` -+---------------------------------------------------------------------------+ -| sequence_match('(?1)(?t>=3600)(?2)', `date`, `number` = 1, `number` = 2) | -+---------------------------------------------------------------------------+ -| 1 | -+---------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 1 | 1 | 1 | ++------+------+------+ ``` **不匹配例子** ```sql -DROP TABLE IF EXISTS sequence_match_test2; - CREATE TABLE sequence_match_test2( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_match_test2(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_match_test2 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ - -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 2) FROM sequence_match_test2; - -+----------------------------------------------------------------+ -| sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 0 | -+----------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?2).*', date, number = 1, number = 2) FROM sequence_match_test2; - -+------------------------------------------------------------------+ -| sequence_match('(?1)(?2).*', `date`, `number` = 1, `number` = 2) | -+------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?t>3600)(?2)', date, number = 1, number = 7) FROM sequence_match_test2; +INSERT INTO sequence_match_test2(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); + +SELECT +sequence_match('(?1)(?2)', date, number = 1, number = 2) as c1, +sequence_match('(?1)(?2).*', date, number = 1, number = 2) as c2, +sequence_match('(?1)(?t>3600)(?2)', date, number = 1, number = 7) as c3 +FROM sequence_match_test2; +``` -+--------------------------------------------------------------------------+ -| sequence_match('(?1)(?t>3600)(?2)', `date`, `number` = 1, `number` = 7) | -+--------------------------------------------------------------------------+ -| 0 | -+--------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 0 | 0 | 0 | ++------+------+------+ ``` **特殊例子** ```sql -DROP TABLE IF EXISTS sequence_match_test3; - CREATE TABLE sequence_match_test3( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_match_test3(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_match_test3 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ -``` - -Perform the query: +INSERT INTO sequence_match_test3(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); -```sql -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5) FROM sequence_match_test3; +SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5) +FROM sequence_match_test3; +``` +```text +----------------------------------------------------------------+ | sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 5) | +----------------------------------------------------------------+ @@ -230,8 +171,11 @@ SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5) FROM sequence_ma 现在,考虑如下执行语句: ```sql -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM sequence_match_test3; +SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 4) +FROM sequence_match_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 4) | +------------------------------------------------------------------------------+ @@ -242,15 +186,14 @@ SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM 您可能对这个结果有些许疑惑,在这种情况下,函数找不到与模式匹配的事件链,因为数字4的事件发生在1和5之间。 如果在相同的情况下,我们检查了数字6的条件,则序列将与模式匹配。 ```sql -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 6) FROM sequence_match_test3; +SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 6) +FROM sequence_match_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 6) | +------------------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------------------+ ``` - -### keywords - -SEQUENCE_MATCH \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/stddev-samp.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/stddev-samp.md index 104ce066a6bb3..e71d23be26f9b 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/stddev-samp.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/stddev-samp.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,23 +22,54 @@ specific language governing permissions and limitations under the License. --> -## STDDEV_SAMP ## 描述 + +返回expr表达式的样本标准差 + ## 语法 -`STDDEV_SAMP(expr)` +```sql +STDDEV_SAMP() +``` + +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 需要被计算标准差的值 | -返回expr表达式的样本标准差 +## 返回值 + +返回参数 expr 的样本标准差 ## 举例 +```sql +-- 创建示例表 +CREATE TABLE score_table ( + student_id INT, + score DOUBLE +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO score_table VALUES +(1, 85), +(2, 90), +(3, 82), +(4, 88), +(5, 95); + +-- 计算所有学生分数的样本标准差 +SELECT STDDEV_SAMP(score) as score_stddev +FROM score_table; ``` -MySQL > select stddev_samp(scan_rows) from log_statis group by datetime; -+--------------------------+ -| stddev_samp(`scan_rows`) | -+--------------------------+ -| 2.372044195280762 | -+--------------------------+ + +```text ++-------------------+ +| score_stddev | ++-------------------+ +| 4.949747468305831 | ++-------------------+ ``` -### keywords -STDDEV_SAMP,STDDEV,SAMP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/stddev.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/stddev.md index 85803054ba7a1..47778ec9dde5f 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/stddev.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/stddev.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,30 +22,58 @@ specific language governing permissions and limitations under the License. --> -## STDDEV,STDDEV_POP ## 描述 + +返回 expr 表达式的标准差 + +## 别名 + +- STDDEV_POP + ## 语法 -`STDDEV(expr)` +```sql +STDDEV() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 需要被计算标准差的值 | +## 返回值 -返回expr表达式的标准差 +返回参数 expr 的标准差 ## 举例 +```sql +-- 创建示例表 +CREATE TABLE score_table ( + student_id INT, + score DOUBLE +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO score_table VALUES +(1, 85), +(2, 90), +(3, 82), +(4, 88), +(5, 95); + +-- 计算所有学生分数的标准差 +SELECT STDDEV(score) as score_stddev +FROM score_table; ``` -MySQL > select stddev(scan_rows) from log_statis group by datetime; -+---------------------+ -| stddev(`scan_rows`) | -+---------------------+ -| 2.3736656687790934 | -+---------------------+ - -MySQL > select stddev_pop(scan_rows) from log_statis group by datetime; -+-------------------------+ -| stddev_pop(`scan_rows`) | -+-------------------------+ -| 2.3722760595994914 | -+-------------------------+ + +```text ++-------------------+ +| score_stddev | ++-------------------+ +| 4.427188724235729 | ++-------------------+ ``` -### keywords -STDDEV,STDDEV_POP,POP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sum.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sum.md index f97b3ae225f73..20023c95ec7f7 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sum.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sum.md @@ -24,23 +24,55 @@ specific language governing permissions and limitations under the License. --> -## SUM ## 描述 + +用于返回选中字段所有值的和。 + ## 语法 -`SUM(expr)` +```sql +SUM() +``` + +## 参数 +| 参数 | 说明 | +| --- | --- | +| `` | 要计算和的字段 | -用于返回选中字段所有值的和 +## 返回值 + +返回选中字段所有值的和。 ## 举例 +```sql +-- 创建示例表 +CREATE TABLE sales_table ( + product_id INT, + price DECIMAL(10,2), + quantity INT +) DISTRIBUTED BY HASH(product_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO sales_table VALUES +(1, 99.99, 2), +(2, 159.99, 1), +(3, 49.99, 5), +(4, 299.99, 1), +(5, 79.99, 3); + +-- 计算销售总金额 +SELECT SUM(price * quantity) as total_sales +FROM sales_table; ``` -MySQL > select sum(scan_rows) from log_statis group by datetime; -+------------------+ -| sum(`scan_rows`) | -+------------------+ -| 8217360135 | -+------------------+ + +```text ++-------------+ +| total_sales | ++-------------+ +| 1149.88 | ++-------------+ ``` -### keywords -SUM diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sum0.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sum0.md index 691d8808adb7a..51abed020e4b1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sum0.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sum0.md @@ -1,7 +1,6 @@ --- { - "title": "sum0 - ", + "title": "SUM0", "language": "zh-CN" } --- @@ -24,3 +23,60 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## 描述 + +用于返回选中字段所有值的和。与 SUM 函数不同的是,当输入值全为 NULL 时,SUM0 返回 0 而不是 NULL。 + +## 语法 + +```sql +SUM0() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 要计算和的字段 | + +## 返回值 + +返回选中字段所有值的和。如果所有值都为 NULL,则返回 0。 + +## 举例 + +```sql +-- 创建示例表 +CREATE TABLE sales_table ( + product_id INT, + price DECIMAL(10,2), + quantity INT, + discount DECIMAL(10,2) +) DISTRIBUTED BY HASH(product_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO sales_table VALUES +(1, 99.99, 2, NULL), +(2, 159.99, 1, NULL), +(3, 49.99, 5, NULL), +(4, 299.99, 1, NULL), +(5, 79.99, 3, NULL); + +-- 对比 SUM 和 SUM0 的区别 +SELECT + SUM(discount) as sum_discount, -- 返回 NULL + SUM0(discount) as sum0_discount -- 返回 0 +FROM sales_table; +``` + +```text ++--------------+---------------+ +| sum_discount | sum0_discount | ++--------------+---------------+ +| NULL | 0.00 | ++--------------+---------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn-array.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn-array.md index d97028c5bf6c5..88aafaa85d4ff 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn-array.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn-array.md @@ -24,37 +24,58 @@ specific language governing permissions and limitations under the License. --> -## TOPN_ARRAY ## 描述 -## 语法 -`ARRAY topn_array(expr, INT top_num[, INT space_expand_rate])` +TOPN_ARRAY 函数返回指定列中出现频率最高的 N 个值的数组。与 TOPN 函数不同,TOPN_ARRAY 返回一个数组类型,便于后续处理和分析。 -该topn_array函数使用Space-Saving算法计算expr中的top_num个频繁项,返回由前top_num个组成的数组,该结果为近似值 +## 语法 -space_expand_rate参数是可选项,该值用来设置Space-Saving算法中使用的counter个数 +```sql +TOPN_ARRAY(, [, ]) ``` -counter numbers = top_num * space_expand_rate -``` -space_expand_rate的值越大,结果越准确,默认值为50 + +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 要统计的列或表达式 | +| `` | 要返回的最高频率值的数量,必须是正整数 | +| `` | 可选项,该值用来设置 Space-Saving 算法中使用的 counter 个数`counter_numbers = top_num * space_expand_rate` space_expand_rate 的值越大,结果越准确,默认值为50 | + +## 返回值 +返回一个数组,包含出现频率最高的 N 个值。 ## 举例 +```sql +-- 创建示例表 +CREATE TABLE page_visits ( + page_id INT, + user_id INT, + visit_date DATE +) DISTRIBUTED BY HASH(page_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO page_visits VALUES +(1, 101, '2024-01-01'), +(2, 102, '2024-01-01'), +(1, 103, '2024-01-01'), +(3, 101, '2024-01-01'), +(1, 104, '2024-01-01'), +(2, 105, '2024-01-01'), +(1, 106, '2024-01-01'), +(4, 107, '2024-01-01'); + +-- 查找访问量最高的前3个页面 +SELECT TOPN_ARRAY(page_id, 3) as top_pages +FROM page_visits; ``` -mysql> select topn_array(k3,3) from baseall; -+--------------------------+ -| topn_array(`k3`, 3) | -+--------------------------+ -| [3021, 2147483647, 5014] | -+--------------------------+ -1 row in set (0.02 sec) - -mysql> select topn_array(k3,3,100) from baseall; -+--------------------------+ -| topn_array(`k3`, 3, 100) | -+--------------------------+ -| [3021, 2147483647, 5014] | -+--------------------------+ -1 row in set (0.02 sec) + +```text ++-----------+ +| top_pages | ++-----------+ +| [1, 2, 4] | ++-----------+ ``` -### keywords -TOPN, TOPN_ARRAY diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn-weighted.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn-weighted.md index abd13f58138a9..87d8bddcd25b1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn-weighted.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn-weighted.md @@ -24,37 +24,60 @@ specific language governing permissions and limitations under the License. --> -## TOPN_WEIGHTED ## 描述 -## 语法 -`ARRAY topn_weighted(expr, BigInt weight, INT top_num[, INT space_expand_rate])` +TOPN_WEIGHTED 函数返回指定列中出现频率最高的 N 个值,并且可以为每个值指定权重。与普通的 TOPN 函数不同,TOPN_WEIGHTED 允许通过权重来调整值的重要性。 -该topn_weighted函数使用Space-Saving算法计算,取expr中权重和为前top_num个数组成的结果,该结果为近似值 +## 语法 -space_expand_rate参数是可选项,该值用来设置Space-Saving算法中使用的counter个数 -``` -counter numbers = top_num * space_expand_rate +```sql +TOPN_WEIGHTED(, , [, ]) ``` -space_expand_rate的值越大,结果越准确,默认值为50 + +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 要统计的列或表达式 | +| `` | 用于调整权重的列或表达式 | +| `` | 要返回的最高频率值的数量,必须是正整数 | +| `` | 可选项,该值用来设置 Space-Saving 算法中使用的 counter 个数`counter_numbers = top_num * space_expand_rate` space_expand_rate 的值越大,结果越准确,默认值为50 | + +## 返回值 + +返回一个数组,包含值和对应的加权计数。 ## 举例 +```sql +-- 创建示例表 +CREATE TABLE product_sales ( + product_id INT, + sale_amount DECIMAL(10,2), + sale_date DATE +) DISTRIBUTED BY HASH(product_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO product_sales VALUES +(1, 100.00, '2024-01-01'), +(2, 50.00, '2024-01-01'), +(1, 150.00, '2024-01-01'), +(3, 75.00, '2024-01-01'), +(1, 200.00, '2024-01-01'), +(2, 80.00, '2024-01-01'), +(1, 120.00, '2024-01-01'), +(4, 90.00, '2024-01-01'); + +-- 查找销售额最高的前3个产品(按销售金额加权) +SELECT TOPN_WEIGHTED(product_id, sale_amount, 3) as top_products +FROM product_sales; ``` -mysql> select topn_weighted(k5,k1,3) from baseall; -+------------------------------+ -| topn_weighted(`k5`, `k1`, 3) | -+------------------------------+ -| [0, 243.325, 100.001] | -+------------------------------+ -1 row in set (0.02 sec) - -mysql> select topn_weighted(k5,k1,3,100) from baseall; -+-----------------------------------+ -| topn_weighted(`k5`, `k1`, 3, 100) | -+-----------------------------------+ -| [0, 243.325, 100.001] | -+-----------------------------------+ -1 row in set (0.02 sec) + +```text ++--------------+ +| top_products | ++--------------+ +| [1, 2, 4] | ++--------------+ ``` -### keywords -TOPN, TOPN_WEIGHTED diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn.md index 649222139a656..9b75f9b83acae 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn.md @@ -24,37 +24,58 @@ specific language governing permissions and limitations under the License. --> -## TOPN ## 描述 -## 语法 -`topn(expr, INT top_num[, INT space_expand_rate])` +TOPN 函数用于返回指定列中出现频率最高的 N 个值。它是一个近似计算函数,返回结果的顺序是按照计数值从大到小排序。 -该topn函数使用Space-Saving算法计算expr中的top_num个频繁项,结果为频繁项及其出现次数,该结果为近似值 +## 语法 -space_expand_rate参数是可选项,该值用来设置Space-Saving算法中使用的counter个数 -``` -counter numbers = top_num * space_expand_rate +```sql +TOPN(, [, ]) ``` -space_expand_rate的值越大,结果越准确,默认值为50 + +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 要统计的列或表达式 | +| `` | 要返回的最高频率值的数量,必须是正整数 | +| `` | 可选项,该值用来设置 Space-Saving 算法中使用的 counter 个数`counter_numbers = top_num * space_expand_rate` space_expand_rate 的值越大,结果越准确,默认值为50 | + +## 返回值 +返回一个 JSON 字符串,包含值和对应的出现次数。 ## 举例 +```sql +-- 创建示例表 +CREATE TABLE page_visits ( + page_id INT, + user_id INT, + visit_date DATE +) DISTRIBUTED BY HASH(page_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO page_visits VALUES +(1, 101, '2024-01-01'), +(2, 102, '2024-01-01'), +(1, 103, '2024-01-01'), +(3, 101, '2024-01-01'), +(1, 104, '2024-01-01'), +(2, 105, '2024-01-01'), +(1, 106, '2024-01-01'), +(4, 107, '2024-01-01'); + +-- 查找访问量最高的前3个页面 +SELECT TOPN(page_id, 3) as top_pages +FROM page_visits; ``` -MySQL [test]> select topn(keyword,10) from keyword_table where date>= '2020-06-01' and date <= '2020-06-19' ; -+------------------------------------------------------------------------------------------------------------+ -| topn(`keyword`, 10) | -+------------------------------------------------------------------------------------------------------------+ -| a:157, b:138, c:133, d:133, e:131, f:127, g:124, h:122, i:117, k:117 | -+------------------------------------------------------------------------------------------------------------+ - -MySQL [test]> select date,topn(keyword,10,100) from keyword_table where date>= '2020-06-17' and date <= '2020-06-19' group by date; -+------------+-----------------------------------------------------------------------------------------------+ -| date | topn(`keyword`, 10, 100) | -+------------+-----------------------------------------------------------------------------------------------+ -| 2020-06-19 | a:11, b:8, c:8, d:7, e:7, f:7, g:7, h:7, i:7, j:7 | -| 2020-06-18 | a:10, b:8, c:7, f:7, g:7, i:7, k:7, l:7, m:6, d:6 | -| 2020-06-17 | a:9, b:8, c:8, j:8, d:7, e:7, f:7, h:7, i:7, k:7 | -+------------+-----------------------------------------------------------------------------------------------+ -``` -### keywords -TOPN + +```text ++---------------------+ +| top_pages | ++---------------------+ +| {"1":4,"2":2,"4":1} | ++---------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/var-samp.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/var-samp.md index b563f95e59e27..06154cb8343c4 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/var-samp.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/var-samp.md @@ -24,24 +24,62 @@ specific language governing permissions and limitations under the License. --> -## VAR_SAMP,VARIANCE_SAMP ## 描述 + +VAR_SAMP 函数计算指定表达式的样本方差。与 VARIANCE(总体方差)不同,VAR_SAMP 使用 n-1 作为除数,这在统计学上被认为是对总体方差的无偏估计。 + +## 别名 + +- VARIANCE_SAMP + ## 语法 -`VAR_SAMP(expr)` +```sql +VAR_SAMP() +``` + +## 参数 +| 参数 | 描述 | +| -- | -- | +| `` | 要计算样本方差的列或表达式 | -返回expr表达式的样本方差 +## 返回值 +返回一个 DOUBLE 类型的值,表示计算得到的样本方差。 ## 举例 -``` -MySQL > select var_samp(scan_rows) from log_statis group by datetime; -+-----------------------+ -| var_samp(`scan_rows`) | -+-----------------------+ -| 5.6227132145741789 | -+-----------------------+ +```sql +-- 创建示例表 +CREATE TABLE student_scores ( + student_id INT, + score DECIMAL(4,1) +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO student_scores VALUES +(1, 85.5), +(2, 92.0), +(3, 78.5), +(4, 88.0), +(5, 95.5), +(6, 82.0), +(7, 90.0), +(8, 87.5); + +-- 计算学生成绩的样本方差 +SELECT + VAR_SAMP(score) as sample_variance, + VARIANCE(score) as population_variance +FROM student_scores; ``` -### keywords -VAR_SAMP,VARIANCE_SAMP,VAR,SAMP,VARIANCE +```text ++------------------+---------------------+ +| sample_variance | population_variance | ++------------------+---------------------+ +| 29.4107142857143 | 25.73437500000001 | ++------------------+---------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/variance.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/variance.md index 019582b0822a7..b873857e02e54 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/variance.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/variance.md @@ -24,31 +24,59 @@ specific language governing permissions and limitations under the License. --> -## VARIANCE,VAR_POP,VARIANCE_POP ## 描述 + +VARIANCE 函数计算指定表达式的统计方差。它衡量了数据值与其算术平均值之间的差异程度。 + +## 别名 + +- VAR_POP +- VARIANCE_POP + ## 语法 -`VARIANCE(expr)` +```sql +VARIANCE() +``` +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 要计算方差的列或表达式 | -返回expr表达式的方差 +## 返回值 +返回一个 DOUBLE 类型的值,表示计算得到的方差。 ## 举例 -``` -MySQL > select variance(scan_rows) from log_statis group by datetime; -+-----------------------+ -| variance(`scan_rows`) | -+-----------------------+ -| 5.6183332881176211 | -+-----------------------+ - -MySQL > select var_pop(scan_rows) from log_statis group by datetime; -+----------------------+ -| var_pop(`scan_rows`) | -+----------------------+ -| 5.6230744719006163 | -+----------------------+ +```sql +-- 创建示例表 +CREATE TABLE student_scores ( + student_id INT, + score DECIMAL(4,1) +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO student_scores VALUES +(1, 85.5), +(2, 92.0), +(3, 78.5), +(4, 88.0), +(5, 95.5), +(6, 82.0), +(7, 90.0), +(8, 87.5); +-- 计算学生成绩的方差 +SELECT VARIANCE(score) as score_variance +FROM student_scores; ``` -### keywords -VARIANCE,VAR_POP,VARIANCE_POP,VAR,POP +```text ++-------------------+ +| score_variance | ++-------------------+ +| 25.73437499999998 | ++-------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/window-funnel.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/window-funnel.md index dd00c0bada841..c25d317952a5d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/window-funnel.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/aggregate-functions/window-funnel.md @@ -1,6 +1,6 @@ --- { - "title": "WINDOW_FUNCTION_WINDOW_FUNNEL", + "title": "WINDOW_FUNNEL", "language": "zh-CN" } --- @@ -11,19 +11,9 @@ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> -## WINDOW FUNCTION WINDOW_FUNNEL ## 描述 -在滑动时间窗口中搜索事件链,并计算链中发生的最大事件数。 - -- window :滑动时间窗口大小,单位为秒。 -- mode :模式,共有四种模式 - - "default": 默认模式。 - - "deduplication": 当某个事件重复发生时,这个重复发生的事件会阻止后续的处理过程。如,指定事件链为[event1='A', event2='B', event3='C', event4='D'],原始事件链为"A-B-C-B-D"。由于B事件重复,最终的结果事件链为A-B-C,最大长度为3。 - - "fixed": 不允许事件的顺序发生交错,即事件发生的顺序必须和指定的事件链顺序一致。如,指定事件链为[event1='A', event2='B', event3='C', event4='D'],原始事件链为"A-B-D-C",则结果事件链为A-B,最大长度为2 - - "increase": 选中的事件的时间戳必须按照指定事件链严格递增。 -- timestamp_column :指定时间列,类型为DATETIME, 滑动窗口沿着此列工作。 -- eventN :表示事件的布尔表达式。 +WINDOW_FUNNEL 函数用于分析用户行为序列,它在指定的时间窗口内搜索事件链,并计算事件链中完成的最大步骤数。这个函数特别适用于转化漏斗分析,比如分析用户从访问网站到最终购买的转化过程。 漏斗分析函数按照如下算法工作: @@ -31,15 +21,36 @@ Unless required by applicable law or agreed to in writing, software distributed - 如果事件在时间窗口内按照指定的顺序发生,时间长度累计增加。如果事件没有按照指定的顺序发生,时间长度不增加。 - 如果搜索到多个事件链,漏斗分析函数返回最大的长度。 +## 语法 + ```sql -window_funnel(window, mode, timestamp_column, event1, event2, ... , eventN) +WINDOW_FUNNEL(, , , [, event_2, ... , event_n]) ``` +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 滑动时间窗口大小,单位为秒 | +| `` | 模式,共有四种模式,分别为`default`, `deduplication`, `fixed`, `increase`,详细请参见下面的**模式** | +| `` | 指定时间列,类型为DATETIME, 滑动窗口沿着此列工作 | +| `` | 表示事件的布尔表达式。 | + +**模式** + - `default`: 默认模式。 + - `deduplication`: 当某个事件重复发生时,这个重复发生的事件会阻止后续的处理过程。如,指定事件链为[event1='A', event2='B', event3='C', event4='D'],原始事件链为"A-B-C-B-D"。由于B事件重复,最终的结果事件链为A-B-C,最大长度为3。 + - `fixed`: 不允许事件的顺序发生交错,即事件发生的顺序必须和指定的事件链顺序一致。如,指定事件链为[event1='A', event2='B', event3='C', event4='D'],原始事件链为"A-B-D-C",则结果事件链为A-B,最大长度为2 + - `increase`: 选中的事件的时间戳必须按照指定事件链严格递增。 + +## 返回值 + +返回一个整数,表示在指定时间窗口内完成的最大连续步骤数。 + ## 举例 ### 举例1: default 模式 -使用默认模式,筛选出不同```user_id```对应的最大连续事件数,时间窗口为```5```分钟: +使用默认模式,筛选出不同`user_id`对应的最大连续事件数,时间窗口为`5`分钟: ```sql CREATE TABLE events( @@ -82,7 +93,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -93,11 +106,11 @@ order BY +---------+-------+ ``` -对于```uesr_id=100123```,因为```付款```事件发生的时间超出了时间窗口,所以匹配到的事件链是```登陆-访问-下单```。 +对于`uesr_id=100123`,因为`付款`事件发生的时间超出了时间窗口,所以匹配到的事件链是`登陆-访问-下单`。 ### 举例2: deduplication 模式 -使用```deduplication```模式,筛选出不同```user_id```对应的最大连续事件数,时间窗口为```1```小时: +使用`deduplication`模式,筛选出不同`user_id`对应的最大连续事件数,时间窗口为`1`小时: ```sql CREATE TABLE events( @@ -141,7 +154,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -151,11 +166,11 @@ order BY | 100127 | 2 | +---------+-------+ ``` -对于```uesr_id=100123```,匹配到```访问```事件后,```登录```事件重复出现,所以匹配到的事件链是```登陆-访问```。 +对于`uesr_id=100123`,匹配到`访问`事件后,`登录`事件重复出现,所以匹配到的事件链是`登陆-访问`。 ### 举例3: fixed 模式 -使用```fixed```模式,筛选出不同```user_id```对应的最大连续事件数,时间窗口为```1```小时: +使用`fixed`模式,筛选出不同`user_id`对应的最大连续事件数,时间窗口为`1`小时: ```sql CREATE TABLE events( @@ -199,7 +214,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -209,11 +226,11 @@ order BY | 100127 | 2 | +---------+-------+ ``` -对于```uesr_id=100123```,匹配到```下单```事件后,事件链被```登录2```事件打断,所以匹配到的事件链是```登陆-访问-下单```。 +对于`uesr_id=100123`,匹配到`下单`事件后,事件链被`登录2`事件打断,所以匹配到的事件链是`登陆-访问-下单`。 ### 举例4: increase 模式 -使用```increase```模式,筛选出不同```user_id```对应的最大连续事件数,时间窗口为```1```小时: +使用`increase`模式,筛选出不同`user_id`对应的最大连续事件数,时间窗口为`1`小时: ```sql CREATE TABLE events( @@ -256,7 +273,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -266,8 +285,5 @@ order BY | 100127 | 2 | +---------+-------+ ``` -对于```uesr_id=100123```,```付款```事件的时间戳与```下单```事件的时间戳发生在同一秒,没有递增,所以匹配到的事件链是```登陆-访问-下单```。 - -### keywords +对于`uesr_id=100123`,`付款`事件的时间戳与`下单`事件的时间戳发生在同一秒,没有递增,所以匹配到的事件链是`登陆-访问-下单`。 - WINDOW,FUNCTION,WINDOW_FUNNEL diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md index 2e658573e9936..571a0d1543161 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md @@ -24,27 +24,38 @@ specific language governing permissions and limitations under the License. --> -## hours_add + ## 描述 + +返回一个新的日期时间值,该值是在输入的日期时间上增加指定的小时数。 + ## 语法 -`DATETIME HOURS_ADD(DATETIME date, INT hours)` +```sql +HOURS_ADD(, ) +``` + +## 参数 -从日期时间或日期加上指定小时数 +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIME 或 DATE | +| `` | 要增加的小时数,类型为 INT | -参数 date 可以是 DATETIME 或者 DATE 类型,返回类型为 DATETIME。 +## 返回值 + +返回类型为 DATETIME,返回以输入日期时间为基准,增加指定小时数后的时间值。 ## 举例 -``` -mysql> select hours_add("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| hours_add('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-02-02 03:02:02 | -+-------------------------------------+ +```sql +SELECT HOURS_ADD('2020-02-02 02:02:02', 1); ``` -### keywords - - HOURS_ADD +```text ++------------------------------------------------------------+ +| hours_add(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), 1) | ++------------------------------------------------------------+ +| 2020-02-02 03:02:02 | ++------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md index 42290a06a827d..7b0150d470c65 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md @@ -24,25 +24,38 @@ specific language governing permissions and limitations under the License. --> -## hours_diff + ## 描述 + +开始时间到结束时间相差几小时。 + ## 语法 -`INT hours_diff(DATETIME enddate, DATETIME startdate)` +```sql +HOURS_DIFF(, ) +``` + +## 参数 -开始时间到结束时间相差几小时 +| 参数 | 说明 | +| ---- | ---- | +| `` | 结束时间,类型为 DATETIME 或 DATE | +| `` | 开始时间,类型为 DATETIME 或 DATE | + +## 返回值 + +返回类型为 INT,返回开始时间到结束时间相差的小时数。 ## 举例 -``` -mysql> select hours_diff('2020-12-25 22:00:00','2020-12-25 21:00:00'); -+----------------------------------------------------------+ -| hours_diff('2020-12-25 22:00:00', '2020-12-25 21:00:00') | -+----------------------------------------------------------+ -| 1 | -+----------------------------------------------------------+ +```sql +SELECT HOURS_DIFF('2020-12-25 22:00:00', '2020-12-25 21:00:00'); ``` -### keywords - - hours_diff +```text ++--------------------------------------------------------------------------------------------------------+ +| hours_diff(cast('2020-12-25 22:00:00' as DATETIMEV2(0)), cast('2020-12-25 21:00:00' as DATETIMEV2(0))) | ++--------------------------------------------------------------------------------------------------------+ +| 1 | ++--------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md index 72cdcbb4b3a6c..7d46e4a94db55 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md @@ -24,27 +24,38 @@ specific language governing permissions and limitations under the License. --> -## hours_sub + ## 描述 + +返回一个新的日期时间值,该值是从输入的日期时间中减去指定的小时数。 + ## 语法 -`DATETIME HOURS_SUB(DATETIME date, INT hours)` +```sql +HOURS_SUB(, ) +``` + +## 参数 -从日期时间或日期减去指定小时数 +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIME 或 DATE | +| `` | 要减去的小时数,类型为 INT | -参数 date 可以是 DATETIME 或者 DATE 类型,返回类型为 DATETIME。 +## 返回值 + +返回类型为 DATETIME,返回以输入日期时间为基准,减去指定小时数后的时间值。 ## 举例 -``` -mysql> select hours_sub("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| hours_sub('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-02-02 01:02:02 | -+-------------------------------------+ +```sql +SELECT HOURS_SUB('2020-02-02 02:02:02', 1); ``` -### keywords - - HOURS_SUB +```text ++------------------------------------------------------------+ +| hours_sub(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), 1) | ++------------------------------------------------------------+ +| 2020-02-02 01:02:02 | ++------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md index 02f695b712737..456daea9869af 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md @@ -22,28 +22,42 @@ specific language governing permissions and limitations under the License. --> -## last_day + ## 描述 + +返回输入日期所在月份的最后一天的日期。根据不同月份,返回日期的具体日期值为: + +- 28 日:非闰年的二月 +- 29 日:闰年的二月 +- 30 日:四月、六月、九月、十一月 +- 31 日:一月、三月、五月、七月、八月、十月、十二月 + ## 语法 -`DATE last_day(DATETIME date)` +```sql +LAST_DAY() +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIME 或 DATE | + +## 返回值 -返回输入日期中月份的最后一天;所以返回的日期中,年和月不变,日可能是如下情况: -'28'(非闰年的二月份), -'29'(闰年的二月份), -'30'(四月,六月,九月,十一月), -'31'(一月,三月,五月,七月,八月,十月,十二月) +返回类型为 DATE,返回输入日期所在月份的最后一天的日期。 ## 举例 -``` -mysql > select last_day('2000-02-03'); -+-------------------+ -| last_day('2000-02-03 00:00:00') | -+-------------------+ -| 2000-02-29 | -+-------------------+ +```sql +SELECT LAST_DAY('2000-02-03'); ``` -### keywords - LAST_DAY,DAYS +```text ++-----------------------------------------------+ +| last_day(cast('2000-02-03' as DATETIMEV2(0))) | ++-----------------------------------------------+ +| 2000-02-29 | ++-----------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md index 6ab0f9704b8ab..e912d3b87ce58 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md @@ -24,24 +24,42 @@ specific language governing permissions and limitations under the License. --> -## makedate + ## 描述 + +根据指定的年份和一年中的天数(dayofyear)构建并返回一个日期。 + +特殊情况: +- 当 `` 小于等于 0 时,返回 NULL +- 当 `` 超过当年天数时,会自动往后顺延到下一年 + ## 语法 -`DATE MAKEDATE(INT year, INT dayofyear)` +```sql +MAKEDATE(, ) +``` + +## 参数 -返回指定年份和dayofyear构建的日期。dayofyear必须大于0,否则结果为空。 +| 参数 | 说明 | +| ---- | ---- | +| `` | 指定的年份,类型为 INT | +| `` | 一年中的第几天(1-366),类型为 INT | + +## 返回值 + +返回类型为 DATE,返回以指定年份和一年中的第几天构建的日期。 ## 举例 + +```sql +SELECT MAKEDATE(2021, 1), MAKEDATE(2021, 100), MAKEDATE(2021, 400); ``` -mysql> select makedate(2021,1), makedate(2021,100), makedate(2021,400); + +```text +-------------------+---------------------+---------------------+ | makedate(2021, 1) | makedate(2021, 100) | makedate(2021, 400) | +-------------------+---------------------+---------------------+ | 2021-01-01 | 2021-04-10 | 2022-02-04 | +-------------------+---------------------+---------------------+ ``` - -### keywords - - MAKEDATE diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md index 513b0314b5d80..e529b88d9d49c 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md @@ -24,26 +24,37 @@ specific language governing permissions and limitations under the License. --> -## microsecond + ## 描述 + +从日期时间值中提取微秒部分的值。返回的范围是 0 到 999999。 + ## 语法 -`INT MICROSECOND(DATETIMEV2 date)` +```sql +MICROSECOND() +``` + +## 参数 +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIMEV2,精度需要大于 0 | -获得日期中的微秒信息。 +## 返回值 -参数为 Datetime 类型 +返回类型为 INT,返回日期时间值中的微秒部分。取值范围为 0 到 999999。对于精度小于 6 的输入,不足的位数补 0。 ## 举例 +```sql +SELECT MICROSECOND(CAST('1999-01-02 10:11:12.000123' AS DATETIMEV2(6))) AS microsecond; ``` -mysql> select microsecond(cast('1999-01-02 10:11:12.000123' as datetimev2(6))) as microsecond; + +```text +-------------+ | microsecond | +-------------+ | 123 | +-------------+ ``` -### keywords - MICROSECOND diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md index 962a328dcf636..7eb111621184b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md @@ -24,25 +24,42 @@ specific language governing permissions and limitations under the License. --> -## microseconds_add + ## 描述 + +向日期时间值中添加指定的微秒数,返回一个新的日期时间值。 + ## 语法 -`DATETIMEV2 microseconds_add(DATETIMEV2 basetime, INT delta)` -- basetime: DATETIMEV2 类型起始时间 -- delta: 从 basetime 起需要相加的微秒数 -- 返回类型为 DATETIMEV2 +```sql +MICROSECONDS_ADD(, ) +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIMEV2 | +| `` | 要添加的微秒数,类型为 INT,1 秒 = 1,000,000 微秒 | + +## 返回值 + +返回类型为 DATETIMEV2,返回以输入日期时间为基准,增加指定微秒数后的时间值。返回值的精度与输入参数 basetime 的精度相同。 ## 举例 + +```sql +SELECT NOW(3) AS current_time, MICROSECONDS_ADD(NOW(3), 100000) AS after_add; ``` -mysql> select now(3), microseconds_add(now(3), 100000); -+-------------------------+----------------------------------+ -| now(3) | microseconds_add(now(3), 100000) | -+-------------------------+----------------------------------+ -| 2023-02-21 11:35:56.556 | 2023-02-21 11:35:56.656 | -+-------------------------+----------------------------------+ + +```text ++-------------------------+----------------------------+ +| current_time | after_add | ++-------------------------+----------------------------+ +| 2025-01-16 11:48:10.505 | 2025-01-16 11:48:10.605000 | ++-------------------------+----------------------------+ ``` -`now(3)` 返回精度位数 3 的 DATETIMEV2 类型当前时间,`microseconds_add(now(3), 100000)` 返回当前时间加上 100000 微秒后的 DATETIMEV2 类型时间 -### keywords - microseconds_add +注意: +- NOW(3) 返回精度为 3 位小数的当前时间 +- 添加 100000 微秒(0.1 秒)后,时间增加了 0.1 秒 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md index 2dfb6fe286610..fa70308687ee5 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md @@ -24,26 +24,41 @@ specific language governing permissions and limitations under the License. --> -## microseconds_diff + ## 描述 + +计算两个日期时间值之间的微秒差值。结果为 `` 减去 `` 的微秒数。 + ## 语法 -`INT microseconds_diff(DATETIME enddate, DATETIME startdate)` +```sql +MICROSECONDS_DIFF(, ) +``` + +## 参数 -开始时间到结束时间相差几微秒 +| 参数 | 说明 | +| ---- | ---- | +| `` | 结束时间,类型为 DATETIMEV2 | +| `` | 开始时间,类型为 DATETIMEV2 | + +## 返回值 + +返回类型为 INT,表示两个时间之间的微秒差值。 +- 如果 `` 大于 ``,返回正数 +- 如果 `` 小于 ``,返回负数 +- 1 秒 = 1,000,000 微秒 ## 举例 +```sql +SELECT MICROSECONDS_DIFF('2020-12-25 21:00:00.623000','2020-12-25 21:00:00.123000'); ``` -mysql> select microseconds_diff('2020-12-25 21:00:00.623000','2020-12-25 21:00:00.123000'); + +```text +-----------------------------------------------------------------------------------------------------------------------------+ -| microseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(6)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(6))) | +| microseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(3)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(3))) | +-----------------------------------------------------------------------------------------------------------------------------+ | 500000 | +-----------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.12 sec) ``` - -### keywords - - microseconds_diff diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md index 6882ec9daa6f0..02ea9014147a4 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md @@ -24,27 +24,43 @@ specific language governing permissions and limitations under the License. --> -## microseconds_sub + ## 描述 + +从日期时间值中减去指定的微秒数,返回一个新的日期时间值。 + ## 语法 -`DATETIMEV2 microseconds_sub(DATETIMEV2 basetime, INT delta)` -- basetime: DATETIMEV2 类型起始时间 -- delta: 从 basetime 起需要扣减的微秒数 -- 返回类型为 DATETIMEV2 +```sql +MICROSECONDS_SUB(, ) +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIMEV2 | +| `` | 要减去的微秒数,类型为 INT,1 秒 = 1,000,000 微秒 | + +## 返回值 + +返回类型为 DATETIMEV2,返回以输入日期时间为基准,减去指定微秒数后的时间值。返回值的精度与输入参数 basetime 的精度相同。 ## 举例 + +```sql +SELECT NOW(3) AS current_time, MICROSECONDS_SUB(NOW(3), 100000) AS after_sub; ``` -mysql> select now(3), microseconds_sub(now(3), 100000); -+-------------------------+----------------------------------+ -| now(3) | microseconds_sub(now(3), 100000) | -+-------------------------+----------------------------------+ -| 2023-02-25 02:03:05.174 | 2023-02-25 02:03:05.074 | -+-------------------------+----------------------------------+ -``` -`now(3)` 返回精度位数 3 的 DATETIMEV2 类型当前时间,`microseconds_add(now(3), 100000)` 返回当前时间减去 100000 微秒后的 DATETIMEV2 类型时间 -### keywords - microseconds_sub +```text ++-------------------------+----------------------------+ +| current_time | after_sub | ++-------------------------+----------------------------+ +| 2025-01-16 11:52:22.296 | 2025-01-16 11:52:22.196000 | ++-------------------------+----------------------------+ +``` - \ No newline at end of file +注意: +- `NOW(3)` 返回精度为 3 位小数的当前时间 +- 减去 100000 微秒(0.1 秒)后,时间减少了 0.1 秒 +- 函数的计算结果与输入时间的精度有关 \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md index 7575f0502214c..658634d67ea9a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md @@ -24,28 +24,43 @@ specific language governing permissions and limitations under the License. --> -## milliseconds_add + ## 描述 + +向日期时间值中添加指定的毫秒数,返回一个新的日期时间值。 + ## 语法 -`DATETIMEV2 milliseconds_add(DATETIMEV2 basetime, INT delta)` -- basetime: DATETIMEV2 类型起始时间 -- delta: 从 basetime 起需要相加的毫秒数 -- 返回类型为 DATETIMEV2 +```sql +MILLISECONDS_ADD(, ) +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIMEV2 | +| `` | 要添加的毫秒数,类型为 INT,1 秒 = 1,000 毫秒 = 1,000,000 微秒 | + +## 返回值 + +返回类型为 DATETIMEV2,返回以输入日期时间为基准,增加指定毫秒数后的时间值。返回值的精度与输入参数 basetime 的精度相同。 ## 举例 + +```sql +SELECT MILLISECONDS_ADD('2023-09-08 16:02:08.435123', 1); ``` -mysql> select milliseconds_add('2023-09-08 16:02:08.435123', 1); + +```text +--------------------------------------------------------------------------+ | milliseconds_add(cast('2023-09-08 16:02:08.435123' as DATETIMEV2(6)), 1) | +--------------------------------------------------------------------------+ | 2023-09-08 16:02:08.436123 | +--------------------------------------------------------------------------+ -1 row in set (0.04 sec) ``` - -### keywords - milliseconds_add - - \ No newline at end of file +注意: +- 示例中添加 1 毫秒后,时间从 .435123 增加到 .436123 +- 1 毫秒等于 1000 微秒 +- 函数的计算结果与输入时间的精度有关,示例使用了 6 位小数精度 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md index b30e62fb8bd4c..c3c68e3d8386d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md @@ -24,26 +24,46 @@ specific language governing permissions and limitations under the License. --> -## milliseconds_diff ## 描述 + +计算两个日期时间值之间的毫秒差值。结果为 `` 减去 `` 的毫秒数。 + ## 语法 -`INT milliseconds_diff(DATETIME enddate, DATETIME startdate)` +```sql +MILLISECONDS_DIFF(, ) +``` + +## 参数 -开始时间到结束时间相差几毫秒 +| 参数 | 说明 | +| ---- | ---- | +| `` | 结束时间,类型为 DATETIMEV2 | +| `` | 开始时间,类型为 DATETIMEV2 | + +## 返回值 + +返回类型为 INT,表示两个时间之间的毫秒差值。 +- 如果 `` 大于 ``,返回正数 +- 如果 `` 小于 ``,返回负数 +- 1 秒 = 1,000 毫秒 +- 1 毫秒 = 1,000 微秒 ## 举例 +```sql +SELECT MILLISECONDS_DIFF('2020-12-25 21:00:00.623000', '2020-12-25 21:00:00.123000'); ``` -mysql> select milliseconds_diff('2020-12-25 21:00:00.623000','2020-12-25 21:00:00.123000'); + +```text +-----------------------------------------------------------------------------------------------------------------------------+ -| milliseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(6)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(6))) | +| milliseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(3)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(3))) | +-----------------------------------------------------------------------------------------------------------------------------+ | 500 | +-----------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) ``` -### keywords - - milliseconds_diff +注意: +- 示例中的时间差为 0.5 秒,即 500 毫秒 +- 函数的计算结果与输入时间的精度有关,示例使用了 3 位小数精度 +- 结果只返回毫秒差值,不包含微秒部分 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md index 840a533669bab..ee0608d66eb3f 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md @@ -24,28 +24,43 @@ specific language governing permissions and limitations under the License. --> -## milliseconds_sub ## 描述 + +从日期时间值中减去指定的毫秒数,返回一个新的日期时间值。 + ## 语法 -`DATETIMEV2 milliseconds_sub(DATETIMEV2 basetime, INT delta)` -- basetime: DATETIMEV2 类型起始时间 -- delta: 从 basetime 起需要扣减的毫秒数 -- 返回类型为 DATETIMEV2 +```sql +MILLISECONDS_SUB(, ) +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIMEV2 | +| `` | 要减去的毫秒数,类型为 INT,1 秒 = 1,000 毫秒 = 1,000,000 微秒 | + +## 返回值 + +返回类型为 DATETIMEV2,返回以输入日期时间为基准,减去指定毫秒数后的时间值。返回值的精度与输入参数 basetime 的精度相同。 ## 举例 + +```sql +SELECT MILLISECONDS_SUB('2023-09-08 16:02:08.435123', 1); ``` -mysql> select milliseconds_sub('2023-09-08 16:02:08.435123', 1); + +```text +--------------------------------------------------------------------------+ | milliseconds_sub(cast('2023-09-08 16:02:08.435123' as DATETIMEV2(6)), 1) | +--------------------------------------------------------------------------+ | 2023-09-08 16:02:08.434123 | +--------------------------------------------------------------------------+ -1 row in set (0.11 sec) ``` - -### keywords - milliseconds_sub - - \ No newline at end of file +注意: +- 示例中减去 1 毫秒后,时间从 .435123 减少到 .434123 +- 1 毫秒等于 1000 微秒 +- 函数的计算结果与输入时间的精度有关,示例使用了 6 位小数精度 +- 结果保留了微秒级别的精度 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md index 54a81bf3a8668..1a5cdf24810ce 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md @@ -1,6 +1,6 @@ --- { - "title": "minute_floor", + "title": "MINUTE_FLOOR", "language": "zh-CN" } --- @@ -24,39 +24,51 @@ specific language governing permissions and limitations under the License. --> -## minute_floor ## 描述 + +将日期时间向下取整到最近的指定分钟周期。如果指定了起始时间(origin),则以该时间为基准计算周期。 + ## 语法 ```sql -DATETIME MINUTE_FLOOR(DATETIME datetime) -DATETIME MINUTE_FLOOR(DATETIME datetime, DATETIME origin) -DATETIME MINUTE_FLOOR(DATETIME datetime, INT period) -DATETIME MINUTE_FLOOR(DATETIME datetime, INT period, DATETIME origin) +MINUTE_FLOOR() +MINUTE_FLOOR(, ) +MINUTE_FLOOR(, ) +MINUTE_FLOOR(, , ) ``` -将日期转化为指定的时间间隔周期的最近下取整时刻。 +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 需要向下取整的日期时间值,类型为 DATETIME 或 DATETIMEV2 | +| `` | 分钟周期值,类型为 INT,表示每个周期包含的分钟数 | +| `` | 周期的起始时间点,类型为 DATETIME 或 DATETIMEV2,默认值为 0001-01-01 00:00:00 | + +## 返回值 -- datetime:参数是合法的日期表达式。 -- period:参数是指定每个周期有多少天组成。 -- origin:开始的时间起点,如果不填,默认是 0001-01-01T00:00:00。 +返回类型为 DATETIMEV2,表示向下取整后的日期时间值。 ## 举例 +```sql +SELECT MINUTE_FLOOR("2023-07-13 22:28:18", 5); ``` -mysql> select minute_floor("2023-07-13 22:28:18", 5); + +```text +---------------------------------------------------------------+ | minute_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +---------------------------------------------------------------+ | 2023-07-13 22:25:00 | +---------------------------------------------------------------+ -1 row in set (0.06 sec) ``` -### keywords - - MINUTE_FLOOR, MINUTE, FLOOR +注意: +- 不指定 period 时,默认以 1 分钟为周期 +- period 必须为正整数 +- 结果总是向过去时间取整 +- 与 MINUTE_CEIL 相反,MINUTE_FLOOR 总是舍去超出周期的部分 -### Best Practice +## 最佳实践 还可参阅 [date_floor](./date_floor) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md index 0803c1f016ab0..fcd872cb1c358 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md @@ -25,26 +25,41 @@ under the License. --> -## Description +## 描述 +从日期时间值中提取分钟部分的值。返回值范围为 0 到 59。 -获得日期中的分钟的信息,返回值范围从 0-59。 +## 语法 -参数为 Date 或者 Datetime,Time 类型 +```sql +MINUTE() +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型可以是 DATE、DATETIME、DATETIMEV2 或 TIME | -## Syntax +## 返回值 -`INT MINUTE(DATETIME date)` +返回类型为 INT,表示分钟值,取值范围为 0-59。 -## Example +## 举例 ```sql -mysql> select minute('2018-12-31 23:59:59'); -+-----------------------------+ -| minute('2018-12-31 23:59:59') | -+-----------------------------+ -| 59 | -+-----------------------------+ +SELECT MINUTE('2018-12-31 23:59:59'); ``` -## Keywords - MINUTE + +```text ++------------------------------------------------------+ +| minute(cast('2018-12-31 23:59:59' as DATETIMEV2(0))) | ++------------------------------------------------------+ +| 59 | ++------------------------------------------------------+ +``` + +注意: +- 输入参数可以是多种时间相关类型 +- 返回值始终是 0-59 之间的整数 +- 如果输入参数为 NULL,则返回 NULL diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute_ceil.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute_ceil.md index d8f9cec1ff25b..006bac979249d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute_ceil.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute_ceil.md @@ -1,6 +1,6 @@ --- { - "title": "minute_ceil", + "title": "MINUTE_CEIL", "language": "zh-CN" } --- @@ -24,39 +24,50 @@ specific language governing permissions and limitations under the License. --> -## minute_ceil ## 描述 + +将日期时间向上取整到最近的指定分钟周期。如果指定了起始时间(origin),则以该时间为基准计算周期。 + ## 语法 ```sql -DATETIME MINUTE_CEIL(DATETIME datetime) -DATETIME MINUTE_CEIL(DATETIME datetime, DATETIME origin) -DATETIME MINUTE_CEIL(DATETIME datetime, INT period) -DATETIME MINUTE_CEIL(DATETIME datetime, INT period, DATETIME origin) +MINUTE_CEIL() +MINUTE_CEIL(, ) +MINUTE_CEIL(, ) +MINUTE_CEIL(, , ) ``` -将日期转化为指定的时间间隔周期的最近上取整时刻。 +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 需要向上取整的日期时间值,类型为 DATETIME 或 DATETIMEV2 | +| `` | 分钟周期值,类型为 INT,表示每个周期包含的分钟数 | +| `` | 周期的起始时间点,类型为 DATETIME 或 DATETIMEV2,默认值为 0001-01-01 00:00:00 | + +## 返回值 -- datetime:参数是合法的日期表达式。 -- period:参数是指定每个周期有多少分钟组成。 -- origin:开始的时间起点,如果不填,默认是 0001-01-01T00:00:00。 +返回类型为 DATETIMEV2,返回以输入日期时间为基准,向上取整到最近的指定分钟周期后的时间值。返回值的精度与输入参数 datetime 的精度相同。 ## 举例 +```sql +SELECT MINUTE_CEIL("2023-07-13 22:28:18", 5); ``` -mysql> select minute_ceil("2023-07-13 22:28:18", 5); + +```text +--------------------------------------------------------------+ | minute_ceil(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +--------------------------------------------------------------+ | 2023-07-13 22:30:00 | +--------------------------------------------------------------+ -1 row in set (0.21 sec) ``` -### keywords - - MINUTE_CEIL, MINUTE, CEIL +注意: +- 不指定 period 时,默认以 1 分钟为周期 +- period 必须为正整数 +- 结果总是向未来时间取整 -### Best Practice +## 最佳实践 还可参阅 [date_ceil](./date_ceil) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md index 60e3e55c887b0..b7982e4391796 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md @@ -24,27 +24,42 @@ specific language governing permissions and limitations under the License. --> -## minutes_add ## 描述 + +向日期时间值中添加指定的分钟数,返回一个新的日期时间值。 + ## 语法 -`DATETIME MINUTES_ADD(DATETIME date, INT minutes)` +```sql +MINUTES_ADD(, ) +``` + +## 参数 -从日期时间或日期加上指定分钟数 +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型可以是 DATE、DATETIME 或 DATETIMEV2 | +| `` | 要添加的分钟数,类型为 INT,可以为正数或负数 | -参数 date 可以是 DATETIME 或者 DATE 类型,返回类型为 DATETIME。 +## 返回值 + +返回类型为 DATETIMEV2,返回以输入日期时间为基准,添加指定分钟数后的时间值。返回值的精度与输入参数 date 的精度相同。 ## 举例 -``` -mysql> select minutes_add("2020-02-02", 1); -+---------------------------------------+ -| minutes_add('2020-02-02 00:00:00', 1) | -+---------------------------------------+ -| 2020-02-02 00:01:00 | -+---------------------------------------+ +```sql +SELECT MINUTES_ADD("2020-02-02", 1); ``` -### keywords +```text ++-----------------------------------------------------+ +| minutes_add(cast('2020-02-02' as DATETIMEV2(0)), 1) | ++-----------------------------------------------------+ +| 2020-02-02 00:01:00 | ++-----------------------------------------------------+ +``` - MINUTES_ADD +注意: +- 当添加的分钟数为负数时,相当于减去对应的分钟数 +- 函数会自动处理跨小时、跨天的情况 +- 如果输入参数为 NULL,则返回 NULL diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md index 4b216c3428bdd..96e3de8cdb608 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md @@ -24,25 +24,44 @@ specific language governing permissions and limitations under the License. --> -## minutes_diff ## 描述 + +计算两个日期时间值之间的分钟差值。结果为 `` 减去 `` 的分钟数。 + ## 语法 -`INT minutes_diff(DATETIME enddate, DATETIME startdate)` +```sql +MINUTES_DIFF(, ) +``` + +## 参数 -开始时间到结束时间相差几分钟 +| 参数 | 说明 | +| ---- | ---- | +| `` | 结束时间,类型可以是 DATE、DATETIME 或 DATETIMEV2 | +| `` | 开始时间,类型可以是 DATE、DATETIME 或 DATETIMEV2 | + +## 返回值 + +返回类型为 INT,表示两个时间之间的分钟差值。 +- 如果 `` 大于 ``,返回正数 +- 如果 `` 小于 ``,返回负数 ## 举例 -``` -mysql> select minutes_diff('2020-12-25 22:00:00','2020-12-25 21:00:00'); -+------------------------------------------------------------+ -| minutes_diff('2020-12-25 22:00:00', '2020-12-25 21:00:00') | -+------------------------------------------------------------+ -| 60 | -+------------------------------------------------------------+ +```sql +SELECT MINUTES_DIFF('2020-12-25 22:00:00', '2020-12-25 21:00:00'); ``` -### keywords +```text ++----------------------------------------------------------------------------------------------------------+ +| minutes_diff(cast('2020-12-25 22:00:00' as DATETIMEV2(0)), cast('2020-12-25 21:00:00' as DATETIMEV2(0))) | ++----------------------------------------------------------------------------------------------------------+ +| 60 | ++----------------------------------------------------------------------------------------------------------+ +``` - minutes_diff +注意: +- 计算只考虑完整的分钟数,秒和毫秒部分会被忽略 +- 如果任一输入参数为 NULL,则返回 NULL +- 可以处理跨天、跨月、跨年的时间差计算 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md index 1c54f977ef150..238f3ff8159a0 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md @@ -24,27 +24,44 @@ specific language governing permissions and limitations under the License. --> -## minutes_sub + ## 描述 + +从日期时间值中减去指定的分钟数,返回一个新的日期时间值。 + ## 语法 -`DATETIME MINUTES_SUB(DATETIME date, INT minutes)` +```sql +MINUTES_SUB(, ) +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型可以是 DATE、DATETIME 或 DATETIMEV2 | +| `` | 要减去的分钟数,类型为 INT,可以为正数或负数 | -从日期时间或日期减去指定分钟数 +## 返回值 -参数 date 可以是 DATETIME 或者 DATE 类型,返回类型为 DATETIME。 +返回类型为 DATETIME,表示减去指定分钟数后的日期时间值。 ## 举例 -``` -mysql> select minutes_sub("2020-02-02 02:02:02", 1); -+---------------------------------------+ -| minutes_sub('2020-02-02 02:02:02', 1) | -+---------------------------------------+ -| 2020-02-02 02:01:02 | -+---------------------------------------+ +```sql +SELECT MINUTES_SUB("2020-02-02 02:02:02", 1); ``` -### keywords +```text ++--------------------------------------------------------------+ +| minutes_sub(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), 1) | ++--------------------------------------------------------------+ +| 2020-02-02 02:01:02 | ++--------------------------------------------------------------+ +``` - MINUTES_SUB +注意: +- 当减去的分钟数为负数时,相当于加上对应的分钟数 +- 函数会自动处理跨小时、跨天的情况 +- 如果输入参数为 NULL,则返回 NULL +- 结果会保留原始时间的秒数部分 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md index 3c56748a182d3..f26db7f8dc6bc 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md @@ -1,6 +1,6 @@ --- { - "title": "month_ceil", + "title": "MONTH_CEIL", "language": "zh-CN" } --- @@ -24,39 +24,51 @@ specific language governing permissions and limitations under the License. --> -## month_ceil ## 描述 + +将日期时间值向上取整到最近的指定月份周期。如果指定了起始时间(origin),则以该时间为基准计算周期。 + ## 语法 ```sql -DATETIME MONTH_CEIL(DATETIME datetime) -DATETIME MONTH_CEIL(DATETIME datetime, DATETIME origin) -DATETIME MONTH_CEIL(DATETIME datetime, INT period) -DATETIME MONTH_CEIL(DATETIME datetime, INT period, DATETIME origin) +MONTH_CEIL() +MONTH_CEIL(, ) +MONTH_CEIL(, ) +MONTH_CEIL(, , ) ``` -将日期转化为指定的时间间隔周期的最近上取整时刻。 +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 需要向上取整的日期时间值,类型为 DATETIME 或 DATETIMEV2 | +| `` | 月份周期值,类型为 INT,表示每个周期包含的月数 | +| `` | 周期的起始时间点,类型为 DATETIME 或 DATETIMEV2,默认值为 0001-01-01 00:00:00 | + +## 返回值 -- datetime:参数是合法的日期表达式。 -- period:参数是指定每个周期有几个月组成。 -- origin:开始的时间起点,如果不填,默认是 0001-01-01T00:00:00。 +返回类型为 DATETIME,表示向上取整后的日期时间值。结果的时间部分将被设置为 00:00:00。 ## 举例 +```sql +SELECT MONTH_CEIL("2023-07-13 22:28:18", 5); ``` -mysql> select month_ceil("2023-07-13 22:28:18", 5); + +```text +-------------------------------------------------------------+ | month_ceil(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +-------------------------------------------------------------+ | 2023-10-01 00:00:00 | +-------------------------------------------------------------+ -1 row in set (0.02 sec) ``` -### keywords - - MONTH_CEIL, MONTH, CEIL +注意: +- 不指定 period 时,默认以 1 个月为周期 +- period 必须为正整数 +- 结果总是向未来时间取整 +- 返回值的时间部分总是 00:00:00 -### Best Practice +## 最佳实践 还可参阅 [date_ceil](./date_ceil) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md index e1684fce70bfa..45610a1bfb732 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md @@ -1,6 +1,6 @@ --- { - "title": "month_floor", + "title": "MONTH_FLOOR", "language": "zh-CN" } --- @@ -24,39 +24,52 @@ specific language governing permissions and limitations under the License. --> -## month_floor ## 描述 + +将日期时间值向下取整到最近的指定月份周期。如果指定了起始时间(origin),则以该时间为基准计算周期。 + ## 语法 ```sql -DATETIME MONTH_FLOOR(DATETIME datetime) -DATETIME MONTH_FLOOR(DATETIME datetime, DATETIME origin) -DATETIME MONTH_FLOOR(DATETIME datetime, INT period) -DATETIME MONTH_FLOOR(DATETIME datetime, INT period, DATETIME origin) +MONTH_FLOOR() +MONTH_FLOOR(, ) +MONTH_FLOOR(, ) +MONTH_FLOOR(, , ) ``` -将日期转化为指定的时间间隔周期的最近下取整时刻。 +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 需要向下取整的日期时间值,类型为 DATETIME 或 DATETIMEV2 | +| `` | 月份周期值,类型为 INT,表示每个周期包含的月数 | +| `` | 周期的起始时间点,类型为 DATETIME 或 DATETIMEV2,默认值为 0001-01-01 00:00:00 | + +## 返回值 -- datetime:参数是合法的日期表达式。 -- period:参数是指定每个周期有多少天组成。 -- origin:开始的时间起点,如果不填,默认是 0001-01-01T00:00:00。 +返回类型为 DATETIME,表示向下取整后的日期时间值。结果的时间部分将被设置为 00:00:00。 ## 举例 +```sql +SELECT MONTH_FLOOR("2023-07-13 22:28:18", 5); ``` -mysql> select month_floor("2023-07-13 22:28:18", 5); + +```text +--------------------------------------------------------------+ | month_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +--------------------------------------------------------------+ | 2023-05-01 00:00:00 | +--------------------------------------------------------------+ -1 row in set (0.12 sec) ``` -### keywords - - MONTH_FLOOR, MONTH, FLOOR +注意: +- 不指定 period 时,默认以 1 个月为周期 +- period 必须为正整数 +- 结果总是向过去时间取整 +- 返回值的时间部分总是 00:00:00 +- 与 MONTH_CEIL 相反,MONTH_FLOOR 总是舍去超出周期的部分 -### Best Practice +## 最佳实践 还可参阅 [date_floor](./date_floor) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md index 1bd5109dc589f..9a8c52bd24014 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md @@ -24,28 +24,40 @@ specific language governing permissions and limitations under the License. --> -## month + ## 描述 + +从日期时间值中提取月份值。返回值范围为 1 到 12,分别代表一年中的 12 个月。 + ## 语法 -`INT MONTH(DATETIME date)` +```sql +MONTH() +``` + +## 参数 +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型可以是 DATE、DATETIME 或 DATETIMEV2 | -返回时间类型中的月份信息,范围是1, 12 +## 返回值 -参数为Date或者Datetime类型 +返回类型为 INT,表示月份值: +- 范围:1 到 12 +- 1 表示一月,12 表示十二月 +- 如果输入为 NULL,返回 NULL ## 举例 -``` -mysql> select month('1987-01-01'); -+-----------------------------+ -| month('1987-01-01 00:00:00') | -+-----------------------------+ -| 1 | -+-----------------------------+ +```sql +SELECT MONTH('1987-01-01'); ``` -### keywords - - MONTH +```text ++--------------------------------------------+ +| month(cast('1987-01-01' as DATETIMEV2(0))) | ++--------------------------------------------+ +| 1 | ++--------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md index 14475378ebc09..742c6a971f783 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md @@ -24,28 +24,40 @@ specific language governing permissions and limitations under the License. --> -## monthname + ## 描述 + +返回日期对应的英文月份名称。返回值为完整的英文月份名称(January 到 December)。 + ## 语法 -`VARCHAR MONTHNAME(DATE)` +```sql +MONTHNAME() +``` + +## 参数 +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型可以是 DATE、DATETIME 或 DATETIMEV2 | -返回日期对应的月份名字 +## 返回值 -参数为Date或者Datetime类型 +返回类型为 VARCHAR,表示月份的英文名称: +- 返回值范围:January, February, March, April, May, June, July, August, September, October, November, December +- 如果输入为 NULL,返回 NULL +- 返回值首字母大写,其余字母小写 ## 举例 -``` -mysql> select monthname('2008-02-03 00:00:00'); -+----------------------------------+ -| monthname('2008-02-03 00:00:00') | -+----------------------------------+ -| February | -+----------------------------------+ +```sql +SELECT MONTHNAME('2008-02-03 00:00:00'); ``` -### keywords - - MONTHNAME +```text ++---------------------------------------------------------+ +| monthname(cast('2008-02-03 00:00:00' as DATETIMEV2(0))) | ++---------------------------------------------------------+ +| February | ++---------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/json-functions/json-array.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/json-functions/json-array.md index 2b418ae1e17c6..b4b7568b14086 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/json-functions/json-array.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/json-functions/json-array.md @@ -24,47 +24,73 @@ specific language governing permissions and limitations under the License. --> -## json_array ## 描述 + +生成一个包含制定元素的 json 数组,未指定时返回空数组 + ## 语法 -`VARCHAR json_array(VARCHAR,...)` +```sql +JSON_ARRAY(, ...) +``` + +## 参数 +| 参数 | 描述 | +|------|------------------------------------------------------------| +| `, ...` | 要包含在 JSON 数组中的元素。可以是单个或者多个任意类型的值,包括`NULL`。如果没有指定元素,则返回一个空数组。 | -生成一个包含指定元素的json数组,未指定时返回空数组 +## 返回值 -## 举例 +返回一个包含指定元素的 JSON 数组。特殊情况: +* 如果指定的元素为`NULL`,则返回`NULL`。 +## 示例 + +```sql +select json_array(); ``` -MySQL> select json_array(); + +```text +--------------+ | json_array() | +--------------+ | [] | +--------------+ +``` -MySQL> select json_array(null); +```sql +select json_array(null); +``` + +```text +--------------------+ | json_array('NULL') | +--------------------+ | [NULL] | +--------------------+ +``` +```sql +SELECT json_array(1, "abc", NULL, TRUE, CURTIME()); +``` -MySQL> SELECT json_array(1, "abc", NULL, TRUE, CURTIME()); +```text +-----------------------------------------------+ | json_array(1, 'abc', 'NULL', TRUE, curtime()) | +-----------------------------------------------+ | [1, "abc", NULL, TRUE, "10:41:15"] | +-----------------------------------------------+ +``` +```sql +select json_array("a", null, "c"); +``` -MySQL> select json_array("a", null, "c"); +```text +------------------------------+ | json_array('a', 'NULL', 'c') | +------------------------------+ | ["a", NULL, "c"] | +------------------------------+ ``` -### keywords -json,array,json_array diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md index f6b0cdb832217..e1ce4ac677fae 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md @@ -26,48 +26,35 @@ under the License. ## 描述 +判断给定 `map` 中是否包含特定的键 `key` + ## 语法 -`BOOLEAN map_contains_key(Map map, K key)` +```sql +MAP_CONTAINS_KEY(, ) +``` -判断给定 `map` 中是否包含特定的键 `key` +## 参数 -## 举例 +| 参数 | 说明 | +| -- | -- | +| `` | 输入的 map 内容 | +| `` | 需要检索的key | -```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +## 返回值 -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +判断给定 `map` 中是否包含特定的键 `key`,存在返回 1 ,不存在返回 0 。 -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +## 举例 -mysql> select map_contains_key(map(null, 1, 2, null), null); -+-----------------------------------------------+ -| map_contains_key(map(NULL, 1, 2, NULL), NULL) | -+-----------------------------------------------+ -| 1 | -+-----------------------------------------------+ -1 row in set (0.14 sec) +```sql +select map_contains_key(map(null, 1, 2, null), null),map_contains_key(map(1, "100", 0.1, 2), 0.11); ``` -### Keywords - -MAP, CONTAINS, KEY, MAP_CONTAINS_KEY +```text ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_key(map(NULL, 1, 2, NULL), NULL) | map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast(0.11 as DECIMALV3(3, 2))) | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md index 8e2eb5b56a700..c255f874055f1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md @@ -26,64 +26,35 @@ under the License. ## 描述 -## 语法 - -`BOOLEAN map_contains_value(Map map, V value)` - 判断给定 `map` 中是否包含特定的值 `value` -## 举例 +## 语法 ```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +MAP_CONTAINS_VALUE(, ) +``` -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## 参数 -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +| 参数 | 说明 | +| -- | -- | +| `` | 输入的 map 内容 | +| `` | 需要检索的 value | -mysql> select map_contains_value(map(1, "100", 0.1, 2), 100.0); -+--------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(100.0 as VARCHAR(3))) | -+--------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+--------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## 返回值 -mysql> select map_contains_value(map(1, "100", 0.1, 2), 101); -+------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | -+------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.14 sec) +判断给定 `map` 中是否包含特定的值 `value`,存在返回 1 ,不存在返回 0 。 -mysql> select map_contains_value(map(null, 1, 2, null), null); -+-------------------------------------------------+ -| map_contains_value(map(NULL, 1, 2, NULL), NULL) | -+-------------------------------------------------+ -| 1 | -+-------------------------------------------------+ -1 row in set (0.15 sec) -``` +## 举例 -### Keywords +```sql +select map_contains_value(map(null, 1, 2, null), null),map_contains_value(map(1, "100", 0.1, 2), 101); +``` -MAP, CONTAINS, VALUE, MAP_CONTAINS_VALUE +```text ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_value(map(NULL, 1, 2, NULL), NULL) | map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md index 852b288f2440e..5579de67ce60b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md @@ -26,32 +26,34 @@ under the License. ## 描述 +将给定 `map` 的键提取成一个对应类型的 `ARRAY` + ## 语法 -`ARRAY map_keys(Map map)` +```sql +MAP_KEYS() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 输入的 map 内容 | + +## 返回值 将给定 `map` 的键提取成一个对应类型的 `ARRAY` ## 举例 ```sql -mysql> select map_keys(map(1, "100", 0.1, 2)); -+-------------------------------------------------------------------------------------------------+ -| map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+-------------------------------------------------------------------------------------------------+ -| [1.0, 0.1] | -+-------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) - -mysql> select map_keys(map()); -+-----------------+ -| map_keys(map()) | -+-----------------+ -| [] | -+-----------------+ -1 row in set (0.12 sec) +select map_keys(map()),map_keys(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, KEYS, MAP_KEYS +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_keys(map()) | map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| [] | [1.0, 0.1] | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md index 85424d7fecd6f..b3ca337613d91 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md @@ -1,7 +1,6 @@ --- { - "title": "MAP_SIZE - ", + "title": "MAP_SIZE", "language": "zh-CN" } --- @@ -24,3 +23,37 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## 描述 + +计算 Map 中元素的个数 + +## 语法 + +```sql +MAP_SIZE() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 输入的 map 内容 | + +## 返回值 + +返回 Map 中元素的个数 + +## 举例 + +```sql +select map_size(map()),map_size(map(1, "100", 0.1, 2)); +``` + +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_size(map()) | map_size(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| 0 | 2 | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md index b5a0b2e27d326..955db06dddae3 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md @@ -26,32 +26,34 @@ under the License. ## 描述 +将给定 `map` 的值提取成一个对应类型的 `ARRAY` + ## 语法 -`ARRAY map_values(Map map)` +```sql +MAP_VALUES() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 输入的 map 内容 | + +## 返回值 将给定 `map` 的值提取成一个对应类型的 `ARRAY` ## 举例 ```sql -mysql> select map_values(map(1, "100", 0.1, 2)); -+---------------------------------------------------------------------------------------------------+ -| map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+---------------------------------------------------------------------------------------------------+ -| ["100", "2"] | -+---------------------------------------------------------------------------------------------------+ -1 row in set (0.12 sec) - -mysql> select map_values(map()); -+-------------------+ -| map_values(map()) | -+-------------------+ -| [] | -+-------------------+ -1 row in set (0.11 sec) +select map_values(map()),map_values(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, VALUES, MAP_VALUES +```text ++-------------------+---------------------------------------------------------------------------------------------------+ +| map_values(map()) | map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-------------------+---------------------------------------------------------------------------------------------------+ +| [] | ["100", "2"] | ++-------------------+---------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map.md index 80124e9a5d8ff..95896922640e5 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map.md @@ -26,32 +26,35 @@ under the License. ## 描述 +使用若干组键值对构造一个特定类型的 `Map` + ## 语法 -`MAP map(K key0, V value0, K key1, V value1, ..., K keyn, V valuen)` +```sql +MAP( , [, , ... ]) +``` -使用若干组键值对构造一个特定类型的 `Map` +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 构造 map 的 key | +| `` | 构造 map 的 value | + +## 返回值 + +返回由若干组键值对构造的特定类型 `Map` ## 举例 ```sql -mysql> select map(1, "100", 0.1, 2); -+---------------------------------------------------------------------------------------+ -| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | -+---------------------------------------------------------------------------------------+ -| {1.0:"100", 0.1:"2"} | -+---------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) - -mysql> select map(1, "100", 0.1, 2)[1]; -+-------------------------------------------------------------------------------------------------------------------------------+ -| element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | -+-------------------------------------------------------------------------------------------------------------------------------+ -| 100 | -+-------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +select map(1, "100", 0.1, 2),map(1, "100", 0.1, 2)[1]; ``` -### Keywords - -MAP +```text ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| {1.0:"100", 0.1:"2"} | 100 | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md index 2220defaba4de..6bac0360a12b1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md @@ -24,38 +24,52 @@ specific language governing permissions and limitations under the License. --> -## ST_Angle_Sphere +## 描述 -### Syntax +计算地球表面两点之间的圆心角,单位为 度。传入的参数分别为 X 点的经度,X 点的纬度,Y 点的经度,Y 点的纬度。 -`DOUBLE ST_Angle_Sphere(DOUBLE x_lng, DOUBLE x_lat, DOUBLE y_lng, DOUBLE y_lat)` +## 语法 -## 描述 +```sql +ST_Angle_Sphere( , , , ) +``` -计算地球表面两点之间的圆心角,单位为 度。传入的参数分别为X点的经度,X点的纬度,Y点的经度,Y点的纬度。 +## 参数 -x_lng 和 y_lng 都是经度数据,合理的取值范围是 [-180, 180]。 +| 参数 | 说明 | +| -- | -- | +| `` | 经度数据,合理的取值范围是 [-180, 180] | +| `` | 经度数据,合理的取值范围是 [-180, 180] | +| `` | 纬度数据,合理的取值范围是 [-90, 90] | +| `` | 纬度数据,合理的取值范围是 [-90, 90] | -x_lat 和 y_lat 都是纬度数据,合理的取值范围是 [-90, 90]。 +## 返回值 + +两点之间的圆心角角度 ## 举例 +```sql +select ST_Angle_Sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); ``` -mysql> select ST_Angle_Sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); + +```text +---------------------------------------------------------------------------+ | st_angle_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219) | +---------------------------------------------------------------------------+ | 0.0659823452409903 | +---------------------------------------------------------------------------+ -1 row in set (0.06 sec) +``` + +```sql +select ST_Angle_Sphere(0, 0, 45, 0); +``` -mysql> select ST_Angle_Sphere(0, 0, 45, 0); +```text +----------------------------------------+ | st_angle_sphere(0.0, 0.0, 45.0, 0.0) | +----------------------------------------+ | 45 | +----------------------------------------+ -1 row in set (0.06 sec) ``` -### keywords -ST_ANGLE_SPHERE,ST,ANGLE,SPHERE + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md index d43d4f73410e3..7d18f1b8204bf 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md @@ -24,66 +24,94 @@ specific language governing permissions and limitations under the License. --> -## ST_Angle +## 描述 -### Syntax +输入三个点,它们表示两条相交的线。返回这些线之间的夹角。 -`DOUBLE ST_Angle(GEOPOINT point1, GEOPOINT point2, GEOPOINT point3)` +## 语法 -## 描述 +```sql +ST_Angle( , , ) +``` + +## 参数 + +| 参数 | 说明 | +|----------|--------------------------| +| `` | 第一条直线的第一个端点 | +| `` | 第一条直线的第二个端点且是第二条直线的第一个端点 | +| `` | 第二条直线的第二个端点 | -输入三个点,它们表示两条相交的线。返回这些线之间的夹角。点 2 和点 1 表示第一条线,点 2 和点 3 表示第二条线。这些线之间的夹角以弧度表示,范围为 [0, 2pi)。夹角按顺时针方向从第一条线开始测量,直至第二条线。 +## 返回值 + +这些线之间的夹角以弧度表示,范围为 [0, 2pi)。夹角按顺时针方向从第一条线开始测量,直至第二条线。 ST_ANGLE 存在以下边缘情况: -* 如果点 2 和点 3 相同,则返回 NULL。 -* 如果点 2 和点 1 相同,则返回 NULL。 -* 如果点 2 和点 3 是完全对映点,则返回 NULL。 -* 如果点 2 和点 1 是完全对映点,则返回 NULL。 -* 如果任何输入地理位置不是单点或为空地理位置,则会抛出错误。 +- 如果点 2 和点 3 相同,则返回 NULL。 +- 如果点 2 和点 1 相同,则返回 NULL。 +- 如果点 2 和点 3 是完全对映点,则返回 NULL。 +- 如果点 2 和点 1 是完全对映点,则返回 NULL。 +- 如果任何输入地理位置不是单点或为空地理位置,则会抛出错误。 ## 举例 +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1)); ``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1)); + +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------------------------+ | 4.71238898038469 | +----------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1)); +``` -mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1)); +```text +----------------------------------------------------------------------+ | st_angle(st_point(0.0, 0.0), st_point(1.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------------------------+ | 0.78547432161873854 | +----------------------------------------------------------------------+ -1 row in set (0.02 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0)); +``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0)); +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(1.0, 0.0)) | +----------------------------------------------------------------------+ | 0 | +----------------------------------------------------------------------+ -1 row in set (0.02 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 0)); +``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 0)); +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 0.0)) | +----------------------------------------------------------------------+ | NULL | +----------------------------------------------------------------------+ -1 row in set (0.03 sec) +``` -mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(-30, 0),ST_Point(150, 0)); +```sql +SELECT ST_Angle(ST_Point(0, 0),ST_Point(-30, 0),ST_Point(150, 0)); +``` + +```text +--------------------------------------------------------------------------+ | st_angle(st_point(0.0, 0.0), st_point(-30.0, 0.0), st_point(150.0, 0.0)) | +--------------------------------------------------------------------------+ | NULL | +--------------------------------------------------------------------------+ -1 row in set (0.02 sec) -``` -### keywords -ST_ANGLE,ST,ANGLE +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md index 7f3b0da7f28e4..ebb22dd79b48e 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md @@ -24,45 +24,63 @@ specific language governing permissions and limitations under the License. --> -## ST_AsBinary - -### Syntax - -`VARCHAR ST_AsBinary(GEOMETRY geo)` - ## 描述 将一个几何图形转化为一个标准 WKB(Well-known binary)的表示形式。 目前支持对几何图形是:Point, LineString, Polygon。 +## 语法 + +```sql +ST_AsBinary( ) +``` + +## 参数 + +| 参数 | 说明 | +| -- |----------| +| `` | 需要被转换的图形 | + +## 返回值 + +该几何图形的 WKB 表示形式: + ## 举例 +```sql +select ST_AsBinary(st_point(24.7, 56.7)); ``` -mysql> select ST_AsBinary(st_point(24.7, 56.7)); + +```text +----------------------------------------------+ | st_asbinary(st_point(24.7, 56.7)) | +----------------------------------------------+ | \x01010000003333333333b338409a99999999594c40 | +----------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> select ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); +```sql +select ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); +``` + +```text +--------------------------------------------------------------------------------------+ | st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +--------------------------------------------------------------------------------------+ | \x010200000002000000000000000000f03f000000000000f03f00000000000000400000000000000040 | +--------------------------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` -mysql> select ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")); +```sql +select ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")); +``` + +```text +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')) | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | \x01030000000100000006000000f3380ce6af865c402d05a4fd0f8c364041ef8d2100865c403049658a398c3640b9fb1c1f2d865c409d9b36e334883640de921cb0ab865c40cf876709328a36402cefaa07cc865c407b319413ed8a3640f3380ce6af865c402d05a4fd0f8c3640 | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.02 sec) - ``` -### keywords -ST_ASBINARY,ST,ASBINARY + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md index f86ba99a2846c..9346e7acf70df 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_AsText,ST_AsWKT ## 描述 + +将一个几何图形转化为 WKT(Well Known Text)的表示形式 + ## 语法 -`VARCHAR ST_AsText(GEOMETRY geo)` +```sql +ST_AsText( ) +``` + +# 参数 + +| 参数 | 说明 | +| -- |----------| +| `` | 待转换的几何图形 | +## 返回值 -将一个几何图形转化为WKT(Well Known Text)的表示形式 +该几何图形的 WKT 表示形式 ## 举例 +```sql +SELECT ST_AsText(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_AsText(ST_Point(24.7, 56.7)); + +```text +---------------------------------+ | st_astext(st_point(24.7, 56.7)) | +---------------------------------+ | POINT (24.7 56.7) | +---------------------------------+ ``` -### keywords -ST_ASTEXT,ST_ASWKT,ST,ASTEXT,ASWKT diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md index c04d57a205ae3..da2a98caa76d7 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md @@ -24,64 +24,84 @@ specific language governing permissions and limitations under the License. --> -## ST_Azimuth +## 描述 -### Syntax +输入两个点,并返回由点 1 和点 2 形成的线段的方位角。方位角是点 1 的真北方向线与点 1 和点 2 形成的线段之间的角的弧度。 -`DOUBLE ST_Azimuth(GEOPOINT point1, GEOPOINT point2)` +## 语法 -## 描述 +```sql +ST_Azimuth( , ) +``` +## 参数 -输入两个点,并返回由点 1 和点 2 形成的线段的方位角。方位角是点 1 的真北方向线与点 1 和点 2 形成的线段之间的角的弧度。 +| 参数 | 说明 | +|----------|--------------| +| `` | 用于计算方位角的第一个点 | +| `` | 用于计算方位角的第二个点 | -正角在球面上按顺时针方向测量。 例如,线段的方位角: +## 返回值 -* 指北是 0 -* 指东是 PI/2 -* 指南是 PI -* 指西是 3PI/2 +正角在球面上按顺时针方向测量。例如,线段的方位角: + +- 指北是 0 +- 指东是 PI/2 +- 指南是 PI +- 指西是 3PI/2 ST_Azimuth 存在以下边缘情况: -* 如果两个输入点相同,则返回 NULL。 -* 如果两个输入点是完全对映点,则返回 NULL。 -* 如果任一输入地理位置不是单点或为空地理位置,则会抛出错误。 +- 如果两个输入点相同,则返回 NULL。 +- 如果两个输入点是完全对映点,则返回 NULL。 +- 如果任一输入地理位置不是单点或为空地理位置,则会抛出错误。 ## 举例 +```sql +SELECT st_azimuth(ST_Point(1, 0),ST_Point(0, 0)); ``` -mysql> SELECT st_azimuth(ST_Point(1, 0),ST_Point(0, 0)); + +```text +----------------------------------------------------+ | st_azimuth(st_point(1.0, 0.0), st_point(0.0, 0.0)) | +----------------------------------------------------+ | 4.71238898038469 | +----------------------------------------------------+ -1 row in set (0.03 sec) +``` + +```sql +SELECT st_azimuth(ST_Point(0, 0),ST_Point(1, 0)); +``` -mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(1, 0)); +```text +----------------------------------------------------+ | st_azimuth(st_point(0.0, 0.0), st_point(1.0, 0.0)) | +----------------------------------------------------+ | 1.5707963267948966 | +----------------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(0, 1)); +```sql +SELECT st_azimuth(ST_Point(0, 0),ST_Point(0, 1)); +``` + +```text +----------------------------------------------------+ | st_azimuth(st_point(0.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------+ | 0 | +----------------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> SELECT st_azimuth(ST_Point(-30, 0),ST_Point(150, 0)); +```sql +SELECT st_azimuth(ST_Point(-30, 0),ST_Point(150, 0)); +``` + +```text +--------------------------------------------------------+ | st_azimuth(st_point(-30.0, 0.0), st_point(150.0, 0.0)) | +--------------------------------------------------------+ | NULL | +--------------------------------------------------------+ -1 row in set (0.02 sec) - ``` -### keywords -ST_AZIMUTH,ST,AZIMUTH + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md index 3ce013929a449..ff8ae0d148635 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md @@ -24,25 +24,40 @@ specific language governing permissions and limitations under the License. --> -## ST_Circle ## 描述 + +将一个 WKT(Well Known Text)转化为地球球面上的一个圆。 + ## 语法 -`GEOMETRY ST_Circle(DOUBLE center_lng, DOUBLE center_lat, DOUBLE radius)` +```sql +ST_Circle( , , ) +``` +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 圆心的经度 | +| `` | 圆心的纬度 | +| `` | 圆的半径 | +- radius 单位是米,最大支持 9999999 -将一个WKT(Well Known Text)转化为地球球面上的一个圆。其中`center_lng`表示的圆心的经度, -`center_lat`表示的是圆心的纬度,`radius`表示的是圆的半径,单位是米,最大支持9999999 +## 返回值 + +根据圆的基本信息得到的球面上的一个圆 ## 举例 +```sql +SELECT ST_AsText(ST_Circle(111, 64, 10000)); ``` -mysql> SELECT ST_AsText(ST_Circle(111, 64, 10000)); + +```text +--------------------------------------------+ | st_astext(st_circle(111.0, 64.0, 10000.0)) | +--------------------------------------------+ | CIRCLE ((111 64), 10000) | +--------------------------------------------+ ``` -### keywords -ST_CIRCLE,ST,CIRCLE + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md index a13d683fbb3ac..045575c2b24ce 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md @@ -24,31 +24,52 @@ specific language governing permissions and limitations under the License. --> -## ST_Contains ## 描述 + +判断几何图形 shape1 是否完全能够包含几何图形 shape2 + ## 语法 -`BOOL ST_Contains(GEOMETRY shape1, GEOMETRY shape2)` +```sql +ST_Contains( , ) +``` + +## 参数 + +| 参数 | 说明 | +|----------|------------------------| +| `` | 传入的几何图形,用于判断是否包含 shape2 | +| `` | 传入的几何图形,用于判断是被 shape1 包含 | + +## 返回值 +返回 1:shape1 图形可包含图形 shape2 + +返回 0:shape1 图形不可包含图形 shape2 -判断几何图形shape1是否完全能够包含几何图形shape2 ## 举例 +```sql +SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(5, 5)); ``` -mysql> SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(5, 5)); + +```text +----------------------------------------------------------------------------------------+ | st_contains(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'), st_point(5.0, 5.0)) | +----------------------------------------------------------------------------------------+ | 1 | +----------------------------------------------------------------------------------------+ +``` + +```sql +SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(50, 50)); +``` -mysql> SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(50, 50)); +```text +------------------------------------------------------------------------------------------+ | st_contains(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'), st_point(50.0, 50.0)) | +------------------------------------------------------------------------------------------+ | 0 | +------------------------------------------------------------------------------------------+ ``` -### keywords -ST_CONTAINS,ST,CONTAINS diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md index 98b520c066986..a1b787cd00a83 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md @@ -24,27 +24,40 @@ specific language governing permissions and limitations under the License. --> -## ST_Distance_Sphere ## 描述 + +计算地球两点之间的球面距离,单位为 米。传入的参数分别为 X 点的经度,X 点的纬度,Y 点的经度,Y 点的纬度。 + ## 语法 -`DOUBLE ST_Distance_Sphere(DOUBLE x_lng, DOUBLE x_lat, DOUBLE y_lng, DOUBLE y_lat)` +```sql +ST_Distance_Sphere( , , , ) +``` + +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 经度数据,合理的取值范围是 [-180, 180] | +| `` | 经度数据,合理的取值范围是 [-180, 180] | +| `` | 纬度数据,合理的取值范围是 [-90, 90] | +| `` | 纬度数据,合理的取值范围是 [-90, 90] | -计算地球两点之间的球面距离,单位为 米。传入的参数分别为X点的经度,X点的纬度,Y点的经度,Y点的纬度。 +## 返回值 -x_lng 和 y_lng 都是经度数据,合理的取值范围是 [-180, 180]。 -x_lat 和 y_lat 都是纬度数据,合理的取值范围是 [-90, 90]。 +两点之间的球面距离 ## 举例 +```sql +select st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); ``` -mysql> select st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); + +```text +----------------------------------------------------------------------------+ | st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219) | +----------------------------------------------------------------------------+ | 7336.9135549995917 | +----------------------------------------------------------------------------+ ``` -### keywords -ST_DISTANCE_SPHERE,ST,DISTANCE,SPHERE + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md index 81678f1834136..2cac6a62c1d57 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md @@ -24,24 +24,35 @@ specific language governing permissions and limitations under the License. --> -## ST_GeometryFromText,ST_GeomFromText ## 描述 + +将一个线型 WKT(Well Known Text)转化为对应的内存的几何形式 + ## 语法 -`GEOMETRY ST_GeometryFromText(VARCHAR wkt)` +```sql +ST_GeometryFromText( ) +``` +## 参数 + +| 参数 | 说明 | +|-------|---------| +| `` | 图形的内存形式 | +## 返回值 -将一个WKT(Well Known Text)转化为对应的内存的几何形式 +WKB 的对应的几何存储形式 ## 举例 +```sql +SELECT ST_AsText(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); ``` -mysql> SELECT ST_AsText(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); + +```text +---------------------------------------------------------+ | st_astext(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +---------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +---------------------------------------------------------+ -``` -### keywords -ST_GEOMETRYFROMTEXT,ST_GEOMFROMTEXT,ST,GEOMETRYFROMTEXT,GEOMFROMTEXT +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md index 5ddf12fe985bb..0345e42416f79 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md @@ -24,59 +24,83 @@ specific language governing permissions and limitations under the License. --> -## ST_GeometryFromWKB,ST_GeomFromWKB +## 描述 -### Syntax +将一个标准图形 WKB(Well-known binary)转化为对应的内存的几何形式 -`GEOMETRY ST_GeometryFromWKB(VARCHAR WKB)` +## 语法 -## 描述 +```sql +ST_GeometryFromWKB( ) +``` +## 参数 + +| 参数 | 说明 | +|---------|---------| +| `` | 图形的内存形式 | + +## 返回值 -将一个标准 WKB(Well-known binary)转化为对应的内存的几何形式 +WKB 的对应的几何存储形式 ## 举例 +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); ``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); + +```text +------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_point(24.7, 56.7)))) | +------------------------------------------------------------------+ | POINT (24.7 56.7) | +------------------------------------------------------------------+ -1 row in set (0.05 sec) +``` -mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); +```sql +select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); +``` + +```text +--------------------------------------------------------------+ | st_astext(st_geomfromwkb(st_asbinary(st_point(24.7, 56.7)))) | +--------------------------------------------------------------+ | POINT (24.7 56.7) | +--------------------------------------------------------------+ -1 row in set (0.03 sec) +``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")))); +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")))); +``` + +```text +------------------------------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')))) | +------------------------------------------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +------------------------------------------------------------------------------------------+ -1 row in set (0.06 sec) +``` + +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +```text +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) +``` + +```sql +select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +``` -mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +```text +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_astext(st_geomfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) | +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) | +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) - ``` -### keywords -ST_GEOMETRYFROMWKB,ST_GEOMFROMWKB,ST,GEOMETRYFROMWKB,GEOMFROMWKB,WKB diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md index 2a41e25f2641c..74b3cba1b711c 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_LineFromText,ST_LineStringFromText ## 描述 + +将一个 WKT(Well Known Text)转化为一个 Line 形式的内存表现形式 + ## 语法 -`GEOMETRY ST_LineFromText(VARCHAR wkt)` +```sql +ST_LineFromText( ) +``` + +## 参数 +| 参数 | 说明 | +|-----|------------| +| `` | 由两个坐标组成的线段 | -将一个WKT(Well Known Text)转化为一个Line形式的内存表现形式 +## 返回值 + +线段的内存形式。 ## 举例 +```sql +SELECT ST_AsText(ST_LineFromText("LINESTRING (1 1, 2 2)")); ``` -mysql> SELECT ST_AsText(ST_LineFromText("LINESTRING (1 1, 2 2)")); + +```text +---------------------------------------------------------+ | st_astext(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +---------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +---------------------------------------------------------+ -``` -### keywords -ST_LINEFROMTEXT,ST_LINESTRINGFROMTEXT,ST,LINEFROMTEXT,LINESTRINGFROMTEXT +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md index c33eb4b733648..4370a57998dc9 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md @@ -24,25 +24,38 @@ specific language governing permissions and limitations under the License. --> -## ST_Point ## 描述 + +通过给定的 X 坐标值,Y 坐标值返回对应的 Point。 + +当前这个值只是在球面集合上有意义,X/Y 对应的是经度/纬度 (longitude/latitude); + ## 语法 -`POINT ST_Point(DOUBLE x, DOUBLE y)` +```sql +ST_Point( , ) +``` +## 参数 +| 参数 | 说明 | +|-----|-----| +| `` | 横坐标 | +| `` | 纵坐标 | -通过给定的X坐标值,Y坐标值返回对应的Point。 -当前这个值只是在球面集合上有意义,X/Y对应的是经度/纬度(longitude/latitude); +## 返回值 + +给定横坐标以及纵坐标对应的位置信息 ## 举例 +```sql +SELECT ST_AsText(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_AsText(ST_Point(24.7, 56.7)); + +```text +---------------------------------+ | st_astext(st_point(24.7, 56.7)) | +---------------------------------+ | POINT (24.7 56.7) | +---------------------------------+ -``` -### keywords -ST_POINT,ST,POINT +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md index bac2ef264de1e..50c9a24800fc7 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_Polygon,ST_PolyFromText,ST_PolygonFromText ## 描述 + +将一个 WKT(Well Known Text)转化为对应的多边形内存形式 + ## 语法 -`GEOMETRY ST_Polygon(VARCHAR wkt)` +```sql +ST_Polygon( ) +``` + +## 参数 +| 参数 | 说明 | +|------|--------------------| +| `` | 由 POLYGON 函数生成的一个多边形 | -将一个WKT(Well Known Text)转化为对应的多边形内存形式 +## 返回值 + +多边形的内存形式。 ## 举例 +```sql +SELECT ST_AsText(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))")); ``` -mysql> SELECT ST_AsText(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))")); + +```text +------------------------------------------------------------------+ | st_astext(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))')) | +------------------------------------------------------------------+ | POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0)) | +------------------------------------------------------------------+ -``` -### keywords -ST_POLYGON,ST_POLYFROMTEXT,ST_POLYGONFROMTEXT,ST,POLYGON,POLYFROMTEXT,POLYGONFROMTEXT +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md index de572bdb3dc12..331cb096ab595 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_X + ## 描述 + +当 point 是一个合法的 POINT 类型时,返回对应的 X 坐标值 + ## 语法 -`DOUBLE ST_X(POINT point)` +```sql +ST_X( ) +``` +## 参数 +| 参数 | 说明 | +|------|----------| +| `` | 二维点的几何坐标 | -当point是一个合法的POINT类型时,返回对应的X坐标值 +## 返回值 + +几何坐标中的 X 值 ## 举例 +```sql +SELECT ST_X(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_X(ST_Point(24.7, 56.7)); + +```text +----------------------------+ | st_x(st_point(24.7, 56.7)) | +----------------------------+ | 24.7 | +----------------------------+ -``` -### keywords -ST_X,ST,X +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md index c452a7a1464e7..0776ba10b4a70 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md @@ -24,24 +24,35 @@ specific language governing permissions and limitations under the License. --> -## ST_Y ## 描述 + +当 point 是一个合法的 POINT 类型时,返回对应的 Y 坐标值 + ## 语法 -`DOUBLE ST_Y(POINT point)` +```sql +ST_Y( ) +``` +## 参数 + +| 参数 | 说明 | +|------|----------| +| `` | 二维点的几何坐标 | +## 返回值 -当point是一个合法的POINT类型时,返回对应的Y坐标值 +几何坐标中的 Y 值 ## 举例 +```sql +SELECT ST_Y(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_Y(ST_Point(24.7, 56.7)); + +```text +----------------------------+ -| st_y(st_point(24.7, 56.7)) | +| st_x(st_point(24.7, 56.7)) | +----------------------------+ -| 56.7 | +| 24.7 | +----------------------------+ -``` -### keywords -ST_Y,ST,Y +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/compute-storage-decoupled/managing-storage-vault.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/compute-storage-decoupled/managing-storage-vault.md index 76b1e1e6947b3..b23a6bf68efc0 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/compute-storage-decoupled/managing-storage-vault.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/compute-storage-decoupled/managing-storage-vault.md @@ -40,35 +40,36 @@ PROPERTIES ### 创建 HDFS Storage Vault -创建基于 HDFS 的存算分离模式 Doris 集群,需要确保所有的节点(包括 FE / BE 节点、Meta Service) 均有权限访问所指定的 HDFS,包括提前完成机器的 Kerberos 授权配置和连通性检查(可在对应的每个节点上使用 Hadoop Client 进行测试)等。 +创建基于 HDFS 的存算分离模式 Doris 集群,需要确保所有的节点 (包括 FE / BE 节点、Meta Service) 均有权限访问所指定的 HDFS,包括提前完成机器的 Kerberos 授权配置和连通性检查(可在对应的每个节点上使用 Hadoop Client 进行测试)等。 ```sql -CREATE STORAGE VAULT IF NOT EXISTS ssb_hdfs_vault - PROPERTIES ( - "type"="hdfs", -- required - "fs.defaultFS"="hdfs://127.0.0.1:8020", -- required - "path_prefix"="big/data", -- optional, 一般按照业务名称填写 - "hadoop.username"="user" -- optional - "hadoop.security.authentication"="kerberos" -- optional - "hadoop.kerberos.principal"="hadoop/127.0.0.1@XXX" -- optional - "hadoop.kerberos.keytab"="/etc/emr.keytab" -- optional - ); +CREATE STORAGE VAULT IF NOT EXISTS hdfs_vault_demo +PROPERTIES ( + "type" = "hdfs", -- required + "fs.defaultFS" = "hdfs://127.0.0.1:8020", -- required + "path_prefix" = "big/data", -- optional, 一般按照业务名称填写 + "hadoop.username" = "user" -- optional + "hadoop.security.authentication" = "kerberos" -- optional + "hadoop.kerberos.principal" = "hadoop/127.0.0.1@XXX" -- optional + "hadoop.kerberos.keytab" = "/etc/emr.keytab" -- optional +); ``` ### 创建 S3 Storage Vault ```SQL -CREATE STORAGE VAULT IF NOT EXISTS ssb_s3_vault - PROPERTIES ( - "type"="S3", -- required - "s3.endpoint" = "oss-cn-beijing.aliyuncs.com", -- required - "s3.region" = "bj", -- required - "s3.bucket" = "bucket", -- required - "s3.root.path" = "big/data/prefix", -- required - "s3.access_key" = "ak", -- required - "s3.secret_key" = "sk", -- required - "provider" = "OSS" -- required - ); +CREATE STORAGE VAULT IF NOT EXISTS s3_vault_demo +PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "oss-cn-beijing.aliyuncs.com", -- required + "s3.region" = "cn-beijing", -- required + "s3.bucket" = "bucket", -- required + "s3.root.path" = "big/data/prefix", -- required + "s3.access_key" = "ak", -- required + "s3.secret_key" = "sk", -- required + "provider" = "OSS", -- required + "use_path_style" = "false" -- optional +); ``` 更多参数说明及示例可见 [CREATE-STORAGE-VAULT](../sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT.md)。 @@ -110,8 +111,8 @@ CREATE TABLE IF NOT EXISTS supplier ( UNIQUE KEY (s_suppkey) DISTRIBUTED BY HASH(s_suppkey) BUCKETS 1 PROPERTIES ( -"replication_num" = "1", -"storage_vault_name" = "ssb_hdfs_vault" + "replication_num" = "1", + "storage_vault_name" = "hdfs_demo_vault" ); ``` @@ -171,7 +172,7 @@ GRANT 仅 Admin 用户有权限执行 `GRANT` 语句,该语句用于向 User / Role 授予指定 Storage Vault 的权限。拥有某个 Storage Vault 的 `USAGE_PRIV` 权限的 User / Role 可进行以下操作: -- 通过 `SHOW STORAGE VAULT` 查看该 Storage Vault 的信息; +- 通过 `SHOW STORAGE VAULTS` 查看该 Storage Vault 的信息; - 建表时在 `PROPERTIES` 中指定使用该 Storage Vault 。 ### 撤销 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/data-operate/import/data-source/kafka.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/data-operate/import/data-source/kafka.md index cb1b29c1a4725..091e577fa4c43 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/data-operate/import/data-source/kafka.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/data-operate/import/data-source/kafka.md @@ -191,7 +191,7 @@ Doris Kafka Connector 是将 Kafka 数据流导入 Doris 数据库的工具。 2. 配置 `config/connect-distributed.properties`: ```Bash -# 修改 broker 地址 +# 修改 kafka server 地址 bootstrap.servers=127.0.0.1:9092 # 修改 group.id,同一集群的需要一致 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/ecosystem/doris-kafka-connector.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/ecosystem/doris-kafka-connector.md index 4b11da343de25..0e4032dff1eb4 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/ecosystem/doris-kafka-connector.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/ecosystem/doris-kafka-connector.md @@ -99,7 +99,7 @@ $KAFKA_HOME/bin/connect-standalone.sh -daemon $KAFKA_HOME/config/connect-standal 配置 config/connect-distributed.properties ```properties -# 修改 broker 地址 +# 修改 kafka server 地址 bootstrap.servers=127.0.0.1:9092 # 修改 group.id,同一集群的需要一致 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/gettingStarted/what-is-apache-doris.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/gettingStarted/what-is-apache-doris.md index fa9f8dc01b2f8..5bb1c831ec60d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/gettingStarted/what-is-apache-doris.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/gettingStarted/what-is-apache-doris.md @@ -83,7 +83,7 @@ FE 与 BE 进程都是可以横向扩展的,单集群可以支持到数百台 - 存储层:存储层可以使用 S3、HDFS、OSS、COS、OBS、Minio、Ceph 等共享存储存放 Doris 的数据文件,包含包括 Segment 文件、反向索引的索引文件等。 -![存算分离整体架构和技术特点](/images/getting-started/apache-doris-technical-compute-storage-decouple-overview.png) +![存算分离整体架构和技术特点](/images/getting-started/apache-doris-technical-compute-storage-decouple-overview.jpg) ## Apache Doris 的核心特性 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/releasenotes/v1.1/release-1.1.0.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/releasenotes/v1.1/release-1.1.0.md index 0e4f3961e3c31..ff11843f2b632 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/releasenotes/v1.1/release-1.1.0.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/releasenotes/v1.1/release-1.1.0.md @@ -89,11 +89,11 @@ Iceberg 外部表为 Apache Doris 提供了直接访问存储在 Iceberg 数据 - 在 TPC-H 测试数据集的全部 22 个 SQL 上,1.1 版本均优于 0.15 版本,整体性能约提升了 4.5 倍,部分场景性能达到了十余倍的提升; -![](/images/release-note-1.1.0-SSB.png) +![release-note-1.1.0-SSB](/images/release-note-1.1.0-SSB.png)

SSB 测试数据集

-![](/images/release-note-1.1.0-TPC-H.png) +![release-note-1.1.0-TPC-H](/images/release-note-1.1.0-TPC-H.png)

TPC-H 测试数据集

diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/group-concat.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/group-concat.md index 0fd25a72e2dba..ff40fa49751ff 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/group-concat.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/group-concat.md @@ -24,25 +24,37 @@ specific language governing permissions and limitations under the License. --> -## group_concat + ## 描述 + +GROUP_CONCAT 函数将结果集中的多行结果连接成一个字符串 + ## 语法 -`VARCHAR GROUP_CONCAT([DISTINCT] VARCHAR str[, VARCHAR sep] [ORDER BY { col_name | expr} [ASC | DESC]])` +```sql +GROUP_CONCAT([DISTINCT] [, ] [ORDER BY { | } [ASC | DESC]]) +``` +## 参数 -该函数是类似于 sum() 的聚合函数,group_concat 将结果集中的多行结果连接成一个字符串。第二个参数 sep 为字符串之间的连接符号,该参数可以省略。该函数通常需要和 group by 语句一起使用。 +| 参数 | 说明 | +| -- | -- | +| `` | 必选。需要连接值的表达式 | +| `` | 可选。字符串之间的连接符号 | +| `` | 可选。用于指定排序的列 | +| `` | 可选。用于指定排序的表达式 | -支持Order By进行多行结果的排序,排序和聚合列可不同。 +## 返回值 -:::caution -`group_concat`暂不支持`distinct`和`order by`一起用。 -::: +返回 VARCHAR 类型的数值。 ## 举例 +```sql +select value from test; ``` -mysql> select value from test; + +```text +-------+ | value | +-------+ @@ -51,35 +63,52 @@ mysql> select value from test; | c | | c | +-------+ +``` + +```sql +select GROUP_CONCAT(value) from test; +``` -mysql> select GROUP_CONCAT(value) from test; +```text +-----------------------+ | GROUP_CONCAT(`value`) | +-----------------------+ -| a, b, c, c | +| a, b, c, c | +-----------------------+ +``` -mysql> select GROUP_CONCAT(DISTINCT value) from test; +```sql +select GROUP_CONCAT(DISTINCT value) from test; +``` + +```text +-----------------------+ | GROUP_CONCAT(`value`) | +-----------------------+ | a, b, c | +-----------------------+ +``` + +```sql +select GROUP_CONCAT(value, " ") from test; +``` -mysql> select GROUP_CONCAT(value, " ") from test; +```text +----------------------------+ | GROUP_CONCAT(`value`, ' ') | +----------------------------+ | a b c c | +----------------------------+ +``` + +```sql +select GROUP_CONCAT(value, NULL) from test; +``` -mysql> select GROUP_CONCAT(value, NULL) from test; +```text +----------------------------+ | GROUP_CONCAT(`value`, NULL)| +----------------------------+ | NULL | +----------------------------+ ``` - -### keywords -GROUP_CONCAT,GROUP,CONCAT diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/histogram.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/histogram.md index e02ef61b695e6..6a7303152c8ee 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/histogram.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/histogram.md @@ -24,31 +24,53 @@ specific language governing permissions and limitations under the License. --> -## HISTOGRAM + ## 描述 + +HISTOGRAM(直方图)函数用于描述数据分布情况,它使用“等高”的分桶策略,并按照数据的值大小进行分桶,并用一些简单的数据来描述每个桶,比如落在桶里的值的个数。 + +## 别名 + +HIST + ## 语法 -`histogram(expr[, INT num_buckets])` +```sql +HISTOGRAM([, ]) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `expr` | 需要获取第一个值的表达式 | +| `num_buckets` | 可选。用于限制直方图桶(bucket)的数量,默认值 128 | -histogram(直方图)函数用于描述数据分布情况,它使用“等高”的分桶策略,并按照数据的值大小进行分桶,并用一些简单的数据来描述每个桶,比如落在桶里的值的个数。主要用于优化器进行区间查询的估算。 -函数结果返回空或者 Json 字符串。 +## 返回值 -参数说明: -- num_buckets:可选项。用于限制直方图桶(bucket)的数量,默认值 128。 +返回直方图估算后的 JSON 类型的值。特殊情况: +- 当参数为NULL时,返回 NULL。 -别名函数:`hist(expr[, INT num_buckets])` ## 举例 +```sql +SELECT histogram(c_float) FROM histogram_test; ``` -MySQL [test]> SELECT histogram(c_float) FROM histogram_test; + +```text +-------------------------------------------------------------------------------------------------------------------------------------+ | histogram(`c_float`) | +-------------------------------------------------------------------------------------------------------------------------------------+ | {"num_buckets":3,"buckets":[{"lower":"0.1","upper":"0.1","count":1,"pre_sum":0,"ndv":1},...]} | +-------------------------------------------------------------------------------------------------------------------------------------+ +``` + +```sql +SELECT histogram(c_string, 2) FROM histogram_test; +``` -MySQL [test]> SELECT histogram(c_string, 2) FROM histogram_test; +```text +-------------------------------------------------------------------------------------------------------------------------------------+ | histogram(`c_string`) | +-------------------------------------------------------------------------------------------------------------------------------------+ @@ -58,7 +80,7 @@ MySQL [test]> SELECT histogram(c_string, 2) FROM histogram_test; 查询结果说明: -``` +```json { "num_buckets": 3, "buckets": [ @@ -87,6 +109,7 @@ MySQL [test]> SELECT histogram(c_string, 2) FROM histogram_test; } ``` +```text 字段说明: - num_buckets:桶的数量 - buckets:直方图所包含的桶 @@ -97,7 +120,4 @@ MySQL [test]> SELECT histogram(c_string, 2) FROM histogram_test; - ndv:桶内不同值的个数 > 直方图总的元素数量 = 最后一个桶的元素数量(count)+ 前面桶的元素总量(pre_sum)。 - -### keywords - -HISTOGRAM, HIST +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md index 1826b413075ec..2d06c5a0f2d5b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md @@ -24,29 +24,36 @@ specific language governing permissions and limitations under the License. --> -## HLL_UNION_AGG ## 描述 -## 语法 -`HLL_UNION_AGG(hll)` +HLL_UNION_AGG 函数是一种聚合函数,主要用于将多个 HyperLogLog 数据结构合并,估算合并后基数的近似值。 + + +## 语法 +```sql +hll_union_agg() +``` -HLL是基于HyperLogLog算法的工程实现,用于保存HyperLogLog计算过程的中间结果 +## 参数 -它只能作为表的value列类型、通过聚合来不断的减少数据量,以此来实现加快查询的目的 +| 参数 | 说明 | +| -- | -- | +| `` | 需要被计算HyperLogLog类型表达式 | -基于它得到的是一个估算结果,误差大概在1%左右,hll列是通过其它列或者导入数据里面的数据生成的 +## 返回值 -导入的时候通过hll_hash函数来指定数据中哪一列用于生成hll列,它常用于替代count distinct,通过结合rollup在业务上用于快速计算uv等 +返回 BIGINT 类型的基数值。 ## 举例 +```sql +select HLL_UNION_AGG(uv_set) from test_uv; ``` -MySQL > select HLL_UNION_AGG(uv_set) from test_uv;; + +```text +-------------------------+ | HLL_UNION_AGG(`uv_set`) | +-------------------------+ | 17721 | +-------------------------+ ``` -### keywords -HLL_UNION_AGG,HLL,UNION,AGG diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/intersect-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/intersect-count.md index 5d3b8b939f532..c054e126f6dda 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/intersect-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/intersect-count.md @@ -22,35 +22,52 @@ specific language governing permissions and limitations under the License. --> -## intersect_count + ## 描述 + +INTERSECT_COUNT 函数用于计算 Bitmap 数据结构的交集元素的数量。 + ## 语法 -`BITMAP INTERSECT_COUNT(bitmap_column, column_to_filter, filter_values)` -聚合函数,求bitmap交集大小的函数, 不要求数据分布正交 -第一个参数是Bitmap列,第二个参数是用来过滤的维度列,第三个参数是变长参数,含义是过滤维度列的不同取值 +```sql +INTERSECT_COUNT(, , ) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 需要获取第一个值的表达式 | +| `` | 可选。需要进行过滤的维度列 | +| `` | 可选。过滤维度列的不同取值 | + +## 返回值 + +返回 BIGINT 类型的值。 ## 举例 +```sql +select dt,bitmap_to_string(user_id) from pv_bitmap where dt in (3,4); ``` -MySQL [test_query_qa]> select dt,bitmap_to_string(user_id) from pv_bitmap where dt in (3,4); + +```text +------+-----------------------------+ | dt | bitmap_to_string(`user_id`) | +------+-----------------------------+ -| 4 | 1,2,3 | -| 3 | 1,2,3,4,5 | +| 4 | 1,2,3 | +| 3 | 1,2,3,4,5 | +------+-----------------------------+ -2 rows in set (0.012 sec) +``` -MySQL [test_query_qa]> select intersect_count(user_id,dt,3,4) from pv_bitmap; +```sql +select intersect_count(user_id,dt,3,4) from pv_bitmap; +``` + +```text +----------------------------------------+ | intersect_count(`user_id`, `dt`, 3, 4) | +----------------------------------------+ | 3 | +----------------------------------------+ -1 row in set (0.014 sec) ``` - -### keywords - - INTERSECT_COUNT,BITMAP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/kurt.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/kurt.md index ed4aad61341cd..c027c193bd5cc 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/kurt.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/kurt.md @@ -26,41 +26,65 @@ under the License. ## 描述 -kurtosis 返回 expr 表达式的[峰度值](https://en.wikipedia.org/wiki/Kurtosis)。此函数使用的公式为 第四阶中心矩 / (方差的平方) - 3,当方差为零时,kurtosis 将返回 NULL。 +KURTOSIS 函数用于计算数据的[峰度值](https://en.wikipedia.org/wiki/Kurtosis)。此函数使用的公式为 第四阶中心矩 / (方差的平方) - 3。 + +## 别名 + +KURT_POP,KURTOSIS ## 语法 -`kurtosis(expr)` +```sql +KURTOSIS() +``` ## 参数说明 -TinyInt/SmallInt/Integer/BigInt/Float/Double, Decimal 会被 cast 成浮点数参与运算。 +| 参数 | 说明 | +| -- | -- | +| `` | 需要获取值的表达式 | -## 返回值说明 +## 返回值 -`Double` +返回 DOUBLE 类型的值。特殊情况: + +- 当方差为零时,返回 NULL ## 举例 ```sql -create table statistic_test(tag int, val1 double not null, val2 double null) distributed by hash(tag) properties("replication_num"="1"); +select * from statistic_test; +``` -insert into statistic_test values (1, -10, -10),(2, -20, NULL),(3, 100, NULL),(4, 100, NULL),(5, 1000,1000); +```text ++-----+------+------+ +| tag | val1 | val2 | ++-----+------+------+ +| 1 | -10 | -10| +| 2 | -20 | NULL| +| 3 | 100 | NULL| +| 4 | 100 | NULL| +| 5 | 1000 | 1000| ++-----+------+------+ +``` -// NULL 值会被忽略 +```sql select kurt(val1), kurt(val2) from statistic_test; --------------- +``` +```text +-------------------+--------------------+ | kurt(val1) | kurt(val2) | +-------------------+--------------------+ | 0.162124583734851 | -1.3330994719286338 | +-------------------+--------------------+ -1 row in set (0.02 sec) +``` +```sql // 每组只有一行数据,结果为 NULL select kurt(val1), kurt(val2) from statistic_test group by tag; --------------- +``` +```text +------------+------------+ | kurt(val1) | kurt(val2) | +------------+------------+ @@ -70,9 +94,5 @@ select kurt(val1), kurt(val2) from statistic_test group by tag; | NULL | NULL | | NULL | NULL | +------------+------------+ -5 rows in set (0.02 sec) ``` -## 相关命令 - -[skew](./skew.md) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/linear-histogram.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/linear-histogram.md index 42c6348ababdb..ded3196246484 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/linear-histogram.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/linear-histogram.md @@ -24,29 +24,46 @@ specific language governing permissions and limitations under the License. --> -## Description -### Syntax +## 描述 -`LINEAR_HISTOGRAM(expr, DOUBLE interval[, DOUBLE offset)` +LINEAR_HISTOGRAM 函数用于描述数据分布情况,它使用“等宽”的分桶策略,并按照数据的值大小进行分桶。 -linear_histogram 函数用于描述数据分布情况,它使用“等宽”的分桶策略,并按照数据的值大小进行分桶。 +## 语法 -参数说明: +```sql +`LINEAR_HISTOGRAM(, DOUBLE [, DOUBLE )` +``` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `interval` | 必须。桶的宽度 | +| `offset` | 可选。默认为 0,范围是 `[0, interval)` | -- `interval`:必须项。桶的宽度。 -- `offset`:可选项。默认为 0,范围是 `[0, interval)`。 +## 返回值 -## Example +返回计算后的 JSON 类型的值。 +## 举例 + +```sql +select linear_histogram(a, 2) from histogram_test; ``` -mysql> select linear_histogram(a, 2) from histogram_test; + +```text +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | linear_histogram(a, cast(2 as DOUBLE)) | +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | {"num_buckets":6,"buckets":[{"lower":0.0,"upper":2.0,"count":2,"acc_count":2},{"lower":2.0,"upper":4.0,"count":4,"acc_count":6},{"lower":4.0,"upper":6.0,"count":4,"acc_count":10},{"lower":6.0,"upper":8.0,"count":4,"acc_count":14},{"lower":8.0,"upper":10.0,"count":4,"acc_count":18},{"lower":10.0,"upper":12.0,"count":2,"acc_count":20}]} | +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +``` -mysql> select linear_histogram(a, 2, 1) from histogram_test; +```sql +select linear_histogram(a, 2, 1) from histogram_test; +``` + +```text +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | linear_histogram(a, cast(2 as DOUBLE), cast(1 as DOUBLE)) | +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ @@ -54,6 +71,7 @@ mysql> select linear_histogram(a, 2, 1) from histogram_test; +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ``` +```text 字段说明: - `num_buckets`:桶的数量。 @@ -62,8 +80,4 @@ mysql> select linear_histogram(a, 2, 1) from histogram_test; - `upper`:桶的上界。(不包含在内) - `count`:桶内包含的元素数量。 - `acc_count`:前面桶与当前桶元素的累计总量。 - - -## Keywords - -LINEAR_HISTOGRAM \ No newline at end of file +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/map-agg.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/map-agg.md index 8327da387592b..a5ce0daf7d28f 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/map-agg.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/map-agg.md @@ -24,17 +24,32 @@ specific language governing permissions and limitations under the License. --> -## MAP_AGG ## 描述 + +MAP_AGG 函数用于根据多行数据中的键值对形成一个映射结构。 + ## 语法 -`MAP_AGG(expr1, expr2)` +`MAP_AGG(, )` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `` | 用于指定作为键的表达式。 | +| `` | 用于指定作为对应的值的表达式。 | -返回一个 map, 由 expr1 作为键,expr2 作为对应的值。 +## 返回值 + +返回映射后的 MAP 类型的值。 ## 举例 + +```sql +select `n_nationkey`, `n_name`, `n_regionkey` from `nation`; ``` -MySQL > select `n_nationkey`, `n_name`, `n_regionkey` from `nation`; + +```text +-------------+----------------+-------------+ | n_nationkey | n_name | n_regionkey | +-------------+----------------+-------------+ @@ -64,8 +79,13 @@ MySQL > select `n_nationkey`, `n_name`, `n_regionkey` from `nation`; | 23 | UNITED KINGDOM | 3 | | 24 | UNITED STATES | 1 | +-------------+----------------+-------------+ +``` + +```sql +select `n_regionkey`, map_agg(`n_nationkey`, `n_name`) from `nation` group by `n_regionkey`; +``` -MySQL > select `n_regionkey`, map_agg(`n_nationkey`, `n_name`) from `nation` group by `n_regionkey`; +```text +-------------+---------------------------------------------------------------------------+ | n_regionkey | map_agg(`n_nationkey`, `n_name`) | +-------------+---------------------------------------------------------------------------+ @@ -75,8 +95,13 @@ MySQL > select `n_regionkey`, map_agg(`n_nationkey`, `n_name`) from `nation` gro | 4 | {4:"EGYPT", 10:"IRAN", 11:"IRAQ", 13:"JORDAN", 20:"SAUDI ARABIA"} | | 2 | {8:"INDIA", 9:"INDONESIA", 12:"JAPAN", 18:"CHINA", 21:"VIETNAM"} | +-------------+---------------------------------------------------------------------------+ +``` + +```sql +select n_regionkey, map_agg(`n_name`, `n_nationkey` % 5) from `nation` group by `n_regionkey`; +``` -MySQL > select n_regionkey, map_agg(`n_name`, `n_nationkey` % 5) from `nation` group by `n_regionkey`; +```text +-------------+------------------------------------------------------------------------+ | n_regionkey | map_agg(`n_name`, (`n_nationkey` % 5)) | +-------------+------------------------------------------------------------------------+ @@ -87,5 +112,3 @@ MySQL > select n_regionkey, map_agg(`n_name`, `n_nationkey` % 5) from `nation` g | 4 | {"EGYPT":4, "IRAN":0, "IRAQ":1, "JORDAN":3, "SAUDI ARABIA":0} | +-------------+------------------------------------------------------------------------+ ``` -### keywords -MAP_AGG diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/max-by.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/max-by.md index 7c412ebfc0449..41bfcd7756d81 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/max-by.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/max-by.md @@ -24,18 +24,35 @@ specific language governing permissions and limitations under the License. --> -## MAX_BY + ## 描述 + +MAX_BY 函数用于根据指定列的最大值,返回对应的的关联值。 + ## 语法 -`MAX_BY(expr1, expr2)` +```sql +MAX_BY(, ) +``` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `` | 用于指定对应关联的表达式。 | +| `` | 用于指定最大值统计的表达式。 | +## 返回值 -返回与 expr2 的最大值关联的 expr1 的值。 +返回与输入表达式 相同的数据类型。 ## 举例 + +```sql +select * from tbl; ``` -MySQL > select * from tbl; + +```text +------+------+------+------+ | k1 | k2 | k3 | k4 | +------+------+------+------+ @@ -44,13 +61,16 @@ MySQL > select * from tbl; | 4 | 3 | 2 | 1 | | 3 | 4 | 2 | 1 | +------+------+------+------+ +``` + +```sql +select max_by(k1, k4) from tbl; +``` -MySQL > select max_by(k1, k4) from tbl; +```text +--------------------+ | max_by(`k1`, `k4`) | +--------------------+ | 0 | +--------------------+ ``` -### keywords -MAX_BY diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/max.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/max.md index 16bdd21bfd58b..ecf254d4c524e 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/max.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/max.md @@ -24,23 +24,37 @@ specific language governing permissions and limitations under the License. --> -## MAX + ## 描述 + +MAX 函数返回表达式的最大值。 + ## 语法 -`MAX(expr)` +```sql +MAX() +``` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `expr` | 需要获取值的表达式 | +## 返回值 -返回expr表达式的最大值 +返回与输入表达式相同的数据类型。 ## 举例 + +```sql +select max(scan_rows) from log_statis group by datetime; ``` -MySQL > select max(scan_rows) from log_statis group by datetime; + +```text +------------------+ | max(`scan_rows`) | +------------------+ | 4671587 | +------------------+ ``` -### keywords -MAX diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/min-by.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/min-by.md index eceeb6427307f..3ccfa4f885696 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/min-by.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/min-by.md @@ -24,18 +24,34 @@ specific language governing permissions and limitations under the License. --> -## MIN_BY + ## 描述 + +MIN_BY 函数用于根据指定列的最小值,返回对应的的关联值。 + ## 语法 -`MIN_BY(expr1, expr2)` +```sql +MIN_BY(, ) +``` + +## 参数说明 +| 参数 | 说明 | +| -- | -- | +| `` | 用于指定对应关联的表达式。 | +| `` | 用于指定最小值统计的表达式。 | -返回与 expr2 的最小值关联的 expr1 的值。 +## 返回值 + +返回与输入表达式 相同的数据类型。 ## 举例 +```sql +select * from tbl; ``` -MySQL > select * from tbl; + +```text +------+------+------+------+ | k1 | k2 | k3 | k4 | +------+------+------+------+ @@ -44,13 +60,16 @@ MySQL > select * from tbl; | 4 | 3 | 2 | 1 | | 3 | 4 | 2 | 1 | +------+------+------+------+ +``` + +```sql +select min_by(k1, k4) from tbl; +``` -MySQL > select min_by(k1, k4) from tbl; +```text +--------------------+ | min_by(`k1`, `k4`) | +--------------------+ | 4 | +--------------------+ ``` -### keywords -MIN_BY diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/min.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/min.md index b765ab423683b..d4392753fe612 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/min.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/min.md @@ -24,23 +24,36 @@ specific language governing permissions and limitations under the License. --> -## MIN ## 描述 + +MIN 函数返回表达式的最小值。 + ## 语法 -`MIN(expr)` +```sql +MIN(expr) +``` + +## 参数说明 +| 参数 | 说明 | +| -- | -- | +| `expr` | 需要获取值的表达式 | -返回expr表达式的最小值 +## 返回值 + +返回与输入表达式相同的数据类型。 ## 举例 + +```sql +select MIN(scan_rows) from log_statis group by datetime; ``` -MySQL > select min(scan_rows) from log_statis group by datetime; + +```text +------------------+ -| min(`scan_rows`) | +| MIN(`scan_rows`) | +------------------+ | 0 | +------------------+ ``` -### keywords -MIN diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md index 4e3ae39dbbee3..27b5ea423724a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md @@ -1,7 +1,7 @@ --- { -"title": "ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT", -"language": "zh-CN" + "title": "ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT", + "language": "zh-CN" } --- @@ -13,7 +13,9 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -22,19 +24,40 @@ specific language governing permissions and limitations under the License. --> -## orthogonal_bitmap_expr_calculate_count ## 描述 + +ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT 函数返回对 Bitmap 表达式进行交并差计算后集合中的元素数量 + ## 语法 -`BITMAP ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT(bitmap_column, column_to_filter, input_string)` -求表达式bitmap交并差集合计算count函数, 第一个参数是Bitmap列,第二个参数是用来过滤的维度列,即计算的key列,第三个参数是计算表达式字符串,含义是依据key列进行bitmap交并差集表达式计算 -表达式支持的计算符:& 代表交集计算,| 代表并集计算,- 代表差集计算, ^ 代表异或计算,\ 代表转义字符 +```sql +ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT(, , ) +``` -## 举例 +## 参数说明 +| 参数 | 说明 | +| -- | -- | +| `bitmap_column` | 需要获取值的 Bitmap 类型表达式 | +| `column_to_filter` | 过滤的维度列,即计算的 Key 列 | +| `input_string` | 计算表达式字符串,含义是依据 Key 列进行 Bitmap 交并差集表达式计算,表达式支持的计算符:& 代表交集计算,\| 代表并集计算,- 代表差集计算, ^ 代表异或计算,\ 代表转义字符 | + +## 返回值 + +返回 BIGINT 类型的值。 + +## 举例 ```sql select orthogonal_bitmap_expr_calculate_count(user_id, tag, '(833736|999777)&(1308083|231207)&(1000|20000-30000)') from user_tag_bitmap where tag in (833736,999777,130808,231207,1000,20000,30000); -注:1000、20000、30000等整形tag,代表用户不同标签 +注:1000、20000、30000 等整形tag,代表用户不同标签 +``` + +```text ++-----------------------------------------------------------------------------------------------------------------+ +| orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(833736|999777)&(1308083|231207)&(1000|20000-30000)') | ++-----------------------------------------------------------------------------------------------------------------+ +| 1000 | ++-----------------------------------------------------------------------------------------------------------------+ ``` ```sql @@ -42,6 +65,10 @@ select orthogonal_bitmap_expr_calculate_count(user_id, tag, '(A:a/b|B:2\\-4)&(C: 注:'A:a/b', 'B:2-4'等是字符串类型tag,代表用户不同标签, 其中'B:2-4'需要转义成'B:2\\-4' ``` -### keywords - - ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT,BITMAP +```text ++---------------------------------------------------------------------------------------------+ +| orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23') | ++---------------------------------------------------------------------------------------------+ +| 30 | ++---------------------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md index e7405e82e79f4..f3b457bf09e51 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md @@ -1,7 +1,7 @@ --- { -"title": "ORTHOGONAL_BITMAP_EXPR_CALCULATE", -"language": "zh-CN" + "title": "ORTHOGONAL_BITMAP_EXPR_CALCULATE", + "language": "zh-CN" } --- @@ -13,7 +13,9 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -22,26 +24,51 @@ specific language governing permissions and limitations under the License. --> -## orthogonal_bitmap_expr_calculate ## 描述 + +ORTHOGONAL_BITMAP_EXPR_CALCULATE 函数返回对 Bitmap 表达式进行交并差计算后的集合 + ## 语法 -`BITMAP ORTHOGONAL_BITMAP_EXPR_CALCULATE(bitmap_column, column_to_filter, input_string)` -求表达式bitmap交并差集合计算函数, 第一个参数是Bitmap列,第二个参数是用来过滤的维度列,即计算的key列,第三个参数是计算表达式字符串,含义是依据key列进行bitmap交并差集表达式计算 -表达式支持的计算符:& 代表交集计算,| 代表并集计算,- 代表差集计算, ^ 代表异或计算,\ 代表转义字符 +```sql +ORTHOGONAL_BITMAP_EXPR_CALCULATE(, , ) +``` -## 举例 +## 参数说明 +| 参数 | 说明 | +| -- | -- | +| `bitmap_column` | 需要获取值的 Bitmap 类型表达式 | +| `column_to_filter` | 过滤的维度列,即计算的 Key 列 | +| `input_string` | 计算表达式字符串,含义是依据 Key 列进行 Bitmap 交并差集表达式计算,表达式支持的计算符:& 代表交集计算,\| 代表并集计算,- 代表差集计算, ^ 代表异或计算,\ 代表转义字符 | + +## 返回值 + +返回 BITMAP 类型的集合。 + +## 举例 ```sql -select orthogonal_bitmap_expr_calculate(user_id, tag, '(833736|999777)&(1308083|231207)&(1000|20000-30000)') from user_tag_bitmap where tag in (833736,999777,130808,231207,1000,20000,30000); +select bitmap_count(orthogonal_bitmap_expr_calculate(user_id, tag, '(833736|999777)&(1308083|231207)&(1000|20000-30000)')) from user_tag_bitmap where tag in (833736,999777,130808,231207,1000,20000,30000); 注:1000、20000、30000等整形tag,代表用户不同标签 ``` +```text ++-------------------------------------------------------------------------------------------------------------------------------+ +| bitmap_count(orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(833736|999777)&(1308083|231207)&(1000|20000-30000)')) | ++-------------------------------------------------------------------------------------------------------------------------------+ +| 1000 | ++-------------------------------------------------------------------------------------------------------------------------------+ +``` + ```sql -select orthogonal_bitmap_expr_calculate(user_id, tag, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23') from user_str_tag_bitmap where tag in ('A:a/b', 'B:2-4', 'C:1', 'D:12', 'E:23'); +select bitmap_count(orthogonal_bitmap_expr_calculate(user_id, tag, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23')) from user_str_tag_bitmap where tag in ('A:a/b', 'B:2-4', 'C:1', 'D:12', 'E:23'); 注:'A:a/b', 'B:2-4'等是字符串类型tag,代表用户不同标签, 其中'B:2-4'需要转义成'B:2\\-4' ``` -### keywords - - ORTHOGONAL_BITMAP_EXPR_CALCULATE,BITMAP +```text ++-----------------------------------------------------------------------------------------------------------+ +| bitmap_count(orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23')) | ++-----------------------------------------------------------------------------------------------------------+ +| 30 | ++-----------------------------------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md index 7eebc3aa700bc..fac7fbfeb7c9b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md @@ -1,7 +1,7 @@ --- { -"title": "ORTHOGONAL_BITMAP_INTERSECT_COUNT", -"language": "zh-CN" + "title": "ORTHOGONAL_BITMAP_INTERSECT_COUNT", + "language": "zh-CN" } --- @@ -13,7 +13,9 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -21,26 +23,39 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - -## orthogonal_bitmap_intersect_count ## 描述 + +ORTHOGONAL_BITMAP_INTERSECT_COUNT 函数返回对 Bitmap 表达式进行交集计算后集合中的元素数量 + ## 语法 -`BITMAP ORTHOGONAL_BITMAP_INTERSECT_COUNT(bitmap_column, column_to_filter, filter_values)` -求bitmap交集大小的函数, 第一个参数是Bitmap列,第二个参数是用来过滤的维度列,第三个参数是变长参数,含义是过滤维度列的不同取值 +```sql +ORTHOGONAL_BITMAP_INTERSECT_COUNT(, , ) +``` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `bitmap_column` | 需要获取值的 Bitmap 类型表达式 | +| `column_to_filter` | 可选。需要进行过滤的维度列 | +| `filter_values` | 可选。变长参数,用于过滤维度列的不同取值 | + + +## 返回值 + +返回 BIGINT 类型的值。 ## 举例 +```sql +select orthogonal_bitmap_intersect_count(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); ``` -mysql> select orthogonal_bitmap_intersect_count(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); + +```text +-------------------------------------------------------------------------------------+ | orthogonal_bitmap_intersect_count(`members`, `tag_group`, 1150000, 1150001, 390006) | +-------------------------------------------------------------------------------------+ | 0 | +-------------------------------------------------------------------------------------+ -1 row in set (3.382 sec) -``` - -### keywords - - ORTHOGONAL_BITMAP_INTERSECT_COUNT,BITMAP +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md index e6b65df82d2e8..2460c03a4a600 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md @@ -1,7 +1,7 @@ --- { -"title": "ORTHOGONAL_BITMAP_INTERSECT", -"language": "zh-CN" + "title": "ORTHOGONAL_BITMAP_INTERSECT", + "language": "zh-CN" } --- @@ -13,7 +13,9 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -21,27 +23,39 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - -## orthogonal_bitmap_intersect ## 描述 + +ORTHOGONAL_BITMAP_INTERSECT 函数返回对 Bitmap 表达式进行交集集合 + ## 语法 -`BITMAP ORTHOGONAL_BITMAP_INTERSECT(bitmap_column, column_to_filter, filter_values)` -求bitmap交集函数, 第一个参数是Bitmap列,第二个参数是用来过滤的维度列,第三个参数是变长参数,含义是过滤维度列的不同取值 +```sql +ORTHOGONAL_BITMAP_INTERSECT(, , ) +``` + +## 参数说明 + +| 参数 | 说明 | +| -- | -- | +| `bitmap_column` | 需要获取值的 Bitmap 类型表达式 | +| `column_to_filter` | 可选。需要进行过滤的维度列 | +| `filter_values` | 可选。变长参数,用于过滤维度列的不同取值 | + +## 返回值 + +返回 BITMAP 类型的集合。 ## 举例 +```sql +select orthogonal_bitmap_intersect(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); + ``` -mysql> select orthogonal_bitmap_intersect(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); + +```text +-------------------------------------------------------------------------------+ | orthogonal_bitmap_intersect(`members`, `tag_group`, 1150000, 1150001, 390006) | +-------------------------------------------------------------------------------+ | NULL | +-------------------------------------------------------------------------------+ -1 row in set (3.505 sec) - -``` - -### keywords - - ORTHOGONAL_BITMAP_INTERSECT,BITMAP +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md index 2131b91d7419b..4b1649eda9789 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md @@ -1,7 +1,7 @@ --- { -"title": "ORTHOGONAL_BITMAP_UNION_COUNT", -"language": "zh-CN" + "title": "ORTHOGONAL_BITMAP_UNION_COUNT", + "language": "zh-CN" } --- @@ -13,7 +13,9 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -21,27 +23,38 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - -## orthogonal_bitmap_union_count ## 描述 + +ORTHOGONAL_BITMAP_UNION_COUNT 函数返回对 Bitmap 表达式进行并集计算后集合中的元素数量 + ## 语法 -`BITMAP ORTHOGONAL_BITMAP_UNION_COUNT(bitmap_column, column_to_filter, filter_values)` -求bitmap并集大小的函数, 参数类型是bitmap,是待求并集count的列 +```sql +ORTHOGONAL_BITMAP_UNION_COUNT(, , ) +``` + +## 参数说明 +| 参数 | 说明 | +| -- | -- | +| `bitmap_column` | 需要获取值的 Bitmap 类型表达式 | +| `column_to_filter` | 可选。需要进行过滤的维度列 | +| `filter_values` | 可选。变长参数,用于过滤维度列的不同取值 | + +## 返回值 + +返回 BITMAP 类型的集合。 ## 举例 +```sql +select ORTHOGONAL_BITMAP_UNION_COUNT(members) from tag_map where tag_group in ( 1150000, 1150001, 390006); ``` -mysql> select orthogonal_bitmap_union_count(members) from tag_map where tag_group in ( 1150000, 1150001, 390006); + +```text +------------------------------------------+ | orthogonal_bitmap_union_count(`members`) | +------------------------------------------+ | 286957811 | +------------------------------------------+ -1 row in set (2.645 sec) -``` - -### keywords - - ORTHOGONAL_BITMAP_UNION_COUNT,BITMAP +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile-approx.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile-approx.md index 573dbcf572bea..091f30c0729b4 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile-approx.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile-approx.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,36 +22,72 @@ specific language governing permissions and limitations under the License. --> -## PERCENTILE_APPROX ## 描述 + +`PERCENTILE_APPROX` 函数用于计算近似百分位数,主要用于大数据集的场景。与 `PERCENTILE` 函数相比,它具有以下特点: + +1. 内存效率:使用固定大小的内存,即使在处理高基数列(数据量很大)时也能保持较低的内存消耗 +2. 性能优势:适合处理大规模数据集,计算速度快 +3. 精度可调:通过 compression 参数可以在精度和性能之间做平衡 + ## 语法 -`PERCENTILE_APPROX(expr, DOUBLE p[, DOUBLE compression])` +```sql +PERCENTILE_APPROX(,

[, ]) +``` +## 参数 -返回第p个百分位点的近似值,p的值介于0到1之间 +| 参数 | 说明 | +| -- | -- | +| `` | 需要计算百分位数的列 | +| `

` | 百分位数值,取值范围 `[0.0, 1.0]`,例如 `0.99` 表示 `99` 分位数 | +| `` | 可选参数,压缩度,取值范围 `[2048, 10000]`。值越大,精度越高,但内存消耗也越大。如果不指定或超出范围,则使用 `10000`。 | -compression参数是可选项,可设置范围是[2048, 10000],值越大,精度越高,内存消耗越大,计算耗时越长。 -compression参数未指定或设置的值在[2048, 10000]范围外,以10000的默认值运行 +## 返回值 -该函数使用固定大小的内存,因此对于高基数的列可以使用更少的内存,可用于计算tp99等统计值 +返回一个 `DOUBLE` 类型的值,表示计算得到的近似百分位数。 ## 举例 + +```sql +-- 创建示例表 +CREATE TABLE response_times ( + request_id INT, + response_time DECIMAL(10, 2) +) DUPLICATE KEY(`request_id`) +DISTRIBUTED BY HASH(`request_id`) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- 插入示例数据 +INSERT INTO response_times VALUES +(1, 10.5), +(2, 15.2), +(3, 20.1), +(4, 25.8), +(5, 30.3), +(6, 35.7), +(7, 40.2), +(8, 45.9), +(9, 50.4), +(10, 100.6); + +-- 使用不同压缩度计算 99 分位数 +SELECT + percentile_approx(response_time, 0.99) as p99_default, -- 默认压缩度 + percentile_approx(response_time, 0.99, 2048) as p99_fast, -- 低压缩度,更快 + percentile_approx(response_time, 0.99, 10000) as p99_accurate -- 高压缩度,更精确 +FROM response_times; ``` -MySQL > select `table`, percentile_approx(cost_time,0.99) from log_statis group by `table`; -+---------------------+---------------------------+ -| table | percentile_approx(`cost_time`, 0.99) | -+----------+--------------------------------------+ -| test | 54.22 | -+----------+--------------------------------------+ - -MySQL > select `table`, percentile_approx(cost_time,0.99, 4096) from log_statis group by `table`; -+---------------------+---------------------------+ -| table | percentile_approx(`cost_time`, 0.99, 4096.0) | -+----------+--------------------------------------+ -| test | 54.21 | -+----------+--------------------------------------+ + +```text ++-------------------+-------------------+-------------------+ +| p99_default | p99_fast | p99_accurate | ++-------------------+-------------------+-------------------+ +| 100.5999984741211 | 100.5999984741211 | 100.5999984741211 | ++-------------------+-------------------+-------------------+ ``` -### keywords -PERCENTILE_APPROX,PERCENTILE,APPROX + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile-array.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile-array.md index 9f33f295d7c1c..4a141e5157457 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile-array.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile-array.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,29 +22,67 @@ specific language governing permissions and limitations under the License. --> -## PERCENTILE_ARRAY ## 描述 + +`PERCENTILE_ARRAY` 函数用于计算精确的百分位数数组,允许一次性计算多个百分位数值。这个函数主要适用于小数据量。 + +主要特点: +1. 精确计算:提供精确的百分位数结果,而不是近似值 +2. 批量处理:可以一次计算多个百分位数 +3. 适用范围:最适合处理数据量较小的场景 + ## 语法 -`ARRAY_DOUBLE PERCENTILE_ARRAY(expr, ARRAY_DOUBLE p)` +```sql +PERCENTILE_ARRAY(, ) +``` + +## 参数 -计算精确的百分位数,适用于小数据量。先对指定列降序排列,然后取精确的第 p 位百分数。 -返回值为依次取数组p中指定的百分数组成的结果。 -参数说明: -expr: 必填。值为整数(最大为bigint) 类型的列。 -p: 需要精确的百分位数, 由常量组成的数组, 取值为 [0.0,1.0]。 +| 参数 | 说明 | +| -- | -- | +| `` | 需要计算百分位数的列 | +| `` | 百分位数数组,数组中的每个元素必须在 `[0.0, 1.0]` 范围内,例如 `[0.5, 0.95, 0.99]` | + +## 返回值 + +返回一个 `DOUBLE` 类型的数组,包含了对应于输入百分位数数组的计算结果。 ## 举例 -``` -mysql> select percentile_array(k1,[0.3,0.5,0.9]) from baseall; -+----------------------------------------------+ -| percentile_array(`k1`, ARRAY(0.3, 0.5, 0.9)) | -+----------------------------------------------+ -| [5.2, 8, 13.6] | -+----------------------------------------------+ -1 row in set (0.02 sec) +```sql +-- 创建示例表 +CREATE TABLE sales_data ( + id INT, + amount DECIMAL(10, 2) +) DUPLICATE KEY(`id`) +DISTRIBUTED BY HASH(`id`) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- 插入示例数据 +INSERT INTO sales_data VALUES +(1, 10.5), +(2, 15.2), +(3, 20.1), +(4, 25.8), +(5, 30.3), +(6, 35.7), +(7, 40.2), +(8, 45.9), +(9, 50.4), +(10, 100.6); + +-- 计算多个百分位数 +SELECT percentile_array(amount, [0.25, 0.5, 0.75, 0.9]) as percentiles +FROM sales_data; ``` -### keywords -PERCENTILE_ARRAY +```text ++-----------------------------------------+ +| percentiles | ++-----------------------------------------+ +| [21.25, 32.5, 43.75, 54.99999999999998] | ++-----------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md index 07857cfe22ea4..25d93ff36ca8a 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,36 +22,76 @@ specific language governing permissions and limitations under the License. --> -## PERCENTILE_APPROX_WEIGHTED ## 描述 + +`PERCENTILE_APPROX_WEIGHTED` 函数用于计算带权重的近似百分位数,主要用于需要考虑数值重要性的场景。它是 `PERCENTILE_APPROX` 的加权版本,允许为每个值指定一个权重。 + +主要特点: +1. 支持权重:每个数值可以设置对应的权重,影响最终的百分位数计算 +2. 内存效率:使用固定大小的内存,适合处理大规模数据 +3. 精度可调:通过 compression 参数平衡精度和性能 + ## 语法 -`PERCENTILE_APPROX_WEIGHTED(expr, w ,DOUBLE p [, DOUBLE compression])` +```sql +PERCENTILE_APPROX_WEIGHTED(, ,

[, ]) +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 需要计算百分位数的列 | +| `` | 权重列,必须是正数 | +| `

` | 百分位数值,取值范围 `[0.0, 1.0]`,例如 `0.99` 表示 `99` 分位数 | +| `` | 可选参数,压缩度,取值范围 `[2048, 10000]`。值越大,精度越高,但内存消耗也越大。如果不指定或超出范围,则使用 `10000`。 | +## 返回值 -该函数和 PERCENTILE_APPROX 类似,唯一的区别是多了一个参数 w,用来表示 expr 出现的次数。 -注意参数 W 的取值需要大于0,如果计算过程中某一行的取值小于等于0时,则会跳过当前行。 +返回一个 `DOUBLE` 类型的值,表示计算得到的加权近似百分位数。 ## 举例 + +```sql +-- 创建示例表 +CREATE TABLE weighted_scores ( + student_id INT, + score DECIMAL(10, 2), + weight INT +) DUPLICATE KEY(student_id) +DISTRIBUTED BY HASH(student_id) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- 插入示例数据 +INSERT INTO weighted_scores VALUES +(1, 85.5, 1), -- 普通作业分数,权重1 +(2, 90.0, 2), -- 重要作业分数,权重2 +(3, 75.5, 1), +(4, 95.5, 3), -- 非常重要的作业,权重3 +(5, 88.0, 2), +(6, 92.5, 2), +(7, 78.0, 1), +(8, 89.5, 2), +(9, 94.0, 3), +(10, 83.5, 1); + +-- 计算带权重的分数分布 +SELECT + -- 计算不同压缩度下的90分位数 + percentile_approx_weighted(score, weight, 0.9) as p90_default, -- 默认压缩度 + percentile_approx_weighted(score, weight, 0.9, 2048) as p90_fast, -- 低压缩度,更快 + percentile_approx_weighted(score, weight, 0.9, 10000) as p90_accurate -- 高压缩度,更精确 +FROM weighted_scores; ``` -mysql >select * from quantile_weighted_table order by k; -+------+------+ -| k | w | -+------+------+ -| 1 | 2 | -| 3 | 1 | -| 5 | 2 | -+------+------+ - - -mysql >select percentile_approx_weighted(k,w,0.55) from quantile_weighted_table; -+----------------------------------------------------------------------------------------+ -| percentile_approx_weighted(cast(k as DOUBLE), cast(w as DOUBLE), cast(0.55 as DOUBLE)) | -+----------------------------------------------------------------------------------------+ -| 3.3333332538604736 | -+----------------------------------------------------------------------------------------+ +```text ++------------------+------------------+------------------+ +| p90_default | p90_fast | p90_accurate | ++------------------+------------------+------------------+ +| 95.3499984741211 | 95.3499984741211 | 95.3499984741211 | ++------------------+------------------+------------------+ ``` -### keywords -PERCENTILE_APPROX,PERCENTILE,APPROX,PERCENTILE_APPROX_WEIGHTED + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/quantile-union.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/quantile-union.md index 6bb8e3e6d5265..4c899d578b3c1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/quantile-union.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/quantile-union.md @@ -1,6 +1,6 @@ --- { - "title": "quantile_union", + "title": "QUANTILE_UNION", "language": "zh-CN" } --- @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -23,3 +21,73 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## 描述 + +`QUANTILE_UNION` 函数用于合并多个分位数计算的中间结果。这个函数通常与 `QUANTILE_STATE` 配合使用,特别适用于需要分阶段计算分位数的场景。 + +## 语法 + +```sql +QUANTILE_UNION() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 由 `TO_QUANTILE_STATE` 函数生成的中间状态 | + +## 返回值 + +返回一个可以用于进一步分位数计算的聚合状态。此函数返回的结果仍是 `QUANTILE_STATE`。 + +## 举例 + +```sql +-- 创建示例表 +CREATE TABLE response_times ( + request_id INT, + response_time DOUBLE, + region STRING +) DUPLICATE KEY(request_id) +DISTRIBUTED BY HASH(request_id) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- 插入示例数据 +INSERT INTO response_times VALUES +(1, 10.5, 'east'), +(2, 15.2, 'east'), +(3, 20.1, 'west'), +(4, 25.8, 'east'), +(5, 30.3, 'west'), +(6, 35.7, 'east'), +(7, 40.2, 'west'), +(8, 45.9, 'east'), +(9, 50.4, 'west'), +(10, 100.6, 'east'); + +-- 按区域计算响应时间的50%分位数 +SELECT + region, + QUANTILE_PERCENT( + QUANTILE_UNION( + TO_QUANTILE_STATE(response_time, 2048) + ), + 0.5 + ) AS median_response_time +FROM response_times +GROUP BY region; + +``` + +```text ++--------+----------------------+ +| region | median_response_time | ++--------+----------------------+ +| west | 35.25 | +| east | 30.75 | ++--------+----------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/retention.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/retention.md index d23fb985ec208..6f6be9a736e8a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/retention.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/retention.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,118 +22,73 @@ specific language governing permissions and limitations under the License. --> -## RETENTION - -RETENTION - ## 描述 -## 语法 - -`retention(event1, event2, ... , eventN);` -留存函数将一组条件作为参数,类型为1到32个`UInt8`类型的参数,用来表示事件是否满足特定条件。 任何条件都可以指定为参数. +留存函数将一组条件作为参数,类型为1到32个`UInt8`类型的参数,用来表示事件是否满足特定条件。 任何条件都可以指定为参数。 除了第一个以外,条件成对适用:如果第一个和第二个是真的,第二个结果将是真的,如果第一个和第三个是真的,第三个结果将是真的,等等。 -简单来讲,返回值数组第1位表示`event1`的真假,第二位表示`event1`真假与`event2`真假相与,第三位表示`event1`真假与`event3`真假相与,等等。如果`event1`为假,则返回全是0的数组。 +简单来讲,返回值数组第1位表示`event_1`的真假,第二位表示`event_1`真假与`event_2`真假相与,第三位表示`event_1`真假与`event_3`真假相与,等等。如果`event_1`为假,则返回全是0的数组。 + +## 语法 + +```sql +RETENTION( [, , ... , ]); +``` ## 参数 -`event` — 返回`UInt8`结果(1或0)的表达式. +| 参数 | 说明 | +| -- | -- | +| `` | 第`n`个事件条件,类型为`UInt8`,取值为1或0 | ## 返回值 由1和0组成的最大长度为32位的数组,最终输出数组的长度与输入参数长度相同。 -1 — 条件满足。 +- 1: 条件满足。 -0 — 条件不满足 +- 0: 条件不满足。 ## 举例 ```sql -DROP TABLE IF EXISTS retention_test; - +-- 创建示例表 CREATE TABLE retention_test( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( - "replication_num" = "1" -); - -INSERT into retention_test (uid, date) values (0, '2022-10-12'), - (0, '2022-10-13'), - (0, '2022-10-14'), - (1, '2022-10-12'), - (1, '2022-10-13'), - (2, '2022-10-12'); - -SELECT * from retention_test; - -+------+---------------------+ -| uid | date | -+------+---------------------+ -| 0 | 2022-10-14 00:00:00 | -| 0 | 2022-10-13 00:00:00 | -| 0 | 2022-10-12 00:00:00 | -| 1 | 2022-10-13 00:00:00 | -| 1 | 2022-10-12 00:00:00 | -| 2 | 2022-10-12 00:00:00 | -+------+---------------------+ - -SELECT - uid, - retention(date = '2022-10-12') - AS r - FROM retention_test - GROUP BY uid - ORDER BY uid ASC; - -+------+------+ -| uid | r | -+------+------+ -| 0 | [1] | -| 1 | [1] | -| 2 | [1] | -+------+------+ - + "replication_allocation" = "tag.location.default: 1" +); + +-- 插入示例数据 +INSERT into retention_test values +(0, '2022-10-12'), +(0, '2022-10-13'), +(0, '2022-10-14'), +(1, '2022-10-12'), +(1, '2022-10-13'), +(2, '2022-10-12'); + +-- 计算用户留存 SELECT uid, - retention(date = '2022-10-12', date = '2022-10-13') - AS r - FROM retention_test - GROUP BY uid - ORDER BY uid ASC; - -+------+--------+ -| uid | r | -+------+--------+ -| 0 | [1, 1] | -| 1 | [1, 1] | -| 2 | [1, 0] | -+------+--------+ - -SELECT - uid, - retention(date = '2022-10-12', date = '2022-10-13', date = '2022-10-14') - AS r - FROM retention_test - GROUP BY uid - ORDER BY uid ASC; - -+------+-----------+ -| uid | r | -+------+-----------+ -| 0 | [1, 1, 1] | -| 1 | [1, 1, 0] | -| 2 | [1, 0, 0] | -+------+-----------+ - + RETENTION(date = '2022-10-12') AS r, + RETENTION(date = '2022-10-12', date = '2022-10-13') AS r2, + RETENTION(date = '2022-10-12', date = '2022-10-13', date = '2022-10-14') AS r3 +FROM retention_test +GROUP BY uid +ORDER BY uid ASC; ``` -### keywords - -RETENTION +```text ++------+------+--------+-----------+ +| uid | r | r2 | r3 | ++------+------+--------+-----------+ +| 0 | [1] | [1, 1] | [1, 1, 1] | +| 1 | [1] | [1, 1] | [1, 1, 0] | +| 2 | [1] | [1, 0] | [1, 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/aggregate-functions/sequence-count.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sequence-count.md index b2e312eb6f7c6..dff1be7e0b230 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sequence-count.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sequence-count.md @@ -22,11 +22,7 @@ specific language governing permissions and limitations under the License. --> -## SEQUENCE-COUNT ## 描述 -## 语法 - -`sequence_count(pattern, timestamp, cond1, cond2, ...);` 计算与模式匹配的事件链的数量。该函数搜索不重叠的事件链。当前链匹配后,它开始搜索下一个链。 @@ -34,23 +30,29 @@ under the License. 在同一秒钟发生的事件可能以未定义的顺序排列在序列中,会影响最终结果。 -## 参数 +## 语法 -`pattern` — 模式字符串. +```sql +SEQUENCE_COUNT(, , [, , ..., ]); +``` -**模式语法** +## 参数 -`(?N)` — 在位置N匹配条件参数。 条件在编号 `[1, 32]` 范围。 例如, `(?1)` 匹配传递给 `cond1` 参数。 +| 参数 | 说明 | +| -- | -- | +| `` | 模式字符串,可参考下面的**模式语法** | +| `` | 包含时间的列。典型的时间类型是: `Date` 和 `DateTime`。也可以使用任何支持的 `UInt` 数据类型。 | +| `` | 事件链的约束条件。 数据类型是: `UInt8`。 最多可以传递32个条件参数。 该函数只考虑这些条件中描述的事件。 如果序列包含未在条件中描述的数据,则函数将跳过这些数据 | -`.*` — 匹配任何事件的数字。 不需要条件参数来匹配这个模式。 +**模式语法** -`(?t operator value)` — 分开两个事件的时间。 单位为秒。 +- `(?N)` — 在位置N匹配条件参数。 条件在编号 `[1, 32]` 范围。 例如, `(?1)` 匹配传递给 `cond_1` 参数。 -`t`表示为两个时间的差值,单位为秒。 例如: `(?1)(?t>1800)(?2)` 匹配彼此发生超过1800秒的事件, `(?1)(?t>10000)(?2)`匹配彼此发生超过10000秒的事件。 这些事件之间可以存在任意数量的任何事件。 您可以使用 `>=`, `>`, `<`, `<=`, `==` 运算符。 +- `.*` — 匹配任何事件的数字。 不需要条件参数来匹配这个模式。 -`timestamp` — 包含时间的列。典型的时间类型是: `Date` 和 `DateTime`。也可以使用任何支持的 `UInt` 数据类型。 +- `(?t operator value)` — 分开两个事件的时间。 单位为秒。 -`cond1`, `cond2` — 事件链的约束条件。 数据类型是: `UInt8`。 最多可以传递32个条件参数。 该函数只考虑这些条件中描述的事件。 如果序列包含未在条件中描述的数据,则函数将跳过这些数据。 +- `t`表示为两个时间的差值,单位为秒。 例如: `(?1)(?t>1800)(?2)` 匹配彼此发生超过1800秒的事件, `(?1)(?t>10000)(?2)`匹配彼此发生超过10000秒的事件。 这些事件之间可以存在任意数量的任何事件。 您可以使用 `>=`, `>`, `<`, `<=`, `==` 运算符。 ## 返回值 @@ -61,161 +63,106 @@ under the License. **匹配例子** ```sql -DROP TABLE IF EXISTS sequence_count_test1; - +-- 创建示例表 CREATE TABLE sequence_count_test1( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_count_test1(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 13:28:02', 2), - (3, '2022-11-02 16:15:01', 1), - (4, '2022-11-02 19:05:04', 2), - (5, '2022-11-02 20:08:44', 3); - -SELECT * FROM sequence_count_test1 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 13:28:02 | 2 | -| 3 | 2022-11-02 16:15:01 | 1 | -| 4 | 2022-11-02 19:05:04 | 2 | -| 5 | 2022-11-02 20:08:44 | 3 | -+------+---------------------+--------+ - -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 3) FROM sequence_count_test1; - -+----------------------------------------------------------------+ -| sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 3) | -+----------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 2) FROM sequence_count_test1; - -+----------------------------------------------------------------+ -| sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 2 | -+----------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) FROM sequence_count_test1; +-- 插入示例数据 +INSERT INTO sequence_count_test1(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 13:28:02', 2), +(3, '2022-11-02 16:15:01', 1), +(4, '2022-11-02 19:05:04', 2), +(5, '2022-11-02 20:08:44', 3); + +-- 查询示例 +SELECT + SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 3) as c1, + SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 2) as c2, + SEQUENCE_COUNT('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) as c3 +FROM sequence_count_test1; +``` -+---------------------------------------------------------------------------+ -| sequence_count('(?1)(?t>=3600)(?2)', `date`, `number` = 1, `number` = 2) | -+---------------------------------------------------------------------------+ -| 2 | -+---------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 1 | 2 | 2 | ++------+------+------+ ``` **不匹配例子** ```sql -DROP TABLE IF EXISTS sequence_count_test2; - +-- 创建示例表 CREATE TABLE sequence_count_test2( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_count_test2(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_count_test2 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ - -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 2) FROM sequence_count_test2; - -+----------------------------------------------------------------+ -| sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 0 | -+----------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?2).*', date, number = 1, number = 2) FROM sequence_count_test2; - -+------------------------------------------------------------------+ -| sequence_count('(?1)(?2).*', `date`, `number` = 1, `number` = 2) | -+------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?t>3600)(?2)', date, number = 1, number = 7) FROM sequence_count_test2; +-- 插入示例数据 +INSERT INTO sequence_count_test2(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); + +-- 查询示例 +SELECT + SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 2) as c1, + SEQUENCE_COUNT('(?1)(?2).*', date, number = 1, number = 2) as c2, + SEQUENCE_COUNT('(?1)(?t>3600)(?2)', date, number = 1, number = 7) as c3 +FROM sequence_count_test2; +``` -+--------------------------------------------------------------------------+ -| sequence_count('(?1)(?t>3600)(?2)', `date`, `number` = 1, `number` = 7) | -+--------------------------------------------------------------------------+ -| 0 | -+--------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 0 | 0 | 0 | ++------+------+------+ ``` **特殊例子** ```sql -DROP TABLE IF EXISTS sequence_count_test3; - +-- 创建示例表 CREATE TABLE sequence_count_test3( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_count_test3(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_count_test3 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ -``` - -Perform the query: +-- 插入示例数据 +INSERT INTO sequence_count_test3(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); -```sql -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5) FROM sequence_count_test3; +-- 查询示例 +SELECT SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 5) FROM sequence_count_test3; +``` +```text +----------------------------------------------------------------+ | sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 5) | +----------------------------------------------------------------+ @@ -228,8 +175,10 @@ SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5) FROM sequence_co 现在,考虑如下执行语句: ```sql -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM sequence_count_test3; +SELECT SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM sequence_count_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 4) | +------------------------------------------------------------------------------+ @@ -240,15 +189,13 @@ SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM 您可能对这个结果有些许疑惑,在这种情况下,函数找不到与模式匹配的事件链,因为数字4的事件发生在1和5之间。 如果在相同的情况下,我们检查了数字6的条件,则序列将与模式匹配。 ```sql -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5, number = 6) FROM sequence_count_test3; +SELECT SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 5, number = 6) FROM sequence_count_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 6) | +------------------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------------------+ ``` - -### keywords - -SEQUENCE_COUNT \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sequence-match.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sequence-match.md index c07318fc990e1..7491cd0fcfa73 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sequence-match.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sequence-match.md @@ -22,11 +22,7 @@ specific language governing permissions and limitations under the License. --> -## SEQUENCE-MATCH ## 描述 -## 语法 - -`sequence_match(pattern, timestamp, cond1, cond2, ...);` 检查序列是否包含与模式匹配的事件链。 @@ -34,190 +30,135 @@ under the License. 在同一秒钟发生的事件可能以未定义的顺序排列在序列中,会影响最终结果。 +## 语法 +```sql +SEQUENCE_MATCH(, , [, , ..., ]) +``` + ## 参数 -`pattern` — 模式字符串. +| 参数 | 说明 | +| -- | -- | +| `` | 模式字符串,可参考下面的**模式语法** | +| `` | 包含时间的列。典型的时间类型是: `Date` 和 `DateTime`。也可以使用任何支持的 `UInt` 数据类型。 | +| `` | 事件链的约束条件。 数据类型是: `UInt8`。最多可以传递32个条件参数。该函数只考虑这些条件中描述的事件。如果序列包含未在条件中描述的数据,则函数将跳过这些数据。 | -**模式语法** -`(?N)` — 在位置N匹配条件参数。 条件在编号 `[1, 32]` 范围。 例如, `(?1)` 匹配传递给 `cond1` 参数。 +**模式语法** -`.*` — 匹配任何事件的数字。 不需要条件参数来匹配这个模式。 +- `(?N)` — 在位置N匹配条件参数。 条件在编号 `[1, 32]` 范围。 例如, `(?1)` 匹配传递给 `cond1` 参数。 -`(?t operator value)` — 分开两个事件的时间。 单位为秒。 +- `.*` — 匹配任何事件的数字。 不需要条件参数来匹配这个模式。 -`t`表示为两个时间的差值,单位为秒。 例如: `(?1)(?t>1800)(?2)` 匹配彼此发生超过1800秒的事件, `(?1)(?t>10000)(?2)`匹配彼此发生超过10000秒的事件。 这些事件之间可以存在任意数量的任何事件。 您可以使用 `>=`, `>`, `<`, `<=`, `==` 运算符。 +- `(?t operator value)` — 分开两个事件的时间。 单位为秒。 -`timestamp` — 包含时间的列。典型的时间类型是: `Date` 和 `DateTime`。也可以使用任何支持的 `UInt` 数据类型。 +- `t`表示为两个时间的差值,单位为秒。 例如: `(?1)(?t>1800)(?2)` 匹配彼此发生超过1800秒的事件, `(?1)(?t>10000)(?2)`匹配彼此发生超过10000秒的事件。 这些事件之间可以存在任意数量的任何事件。 您可以使用 `>=`, `>`, `<`, `<=`, `==` 运算符。 -`cond1`, `cond2` — 事件链的约束条件。 数据类型是: `UInt8`。 最多可以传递32个条件参数。 该函数只考虑这些条件中描述的事件。 如果序列包含未在条件中描述的数据,则函数将跳过这些数据。 ## 返回值 -1,如果模式匹配。 +1:模式匹配。 -0,如果模式不匹配。 +0:模式不匹配。 ## 举例 **匹配例子** ```sql -DROP TABLE IF EXISTS sequence_match_test1; - CREATE TABLE sequence_match_test1( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_match_test1(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 13:28:02', 2), - (3, '2022-11-02 16:15:01', 1), - (4, '2022-11-02 19:05:04', 2), - (5, '2022-11-02 20:08:44', 3); - -SELECT * FROM sequence_match_test1 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 13:28:02 | 2 | -| 3 | 2022-11-02 16:15:01 | 1 | -| 4 | 2022-11-02 19:05:04 | 2 | -| 5 | 2022-11-02 20:08:44 | 3 | -+------+---------------------+--------+ +INSERT INTO sequence_match_test1(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 13:28:02', 2), +(3, '2022-11-02 16:15:01', 1), +(4, '2022-11-02 19:05:04', 2), +(5, '2022-11-02 20:08:44', 3); -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 3) FROM sequence_match_test1; - -+----------------------------------------------------------------+ -| sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 3) | -+----------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 2) FROM sequence_match_test1; - -+----------------------------------------------------------------+ -| sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------+ -SELECT sequence_match('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) FROM sequence_match_test1; +SELECT +sequence_match('(?1)(?2)', date, number = 1, number = 3) as c1, +sequence_match('(?1)(?2)', date, number = 1, number = 2) as c2, +sequence_match('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) as c3 +FROM sequence_match_test1; +``` -+---------------------------------------------------------------------------+ -| sequence_match('(?1)(?t>=3600)(?2)', `date`, `number` = 1, `number` = 2) | -+---------------------------------------------------------------------------+ -| 1 | -+---------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 1 | 1 | 1 | ++------+------+------+ ``` **不匹配例子** ```sql -DROP TABLE IF EXISTS sequence_match_test2; - CREATE TABLE sequence_match_test2( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_match_test2(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_match_test2 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ - -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 2) FROM sequence_match_test2; - -+----------------------------------------------------------------+ -| sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 0 | -+----------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?2).*', date, number = 1, number = 2) FROM sequence_match_test2; - -+------------------------------------------------------------------+ -| sequence_match('(?1)(?2).*', `date`, `number` = 1, `number` = 2) | -+------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?t>3600)(?2)', date, number = 1, number = 7) FROM sequence_match_test2; +INSERT INTO sequence_match_test2(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); + +SELECT +sequence_match('(?1)(?2)', date, number = 1, number = 2) as c1, +sequence_match('(?1)(?2).*', date, number = 1, number = 2) as c2, +sequence_match('(?1)(?t>3600)(?2)', date, number = 1, number = 7) as c3 +FROM sequence_match_test2; +``` -+--------------------------------------------------------------------------+ -| sequence_match('(?1)(?t>3600)(?2)', `date`, `number` = 1, `number` = 7) | -+--------------------------------------------------------------------------+ -| 0 | -+--------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 0 | 0 | 0 | ++------+------+------+ ``` **特殊例子** ```sql -DROP TABLE IF EXISTS sequence_match_test3; - CREATE TABLE sequence_match_test3( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_match_test3(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_match_test3 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ -``` - -Perform the query: +INSERT INTO sequence_match_test3(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); -```sql -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5) FROM sequence_match_test3; +SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5) +FROM sequence_match_test3; +``` +```text +----------------------------------------------------------------+ | sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 5) | +----------------------------------------------------------------+ @@ -230,8 +171,11 @@ SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5) FROM sequence_ma 现在,考虑如下执行语句: ```sql -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM sequence_match_test3; +SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 4) +FROM sequence_match_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 4) | +------------------------------------------------------------------------------+ @@ -242,15 +186,14 @@ SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM 您可能对这个结果有些许疑惑,在这种情况下,函数找不到与模式匹配的事件链,因为数字4的事件发生在1和5之间。 如果在相同的情况下,我们检查了数字6的条件,则序列将与模式匹配。 ```sql -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 6) FROM sequence_match_test3; +SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 6) +FROM sequence_match_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 6) | +------------------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------------------+ ``` - -### keywords - -SEQUENCE_MATCH \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/skew.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/skew.md index 2328228628cd1..4f36d3ec28eb6 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/skew.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/skew.md @@ -1,7 +1,7 @@ --- { "title": "SKEW,SKEW_POP,SKEWNESS", - "language": "en" + "language": "zh-CN" } --- @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,50 +22,79 @@ specific language governing permissions and limitations under the License. --> -## skewness,skew,skew_pop -### 描述 +## 描述 返回表达式的 [斜度](https://en.wikipedia.org/wiki/Skewness)。 -用来计算斜度的公式是 `3阶中心矩 / ((方差)^{1.5})`, 当方差为零时, `skewness` 会返回 `NULL`. +用来计算斜度的公式是 `3阶中心矩 / ((方差)^{1.5})`, 当方差为零时, `SKEWNESS` 会返回 `NULL`。 -### 语法 +**相关命令** -`skewness(expr)` +[kurt](./kurt.md) -### 参数说明 +## 别名 -TinyInt/SmallInt/Integer/BigInt/Float/Double, Decimal 会被 cast 成浮点数参与运算。 +- SKEW +- SKEW_POP -### 返回值说明 +## 语法 -`Double` - -### 举例 ```sql -create table statistic_test (tag int, val1 double not null, val2 double null) - distributed by hash(tag) properties("replication_num"="1") +SKEWNESS() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 需要被计算斜度的列 | + +## 返回值 -insert into statistic_test values (1, -10, -10), - (2, -20, NULL), - (3, 100, NULL), - (4, 100, NULL), - (5, 1000,1000); +返回表达式的斜度, `Double` 类型。 -// NULL is ignored -select skew(val1), skew(val2) from statistic_test --------------- +## 举例 +```sql +CREATE TABLE statistic_test( + tag int, + val1 double not null, + val2 double null +) DISTRIBUTED BY HASH(tag) +PROPERTIES ( + "replication_num"="1" +); + +INSERT INTO statistic_test VALUES +(1, -10, -10), +(2, -20, NULL), +(3, 100, NULL), +(4, 100, NULL), +(5, 1000,1000); + +-- NULL 值会被忽略 +SELECT + skew(val1), + skew(val2) +FROM statistic_test; +``` +```text +--------------------+--------------------+ | skew(val1) | skew(val2) | +--------------------+--------------------+ | 1.4337199628825619 | 1.1543940205711711 | +--------------------+--------------------+ -1 row in set (0.01 sec) +``` -// Each group just has one row, result is NULL -select skew(val1), skew(val2) from statistic_test group by tag --------------- +```sql +-- 每组仅包含一行,结果为 NULL。 +SELECT + skew(val1), + skew(val2) +FROM statistic_test +GROUP BY tag; +``` +```text +------------+------------+ | skew(val1) | skew(val2) | +------------+------------+ @@ -77,8 +104,4 @@ select skew(val1), skew(val2) from statistic_test group by tag | NULL | NULL | | NULL | NULL | +------------+------------+ -5 rows in set (0.04 sec) -``` -### 相关命令 - -[kurt](./kurt.md) \ No newline at end of file +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/stddev-samp.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/stddev-samp.md index 104ce066a6bb3..e71d23be26f9b 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/stddev-samp.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/stddev-samp.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,23 +22,54 @@ specific language governing permissions and limitations under the License. --> -## STDDEV_SAMP ## 描述 + +返回expr表达式的样本标准差 + ## 语法 -`STDDEV_SAMP(expr)` +```sql +STDDEV_SAMP() +``` + +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 需要被计算标准差的值 | -返回expr表达式的样本标准差 +## 返回值 + +返回参数 expr 的样本标准差 ## 举例 +```sql +-- 创建示例表 +CREATE TABLE score_table ( + student_id INT, + score DOUBLE +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO score_table VALUES +(1, 85), +(2, 90), +(3, 82), +(4, 88), +(5, 95); + +-- 计算所有学生分数的样本标准差 +SELECT STDDEV_SAMP(score) as score_stddev +FROM score_table; ``` -MySQL > select stddev_samp(scan_rows) from log_statis group by datetime; -+--------------------------+ -| stddev_samp(`scan_rows`) | -+--------------------------+ -| 2.372044195280762 | -+--------------------------+ + +```text ++-------------------+ +| score_stddev | ++-------------------+ +| 4.949747468305831 | ++-------------------+ ``` -### keywords -STDDEV_SAMP,STDDEV,SAMP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/stddev.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/stddev.md index 85803054ba7a1..47778ec9dde5f 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/stddev.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/stddev.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,30 +22,58 @@ specific language governing permissions and limitations under the License. --> -## STDDEV,STDDEV_POP ## 描述 + +返回 expr 表达式的标准差 + +## 别名 + +- STDDEV_POP + ## 语法 -`STDDEV(expr)` +```sql +STDDEV() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 需要被计算标准差的值 | +## 返回值 -返回expr表达式的标准差 +返回参数 expr 的标准差 ## 举例 +```sql +-- 创建示例表 +CREATE TABLE score_table ( + student_id INT, + score DOUBLE +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO score_table VALUES +(1, 85), +(2, 90), +(3, 82), +(4, 88), +(5, 95); + +-- 计算所有学生分数的标准差 +SELECT STDDEV(score) as score_stddev +FROM score_table; ``` -MySQL > select stddev(scan_rows) from log_statis group by datetime; -+---------------------+ -| stddev(`scan_rows`) | -+---------------------+ -| 2.3736656687790934 | -+---------------------+ - -MySQL > select stddev_pop(scan_rows) from log_statis group by datetime; -+-------------------------+ -| stddev_pop(`scan_rows`) | -+-------------------------+ -| 2.3722760595994914 | -+-------------------------+ + +```text ++-------------------+ +| score_stddev | ++-------------------+ +| 4.427188724235729 | ++-------------------+ ``` -### keywords -STDDEV,STDDEV_POP,POP diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sum.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sum.md index f97b3ae225f73..20023c95ec7f7 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sum.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sum.md @@ -24,23 +24,55 @@ specific language governing permissions and limitations under the License. --> -## SUM ## 描述 + +用于返回选中字段所有值的和。 + ## 语法 -`SUM(expr)` +```sql +SUM() +``` + +## 参数 +| 参数 | 说明 | +| --- | --- | +| `` | 要计算和的字段 | -用于返回选中字段所有值的和 +## 返回值 + +返回选中字段所有值的和。 ## 举例 +```sql +-- 创建示例表 +CREATE TABLE sales_table ( + product_id INT, + price DECIMAL(10,2), + quantity INT +) DISTRIBUTED BY HASH(product_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO sales_table VALUES +(1, 99.99, 2), +(2, 159.99, 1), +(3, 49.99, 5), +(4, 299.99, 1), +(5, 79.99, 3); + +-- 计算销售总金额 +SELECT SUM(price * quantity) as total_sales +FROM sales_table; ``` -MySQL > select sum(scan_rows) from log_statis group by datetime; -+------------------+ -| sum(`scan_rows`) | -+------------------+ -| 8217360135 | -+------------------+ + +```text ++-------------+ +| total_sales | ++-------------+ +| 1149.88 | ++-------------+ ``` -### keywords -SUM diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sum0.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sum0.md index 691d8808adb7a..51abed020e4b1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sum0.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sum0.md @@ -1,7 +1,6 @@ --- { - "title": "sum0 - ", + "title": "SUM0", "language": "zh-CN" } --- @@ -24,3 +23,60 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## 描述 + +用于返回选中字段所有值的和。与 SUM 函数不同的是,当输入值全为 NULL 时,SUM0 返回 0 而不是 NULL。 + +## 语法 + +```sql +SUM0() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 要计算和的字段 | + +## 返回值 + +返回选中字段所有值的和。如果所有值都为 NULL,则返回 0。 + +## 举例 + +```sql +-- 创建示例表 +CREATE TABLE sales_table ( + product_id INT, + price DECIMAL(10,2), + quantity INT, + discount DECIMAL(10,2) +) DISTRIBUTED BY HASH(product_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO sales_table VALUES +(1, 99.99, 2, NULL), +(2, 159.99, 1, NULL), +(3, 49.99, 5, NULL), +(4, 299.99, 1, NULL), +(5, 79.99, 3, NULL); + +-- 对比 SUM 和 SUM0 的区别 +SELECT + SUM(discount) as sum_discount, -- 返回 NULL + SUM0(discount) as sum0_discount -- 返回 0 +FROM sales_table; +``` + +```text ++--------------+---------------+ +| sum_discount | sum0_discount | ++--------------+---------------+ +| NULL | 0.00 | ++--------------+---------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn-array.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn-array.md index d97028c5bf6c5..88aafaa85d4ff 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn-array.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn-array.md @@ -24,37 +24,58 @@ specific language governing permissions and limitations under the License. --> -## TOPN_ARRAY ## 描述 -## 语法 -`ARRAY topn_array(expr, INT top_num[, INT space_expand_rate])` +TOPN_ARRAY 函数返回指定列中出现频率最高的 N 个值的数组。与 TOPN 函数不同,TOPN_ARRAY 返回一个数组类型,便于后续处理和分析。 -该topn_array函数使用Space-Saving算法计算expr中的top_num个频繁项,返回由前top_num个组成的数组,该结果为近似值 +## 语法 -space_expand_rate参数是可选项,该值用来设置Space-Saving算法中使用的counter个数 +```sql +TOPN_ARRAY(, [, ]) ``` -counter numbers = top_num * space_expand_rate -``` -space_expand_rate的值越大,结果越准确,默认值为50 + +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 要统计的列或表达式 | +| `` | 要返回的最高频率值的数量,必须是正整数 | +| `` | 可选项,该值用来设置 Space-Saving 算法中使用的 counter 个数`counter_numbers = top_num * space_expand_rate` space_expand_rate 的值越大,结果越准确,默认值为50 | + +## 返回值 +返回一个数组,包含出现频率最高的 N 个值。 ## 举例 +```sql +-- 创建示例表 +CREATE TABLE page_visits ( + page_id INT, + user_id INT, + visit_date DATE +) DISTRIBUTED BY HASH(page_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO page_visits VALUES +(1, 101, '2024-01-01'), +(2, 102, '2024-01-01'), +(1, 103, '2024-01-01'), +(3, 101, '2024-01-01'), +(1, 104, '2024-01-01'), +(2, 105, '2024-01-01'), +(1, 106, '2024-01-01'), +(4, 107, '2024-01-01'); + +-- 查找访问量最高的前3个页面 +SELECT TOPN_ARRAY(page_id, 3) as top_pages +FROM page_visits; ``` -mysql> select topn_array(k3,3) from baseall; -+--------------------------+ -| topn_array(`k3`, 3) | -+--------------------------+ -| [3021, 2147483647, 5014] | -+--------------------------+ -1 row in set (0.02 sec) - -mysql> select topn_array(k3,3,100) from baseall; -+--------------------------+ -| topn_array(`k3`, 3, 100) | -+--------------------------+ -| [3021, 2147483647, 5014] | -+--------------------------+ -1 row in set (0.02 sec) + +```text ++-----------+ +| top_pages | ++-----------+ +| [1, 2, 4] | ++-----------+ ``` -### keywords -TOPN, TOPN_ARRAY diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn-weighted.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn-weighted.md index abd13f58138a9..87d8bddcd25b1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn-weighted.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn-weighted.md @@ -24,37 +24,60 @@ specific language governing permissions and limitations under the License. --> -## TOPN_WEIGHTED ## 描述 -## 语法 -`ARRAY topn_weighted(expr, BigInt weight, INT top_num[, INT space_expand_rate])` +TOPN_WEIGHTED 函数返回指定列中出现频率最高的 N 个值,并且可以为每个值指定权重。与普通的 TOPN 函数不同,TOPN_WEIGHTED 允许通过权重来调整值的重要性。 -该topn_weighted函数使用Space-Saving算法计算,取expr中权重和为前top_num个数组成的结果,该结果为近似值 +## 语法 -space_expand_rate参数是可选项,该值用来设置Space-Saving算法中使用的counter个数 -``` -counter numbers = top_num * space_expand_rate +```sql +TOPN_WEIGHTED(, , [, ]) ``` -space_expand_rate的值越大,结果越准确,默认值为50 + +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 要统计的列或表达式 | +| `` | 用于调整权重的列或表达式 | +| `` | 要返回的最高频率值的数量,必须是正整数 | +| `` | 可选项,该值用来设置 Space-Saving 算法中使用的 counter 个数`counter_numbers = top_num * space_expand_rate` space_expand_rate 的值越大,结果越准确,默认值为50 | + +## 返回值 + +返回一个数组,包含值和对应的加权计数。 ## 举例 +```sql +-- 创建示例表 +CREATE TABLE product_sales ( + product_id INT, + sale_amount DECIMAL(10,2), + sale_date DATE +) DISTRIBUTED BY HASH(product_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO product_sales VALUES +(1, 100.00, '2024-01-01'), +(2, 50.00, '2024-01-01'), +(1, 150.00, '2024-01-01'), +(3, 75.00, '2024-01-01'), +(1, 200.00, '2024-01-01'), +(2, 80.00, '2024-01-01'), +(1, 120.00, '2024-01-01'), +(4, 90.00, '2024-01-01'); + +-- 查找销售额最高的前3个产品(按销售金额加权) +SELECT TOPN_WEIGHTED(product_id, sale_amount, 3) as top_products +FROM product_sales; ``` -mysql> select topn_weighted(k5,k1,3) from baseall; -+------------------------------+ -| topn_weighted(`k5`, `k1`, 3) | -+------------------------------+ -| [0, 243.325, 100.001] | -+------------------------------+ -1 row in set (0.02 sec) - -mysql> select topn_weighted(k5,k1,3,100) from baseall; -+-----------------------------------+ -| topn_weighted(`k5`, `k1`, 3, 100) | -+-----------------------------------+ -| [0, 243.325, 100.001] | -+-----------------------------------+ -1 row in set (0.02 sec) + +```text ++--------------+ +| top_products | ++--------------+ +| [1, 2, 4] | ++--------------+ ``` -### keywords -TOPN, TOPN_WEIGHTED diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn.md index 649222139a656..9b75f9b83acae 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn.md @@ -24,37 +24,58 @@ specific language governing permissions and limitations under the License. --> -## TOPN ## 描述 -## 语法 -`topn(expr, INT top_num[, INT space_expand_rate])` +TOPN 函数用于返回指定列中出现频率最高的 N 个值。它是一个近似计算函数,返回结果的顺序是按照计数值从大到小排序。 -该topn函数使用Space-Saving算法计算expr中的top_num个频繁项,结果为频繁项及其出现次数,该结果为近似值 +## 语法 -space_expand_rate参数是可选项,该值用来设置Space-Saving算法中使用的counter个数 -``` -counter numbers = top_num * space_expand_rate +```sql +TOPN(, [, ]) ``` -space_expand_rate的值越大,结果越准确,默认值为50 + +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 要统计的列或表达式 | +| `` | 要返回的最高频率值的数量,必须是正整数 | +| `` | 可选项,该值用来设置 Space-Saving 算法中使用的 counter 个数`counter_numbers = top_num * space_expand_rate` space_expand_rate 的值越大,结果越准确,默认值为50 | + +## 返回值 +返回一个 JSON 字符串,包含值和对应的出现次数。 ## 举例 +```sql +-- 创建示例表 +CREATE TABLE page_visits ( + page_id INT, + user_id INT, + visit_date DATE +) DISTRIBUTED BY HASH(page_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO page_visits VALUES +(1, 101, '2024-01-01'), +(2, 102, '2024-01-01'), +(1, 103, '2024-01-01'), +(3, 101, '2024-01-01'), +(1, 104, '2024-01-01'), +(2, 105, '2024-01-01'), +(1, 106, '2024-01-01'), +(4, 107, '2024-01-01'); + +-- 查找访问量最高的前3个页面 +SELECT TOPN(page_id, 3) as top_pages +FROM page_visits; ``` -MySQL [test]> select topn(keyword,10) from keyword_table where date>= '2020-06-01' and date <= '2020-06-19' ; -+------------------------------------------------------------------------------------------------------------+ -| topn(`keyword`, 10) | -+------------------------------------------------------------------------------------------------------------+ -| a:157, b:138, c:133, d:133, e:131, f:127, g:124, h:122, i:117, k:117 | -+------------------------------------------------------------------------------------------------------------+ - -MySQL [test]> select date,topn(keyword,10,100) from keyword_table where date>= '2020-06-17' and date <= '2020-06-19' group by date; -+------------+-----------------------------------------------------------------------------------------------+ -| date | topn(`keyword`, 10, 100) | -+------------+-----------------------------------------------------------------------------------------------+ -| 2020-06-19 | a:11, b:8, c:8, d:7, e:7, f:7, g:7, h:7, i:7, j:7 | -| 2020-06-18 | a:10, b:8, c:7, f:7, g:7, i:7, k:7, l:7, m:6, d:6 | -| 2020-06-17 | a:9, b:8, c:8, j:8, d:7, e:7, f:7, h:7, i:7, k:7 | -+------------+-----------------------------------------------------------------------------------------------+ -``` -### keywords -TOPN + +```text ++---------------------+ +| top_pages | ++---------------------+ +| {"1":4,"2":2,"4":1} | ++---------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/var-samp.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/var-samp.md index b563f95e59e27..06154cb8343c4 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/var-samp.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/var-samp.md @@ -24,24 +24,62 @@ specific language governing permissions and limitations under the License. --> -## VAR_SAMP,VARIANCE_SAMP ## 描述 + +VAR_SAMP 函数计算指定表达式的样本方差。与 VARIANCE(总体方差)不同,VAR_SAMP 使用 n-1 作为除数,这在统计学上被认为是对总体方差的无偏估计。 + +## 别名 + +- VARIANCE_SAMP + ## 语法 -`VAR_SAMP(expr)` +```sql +VAR_SAMP() +``` + +## 参数 +| 参数 | 描述 | +| -- | -- | +| `` | 要计算样本方差的列或表达式 | -返回expr表达式的样本方差 +## 返回值 +返回一个 DOUBLE 类型的值,表示计算得到的样本方差。 ## 举例 -``` -MySQL > select var_samp(scan_rows) from log_statis group by datetime; -+-----------------------+ -| var_samp(`scan_rows`) | -+-----------------------+ -| 5.6227132145741789 | -+-----------------------+ +```sql +-- 创建示例表 +CREATE TABLE student_scores ( + student_id INT, + score DECIMAL(4,1) +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO student_scores VALUES +(1, 85.5), +(2, 92.0), +(3, 78.5), +(4, 88.0), +(5, 95.5), +(6, 82.0), +(7, 90.0), +(8, 87.5); + +-- 计算学生成绩的样本方差 +SELECT + VAR_SAMP(score) as sample_variance, + VARIANCE(score) as population_variance +FROM student_scores; ``` -### keywords -VAR_SAMP,VARIANCE_SAMP,VAR,SAMP,VARIANCE +```text ++------------------+---------------------+ +| sample_variance | population_variance | ++------------------+---------------------+ +| 29.4107142857143 | 25.73437500000001 | ++------------------+---------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/variance.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/variance.md index 019582b0822a7..b873857e02e54 100755 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/variance.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/variance.md @@ -24,31 +24,59 @@ specific language governing permissions and limitations under the License. --> -## VARIANCE,VAR_POP,VARIANCE_POP ## 描述 + +VARIANCE 函数计算指定表达式的统计方差。它衡量了数据值与其算术平均值之间的差异程度。 + +## 别名 + +- VAR_POP +- VARIANCE_POP + ## 语法 -`VARIANCE(expr)` +```sql +VARIANCE() +``` +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 要计算方差的列或表达式 | -返回expr表达式的方差 +## 返回值 +返回一个 DOUBLE 类型的值,表示计算得到的方差。 ## 举例 -``` -MySQL > select variance(scan_rows) from log_statis group by datetime; -+-----------------------+ -| variance(`scan_rows`) | -+-----------------------+ -| 5.6183332881176211 | -+-----------------------+ - -MySQL > select var_pop(scan_rows) from log_statis group by datetime; -+----------------------+ -| var_pop(`scan_rows`) | -+----------------------+ -| 5.6230744719006163 | -+----------------------+ +```sql +-- 创建示例表 +CREATE TABLE student_scores ( + student_id INT, + score DECIMAL(4,1) +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- 插入测试数据 +INSERT INTO student_scores VALUES +(1, 85.5), +(2, 92.0), +(3, 78.5), +(4, 88.0), +(5, 95.5), +(6, 82.0), +(7, 90.0), +(8, 87.5); +-- 计算学生成绩的方差 +SELECT VARIANCE(score) as score_variance +FROM student_scores; ``` -### keywords -VARIANCE,VAR_POP,VARIANCE_POP,VAR,POP +```text ++-------------------+ +| score_variance | ++-------------------+ +| 25.73437499999998 | ++-------------------+ +``` \ No newline at end of file diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/window-funnel.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/window-funnel.md index dd00c0bada841..c25d317952a5d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/window-funnel.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/window-funnel.md @@ -1,6 +1,6 @@ --- { - "title": "WINDOW_FUNCTION_WINDOW_FUNNEL", + "title": "WINDOW_FUNNEL", "language": "zh-CN" } --- @@ -11,19 +11,9 @@ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> -## WINDOW FUNCTION WINDOW_FUNNEL ## 描述 -在滑动时间窗口中搜索事件链,并计算链中发生的最大事件数。 - -- window :滑动时间窗口大小,单位为秒。 -- mode :模式,共有四种模式 - - "default": 默认模式。 - - "deduplication": 当某个事件重复发生时,这个重复发生的事件会阻止后续的处理过程。如,指定事件链为[event1='A', event2='B', event3='C', event4='D'],原始事件链为"A-B-C-B-D"。由于B事件重复,最终的结果事件链为A-B-C,最大长度为3。 - - "fixed": 不允许事件的顺序发生交错,即事件发生的顺序必须和指定的事件链顺序一致。如,指定事件链为[event1='A', event2='B', event3='C', event4='D'],原始事件链为"A-B-D-C",则结果事件链为A-B,最大长度为2 - - "increase": 选中的事件的时间戳必须按照指定事件链严格递增。 -- timestamp_column :指定时间列,类型为DATETIME, 滑动窗口沿着此列工作。 -- eventN :表示事件的布尔表达式。 +WINDOW_FUNNEL 函数用于分析用户行为序列,它在指定的时间窗口内搜索事件链,并计算事件链中完成的最大步骤数。这个函数特别适用于转化漏斗分析,比如分析用户从访问网站到最终购买的转化过程。 漏斗分析函数按照如下算法工作: @@ -31,15 +21,36 @@ Unless required by applicable law or agreed to in writing, software distributed - 如果事件在时间窗口内按照指定的顺序发生,时间长度累计增加。如果事件没有按照指定的顺序发生,时间长度不增加。 - 如果搜索到多个事件链,漏斗分析函数返回最大的长度。 +## 语法 + ```sql -window_funnel(window, mode, timestamp_column, event1, event2, ... , eventN) +WINDOW_FUNNEL(, , , [, event_2, ... , event_n]) ``` +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 滑动时间窗口大小,单位为秒 | +| `` | 模式,共有四种模式,分别为`default`, `deduplication`, `fixed`, `increase`,详细请参见下面的**模式** | +| `` | 指定时间列,类型为DATETIME, 滑动窗口沿着此列工作 | +| `` | 表示事件的布尔表达式。 | + +**模式** + - `default`: 默认模式。 + - `deduplication`: 当某个事件重复发生时,这个重复发生的事件会阻止后续的处理过程。如,指定事件链为[event1='A', event2='B', event3='C', event4='D'],原始事件链为"A-B-C-B-D"。由于B事件重复,最终的结果事件链为A-B-C,最大长度为3。 + - `fixed`: 不允许事件的顺序发生交错,即事件发生的顺序必须和指定的事件链顺序一致。如,指定事件链为[event1='A', event2='B', event3='C', event4='D'],原始事件链为"A-B-D-C",则结果事件链为A-B,最大长度为2 + - `increase`: 选中的事件的时间戳必须按照指定事件链严格递增。 + +## 返回值 + +返回一个整数,表示在指定时间窗口内完成的最大连续步骤数。 + ## 举例 ### 举例1: default 模式 -使用默认模式,筛选出不同```user_id```对应的最大连续事件数,时间窗口为```5```分钟: +使用默认模式,筛选出不同`user_id`对应的最大连续事件数,时间窗口为`5`分钟: ```sql CREATE TABLE events( @@ -82,7 +93,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -93,11 +106,11 @@ order BY +---------+-------+ ``` -对于```uesr_id=100123```,因为```付款```事件发生的时间超出了时间窗口,所以匹配到的事件链是```登陆-访问-下单```。 +对于`uesr_id=100123`,因为`付款`事件发生的时间超出了时间窗口,所以匹配到的事件链是`登陆-访问-下单`。 ### 举例2: deduplication 模式 -使用```deduplication```模式,筛选出不同```user_id```对应的最大连续事件数,时间窗口为```1```小时: +使用`deduplication`模式,筛选出不同`user_id`对应的最大连续事件数,时间窗口为`1`小时: ```sql CREATE TABLE events( @@ -141,7 +154,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -151,11 +166,11 @@ order BY | 100127 | 2 | +---------+-------+ ``` -对于```uesr_id=100123```,匹配到```访问```事件后,```登录```事件重复出现,所以匹配到的事件链是```登陆-访问```。 +对于`uesr_id=100123`,匹配到`访问`事件后,`登录`事件重复出现,所以匹配到的事件链是`登陆-访问`。 ### 举例3: fixed 模式 -使用```fixed```模式,筛选出不同```user_id```对应的最大连续事件数,时间窗口为```1```小时: +使用`fixed`模式,筛选出不同`user_id`对应的最大连续事件数,时间窗口为`1`小时: ```sql CREATE TABLE events( @@ -199,7 +214,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -209,11 +226,11 @@ order BY | 100127 | 2 | +---------+-------+ ``` -对于```uesr_id=100123```,匹配到```下单```事件后,事件链被```登录2```事件打断,所以匹配到的事件链是```登陆-访问-下单```。 +对于`uesr_id=100123`,匹配到`下单`事件后,事件链被`登录2`事件打断,所以匹配到的事件链是`登陆-访问-下单`。 ### 举例4: increase 模式 -使用```increase```模式,筛选出不同```user_id```对应的最大连续事件数,时间窗口为```1```小时: +使用`increase`模式,筛选出不同`user_id`对应的最大连续事件数,时间窗口为`1`小时: ```sql CREATE TABLE events( @@ -256,7 +273,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -266,8 +285,5 @@ order BY | 100127 | 2 | +---------+-------+ ``` -对于```uesr_id=100123```,```付款```事件的时间戳与```下单```事件的时间戳发生在同一秒,没有递增,所以匹配到的事件链是```登陆-访问-下单```。 - -### keywords +对于`uesr_id=100123`,`付款`事件的时间戳与`下单`事件的时间戳发生在同一秒,没有递增,所以匹配到的事件链是`登陆-访问-下单`。 - WINDOW,FUNCTION,WINDOW_FUNNEL diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md index 2e658573e9936..571a0d1543161 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md @@ -24,27 +24,38 @@ specific language governing permissions and limitations under the License. --> -## hours_add + ## 描述 + +返回一个新的日期时间值,该值是在输入的日期时间上增加指定的小时数。 + ## 语法 -`DATETIME HOURS_ADD(DATETIME date, INT hours)` +```sql +HOURS_ADD(, ) +``` + +## 参数 -从日期时间或日期加上指定小时数 +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIME 或 DATE | +| `` | 要增加的小时数,类型为 INT | -参数 date 可以是 DATETIME 或者 DATE 类型,返回类型为 DATETIME。 +## 返回值 + +返回类型为 DATETIME,返回以输入日期时间为基准,增加指定小时数后的时间值。 ## 举例 -``` -mysql> select hours_add("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| hours_add('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-02-02 03:02:02 | -+-------------------------------------+ +```sql +SELECT HOURS_ADD('2020-02-02 02:02:02', 1); ``` -### keywords - - HOURS_ADD +```text ++------------------------------------------------------------+ +| hours_add(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), 1) | ++------------------------------------------------------------+ +| 2020-02-02 03:02:02 | ++------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md index 42290a06a827d..7b0150d470c65 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md @@ -24,25 +24,38 @@ specific language governing permissions and limitations under the License. --> -## hours_diff + ## 描述 + +开始时间到结束时间相差几小时。 + ## 语法 -`INT hours_diff(DATETIME enddate, DATETIME startdate)` +```sql +HOURS_DIFF(, ) +``` + +## 参数 -开始时间到结束时间相差几小时 +| 参数 | 说明 | +| ---- | ---- | +| `` | 结束时间,类型为 DATETIME 或 DATE | +| `` | 开始时间,类型为 DATETIME 或 DATE | + +## 返回值 + +返回类型为 INT,返回开始时间到结束时间相差的小时数。 ## 举例 -``` -mysql> select hours_diff('2020-12-25 22:00:00','2020-12-25 21:00:00'); -+----------------------------------------------------------+ -| hours_diff('2020-12-25 22:00:00', '2020-12-25 21:00:00') | -+----------------------------------------------------------+ -| 1 | -+----------------------------------------------------------+ +```sql +SELECT HOURS_DIFF('2020-12-25 22:00:00', '2020-12-25 21:00:00'); ``` -### keywords - - hours_diff +```text ++--------------------------------------------------------------------------------------------------------+ +| hours_diff(cast('2020-12-25 22:00:00' as DATETIMEV2(0)), cast('2020-12-25 21:00:00' as DATETIMEV2(0))) | ++--------------------------------------------------------------------------------------------------------+ +| 1 | ++--------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md index 72cdcbb4b3a6c..7d46e4a94db55 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md @@ -24,27 +24,38 @@ specific language governing permissions and limitations under the License. --> -## hours_sub + ## 描述 + +返回一个新的日期时间值,该值是从输入的日期时间中减去指定的小时数。 + ## 语法 -`DATETIME HOURS_SUB(DATETIME date, INT hours)` +```sql +HOURS_SUB(, ) +``` + +## 参数 -从日期时间或日期减去指定小时数 +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIME 或 DATE | +| `` | 要减去的小时数,类型为 INT | -参数 date 可以是 DATETIME 或者 DATE 类型,返回类型为 DATETIME。 +## 返回值 + +返回类型为 DATETIME,返回以输入日期时间为基准,减去指定小时数后的时间值。 ## 举例 -``` -mysql> select hours_sub("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| hours_sub('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-02-02 01:02:02 | -+-------------------------------------+ +```sql +SELECT HOURS_SUB('2020-02-02 02:02:02', 1); ``` -### keywords - - HOURS_SUB +```text ++------------------------------------------------------------+ +| hours_sub(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), 1) | ++------------------------------------------------------------+ +| 2020-02-02 01:02:02 | ++------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md index 02f695b712737..456daea9869af 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md @@ -22,28 +22,42 @@ specific language governing permissions and limitations under the License. --> -## last_day + ## 描述 + +返回输入日期所在月份的最后一天的日期。根据不同月份,返回日期的具体日期值为: + +- 28 日:非闰年的二月 +- 29 日:闰年的二月 +- 30 日:四月、六月、九月、十一月 +- 31 日:一月、三月、五月、七月、八月、十月、十二月 + ## 语法 -`DATE last_day(DATETIME date)` +```sql +LAST_DAY() +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIME 或 DATE | + +## 返回值 -返回输入日期中月份的最后一天;所以返回的日期中,年和月不变,日可能是如下情况: -'28'(非闰年的二月份), -'29'(闰年的二月份), -'30'(四月,六月,九月,十一月), -'31'(一月,三月,五月,七月,八月,十月,十二月) +返回类型为 DATE,返回输入日期所在月份的最后一天的日期。 ## 举例 -``` -mysql > select last_day('2000-02-03'); -+-------------------+ -| last_day('2000-02-03 00:00:00') | -+-------------------+ -| 2000-02-29 | -+-------------------+ +```sql +SELECT LAST_DAY('2000-02-03'); ``` -### keywords - LAST_DAY,DAYS +```text ++-----------------------------------------------+ +| last_day(cast('2000-02-03' as DATETIMEV2(0))) | ++-----------------------------------------------+ +| 2000-02-29 | ++-----------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md index 6ab0f9704b8ab..e2d1615ec6d47 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md @@ -24,24 +24,42 @@ specific language governing permissions and limitations under the License. --> -## makedate + ## 描述 + +根据指定的年份和一年中的天数(dayofyear)构建并返回一个日期。 + +特殊情况: +- 当 `` 小于等于 0 时,返回 NULL +- 当 `` 超过当年天数时,会自动往后顺延到下一年 + ## 语法 -`DATE MAKEDATE(INT year, INT dayofyear)` +```sql +MAKEDATE(, ) +``` + +## 参数 -返回指定年份和dayofyear构建的日期。dayofyear必须大于0,否则结果为空。 +| 参数 | 说明 | +| ---- | ---- | +| year | 指定的年份,类型为 INT | +| dayofyear | 一年中的第几天(1-366),类型为 INT | + +## 返回值 + +返回类型为 DATE,返回以指定年份和一年中的第几天构建的日期。 ## 举例 + +```sql +SELECT MAKEDATE(2021, 1), MAKEDATE(2021, 100), MAKEDATE(2021, 400); ``` -mysql> select makedate(2021,1), makedate(2021,100), makedate(2021,400); + +```text +-------------------+---------------------+---------------------+ | makedate(2021, 1) | makedate(2021, 100) | makedate(2021, 400) | +-------------------+---------------------+---------------------+ | 2021-01-01 | 2021-04-10 | 2022-02-04 | +-------------------+---------------------+---------------------+ ``` - -### keywords - - MAKEDATE diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md index 513b0314b5d80..e529b88d9d49c 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md @@ -24,26 +24,37 @@ specific language governing permissions and limitations under the License. --> -## microsecond + ## 描述 + +从日期时间值中提取微秒部分的值。返回的范围是 0 到 999999。 + ## 语法 -`INT MICROSECOND(DATETIMEV2 date)` +```sql +MICROSECOND() +``` + +## 参数 +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIMEV2,精度需要大于 0 | -获得日期中的微秒信息。 +## 返回值 -参数为 Datetime 类型 +返回类型为 INT,返回日期时间值中的微秒部分。取值范围为 0 到 999999。对于精度小于 6 的输入,不足的位数补 0。 ## 举例 +```sql +SELECT MICROSECOND(CAST('1999-01-02 10:11:12.000123' AS DATETIMEV2(6))) AS microsecond; ``` -mysql> select microsecond(cast('1999-01-02 10:11:12.000123' as datetimev2(6))) as microsecond; + +```text +-------------+ | microsecond | +-------------+ | 123 | +-------------+ ``` -### keywords - MICROSECOND diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md index 962a328dcf636..7eb111621184b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md @@ -24,25 +24,42 @@ specific language governing permissions and limitations under the License. --> -## microseconds_add + ## 描述 + +向日期时间值中添加指定的微秒数,返回一个新的日期时间值。 + ## 语法 -`DATETIMEV2 microseconds_add(DATETIMEV2 basetime, INT delta)` -- basetime: DATETIMEV2 类型起始时间 -- delta: 从 basetime 起需要相加的微秒数 -- 返回类型为 DATETIMEV2 +```sql +MICROSECONDS_ADD(, ) +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIMEV2 | +| `` | 要添加的微秒数,类型为 INT,1 秒 = 1,000,000 微秒 | + +## 返回值 + +返回类型为 DATETIMEV2,返回以输入日期时间为基准,增加指定微秒数后的时间值。返回值的精度与输入参数 basetime 的精度相同。 ## 举例 + +```sql +SELECT NOW(3) AS current_time, MICROSECONDS_ADD(NOW(3), 100000) AS after_add; ``` -mysql> select now(3), microseconds_add(now(3), 100000); -+-------------------------+----------------------------------+ -| now(3) | microseconds_add(now(3), 100000) | -+-------------------------+----------------------------------+ -| 2023-02-21 11:35:56.556 | 2023-02-21 11:35:56.656 | -+-------------------------+----------------------------------+ + +```text ++-------------------------+----------------------------+ +| current_time | after_add | ++-------------------------+----------------------------+ +| 2025-01-16 11:48:10.505 | 2025-01-16 11:48:10.605000 | ++-------------------------+----------------------------+ ``` -`now(3)` 返回精度位数 3 的 DATETIMEV2 类型当前时间,`microseconds_add(now(3), 100000)` 返回当前时间加上 100000 微秒后的 DATETIMEV2 类型时间 -### keywords - microseconds_add +注意: +- NOW(3) 返回精度为 3 位小数的当前时间 +- 添加 100000 微秒(0.1 秒)后,时间增加了 0.1 秒 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md index 2dfb6fe286610..fa70308687ee5 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md @@ -24,26 +24,41 @@ specific language governing permissions and limitations under the License. --> -## microseconds_diff + ## 描述 + +计算两个日期时间值之间的微秒差值。结果为 `` 减去 `` 的微秒数。 + ## 语法 -`INT microseconds_diff(DATETIME enddate, DATETIME startdate)` +```sql +MICROSECONDS_DIFF(, ) +``` + +## 参数 -开始时间到结束时间相差几微秒 +| 参数 | 说明 | +| ---- | ---- | +| `` | 结束时间,类型为 DATETIMEV2 | +| `` | 开始时间,类型为 DATETIMEV2 | + +## 返回值 + +返回类型为 INT,表示两个时间之间的微秒差值。 +- 如果 `` 大于 ``,返回正数 +- 如果 `` 小于 ``,返回负数 +- 1 秒 = 1,000,000 微秒 ## 举例 +```sql +SELECT MICROSECONDS_DIFF('2020-12-25 21:00:00.623000','2020-12-25 21:00:00.123000'); ``` -mysql> select microseconds_diff('2020-12-25 21:00:00.623000','2020-12-25 21:00:00.123000'); + +```text +-----------------------------------------------------------------------------------------------------------------------------+ -| microseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(6)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(6))) | +| microseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(3)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(3))) | +-----------------------------------------------------------------------------------------------------------------------------+ | 500000 | +-----------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.12 sec) ``` - -### keywords - - microseconds_diff diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md index 6882ec9daa6f0..20dc5382c3208 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md @@ -24,27 +24,43 @@ specific language governing permissions and limitations under the License. --> -## microseconds_sub + ## 描述 + +从日期时间值中减去指定的微秒数,返回一个新的日期时间值。 + ## 语法 -`DATETIMEV2 microseconds_sub(DATETIMEV2 basetime, INT delta)` -- basetime: DATETIMEV2 类型起始时间 -- delta: 从 basetime 起需要扣减的微秒数 -- 返回类型为 DATETIMEV2 +```sql +MICROSECONDS_SUB(, ) +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIMEV2 | +| `` | 要减去的微秒数,类型为 INT,1 秒 = 1,000,000 微秒 | + +## 返回值 + +返回类型为 DATETIMEV2,返回以输入日期时间为基准,减去指定微秒数后的时间值。返回值的精度与输入参数 basetime 的精度相同。 ## 举例 + +```sql +SELECT NOW(3) AS current_time, MICROSECONDS_SUB(NOW(3), 100000) AS after_sub; ``` -mysql> select now(3), microseconds_sub(now(3), 100000); -+-------------------------+----------------------------------+ -| now(3) | microseconds_sub(now(3), 100000) | -+-------------------------+----------------------------------+ -| 2023-02-25 02:03:05.174 | 2023-02-25 02:03:05.074 | -+-------------------------+----------------------------------+ -``` -`now(3)` 返回精度位数 3 的 DATETIMEV2 类型当前时间,`microseconds_add(now(3), 100000)` 返回当前时间减去 100000 微秒后的 DATETIMEV2 类型时间 -### keywords - microseconds_sub +```text ++-------------------------+----------------------------+ +| current_time | after_sub | ++-------------------------+----------------------------+ +| 2025-01-16 11:52:22.296 | 2025-01-16 11:52:22.196000 | ++-------------------------+----------------------------+ +``` - \ No newline at end of file +注意: +- `NOW(3)` 返回精度为 3 位小数的当前时间 +- 减去 100000 微秒(0.1 秒)后,时间减少了 0.1 秒 +- 函数的计算结果与输入时间的精度有关 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md index 7575f0502214c..658634d67ea9a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md @@ -24,28 +24,43 @@ specific language governing permissions and limitations under the License. --> -## milliseconds_add + ## 描述 + +向日期时间值中添加指定的毫秒数,返回一个新的日期时间值。 + ## 语法 -`DATETIMEV2 milliseconds_add(DATETIMEV2 basetime, INT delta)` -- basetime: DATETIMEV2 类型起始时间 -- delta: 从 basetime 起需要相加的毫秒数 -- 返回类型为 DATETIMEV2 +```sql +MILLISECONDS_ADD(, ) +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIMEV2 | +| `` | 要添加的毫秒数,类型为 INT,1 秒 = 1,000 毫秒 = 1,000,000 微秒 | + +## 返回值 + +返回类型为 DATETIMEV2,返回以输入日期时间为基准,增加指定毫秒数后的时间值。返回值的精度与输入参数 basetime 的精度相同。 ## 举例 + +```sql +SELECT MILLISECONDS_ADD('2023-09-08 16:02:08.435123', 1); ``` -mysql> select milliseconds_add('2023-09-08 16:02:08.435123', 1); + +```text +--------------------------------------------------------------------------+ | milliseconds_add(cast('2023-09-08 16:02:08.435123' as DATETIMEV2(6)), 1) | +--------------------------------------------------------------------------+ | 2023-09-08 16:02:08.436123 | +--------------------------------------------------------------------------+ -1 row in set (0.04 sec) ``` - -### keywords - milliseconds_add - - \ No newline at end of file +注意: +- 示例中添加 1 毫秒后,时间从 .435123 增加到 .436123 +- 1 毫秒等于 1000 微秒 +- 函数的计算结果与输入时间的精度有关,示例使用了 6 位小数精度 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md index b30e62fb8bd4c..caea0e696f08e 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md @@ -24,26 +24,46 @@ specific language governing permissions and limitations under the License. --> -## milliseconds_diff ## 描述 + +计算两个日期时间值之间的毫秒差值。结果为 `` 减去 `` 的毫秒数。 + ## 语法 -`INT milliseconds_diff(DATETIME enddate, DATETIME startdate)` +```sql +MILLISECONDS_DIFF(, ) +``` + +## 参数 -开始时间到结束时间相差几毫秒 +| 参数 | 说明 | +| ---- | ---- | +| `` | 结束时间,类型为 DATETIMEV2 | +| `` | 开始时间,类型为 DATETIMEV2 | + +## 返回值 + +返回类型为 INT,表示两个时间之间的毫秒差值。 +- 如果 `` 大于 ``,返回正数 +- 如果 `` 小于 ``,返回负数 +- 1 秒 = 1,000 毫秒 +- 1 毫秒 = 1,000 微秒 ## 举例 +```sql +SELECT MILLISECONDS_DIFF('2020-12-25 21:00:00.623000', '2020-12-25 21:00:00.123000'); ``` -mysql> select milliseconds_diff('2020-12-25 21:00:00.623000','2020-12-25 21:00:00.123000'); + +```text +-----------------------------------------------------------------------------------------------------------------------------+ -| milliseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(6)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(6))) | +| milliseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(3)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(3))) | +-----------------------------------------------------------------------------------------------------------------------------+ | 500 | +-----------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) ``` -### keywords - - milliseconds_diff +注意: +- 示例中的时间差为 0.5 秒,即 500 毫秒 +- 函数的计算结果与输入时间的精度有关,示例使用了 3 位小数精度 +- 结果只返回毫秒差值,不包含微秒部分 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md index 840a533669bab..ee0608d66eb3f 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md @@ -24,28 +24,43 @@ specific language governing permissions and limitations under the License. --> -## milliseconds_sub ## 描述 + +从日期时间值中减去指定的毫秒数,返回一个新的日期时间值。 + ## 语法 -`DATETIMEV2 milliseconds_sub(DATETIMEV2 basetime, INT delta)` -- basetime: DATETIMEV2 类型起始时间 -- delta: 从 basetime 起需要扣减的毫秒数 -- 返回类型为 DATETIMEV2 +```sql +MILLISECONDS_SUB(, ) +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型为 DATETIMEV2 | +| `` | 要减去的毫秒数,类型为 INT,1 秒 = 1,000 毫秒 = 1,000,000 微秒 | + +## 返回值 + +返回类型为 DATETIMEV2,返回以输入日期时间为基准,减去指定毫秒数后的时间值。返回值的精度与输入参数 basetime 的精度相同。 ## 举例 + +```sql +SELECT MILLISECONDS_SUB('2023-09-08 16:02:08.435123', 1); ``` -mysql> select milliseconds_sub('2023-09-08 16:02:08.435123', 1); + +```text +--------------------------------------------------------------------------+ | milliseconds_sub(cast('2023-09-08 16:02:08.435123' as DATETIMEV2(6)), 1) | +--------------------------------------------------------------------------+ | 2023-09-08 16:02:08.434123 | +--------------------------------------------------------------------------+ -1 row in set (0.11 sec) ``` - -### keywords - milliseconds_sub - - \ No newline at end of file +注意: +- 示例中减去 1 毫秒后,时间从 .435123 减少到 .434123 +- 1 毫秒等于 1000 微秒 +- 函数的计算结果与输入时间的精度有关,示例使用了 6 位小数精度 +- 结果保留了微秒级别的精度 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md index 54a81bf3a8668..1a5cdf24810ce 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md @@ -1,6 +1,6 @@ --- { - "title": "minute_floor", + "title": "MINUTE_FLOOR", "language": "zh-CN" } --- @@ -24,39 +24,51 @@ specific language governing permissions and limitations under the License. --> -## minute_floor ## 描述 + +将日期时间向下取整到最近的指定分钟周期。如果指定了起始时间(origin),则以该时间为基准计算周期。 + ## 语法 ```sql -DATETIME MINUTE_FLOOR(DATETIME datetime) -DATETIME MINUTE_FLOOR(DATETIME datetime, DATETIME origin) -DATETIME MINUTE_FLOOR(DATETIME datetime, INT period) -DATETIME MINUTE_FLOOR(DATETIME datetime, INT period, DATETIME origin) +MINUTE_FLOOR() +MINUTE_FLOOR(, ) +MINUTE_FLOOR(, ) +MINUTE_FLOOR(, , ) ``` -将日期转化为指定的时间间隔周期的最近下取整时刻。 +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 需要向下取整的日期时间值,类型为 DATETIME 或 DATETIMEV2 | +| `` | 分钟周期值,类型为 INT,表示每个周期包含的分钟数 | +| `` | 周期的起始时间点,类型为 DATETIME 或 DATETIMEV2,默认值为 0001-01-01 00:00:00 | + +## 返回值 -- datetime:参数是合法的日期表达式。 -- period:参数是指定每个周期有多少天组成。 -- origin:开始的时间起点,如果不填,默认是 0001-01-01T00:00:00。 +返回类型为 DATETIMEV2,表示向下取整后的日期时间值。 ## 举例 +```sql +SELECT MINUTE_FLOOR("2023-07-13 22:28:18", 5); ``` -mysql> select minute_floor("2023-07-13 22:28:18", 5); + +```text +---------------------------------------------------------------+ | minute_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +---------------------------------------------------------------+ | 2023-07-13 22:25:00 | +---------------------------------------------------------------+ -1 row in set (0.06 sec) ``` -### keywords - - MINUTE_FLOOR, MINUTE, FLOOR +注意: +- 不指定 period 时,默认以 1 分钟为周期 +- period 必须为正整数 +- 结果总是向过去时间取整 +- 与 MINUTE_CEIL 相反,MINUTE_FLOOR 总是舍去超出周期的部分 -### Best Practice +## 最佳实践 还可参阅 [date_floor](./date_floor) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md index 0803c1f016ab0..fcd872cb1c358 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md @@ -25,26 +25,41 @@ under the License. --> -## Description +## 描述 +从日期时间值中提取分钟部分的值。返回值范围为 0 到 59。 -获得日期中的分钟的信息,返回值范围从 0-59。 +## 语法 -参数为 Date 或者 Datetime,Time 类型 +```sql +MINUTE() +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型可以是 DATE、DATETIME、DATETIMEV2 或 TIME | -## Syntax +## 返回值 -`INT MINUTE(DATETIME date)` +返回类型为 INT,表示分钟值,取值范围为 0-59。 -## Example +## 举例 ```sql -mysql> select minute('2018-12-31 23:59:59'); -+-----------------------------+ -| minute('2018-12-31 23:59:59') | -+-----------------------------+ -| 59 | -+-----------------------------+ +SELECT MINUTE('2018-12-31 23:59:59'); ``` -## Keywords - MINUTE + +```text ++------------------------------------------------------+ +| minute(cast('2018-12-31 23:59:59' as DATETIMEV2(0))) | ++------------------------------------------------------+ +| 59 | ++------------------------------------------------------+ +``` + +注意: +- 输入参数可以是多种时间相关类型 +- 返回值始终是 0-59 之间的整数 +- 如果输入参数为 NULL,则返回 NULL diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute_ceil.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute_ceil.md index d8f9cec1ff25b..006bac979249d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute_ceil.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute_ceil.md @@ -1,6 +1,6 @@ --- { - "title": "minute_ceil", + "title": "MINUTE_CEIL", "language": "zh-CN" } --- @@ -24,39 +24,50 @@ specific language governing permissions and limitations under the License. --> -## minute_ceil ## 描述 + +将日期时间向上取整到最近的指定分钟周期。如果指定了起始时间(origin),则以该时间为基准计算周期。 + ## 语法 ```sql -DATETIME MINUTE_CEIL(DATETIME datetime) -DATETIME MINUTE_CEIL(DATETIME datetime, DATETIME origin) -DATETIME MINUTE_CEIL(DATETIME datetime, INT period) -DATETIME MINUTE_CEIL(DATETIME datetime, INT period, DATETIME origin) +MINUTE_CEIL() +MINUTE_CEIL(, ) +MINUTE_CEIL(, ) +MINUTE_CEIL(, , ) ``` -将日期转化为指定的时间间隔周期的最近上取整时刻。 +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 需要向上取整的日期时间值,类型为 DATETIME 或 DATETIMEV2 | +| `` | 分钟周期值,类型为 INT,表示每个周期包含的分钟数 | +| `` | 周期的起始时间点,类型为 DATETIME 或 DATETIMEV2,默认值为 0001-01-01 00:00:00 | + +## 返回值 -- datetime:参数是合法的日期表达式。 -- period:参数是指定每个周期有多少分钟组成。 -- origin:开始的时间起点,如果不填,默认是 0001-01-01T00:00:00。 +返回类型为 DATETIMEV2,返回以输入日期时间为基准,向上取整到最近的指定分钟周期后的时间值。返回值的精度与输入参数 datetime 的精度相同。 ## 举例 +```sql +SELECT MINUTE_CEIL("2023-07-13 22:28:18", 5); ``` -mysql> select minute_ceil("2023-07-13 22:28:18", 5); + +```text +--------------------------------------------------------------+ | minute_ceil(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +--------------------------------------------------------------+ | 2023-07-13 22:30:00 | +--------------------------------------------------------------+ -1 row in set (0.21 sec) ``` -### keywords - - MINUTE_CEIL, MINUTE, CEIL +注意: +- 不指定 period 时,默认以 1 分钟为周期 +- period 必须为正整数 +- 结果总是向未来时间取整 -### Best Practice +## 最佳实践 还可参阅 [date_ceil](./date_ceil) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md index 60e3e55c887b0..fe4721e2ce618 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md @@ -24,27 +24,42 @@ specific language governing permissions and limitations under the License. --> -## minutes_add ## 描述 + +向日期时间值中添加指定的分钟数,返回一个新的日期时间值。 + ## 语法 -`DATETIME MINUTES_ADD(DATETIME date, INT minutes)` +```sql +MINUTES_ADD(, ) +``` + +## 参数 -从日期时间或日期加上指定分钟数 +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型可以是 DATE、DATETIME 或 DATETIMEV2 | +| `` | 要添加的分钟数,类型为 INT,可以为正数或负数 | -参数 date 可以是 DATETIME 或者 DATE 类型,返回类型为 DATETIME。 +## 返回值 + +返回类型为 DATETIME,表示添加指定分钟数后的日期时间值。 ## 举例 -``` -mysql> select minutes_add("2020-02-02", 1); -+---------------------------------------+ -| minutes_add('2020-02-02 00:00:00', 1) | -+---------------------------------------+ -| 2020-02-02 00:01:00 | -+---------------------------------------+ +```sql +SELECT MINUTES_ADD("2020-02-02", 1); ``` -### keywords +```text ++-----------------------------------------------------+ +| minutes_add(cast('2020-02-02' as DATETIMEV2(0)), 1) | ++-----------------------------------------------------+ +| 2020-02-02 00:01:00 | ++-----------------------------------------------------+ +``` - MINUTES_ADD +注意: +- 当添加的分钟数为负数时,相当于减去对应的分钟数 +- 函数会自动处理跨小时、跨天的情况 +- 如果输入参数为 NULL,则返回 NULL diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md index 4b216c3428bdd..96e3de8cdb608 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md @@ -24,25 +24,44 @@ specific language governing permissions and limitations under the License. --> -## minutes_diff ## 描述 + +计算两个日期时间值之间的分钟差值。结果为 `` 减去 `` 的分钟数。 + ## 语法 -`INT minutes_diff(DATETIME enddate, DATETIME startdate)` +```sql +MINUTES_DIFF(, ) +``` + +## 参数 -开始时间到结束时间相差几分钟 +| 参数 | 说明 | +| ---- | ---- | +| `` | 结束时间,类型可以是 DATE、DATETIME 或 DATETIMEV2 | +| `` | 开始时间,类型可以是 DATE、DATETIME 或 DATETIMEV2 | + +## 返回值 + +返回类型为 INT,表示两个时间之间的分钟差值。 +- 如果 `` 大于 ``,返回正数 +- 如果 `` 小于 ``,返回负数 ## 举例 -``` -mysql> select minutes_diff('2020-12-25 22:00:00','2020-12-25 21:00:00'); -+------------------------------------------------------------+ -| minutes_diff('2020-12-25 22:00:00', '2020-12-25 21:00:00') | -+------------------------------------------------------------+ -| 60 | -+------------------------------------------------------------+ +```sql +SELECT MINUTES_DIFF('2020-12-25 22:00:00', '2020-12-25 21:00:00'); ``` -### keywords +```text ++----------------------------------------------------------------------------------------------------------+ +| minutes_diff(cast('2020-12-25 22:00:00' as DATETIMEV2(0)), cast('2020-12-25 21:00:00' as DATETIMEV2(0))) | ++----------------------------------------------------------------------------------------------------------+ +| 60 | ++----------------------------------------------------------------------------------------------------------+ +``` - minutes_diff +注意: +- 计算只考虑完整的分钟数,秒和毫秒部分会被忽略 +- 如果任一输入参数为 NULL,则返回 NULL +- 可以处理跨天、跨月、跨年的时间差计算 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md index 1c54f977ef150..238f3ff8159a0 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md @@ -24,27 +24,44 @@ specific language governing permissions and limitations under the License. --> -## minutes_sub + ## 描述 + +从日期时间值中减去指定的分钟数,返回一个新的日期时间值。 + ## 语法 -`DATETIME MINUTES_SUB(DATETIME date, INT minutes)` +```sql +MINUTES_SUB(, ) +``` + +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型可以是 DATE、DATETIME 或 DATETIMEV2 | +| `` | 要减去的分钟数,类型为 INT,可以为正数或负数 | -从日期时间或日期减去指定分钟数 +## 返回值 -参数 date 可以是 DATETIME 或者 DATE 类型,返回类型为 DATETIME。 +返回类型为 DATETIME,表示减去指定分钟数后的日期时间值。 ## 举例 -``` -mysql> select minutes_sub("2020-02-02 02:02:02", 1); -+---------------------------------------+ -| minutes_sub('2020-02-02 02:02:02', 1) | -+---------------------------------------+ -| 2020-02-02 02:01:02 | -+---------------------------------------+ +```sql +SELECT MINUTES_SUB("2020-02-02 02:02:02", 1); ``` -### keywords +```text ++--------------------------------------------------------------+ +| minutes_sub(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), 1) | ++--------------------------------------------------------------+ +| 2020-02-02 02:01:02 | ++--------------------------------------------------------------+ +``` - MINUTES_SUB +注意: +- 当减去的分钟数为负数时,相当于加上对应的分钟数 +- 函数会自动处理跨小时、跨天的情况 +- 如果输入参数为 NULL,则返回 NULL +- 结果会保留原始时间的秒数部分 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md index 3c56748a182d3..f26db7f8dc6bc 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md @@ -1,6 +1,6 @@ --- { - "title": "month_ceil", + "title": "MONTH_CEIL", "language": "zh-CN" } --- @@ -24,39 +24,51 @@ specific language governing permissions and limitations under the License. --> -## month_ceil ## 描述 + +将日期时间值向上取整到最近的指定月份周期。如果指定了起始时间(origin),则以该时间为基准计算周期。 + ## 语法 ```sql -DATETIME MONTH_CEIL(DATETIME datetime) -DATETIME MONTH_CEIL(DATETIME datetime, DATETIME origin) -DATETIME MONTH_CEIL(DATETIME datetime, INT period) -DATETIME MONTH_CEIL(DATETIME datetime, INT period, DATETIME origin) +MONTH_CEIL() +MONTH_CEIL(, ) +MONTH_CEIL(, ) +MONTH_CEIL(, , ) ``` -将日期转化为指定的时间间隔周期的最近上取整时刻。 +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 需要向上取整的日期时间值,类型为 DATETIME 或 DATETIMEV2 | +| `` | 月份周期值,类型为 INT,表示每个周期包含的月数 | +| `` | 周期的起始时间点,类型为 DATETIME 或 DATETIMEV2,默认值为 0001-01-01 00:00:00 | + +## 返回值 -- datetime:参数是合法的日期表达式。 -- period:参数是指定每个周期有几个月组成。 -- origin:开始的时间起点,如果不填,默认是 0001-01-01T00:00:00。 +返回类型为 DATETIME,表示向上取整后的日期时间值。结果的时间部分将被设置为 00:00:00。 ## 举例 +```sql +SELECT MONTH_CEIL("2023-07-13 22:28:18", 5); ``` -mysql> select month_ceil("2023-07-13 22:28:18", 5); + +```text +-------------------------------------------------------------+ | month_ceil(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +-------------------------------------------------------------+ | 2023-10-01 00:00:00 | +-------------------------------------------------------------+ -1 row in set (0.02 sec) ``` -### keywords - - MONTH_CEIL, MONTH, CEIL +注意: +- 不指定 period 时,默认以 1 个月为周期 +- period 必须为正整数 +- 结果总是向未来时间取整 +- 返回值的时间部分总是 00:00:00 -### Best Practice +## 最佳实践 还可参阅 [date_ceil](./date_ceil) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md index e1684fce70bfa..45610a1bfb732 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md @@ -1,6 +1,6 @@ --- { - "title": "month_floor", + "title": "MONTH_FLOOR", "language": "zh-CN" } --- @@ -24,39 +24,52 @@ specific language governing permissions and limitations under the License. --> -## month_floor ## 描述 + +将日期时间值向下取整到最近的指定月份周期。如果指定了起始时间(origin),则以该时间为基准计算周期。 + ## 语法 ```sql -DATETIME MONTH_FLOOR(DATETIME datetime) -DATETIME MONTH_FLOOR(DATETIME datetime, DATETIME origin) -DATETIME MONTH_FLOOR(DATETIME datetime, INT period) -DATETIME MONTH_FLOOR(DATETIME datetime, INT period, DATETIME origin) +MONTH_FLOOR() +MONTH_FLOOR(, ) +MONTH_FLOOR(, ) +MONTH_FLOOR(, , ) ``` -将日期转化为指定的时间间隔周期的最近下取整时刻。 +## 参数 + +| 参数 | 说明 | +| ---- | ---- | +| `` | 需要向下取整的日期时间值,类型为 DATETIME 或 DATETIMEV2 | +| `` | 月份周期值,类型为 INT,表示每个周期包含的月数 | +| `` | 周期的起始时间点,类型为 DATETIME 或 DATETIMEV2,默认值为 0001-01-01 00:00:00 | + +## 返回值 -- datetime:参数是合法的日期表达式。 -- period:参数是指定每个周期有多少天组成。 -- origin:开始的时间起点,如果不填,默认是 0001-01-01T00:00:00。 +返回类型为 DATETIME,表示向下取整后的日期时间值。结果的时间部分将被设置为 00:00:00。 ## 举例 +```sql +SELECT MONTH_FLOOR("2023-07-13 22:28:18", 5); ``` -mysql> select month_floor("2023-07-13 22:28:18", 5); + +```text +--------------------------------------------------------------+ | month_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +--------------------------------------------------------------+ | 2023-05-01 00:00:00 | +--------------------------------------------------------------+ -1 row in set (0.12 sec) ``` -### keywords - - MONTH_FLOOR, MONTH, FLOOR +注意: +- 不指定 period 时,默认以 1 个月为周期 +- period 必须为正整数 +- 结果总是向过去时间取整 +- 返回值的时间部分总是 00:00:00 +- 与 MONTH_CEIL 相反,MONTH_FLOOR 总是舍去超出周期的部分 -### Best Practice +## 最佳实践 还可参阅 [date_floor](./date_floor) diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md index 1bd5109dc589f..9a8c52bd24014 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md @@ -24,28 +24,40 @@ specific language governing permissions and limitations under the License. --> -## month + ## 描述 + +从日期时间值中提取月份值。返回值范围为 1 到 12,分别代表一年中的 12 个月。 + ## 语法 -`INT MONTH(DATETIME date)` +```sql +MONTH() +``` + +## 参数 +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型可以是 DATE、DATETIME 或 DATETIMEV2 | -返回时间类型中的月份信息,范围是1, 12 +## 返回值 -参数为Date或者Datetime类型 +返回类型为 INT,表示月份值: +- 范围:1 到 12 +- 1 表示一月,12 表示十二月 +- 如果输入为 NULL,返回 NULL ## 举例 -``` -mysql> select month('1987-01-01'); -+-----------------------------+ -| month('1987-01-01 00:00:00') | -+-----------------------------+ -| 1 | -+-----------------------------+ +```sql +SELECT MONTH('1987-01-01'); ``` -### keywords - - MONTH +```text ++--------------------------------------------+ +| month(cast('1987-01-01' as DATETIMEV2(0))) | ++--------------------------------------------+ +| 1 | ++--------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md index 14475378ebc09..742c6a971f783 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md @@ -24,28 +24,40 @@ specific language governing permissions and limitations under the License. --> -## monthname + ## 描述 + +返回日期对应的英文月份名称。返回值为完整的英文月份名称(January 到 December)。 + ## 语法 -`VARCHAR MONTHNAME(DATE)` +```sql +MONTHNAME() +``` + +## 参数 +| 参数 | 说明 | +| ---- | ---- | +| `` | 输入的日期时间值,类型可以是 DATE、DATETIME 或 DATETIMEV2 | -返回日期对应的月份名字 +## 返回值 -参数为Date或者Datetime类型 +返回类型为 VARCHAR,表示月份的英文名称: +- 返回值范围:January, February, March, April, May, June, July, August, September, October, November, December +- 如果输入为 NULL,返回 NULL +- 返回值首字母大写,其余字母小写 ## 举例 -``` -mysql> select monthname('2008-02-03 00:00:00'); -+----------------------------------+ -| monthname('2008-02-03 00:00:00') | -+----------------------------------+ -| February | -+----------------------------------+ +```sql +SELECT MONTHNAME('2008-02-03 00:00:00'); ``` -### keywords - - MONTHNAME +```text ++---------------------------------------------------------+ +| monthname(cast('2008-02-03 00:00:00' as DATETIMEV2(0))) | ++---------------------------------------------------------+ +| February | ++---------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/json-functions/json-array.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/json-functions/json-array.md index 2b418ae1e17c6..b4b7568b14086 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/json-functions/json-array.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/json-functions/json-array.md @@ -24,47 +24,73 @@ specific language governing permissions and limitations under the License. --> -## json_array ## 描述 + +生成一个包含制定元素的 json 数组,未指定时返回空数组 + ## 语法 -`VARCHAR json_array(VARCHAR,...)` +```sql +JSON_ARRAY(, ...) +``` + +## 参数 +| 参数 | 描述 | +|------|------------------------------------------------------------| +| `, ...` | 要包含在 JSON 数组中的元素。可以是单个或者多个任意类型的值,包括`NULL`。如果没有指定元素,则返回一个空数组。 | -生成一个包含指定元素的json数组,未指定时返回空数组 +## 返回值 -## 举例 +返回一个包含指定元素的 JSON 数组。特殊情况: +* 如果指定的元素为`NULL`,则返回`NULL`。 +## 示例 + +```sql +select json_array(); ``` -MySQL> select json_array(); + +```text +--------------+ | json_array() | +--------------+ | [] | +--------------+ +``` -MySQL> select json_array(null); +```sql +select json_array(null); +``` + +```text +--------------------+ | json_array('NULL') | +--------------------+ | [NULL] | +--------------------+ +``` +```sql +SELECT json_array(1, "abc", NULL, TRUE, CURTIME()); +``` -MySQL> SELECT json_array(1, "abc", NULL, TRUE, CURTIME()); +```text +-----------------------------------------------+ | json_array(1, 'abc', 'NULL', TRUE, curtime()) | +-----------------------------------------------+ | [1, "abc", NULL, TRUE, "10:41:15"] | +-----------------------------------------------+ +``` +```sql +select json_array("a", null, "c"); +``` -MySQL> select json_array("a", null, "c"); +```text +------------------------------+ | json_array('a', 'NULL', 'c') | +------------------------------+ | ["a", NULL, "c"] | +------------------------------+ ``` -### keywords -json,array,json_array diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md index f6b0cdb832217..e1ce4ac677fae 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md @@ -26,48 +26,35 @@ under the License. ## 描述 +判断给定 `map` 中是否包含特定的键 `key` + ## 语法 -`BOOLEAN map_contains_key(Map map, K key)` +```sql +MAP_CONTAINS_KEY(, ) +``` -判断给定 `map` 中是否包含特定的键 `key` +## 参数 -## 举例 +| 参数 | 说明 | +| -- | -- | +| `` | 输入的 map 内容 | +| `` | 需要检索的key | -```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +## 返回值 -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +判断给定 `map` 中是否包含特定的键 `key`,存在返回 1 ,不存在返回 0 。 -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +## 举例 -mysql> select map_contains_key(map(null, 1, 2, null), null); -+-----------------------------------------------+ -| map_contains_key(map(NULL, 1, 2, NULL), NULL) | -+-----------------------------------------------+ -| 1 | -+-----------------------------------------------+ -1 row in set (0.14 sec) +```sql +select map_contains_key(map(null, 1, 2, null), null),map_contains_key(map(1, "100", 0.1, 2), 0.11); ``` -### Keywords - -MAP, CONTAINS, KEY, MAP_CONTAINS_KEY +```text ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_key(map(NULL, 1, 2, NULL), NULL) | map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast(0.11 as DECIMALV3(3, 2))) | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md index 8e2eb5b56a700..c255f874055f1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md @@ -26,64 +26,35 @@ under the License. ## 描述 -## 语法 - -`BOOLEAN map_contains_value(Map map, V value)` - 判断给定 `map` 中是否包含特定的值 `value` -## 举例 +## 语法 ```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +MAP_CONTAINS_VALUE(, ) +``` -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## 参数 -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +| 参数 | 说明 | +| -- | -- | +| `` | 输入的 map 内容 | +| `` | 需要检索的 value | -mysql> select map_contains_value(map(1, "100", 0.1, 2), 100.0); -+--------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(100.0 as VARCHAR(3))) | -+--------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+--------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## 返回值 -mysql> select map_contains_value(map(1, "100", 0.1, 2), 101); -+------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | -+------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.14 sec) +判断给定 `map` 中是否包含特定的值 `value`,存在返回 1 ,不存在返回 0 。 -mysql> select map_contains_value(map(null, 1, 2, null), null); -+-------------------------------------------------+ -| map_contains_value(map(NULL, 1, 2, NULL), NULL) | -+-------------------------------------------------+ -| 1 | -+-------------------------------------------------+ -1 row in set (0.15 sec) -``` +## 举例 -### Keywords +```sql +select map_contains_value(map(null, 1, 2, null), null),map_contains_value(map(1, "100", 0.1, 2), 101); +``` -MAP, CONTAINS, VALUE, MAP_CONTAINS_VALUE +```text ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_value(map(NULL, 1, 2, NULL), NULL) | map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md index 852b288f2440e..5579de67ce60b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md @@ -26,32 +26,34 @@ under the License. ## 描述 +将给定 `map` 的键提取成一个对应类型的 `ARRAY` + ## 语法 -`ARRAY map_keys(Map map)` +```sql +MAP_KEYS() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 输入的 map 内容 | + +## 返回值 将给定 `map` 的键提取成一个对应类型的 `ARRAY` ## 举例 ```sql -mysql> select map_keys(map(1, "100", 0.1, 2)); -+-------------------------------------------------------------------------------------------------+ -| map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+-------------------------------------------------------------------------------------------------+ -| [1.0, 0.1] | -+-------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) - -mysql> select map_keys(map()); -+-----------------+ -| map_keys(map()) | -+-----------------+ -| [] | -+-----------------+ -1 row in set (0.12 sec) +select map_keys(map()),map_keys(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, KEYS, MAP_KEYS +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_keys(map()) | map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| [] | [1.0, 0.1] | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md index 85424d7fecd6f..b3ca337613d91 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md @@ -1,7 +1,6 @@ --- { - "title": "MAP_SIZE - ", + "title": "MAP_SIZE", "language": "zh-CN" } --- @@ -24,3 +23,37 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## 描述 + +计算 Map 中元素的个数 + +## 语法 + +```sql +MAP_SIZE() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 输入的 map 内容 | + +## 返回值 + +返回 Map 中元素的个数 + +## 举例 + +```sql +select map_size(map()),map_size(map(1, "100", 0.1, 2)); +``` + +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_size(map()) | map_size(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| 0 | 2 | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md index b5a0b2e27d326..955db06dddae3 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md @@ -26,32 +26,34 @@ under the License. ## 描述 +将给定 `map` 的值提取成一个对应类型的 `ARRAY` + ## 语法 -`ARRAY map_values(Map map)` +```sql +MAP_VALUES() +``` + +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 输入的 map 内容 | + +## 返回值 将给定 `map` 的值提取成一个对应类型的 `ARRAY` ## 举例 ```sql -mysql> select map_values(map(1, "100", 0.1, 2)); -+---------------------------------------------------------------------------------------------------+ -| map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+---------------------------------------------------------------------------------------------------+ -| ["100", "2"] | -+---------------------------------------------------------------------------------------------------+ -1 row in set (0.12 sec) - -mysql> select map_values(map()); -+-------------------+ -| map_values(map()) | -+-------------------+ -| [] | -+-------------------+ -1 row in set (0.11 sec) +select map_values(map()),map_values(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, VALUES, MAP_VALUES +```text ++-------------------+---------------------------------------------------------------------------------------------------+ +| map_values(map()) | map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-------------------+---------------------------------------------------------------------------------------------------+ +| [] | ["100", "2"] | ++-------------------+---------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map.md index 80124e9a5d8ff..95896922640e5 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map.md @@ -26,32 +26,35 @@ under the License. ## 描述 +使用若干组键值对构造一个特定类型的 `Map` + ## 语法 -`MAP map(K key0, V value0, K key1, V value1, ..., K keyn, V valuen)` +```sql +MAP( , [, , ... ]) +``` -使用若干组键值对构造一个特定类型的 `Map` +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 构造 map 的 key | +| `` | 构造 map 的 value | + +## 返回值 + +返回由若干组键值对构造的特定类型 `Map` ## 举例 ```sql -mysql> select map(1, "100", 0.1, 2); -+---------------------------------------------------------------------------------------+ -| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | -+---------------------------------------------------------------------------------------+ -| {1.0:"100", 0.1:"2"} | -+---------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) - -mysql> select map(1, "100", 0.1, 2)[1]; -+-------------------------------------------------------------------------------------------------------------------------------+ -| element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | -+-------------------------------------------------------------------------------------------------------------------------------+ -| 100 | -+-------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +select map(1, "100", 0.1, 2),map(1, "100", 0.1, 2)[1]; ``` -### Keywords - -MAP +```text ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| {1.0:"100", 0.1:"2"} | 100 | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md index 2220defaba4de..6bac0360a12b1 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md @@ -24,38 +24,52 @@ specific language governing permissions and limitations under the License. --> -## ST_Angle_Sphere +## 描述 -### Syntax +计算地球表面两点之间的圆心角,单位为 度。传入的参数分别为 X 点的经度,X 点的纬度,Y 点的经度,Y 点的纬度。 -`DOUBLE ST_Angle_Sphere(DOUBLE x_lng, DOUBLE x_lat, DOUBLE y_lng, DOUBLE y_lat)` +## 语法 -## 描述 +```sql +ST_Angle_Sphere( , , , ) +``` -计算地球表面两点之间的圆心角,单位为 度。传入的参数分别为X点的经度,X点的纬度,Y点的经度,Y点的纬度。 +## 参数 -x_lng 和 y_lng 都是经度数据,合理的取值范围是 [-180, 180]。 +| 参数 | 说明 | +| -- | -- | +| `` | 经度数据,合理的取值范围是 [-180, 180] | +| `` | 经度数据,合理的取值范围是 [-180, 180] | +| `` | 纬度数据,合理的取值范围是 [-90, 90] | +| `` | 纬度数据,合理的取值范围是 [-90, 90] | -x_lat 和 y_lat 都是纬度数据,合理的取值范围是 [-90, 90]。 +## 返回值 + +两点之间的圆心角角度 ## 举例 +```sql +select ST_Angle_Sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); ``` -mysql> select ST_Angle_Sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); + +```text +---------------------------------------------------------------------------+ | st_angle_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219) | +---------------------------------------------------------------------------+ | 0.0659823452409903 | +---------------------------------------------------------------------------+ -1 row in set (0.06 sec) +``` + +```sql +select ST_Angle_Sphere(0, 0, 45, 0); +``` -mysql> select ST_Angle_Sphere(0, 0, 45, 0); +```text +----------------------------------------+ | st_angle_sphere(0.0, 0.0, 45.0, 0.0) | +----------------------------------------+ | 45 | +----------------------------------------+ -1 row in set (0.06 sec) ``` -### keywords -ST_ANGLE_SPHERE,ST,ANGLE,SPHERE + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md index d43d4f73410e3..5309c3fb6222a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md @@ -24,66 +24,95 @@ specific language governing permissions and limitations under the License. --> -## ST_Angle +## 描述 -### Syntax +输入三个点,它们表示两条相交的线。返回这些线之间的夹角。 -`DOUBLE ST_Angle(GEOPOINT point1, GEOPOINT point2, GEOPOINT point3)` +## 语法 -## 描述 +```sql +ST_Angle( , , ) +``` + +## 参数 + +| 参数 | 说明 | +|----------|--------------------------| +| `` | 第一条直线的第一个端点 | +| `` | 第一条直线的第二个端点且是第二条直线的第一个端点 | +| `` | 第二条直线的第二个端点 | -输入三个点,它们表示两条相交的线。返回这些线之间的夹角。点 2 和点 1 表示第一条线,点 2 和点 3 表示第二条线。这些线之间的夹角以弧度表示,范围为 [0, 2pi)。夹角按顺时针方向从第一条线开始测量,直至第二条线。 +## 返回值 + +这些线之间的夹角以弧度表示,范围为 [0, 2pi)。夹角按顺时针方向从第一条线开始测量,直至第二条线。 ST_ANGLE 存在以下边缘情况: -* 如果点 2 和点 3 相同,则返回 NULL。 -* 如果点 2 和点 1 相同,则返回 NULL。 -* 如果点 2 和点 3 是完全对映点,则返回 NULL。 -* 如果点 2 和点 1 是完全对映点,则返回 NULL。 -* 如果任何输入地理位置不是单点或为空地理位置,则会抛出错误。 +- 如果点 2 和点 3 相同,则返回 NULL。 +- 如果点 2 和点 1 相同,则返回 NULL。 +- 如果点 2 和点 3 是完全对映点,则返回 NULL。 +- 如果点 2 和点 1 是完全对映点,则返回 NULL。 +- 如果任何输入地理位置不是单点或为空地理位置,则会抛出错误。 ## 举例 +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1)); ``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1)); + +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------------------------+ | 4.71238898038469 | +----------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1)); +``` -mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1)); +```text +----------------------------------------------------------------------+ | st_angle(st_point(0.0, 0.0), st_point(1.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------------------------+ | 0.78547432161873854 | +----------------------------------------------------------------------+ -1 row in set (0.02 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0)); +``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0)); +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(1.0, 0.0)) | +----------------------------------------------------------------------+ | 0 | +----------------------------------------------------------------------+ -1 row in set (0.02 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 0)); +``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 0)); +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 0.0)) | +----------------------------------------------------------------------+ | NULL | +----------------------------------------------------------------------+ -1 row in set (0.03 sec) +``` -mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(-30, 0),ST_Point(150, 0)); +```sql +SELECT ST_Angle(ST_Point(0, 0),ST_Point(-30, 0),ST_Point(150, 0)); +``` + +```text +--------------------------------------------------------------------------+ | st_angle(st_point(0.0, 0.0), st_point(-30.0, 0.0), st_point(150.0, 0.0)) | +--------------------------------------------------------------------------+ | NULL | +--------------------------------------------------------------------------+ -1 row in set (0.02 sec) ``` -### keywords -ST_ANGLE,ST,ANGLE + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md index 7f3b0da7f28e4..03238653e26cc 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md @@ -24,11 +24,6 @@ specific language governing permissions and limitations under the License. --> -## ST_AsBinary - -### Syntax - -`VARCHAR ST_AsBinary(GEOMETRY geo)` ## 描述 @@ -36,33 +31,57 @@ under the License. 目前支持对几何图形是:Point, LineString, Polygon。 +## 语法 + +```sql +ST_AsBinary( ) +``` + +## 参数 + +| 参数 | 说明 | +| -- |----------| +| `` | 需要被转换的图形 | + +## 返回值 + +该几何图形的 WKB 表示形式: + ## 举例 +```sql +select ST_AsBinary(st_point(24.7, 56.7)); ``` -mysql> select ST_AsBinary(st_point(24.7, 56.7)); + +```text +----------------------------------------------+ | st_asbinary(st_point(24.7, 56.7)) | +----------------------------------------------+ | \x01010000003333333333b338409a99999999594c40 | +----------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> select ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); +```sql +select ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); +``` + +```text +--------------------------------------------------------------------------------------+ | st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +--------------------------------------------------------------------------------------+ | \x010200000002000000000000000000f03f000000000000f03f00000000000000400000000000000040 | +--------------------------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` -mysql> select ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")); +```sql +select ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")); +``` + +```text +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')) | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | \x01030000000100000006000000f3380ce6af865c402d05a4fd0f8c364041ef8d2100865c403049658a398c3640b9fb1c1f2d865c409d9b36e334883640de921cb0ab865c40cf876709328a36402cefaa07cc865c407b319413ed8a3640f3380ce6af865c402d05a4fd0f8c3640 | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.02 sec) - ``` -### keywords -ST_ASBINARY,ST,ASBINARY + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md index f86ba99a2846c..e09f323d12e1e 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md @@ -24,24 +24,37 @@ specific language governing permissions and limitations under the License. --> -## ST_AsText,ST_AsWKT + ## 描述 + +将一个几何图形转化为 WKT(Well Known Text)的表示形式 + ## 语法 -`VARCHAR ST_AsText(GEOMETRY geo)` +```sql +ST_AsText( ) +``` +# 参数 -将一个几何图形转化为WKT(Well Known Text)的表示形式 +| 参数 | 说明 | +| -- |----------| +| `` | 待转换的几何图形 | + +## 返回值 + +该几何图形的 WKT 表示形式 ## 举例 +```sql +SELECT ST_AsText(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_AsText(ST_Point(24.7, 56.7)); + +```text +---------------------------------+ | st_astext(st_point(24.7, 56.7)) | +---------------------------------+ | POINT (24.7 56.7) | +---------------------------------+ ``` -### keywords -ST_ASTEXT,ST_ASWKT,ST,ASTEXT,ASWKT diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md index c04d57a205ae3..da2a98caa76d7 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md @@ -24,64 +24,84 @@ specific language governing permissions and limitations under the License. --> -## ST_Azimuth +## 描述 -### Syntax +输入两个点,并返回由点 1 和点 2 形成的线段的方位角。方位角是点 1 的真北方向线与点 1 和点 2 形成的线段之间的角的弧度。 -`DOUBLE ST_Azimuth(GEOPOINT point1, GEOPOINT point2)` +## 语法 -## 描述 +```sql +ST_Azimuth( , ) +``` +## 参数 -输入两个点,并返回由点 1 和点 2 形成的线段的方位角。方位角是点 1 的真北方向线与点 1 和点 2 形成的线段之间的角的弧度。 +| 参数 | 说明 | +|----------|--------------| +| `` | 用于计算方位角的第一个点 | +| `` | 用于计算方位角的第二个点 | -正角在球面上按顺时针方向测量。 例如,线段的方位角: +## 返回值 -* 指北是 0 -* 指东是 PI/2 -* 指南是 PI -* 指西是 3PI/2 +正角在球面上按顺时针方向测量。例如,线段的方位角: + +- 指北是 0 +- 指东是 PI/2 +- 指南是 PI +- 指西是 3PI/2 ST_Azimuth 存在以下边缘情况: -* 如果两个输入点相同,则返回 NULL。 -* 如果两个输入点是完全对映点,则返回 NULL。 -* 如果任一输入地理位置不是单点或为空地理位置,则会抛出错误。 +- 如果两个输入点相同,则返回 NULL。 +- 如果两个输入点是完全对映点,则返回 NULL。 +- 如果任一输入地理位置不是单点或为空地理位置,则会抛出错误。 ## 举例 +```sql +SELECT st_azimuth(ST_Point(1, 0),ST_Point(0, 0)); ``` -mysql> SELECT st_azimuth(ST_Point(1, 0),ST_Point(0, 0)); + +```text +----------------------------------------------------+ | st_azimuth(st_point(1.0, 0.0), st_point(0.0, 0.0)) | +----------------------------------------------------+ | 4.71238898038469 | +----------------------------------------------------+ -1 row in set (0.03 sec) +``` + +```sql +SELECT st_azimuth(ST_Point(0, 0),ST_Point(1, 0)); +``` -mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(1, 0)); +```text +----------------------------------------------------+ | st_azimuth(st_point(0.0, 0.0), st_point(1.0, 0.0)) | +----------------------------------------------------+ | 1.5707963267948966 | +----------------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(0, 1)); +```sql +SELECT st_azimuth(ST_Point(0, 0),ST_Point(0, 1)); +``` + +```text +----------------------------------------------------+ | st_azimuth(st_point(0.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------+ | 0 | +----------------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> SELECT st_azimuth(ST_Point(-30, 0),ST_Point(150, 0)); +```sql +SELECT st_azimuth(ST_Point(-30, 0),ST_Point(150, 0)); +``` + +```text +--------------------------------------------------------+ | st_azimuth(st_point(-30.0, 0.0), st_point(150.0, 0.0)) | +--------------------------------------------------------+ | NULL | +--------------------------------------------------------+ -1 row in set (0.02 sec) - ``` -### keywords -ST_AZIMUTH,ST,AZIMUTH + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md index 3ce013929a449..ff8ae0d148635 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md @@ -24,25 +24,40 @@ specific language governing permissions and limitations under the License. --> -## ST_Circle ## 描述 + +将一个 WKT(Well Known Text)转化为地球球面上的一个圆。 + ## 语法 -`GEOMETRY ST_Circle(DOUBLE center_lng, DOUBLE center_lat, DOUBLE radius)` +```sql +ST_Circle( , , ) +``` +## 参数 + +| 参数 | 说明 | +| -- | -- | +| `` | 圆心的经度 | +| `` | 圆心的纬度 | +| `` | 圆的半径 | +- radius 单位是米,最大支持 9999999 -将一个WKT(Well Known Text)转化为地球球面上的一个圆。其中`center_lng`表示的圆心的经度, -`center_lat`表示的是圆心的纬度,`radius`表示的是圆的半径,单位是米,最大支持9999999 +## 返回值 + +根据圆的基本信息得到的球面上的一个圆 ## 举例 +```sql +SELECT ST_AsText(ST_Circle(111, 64, 10000)); ``` -mysql> SELECT ST_AsText(ST_Circle(111, 64, 10000)); + +```text +--------------------------------------------+ | st_astext(st_circle(111.0, 64.0, 10000.0)) | +--------------------------------------------+ | CIRCLE ((111 64), 10000) | +--------------------------------------------+ ``` -### keywords -ST_CIRCLE,ST,CIRCLE + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md index a13d683fbb3ac..045575c2b24ce 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md @@ -24,31 +24,52 @@ specific language governing permissions and limitations under the License. --> -## ST_Contains ## 描述 + +判断几何图形 shape1 是否完全能够包含几何图形 shape2 + ## 语法 -`BOOL ST_Contains(GEOMETRY shape1, GEOMETRY shape2)` +```sql +ST_Contains( , ) +``` + +## 参数 + +| 参数 | 说明 | +|----------|------------------------| +| `` | 传入的几何图形,用于判断是否包含 shape2 | +| `` | 传入的几何图形,用于判断是被 shape1 包含 | + +## 返回值 +返回 1:shape1 图形可包含图形 shape2 + +返回 0:shape1 图形不可包含图形 shape2 -判断几何图形shape1是否完全能够包含几何图形shape2 ## 举例 +```sql +SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(5, 5)); ``` -mysql> SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(5, 5)); + +```text +----------------------------------------------------------------------------------------+ | st_contains(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'), st_point(5.0, 5.0)) | +----------------------------------------------------------------------------------------+ | 1 | +----------------------------------------------------------------------------------------+ +``` + +```sql +SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(50, 50)); +``` -mysql> SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(50, 50)); +```text +------------------------------------------------------------------------------------------+ | st_contains(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'), st_point(50.0, 50.0)) | +------------------------------------------------------------------------------------------+ | 0 | +------------------------------------------------------------------------------------------+ ``` -### keywords -ST_CONTAINS,ST,CONTAINS diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md index 98b520c066986..a1b787cd00a83 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md @@ -24,27 +24,40 @@ specific language governing permissions and limitations under the License. --> -## ST_Distance_Sphere ## 描述 + +计算地球两点之间的球面距离,单位为 米。传入的参数分别为 X 点的经度,X 点的纬度,Y 点的经度,Y 点的纬度。 + ## 语法 -`DOUBLE ST_Distance_Sphere(DOUBLE x_lng, DOUBLE x_lat, DOUBLE y_lng, DOUBLE y_lat)` +```sql +ST_Distance_Sphere( , , , ) +``` + +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 经度数据,合理的取值范围是 [-180, 180] | +| `` | 经度数据,合理的取值范围是 [-180, 180] | +| `` | 纬度数据,合理的取值范围是 [-90, 90] | +| `` | 纬度数据,合理的取值范围是 [-90, 90] | -计算地球两点之间的球面距离,单位为 米。传入的参数分别为X点的经度,X点的纬度,Y点的经度,Y点的纬度。 +## 返回值 -x_lng 和 y_lng 都是经度数据,合理的取值范围是 [-180, 180]。 -x_lat 和 y_lat 都是纬度数据,合理的取值范围是 [-90, 90]。 +两点之间的球面距离 ## 举例 +```sql +select st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); ``` -mysql> select st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); + +```text +----------------------------------------------------------------------------+ | st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219) | +----------------------------------------------------------------------------+ | 7336.9135549995917 | +----------------------------------------------------------------------------+ ``` -### keywords -ST_DISTANCE_SPHERE,ST,DISTANCE,SPHERE + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md index 81678f1834136..c56bf92b5599f 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md @@ -24,24 +24,37 @@ specific language governing permissions and limitations under the License. --> -## ST_GeometryFromText,ST_GeomFromText ## 描述 + +将一个线型 WKT(Well Known Text)转化为对应的内存的几何形式 + ## 语法 -`GEOMETRY ST_GeometryFromText(VARCHAR wkt)` +```sql +ST_GeometryFromText( ) +``` +## 参数 + +| 参数 | 说明 | +| -- |---------| +| `` | 图形的内存形式 | +## 返回值 -将一个WKT(Well Known Text)转化为对应的内存的几何形式 +WKB 的对应的几何存储形式 ## 举例 +```sql +SELECT ST_AsText(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); ``` -mysql> SELECT ST_AsText(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); + +```text +---------------------------------------------------------+ | st_astext(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +---------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +---------------------------------------------------------+ ``` -### keywords -ST_GEOMETRYFROMTEXT,ST_GEOMFROMTEXT,ST,GEOMETRYFROMTEXT,GEOMFROMTEXT + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md index 5ddf12fe985bb..a8585e143de8c 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md @@ -24,59 +24,85 @@ specific language governing permissions and limitations under the License. --> -## ST_GeometryFromWKB,ST_GeomFromWKB +## 描述 -### Syntax +将一个标准图形 WKB(Well-known binary)转化为对应的内存的几何形式 -`GEOMETRY ST_GeometryFromWKB(VARCHAR WKB)` +## 语法 -## 描述 +```sql +ST_GeometryFromWKB( ) +``` +## 参数 -将一个标准 WKB(Well-known binary)转化为对应的内存的几何形式 +| 参数 | 说明 | +| -- |---------| +| `` | 图形的内存形式 | + +## 返回值 + +WKB 的对应的几何存储形式 ## 举例 +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); ``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); + +```text +------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_point(24.7, 56.7)))) | +------------------------------------------------------------------+ | POINT (24.7 56.7) | +------------------------------------------------------------------+ -1 row in set (0.05 sec) +``` + +```sql +select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); +``` -mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); +```text +--------------------------------------------------------------+ | st_astext(st_geomfromwkb(st_asbinary(st_point(24.7, 56.7)))) | +--------------------------------------------------------------+ | POINT (24.7 56.7) | +--------------------------------------------------------------+ -1 row in set (0.03 sec) +``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")))); +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")))); +``` + +```text +------------------------------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')))) | +------------------------------------------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +------------------------------------------------------------------------------------------+ -1 row in set (0.06 sec) +``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +``` + +```text +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) +``` -mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +```sql +select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +``` + +```text +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_astext(st_geomfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) | +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) | +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) - ``` -### keywords -ST_GEOMETRYFROMWKB,ST_GEOMFROMWKB,ST,GEOMETRYFROMWKB,GEOMFROMWKB,WKB + + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md index 2a41e25f2641c..de688ae67ab42 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md @@ -24,24 +24,37 @@ specific language governing permissions and limitations under the License. --> -## ST_LineFromText,ST_LineStringFromText ## 描述 + +将一个 WKT(Well Known Text)转化为一个 Line 形式的内存表现形式 + ## 语法 -`GEOMETRY ST_LineFromText(VARCHAR wkt)` +```sql +ST_LineFromText( ) +``` + +## 参数 +| 参数 | 说明 | +|-----|------------| +| `` | 由两个坐标组成的线段 | -将一个WKT(Well Known Text)转化为一个Line形式的内存表现形式 +## 返回值 + +线段的内存形式。 ## 举例 +```sql +SELECT ST_AsText(ST_LineFromText("LINESTRING (1 1, 2 2)")); ``` -mysql> SELECT ST_AsText(ST_LineFromText("LINESTRING (1 1, 2 2)")); + +```text +---------------------------------------------------------+ | st_astext(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +---------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +---------------------------------------------------------+ ``` -### keywords -ST_LINEFROMTEXT,ST_LINESTRINGFROMTEXT,ST,LINEFROMTEXT,LINESTRINGFROMTEXT + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md index c33eb4b733648..3039ac17a4364 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md @@ -24,25 +24,39 @@ specific language governing permissions and limitations under the License. --> -## ST_Point ## 描述 + +通过给定的 X 坐标值,Y 坐标值返回对应的 Point。 + +当前这个值只是在球面集合上有意义,X/Y 对应的是经度/纬度 (longitude/latitude); + ## 语法 -`POINT ST_Point(DOUBLE x, DOUBLE y)` +```sql +ST_Point( , ) +``` +## 参数 +| 参数 | 说明 | +|-----|-----| +| `` | 横坐标 | +| `` | 纵坐标 | -通过给定的X坐标值,Y坐标值返回对应的Point。 -当前这个值只是在球面集合上有意义,X/Y对应的是经度/纬度(longitude/latitude); +## 返回值 + +给定横坐标以及纵坐标对应的位置信息 ## 举例 +```sql +SELECT ST_AsText(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_AsText(ST_Point(24.7, 56.7)); + +```text +---------------------------------+ | st_astext(st_point(24.7, 56.7)) | +---------------------------------+ | POINT (24.7 56.7) | +---------------------------------+ ``` -### keywords -ST_POINT,ST,POINT + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md index bac2ef264de1e..6fd0603e6c28b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md @@ -24,24 +24,37 @@ specific language governing permissions and limitations under the License. --> -## ST_Polygon,ST_PolyFromText,ST_PolygonFromText ## 描述 + +将一个 WKT(Well Known Text)转化为对应的多边形内存形式 + ## 语法 -`GEOMETRY ST_Polygon(VARCHAR wkt)` +```sql +ST_Polygon( ) +``` + +## 参数 +| 参数 | 说明 | +|------|--------------------| +| `` | 由 POLYGON 函数生成的一个多边形 | -将一个WKT(Well Known Text)转化为对应的多边形内存形式 +## 返回值 + +多边形的内存形式。 ## 举例 +```sql +SELECT ST_AsText(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))")); ``` -mysql> SELECT ST_AsText(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))")); + +```text +------------------------------------------------------------------+ | st_astext(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))')) | +------------------------------------------------------------------+ | POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0)) | +------------------------------------------------------------------+ ``` -### keywords -ST_POLYGON,ST_POLYFROMTEXT,ST_POLYGONFROMTEXT,ST,POLYGON,POLYFROMTEXT,POLYGONFROMTEXT + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md index de572bdb3dc12..f922879febf6f 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md @@ -24,24 +24,37 @@ specific language governing permissions and limitations under the License. --> -## ST_X ## 描述 + +当 point 是一个合法的 POINT 类型时,返回对应的 X 坐标值 + ## 语法 -`DOUBLE ST_X(POINT point)` +```sql +ST_X( ) +``` + +## 参数 +| 参数 | 说明 | +|------|----------| +| `` | 二维点的几何坐标 | -当point是一个合法的POINT类型时,返回对应的X坐标值 +## 返回值 + +几何坐标中的 X 值 ## 举例 +```sql +SELECT ST_X(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_X(ST_Point(24.7, 56.7)); + +```text +----------------------------+ | st_x(st_point(24.7, 56.7)) | +----------------------------+ | 24.7 | +----------------------------+ ``` -### keywords -ST_X,ST,X + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md index c452a7a1464e7..987150b16a133 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md @@ -24,24 +24,37 @@ specific language governing permissions and limitations under the License. --> -## ST_Y ## 描述 + +当 point 是一个合法的 POINT 类型时,返回对应的 Y 坐标值 + ## 语法 -`DOUBLE ST_Y(POINT point)` +```sql +ST_Y( ) +``` + +## 参数 +| 参数 | 说明 | +|------|----------| +| `` | 二维点的几何坐标 | -当point是一个合法的POINT类型时,返回对应的Y坐标值 +## 返回值 + +几何坐标中的 Y 值 ## 举例 +```sql +SELECT ST_Y(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_Y(ST_Point(24.7, 56.7)); + +```text +----------------------------+ -| st_y(st_point(24.7, 56.7)) | +| st_x(st_point(24.7, 56.7)) | +----------------------------+ -| 56.7 | +| 24.7 | +----------------------------+ ``` -### keywords -ST_Y,ST,Y + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT.md index 4e55975ccf041..5c432060aedab 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT.md @@ -1,6 +1,6 @@ --- { - "title": "CREATE STORAGE VAULT", + "title": "CREATE-STORAGE-VAULT", "language": "zh-CN", "toc_min_heading_level": 2, "toc_max_heading_level": 4 @@ -26,7 +26,7 @@ specific language governing permissions and limitations under the License. --> - +## CREATE-STORAGE-VAULT ## 描述 @@ -47,130 +47,168 @@ CREATE STORAGE VAULT [IF NOT EXISTS] vault | 参数 | 是否必需 | 描述 | |:----------------|:-----|:--------------------------------------------------------------------------------------------------------| -| `s3.endpoint` | 必需 | 用于对象存储的端点。
注意,请不要提供带有 http:// 或 https:// 开头的链接。对于 Azure Blob 存储,链接应该像 ${ak}.blob.core.windows.net/。 | -| `s3.region` | 必需 | 您的存储桶的区域。(如果您使用 GCP 或 AZURE,则不需要)。 | +| `s3.endpoint` | 必需 | 用于对象存储的端点。
注意,请不要提供带有 http:// 或 https:// 开头的链接。对于 Azure Blob 存储,endpoint是固定的blob.core.windows.net。 | +| `s3.region` | 必需 | 您的存储桶的区域。(如果您使用 GCP 或 AZURE,则不需要)。 | | `s3.root.path` | 必需 | 存储数据的路径。 | -| `s3.bucket` | 必需 | 您的对象存储账户的存储桶。(如果您使用 Azure,则为 StorageAccount)。 | -| `s3.access_key` | 必需 | 您的对象存储账户的访问密钥。(如果您使用 Azure,则为 AccountName)。 | -| `s3.secret_key` | 必需 | 您的对象存储账户的秘密密钥。(如果您使用 Azure,则为 AccountKey)。 | +| `s3.bucket` | 必需 | 您的对象存储账户的存储桶。(如果您使用 Azure,则为 StorageAccount)。 | +| `s3.access_key` | 必需 | 您的对象存储账户的访问密钥。(如果您使用 Azure,则为 AccountName)。 | +| `s3.secret_key` | 必需 | 您的对象存储账户的秘密密钥。(如果您使用 Azure,则为 AccountKey)。 | | `provider` | 必需 | 提供对象存储服务的云供应商。支持的值有`COS`,`OSS`,`S3`,`OBS`,`BOS`,`AZURE`,`GCP` | -| `use_path_style` | 可选 | 使用 `path-style URL`(私有化部署环境)或者`virtual-hosted-style URL`(公有云环境建议), 默认值 `true` (`path-style`) | +| `use_path_style` | 可选 | 使用 `path-style URL`(私有化部署环境)或者`virtual-hosted-style URL`(公有云环境建议), 默认值 `true` (path-style) | ##### HDFS vault | 参数 | 是否必需 | 描述 | |:---------------------------------|:-----|:------------------------------------------------------| -| `fs.defaultFS` |必需 | Hadoop 配置属性,指定要使用的默认文件系统。 | -| `path_prefix` |可选 | 存储数据的路径前缀。如果没有指定则会使用 user 账户下的默认路径。 | -| `hadoop.username` |可选 | Hadoop 配置属性,指定访问文件系统的用户。如果没有指定则会使用启动 hadoop 进程的 user。 | -| `hadoop.security.authentication` |可选 | 用于 hadoop 的认证方式。如果希望使用 kerberos 则可以填写`kerberos`。 | -| `hadoop.kerberos.principal` |可选 | 您的 kerberos 主体的路径。 | -| `hadoop.kerberos.keytab` |可选 | 您的 kerberos keytab 的路径。 | +| `fs.defaultFS` |必需| Hadoop 配置属性,指定要使用的默认文件系统。 | +| `path_prefix` |可选| 存储数据的路径前缀。如果没有指定则会使用 user 账户下的默认路径。 | +| `hadoop.username` |可选| Hadoop 配置属性,指定访问文件系统的用户。如果没有指定则会使用启动 hadoop 进程的 user。 | +| `hadoop.security.authentication` |可选| 用于 hadoop 的认证方式。如果希望使用 kerberos 则可以填写`kerberos`。 | +| `hadoop.kerberos.principal` |可选| 您的 kerberos 主体的路径。 | +| `hadoop.kerberos.keytab` |可选| 您的 kerberos keytab 的路径。 | ### 示例 1. 创建 HDFS storage vault。 ```sql - CREATE STORAGE VAULT IF NOT EXISTS hdfs_vault - PROPERTIES ( - "type"="hdfs", - "fs.defaultFS"="hdfs://127.0.0.1:8020" - ); + CREATE STORAGE VAULT IF NOT EXISTS hdfs_vault_demo + PROPERTIES ( + "type" = "hdfs", -- required + "fs.defaultFS" = "hdfs://127.0.0.1:8020", -- required + "path_prefix" = "big/data", -- optional, 一般按照业务名称填写 + "hadoop.username" = "user" -- optional + "hadoop.security.authentication" = "kerberos" -- optional + "hadoop.kerberos.principal" = "hadoop/127.0.0.1@XXX" -- optional + "hadoop.kerberos.keytab" = "/etc/emr.keytab" -- optional + ); ``` -2. 创建微软 azure S3 storage vault。 +2. 创建阿里云 OSS storage vault。 ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="ak.blob.core.windows.net/", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "AZURE" - ); + CREATE STORAGE VAULT IF NOT EXISTS oss_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "oss-cn-beijing.aliyuncs.com", -- required + "s3.access_key" = "xxxxxx", -- required, Your OSS access key + "s3.secret_key" = "xxxxxx", -- required, Your OSS secret key + "s3.region" = "cn-beijing", -- required + "s3.root.path" = "oss_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your OSS bucket name + "provider" = "OSS", -- required + "use_path_style" = "false" -- optional, OSS 建议设置false + ); ``` -3. 创建阿里云 OSS S3 storage vault。 +3. 创建腾讯云 COS storage vault。 ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="oss.aliyuncs.com", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.region" = "cn-hangzhou", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "OSS", - "use_path_style" = "false" - ); + CREATE STORAGE VAULT IF NOT EXISTS cos_demo_vault + PROPERTIES ( + "type" = "S3", + "s3.endpoint" = "cos.ap-guangzhou.myqcloud.com", -- required + "s3.access_key" = "xxxxxx", -- required, Your COS access key + "s3.secret_key" = "xxxxxx", -- required, Your COS secret key + "s3.region" = "ap-guangzhou", -- required + "s3.root.path" = "cos_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your COS bucket name + "provider" = "COS", -- required + "use_path_style" = "false" -- optional, COS 建议设置false + ); ``` -4. 创建腾讯云 COS S3 storage vault。 +4. 创建华为云 OBS storage vault。 ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="cos.ap-guangzhou.myqcloud.com", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.region" = "ap-guangzhou", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "COS", - "use_path_style" = "false" - ); + CREATE STORAGE VAULT IF NOT EXISTS obs_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "obs.cn-north-4.myhuaweicloud.com", -- required + "s3.access_key" = "xxxxxx", -- required, Your OBS access key + "s3.secret_key" = "xxxxxx", -- required, Your OBS secret key + "s3.region" = "cn-north-4", -- required + "s3.root.path" = "obs_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your COS bucket name + "provider" = "OBS", -- required + "use_path_style" = "false" -- optional, OBS 建议设置false + ); ``` -5. 创建华为云 OBS S3 storage vault。 +5. 创建百度云 BOS storage vault。 ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="obs.cn-north-4.myhuaweicloud.com", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.region" = "cn-north-4", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "OBS", - "use_path_style" = "false" - ); + CREATE STORAGE VAULT IF NOT EXISTS obs_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "s3.bj.bcebos.com", -- required + "s3.access_key" = "xxxxxx", -- required, Your BOS access key + "s3.secret_key" = "xxxxxx", -- required, Your BOS secret key + "s3.region" = "bj", -- required + "s3.root.path" = "bos_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your BOS bucket name + "provider" = "BOS", -- required + "use_path_style" = "false" -- optional, BOS 建议设置false + ); ``` 6. 创建亚马逊云 S3 storage vault。 ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="s3.us-east-1.amazonaws.com", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.region" = "us-east-1", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "S3", - "use_path_style" = "false" - ); + CREATE STORAGE VAULT IF NOT EXISTS s3_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "s3.us-east-1.amazonaws.com", -- required + "s3.access_key" = "xxxxxx", -- required, Your S3 access key + "s3.secret_key" = "xxxxxx", -- required, Your OBS secret key + "s3.region" = "us-east-1", -- required + "s3.root.path" = "s3_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your s3 bucket name + "provider" = "S3", -- required + "use_path_style" = "false" -- optional, S3 建议设置false + ); ``` -7. 创建 MinIO S3 storage vault。 + +7. 创建 MinIO storage vault。 ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="127.0.0.1:9000", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.region" = "us-east-1", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "S3", - "use_path_style" = "true" - ); + CREATE STORAGE VAULT IF NOT EXISTS minio_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "127.0.0.1:9000", -- required + "s3.access_key" = "xxxxxx", -- required, Your minio access key + "s3.secret_key" = "xxxxxx", -- required, Your minio secret key + "s3.region" = "us-east-1", -- required + "s3.root.path" = "minio_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your minio bucket name + "provider" = "S3", -- required + "use_path_style" = "true" -- required, minio 建议设置true + ); ``` -## 关键词 +8. 创建微软 AZURE storage vault。 + ```sql + CREATE STORAGE VAULT IF NOT EXISTS azure_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "blob.core.windows.net", -- required + "s3.access_key" = "xxxxxx", -- required, Your Azure AccountName + "s3.secret_key" = "xxxxxx", -- required, Your Azure AccountKey + "s3.region" = "us-east-1", -- required + "s3.root.path" = "azure_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your Azure StorageAccount + "provider" = "AZURE" -- required + ); + ``` + +9. 创建谷歌 GCP storage vault。 + ```sql + CREATE STORAGE VAULT IF NOT EXISTS gcp_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "storage.googleapis.com", -- required + "s3.access_key" = "xxxxxx", -- required + "s3.secret_key" = "xxxxxx", -- required + "s3.region" = "us-east-1", -- required + "s3.root.path" = "gcp_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required + "provider" = "GCP" -- required + ); + ``` + +### 关键词 CREATE, STORAGE VAULT diff --git a/scripts/generate_pdf.sh b/scripts/generate_pdf.sh index 899ef5accba2d..8539ac40bb85a 100755 --- a/scripts/generate_pdf.sh +++ b/scripts/generate_pdf.sh @@ -19,12 +19,14 @@ _version_tag="$(date '+%Y%m%d')" # generate PDF for dev version output_path="output.pdf" +# -V title="Apache Doris 中文手册" \ +# -V title="Apache Doris V1.2 Documentation" \ pandoc -N --toc --smart --latex-engine=xelatex \ --template=templates/template.tex \ --listings \ --columns=80 \ --V title="Apache Doris 中文手册" \ +-V title="Apache Doris V1.2 中文手册" \ -V date="${_version_tag}" \ -V CJKmainfont="${MAINFONT}" \ -V mainfont="${MAINFONT}" \ @@ -32,4 +34,4 @@ pandoc -N --toc --smart --latex-engine=xelatex \ -V monofont="${MONOFONT}" \ -V geometry:margin=1in \ -V include-after="\\input{templates/copyright.tex}" \ -"doc-3.0.md" -s -o "doris-3.0.pdf" \ No newline at end of file +"doc-1.2.md" -s -o "doris-1.2.pdf" \ No newline at end of file diff --git a/scripts/merge_md.js b/scripts/merge_md.js index 9ea6003094b2d..1c36699220483 100644 --- a/scripts/merge_md.js +++ b/scripts/merge_md.js @@ -17,13 +17,28 @@ const fs = require('fs'); const path = require('path'); +const i18nJsonFile = require('../i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2.json'); -const sidebarPath = 'versioned_sidebars/version-3.0-sidebars.json' -const docsBaseDir = 'i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0' -const outputPath = 'doc-3.0.md' -const fileLinkName = {}; +// v2.0 zh +// const sidebarPath = 'versioned_sidebars/version-2.0-sidebars.json'; +// const docsBaseDir = 'i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0'; +// const outputPath = 'doc-2.0.md'; +// const excludes = []; + +// v1.2 +const sidebarPath = 'versioned_sidebars/version-1.2-sidebars.json'; +const excludes = ['SQL Manual']; +// zh +const docsBaseDir = 'i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2'; +const outputPath = 'doc-1.2.md'; + +// en +// const docsBaseDir = 'versioned_docs/version-1.2'; +// const outputPath = 'doc-1.2-en.md'; + +const fileLinkName = {}; function readJSON(filePath) { const data = fs.readFileSync(filePath, 'utf-8'); @@ -49,13 +64,13 @@ function replaceLinkWrap(chapter) { return `[${linkName}](${imgLink})`; } else { if (link.includes('.md#') && frag) { - return frag.replace(/[\s]+/g, '-').toLowerCase() + return frag.replace(/[\s]+/g, '-').toLowerCase(); } else { - let fullPath = path.join(docsBaseDir, customResolve(link)) + let fullPath = path.join(docsBaseDir, customResolve(link)); if (!link.endsWith('.md')) { fullPath += '.md'; } - return `[${linkName}](#${getMainTitleFromFile(fullPath).replace(/[\s]+/g, '-').toLowerCase()})` + return `[${linkName}](#${getMainTitleFromFile(fullPath).replace(/[\s]+/g, '-').toLowerCase()})`; } } } @@ -96,7 +111,7 @@ function processItems(items, level) { if (fs.existsSync(filePath)) { let mdContent = readMarkdownFile(filePath); mdContent = replaceLinkWrap(mdContent); - content += adjustHeaders(mdContent, level) + '\n\n'; + content += adjustHeaders(removeDuplicateTitle(adjustTips(trimCodeFunc(mdContent))), level) + '\n\n'; } } else if (typeof item === 'object' && item.items) { content += `${'#'.repeat(level + 1)} ${item.label}\n\n`; @@ -106,9 +121,108 @@ function processItems(items, level) { return content; } +function adjustTips(mdContent) { + if (!/:::/.test(mdContent)) return mdContent; + const lines = mdContent.split('\n'); + for (let i = 0; i < lines.length; i++) { + // start ::: + if (lines[i].trim().startsWith(':::')) { + const firstLine = lines[i].trim().split(' ')?.[1]; + if (firstLine) { + lines[i] = `> ${firstLine}`; + } else { + lines[i] = ''; + } + for (let j = i + 1; j < lines.length; j++) { + // end ::: + if (lines[j].trim().startsWith(':::')) { + lines[j] = ``; + i = j; + break; + } else { + lines[j] = `> ${lines[j]}`; + } + } + } + } + return lines.join('\n'); +} + +function trimCodeFunc(mdContent) { + if (!/```/.test(mdContent)) return mdContent; + const lines = mdContent.split('\n'); + for (let i = 0; i < lines.length; i++) { + // start ``` + if (lines[i].trim().startsWith('```')) { + lines[i] = lines[i].trim(); + for (let j = i + 1; j < lines.length; j++) { + // end ``` + if (lines[j].trim().startsWith('```')) { + lines[j] = lines[j].trim(); + i = j; + break; + } + } + } + } + return lines.join('\n'); +} + +/** + * + * @example + * + * --- + * { + * "title": "快速体验", + * "language": "zh-CN" + * } + * + * --- + * + * # 快速体验 + * + * "# 快速体验" will be parsed as a title, which will cause title duplication, so remove it + */ +function removeDuplicateTitle(mdContent) { + if (!/#\s/.test(mdContent)) return mdContent; + const lines = mdContent.split('\n'); + for (let i = 0; i < lines.length; i++) { + if (lines[i].startsWith('# ')) { + lines[i] = ''; + break; + } + } + return lines.join('\n'); +} + +function translateTitle(mdContent) { + const map = getI18nMap(); + const lines = mdContent.split('\n'); + for (let i = 0; i < lines.length; i++) { + if ( + lines[i].startsWith('# ') || + lines[i].startsWith('## ') || + lines[i].startsWith('### ') || + lines[i].startsWith('#### ') || + lines[i].startsWith('##### ') || + lines[i].startsWith('###### ') + ) { + const tempArr = lines[i].split('# '); + const value = map.get(tempArr[1]); + if (value) { + tempArr[1] = value; + lines[i] = tempArr.join('# '); + } + } + } + return lines.join('\n'); +} + function adjustHeaders(mdContent, level) { const match = mdContent.match(/{[^}]*}/); - const mainTitle = JSON.parse(match[0].replace(/'/g, '"')).title; + const specialTitle = `{ "title": "What's Apache Doris", "language": "en" }`; + const mainTitle = JSON.parse(match[0] === specialTitle ? match[0] : match[0].replace(/'/g, '"')).title; const lines = mdContent.split('\n'); let hasMainTitle = false; @@ -125,7 +239,7 @@ function adjustHeaders(mdContent, level) { firstSeparatorIndex = i; } else { secondSeparatorIndex = i; - break + break; } } } @@ -146,15 +260,67 @@ function adjustHeaders(mdContent, level) { return adjustedLines.join('\n'); } +function traverseSidebarTree(node, excludes) { + if (excludes.includes(node.label)) { + node.needExclude = true; + return; + } + if (node.items.length) { + for (let newNode of node.items) { + if (typeof newNode === 'object') traverseSidebarTree(newNode, excludes); + } + } + for (let i = 0; i < node.items.length; i++) { + let item = node.items[i]; + if (item.needExclude) { + node.items.splice(i, 1); + i--; + } + } +} + +/** + * + * @description Recursively remove one or more categories under the premise that the default label is unique + */ +function filterSidebarTree(sidebar, excludes) { + for (let node of sidebar.docs) { + traverseSidebarTree(node, excludes); + } + for (let i = 0; i < sidebar.docs.length; i++) { + let item = sidebar.docs[i]; + if (item.needExclude) { + sidebar.docs.splice(i, 1); + i--; + } + } +} + +function getI18nMap() { + const map = new Map(); + Object.keys(i18nJsonFile).forEach(originKey => { + const value = i18nJsonFile[originKey].message; + const temp = originKey.split('.'); + const key = temp[temp.length - 1]; + map.set(key, value); + }); + return map; +} + function mergeMarkdownFiles() { - const sidebarData = readJSON(sidebarPath); + let sidebarData = readJSON(sidebarPath); + if (excludes?.length) { + filterSidebarTree(sidebarData, excludes); + } let content = ''; sidebarData.docs.forEach(category => { content += `# ${category.label}\n\n`; content += processItems(category.items, 1); }); - writeMarkdownContent(outputPath, content); + writeMarkdownContent(outputPath, translateTitle(content)); + // writeMarkdownContent(outputPath, content); } mergeMarkdownFiles(); -console.log('successfully'); \ No newline at end of file + +console.log('successfully'); diff --git a/scripts/modify_filename.js b/scripts/modify_filename.js new file mode 100644 index 0000000000000..e7a7f0ebc36e6 --- /dev/null +++ b/scripts/modify_filename.js @@ -0,0 +1,47 @@ +const fs = require('fs'); +const path = require('path'); + +const directoryPath = path.join(__dirname, '../i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2'); + +const allNeedReplacePath = []; + +function getAllNeedReplacePath(rootPath) { + const statsObj = fs.statSync(rootPath, (err, stats) => { + if (err) { + console.log('err', err); + return; + } + }); + if (statsObj.isFile()) { + allNeedReplacePath.push(rootPath); + } else if (statsObj.isDirectory()) { + const files = fs.readdirSync(rootPath); + for (let filename of files) { + const curPath = `${rootPath}/${filename}`; + getAllNeedReplacePath(curPath); + } + } +} + +function modifyFileName(rootPath) { + getAllNeedReplacePath(rootPath); + allNeedReplacePath.forEach(file => { + const suffix = file.includes('versioned_docs') ? file.split('versioned_docs')[1] : ''; + if ((suffix && suffix.includes('_')) || (!suffix && file.includes('_'))) { + const oldPath = file; + const newPath = suffix + ? file.split('versioned_docs')[0] + 'versioned_docs' + suffix.replace(/_/g, '-') + : file.replace(/_/g, '-'); + + fs.rename(oldPath, newPath, err => { + if (err) { + console.error(`Unable to rename file ${file}:`, err); + } else { + console.log(`File renamed successfully: ${file} -> ${newPath}`); + } + }); + } + }); +} + +modifyFileName(directoryPath); diff --git a/sidebars.json b/sidebars.json index 333f81e45ce92..878d0ec427d7b 100644 --- a/sidebars.json +++ b/sidebars.json @@ -1275,7 +1275,6 @@ "sql-manual/sql-functions/scalar-functions/json-functions/json-replace", "sql-manual/sql-functions/scalar-functions/json-functions/json-set", "sql-manual/sql-functions/scalar-functions/json-functions/json-keys", - "sql-manual/sql-functions/scalar-functions/json-functions/jsonb-extract", "sql-manual/sql-functions/scalar-functions/json-functions/json-extract-bigint", "sql-manual/sql-functions/scalar-functions/json-functions/json-extract-largeint", "sql-manual/sql-functions/scalar-functions/json-functions/json-extract-bool", @@ -1575,315 +1574,455 @@ "items": [ { "type": "category", - "label": "Cluster management", + "label": "Data Queries", "items": [ - "sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-FOLLOWER", - "sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-OBSERVER", - "sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-BACKEND", - "sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-ADD-BROKER", - "sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-MODIFY-BACKEND", - "sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DECOMMISSION-BACKEND", - "sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-FOLLOWER", - "sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-OBSERVER", - "sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-BACKEND", - "sql-manual/sql-statements/Cluster-Management-Statements/ALTER-SYSTEM-DROP-BROKER", - "sql-manual/sql-statements/Cluster-Management-Statements/CANCEL-ALTER-SYSTEM" + "sql-manual/sql-statements/data-query/SELECT", + "sql-manual/sql-statements/data-query/EXPLAIN" + ] + }, + { + "type": "category", + "label": "Data Modification", + "items": [ + { + "type": "category", + "label": "DML", + "items": [ + "sql-manual/sql-statements/data-modification/DML/INSERT", + "sql-manual/sql-statements/data-modification/DML/INSERT-OVERWRITE", + "sql-manual/sql-statements/data-modification/DML/SHOW-LAST-INSERT", + "sql-manual/sql-statements/data-modification/DML/UPDATE", + "sql-manual/sql-statements/data-modification/DML/DELETE", + "sql-manual/sql-statements/data-modification/DML/SHOW-DELETE" + ] + }, + { + "type": "category", + "label": "Load and Export", + "items": [ + "sql-manual/sql-statements/data-modification/load-and-export/BROKER-LOAD", + "sql-manual/sql-statements/data-modification/load-and-export/MYSQL-LOAD", + "sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD", + "sql-manual/sql-statements/data-modification/load-and-export/SHOW-STREAM-LOAD", + "sql-manual/sql-statements/data-modification/load-and-export/SHOW-CREATE-LOAD", + "sql-manual/sql-statements/data-modification/load-and-export/CANCEL-LOAD", + "sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD-PROFILE", + "sql-manual/sql-statements/data-modification/load-and-export/SHOW-LOAD-WARNINGS", + "sql-manual/sql-statements/data-modification/load-and-export/CREATE-ROUTINE-LOAD", + "sql-manual/sql-statements/data-modification/load-and-export/ALTER-ROUTINE-LOAD", + "sql-manual/sql-statements/data-modification/load-and-export/PAUSE-ROUTINE-LOAD", + "sql-manual/sql-statements/data-modification/load-and-export/RESUME-ROUTINE-LOAD", + "sql-manual/sql-statements/data-modification/load-and-export/STOP-ROUTINE-LOAD", + "sql-manual/sql-statements/data-modification/load-and-export/SHOW-ROUTINE-LOAD", + "sql-manual/sql-statements/data-modification/load-and-export/SHOW-ROUTINE-LOAD-TASK", + "sql-manual/sql-statements/data-modification/load-and-export/SHOW-CREATE-ROUTINE-LOAD", + "sql-manual/sql-statements/data-modification/load-and-export/CREATE-SYNC-JOB", + "sql-manual/sql-statements/data-modification/load-and-export/PAUSE-SYNC-JOB", + "sql-manual/sql-statements/data-modification/load-and-export/RESUME-SYNC-JOB", + "sql-manual/sql-statements/data-modification/load-and-export/STOP-SYNC-JOB", + "sql-manual/sql-statements/data-modification/load-and-export/SHOW-SYNC-JOB", + "sql-manual/sql-statements/data-modification/load-and-export/SYNC", + "sql-manual/sql-statements/data-modification/load-and-export/EXPORT", + "sql-manual/sql-statements/data-modification/load-and-export/CANCEL-EXPORT", + "sql-manual/sql-statements/data-modification/load-and-export/SHOW-EXPORT", + "sql-manual/sql-statements/data-modification/load-and-export/OUTFILE", + "sql-manual/sql-statements/data-modification/load-and-export/CLEAN-LABEL" + ] + }, + { + "type": "category", + "label": "Backup and Restore", + "items": [ + "sql-manual/sql-statements/data-modification/backup-and-restore/CREATE-REPOSITORY", + "sql-manual/sql-statements/data-modification/backup-and-restore/DROP-REPOSITORY", + "sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-CREATE-REPOSITORY", + "sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-REPOSITORIES", + "sql-manual/sql-statements/data-modification/backup-and-restore/BACKUP", + "sql-manual/sql-statements/data-modification/backup-and-restore/CANCEL-BACKUP", + "sql-manual/sql-statements/data-modification/backup-and-restore/RESTORE", + "sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-RESTORE", + "sql-manual/sql-statements/data-modification/backup-and-restore/CANCEL-RESTORE", + "sql-manual/sql-statements/data-modification/backup-and-restore/SHOW-SNAPSHOT" + ] + } ] }, { "type": "category", "label": "Account Management", "items": [ - "sql-manual/sql-statements/Account-Management-Statements/CREATE-ROLE", - "sql-manual/sql-statements/Account-Management-Statements/CREATE-USER", - "sql-manual/sql-statements/Account-Management-Statements/ALTER-ROLE", - "sql-manual/sql-statements/Account-Management-Statements/ALTER-USER", - "sql-manual/sql-statements/Account-Management-Statements/SET-PASSWORD", - "sql-manual/sql-statements/Account-Management-Statements/SET-PROPERTY", - "sql-manual/sql-statements/Account-Management-Statements/LDAP", - "sql-manual/sql-statements/Account-Management-Statements/GRANT", - "sql-manual/sql-statements/Account-Management-Statements/REVOKE", - "sql-manual/sql-statements/Account-Management-Statements/DROP-ROLE", - "sql-manual/sql-statements/Account-Management-Statements/DROP-USER" + "sql-manual/sql-statements/account-management/CREATE-USER", + "sql-manual/sql-statements/account-management/ALTER-USER", + "sql-manual/sql-statements/account-management/DROP-USER", + "sql-manual/sql-statements/account-management/SET-PASSWORD", + "sql-manual/sql-statements/account-management/CREATE-ROLE", + "sql-manual/sql-statements/account-management/ALTER-ROLE", + "sql-manual/sql-statements/account-management/DROP-ROLE", + "sql-manual/sql-statements/account-management/SHOW-ROLES", + "sql-manual/sql-statements/account-management/GRANT-TO", + "sql-manual/sql-statements/account-management/REVOKE-FROM", + "sql-manual/sql-statements/account-management/SHOW-PRIVILEGES", + "sql-manual/sql-statements/account-management/SHOW-GRANTS", + "sql-manual/sql-statements/account-management/REFRESH-LDAP", + "sql-manual/sql-statements/account-management/SET-LDAP_ADMIN_PASSWORD", + "sql-manual/sql-statements/account-management/SET-PROPERTY", + "sql-manual/sql-statements/account-management/SHOW-PROPERTY" ] }, { "type": "category", - "label": "Database Administration", - "items": [ - "sql-manual/sql-statements/Database-Administration-Statements/SHOW-CONFIG", - "sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-CONFIG", - "sql-manual/sql-statements/Database-Administration-Statements/SET-VARIABLE", - "sql-manual/sql-statements/Database-Administration-Statements/INSTALL-PLUGIN", - "sql-manual/sql-statements/Database-Administration-Statements/UNINSTALL-PLUGIN", - "sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-REPLICA-STATUS", - "sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-REPLICA-VERSION", - "sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-PARTITION-VERSION", - "sql-manual/sql-statements/Database-Administration-Statements/ADMIN-SET-TABLE-STATUS", - "sql-manual/sql-statements/Database-Administration-Statements/SHOW-REPLICA-DISTRIBUTION", - "sql-manual/sql-statements/Database-Administration-Statements/SHOW-REPLICA-STATUS", - "sql-manual/sql-statements/Database-Administration-Statements/ADMIN-REPAIR-TABLE", - "sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CANCEL-REPAIR", - "sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CHECK-TABLET", - "sql-manual/sql-statements/Database-Administration-Statements/SHOW-TABLET-DIAGNOSIS", - "sql-manual/sql-statements/Database-Administration-Statements/ADMIN-COPY-TABLET", - "sql-manual/sql-statements/Database-Administration-Statements/SHOW-TABLET-STORAGE-FORMAT", - "sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CLEAN-TRASH", - "sql-manual/sql-statements/Database-Administration-Statements/RECOVER", - "sql-manual/sql-statements/Database-Administration-Statements/KILL", - "sql-manual/sql-statements/Database-Administration-Statements/ADMIN-REBALANCE-DISK", - "sql-manual/sql-statements/Database-Administration-Statements/ADMIN-CANCEL-REBALANCE-DISK", - "sql-manual/sql-statements/Database-Administration-Statements/UNSET-VARIABLE" + "label": "Session", + "items": [ + { + "type": "category", + "label": "Context", + "items": [ + "sql-manual/sql-statements/session/context/USE-COMPUTE-GROUP", + "sql-manual/sql-statements/session/context/SWITCH-CATALOG", + "sql-manual/sql-statements/session/context/USE-DATABASE" + ] + }, + { + "type": "category", + "label": "Variable", + "items": [ + "sql-manual/sql-statements/session/variable/SET-VARIABLE", + "sql-manual/sql-statements/session/variable/UNSET-VARIABLE", + "sql-manual/sql-statements/session/variable/SHOW-VARIABLES" + ] + }, + { + "type": "category", + "label": "Query", + "items": [ + "sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST", + "sql-manual/sql-statements/session/queries/KILL-QUERY", + "sql-manual/sql-statements/session/queries/CLEAN-ALL-PROFILE", + "sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS", + "sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS", + "sql-manual/sql-statements/session/queries/PLAN-REPLAYER-DUMP", + "sql-manual/sql-statements/session/queries/PLAN-REPLAYER-PLAY" + ] + }, + { + "type": "category", + "label": "Connection", + "items": [ + "sql-manual/sql-statements/session/connection/KILL-CONNECTION" + ] + } + ] + }, + { + "type": "category", + "label": "Transaction", + "items": [ + "sql-manual/sql-statements/transaction/BEGIN", + "sql-manual/sql-statements/transaction/COMMIT", + "sql-manual/sql-statements/transaction/ROLLBACK", + "sql-manual/sql-statements/transaction/SHOW-TRANSACTION" ] }, { "type": "category", - "label": "DDL", + "label": "Data Catalog", + "items": [ + "sql-manual/sql-statements/catalog/CREATE-CATALOG", + "sql-manual/sql-statements/catalog/ALTER-CATALOG", + "sql-manual/sql-statements/catalog/DROP-CATALOG", + "sql-manual/sql-statements/catalog/SHOW-CREATE-CATALOG", + "sql-manual/sql-statements/catalog/SHOW-CATALOG", + "sql-manual/sql-statements/catalog/REFRESH" + ] + }, + { + "type": "category", + "label": "Database", + "items": [ + "sql-manual/sql-statements/database/CREATE-DATABASE", + "sql-manual/sql-statements/database/ALTER-DATABASE", + "sql-manual/sql-statements/database/DROP-DATABASE", + "sql-manual/sql-statements/database/SHOW-CREATE-DATABASE", + "sql-manual/sql-statements/database/SHOW-DATABASES", + "sql-manual/sql-statements/database/SHOW-DATABASE-ID" + ] + }, + { + "type": "category", + "label": "Table and Views", "items": [ { "type": "category", - "label": "Create", + "label": "Table", "items": [ - "sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-CATALOG", - "sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-DATABASE", - "sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE", - "sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-AND-GENERATED-COLUMN", - "sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-LIKE", - "sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-TABLE-AS-SELECT", - "sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-INDEX", - "sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-VIEW", - "sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-MATERIALIZED-VIEW", - "sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FUNCTION", - "sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-FILE", - "sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-POLICY", - "sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-ENCRYPT-KEY", - "sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-RESOURCE", - "sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-WORKLOAD-GROUP", - "sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-SQL-BLOCK-RULE", - "sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-STORAGE-VAULT", - "sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-ASYNC-MATERIALIZED-VIEW", - "sql-manual/sql-statements/Data-Definition-Statements/Create/CREATE-JOB" + "sql-manual/sql-statements/table-and-view/table/CREATE-TABLE", + "sql-manual/sql-statements/table-and-view/table/CREATE-TABLE-LIKE", + "sql-manual/sql-statements/table-and-view/table/CREATE-TABLE-AS-SELECT", + "sql-manual/sql-statements/table-and-view/table/DESC-TABLE", + "sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-COLUMN", + "sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-PARTITION", + "sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-ROLLUP", + "sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-RENAME", + "sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-REPLACE", + "sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-PROPERTY", + "sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-COMMENT", + "sql-manual/sql-statements/table-and-view/table/ALTER-TABLE-AND-GENERATED-COLUMN", + "sql-manual/sql-statements/table-and-view/table/CANCEL-ALTER-TABLE", + "sql-manual/sql-statements/table-and-view/table/SHOW-ALTER-TABLE", + "sql-manual/sql-statements/table-and-view/table/TRUNCATE-TABLE", + "sql-manual/sql-statements/table-and-view/table/DROP-TABLE", + "sql-manual/sql-statements/table-and-view/table/SHOW-CREATE-TABLE", + "sql-manual/sql-statements/table-and-view/table/SHOW-TABLES", + "sql-manual/sql-statements/table-and-view/table/SHOW-TABLE-ID", + "sql-manual/sql-statements/table-and-view/table/SHOW-TABLE-STATUS", + "sql-manual/sql-statements/table-and-view/table/SHOW-CONVERT-LIGHT-SCHEMA-CHANGE-PROCESS", + "sql-manual/sql-statements/table-and-view/table/SHOW-PARTITION", + "sql-manual/sql-statements/table-and-view/table/SHOW-PARTITION-ID", + "sql-manual/sql-statements/table-and-view/table/SHOW-PARTITIONS", + "sql-manual/sql-statements/table-and-view/table/SHOW-DYNAMIC-PARTITION-TABLES", + "sql-manual/sql-statements/table-and-view/table/SHOW-COLUMNS", + "sql-manual/sql-statements/table-and-view/table/ALTER-COLOCATE-GROUP" ] }, { "type": "category", - "label": "Alter", + "label": "Index", "items": [ - "sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-CATALOG", - "sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-DATABASE", - "sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-COLUMN", - "sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-PARTITION", - "sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-ROLLUP", - "sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-RENAME", - "sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-REPLACE", - "sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-PROPERTY", - "sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-COMMENT", - "sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-TABLE-AND-GENERATED-COLUMN", - "sql-manual/sql-statements/Data-Definition-Statements/Alter/CANCEL-ALTER-TABLE", - "sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-VIEW", - "sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-STORAGE-POLICY", - "sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-RESOURCE", - "sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-COLOCATE-GROUP", - "sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-WORKLOAD-GROUP", - "sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-SQL-BLOCK-RULE", - "sql-manual/sql-statements/Data-Definition-Statements/Alter/ALTER-ASYNC-MATERIALIZED-VIEW", - "sql-manual/sql-statements/Data-Definition-Statements/Alter/PAUSE-JOB", - "sql-manual/sql-statements/Data-Definition-Statements/Alter/RESUME-JOB" + "sql-manual/sql-statements/table-and-view/index/CREATE-INDEX", + "sql-manual/sql-statements/table-and-view/index/DROP-INDEX", + "sql-manual/sql-statements/table-and-view/index/SHOW-INDEX", + "sql-manual/sql-statements/table-and-view/index/BUILD-INDEX", + "sql-manual/sql-statements/table-and-view/index/CANCEL-BUILD-INDEX", + "sql-manual/sql-statements/table-and-view/index/SHOW-BUILD-INDEX" ] }, { "type": "category", - "label": "Drop", + "label": "View", "items": [ - "sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-CATALOG", - "sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-DATABASE", - "sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-TABLE", - "sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-INDEX", - "sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-MATERIALIZED-VIEW", - "sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-FUNCTION", - "sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-FILE", - "sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-POLICY", - "sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-ENCRYPT-KEY", - "sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-RESOURCE", - "sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-WORKLOAD-GROUP", - "sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-SQL-BLOCK-RULE", - "sql-manual/sql-statements/Data-Definition-Statements/Drop/TRUNCATE-TABLE", - "sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-ASYNC-MATERIALIZED-VIEW", - "sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-JOB", - "sql-manual/sql-statements/Data-Definition-Statements/Drop/DROP-CATALOG-RECYCLE-BIN" + "sql-manual/sql-statements/table-and-view/view/CREATE-VIEW", + "sql-manual/sql-statements/table-and-view/view/ALTER-VIEW", + "sql-manual/sql-statements/table-and-view/view/DROP-VIEW", + "sql-manual/sql-statements/table-and-view/view/SHOW-CREATE-VIEW", + "sql-manual/sql-statements/table-and-view/view/SHOW-VIEW" ] }, { "type": "category", - "label": "Backup and Restore", + "label": "Materialized View", "items": [ - "sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CREATE-REPOSITORY", - "sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/DROP-REPOSITORY", - "sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/BACKUP", - "sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CANCEL-BACKUP", - "sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/RESTORE", - "sql-manual/sql-statements/Data-Definition-Statements/Backup-and-Restore/CANCEL-RESTORE" + "sql-manual/sql-statements/table-and-view/materialized-view/CREATE-MATERIALIZED-VIEW", + "sql-manual/sql-statements/table-and-view/materialized-view/ALTER-ASYNC-MATERIALIZED-VIEW", + "sql-manual/sql-statements/table-and-view/materialized-view/DROP-MATERIALIZED-VIEW", + "sql-manual/sql-statements/table-and-view/materialized-view/DROP-ASYNC-MATERIALIZED-VIEW", + "sql-manual/sql-statements/table-and-view/materialized-view/REFRESH-MATERIALIZED-VIEW", + "sql-manual/sql-statements/table-and-view/materialized-view/SHOW-CREATE-MATERIALIZED-VIEW", + "sql-manual/sql-statements/table-and-view/materialized-view/SHOW-ALTER-TABLE-MATERIALIZED-VIEW", + "sql-manual/sql-statements/table-and-view/materialized-view/PAUSE-MATERIALIZED-VIEW-JOB", + "sql-manual/sql-statements/table-and-view/materialized-view/RESUME-MATERIALIZED-VIEW-JOB", + "sql-manual/sql-statements/table-and-view/materialized-view/CANCEL-MATERIALIZED-VIEW-TASK" + ] + }, + { + "type": "category", + "label": "Data and Status Management", + "items": [ + "sql-manual/sql-statements/table-and-view/data-and-status-management/REBALANCE-DISK", + "sql-manual/sql-statements/table-and-view/data-and-status-management/CANCEL-REBALANCE-DISK", + "sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-DATA", + "sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-DATA-SKEW", + "sql-manual/sql-statements/table-and-view/data-and-status-management/COMPACT-TABLE", + "sql-manual/sql-statements/table-and-view/data-and-status-management/REPAIR-TABLE", + "sql-manual/sql-statements/table-and-view/data-and-status-management/CANCEL-REPAIR-TABLE", + "sql-manual/sql-statements/table-and-view/data-and-status-management/SET-TABLE-STATUS", + "sql-manual/sql-statements/table-and-view/data-and-status-management/SET-TABLE-PARTITION-VERSION", + "sql-manual/sql-statements/table-and-view/data-and-status-management/DIAGNOSE-TABLET", + "sql-manual/sql-statements/table-and-view/data-and-status-management/COPY-TABLET", + "sql-manual/sql-statements/table-and-view/data-and-status-management/CHECK-TABLET", + "sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET", + "sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLETS-BELONG", + "sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET-STORAGE-FORMAT", + "sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TABLET-DIAGNOSIS", + "sql-manual/sql-statements/table-and-view/data-and-status-management/SET-REPLICA-STATUS", + "sql-manual/sql-statements/table-and-view/data-and-status-management/SET-REPLICA-VERSION", + "sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-REPLICA-STATUS", + "sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-REPLICA-DISTRIBUTION", + "sql-manual/sql-statements/table-and-view/data-and-status-management/CLEAN-TRASH", + "sql-manual/sql-statements/table-and-view/data-and-status-management/SHOW-TRASH" ] } ] }, { "type": "category", - "label": "DML", + "label": "Recycle", + "items": [ + "sql-manual/sql-statements/recycle/SHOW-CATALOG-RECYCLE-BIN", + "sql-manual/sql-statements/recycle/DROP-CATALOG-RECYCLE-BIN", + "sql-manual/sql-statements/recycle/RECOVER" + ] + }, + { + "type": "category", + "label": "Function", + "items": [ + "sql-manual/sql-statements/function/CREATE-FUNCTION", + "sql-manual/sql-statements/function/DROP-FUNCTION", + "sql-manual/sql-statements/function/SHOW-CREATE-FUNCTION", + "sql-manual/sql-statements/function/DESC-FUNCTION", + "sql-manual/sql-statements/function/SHOW-FUNCTIONS" + ] + }, + { + "type": "category", + "label": "Statistics", + "items": [ + "sql-manual/sql-statements/statistics/ANALYZE", + "sql-manual/sql-statements/statistics/ALTER-STATS", + "sql-manual/sql-statements/statistics/DROP-STATS", + "sql-manual/sql-statements/statistics/SHOW-TABLE-STATS", + "sql-manual/sql-statements/statistics/SHOW-STATS", + "sql-manual/sql-statements/statistics/DROP-ANALYZE-JOB", + "sql-manual/sql-statements/statistics/KILL-ANALYZE-JOB", + "sql-manual/sql-statements/statistics/SHOW-ANALYZE" + ] + }, + { + "type": "category", + "label": "Cluster Management", "items": [ { "type": "category", - "label": "Load", + "label": "Instance Management", "items": [ - "sql-manual/sql-statements/Data-Manipulation-Statements/Load/STREAM-LOAD", - "sql-manual/sql-statements/Data-Manipulation-Statements/Load/MULTI-LOAD", - "sql-manual/sql-statements/Data-Manipulation-Statements/Load/BROKER-LOAD", - "sql-manual/sql-statements/Data-Manipulation-Statements/Load/MYSQL-LOAD", - "sql-manual/sql-statements/Data-Manipulation-Statements/Load/CREATE-ROUTINE-LOAD", - "sql-manual/sql-statements/Data-Manipulation-Statements/Load/ALTER-ROUTINE-LOAD", - "sql-manual/sql-statements/Data-Manipulation-Statements/Load/PAUSE-ROUTINE-LOAD", - "sql-manual/sql-statements/Data-Manipulation-Statements/Load/RESUME-ROUTINE-LOAD", - "sql-manual/sql-statements/Data-Manipulation-Statements/Load/STOP-ROUTINE-LOAD", - "sql-manual/sql-statements/Data-Manipulation-Statements/Load/CREATE-SYNC-JOB", - "sql-manual/sql-statements/Data-Manipulation-Statements/Load/PAUSE-SYNC-JOB", - "sql-manual/sql-statements/Data-Manipulation-Statements/Load/RESUME-SYNC-JOB", - "sql-manual/sql-statements/Data-Manipulation-Statements/Load/STOP-SYNC-JOB", - "sql-manual/sql-statements/Data-Manipulation-Statements/Load/CANCEL-LOAD", - "sql-manual/sql-statements/Data-Manipulation-Statements/Load/CLEAN-LABEL", - "sql-manual/sql-statements/Data-Manipulation-Statements/Load/CLEAN-PROFILE" + "sql-manual/sql-statements/cluster-management/instance-management/ADD-FOLLOWER", + "sql-manual/sql-statements/cluster-management/instance-management/DROP-FOLLOWER", + "sql-manual/sql-statements/cluster-management/instance-management/ADD-OBSERVER", + "sql-manual/sql-statements/cluster-management/instance-management/DROP-OBSERVER", + "sql-manual/sql-statements/cluster-management/instance-management/SET-FRONTEND-CONFIG", + "sql-manual/sql-statements/cluster-management/instance-management/SHOW-FRONTEND-CONFIG", + "sql-manual/sql-statements/cluster-management/instance-management/MODIFY-FRONTEND-HOSTNAME", + "sql-manual/sql-statements/cluster-management/instance-management/SHOW-FRONTENDS", + "sql-manual/sql-statements/cluster-management/instance-management/SHOW-FRONTENDS-DISKS", + "sql-manual/sql-statements/cluster-management/instance-management/ADD-BACKEND", + "sql-manual/sql-statements/cluster-management/instance-management/DROP-BACKEND", + "sql-manual/sql-statements/cluster-management/instance-management/MODIFY-BACKEND", + "sql-manual/sql-statements/cluster-management/instance-management/SHOW-BACKENDS", + "sql-manual/sql-statements/cluster-management/instance-management/SHOW-BACKEND-CONFIG", + "sql-manual/sql-statements/cluster-management/instance-management/DECOMMISSION-BACKEND", + "sql-manual/sql-statements/cluster-management/instance-management/CANCEL-DECOMMISSION-BACKEND", + "sql-manual/sql-statements/cluster-management/instance-management/ADD-BROKER", + "sql-manual/sql-statements/cluster-management/instance-management/DROP-BROKER", + "sql-manual/sql-statements/cluster-management/instance-management/SHOW-BROKER" ] }, { "type": "category", - "label": "Manipulation", + "label": "Compute Management", "items": [ - "sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/INSERT", - "sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/SELECT", - "sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/EXPLAIN", - "sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/DELETE", - "sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/UPDATE", - "sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/EXPORT", - "sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/CANCEL-EXPORT", - "sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/INSERT-OVERWRITE", - "sql-manual/sql-statements/Data-Manipulation-Statements/Manipulation/ANALYZE" + "sql-manual/sql-statements/cluster-management/compute-management/CREATE-RESOURCE", + "sql-manual/sql-statements/cluster-management/compute-management/ALTER-RESOURCE", + "sql-manual/sql-statements/cluster-management/compute-management/DROP-RESOURCE", + "sql-manual/sql-statements/cluster-management/compute-management/SHOW-RESOURCES", + "sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-GROUP", + "sql-manual/sql-statements/cluster-management/compute-management/ALTER-WORKLOAD-GROUP", + "sql-manual/sql-statements/cluster-management/compute-management/DROP-WORKLOAD-GROUP", + "sql-manual/sql-statements/cluster-management/compute-management/SHOW-WORKLOAD-GROUPS", + "sql-manual/sql-statements/cluster-management/compute-management/CREATE-WORKLOAD-POLICY", + "sql-manual/sql-statements/cluster-management/compute-management/ALTER-WORKLOAD-POLICY", + "sql-manual/sql-statements/cluster-management/compute-management/DROP-WORKLOAD-POLICY", + "sql-manual/sql-statements/cluster-management/compute-management/SHOW-COMPUTE-GROUPS" ] }, - "sql-manual/sql-statements/Data-Manipulation-Statements/OUTFILE" + { + "type": "category", + "label": "Storage Management", + "items": [ + "sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT", + "sql-manual/sql-statements/cluster-management/storage-management/ALTER-STORAGE-VAULT", + "sql-manual/sql-statements/cluster-management/storage-management/SET-DEFAULT-STORAGE-VAULT", + "sql-manual/sql-statements/cluster-management/storage-management/UNSET-DEFAULT-STORAGE-VAULT", + "sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-VAULTS", + "sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-POLICY", + "sql-manual/sql-statements/cluster-management/storage-management/ALTER-STORAGE-POLICY", + "sql-manual/sql-statements/cluster-management/storage-management/DROP-STORAGE-POLICY", + "sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-POLICY", + "sql-manual/sql-statements/cluster-management/storage-management/SHOW-STORAGE-POLICY-USING", + "sql-manual/sql-statements/cluster-management/storage-management/WARM-UP", + "sql-manual/sql-statements/cluster-management/storage-management/CANCEL-WARM-UP", + "sql-manual/sql-statements/cluster-management/storage-management/SHOW-WARM-UP-JOB", + "sql-manual/sql-statements/cluster-management/storage-management/SHOW-CACHE-HOTSPOT" + ] + } + ] + }, + { + "type": "category", + "label": "Security", + "items": [ + "sql-manual/sql-statements/security/CREATE-FILE", + "sql-manual/sql-statements/security/DROP-FILE", + "sql-manual/sql-statements/security/SHOW-FILE", + "sql-manual/sql-statements/security/CREATE-ENCRYPTKEY", + "sql-manual/sql-statements/security/DROP-ENCRYPTKEY", + "sql-manual/sql-statements/security/SHOW-ENCRYPTKEY" + ] + }, + { + "type": "category", + "label": "Data Governance", + "items": [ + "sql-manual/sql-statements/data-governance/CREATE-SQL_BLOCK_RULE", + "sql-manual/sql-statements/data-governance/ALTER-SQL_BLOCK_RULE", + "sql-manual/sql-statements/data-governance/DROP-SQL_BLOCK_RULE", + "sql-manual/sql-statements/data-governance/SHOW-SQL_BLOCK_RULE", + "sql-manual/sql-statements/data-governance/CREATE-ROW-POLICY", + "sql-manual/sql-statements/data-governance/DROP-ROW-POLICY", + "sql-manual/sql-statements/data-governance/SHOW-ROW-POLICY" ] }, { "type": "category", - "label": "Show", - "items": [ - "sql-manual/sql-statements/Show-Statements/SHOW-ALTER-TABLE-MATERIALIZED-VIEW", - "sql-manual/sql-statements/Show-Statements/SHOW-ALTER", - "sql-manual/sql-statements/Show-Statements/SHOW-ANALYZE", - "sql-manual/sql-statements/Show-Statements/SHOW-BACKUP", - "sql-manual/sql-statements/Show-Statements/SHOW-BACKENDS", - "sql-manual/sql-statements/Show-Statements/SHOW-BROKER", - "sql-manual/sql-statements/Show-Statements/SHOW-CATALOGS", - "sql-manual/sql-statements/Show-Statements/SHOW-CREATE-TABLE", - "sql-manual/sql-statements/Show-Statements/SHOW-CREATE-MATERIALIZED-VIEW", - "sql-manual/sql-statements/Show-Statements/SHOW-CREATE-ASYNC-MATERIALIZED-VIEW", - "sql-manual/sql-statements/Show-Statements/SHOW-CHARSET", - "sql-manual/sql-statements/Show-Statements/SHOW-CREATE-CATALOG", - "sql-manual/sql-statements/Show-Statements/SHOW-CREATE-DATABASE", - "sql-manual/sql-statements/Show-Statements/SHOW-CREATE-LOAD", - "sql-manual/sql-statements/Show-Statements/SHOW-CREATE-REPOSITORY", - "sql-manual/sql-statements/Show-Statements/SHOW-CREATE-ROUTINE-LOAD", - "sql-manual/sql-statements/Show-Statements/SHOW-CREATE-FUNCTION", - "sql-manual/sql-statements/Show-Statements/SHOW-COLUMNS", - "sql-manual/sql-statements/Show-Statements/SHOW-COLUMN-STATS", - "sql-manual/sql-statements/Show-Statements/SHOW-COLLATION", - "sql-manual/sql-statements/Show-Statements/SHOW-CONVERT-LIGHT-SCHEMA-CHANGE-PROCESS", - "sql-manual/sql-statements/Show-Statements/SHOW-DATABASES", - "sql-manual/sql-statements/Show-Statements/SHOW-DATA-SKEW", - "sql-manual/sql-statements/Show-Statements/SHOW-DATABASE-ID", - "sql-manual/sql-statements/Show-Statements/SHOW-DYNAMIC-PARTITION", - "sql-manual/sql-statements/Show-Statements/SHOW-DELETE", - "sql-manual/sql-statements/Show-Statements/SHOW-DATA", - "sql-manual/sql-statements/Show-Statements/SHOW-DATA-TYPES", - "sql-manual/sql-statements/Show-Statements/SHOW-ENGINES", - "sql-manual/sql-statements/Show-Statements/SHOW-EVENTS", - "sql-manual/sql-statements/Show-Statements/SHOW-EXPORT", - "sql-manual/sql-statements/Show-Statements/SHOW-ENCRYPT-KEY", - "sql-manual/sql-statements/Show-Statements/SHOW-FUNCTIONS", - "sql-manual/sql-statements/Show-Statements/SHOW-TYPECAST", - "sql-manual/sql-statements/Show-Statements/SHOW-FILE", - "sql-manual/sql-statements/Show-Statements/SHOW-GRANTS", - "sql-manual/sql-statements/Show-Statements/SHOW-LAST-INSERT", - "sql-manual/sql-statements/Show-Statements/SHOW-LOAD-PROFILE", - "sql-manual/sql-statements/Show-Statements/SHOW-LOAD-WARNINGS", - "sql-manual/sql-statements/Show-Statements/SHOW-INDEX", - "sql-manual/sql-statements/Show-Statements/SHOW-PARTITION-ID", - "sql-manual/sql-statements/Show-Statements/SHOW-SNAPSHOT", - "sql-manual/sql-statements/Show-Statements/SHOW-SQL-BLOCK-RULE", - "sql-manual/sql-statements/Show-Statements/SHOW-ROUTINE-LOAD", - "sql-manual/sql-statements/Show-Statements/SHOW-SYNC-JOB", - "sql-manual/sql-statements/Show-Statements/SHOW-WHITE-LIST", - "sql-manual/sql-statements/Show-Statements/SHOW-WARNING", - "sql-manual/sql-statements/Show-Statements/SHOW-TABLET", - "sql-manual/sql-statements/Show-Statements/SHOW-TABLETS-BELONG", - "sql-manual/sql-statements/Show-Statements/SHOW-VARIABLES", - "sql-manual/sql-statements/Show-Statements/SHOW-PLUGINS", - "sql-manual/sql-statements/Show-Statements/SHOW-ROLES", - "sql-manual/sql-statements/Show-Statements/SHOW-PROCEDURE", - "sql-manual/sql-statements/Show-Statements/SHOW-ROUTINE-LOAD-TASK", - "sql-manual/sql-statements/Show-Statements/SHOW-PROC", - "sql-manual/sql-statements/Show-Statements/SHOW-TABLE-STATS", - "sql-manual/sql-statements/Show-Statements/SHOW-TABLE-STATUS", - "sql-manual/sql-statements/Show-Statements/SHOW-REPOSITORIES", - "sql-manual/sql-statements/Show-Statements/SHOW-QUERY-PROFILE", - "sql-manual/sql-statements/Show-Statements/SHOW-OPEN-TABLES", - "sql-manual/sql-statements/Show-Statements/SHOW-TABLETS", - "sql-manual/sql-statements/Show-Statements/SHOW-LOAD", - "sql-manual/sql-statements/Show-Statements/SHOW-TABLES", - "sql-manual/sql-statements/Show-Statements/SHOW-RESOURCES", - "sql-manual/sql-statements/Show-Statements/SHOW-WORKLOAD-GROUPS", - "sql-manual/sql-statements/Show-Statements/SHOW-PARTITIONS", - "sql-manual/sql-statements/Show-Statements/SHOW-FRONTENDS", - "sql-manual/sql-statements/Show-Statements/SHOW-FRONTENDS-DISKS", - "sql-manual/sql-statements/Show-Statements/SHOW-RESTORE", - "sql-manual/sql-statements/Show-Statements/SHOW-PROPERTY", - "sql-manual/sql-statements/Show-Statements/SHOW-TRIGGERS", - "sql-manual/sql-statements/Show-Statements/SHOW-PROCESSLIST", - "sql-manual/sql-statements/Show-Statements/SHOW-PRIVILEGES", - "sql-manual/sql-statements/Show-Statements/SHOW-TRASH", - "sql-manual/sql-statements/Show-Statements/SHOW-VIEW", - "sql-manual/sql-statements/Show-Statements/SHOW-TRANSACTION", - "sql-manual/sql-statements/Show-Statements/SHOW-STREAM-LOAD", - "sql-manual/sql-statements/Show-Statements/SHOW-STATUS", - "sql-manual/sql-statements/Show-Statements/SHOW-TABLE-ID", - "sql-manual/sql-statements/Show-Statements/SHOW-SMALL-FILES", - "sql-manual/sql-statements/Show-Statements/SHOW-POLICY", - "sql-manual/sql-statements/Show-Statements/SHOW-STORAGE-POLICY-USING", - "sql-manual/sql-statements/Show-Statements/SHOW-CATALOG-RECYCLE-BIN", - "sql-manual/sql-statements/Show-Statements/SHOW-QUERY-STATS" + "label": "Job", + "items": [ + "sql-manual/sql-statements/job/CREATE-JOB", + "sql-manual/sql-statements/job/PAUSE-JOB", + "sql-manual/sql-statements/job/DROP-JOB", + "sql-manual/sql-statements/job/RESUME-JOB", + "sql-manual/sql-statements/job/CANCEL-TASK" + ] + }, + { + "type": "category", + "label": "Plugin", + "items": [ + "sql-manual/sql-statements/plugin/INSTALL-PLUGIN", + "sql-manual/sql-statements/plugin/UNINSTALL-PLUGIN", + "sql-manual/sql-statements/plugin/SHOW-PLUGINS" ] }, { "type": "category", - "label": "Operators", + "label": "Character Set", "items": [ - "sql-manual/sql-statements/Operators/in" + "sql-manual/sql-statements/character-set/SHOW-COLLATION", + "sql-manual/sql-statements/character-set/SHOW-CHARSET" ] }, { "type": "category", - "label": "Utility", - "items": [ - "sql-manual/sql-statements/Utility-Statements/HELP", - "sql-manual/sql-statements/Utility-Statements/USE", - "sql-manual/sql-statements/Utility-Statements/DESCRIBE", - "sql-manual/sql-statements/Utility-Statements/SWITCH", - "sql-manual/sql-statements/Utility-Statements/REFRESH", - "sql-manual/sql-statements/Utility-Statements/SYNC", - "sql-manual/sql-statements/Utility-Statements/CLEAN-QUERY-STATS", - "sql-manual/sql-statements/Utility-Statements/CANCEL-MATERIALIZED-VIEW-TASK", - "sql-manual/sql-statements/Utility-Statements/PAUSE-MATERIALIZED-VIEW", - "sql-manual/sql-statements/Utility-Statements/REFRESH-MATERIALIZED-VIEW", - "sql-manual/sql-statements/Utility-Statements/RESUME-MATERIALIZED-VIEW", - "sql-manual/sql-statements/Utility-Statements/REFRESH-LDAP" + "label": "Types", + "items": [ + "sql-manual/sql-statements/types/SHOW-DATA-TYPES", + "sql-manual/sql-statements/types/SHOW-TYPECAST" + ] + }, + { + "type": "category", + "label": "Info System and Help", + "items": [ + "sql-manual/sql-statements/system-info-and-help/SHOW-PROC", + "sql-manual/sql-statements/system-info-and-help/HELP" ] } ] diff --git a/src/constant/common.tsx b/src/constant/common.tsx index b1f71a6bb9a28..308aaf6963d54 100644 --- a/src/constant/common.tsx +++ b/src/constant/common.tsx @@ -20,4 +20,5 @@ export const BLOG_TAG_ICONS = { }; export const VERSIONS = ['1.2', '2.0', '2.1', '3.0', 'dev']; -export const DEFAULT_VERSION = '2.1'; \ No newline at end of file +export const DEFAULT_VERSION = '2.1'; +export const ARCHIVE_PATH = 'archive-docs'; \ No newline at end of file diff --git a/src/pages/archive-docs/index.scss b/src/pages/archive-docs/index.scss new file mode 100644 index 0000000000000..81af83463fb88 --- /dev/null +++ b/src/pages/archive-docs/index.scss @@ -0,0 +1,51 @@ +.archive-container { + padding: 0 1rem; + width: 100%; + margin: 0 auto 5.5rem auto; + .archive-admonition { + padding: 2rem; + margin-top: 1.25rem; + margin-bottom: 1.25rem; + background-color: rgb(255, 248, 230); + border-radius: 6px; + border: 0 solid rgb(230, 167, 0); + border-left-width: 5px; + p { + color: rgb(107, 88, 39); + font-weight: 600; + } + } + h1 { + font-size: 2.25rem; + font-weight: 700; + line-height: 45px; + margin-top: 2.875rem; + } + h2 { + padding-top: 1.25rem; + margin-top: 2.875rem; + margin-bottom: 1.25rem; + font-size: 1.625rem; + font-weight: 700; + line-height: 32px; + } + + ul li { + margin-bottom: 1.25rem; + color: rgb(85, 95, 115); + } + + .download-link:hover { + text-decoration: underline; + color: #444fd9; + } +} + +@media (min-width: 1280px) { + .archive-container { + max-width: 1280px; + .archive-admonition { + max-width: 75%; + } + } +} diff --git a/src/pages/archive-docs/index.tsx b/src/pages/archive-docs/index.tsx new file mode 100644 index 0000000000000..e85f35e925fe5 --- /dev/null +++ b/src/pages/archive-docs/index.tsx @@ -0,0 +1,105 @@ +import React, { useState, useEffect } from 'react'; +import Layout from '@site/src/theme/Layout'; +import Link from '@docusaurus/Link'; +import Translate, { translate } from '@docusaurus/Translate'; +import { downloadFile } from '../../theme/TOC/index'; +import './index.scss'; + +const DOWNLOAD_LINK_ZH = 'https://cdn.selectdb.com/static/doris_1_2_2_18e810982b.pdf'; +const DOWNLOAD_LINK_EN = 'https://cdn.selectdb.com/static/doris_1_2_en_0d0a9b6a03.pdf'; + +const DATE_LINK = '2025-01-17'; + +export default function Archive() { + const [isZH, setIsZH] = useState(false); + + useEffect(() => { + if (typeof window !== 'undefined') { + setIsZH(location.pathname.includes('zh-CN')); + } + }, [typeof window !== 'undefined' && location.pathname]); + return ( + +

+ + ); +} diff --git a/src/theme/Navbar/Content/components/NavbarDocs.tsx b/src/theme/Navbar/Content/components/NavbarDocs.tsx index 25b5ff513ba95..01f0edd301620 100644 --- a/src/theme/Navbar/Content/components/NavbarDocs.tsx +++ b/src/theme/Navbar/Content/components/NavbarDocs.tsx @@ -12,6 +12,7 @@ import { NavbarItems, getNavItem } from '..'; import SearchIcon from '@site/static/images/search-icon.svg'; import CloseIcon from '@site/static/images/icon/close.svg'; import { DataContext } from '../../../Layout'; +import { ARCHIVE_PATH } from '../../../../constant/common' ; interface NavbarDocsProps { isEN: boolean; @@ -22,7 +23,10 @@ export const NavbarDocsLeft = ({ isEN }: NavbarDocsProps) => { const location = useLocation(); const history = useHistory(); const docItems = isEN ? useThemeConfig().docNavbarEN.items : useThemeConfig().docNavbarZH.items; - const [leftDocItems] = splitNavbarItems(docItems); + let [leftDocItems] = splitNavbarItems(docItems); + if(location.pathname.includes(ARCHIVE_PATH)){ + leftDocItems = leftDocItems.filter((item)=>item.type !== 'search') + } useEffect(() => { const secPath = location.pathname.includes('zh-CN/docs') ? location.pathname.split('/')[3] diff --git a/src/theme/Navbar/Content/index.tsx b/src/theme/Navbar/Content/index.tsx index c213024ec2226..2e9447bd93b89 100644 --- a/src/theme/Navbar/Content/index.tsx +++ b/src/theme/Navbar/Content/index.tsx @@ -11,6 +11,7 @@ import { NavbarDocsLeft, NavbarDocsRight, NavbarDocsBottom } from './components/ import { NavbarCommunityLeft, NavbarCommunityBottom, NavbarCommunityRight } from './components/NavbarCommunity'; import { NavbarCommonLeft, NavbarCommonRight } from './components/NavbarCommon'; import { DataContext } from '../../Layout'; +import { ARCHIVE_PATH } from '@site/src/constant/common'; import styles from './styles.module.css'; @@ -117,7 +118,7 @@ export default function NavbarContent(): ReactNode { if (typeof window !== 'undefined') { const pathname = location.pathname.split('/')[1]; location.pathname.includes('zh-CN') ? setIsEN(false) : setIsEN(true); - if (location.pathname.includes(NavBar.DOCS)) { + if (location.pathname.includes(NavBar.DOCS) || location.pathname.includes(ARCHIVE_PATH)) { setCurrentNavbar(NavBar.DOCS); } else if (pathname === NavBar.COMMUNITY || location.pathname.includes('zh-CN/community')) { setCurrentNavbar(NavBar.COMMUNITY); diff --git a/src/theme/TOC/index.tsx b/src/theme/TOC/index.tsx index 2287fc0102b5b..e0961ed7e6ca1 100644 --- a/src/theme/TOC/index.tsx +++ b/src/theme/TOC/index.tsx @@ -18,7 +18,7 @@ import styles from './styles.module.css'; const LINK_CLASS_NAME = 'table-of-contents__link toc-highlight'; const LINK_ACTIVE_CLASS_NAME = 'table-of-contents__link--active'; -function downloadFile(url, filename) { +export function downloadFile(url:string, filename:string) { var xml = new XMLHttpRequest(); xml.open('GET', url, true); xml.responseType = 'blob'; diff --git a/static/images/getting-started/apache-doris-technical-compute-storage-decouple-overview.jpg b/static/images/getting-started/apache-doris-technical-compute-storage-decouple-overview.jpg new file mode 100644 index 0000000000000..ddafab3c4fdb0 Binary files /dev/null and b/static/images/getting-started/apache-doris-technical-compute-storage-decouple-overview.jpg differ diff --git a/static/images/getting-started/apache-doris-technical-compute-storage-decouple-overview.png b/static/images/getting-started/apache-doris-technical-compute-storage-decouple-overview.png deleted file mode 100644 index f21562ddfe6ee..0000000000000 Binary files a/static/images/getting-started/apache-doris-technical-compute-storage-decouple-overview.png and /dev/null differ diff --git a/versioned_docs/version-1.2/admin-manual/certificate.md b/versioned_docs/version-1.2/admin-manual/certificate.md index 26691a8ba54f7..351132e50dbe5 100644 --- a/versioned_docs/version-1.2/admin-manual/certificate.md +++ b/versioned_docs/version-1.2/admin-manual/certificate.md @@ -37,6 +37,7 @@ Enabling SSL functionality in Doris requires configuring both a CA key certifica In addition to the Doris default certificate file, you can also generate a custom certificate file through `openssl`. Here are the steps (refer to [Creating SSL Certificates and Keys Using OpenSSL](https://dev.mysql.com/doc/refman/8.0/en/creating-ssl-files-using-openssl.html)): 1. Generate the CA, server-side, and client-side keys and certificates: + ```shell # Generate the CA certificate openssl genrsa 2048 > ca-key.pem @@ -61,11 +62,13 @@ openssl x509 -req -in client-req.pem -days 3600 \ ``` 2. Verify the created certificates: + ```shell openssl verify -CAfile ca.pem server-cert.pem client-cert.pem ``` 3. Combine your key and certificate in a PKCS#12 (P12) bundle. + ```shell # Package the CA key and certificate openssl pkcs12 -inkey ca-key.pem -in ca.pem -export -out ca_certificate.p12 diff --git a/versioned_docs/version-1.2/admin-manual/config/be-config.md b/versioned_docs/version-1.2/admin-manual/config/be-config.md index 8989e0a18dd7e..71530fb1d14af 100644 --- a/versioned_docs/version-1.2/admin-manual/config/be-config.md +++ b/versioned_docs/version-1.2/admin-manual/config/be-config.md @@ -72,7 +72,9 @@ There are two ways to configure BE configuration items: By adding in the `be.conf` file: - ```max_base_compaction_threads=5``` + ``` + max_base_compaction_threads=5 + ``` Then restart the BE process to take effect the configuration. diff --git a/versioned_docs/version-1.2/admin-manual/http-actions/be/compaction-action.md b/versioned_docs/version-1.2/admin-manual/http-actions/be/compaction-action.md index 40a7e6b867efb..225a7032453b3 100644 --- a/versioned_docs/version-1.2/admin-manual/http-actions/be/compaction-action.md +++ b/versioned_docs/version-1.2/admin-manual/http-actions/be/compaction-action.md @@ -209,3 +209,4 @@ Explanation of results: ``` curl -X GET http://192.168.10.24:8040/api/compaction/run_status?tablet_id=10015 +``` \ No newline at end of file diff --git a/versioned_docs/version-1.2/admin-manual/http-actions/be/tablets_distribution.md b/versioned_docs/version-1.2/admin-manual/http-actions/be/tablets-distribution.md similarity index 100% rename from versioned_docs/version-1.2/admin-manual/http-actions/be/tablets_distribution.md rename to versioned_docs/version-1.2/admin-manual/http-actions/be/tablets-distribution.md diff --git a/versioned_docs/version-1.2/admin-manual/http-actions/fe/table-query-plan-action.md b/versioned_docs/version-1.2/admin-manual/http-actions/fe/table-query-plan-action.md index 0b1b6abaf5a5c..7c81017057c18 100644 --- a/versioned_docs/version-1.2/admin-manual/http-actions/fe/table-query-plan-action.md +++ b/versioned_docs/version-1.2/admin-manual/http-actions/fe/table-query-plan-action.md @@ -73,7 +73,23 @@ None "schemaHash": 1294206575 } }, - "opaqued_query_plan": "DAABDAACDwABDAAAAAEIAAEAAAAACAACAAAAAAgAAwAAAAAKAAT//////////w8ABQgAAAABAAAAAA8ABgIAAAABAAIACAAMABIIAAEAAAAADwACCwAAAAIAAAACazEAAAACazIPAAMIAAAAAgAAAAUAAAAFAgAEAQAAAA8ABAwAAAACDwABDAAAAAEIAAEAAAAQDAACDwABDAAAAAEIAAEAAAAADAACCAABAAAABQAAAAgABAAAAAAMAA8IAAEAAAAACAACAAAAAAAIABT/////CAAX/////wAADwABDAAAAAEIAAEAAAAQDAACDwABDAAAAAEIAAEAAAAADAACCAABAAAABQAAAAgABAAAAAAMAA8IAAEAAAABCAACAAAAAAAIABT/////CAAX/////wAADAAFCAABAAAABgwACAAADAAGCAABAAAAAA8AAgwAAAAAAAoABwAAAAAAAAAACgAIAAAAAAAAAAAADQACCgwAAAABAAAAAAAAJzcKAAEAAAAAAAAnNwoAAgAAAAAAAAACCgADDaJlqbrVdwgIAARNJAZvAAwAAw8AAQwAAAACCAABAAAAAAgAAgAAAAAMAAMPAAEMAAAAAQgAAQAAAAAMAAIIAAEAAAAFAAAACAAE/////wgABQAAAAQIAAYAAAAACAAHAAAAAAsACAAAAAJrMQgACQAAAAACAAoBAAgAAQAAAAEIAAIAAAAADAADDwABDAAAAAEIAAEAAAAADAACCAABAAAABQAAAAgABP////8IAAUAAAAICAAGAAAAAAgABwAAAAELAAgAAAACazIIAAkAAAABAgAKAQAPAAIMAAAAAQgAAQAAAAAIAAIAAAAMCAADAAAAAQoABAAAAAAAACc1CAAFAAAAAgAPAAMMAAAAAQoAAQAAAAAAACc1CAACAAAAAQgAAwAAAAIIAAQAAAAACwAHAAAABHRibDELAAgAAAAADAALCwABAAAABHRibDEAAAAMAAQKAAFfL5rpxl1I4goAArgs6f+h6eMxAAA=", + "opaqued_query_plan": "DAABDAACDwABDAAAAAEIAAEAAAAACAACAAAAAAgAAwAAAAAKAAT////////// + w8ABQgAAAABAAAAAA8ABgIAAAABAAIACAAMABIIAAEAAAAADwACCwAAAAIAAAACazEAAAACazIPAAMIAAAAA + gAAAAUAAAAFAgAEAQAAAA8ABAwAAAACDwABDAAAAAEIAAEAAAAQDAACDwABDAAAAAEIAAEAAAAADAACCAABA + AAABQAAAAgABAAAAAAMAA8IAAEAAAAACAACAAAAAAAIABT/////CAAX/////wAADwABDAAAAAEIAAEAAAAQD + AACDwABDAAAAAEIAAEAAAAADAACCAABAAAABQAAAAgABAAAAAAMAA8IAAEAAAABCAACAAAAAAAIABT + /////CAAX///// + wAADAAFCAABAAAABgwACAAADAAGCAABAAAAAA8AAgwAAAAAAAoABwAAAAAAAAAACgAIAAAAAAAAAAAADQACC + gwAAAABAAAAAAAAJzcKAAEAAAAAAAAnNwoAAgAAAAAAAAACCgADDaJlqbrVdwgIAARNJAZvAAwAAw8AAQwAA + AACCAABAAAAAAgAAgAAAAAMAAMPAAEMAAAAAQgAAQAAAAAMAAIIAAEAAAAFAAAACAAE + ///// + wgABQAAAAQIAAYAAAAACAAHAAAAAAsACAAAAAJrMQgACQAAAAACAAoBAAgAAQAAAAEIAAIAAAAADAADDwABDA + AAAAEIAAEAAAAADAACCAABAAAABQAAAAgABP + //// + 8IAAUAAAAICAAGAAAAAAgABwAAAAELAAgAAAACazIIAAkAAAABAgAKAQAPAAIMAAAAAQgAAQAAAAAIAAIAAAA + MCAADAAAAAQoABAAAAAAAACc1CAAFAAAAAgAPAAMMAAAAAQoAAQAAAAAAACc1CAACAAAAAQgAAwAAAAIIAAQA + AAAACwAHAAAABHRibDELAAgAAAAADAALCwABAAAABHRibDEAAAAMAAQKAAFfL5rpxl1I4goAArgs6f+h6eMxA + AA=", "status": 200 }, "count": 0 diff --git a/versioned_docs/version-1.2/admin-manual/maint-monitor/tablet-repair-and-balance.md b/versioned_docs/version-1.2/admin-manual/maint-monitor/tablet-repair-and-balance.md index 2942d3a186b03..0d07e7c0e45c4 100644 --- a/versioned_docs/version-1.2/admin-manual/maint-monitor/tablet-repair-and-balance.md +++ b/versioned_docs/version-1.2/admin-manual/maint-monitor/tablet-repair-and-balance.md @@ -270,14 +270,14 @@ Tablet state view mainly looks at the state of the tablet, as well as the state Through `SHOW PROC'/cluster_health/tablet_health'; `commands can view the replica status of the entire cluster. ``` - +-------+--------------------------------+-----------+------------+-------------------+----------------------+----------------------+--------------+----------------------------+-------------------------+-------------------+---------------------+----------------------+----------------------+------------------+-----------------------------+-----------------+-------------+------------+ + +-------+--------------------------------+-----------+------------+-------------------+---- | DbId | DbName | TabletNum | HealthyNum | ReplicaMissingNum | VersionIncompleteNum | ReplicaRelocatingNum | RedundantNum | ReplicaMissingInClusterNum | ReplicaMissingForTagNum | ForceRedundantNum | ColocateMismatchNum | ColocateRedundantNum | NeedFurtherRepairNum | UnrecoverableNum | ReplicaCompactionTooSlowNum | InconsistentNum | OversizeNum | CloningNum | - +-------+--------------------------------+-----------+------------+-------------------+----------------------+----------------------+--------------+----------------------------+-------------------------+-------------------+---------------------+----------------------+----------------------+------------------+-----------------------------+-----------------+-------------+------------+ + +-------+--------------------------------+-----------+------------+-------------------+---- | 10005 | default_cluster:doris_audit_db | 84 | 84 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | 13402 | default_cluster:ssb1 | 709 | 708 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | 10108 | default_cluster:tpch1 | 278 | 278 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | | Total | 3 | 1071 | 1070 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | - +-------+--------------------------------+-----------+------------+-------------------+----------------------+----------------------+--------------+----------------------------+-------------------------+-------------------+---------------------+----------------------+----------------------+------------------+-----------------------------+-----------------+-------------+------------+ + +-------+--------------------------------+-----------+------------+-------------------+---- ``` The `HealthyNum` column shows how many Tablets are in a healthy state in the corresponding database. `ReplicaCompactionTooSlowNum` column shows how many Tablets are in a too many versions state in the corresponding database, `InconsistentNum` column shows how many Tablets are in an inconsistent replica state in the corresponding database. The last `Total` line counts the entire cluster. Normally `TabletNum` and `HealthyNum` should be equal. If it's not equal, you can further see which Tablets are there. As shown in the figure above, one table in the ssb1 database is not healthy, you can use the following command to see which one is. @@ -287,11 +287,11 @@ Tablet state view mainly looks at the state of the tablet, as well as the state Among them `13402` is the corresponding DbId. ``` - +-----------------------+--------------------------+--------------------------+------------------+--------------------------------+-----------------------------+-----------------------+-------------------------+--------------------------+--------------------------+----------------------+---------------------------------+---------------------+-----------------+ + +-----------------------+--------------------------+--------------------------+------------- | ReplicaMissingTablets | VersionIncompleteTablets | ReplicaRelocatingTablets | RedundantTablets | ReplicaMissingInClusterTablets | ReplicaMissingForTagTablets | ForceRedundantTablets | ColocateMismatchTablets | ColocateRedundantTablets | NeedFurtherRepairTablets | UnrecoverableTablets | ReplicaCompactionTooSlowTablets | InconsistentTablets | OversizeTablets | - +-----------------------+--------------------------+--------------------------+------------------+--------------------------------+-----------------------------+-----------------------+-------------------------+--------------------------+--------------------------+----------------------+---------------------------------+---------------------+-----------------+ + +-----------------------+--------------------------+--------------------------+------------- | 14679 | | | | | | | | | | | | | | - +-----------------------+--------------------------+--------------------------+------------------+--------------------------------+-----------------------------+-----------------------+-------------------------+--------------------------+--------------------------+----------------------+---------------------------------+---------------------+-----------------+ + +-----------------------+--------------------------+--------------------------+------------- ``` The figure above shows the specific unhealthy Tablet ID (14679). Later we'll show you how to view the status of each copy of a specific Tablet. @@ -303,16 +303,16 @@ Tablet state view mainly looks at the state of the tablet, as well as the state `ADMIN SHOW REPLICA STATUS FROM tbl1 PARTITION (p1, p2) WHERE STATUS = "OK";` ``` - +----------+-----------+-----------+---------+-------------------+--------------------+------------------+------------+------------+-------+--------+--------+ + +----------+-----------+-----------+---------+-------------------+--------------------+ | TabletId | ReplicaId | BackendId | Version | LastFailedVersion | LastSuccessVersion | CommittedVersion | SchemaHash | VersionNum | IsBad | State | Status | - +----------+-----------+-----------+---------+-------------------+--------------------+------------------+------------+------------+-------+--------+--------+ + +----------+-----------+-----------+---------+-------------------+--------------------+ | 29502429 | 29502432 | 10006 | 2 | -1 | 2 | 1 | -1 | 2 | false | NORMAL | OK | | 29502429 | 36885996 | 10002 | 2 | -1 | -1 | 1 | -1 | 2 | false | NORMAL | OK | | 29502429 | 48100551 | 10007 | 2 | -1 | -1 | 1 | -1 | 2 | false | NORMAL | OK | | 29502433 | 29502434 | 10001 | 2 | -1 | 2 | 1 | -1 | 2 | false | NORMAL | OK | | 29502433 | 44900737 | 10004 | 2 | -1 | -1 | 1 | -1 | 2 | false | NORMAL | OK | | 29502433 | 48369135 | 10006 | 2 | -1 | -1 | 1 | -1 | 2 | false | NORMAL | OK | - +----------+-----------+-----------+---------+-------------------+--------------------+------------------+------------+------------+-------+--------+--------+ + +----------+-----------+-----------+---------+-------------------+--------------------+ ``` The status of all copies is shown here. Where `IsBad` is listed as `true`, the copy is damaged. The `Status` column displays other states. Specific status description, you can see help through `HELP ADMIN SHOW REPLICA STATUS`. @@ -322,13 +322,13 @@ Tablet state view mainly looks at the state of the tablet, as well as the state `SHOW TABLETS FROM tbl1;` ``` - +----------+-----------+-----------+------------+---------+-------------+-------------------+-----------------------+------------------+----------------------+---------------+----------+----------+--------+-------------------------+--------------+----------------------+--------------+----------------------+----------------------+----------------------+ + +----------+-----------+-----------+------------+---------+-------------+-------------------+ | TabletId | ReplicaId | BackendId | SchemaHash | Version | VersionHash | LstSuccessVersion | LstSuccessVersionHash | LstFailedVersion | LstFailedVersionHash | LstFailedTime | DataSize | RowCount | State | LstConsistencyCheckTime | CheckVersion | CheckVersionHash | VersionCount | PathHash | MetaUrl | CompactionStatus | - +----------+-----------+-----------+------------+---------+-------------+-------------------+-----------------------+------------------+----------------------+---------------+----------+----------+--------+-------------------------+--------------+----------------------+--------------+----------------------+----------------------+----------------------+ + +----------+-----------+-----------+------------+---------+-------------+-------------------+ | 29502429 | 29502432 | 10006 | 1421156361 | 2 | 0 | 2 | 0 | -1 | 0 | N/A | 784 | 0 | NORMAL | N/A | -1 | -1 | 2 | -5822326203532286804 | url | url | | 29502429 | 36885996 | 10002 | 1421156361 | 2 | 0 | -1 | 0 | -1 | 0 | N/A | 784 | 0 | NORMAL | N/A | -1 | -1 | 2 | -1441285706148429853 | url | url | | 29502429 | 48100551 | 10007 | 1421156361 | 2 | 0 | -1 | 0 | -1 | 0 | N/A | 784 | 0 | NORMAL | N/A | -1 | -1 | 2 | -4784691547051455525 | url | url | - +----------+-----------+-----------+------------+---------+-------------+-------------------+-----------------------+------------------+----------------------+---------------+----------+----------+--------+-------------------------+--------------+----------------------+--------------+----------------------+----------------------+----------------------+ + +----------+-----------+-----------+------------+---------+-------------+-------------------+ ``` The figure above shows some additional information, including copy size, number of rows, number of versions, where the data path is located. @@ -364,11 +364,11 @@ Tablet state view mainly looks at the state of the tablet, as well as the state `SHOW TABLET 29502553;` ``` - +------------------------+-----------+---------------+-----------+----------+----------+-------------+----------+--------+---------------------------------------------------------------------------+ + +------------------------+-----------+---------------+-----------+----------+----------+ | DbName | TableName | PartitionName | IndexName | DbId | TableId | PartitionId | IndexId | IsSync | DetailCmd | - +------------------------+-----------+---------------+-----------+----------+----------+-------------+----------+--------+---------------------------------------------------------------------------+ + +------------------------+-----------+---------------+-----------+----------+----------+ | default_cluster:test | test | test | test | 29502391 | 29502428 | 29502427 | 29502428 | true | SHOW PROC '/dbs/29502391/29502428/partitions/29502427/29502428/29502553'; | - +------------------------+-----------+---------------+-----------+----------+----------+-------------+----------+--------+---------------------------------------------------------------------------+ + +------------------------+-----------+---------------+-----------+----------+----------+ ``` The figure above shows the database, tables, partitions, roll-up tables and other information corresponding to this tablet. The user can copy the command in the `DetailCmd` command to continue executing: @@ -376,13 +376,13 @@ Tablet state view mainly looks at the state of the tablet, as well as the state `Show Proc'/DBS/29502391/29502428/Partitions/29502427/29502428/29502553;` ``` - +-----------+-----------+---------+-------------+-------------------+-----------------------+------------------+----------------------+---------------+------------+----------+----------+--------+-------+--------------+----------------------+ + +-----------+-----------+---------+-------------+-------------------+-----------------------+ | ReplicaId | BackendId | Version | VersionHash | LstSuccessVersion | LstSuccessVersionHash | LstFailedVersion | LstFailedVersionHash | LstFailedTime | SchemaHash | DataSize | RowCount | State | IsBad | VersionCount | PathHash | - +-----------+-----------+---------+-------------+-------------------+-----------------------+------------------+----------------------+---------------+------------+----------+----------+--------+-------+--------------+----------------------+ + +-----------+-----------+---------+-------------+-------------------+-----------------------+ | 43734060 | 10004 | 2 | 0 | -1 | 0 | -1 | 0 | N/A | -1 | 784 | 0 | NORMAL | false | 2 | -8566523878520798656 | | 29502555 | 10002 | 2 | 0 | 2 | 0 | -1 | 0 | N/A | -1 | 784 | 0 | NORMAL | false | 2 | 1885826196444191611 | | 39279319 | 10007 | 2 | 0 | -1 | 0 | -1 | 0 | N/A | -1 | 784 | 0 | NORMAL | false | 2 | 1656508631294397870 | - +-----------+-----------+---------+-------------+-------------------+-----------------------+------------------+----------------------+---------------+------------+----------+----------+--------+-------+--------------+----------------------+ + +-----------+-----------+---------+-------------+-------------------+-----------------------+ ``` The figure above shows all replicas of the corresponding Tablet. The content shown here is the same as `SHOW TABLETS FROM tbl1;`. But here you can clearly see the status of all copies of a specific Tablet. @@ -394,11 +394,11 @@ Tablet state view mainly looks at the state of the tablet, as well as the state `SHOW PROC '/cluster_balance/pending_tablets';` ``` - +----------+--------+-----------------+---------+----------+----------+-------+---------+--------+----------+---------+---------------------+---------------------+---------------------+----------+------+-------------+---------------+---------------------+------------+---------------------+--------+---------------------+-------------------------------+ + +----------+--------+-----------------+---------+----------+----------+-------+---------+ | TabletId | Type | Status | State | OrigPrio | DynmPrio | SrcBe | SrcPath | DestBe | DestPath | Timeout | Create | LstSched | LstVisit | Finished | Rate | FailedSched | FailedRunning | LstAdjPrio | VisibleVer | VisibleVerHash | CmtVer | CmtVerHash | ErrMsg | - +----------+--------+-----------------+---------+----------+----------+-------+---------+--------+----------+---------+---------------------+---------------------+---------------------+----------+------+-------------+---------------+---------------------+------------+---------------------+--------+---------------------+-------------------------------+ + +----------+--------+-----------------+---------+----------+----------+-------+---------+ | 4203036 | REPAIR | REPLICA_MISSING | PENDING | HIGH | LOW | -1 | -1 | -1 | -1 | 0 | 2019-02-21 15:00:20 | 2019-02-24 11:18:41 | 2019-02-24 11:18:41 | N/A | N/A | 2 | 0 | 2019-02-21 15:00:43 | 1 | 0 | 2 | 0 | unable to find source replica | - +----------+--------+-----------------+---------+----------+----------+-------+---------+--------+----------+---------+---------------------+---------------------+---------------------+----------+------+-------------+---------------+---------------------+------------+---------------------+--------+---------------------+-------------------------------+ + +----------+--------+-----------------+---------+----------+----------+-------+---------+ ``` The specific meanings of each column are as follows: @@ -461,9 +461,9 @@ Tablet state view mainly looks at the state of the tablet, as well as the state `SHOW PROC '/cluster_balance/cluster_load_stat/location_default/HDD';` ``` - +----------+-----------------+-----------+---------------+----------------+-------------+------------+----------+-----------+--------------------+-------+ + +----------+-----------------+-----------+---------------+----------------+-------------+ | BeId | Cluster | Available | UsedCapacity | Capacity | UsedPercent | ReplicaNum | CapCoeff | ReplCoeff | Score | Class | - +----------+-----------------+-----------+---------------+----------------+-------------+------------+----------+-----------+--------------------+-------+ + +----------+-----------------+-----------+---------------+----------------+-------------+ | 10003 | default_cluster | true | 3477875259079 | 19377459077121 | 17.948 | 493477 | 0.5 | 0.5 | 0.9284678149967587 | MID | | 10002 | default_cluster | true | 3607326225443 | 19377459077121 | 18.616 | 496928 | 0.5 | 0.5 | 0.948660871419998 | MID | | 10005 | default_cluster | true | 3523518578241 | 19377459077121 | 18.184 | 545331 | 0.5 | 0.5 | 0.9843539990641831 | MID | @@ -472,7 +472,7 @@ Tablet state view mainly looks at the state of the tablet, as well as the state | 10004 | default_cluster | true | 3506558163744 | 15501967261697 | 22.620 | 468957 | 0.5 | 0.5 | 1.0228319835582569 | MID | | 10007 | default_cluster | true | 4036460478905 | 19377459077121 | 20.831 | 551645 | 0.5 | 0.5 | 1.057279369420761 | MID | | 10000 | default_cluster | true | 4369719923760 | 19377459077121 | 22.551 | 547175 | 0.5 | 0.5 | 1.0964036415787461 | MID | - +----------+-----------------+-----------+---------------+----------------+-------------+------------+----------+-----------+--------------------+-------+ + +----------+-----------------+-----------+---------------+----------------+-------------+ ``` Some of these columns have the following meanings: @@ -491,15 +491,15 @@ Tablet state view mainly looks at the state of the tablet, as well as the state `SHOW PROC '/cluster_balance/cluster_load_stat/location_default/HDD/10001';` ``` - +------------------+------------------+---------------+---------------+---------+--------+----------------------+ + +------------------+------------------+---------------+---------------+---------+--------+ | RootPath | DataUsedCapacity | AvailCapacity | TotalCapacity | UsedPct | State | PathHash | - +------------------+------------------+---------------+---------------+---------+--------+----------------------+ + +------------------+------------------+---------------+---------------+---------+--------+ | /home/disk4/palo | 498.757 GB | 3.033 TB | 3.525 TB | 13.94 % | ONLINE | 4883406271918338267 | | /home/disk3/palo | 704.200 GB | 2.832 TB | 3.525 TB | 19.65 % | ONLINE | -5467083960906519443 | | /home/disk1/palo | 512.833 GB | 3.007 TB | 3.525 TB | 14.69 % | ONLINE | -7733211489989964053 | | /home/disk2/palo | 881.955 GB | 2.656 TB | 3.525 TB | 24.65 % | ONLINE | 4870995507205544622 | | /home/disk5/palo | 694.992 GB | 2.842 TB | 3.525 TB | 19.36 % | ONLINE | 1916696897889786739 | - +------------------+------------------+---------------+---------------+---------+--------+----------------------+ + +------------------+------------------+---------------+---------------+---------+--------+ ``` The disk usage of each data path on the specified BE is shown here. diff --git a/versioned_docs/version-1.2/admin-manual/multi-tenant.md b/versioned_docs/version-1.2/admin-manual/multi-tenant.md index 1d7fa3c5ed089..0af4fb4da0755 100644 --- a/versioned_docs/version-1.2/admin-manual/multi-tenant.md +++ b/versioned_docs/version-1.2/admin-manual/multi-tenant.md @@ -81,39 +81,39 @@ Node resource division refers to setting tags for BE nodes in a Doris cluster, a The following figure shows the current node division and data distribution: ``` - ┌────────────────────────────────────────────────────┐ + ┌----------------------------------------------------┐ │ │ - │ ┌──────────────────┐ ┌──────────────────┐ │ + │ ┌------------------┐ ┌------------------┐ │ │ │ host1 │ │ host2 │ │ - │ │ ┌─────────────┐ │ │ │ │ + │ │ ┌-------------┐ │ │ │ │ │ group_a │ │ replica1 │ │ │ │ │ - │ │ └─────────────┘ │ │ │ │ + │ │ └-------------┘ │ │ │ │ │ │ │ │ │ │ - │ └──────────────────┘ └──────────────────┘ │ + │ └------------------┘ └------------------┘ │ │ │ - ├────────────────────────────────────────────────────┤ - ├────────────────────────────────────────────────────┤ + ├----------------------------------------------------┤ + ├----------------------------------------------------┤ │ │ - │ ┌──────────────────┐ ┌──────────────────┐ │ + │ ┌------------------┐ ┌------------------┐ │ │ │ host3 │ │ host4 │ │ - │ │ │ │ ┌─────────────┐ │ │ + │ │ │ │ ┌-------------┐ │ │ │ group_b │ │ │ │ replica2 │ │ │ - │ │ │ │ └─────────────┘ │ │ + │ │ │ │ └-------------┘ │ │ │ │ │ │ │ │ - │ └──────────────────┘ └──────────────────┘ │ + │ └------------------┘ └------------------┘ │ │ │ - ├────────────────────────────────────────────────────┤ - ├────────────────────────────────────────────────────┤ + ├----------------------------------------------------┤ + ├----------------------------------------------------┤ │ │ - │ ┌──────────────────┐ ┌──────────────────┐ │ + │ ┌------------------┐ ┌------------------┐ │ │ │ host5 │ │ host6 │ │ - │ │ │ │ ┌─────────────┐ │ │ + │ │ │ │ ┌-------------┐ │ │ │ group_c │ │ │ │ replica3 │ │ │ - │ │ │ │ └─────────────┘ │ │ + │ │ │ │ └-------------┘ │ │ │ │ │ │ │ │ - │ └──────────────────┘ └──────────────────┘ │ + │ └------------------┘ └------------------┘ │ │ │ - └────────────────────────────────────────────────────┘ + └----------------------------------------------------┘ ``` 3. Use different resource groups for data query @@ -129,7 +129,7 @@ Node resource division refers to setting tags for BE nodes in a Doris cluster, a ``` :::tip - It should be noted that after each modification of the ```resource_tags.location``` property, the user needs to re-establish the connection for the changes to take effect. + It should be noted that after each modification of the `resource_tags.location` property, the user needs to re-establish the connection for the changes to take effect. ::: After the setting is complete, when user1 initiates a query on the UserTable table, it will only access the data copy on the nodes in the `group_a` resource group, and the query will only use the node computing resources in the `group_a` resource group. The query of user3 can use copies and computing resources in any resource group. diff --git a/versioned_docs/version-1.2/admin-manual/privilege-ldap/user-privilege.md b/versioned_docs/version-1.2/admin-manual/privilege-ldap/user-privilege.md index a034c3870fc14..5464f1450d626 100644 --- a/versioned_docs/version-1.2/admin-manual/privilege-ldap/user-privilege.md +++ b/versioned_docs/version-1.2/admin-manual/privilege-ldap/user-privilege.md @@ -61,24 +61,24 @@ When a user and a role are disassociated, the user automatically loses all permi When the role's permissions are added or deleted, the user's permissions will also change. ``` -┌────────┐ ┌────────┐ ┌────────┐ -│ user1 ├────┬───► role1 ├────┬────► priv1 │ -└────────┘ │ └────────┘ │ └────────┘ +┌--------┐ ┌--------┐ ┌--------┐ +│ user1 ├----┬---► role1 ├----┬----► priv1 │ +└--------┘ │ └--------┘ │ └--------┘ │ │ │ │ - │ ┌────────┐ │ - │ │ role2 ├────┤ -┌────────┐ │ └────────┘ │ ┌────────┐ -│ user2 ├────┘ │ ┌─► priv2 │ -└────────┘ │ │ └────────┘ - ┌────────┐ │ │ - ┌──────► role3 ├────┘ │ - │ └────────┘ │ + │ ┌--------┐ │ + │ │ role2 ├----┤ +┌--------┐ │ └--------┘ │ ┌--------┐ +│ user2 ├----┘ │ ┌─► priv2 │ +└--------┘ │ │ └--------┘ + ┌--------┐ │ │ + ┌------► role3 ├----┘ │ + │ └--------┘ │ │ │ │ │ -┌────────┐ │ ┌────────┐ │ ┌────────┐ -│ userN ├─┴──────► roleN ├───────┴─► privN │ -└────────┘ └────────┘ └────────┘ +┌--------┐ │ ┌--------┐ │ ┌--------┐ +│ userN ├-┴------► roleN ├-------┴-► privN │ +└--------┘ └--------┘ └--------┘ ``` As shown in the figure above: diff --git a/versioned_docs/version-1.2/admin-manual/query-profile.md b/versioned_docs/version-1.2/admin-manual/query-profile.md index ac5f631e011ac..c4e50238c29c6 100644 --- a/versioned_docs/version-1.2/admin-manual/query-profile.md +++ b/versioned_docs/version-1.2/admin-manual/query-profile.md @@ -54,6 +54,7 @@ mysql> set enable_profile=true; ``` After executing the corresponding SQL statement(`is_report_success` in old versions), we can see the report information of the corresponding SQL statement on the FE web page like the picture below. + ![image.png](/images/running_profile.png) The latest **100 statements** executed will be listed here. We can view detailed statistics of RunningProfile. diff --git a/versioned_docs/version-1.2/admin-manual/system-table/rowsets.md b/versioned_docs/version-1.2/admin-manual/system-table/rowsets.md index 2ad7c7a5c6eed..f54b1af6c095c 100644 --- a/versioned_docs/version-1.2/admin-manual/system-table/rowsets.md +++ b/versioned_docs/version-1.2/admin-manual/system-table/rowsets.md @@ -59,9 +59,9 @@ MySQL [(none)]> desc information_schema.rowsets; ```sql select * from information_schema.rowsets where BACKEND_ID = 10004 limit 10; -+------------+--------------------------------------------------+-----------+-----------------+--------+--------------+---------------+-------------+-----------------+----------------+---------------+------------------------+------------------------+ ++------------+--------------------------------------------------+-----------+-----------------+ | BACKEND_ID | ROWSET_ID | TABLET_ID | ROWSET_NUM_ROWS | TXN_ID | NUM_SEGMENTS | START_VERSION | END_VERSION | INDEX_DISK_SIZE | DATA_DISK_SIZE | CREATION_TIME | OLDEST_WRITE_TIMESTAMP | NEWEST_WRITE_TIMESTAMP | -+------------+--------------------------------------------------+-----------+-----------------+--------+--------------+---------------+-------------+-----------------+----------------+---------------+------------------------+------------------------+ ++------------+--------------------------------------------------+-----------+-----------------+ | 10004 | 02000000000000994847fbd41a42297d7c7a57d3bcb46f8c | 10771 | 66850 | 6 | 1 | 3 | 3 | 2894 | 688855 | 1659964582 | 1659964581 | 1659964581 | | 10004 | 020000000000008d4847fbd41a42297d7c7a57d3bcb46f8c | 10771 | 66850 | 2 | 1 | 2 | 2 | 2894 | 688855 | 1659964575 | 1659964574 | 1659964574 | | 10004 | 02000000000000894847fbd41a42297d7c7a57d3bcb46f8c | 10771 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1659964567 | 1659964567 | 1659964567 | @@ -72,11 +72,9 @@ select * from information_schema.rowsets where BACKEND_ID = 10004 limit 10; | 10004 | 020000000000008c4847fbd41a42297d7c7a57d3bcb46f8c | 10757 | 66413 | 2 | 1 | 2 | 2 | 2893 | 685381 | 1659964575 | 1659964574 | 1659964574 | | 10004 | 02000000000000874847fbd41a42297d7c7a57d3bcb46f8c | 10757 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1659964567 | 1659964567 | 1659964567 | | 10004 | 020000000000009c4847fbd41a42297d7c7a57d3bcb46f8c | 10739 | 1698 | 8 | 1 | 3 | 3 | 454 | 86126 | 1659964582 | 1659964582 | 1659964582 | -+------------+--------------------------------------------------+-----------+-----------------+--------+--------------+---------------+-------------+-----------------+----------------+---------------+------------------------+------------------------+ ++------------+--------------------------------------------------+-----------+-----------------+ ``` ### KeyWords - rowsets, information_schema - -### Best Practice \ No newline at end of file + rowsets, information_schema \ No newline at end of file diff --git a/versioned_docs/version-1.2/advanced/best-practice/import-analysis.md b/versioned_docs/version-1.2/advanced/best-practice/import-analysis.md index 9f55a33cdeab2..b6dee2cef81f7 100644 --- a/versioned_docs/version-1.2/advanced/best-practice/import-analysis.md +++ b/versioned_docs/version-1.2/advanced/best-practice/import-analysis.md @@ -38,13 +38,13 @@ If you don't know much about Doris' query plan tree, please read the previous ar The execution process of a [Broker Load](../../data-operate/import/import-way/broker-load-manual.md) request is also based on Doris' query framework. A Broker Load job will be split into multiple subtasks based on the number of DATA INFILE clauses in the import request. Each subtask can be regarded as an independent import execution plan. An import plan consists of only one Fragment, which is composed as follows: ```sql -┌────────────────┐ +┌-------------┐ │OlapTableSink│ -└────────────────┘ +└-------------┘ │ -┌────────────────┐ +┌--------------┐ │BrokerScanNode│ -└────────────────┘ +└--------------┘ ``` BrokerScanNode is mainly responsible for reading the source data and sending it to OlapTableSink, and OlapTableSink is responsible for sending data to the corresponding node according to the partition and bucketing rules, and the corresponding node is responsible for the actual data writing. @@ -159,42 +159,42 @@ This shows the time-consuming of four instances of the subtask 980014623046410a- **************************** 1. row ******************** ****** Instance: ┌-----------------------------------------┐ - │[-1: OlapTableSink] │ - │(Active: 2m17s, non-child: 70.91) │ - │ - Counters: │ - │ - CloseWaitTime: 1m53s │ - │ - ConvertBatchTime: 0ns │ - │ - MaxAddBatchExecTime: 1m46s │ - │ - NonBlockingSendTime: 3m11s │ - │ - NumberBatchAdded: 782 │ - │ - NumberNodeChannels: 1 │ - │ - OpenTime: 743.822us │ - │ - RowsFiltered: 0 │ - │ - RowsRead: 1.599729M (1599729) │ - │ - RowsReturned: 1.599729M (1599729)│ - │ - SendDataTime: 11s761ms │ - │ - TotalAddBatchExecTime: 1m46s │ - │ - ValidateDataTime: 9s802ms │ + │[-1: OlapTableSink] │ + │(Active: 2m17s, non-child: 70.91) │ + │ - Counters: │ + │ - CloseWaitTime: 1m53s │ + │ - ConvertBatchTime: 0ns │ + │ - MaxAddBatchExecTime: 1m46s │ + │ - NonBlockingSendTime: 3m11s │ + │ - NumberBatchAdded: 782 │ + │ - NumberNodeChannels: 1 │ + │ - OpenTime: 743.822us │ + │ - RowsFiltered: 0 │ + │ - RowsRead: 1.599729M (1599729) │ + │ - RowsReturned: 1.599729M (1599729) │ + │ - SendDataTime: 11s761ms │ + │ - TotalAddBatchExecTime: 1m46s │ + │ - ValidateDataTime: 9s802ms │ └-----------------------------------------┘ │ - ┌------------------------------------------------- ----┐ - │[0: BROKER_SCAN_NODE] │ - │(Active: 56s537ms, non-child: 29.06) │ - │ - Counters: │ - │ - BytesDecompressed: 0.00 │ - │ - BytesRead: 5.77 GB │ - │ - DecompressTime: 0ns │ - │ - FileReadTime: 34s263ms │ - │ - MaterializeTupleTime(*): 45s54ms │ - │ - NumDiskAccess: 0 │ - │ - PeakMemoryUsage: 33.03 MB │ - │ - RowsRead: 1.599729M (1599729) │ - │ - RowsReturned: 1.599729M (1599729) │ - │ - RowsReturnedRate: 28.295K /sec │ - │ - TotalRawReadTime(*): 1m20s │ - │ - TotalReadThroughput: 30.39858627319336 MB/sec│ - │ - WaitScannerTime: 56s528ms │ - └------------------------------------------------- ----┘ + ┌------------------------------------------------------┐ + │[0: BROKER_SCAN_NODE] │ + │(Active: 56s537ms, non-child: 29.06) │ + │ - Counters: │ + │ - BytesDecompressed: 0.00 │ + │ - BytesRead: 5.77 GB │ + │ - DecompressTime: 0ns │ + │ - FileReadTime: 34s263ms │ + │ - MaterializeTupleTime(*): 45s54ms │ + │ - NumDiskAccess: 0 │ + │ - PeakMemoryUsage: 33.03 MB │ + │ - RowsRead: 1.599729M (1599729) │ + │ - RowsReturned: 1.599729M (1599729) │ + │ - RowsReturnedRate: 28.295K /sec │ + │ - TotalRawReadTime(*): 1m20s │ + │ - TotalReadThroughput: 30.39858627319336 MB/sec │ + │ - WaitScannerTime: 56s528ms │ + └------------------------------------------------------┘ ``` The figure above shows the specific profiles of each operator of Instance 980014623046410a-af5d36f23381017f in subtask 980014623046410a-88e260f0c43031f5. diff --git a/versioned_docs/version-1.2/advanced/best-practice/query-analysis.md b/versioned_docs/version-1.2/advanced/best-practice/query-analysis.md index 06ef0da19f77b..8d2243f76ba94 100644 --- a/versioned_docs/version-1.2/advanced/best-practice/query-analysis.md +++ b/versioned_docs/version-1.2/advanced/best-practice/query-analysis.md @@ -38,55 +38,55 @@ For example, if the user specifies a Join operator, the query planner needs to d Doris' query planning process is to first convert an SQL statement into a single-machine execution plan tree. ```text - ┌────┐ + ┌----┐ │Sort│ - └────┘ + └----┘ │ - ┌──────────────┐ - │Aggregation│ - └──────────────┘ + ┌--------------┐ + │Aggregation │ + └--------------┘ │ - ┌────┐ + ┌----┐ │Join│ - └────┘ - ┌────┴────┐ -┌──────┐ ┌──────┐ + └----┘ + ┌---┴---┐ +┌------┐ ┌------┐ │Scan-1│ │Scan-2│ -└──────┘ └──────┘ +└------┘ └------┘ ``` After that, the query planner will convert the single-machine query plan into a distributed query plan according to the specific operator execution mode and the specific distribution of data. The distributed query plan is composed of multiple fragments, each fragment is responsible for a part of the query plan, and the data is transmitted between the fragments through the ExchangeNode operator. ```text - ┌────┐ + ┌----┐ │Sort│ - │F1 │ - └────┘ + │F1 │ + └----┘ │ - ┌──────────────┐ - │Aggregation│ - │F1 │ - └──────────────┘ + ┌--------------┐ + │Aggregation │ + │F1 │ + └--------------┘ │ - ┌────┐ + ┌----┐ │Join│ - │F1 │ - └────┘ - ┌──────┴────┐ -┌──────┐ ┌────────────┐ + │F1 │ + └----┘ + ┌-----┴-----┐ +┌------┐ ┌------------┐ │Scan-1│ │ExchangeNode│ -│F1 │ │F1 │ -└──────┘ └────────────┘ +│F1 │ │F1 │ +└------┘ └------------┘ │ - ┌────────────────┐ - │DataStreamDink│ - │F2 │ - └────────────────┘ + ┌----------------┐ + │DataStreamDink │ + │F2 │ + └----------------┘ │ - ┌──────┐ + ┌------┐ │Scan-2│ - │F2 │ - └──────┘ + │F2 │ + └------┘ ``` As shown above, we divided the stand-alone plan into two Fragments: F1 and F2. Data is transmitted between two Fragments through an ExchangeNode. @@ -105,83 +105,83 @@ The first command displays a query plan graphically. This command can more intui ```sql mysql> explain graph select tbl1.k1, sum(tbl1.k2) from tbl1 join tbl2 on tbl1.k1 = tbl2.k1 group by tbl1.k1 order by tbl1.k1; -+---------------------------------------------------------------------------------------------------------------------------------+ -| Explain String | -+---------------------------------------------------------------------------------------------------------------------------------+ -| | -| ┌───────────────┐ | -| │[9: ResultSink]│ | -| │[Fragment: 4] │ | -| │RESULT SINK │ | -| └───────────────┘ | -| │ | -| ┌─────────────────────┐ | -| │[9: MERGING-EXCHANGE]│ | -| │[Fragment: 4] │ | -| └─────────────────────┘ | -| │ | -| ┌───────────────────┐ | -| │[9: DataStreamSink]│ | -| │[Fragment: 3] │ | -| │STREAM DATA SINK │ | -| │ EXCHANGE ID: 09 │ | -| │ UNPARTITIONED │ | -| └───────────────────┘ | -| │ | -| ┌─────────────┐ | -| │[4: TOP-N] │ | -| │[Fragment: 3]│ | -| └─────────────┘ | -| │ | -| ┌───────────────────────────────┐ | -| │[8: AGGREGATE (merge finalize)]│ | -| │[Fragment: 3] │ | -| └───────────────────────────────┘ | -| │ | -| ┌─────────────┐ | -| │[7: EXCHANGE]│ | -| │[Fragment: 3]│ | -| └─────────────┘ | -| │ | -| ┌───────────────────┐ | -| │[7: DataStreamSink]│ | -| │[Fragment: 2] │ | -| │STREAM DATA SINK │ | -| │ EXCHANGE ID: 07 │ | -| │ HASH_PARTITIONED │ | -| └───────────────────┘ | -| │ | -| ┌─────────────────────────────────┐ | -| │[3: AGGREGATE (update serialize)]│ | -| │[Fragment: 2] │ | -| │STREAMING │ | -| └─────────────────────────────────┘ | -| │ | -| ┌─────────────────────────────────┐ | -| │[2: HASH JOIN] │ | -| │[Fragment: 2] │ | -| │join op: INNER JOIN (PARTITIONED)│ | -| └─────────────────────────────────┘ | -| ┌──────────┴──────────┐ | -| ┌─────────────┐ ┌─────────────┐ | -| │[5: EXCHANGE]│ │[6: EXCHANGE]│ | -| │[Fragment: 2]│ │[Fragment: 2]│ | -| └─────────────┘ └─────────────┘ | -| │ │ | -| ┌───────────────────┐ ┌───────────────────┐ | -| │[5: DataStreamSink]│ │[6: DataStreamSink]│ | -| │[Fragment: 0] │ │[Fragment: 1] │ | -| │STREAM DATA SINK │ │STREAM DATA SINK │ | -| │ EXCHANGE ID: 05 │ │ EXCHANGE ID: 06 │ | -| │ HASH_PARTITIONED │ │ HASH_PARTITIONED │ | -| └───────────────────┘ └───────────────────┘ | -| │ │ | -| ┌─────────────────┐ ┌─────────────────┐ | -| │[0: OlapScanNode]│ │[1: OlapScanNode]│ | -| │[Fragment: 0] │ │[Fragment: 1] │ | -| │TABLE: tbl1 │ │TABLE: tbl2 │ | -| └─────────────────┘ └─────────────────┘ | -+---------------------------------------------------------------------------------------------------------------------------------+ ++--------------------------------------------------+ +| Explain String | ++--------------------------------------------------+ +| | +| ┌---------------┐ | +| │[9: ResultSink]│ | +| │[Fragment: 4] │ | +| │RESULT SINK │ | +| └---------------┘ | +| │ | +| ┌---------------------┐ | +| │[9: MERGING-EXCHANGE]│ | +| │[Fragment: 4] │ | +| └---------------------┘ | +| │ | +| ┌-------------------┐ | +| │[9: DataStreamSink]│ | +| │[Fragment: 3] │ | +| │STREAM DATA SINK │ | +| │ EXCHANGE ID: 09 │ | +| │ UNPARTITIONED │ | +| └-------------------┘ | +| │ | +| ┌-------------┐ | +| │[4: TOP-N] │ | +| │[Fragment: 3]│ | +| └-------------┘ | +| │ | +| ┌-------------------------------┐ | +| │[8: AGGREGATE (merge finalize)]│ | +| │[Fragment: 3] │ | +| └-------------------------------┘ | +| │ | +| ┌-------------┐ | +| │[7: EXCHANGE]│ | +| │[Fragment: 3]│ | +| └-------------┘ | +| │ | +| ┌-------------------┐ | +| │[7: DataStreamSink]│ | +| │[Fragment: 2] │ | +| │STREAM DATA SINK │ | +| │ EXCHANGE ID: 07 │ | +| │ HASH_PARTITIONED │ | +| └-------------------┘ | +| │ | +| ┌---------------------------------┐ | +| │[3: AGGREGATE (update serialize)]│ | +| │[Fragment: 2] │ | +| │STREAMING │ | +| └---------------------------------┘ | +| │ | +| ┌---------------------------------┐ | +| │[2: HASH JOIN] │ | +| │[Fragment: 2] │ | +| │join op: INNER JOIN (PARTITIONED)│ | +| └---------------------------------┘ | +| ┌----------┴----------┐ | +| ┌-------------┐ ┌-------------┐ | +| │[5: EXCHANGE]│ │[6: EXCHANGE]│ | +| │[Fragment: 2]│ │[Fragment: 2]│ | +| └-------------┘ └-------------┘ | +| │ │ | +| ┌-------------------┐ ┌-------------------┐ | +| │[5: DataStreamSink]│ │[6: DataStreamSink]│ | +| │[Fragment: 0] │ │[Fragment: 1] │ | +| │STREAM DATA SINK │ │STREAM DATA SINK │ | +| │ EXCHANGE ID: 05 │ │ EXCHANGE ID: 06 │ | +| │ HASH_PARTITIONED │ │ HASH_PARTITIONED │ | +| └-------------------┘ └-------------------┘ | +| │ │ | +| ┌-----------------┐ ┌-----------------┐ | +| │[0: OlapScanNode]│ │[1: OlapScanNode]│ | +| │[Fragment: 0] │ │[Fragment: 1] │ | +| │TABLE: tbl1 │ │TABLE: tbl2 │ | +| └-----------------┘ └-----------------┘ | ++--------------------------------------------------+ ``` As can be seen from the figure, the query plan tree is divided into 5 fragments: 0, 1, 2, 3, and 4. For example, `[Fragment: 0]` on the `OlapScanNode` node indicates that this node belongs to Fragment 0. Data is transferred between each Fragment through DataStreamSink and ExchangeNode. @@ -290,172 +290,174 @@ mysql> explain select tbl1.k1, sum(tbl1.k2) from tbl1 join tbl2 on tbl1.k1 = tbl The third command `explain verbose select ...;` gives you more details than the second command. + ```sql mysql> explain verbose select tbl1.k1, sum(tbl1.k2) from tbl1 join tbl2 on tbl1.k1 = tbl2.k1 group by tbl1.k1 order by tbl1.k1; -+---------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Explain String | -+---------------------------------------------------------------------------------------------------------------------------------------------------------+ -| PLAN FRAGMENT 0 | -| OUTPUT EXPRS: `tbl1`.`k1` | sum(`tbl1`.`k2`) | -| PARTITION: UNPARTITIONED | -| | -| VRESULT SINK | -| | -| 6:VMERGING-EXCHANGE | -| limit: 65535 | -| tuple ids: 3 | -| | -| PLAN FRAGMENT 1 | -| | -| PARTITION: HASH_PARTITIONED: `default_cluster:test`.`tbl1`.`k2` | -| | -| STREAM DATA SINK | -| EXCHANGE ID: 06 | -| UNPARTITIONED | -| | -| 4:VTOP-N | -| | order by: `tbl1`.`k1` ASC | -| | offset: 0 | -| | limit: 65535 | -| | tuple ids: 3 | -| | | -| 3:VAGGREGATE (update finalize) | -| | output: sum() | -| | group by: | -| | cardinality=-1 | -| | tuple ids: 2 | -| | | -| 2:VHASH JOIN | -| | join op: INNER JOIN(BROADCAST)[Tables are not in the same group] | -| | equal join conjunct: CAST(`tbl1`.`k1` AS DATETIME) = `tbl2`.`k1` | -| | runtime filters: RF000[in_or_bloom] <- `tbl2`.`k1` | -| | cardinality=0 | -| | vec output tuple id: 4 | tuple ids: 0 1 | -| | | -| |----5:VEXCHANGE | -| | tuple ids: 1 | -| | | -| 0:VOlapScanNode | -| TABLE: tbl1(null), PREAGGREGATION: OFF. Reason: the type of agg on StorageEngine's Key column should only be MAX or MIN.agg expr: sum(`tbl1`.`k2`) | -| runtime filters: RF000[in_or_bloom] -> CAST(`tbl1`.`k1` AS DATETIME) | -| partitions=0/1, tablets=0/0, tabletList= | -| cardinality=0, avgRowSize=20.0, numNodes=1 | -| tuple ids: 0 | -| | -| PLAN FRAGMENT 2 | -| | -| PARTITION: HASH_PARTITIONED: `default_cluster:test`.`tbl2`.`k2` | -| | -| STREAM DATA SINK | -| EXCHANGE ID: 05 | -| UNPARTITIONED | -| | -| 1:VOlapScanNode | -| TABLE: tbl2(null), PREAGGREGATION: OFF. Reason: null | -| partitions=0/1, tablets=0/0, tabletList= | -| cardinality=0, avgRowSize=16.0, numNodes=1 | -| tuple ids: 1 | -| | -| Tuples: | -| TupleDescriptor{id=0, tbl=tbl1, byteSize=32, materialized=true} | -| SlotDescriptor{id=0, col=k1, type=DATE} | -| parent=0 | -| materialized=true | -| byteSize=16 | -| byteOffset=16 | -| nullIndicatorByte=0 | -| nullIndicatorBit=-1 | -| slotIdx=1 | -| | -| SlotDescriptor{id=2, col=k2, type=INT} | -| parent=0 | -| materialized=true | -| byteSize=4 | -| byteOffset=0 | -| nullIndicatorByte=0 | -| nullIndicatorBit=-1 | -| slotIdx=0 | -| | -| | -| TupleDescriptor{id=1, tbl=tbl2, byteSize=16, materialized=true} | -| SlotDescriptor{id=1, col=k1, type=DATETIME} | -| parent=1 | -| materialized=true | -| byteSize=16 | -| byteOffset=0 | -| nullIndicatorByte=0 | -| nullIndicatorBit=-1 | -| slotIdx=0 | -| | -| | -| TupleDescriptor{id=2, tbl=null, byteSize=32, materialized=true} | -| SlotDescriptor{id=3, col=null, type=DATE} | -| parent=2 | -| materialized=true | -| byteSize=16 | -| byteOffset=16 | -| nullIndicatorByte=0 | -| nullIndicatorBit=-1 | -| slotIdx=1 | -| | -| SlotDescriptor{id=4, col=null, type=BIGINT} | -| parent=2 | -| materialized=true | -| byteSize=8 | -| byteOffset=0 | -| nullIndicatorByte=0 | -| nullIndicatorBit=-1 | -| slotIdx=0 | -| | -| | -| TupleDescriptor{id=3, tbl=null, byteSize=32, materialized=true} | -| SlotDescriptor{id=5, col=null, type=DATE} | -| parent=3 | -| materialized=true | -| byteSize=16 | -| byteOffset=16 | -| nullIndicatorByte=0 | -| nullIndicatorBit=-1 | -| slotIdx=1 | -| | -| SlotDescriptor{id=6, col=null, type=BIGINT} | -| parent=3 | -| materialized=true | -| byteSize=8 | -| byteOffset=0 | -| nullIndicatorByte=0 | -| nullIndicatorBit=-1 | -| slotIdx=0 | -| | -| | -| TupleDescriptor{id=4, tbl=null, byteSize=48, materialized=true} | -| SlotDescriptor{id=7, col=k1, type=DATE} | -| parent=4 | -| materialized=true | -| byteSize=16 | -| byteOffset=16 | -| nullIndicatorByte=0 | -| nullIndicatorBit=-1 | -| slotIdx=1 | -| | -| SlotDescriptor{id=8, col=k2, type=INT} | -| parent=4 | -| materialized=true | -| byteSize=4 | -| byteOffset=0 | -| nullIndicatorByte=0 | -| nullIndicatorBit=-1 | -| slotIdx=0 | -| | -| SlotDescriptor{id=9, col=k1, type=DATETIME} | -| parent=4 | -| materialized=true | -| byteSize=16 | -| byteOffset=32 | -| nullIndicatorByte=0 | -| nullIndicatorBit=-1 | -| slotIdx=2 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------+ ++-----------------------------------------------------------------------------------+ +| Explain String | ++-----------------------------------------------------------------------------------+ +| PLAN FRAGMENT 0 | +| OUTPUT EXPRS: `tbl1`.`k1` | sum(`tbl1`.`k2`) | +| PARTITION: UNPARTITIONED | +| | +| VRESULT SINK | +| | +| 6:VMERGING-EXCHANGE | +| limit: 65535 | +| tuple ids: 3 | +| | +| PLAN FRAGMENT 1 | +| | +| PARTITION: HASH_PARTITIONED: `default_cluster:test`.`tbl1`.`k2` | +| | +| STREAM DATA SINK | +| EXCHANGE ID: 06 | +| UNPARTITIONED | +| | +| 4:VTOP-N | +| | order by: `tbl1`.`k1` ASC | +| | offset: 0 | +| | limit: 65535 | +| | tuple ids: 3 | +| | | +| 3:VAGGREGATE (update finalize) | +| | output: sum() | +| | group by: | +| | cardinality=-1 | +| | tuple ids: 2 | +| | | +| 2:VHASH JOIN | +| | join op: INNER JOIN(BROADCAST)[Tables are not in the same group] | +| | equal join conjunct: CAST(`tbl1`.`k1` AS DATETIME) = `tbl2`.`k1` | +| | runtime filters: RF000[in_or_bloom] <- `tbl2`.`k1` | +| | cardinality=0 | +| | vec output tuple id: 4 | tuple ids: 0 1 | +| | | +| |----5:VEXCHANGE | +| | tuple ids: 1 | +| | | +| 0:VOlapScanNode | +| TABLE: tbl1(null), PREAGGREGATION: OFF. Reason: the type of agg on | +| StorageEngine's Key column should only be MAX or MIN.agg expr: sum(`tbl1`.`k2`) | +| runtime filters: RF000[in_or_bloom] -> CAST(`tbl1`.`k1` AS DATETIME) | +| partitions=0/1, tablets=0/0, tabletList= | +| cardinality=0, avgRowSize=20.0, numNodes=1 | +| tuple ids: 0 | +| | +| PLAN FRAGMENT 2 | +| | +| PARTITION: HASH_PARTITIONED: `default_cluster:test`.`tbl2`.`k2` | +| | +| STREAM DATA SINK | +| EXCHANGE ID: 05 | +| UNPARTITIONED | +| | +| 1:VOlapScanNode | +| TABLE: tbl2(null), PREAGGREGATION: OFF. Reason: null | +| partitions=0/1, tablets=0/0, tabletList= | +| cardinality=0, avgRowSize=16.0, numNodes=1 | +| tuple ids: 1 | +| | +| Tuples: | +| TupleDescriptor{id=0, tbl=tbl1, byteSize=32, materialized=true} | +| SlotDescriptor{id=0, col=k1, type=DATE} | +| parent=0 | +| materialized=true | +| byteSize=16 | +| byteOffset=16 | +| nullIndicatorByte=0 | +| nullIndicatorBit=-1 | +| slotIdx=1 | +| | +| SlotDescriptor{id=2, col=k2, type=INT} | +| parent=0 | +| materialized=true | +| byteSize=4 | +| byteOffset=0 | +| nullIndicatorByte=0 | +| nullIndicatorBit=-1 | +| slotIdx=0 | +| | +| | +| TupleDescriptor{id=1, tbl=tbl2, byteSize=16, materialized=true} | +| SlotDescriptor{id=1, col=k1, type=DATETIME} | +| parent=1 | +| materialized=true | +| byteSize=16 | +| byteOffset=0 | +| nullIndicatorByte=0 | +| nullIndicatorBit=-1 | +| slotIdx=0 | +| | +| | +| TupleDescriptor{id=2, tbl=null, byteSize=32, materialized=true} | +| SlotDescriptor{id=3, col=null, type=DATE} | +| parent=2 | +| materialized=true | +| byteSize=16 | +| byteOffset=16 | +| nullIndicatorByte=0 | +| nullIndicatorBit=-1 | +| slotIdx=1 | +| | +| SlotDescriptor{id=4, col=null, type=BIGINT} | +| parent=2 | +| materialized=true | +| byteSize=8 | +| byteOffset=0 | +| nullIndicatorByte=0 | +| nullIndicatorBit=-1 | +| slotIdx=0 | +| | +| | +| TupleDescriptor{id=3, tbl=null, byteSize=32, materialized=true} | +| SlotDescriptor{id=5, col=null, type=DATE} | +| parent=3 | +| materialized=true | +| byteSize=16 | +| byteOffset=16 | +| nullIndicatorByte=0 | +| nullIndicatorBit=-1 | +| slotIdx=1 | +| | +| SlotDescriptor{id=6, col=null, type=BIGINT} | +| parent=3 | +| materialized=true | +| byteSize=8 | +| byteOffset=0 | +| nullIndicatorByte=0 | +| nullIndicatorBit=-1 | +| slotIdx=0 | +| | +| | +| TupleDescriptor{id=4, tbl=null, byteSize=48, materialized=true} | +| SlotDescriptor{id=7, col=k1, type=DATE} | +| parent=4 | +| materialized=true | +| byteSize=16 | +| byteOffset=16 | +| nullIndicatorByte=0 | +| nullIndicatorBit=-1 | +| slotIdx=1 | +| | +| SlotDescriptor{id=8, col=k2, type=INT} | +| parent=4 | +| materialized=true | +| byteSize=4 | +| byteOffset=0 | +| nullIndicatorByte=0 | +| nullIndicatorBit=-1 | +| slotIdx=0 | +| | +| SlotDescriptor{id=9, col=k1, type=DATETIME} | +| parent=4 | +| materialized=true | +| byteSize=16 | +| byteOffset=32 | +| nullIndicatorByte=0 | +| nullIndicatorBit=-1 | +| slotIdx=2 | ++-----------------------------------------------------------------------------------+ 160 rows in set (0.00 sec) ``` @@ -498,79 +500,79 @@ Viewing a Profile is divided into 3 steps: mysql> show query profile "/c257c52f93e149ee-ace8ac14e8c9fef9"\G *************************** 1. row *************************** Fragments: - ┌──────────────────────┐ + ┌----------------------┐ │[-1: DataBufferSender]│ │Fragment: 0 │ │MaxActiveTime: 6.626ms│ - └──────────────────────┘ + └----------------------┘ │ - ┌──────────────────┐ + ┌------------------┐ │[9: EXCHANGE_NODE]│ │Fragment: 0 │ - └──────────────────┘ + └------------------┘ │ - ┌──────────────────────┐ + ┌----------------------┐ │[9: DataStreamSender] │ │Fragment: 1 │ │MaxActiveTime: 5.449ms│ - └──────────────────────┘ + └----------------------┘ │ - ┌──────────────┐ + ┌--------------┐ │[4: SORT_NODE]│ │Fragment: 1 │ - └──────────────┘ + └--------------┘ ┌┘ - ┌─────────────────────┐ + ┌---------------------┐ │[8: AGGREGATION_NODE]│ │Fragment: 1 │ - └─────────────────────┘ + └---------------------┘ └┐ - ┌──────────────────┐ + ┌------------------┐ │[7: EXCHANGE_NODE]│ │Fragment: 1 │ - └──────────────────┘ + └------------------┘ │ - ┌──────────────────────┐ + ┌----------------------┐ │[7: DataStreamSender] │ │Fragment: 2 │ │MaxActiveTime: 3.505ms│ - └──────────────────────┘ + └----------------------┘ ┌┘ - ┌─────────────────────┐ + ┌---------------------┐ │[3: AGGREGATION_NODE]│ │Fragment: 2 │ - └─────────────────────┘ + └---------------------┘ │ - ┌───────────────────┐ + ┌-------------------┐ │[2: HASH_JOIN_NODE]│ │Fragment: 2 │ - └───────────────────┘ - ┌────────────┴────────────┐ - ┌──────────────────┐ ┌──────────────────┐ + └-------------------┘ + ┌------------┴------------┐ + ┌------------------┐ ┌------------------┐ │[5: EXCHANGE_NODE]│ │[6: EXCHANGE_NODE]│ │Fragment: 2 │ │Fragment: 2 │ - └──────────────────┘ └──────────────────┘ + └------------------┘ └------------------┘ │ │ - ┌─────────────────────┐ ┌────────────────────────┐ + ┌---------------------┐ ┌------------------------┐ │[5: DataStreamSender]│ │[6: DataStreamSender] │ │Fragment: 4 │ │Fragment: 3 │ │MaxActiveTime: 1.87ms│ │MaxActiveTime: 636.767us│ - └─────────────────────┘ └────────────────────────┘ + └---------------------┘ └------------------------┘ │ ┌┘ - ┌───────────────────┐ ┌───────────────────┐ + ┌-------------------┐ ┌-------------------┐ │[0: OLAP_SCAN_NODE]│ │[1: OLAP_SCAN_NODE]│ │Fragment: 4 │ │Fragment: 3 │ - └───────────────────┘ └───────────────────┘ + └-------------------┘ └-------------------┘ │ │ - ┌─────────────┐ ┌─────────────┐ + ┌-------------┐ ┌-------------┐ │[OlapScanner]│ │[OlapScanner]│ │Fragment: 4 │ │Fragment: 3 │ - └─────────────┘ └─────────────┘ + └-------------┘ └-------------┘ │ │ - ┌─────────────────┐ ┌─────────────────┐ + ┌-----------------┐ ┌-----------------┐ │[SegmentIterator]│ │[SegmentIterator]│ │Fragment: 4 │ │Fragment: 3 │ - └─────────────────┘ └─────────────────┘ + └-----------------┘ └-----------------┘ 1 row in set (0.02 sec) ``` @@ -600,70 +602,70 @@ This shows the execution nodes and time consumption of all three Instances on Fr mysql> show query profile "/c257c52f93e149ee-ace8ac14e8c9fef9/1/c257c52f93e149ee-ace8ac14e8c9ff03"\G **************************** 1. row ******************** ****** Instance: - ┌────────────────────────────────────────────┐ - │[9: DataStreamSender] │ - │(Active: 37.222us, non-child: 0.40) │ - │ - Counters: │ - │ - BytesSent: 0.00 │ - │ - IgnoreRows: 0 │ - │ - OverallThroughput: 0.0 /sec │ - │ - PeakMemoryUsage: 8.00 KB │ - │ - SerializeBatchTime: 0ns │ - │ - UncompressedRowBatchSize: 0.00 │ - └──────────────────────────────────────────┘ + ┌------------------------------------------┐ + │[9: DataStreamSender] │ + │(Active: 37.222us, non-child: 0.40) │ + │ - Counters: │ + │ - BytesSent: 0.00 │ + │ - IgnoreRows: 0 │ + │ - OverallThroughput: 0.0 /sec │ + │ - PeakMemoryUsage: 8.00 KB │ + │ - SerializeBatchTime: 0ns │ + │ - UncompressedRowBatchSize: 0.00 │ + └------------------------------------------┘ └┐ │ - ┌──────────────────────────────────────┐ - │[4: SORT_NODE] │ - │(Active: 5.421ms, non-child: 0.71)│ - │ - Counters: │ - │ - PeakMemoryUsage: 12.00 KB │ - │ - RowsReturned: 0 │ - │ - RowsReturnedRate: 0 │ - └──────────────────────────────────────┘ + ┌--------------------------------------┐ + │[4: SORT_NODE] │ + │(Active: 5.421ms, non-child: 0.71) │ + │ - Counters: │ + │ - PeakMemoryUsage: 12.00 KB │ + │ - RowsReturned: 0 │ + │ - RowsReturnedRate: 0 │ + └--------------------------------------┘ ┌┘ │ - ┌──────────────────────────────────────┐ - │[8: AGGREGATION_NODE] │ - │(Active: 5.355ms, non-child: 10.68)│ - │ - Counters: │ - │ - BuildTime: 3.701us │ - │ - GetResultsTime: 0ns │ - │ - HTResize: 0 │ - │ - HTResizeTime: 1.211us │ - │ - HashBuckets: 0 │ - │ - HashCollisions: 0 │ - │ - HashFailedProbe: 0 │ - │ - HashFilledBuckets: 0 │ - │ - HashProbe: 0 │ - │ - HashTravelLength: 0 │ - │ - LargestPartitionPercent: 0 │ - │ - MaxPartitionLevel: 0 │ - │ - NumRepartitions: 0 │ - │ - PartitionsCreated: 16 │ - │ - PeakMemoryUsage: 34.02 MB │ - │ - RowsProcessed: 0 │ - │ - RowsRepartitioned: 0 │ - │ - RowsReturned: 0 │ - │ - RowsReturnedRate: 0 │ - │ - SpilledPartitions: 0 │ - └──────────────────────────────────────┘ + ┌----------------------------------------┐ + │[8: AGGREGATION_NODE] │ + │(Active: 5.355ms, non-child: 10.68) │ + │ - Counters: │ + │ - BuildTime: 3.701us │ + │ - GetResultsTime: 0ns │ + │ - HTResize: 0 │ + │ - HTResizeTime: 1.211us │ + │ - HashBuckets: 0 │ + │ - HashCollisions: 0 │ + │ - HashFailedProbe: 0 │ + │ - HashFilledBuckets: 0 │ + │ - HashProbe: 0 │ + │ - HashTravelLength: 0 │ + │ - LargestPartitionPercent: 0 │ + │ - MaxPartitionLevel: 0 │ + │ - NumRepartitions: 0 │ + │ - PartitionsCreated: 16 │ + │ - PeakMemoryUsage: 34.02 MB │ + │ - RowsProcessed: 0 │ + │ - RowsRepartitioned: 0 │ + │ - RowsReturned: 0 │ + │ - RowsReturnedRate: 0 │ + │ - SpilledPartitions: 0 │ + └----------------------------------------┘ └┐ │ - ┌────────────────────────────────────────────────────┐ - │[7: EXCHANGE_NODE] │ - │(Active: 4.360ms, non-child: 46.84) │ - │ - Counters: │ - │ - BytesReceived: 0.00 │ - │ - ConvertRowBatchTime: 387ns │ - │ - DataArrivalWaitTime: 4.357ms │ - │ - DeserializeRowBatchTimer: 0ns │ - │ - FirstBatchArrivalWaitTime: 4.356ms│ - │ - PeakMemoryUsage: 0.00 │ - │ - RowsReturned: 0 │ - │ - RowsReturnedRate: 0 │ - │ - SendersBlockedTotalTimer(*): 0ns │ - └────────────────────────────────────────────────────┘ + ┌----------------------------------------------------┐ + │[7: EXCHANGE_NODE] │ + │(Active: 4.360ms, non-child: 46.84) │ + │ - Counters: │ + │ - BytesReceived: 0.00 │ + │ - ConvertRowBatchTime: 387ns │ + │ - DataArrivalWaitTime: 4.357ms │ + │ - DeserializeRowBatchTimer: 0ns │ + │ - FirstBatchArrivalWaitTime: 4.356ms │ + │ - PeakMemoryUsage: 0.00 │ + │ - RowsReturned: 0 │ + │ - RowsReturnedRate: 0 │ + │ - SendersBlockedTotalTimer(*): 0ns │ + └----------------------------------------------------┘ ``` The above figure shows the specific profiles of each operator of Instance c257c52f93e149ee-ace8ac14e8c9ff03 in Fragment 1. diff --git a/versioned_docs/version-1.2/advanced/cold-hot-separation.md b/versioned_docs/version-1.2/advanced/cold-hot-separation.md new file mode 100644 index 0000000000000..ea8c67c3fa6e6 --- /dev/null +++ b/versioned_docs/version-1.2/advanced/cold-hot-separation.md @@ -0,0 +1,128 @@ +--- +{ +"title": "Cold hot separation", +"language": "en" +} +--- + + + +# [Experimental] Cold hot separation + +## Demand scenario + +A big usage scenario in the future is similar to the es log storage. In the log scenario, the data will be cut by date. Many data are cold data, with few queries. Therefore, the storage cost of such data needs to be reduced. From the perspective of saving storage costs +1. The price of ordinary cloud disks of cloud manufacturers is higher than that of object storage +2. In the actual online use of the doris cluster, the utilization rate of ordinary cloud disks cannot reach 100% +3. Cloud disk is not paid on demand, but object storage can be paid on demand +4. High availability based on ordinary cloud disks requires multiple replicas, and a replica migration is required for a replica exception. This problem does not exist when data is placed on the object store, because the object store is shared。 + +## Solution +Set the freeze time on the partition level to indicate how long the partition will be frozen, and define the location of remote storage stored after the freeze. On the be, the daemon thread will periodically determine whether the table needs to be frozen. If it does, it will upload the data to s3. + +The cold and hot separation supports all doris functions, but only places some data on object storage to save costs without sacrificing functions. Therefore, it has the following characteristics: + +- When cold data is stored on object storage, users need not worry about data consistency and data security +- Flexible freeze policy, cooling remote storage property can be applied to table and partition levels +- Users query data without paying attention to the data distribution location. If the data is not local, they will pull the data on the object and cache it to be local +- Optimization of replica clone. If the stored data is on the object, the replica clone does not need to pull the stored data locally +- Remote object space recycling recycler. If the table and partition are deleted, or the space is wasted due to abnormal conditions in the cold and hot separation process, the recycler thread will periodically recycle, saving storage resources +- Cache optimization, which caches the accessed cold data to be local, achieving the query performance of non cold and hot separation +- Be thread pool optimization, distinguish whether the data source is local or object storage, and prevent the delay of reading objects from affecting query performance +- newly created materialized view would inherit storage policy from it's base table's correspoding partition + +## Storage policy + +The storage policy is the entry to use the cold and hot separation function. Users only need to associate a storage policy with a table or partition during table creation or doris use. that is, they can use the cold and hot separation function. + + When creating an S3 RESOURCE, the S3 remote link verification will be performed to ensure that the RESOURCE is created correctly. + +In addition, fe configuration needs to be added: `enable_storage_policy=true` + +For example: + +``` +CREATE RESOURCE "remote_s3" +PROPERTIES +( + "type" = "s3", + "AWS_ENDPOINT" = "bj.s3.com", + "AWS_REGION" = "bj", + "AWS_BUCKET" = "test-bucket", + "AWS_ROOT_PATH" = "path/to/root", + "AWS_ACCESS_KEY" = "bbb", + "AWS_SECRET_KEY" = "aaaa", + "AWS_MAX_CONNECTIONS" = "50", + "AWS_REQUEST_TIMEOUT_MS" = "3000", + "AWS_CONNECTION_TIMEOUT_MS" = "1000" +); + +CREATE STORAGE POLICY test_policy +PROPERTIES( + "storage_resource" = "remote_s3", + "cooldown_ttl" = "1d" +); + +CREATE TABLE IF NOT EXISTS create_table_use_created_policy +( + k1 BIGINT, + k2 LARGEINT, + v1 VARCHAR(2048) +) +UNIQUE KEY(k1) +DISTRIBUTED BY HASH (k1) BUCKETS 3 +PROPERTIES( + "storage_policy" = "test_policy" +); +``` +Or for an existing table, associate the storage policy +``` +ALTER TABLE create_table_not_have_policy set ("storage_policy" = "test_policy"); +``` +Or associate a storage policy with an existing partition +``` +ALTER TABLE create_table_partition MODIFY PARTITION (*) SET("storage_policy"="test_policy"); +``` +For details, please refer to the [resource](../sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-RESOURCE.md), [policy](../sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-POLICY.md), create table, alter and other documents in the docs directory + +### Some restrictions + +- A single table or a single partition can only be associated with one storage policy. After association, the storage policy cannot be dropped +- The object information associated with the storage policy does not support modifying the data storage path information, such as bucket, endpoint, and root_Path and other information +- Currently, the storage policy only supports creation and modification, not deletion + +## Show size of objects occupied by cold data +1. Through show proc '/backends', you can view the size of each object being uploaded to, and the RemoteUsedCapacity item. + +2. Through show tables from tableName, you can view the object size occupied by each table, and the RemoteDataSize item. + +## cold data cache + +As above, cold data introduces the cache in order to optimize query performance. After the first hit after cooling, Doris will reload the cooled data to be's local disk. The cache has the following characteristics: +- The cache is actually stored on the be local disk and does not occupy memory. +- the cache can limit expansion and clean up data through LRU +- The be parameter `file_cache_alive_time_sec` can set the maximum storage time of the cache data after it has not been accessed. The default is 604800, which is one week. +- The be parameter `file_cache_max_size_per_disk` can set the disk size occupied by the cache. Once this setting is exceeded, the cache that has not been accessed for the longest time will be deleted. The default is 0, means no limit to the size, unit: byte. +- The be parameter `file_cache_type` is optional `sub_file_cache` (segment the remote file for local caching) and `whole_file_cache` (the entire remote file for local caching), the default is "", means no file is cached, please set it when caching is required this parameter. + +## Unfinished Matters + +- After the data is frozen, there are new data updates or imports, etc. The compression has not been processed at present. +- The schema change operation after the data is frozen is not supported at present. diff --git a/versioned_docs/version-1.2/advanced/cold_hot_separation.md b/versioned_docs/version-1.2/advanced/cold_hot_separation.md deleted file mode 100644 index ab814f056ba8a..0000000000000 --- a/versioned_docs/version-1.2/advanced/cold_hot_separation.md +++ /dev/null @@ -1,128 +0,0 @@ ---- -{ -"title": "Cold hot separation", -"language": "en" -} ---- - - - -# [Experimental] Cold hot separation - -## Demand scenario - -A big usage scenario in the future is similar to the es log storage. In the log scenario, the data will be cut by date. Many data are cold data, with few queries. Therefore, the storage cost of such data needs to be reduced. From the perspective of saving storage costs -1. The price of ordinary cloud disks of cloud manufacturers is higher than that of object storage -2. In the actual online use of the doris cluster, the utilization rate of ordinary cloud disks cannot reach 100% -3. Cloud disk is not paid on demand, but object storage can be paid on demand -4. High availability based on ordinary cloud disks requires multiple replicas, and a replica migration is required for a replica exception. This problem does not exist when data is placed on the object store, because the object store is shared。 - -## Solution -Set the freeze time on the partition level to indicate how long the partition will be frozen, and define the location of remote storage stored after the freeze. On the be, the daemon thread will periodically determine whether the table needs to be frozen. If it does, it will upload the data to s3. - -The cold and hot separation supports all doris functions, but only places some data on object storage to save costs without sacrificing functions. Therefore, it has the following characteristics: - -- When cold data is stored on object storage, users need not worry about data consistency and data security -- Flexible freeze policy, cooling remote storage property can be applied to table and partition levels -- Users query data without paying attention to the data distribution location. If the data is not local, they will pull the data on the object and cache it to be local -- Optimization of replica clone. If the stored data is on the object, the replica clone does not need to pull the stored data locally -- Remote object space recycling recycler. If the table and partition are deleted, or the space is wasted due to abnormal conditions in the cold and hot separation process, the recycler thread will periodically recycle, saving storage resources -- Cache optimization, which caches the accessed cold data to be local, achieving the query performance of non cold and hot separation -- Be thread pool optimization, distinguish whether the data source is local or object storage, and prevent the delay of reading objects from affecting query performance -- newly created materialized view would inherit storage policy from it's base table's correspoding partition - -## Storage policy - -The storage policy is the entry to use the cold and hot separation function. Users only need to associate a storage policy with a table or partition during table creation or doris use. that is, they can use the cold and hot separation function. - - When creating an S3 RESOURCE, the S3 remote link verification will be performed to ensure that the RESOURCE is created correctly. - -In addition, fe configuration needs to be added: `enable_storage_policy=true` - -For example: - -``` -CREATE RESOURCE "remote_s3" -PROPERTIES -( - "type" = "s3", - "AWS_ENDPOINT" = "bj.s3.com", - "AWS_REGION" = "bj", - "AWS_BUCKET" = "test-bucket", - "AWS_ROOT_PATH" = "path/to/root", - "AWS_ACCESS_KEY" = "bbb", - "AWS_SECRET_KEY" = "aaaa", - "AWS_MAX_CONNECTIONS" = "50", - "AWS_REQUEST_TIMEOUT_MS" = "3000", - "AWS_CONNECTION_TIMEOUT_MS" = "1000" -); - -CREATE STORAGE POLICY test_policy -PROPERTIES( - "storage_resource" = "remote_s3", - "cooldown_ttl" = "1d" -); - -CREATE TABLE IF NOT EXISTS create_table_use_created_policy -( - k1 BIGINT, - k2 LARGEINT, - v1 VARCHAR(2048) -) -UNIQUE KEY(k1) -DISTRIBUTED BY HASH (k1) BUCKETS 3 -PROPERTIES( - "storage_policy" = "test_policy" -); -``` -Or for an existing table, associate the storage policy -``` -ALTER TABLE create_table_not_have_policy set ("storage_policy" = "test_policy"); -``` -Or associate a storage policy with an existing partition -``` -ALTER TABLE create_table_partition MODIFY PARTITION (*) SET("storage_policy"="test_policy"); -``` -For details, please refer to the [resource](../sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-RESOURCE.md), [policy](../sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-POLICY.md), create table, alter and other documents in the docs directory - -### Some restrictions - -- A single table or a single partition can only be associated with one storage policy. After association, the storage policy cannot be dropped -- The object information associated with the storage policy does not support modifying the data storage path information, such as bucket, endpoint, and root_ Path and other information -- Currently, the storage policy only supports creation and modification, not deletion - -## Show size of objects occupied by cold data -1. Through show proc '/backends', you can view the size of each object being uploaded to, and the RemoteUsedCapacity item. - -2. Through show tables from tableName, you can view the object size occupied by each table, and the RemoteDataSize item. - -## cold data cache - -As above, cold data introduces the cache in order to optimize query performance. After the first hit after cooling, Doris will reload the cooled data to be's local disk. The cache has the following characteristics: -- The cache is actually stored on the be local disk and does not occupy memory. -- the cache can limit expansion and clean up data through LRU -- The be parameter `file_cache_alive_time_sec` can set the maximum storage time of the cache data after it has not been accessed. The default is 604800, which is one week. -- The be parameter `file_cache_max_size_per_disk` can set the disk size occupied by the cache. Once this setting is exceeded, the cache that has not been accessed for the longest time will be deleted. The default is 0, means no limit to the size, unit: byte. -- The be parameter `file_cache_type` is optional `sub_file_cache` (segment the remote file for local caching) and `whole_file_cache` (the entire remote file for local caching), the default is "", means no file is cached, please set it when caching is required this parameter. - -## Unfinished Matters - -- After the data is frozen, there are new data updates or imports, etc. The compression has not been processed at present. -- The schema change operation after the data is frozen is not supported at present. diff --git a/versioned_docs/version-1.2/advanced/compute_node.md b/versioned_docs/version-1.2/advanced/compute-node.md similarity index 100% rename from versioned_docs/version-1.2/advanced/compute_node.md rename to versioned_docs/version-1.2/advanced/compute-node.md diff --git a/versioned_docs/version-1.2/advanced/partition/dynamic-partition.md b/versioned_docs/version-1.2/advanced/partition/dynamic-partition.md index 0aad67c6ccf8b..1292f8b1e4b85 100644 --- a/versioned_docs/version-1.2/advanced/partition/dynamic-partition.md +++ b/versioned_docs/version-1.2/advanced/partition/dynamic-partition.md @@ -397,16 +397,16 @@ You can further view the scheduling of dynamic partitioned tables by using the f ``` mysql> SHOW DYNAMIC PARTITION TABLES; -+-----------+--------+----------+-------------+------+--------+---------+-----------+----------------+---------------------+--------+------------------------+----------------------+-------------------------+ ++-----------+--------+----------+-------------+------+--------+---------+-----------+ | TableName | Enable | TimeUnit | Start | End | Prefix | Buckets | StartOf | LastUpdateTime | LastSchedulerTime | State | LastCreatePartitionMsg | LastDropPartitionMsg | ReservedHistoryPeriods | -+-----------+--------+----------+-------------+------+--------+---------+-----------+----------------+---------------------+--------+------------------------+----------------------+-------------------------+ ++-----------+--------+----------+-------------+------+--------+---------+-----------+ | d3 | true | WEEK | -3 | 3 | p | 1 | MONDAY | N/A | 2020-05-25 14:29:24 | NORMAL | N/A | N/A | [2021-12-01,2021-12-31] | | d5 | true | DAY | -7 | 3 | p | 32 | N/A | N/A | 2020-05-25 14:29:24 | NORMAL | N/A | N/A | NULL | | d4 | true | WEEK | -3 | 3 | p | 1 | WEDNESDAY | N/A | 2020-05-25 14:29:24 | NORMAL | N/A | N/A | NULL | | d6 | true | MONTH | -2147483648 | 2 | p | 8 | 3rd | N/A | 2020-05-25 14:29:24 | NORMAL | N/A | N/A | NULL | | d2 | true | DAY | -3 | 3 | p | 32 | N/A | N/A | 2020-05-25 14:29:24 | NORMAL | N/A | N/A | NULL | | d7 | true | MONTH | -2147483648 | 5 | p | 8 | 24th | N/A | 2020-05-25 14:29:24 | NORMAL | N/A | N/A | NULL | -+-----------+--------+----------+-------------+------+--------+---------+-----------+----------------+---------------------+--------+------------------------+----------------------+-------------------------+ ++-----------+--------+----------+-------------+------+--------+---------+-----------+ 7 rows in set (0.02 sec) ``` diff --git a/versioned_docs/version-1.2/data-operate/export/export-manual.md b/versioned_docs/version-1.2/data-operate/export/export-manual.md index f0f6740844014..386418a63a113 100644 --- a/versioned_docs/version-1.2/data-operate/export/export-manual.md +++ b/versioned_docs/version-1.2/data-operate/export/export-manual.md @@ -129,9 +129,9 @@ WITH BROKER "hdfs" ``` * `label`: The identifier of this export job. You can use this identifier to view the job status later. -* `column_separator`: Column separator. The default is `\t`. Supports invisible characters, such as'\x07'. +* `column_separator`: Column separator. The default is `\t`. Supports invisible characters, such as `'\x07'`. * `column`: columns to be exported, separated by commas, if this parameter is not filled in, all columns of the table will be exported by default. -* `line_delimiter`: Line separator. The default is `\n`. Supports invisible characters, such as'\x07'. +* `line_delimiter`: Line separator. The default is `\n`. Supports invisible characters, such as `'\x07'`. * `exec_mem_limit`: Represents the memory usage limitation of a query plan on a single BE in an Export job. Default 2GB. Unit bytes. * `timeout`: homework timeout. Default 2 hours. Unit seconds. * `tablet_num_per_task`: The maximum number of fragments allocated per query plan. The default is 5. diff --git a/versioned_docs/version-1.2/data-operate/export/export_with_mysql_dump.md b/versioned_docs/version-1.2/data-operate/export/export-with-mysql-dump.md similarity index 100% rename from versioned_docs/version-1.2/data-operate/export/export_with_mysql_dump.md rename to versioned_docs/version-1.2/data-operate/export/export-with-mysql-dump.md diff --git a/versioned_docs/version-1.2/data-operate/export/outfile.md b/versioned_docs/version-1.2/data-operate/export/outfile.md index 9532377cde5b6..13bfda1beb4d3 100644 --- a/versioned_docs/version-1.2/data-operate/export/outfile.md +++ b/versioned_docs/version-1.2/data-operate/export/outfile.md @@ -117,11 +117,12 @@ If it exports and returns normally, the result is as follows: ``` mysql> select * from tbl1 limit 10 into outfile "file:///home/work/path/result_"; -+------------+-----------+----------+--------------------------------------------------------------------+ -| FileNumber | TotalRows | FileSize | URL | -+------------+-----------+----------+--------------------------------------------------------------------+ -| 1 | 2 | 8 | file:///192.168.1.10/home/work/path/result_{fragment_instance_id}_ | -+------------+-----------+----------+--------------------------------------------------------------------+ ++------------+-----------+----------+-------------------------------------------------+ +| FileNumber | TotalRows | FileSize | URL | ++------------+-----------+----------+-------------------------------------------------+ +| 1 | 2 | 8 | file:///192.168.1.10/home/work/path/result_ | +| | | | {fragment_instance_id}_ | ++------------+-----------+----------+-------------------------------------------------+ 1 row in set (0.05 sec) ``` @@ -133,12 +134,14 @@ mysql> select * from tbl1 limit 10 into outfile "file:///home/work/path/result_" If a concurrent export is performed, multiple rows of data will be returned. ``` -+------------+-----------+----------+--------------------------------------------------------------------+ -| FileNumber | TotalRows | FileSize | URL | -+------------+-----------+----------+--------------------------------------------------------------------+ -| 1 | 3 | 7 | file:///192.168.1.10/home/work/path/result_{fragment_instance_id}_ | -| 1 | 2 | 4 | file:///192.168.1.11/home/work/path/result_{fragment_instance_id}_ | -+------------+-----------+----------+--------------------------------------------------------------------+ ++------------+-----------+----------+-------------------------------------------------+ +| FileNumber | TotalRows | FileSize | URL | ++------------+-----------+----------+-------------------------------------------------+ +| 1 | 3 | 7 | file:///192.168.1.10/home/work/path/result_ | +| | | | {fragment_instance_id}_ | +| 1 | 2 | 4 | file:///192.168.1.11/home/work/path/result_ | +| | | | {fragment_instance_id}_ | ++------------+-----------+----------+-------------------------------------------------+ 2 rows in set (2.218 sec) ``` diff --git a/versioned_docs/version-1.2/data-operate/import/import-scenes/load-data-convert.md b/versioned_docs/version-1.2/data-operate/import/import-scenes/load-data-convert.md index f11fe902ef265..bfc886fb77f4d 100644 --- a/versioned_docs/version-1.2/data-operate/import/import-scenes/load-data-convert.md +++ b/versioned_docs/version-1.2/data-operate/import/import-scenes/load-data-convert.md @@ -107,7 +107,7 @@ Assuming that the source file has 4 columns, the contents are as follows (the he | 1 | 100 | beijing | 1.1 | | 2 | 200 | shanghai | 1.2 | | 3 | 300 | guangzhou | 1.3 | -| 4 | \N | chongqing | 1.4 | +| 4 | `\N` | chongqing | 1.4 | > Note: `\N` means null in the source file. @@ -195,7 +195,7 @@ Assuming that the source file has 4 columns, the contents are as follows (the he | 1 | 100 | beijing | 1.1 | | 2 | 200 | shanghai | 1.2 | | 3 | 300 | guangzhou | 1.3 | -| \N | 400 | chongqing | 1.4 | +| `\N` | 400 | chongqing | 1.4 | 1. Convert the column values in the source file and import them into the table @@ -286,7 +286,7 @@ Assuming that the source file has 4 columns, the contents are as follows (the he | 1 | 100 | beijing | 1.1 | | 2 | 200 | shanghai | 1.2 | | 3 | 300 | guangzhou | 1.3 | -| \N | 400 | chongqing | 1.4 | +| `\N` | 400 | chongqing | 1.4 | 1. In the default case of column mapping and transformation, filter directly diff --git a/versioned_docs/version-1.2/data-operate/import/import-scenes/load-strict-mode.md b/versioned_docs/version-1.2/data-operate/import/import-scenes/load-strict-mode.md index 4c29c9f1cb5b4..709dc45491c37 100644 --- a/versioned_docs/version-1.2/data-operate/import/import-scenes/load-strict-mode.md +++ b/versioned_docs/version-1.2/data-operate/import/import-scenes/load-strict-mode.md @@ -106,7 +106,7 @@ For an imported column type that contains range restrictions, if the original da | Primitive data type | Primitive data example | Converted value to TinyInt | Strict mode | Result | | ------------------- | ---------------------- | -------------------------- | ----------- | ------------------------ | - | NULL | \N | NULL | ON or OFF | NULL | + | NULL | `\N` | NULL | ON or OFF | NULL | | Non-null value | "abc" or 2000 | NULL | On | Illegal value (filtered) | | non-null value | "abc" | NULL | off | NULL | | non-null value | 1 | 1 | on or off | import correctly | @@ -120,7 +120,7 @@ For an imported column type that contains range restrictions, if the original da | Primitive Data Types | Examples of Primitive Data | Converted to Decimal | Strict Mode | Result | | -------------------- | -------------------------- | -------------------- | ----------- | ------------------------ | - | Null | \N | null | On or Off | NULL | + | Null | `\N` | null | On or Off | NULL | | non-null value | aaa | NULL | on | illegal value (filtered) | | non-null value | aaa | NULL | off | NULL | | non-null value | 1 or 10 | 1 or 10 | on or off | import correctly | diff --git a/versioned_docs/version-1.2/data-operate/import/import-way/binlog-load-manual.md b/versioned_docs/version-1.2/data-operate/import/import-way/binlog-load-manual.md index 061bfff950cfc..6dfe517f73417 100644 --- a/versioned_docs/version-1.2/data-operate/import/import-way/binlog-load-manual.md +++ b/versioned_docs/version-1.2/data-operate/import/import-way/binlog-load-manual.md @@ -113,8 +113,8 @@ To enable the binlog of MySQL, you need to edit the my.cnf file and set it like: ``` [mysqld] -log-bin = mysql-bin # 开启 binlog -binlog-format=ROW # 选择 ROW 模式 +log-bin = mysql-bin # Enable binlog +binlog-format=ROW # Select ROW mode ``` ### Principle Description @@ -460,7 +460,7 @@ The parameters in the result set have the following meanings: User can control the status of the job by three commands: `stop/pause/resume`. After the operation, the job status is `cancelled/paused/running` respectively. - There is only one final stage of the job, Cancelled. When the job status changes to Canceled, it cannot be resumed again. + There is only one final stage of the job, Cancelled. When the job status changes to Canceled, it cannot be resumed again. When an error occurs during SyncJob is running, if the error is unrecoverable, the status will change to cancelled, otherwise it will change to paused. @@ -537,7 +537,7 @@ The following configuration belongs to the system level configuration of SyncJob 2. Will the SyncJob continue to run after the database is deleted? - No. In this case, the SyncJob will be checked by the Fe's scheduler thread and be stopped. + No. In this case, the SyncJob will be checked by the Fe's scheduler thread and be stopped. 3. Can multiple SyncJobs be configured with the same `IP:Port + destination`? diff --git a/versioned_docs/version-1.2/data-operate/import/import-way/insert-into-manual.md b/versioned_docs/version-1.2/data-operate/import/import-way/insert-into-manual.md index dbb6e7f85c2df..1c366c24ef702 100644 --- a/versioned_docs/version-1.2/data-operate/import/import-way/insert-into-manual.md +++ b/versioned_docs/version-1.2/data-operate/import/import-way/insert-into-manual.md @@ -245,7 +245,7 @@ Cluster situation: The average import speed of current user cluster is about 5M/ - Step2: Create Import Tasks - Since users want to ETL data from a table and import it into the target table, they should use the Insert in query\stmt mode to import it. + Since users want to ETL data from a table and import it into the target table, they should use the Insert in query\_stmt mode to import it. ```text INSERT INTO bj_store_sales SELECT id, total, user_id, sale_timestamp FROM store_sales where region = "bj"; diff --git a/versioned_docs/version-1.2/data-operate/import/import-way/routine-load-manual.md b/versioned_docs/version-1.2/data-operate/import/import-way/routine-load-manual.md index 1c5fd2536aaf2..b02384c203052 100644 --- a/versioned_docs/version-1.2/data-operate/import/import-way/routine-load-manual.md +++ b/versioned_docs/version-1.2/data-operate/import/import-way/routine-load-manual.md @@ -264,7 +264,7 @@ Here is an example with a column type of TinyInt | source data | source data example | string to int | strict_mode | result | | ----------- | ------------------- | ------------- | ------------- | ---------------------- | -| Null value | \N | N/A | true or false | NULL | +| Null value | `\N` | N/A | true or false | NULL | | not null | aaa or 2000 | NULL | true | invalid data(filtered) | | not null | aaa | NULL | false | NULL | | not null | 1 | 1 | true or false | correct data | @@ -277,7 +277,7 @@ Here is an example with the column type Decimal(1,0) | source data | source data example | string to int | strict_mode | result | | ----------- | ------------------- | ------------- | ------------- | ---------------------- | -| Null value | \N | N/A | true or false | NULL | +| Null value | `\N` | N/A | true or false | NULL | | not null | aaa | NULL | true | invalid data(filtered) | | not null | aaa | NULL | false | NULL | | not null | 1 or 10 | 1 | true or false | correct data | diff --git a/versioned_docs/version-1.2/data-operate/import/import-way/spark-load-manual.md b/versioned_docs/version-1.2/data-operate/import/import-way/spark-load-manual.md index 57bed58c3ba01..b71d07b096842 100644 --- a/versioned_docs/version-1.2/data-operate/import/import-way/spark-load-manual.md +++ b/versioned_docs/version-1.2/data-operate/import/import-way/spark-load-manual.md @@ -701,7 +701,11 @@ These values represent the creation time of the load, the start time of the ETL Display the detailed running status of some jobs, which will be updated when ETL ends. It includes the number of loaded files, the total size (bytes), the number of subtasks, the number of processed original lines, etc. -```{"ScannedRows":139264,"TaskNumber":1,"FileNumber":1,"FileSize":940754064}``` +``` + + {"ScannedRows":139264,"TaskNumber":1,"FileNumber":1,"FileSize":940754064} + +``` + URL diff --git a/versioned_docs/version-1.2/ecosystem/automq-load.md b/versioned_docs/version-1.2/ecosystem/automq-load.md index b395052529f91..1ab80bf0d0c59 100644 --- a/versioned_docs/version-1.2/ecosystem/automq-load.md +++ b/versioned_docs/version-1.2/ecosystem/automq-load.md @@ -6,6 +6,7 @@ --- [AutoMQ](https://github.com/AutoMQ/automq) is a cloud-native fork of Kafka by separating storage to object storage like S3. It remains 100% compatible with Apache Kafka® while offering users up to a 10x cost-effective and 100x elasticity . Through its innovative shared storage architecture, it achieves capabilities such as reassign partitions in seconds, self-balancing and auto scaling in seconds while ensuring high throughput and low latency. + ![AutoMQ Storage Architecture](/images/automq/automq_storage_architecture.png) This article will explain how to use Apache Doris Routine Load to import data from AutoMQ into Doris. For more details on Routine Load, please refer to the [Routine Load](https://doris.apache.org/docs/data-operate/import/routine-load-manual/) document. diff --git a/versioned_docs/version-1.2/ecosystem/beats.md b/versioned_docs/version-1.2/ecosystem/beats.md index 63d2cd4ffa287..06220699957b4 100644 --- a/versioned_docs/version-1.2/ecosystem/beats.md +++ b/versioned_docs/version-1.2/ecosystem/beats.md @@ -62,8 +62,8 @@ go build -o heartbeat-doris heartbeat/heartbeat.go The configuration for the Beats Doris output plugin is as follows: -Configuration | Description ---- | --- +Configuration | Description +----------------------- | --------------------------------------------------------- `http_hosts` | Stream Load HTTP address, formatted as a string array, can have one or more elements, each element is host:port. For example: ["http://fe1:8030", "http://fe2:8030"] `user` | Doris username, this user needs to have import permissions for the corresponding Doris database and table `password` | Doris user's password diff --git a/versioned_docs/version-1.2/ecosystem/bi/dbeaver.md b/versioned_docs/version-1.2/ecosystem/bi/dbeaver.md index 2ecbc2fae3a7a..a38a8cef56a2c 100644 --- a/versioned_docs/version-1.2/ecosystem/bi/dbeaver.md +++ b/versioned_docs/version-1.2/ecosystem/bi/dbeaver.md @@ -74,18 +74,23 @@ Currently verified using DBeaver version 24.0.0 ::: - internal catalog + ![connect internal catalog](/images/dbeaver4.png) + - external catalog + ![connect external catalog](/images/dbeaver5.png) 5. Test data source connection After filling in the connection information, click Test Connection in the lower left corner to verify the accuracy of the database connection information. DBeaver returns to the following dialog box to confirm the configuration of the connection information. Click OK to confirm that the configured connection information is correct. Then click Finish in the lower right corner to complete the connection configuration. + ![test connection](/images/dbeaver6.png) 6. Connect to database After the database connection is established, you can see the created data source connection in the database connection navigation on the left, and you can connect and manage the database through DBeaver. + ![create connection](/images/dbeaver7.png) ## Function support diff --git a/versioned_docs/version-1.2/ecosystem/cloudcanal.md b/versioned_docs/version-1.2/ecosystem/cloudcanal.md index 6a7f63a693a2d..ba290a64ca474 100644 --- a/versioned_docs/version-1.2/ecosystem/cloudcanal.md +++ b/versioned_docs/version-1.2/ecosystem/cloudcanal.md @@ -54,24 +54,30 @@ Taking a MySQL instance as an example, the following part describes how to move ### Add DataSources 1. Log in to the [BladePipe Cloud](https://cloud.bladepipe.com/). Click **DataSource** > **Add DataSource**. 2. Select MySQL and Doris as the Type respectively, and fill in the setup form accordingly. + ![Add DataSources-1](/images/bp-doris-1.png) 3. Click **Test Connection**. After successful connection, click **Add DataSource** to add the DataSource. + ![Add DataSources-2](/images/bp-doris-2.png) ### Create a DataJob 1. Click DataJob > [Create DataJob](https://doc.bladepipe.com/operation/job_manage/create_job/create_full_incre_task). 2. Select the source and target DataSources, and click **Test Connection** to ensure the connection to the source and target DataSources are both successful. + ![Create a DataJob-1](/images/bp-doris-3.png) 1. Select **Incremental** for DataJob Type, together with the **Full Data** option. + ![Create a DataJob-2](/images/bp-doris-4.png) 1. Select the tables to be replicated. + ![Create a DataJob-3](/images/bp-doris-5.png) 1. Select the columns to be replicated. + ![Create a DataJob-4](/images/bp-doris-6.png) 1. Confirm the DataJob creation. @@ -79,4 +85,5 @@ Taking a MySQL instance as an example, the following part describes how to move - **Schema Migration**: The schemas of the source tables will be migrated to the target instance. - **Full Data**: All existing data of the source tables will be fully migrated to the target instance. - **Incremental**: Ongoing data changes will be continuously synchronized to the target instance. + ![Create a DataJob-5](/images/bp-doris-8.png) \ No newline at end of file diff --git a/versioned_docs/version-1.2/ecosystem/datax.md b/versioned_docs/version-1.2/ecosystem/datax.md index 0c28ca3d3f432..30ff13eb1ea79 100644 --- a/versioned_docs/version-1.2/ecosystem/datax.md +++ b/versioned_docs/version-1.2/ecosystem/datax.md @@ -276,7 +276,7 @@ my_import.json >} >``` > ->**CSV format should pay special attention to row and column separators to avoid conflicts with special characters in the data. Hidden characters are recommended here. The default column separator is: \t, row separator: \n** +>**CSV format should pay special attention to row and column separators to avoid conflicts with special characters in the data. Hidden characters are recommended here. The default column separator is: `\t`, row separator: `\n`** 4.Execute the datax task, refer to the specific [datax official website](https://github.com/alibaba/DataX/blob/master/userGuid.md) diff --git a/versioned_docs/version-1.2/ecosystem/doris-streamloader.md b/versioned_docs/version-1.2/ecosystem/doris-streamloader.md index d6dabdf1715e8..ee19513904cea 100644 --- a/versioned_docs/version-1.2/ecosystem/doris-streamloader.md +++ b/versioned_docs/version-1.2/ecosystem/doris-streamloader.md @@ -109,24 +109,24 @@ doris-streamloader --source_file="data.csv" --url="http://localhost:8330" --head The parameters above are required, and the following parameters are optional: -| Parameter | Description | Default Value | Suggestions | -|---|---|---|---| -| --u | Username of the database | root | | -| --p | Password | empty string | | -| --compress | Whether to compress data upon HTTP transmission | false | Remain as default. Compression and decompression can increase pressure on Doris Streamloader side and the CPU resources on Doris BE side, so it is advised to only enable this when network bandwidth is constrained. | -|--timeout | Timeout of the HTTP request sent to Doris (seconds) | 60\*60\*10 | Remain as default | -| --batch | Granularity of batch reading and sending of files (rows) | 4096 | Remain as default | -| --batch_byte | Granularity of batch reading and sending of files (byte) | 943718400 (900MB) | Remain as default | -| --workers | Concurrency level of data loading | 0 | "0" means the auto mode, in which the streamload speed is based on the data size and disk throughput. You can dial this up for a high-performance cluster, but it is advised to keep it below 10. If you observe excessive memory usage (via the memtracker in log), you can dial this down. | -| --disk_throughput | Disk throughput (MB/s) | 800 | Usually remain as default. This parameter is a basis of the automatic inference of workers. You can adjust this based on your needs to get a more appropriate value of workers. | -|--streamload_throughput | Streamload throughput (MB/s) | 100 | Usually remain as default. The default value is derived from the streamload throughput and predicted performance provided by the daily performance testing environment. To get a more appropriate value of workers, you can configure this based on your measured streamload throughput: (LoadBytes*1000)/(LoadTimeMs*1024*1024) | +| Parameter | Description | Default Value | Suggestions | +|--------------------------|----------------------------------------|-----------------|--------------------------------------------| +| --u | Username of the database | root | | +| --p | Password | empty string | | +| --compress | Whether to compress data upon HTTP transmission | false | Remain as default. Compression and decompression can increase pressure on Doris Streamloader side and the CPU resources on Doris BE side, so it is advised to only enable this when network bandwidth is constrained. | +|--timeout | Timeout of the HTTP request sent to Doris (seconds) | 60\*60\*10 | Remain as default | +| --batch | Granularity of batch reading and sending of files (rows) | 4096 | Remain as default | +| --batch_byte | Granularity of batch reading and sending of files (byte) | 943718400 (900MB) | Remain as default | +| --workers | Concurrency level of data loading | 0 | "0" means the auto mode, in which the streamload speed is based on the data size and disk throughput. You can dial this up for a high-performance cluster, but it is advised to keep it below 10. If you observe excessive memory usage (via the memtracker in log), you can dial this down. | +| --disk_throughput | Disk throughput (MB/s) | 800 | Usually remain as default. This parameter is a basis of the automatic inference of workers. You can adjust this based on your needs to get a more appropriate value of workers. | +|--streamload_throughput | Streamload throughput (MB/s) | 100 | Usually remain as default. The default value is derived from the streamload throughput and predicted performance provided by the daily performance testing environment. To get a more appropriate value of workers, you can configure this based on your measured streamload throughput: (LoadBytes*1000)/(LoadTimeMs*1024*1024) | | --max_byte_per_task | Maximum data size for each load task. For a dataset exceeding this size, the remaining part will be split into a new load task. | 107374182400 (100G) | This is recommended to be large in order to reduce the number of load versions. However, if you encounter a "body exceed max size" and try to avoid adjusting the streaming_load_max_mb parameter (which requires restarting the backend), or if you encounter a "-238 TOO MANY SEGMENT" error, you can temporarily dial this down. | -| --check_utf8 |

Whether to check the encoding of the data that has been loaded:

1) false, direct load of raw data without checking; 2) true, replacing non UTF-8 characters with �

| true |Remain as default| -|--debug |Print debug log | false | Remain as default | -|--auto_retry| The list of failed workers and tasks for auto retry | empty string | This is only used when there is an load failure. The serial numbers of the failed workers and tasks will be shown and all you need is to copy and execute the the entire command. For example, if --auto_retry="1,1;2,1", that means the failed tasks include the first task in the first worker and the first task in the second worker. | -|--auto_retry_times | Times of auto retries | 3 | Remain as default. If you don't need retries, you can set this to 0. | -|--auto_retry_interval | Interval of auto retries | 60 | Remain as default. If the load failure is caused by a Doris downtime, it is recommended to set this parameter based on the restart interval of Doris. | -|--log_filename | Path for log storage | "" | Logs are printed to the console by default. To print them to a log file, you can set the path, such as --log_filename="/var/log". | +| --check_utf8 |

Whether to check the encoding of the data that has been loaded:

1) false, direct load of raw data without checking; 2) true, replacing non UTF-8 characters with �

| true |Remain as default| +|--debug |Print debug log | false | Remain as default | +|--auto_retry | The list of failed workers and tasks for auto retry | empty string | This is only used when there is an load failure. The serial numbers of the failed workers and tasks will be shown and all you need is to copy and execute the the entire command. For example, if --auto_retry="1,1;2,1", that means the failed tasks include the first task in the first worker and the first task in the second worker. | +|--auto_retry_times | Times of auto retries | 3 | Remain as default. If you don't need retries, you can set this to 0. | +|--auto_retry_interval | Interval of auto retries | 60 | Remain as default. If the load failure is caused by a Doris downtime, it is recommended to set this parameter based on the restart interval of Doris. | +|--log_filename | Path for log storage | "" | Logs are printed to the console by default. To print them to a log file, you can set the path, such as --log_filename="/var/log". | @@ -135,17 +135,17 @@ The parameters above are required, and the following parameters are optional: A result will be returned no matter the data loading succeeds or fails. -|Parameter | Description | -|---|---| -| Status | Loading succeeded or failed | -| TotalRows | Total number of rows | -| FailLoadRows | Number of rows failed to be loaded | -| LoadedRows | Number of rows loaded | -| FilteredRows | Number of rows filtered | -| UnselectedRows | Number of rows unselected | -| LoadBytes | Number of bytes loaded | -| LoadTimeMs | Actual loading time | -| LoadFiles | List of loaded files | +|Parameter | Description | +|----------------|------------------------------------| +| Status | Loading succeeded or failed | +| TotalRows | Total number of rows | +| FailLoadRows | Number of rows failed to be loaded | +| LoadedRows | Number of rows loaded | +| FilteredRows | Number of rows filtered | +| UnselectedRows | Number of rows unselected | +| LoadBytes | Number of bytes loaded | +| LoadTimeMs | Actual loading time | +| LoadFiles | List of loaded files | diff --git a/versioned_docs/version-1.2/ecosystem/flink-doris-connector.md b/versioned_docs/version-1.2/ecosystem/flink-doris-connector.md index 24c8d07a47033..ab0239b8d520d 100644 --- a/versioned_docs/version-1.2/ecosystem/flink-doris-connector.md +++ b/versioned_docs/version-1.2/ecosystem/flink-doris-connector.md @@ -368,7 +368,7 @@ ON a.city = c.city | Key | Default Value | Required | Comment | | --------------------------- | ------------- | -------- | ------------------------------------------------------------ | | sink.label-prefix | -- | Y | The label prefix used by Stream load import. In the 2pc scenario, global uniqueness is required to ensure Flink's EOS semantics. | -| sink.properties.* | -- | N | Import parameters for Stream Load.
For example: 'sink.properties.column_separator' = ', ' defines column delimiters, 'sink.properties.escape_delimiters' = 'true' special characters as delimiters, '\x01' will be converted to binary 0x01

JSON format import
'sink.properties.format' = 'json' 'sink.properties. read_json_by_line' = 'true'
Detailed parameters refer to [here](../data-operate/import/stream-load-manual.md).

Group Commit mode
'sink.properties.group_commit' = 'sync_mode'
Starting from version 1.6.2, we have introduced support for load data with group commit functionality. For a comprehensive understanding of the available parameters, please refer to the Group Commit Manual [group commit](https://doris.apache.org/docs/data-operate/import/import-way/group-commit-manual/). | +| sink.properties.* | -- | N | Import parameters for Stream Load.
For example: 'sink.properties.column_separator' = ', ' defines column delimiters, 'sink.properties.escape_delimiters' = 'true' special characters as delimiters, `\x01` will be converted to binary 0x01

JSON format import
'sink.properties.format' = 'json' 'sink.properties. read_json_by_line' = 'true'
Detailed parameters refer to [here](../data-operate/import/stream-load-manual.md).

Group Commit mode
'sink.properties.group_commit' = 'sync_mode'
Starting from version 1.6.2, we have introduced support for load data with group commit functionality. For a comprehensive understanding of the available parameters, please refer to the Group Commit Manual [group commit](https://doris.apache.org/docs/data-operate/import/import-way/group-commit-manual/). | | sink.enable-delete | TRUE | N | Whether to enable delete. This option requires the Doris table to enable the batch delete function (Doris 0.15+ version is enabled by default), and only supports the Unique model. | | sink.enable-2pc | TRUE | N | Whether to enable two-phase commit (2pc), the default is true, to ensure Exactly-Once semantics. For two-phase commit, please refer to [here](../data-operate/import/stream-load-manual.md). | | sink.buffer-size | 1MB | N | The size of the write data cache buffer, in bytes. It is not recommended to modify, the default configuration is enough | diff --git a/versioned_docs/version-1.2/ecosystem/kettle.md b/versioned_docs/version-1.2/ecosystem/kettle.md index 93c6886d27214..8840a22b715d0 100644 --- a/versioned_docs/version-1.2/ecosystem/kettle.md +++ b/versioned_docs/version-1.2/ecosystem/kettle.md @@ -57,9 +57,11 @@ mvn clean package -DskipTests ``` ### Build a job Find Doris Stream Loader in the batch loading in Kettle and build a job + ![create_zh.png](https://raw.githubusercontent.com/apache/doris/refs/heads/master/extension/kettle/images/create.png) Click Start Running the Job to complete data synchronization + ![running_zh.png](https://raw.githubusercontent.com/apache/doris/refs/heads/master/extension/kettle/images/running.png) ### Parameter Description diff --git a/versioned_docs/version-1.2/ecosystem/kyuubi.md b/versioned_docs/version-1.2/ecosystem/kyuubi.md index d2c0afab71f2b..166ef1cdba42d 100644 --- a/versioned_docs/version-1.2/ecosystem/kyuubi.md +++ b/versioned_docs/version-1.2/ecosystem/kyuubi.md @@ -101,16 +101,16 @@ Execute query statement `select * from demo.expamle_tbl;` with query results ret select * from demo.example_tbl 2023-03-07 09:29:14.786 INFO org.apache.kyuubi.operation.ExecuteStatement: Query[bdc59dd0-ceea-4c02-8c3a-23424323f5db] in FINISHED_STATE 2023-03-07 09:29:14.787 INFO org.apache.kyuubi.operation.ExecuteStatement: Processing anonymous's query[bdc59dd0-ceea-4c02-8c3a-23424323f5db]: RUNNING_STATE -> FINISHED_STATE, time taken: 0.015 seconds -+----------+-------------+-------+------+------+------------------------+-------+-----------------+-----------------+ ++----------+-------------+-------+------+------+------------------------+-------+---------------+ | user_id | date | city | age | sex | last_visit_date | cost | max_dwell_time | min_dwell_time | -+----------+-------------+-------+------+------+------------------------+-------+-----------------+-----------------+ ++----------+-------------+-------+------+------+------------------------+-------+---------------+ | 10000 | 2017-10-01 | Beijing | 20 | 0 | 2017-10-01 07:00:00.0 | 70 | 10 | 2 | | 10001 | 2017-10-01 | Beijing | 30 | 1 | 2017-10-01 17:05:45.0 | 4 | 22 | 22 | | 10002 | 2017-10-02 | Shanghai| 20 | 1 | 2017-10-02 12:59:12.0 | 400 | 5 | 5 | | 10003 | 2017-10-02 | Guangzhou| 32 | 0 | 2017-10-02 11:20:00.0 | 60 | 11 | 11 | | 10004 | 2017-10-01 | Shenzhen| 35 | 0 | 2017-10-01 10:00:15.0 | 200 | 3 | 3 | | 10004 | 2017-10-03 | Shenzhen| 35 | 0 | 2017-10-03 10:20:22.0 | 22 | 6 | 6 | -+----------+-------------+-------+------+------+------------------------+-------+-----------------+-----------------+ ++----------+-------------+-------+------+------+------------------------+-------+---------------+ 6 rows selected (0.068 seconds) ``` diff --git a/versioned_docs/version-1.2/ecosystem/logstash.md b/versioned_docs/version-1.2/ecosystem/logstash.md index 87bb3b1bd1659..d81d181fb69ab 100644 --- a/versioned_docs/version-1.2/ecosystem/logstash.md +++ b/versioned_docs/version-1.2/ecosystem/logstash.md @@ -87,8 +87,8 @@ Install successful The configuration for the Logstash Doris output plugin is as follows: -Configuration | Description ---- | --- +Configuration | Description +-------------------- | --------------------------------------------------------- `http_hosts` | Stream Load HTTP address, formatted as a string array, can have one or more elements, each element is host:port. For example: ["http://fe1:8030", "http://fe2:8030"] `user` | Doris username, this user needs to have import permissions for the corresponding Doris database and table `password` | Password for the Doris user diff --git a/versioned_docs/version-1.2/ecosystem/spark-doris-connector.md b/versioned_docs/version-1.2/ecosystem/spark-doris-connector.md index 4d3922071101c..9c21637ee9e08 100644 --- a/versioned_docs/version-1.2/ecosystem/spark-doris-connector.md +++ b/versioned_docs/version-1.2/ecosystem/spark-doris-connector.md @@ -250,8 +250,8 @@ kafkaSource.selectExpr("CAST(key AS STRING)", "CAST(value as STRING)") ### General -| Key | Default Value | Comment | -|----------------------------------|-------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Key | Default Value | Comment | +|----------------------------------|-------------------------|-----------------------------------------------------------------------------------| | doris.fenodes | -- | Doris FE http address, support multiple addresses, separated by commas | | doris.table.identifier | -- | Doris table identifier, eg, db1.tbl1 | | doris.request.retries | 3 | Number of retries to send requests to Doris | @@ -277,8 +277,8 @@ kafkaSource.selectExpr("CAST(key AS STRING)", "CAST(value as STRING)") ### SQL & Dataframe Configuration -| Key | Default Value | Comment | -|---------------------------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Key | Default Value | Comment | +|---------------------------------|------------------------|----------------------------------------------------| | user | -- | Doris username | | password | -- | Doris password | | doris.filter.query.in.max.count | 100 | In the predicate pushdown, the maximum number of elements in the in expression value list. If this number is exceeded, the in-expression conditional filtering is processed on the Spark side. | @@ -292,8 +292,8 @@ kafkaSource.selectExpr("CAST(key AS STRING)", "CAST(value as STRING)") ### RDD Configuration -| Key | Default Value | Comment | -|-----------------------------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------| +| Key | Default Value | Comment | +|-----------------------------|---------------|-------------------------------------------------------------| | doris.request.auth.user | -- | Doris username | | doris.request.auth.password | -- | Doris password | | doris.filter.query | -- | Filter expression of the query, which is transparently transmitted to Doris. Doris uses this expression to complete source-side data filtering. | diff --git a/versioned_docs/version-1.2/install/construct-docker/run-docker-cluster.md b/versioned_docs/version-1.2/install/construct-docker/run-docker-cluster.md index a8778df63ab9a..136a8ddea48a2 100644 --- a/versioned_docs/version-1.2/install/construct-docker/run-docker-cluster.md +++ b/versioned_docs/version-1.2/install/construct-docker/run-docker-cluster.md @@ -78,7 +78,7 @@ From the version of `Apache Doris 1.2.1 Docker Image`, the interface list of eac | process name | interface name | interface definition | interface example | | -------------- |-------------| ------------------- | -------------------------------------------------------------- | -| FE\BE\BROKER | FE_SERVERS | FE node main information | fe1:172.20.80.2:9010,fe2:172.20.80.3:9010,fe3:172.20.80.4:9010 | +| `FE\BE\BROKER` | FE_SERVERS | FE node main information | fe1:172.20.80.2:9010,fe2:172.20.80.3:9010,fe3:172.20.80.4:9010 | | FE | FE_ID | FE node ID | 1 | | BE | BE_ADDR | BE node main information | 172.20.80.5:9050 | | BE | NODE_ROLE | BE node type | computation | diff --git a/versioned_docs/version-1.2/install/standard-deployment.md b/versioned_docs/version-1.2/install/standard-deployment.md index 5129b7ba4ce2e..e48d51cea8227 100644 --- a/versioned_docs/version-1.2/install/standard-deployment.md +++ b/versioned_docs/version-1.2/install/standard-deployment.md @@ -114,17 +114,17 @@ Broker is a process for accessing external data sources, such as hdfs. Usually, Doris instances communicate directly over the network. The following table shows all required ports. -| Instance Name | Port Name | Default Port | Communication Direction | Description| -| ---|---|---|---|---| -| BE | be_port | 9060 | FE --> BE | Thrift server port on BE for receiving requests from FE | -| BE | webserver\_port | 8040 | BE <--> BE | HTTP server port on BE | -| BE | heartbeat\_service_port | 9050 | FE --> BE | Heart beat service port (thrift) on BE, used to receive heartbeat from FE | -| BE | brpc\_port | 8060 | FE <--> BE, BE <--> BE | BRPC port on BE for communication between BEs | -| FE | http_port | 8030 | FE <--> FE, user <--> FE | HTTP server port on FE | -| FE | rpc_port | 9020 | BE --> FE, FE <--> FE | Thrift server port on FE; The configurations of each FE should be consistent. | -| FE | query_port | 9030 | user <--> FE | MySQL server port on FE | -| FE | edit\_log_port | 9010 | FE <--> FE | Port on FE for BDBJE communication | -| Broker | broker ipc_port | 8000 | FE --> Broker, BE --> Broker | Thrift server port on Broker for receiving requests | +| Instance Name | Port Name | Default Port | Communication Direction | Description | +| --------------|-------------------------|--------------|------------------------------|-------------------------------------------------------------------------------| +| BE | be_port | 9060 | FE --> BE | Thrift server port on BE for receiving requests from FE | +| BE | webserver\_port | 8040 | BE <--> BE | HTTP server port on BE | +| BE | heartbeat\_service_port | 9050 | FE --> BE | Heart beat service port (thrift) on BE, used to receive heartbeat from FE | +| BE | brpc\_port | 8060 | FE <--> BE, BE <--> BE | BRPC port on BE for communication between BEs | +| FE | http_port | 8030 | FE <--> FE, user <--> FE | HTTP server port on FE | +| FE | rpc_port | 9020 | BE --> FE, FE <--> FE | Thrift server port on FE; The configurations of each FE should be consistent. | +| FE | query_port | 9030 | user <--> FE | MySQL server port on FE | +| FE | edit\_log_port | 9010 | FE <--> FE | Port on FE for BDBJE communication | +| Broker | broker ipc_port | 8000 | FE --> Broker, BE --> Broker | Thrift server port on Broker for receiving requests | > Note: > @@ -231,11 +231,13 @@ See the `lower_case_table_names` section in [Variables](../advanced/variables.md * Set JAVA_HOME environment variable + Java UDF is supported since version 1.2, so BEs are dependent on the Java environment. It is necessary to set the `JAVA_HOME` environment variable before starting. You can also do this by adding `export JAVA_HOME=your_java_home_path` to the first line of the `start_be.sh` startup script. * Install Java UDF + Because Java UDF is supported since version 1.2, you need to download the JAR package of Java UDF from the official website and put them under the lib directory of BE, otherwise it may fail to start. * Add all BE nodes to FE diff --git a/versioned_docs/version-1.2/lakehouse/external-table/es.md b/versioned_docs/version-1.2/lakehouse/external-table/es.md index f6f6594b7609b..7cc264bf11001 100644 --- a/versioned_docs/version-1.2/lakehouse/external-table/es.md +++ b/versioned_docs/version-1.2/lakehouse/external-table/es.md @@ -175,18 +175,18 @@ Operators will be converted into ES queries as follows: ##### Data Type Mapping -| Doris\ES | byte | short | integer | long | float | double | keyword | text | date | -| -------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | -| tinyint | √ | | | | | | | | | -| smallint | √ | √ | | | | | | | | -| int | √ | √ | √ | | | | | | | -| bigint | √ | √ | √ | √ | | | | | | -| float | | | | | √ | | | | | -| double | | | | | | √ | | | | -| char | | | | | | | √ | √ | | -| varchar | | | | | | | √ | √ | | -| date | | | | | | | | | √ | -| datetime | | | | | | | | | √ | +| Doris vs ES | byte | short | integer | long | float | double | keyword | text | date | +| ----------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | +| tinyint | √ | | | | | | | | | +| smallint | √ | √ | | | | | | | | +| int | √ | √ | √ | | | | | | | +| bigint | √ | √ | √ | √ | | | | | | +| float | | | | | √ | | | | | +| double | | | | | | √ | | | | +| char | | | | | | | √ | √ | | +| varchar | | | | | | | √ | √ | | +| date | | | | | | | | | √ | +| datetime | | | | | | | | | √ | ### Improve Query Speed by Enabling Columnar Scan (enable\_docvalue\_scan=true) diff --git a/versioned_docs/version-1.2/lakehouse/external-table/jdbc.md b/versioned_docs/version-1.2/lakehouse/external-table/jdbc.md index ef8684397676f..5838363c49862 100644 --- a/versioned_docs/version-1.2/lakehouse/external-table/jdbc.md +++ b/versioned_docs/version-1.2/lakehouse/external-table/jdbc.md @@ -36,7 +36,7 @@ Please use [JDBC Catalog](https://doris.apache.org/docs/dev/lakehouse/multi-cata By creating JDBC External Tables, Doris can access external tables via JDBC, the standard database access inferface. This allows Doris to visit various databases without tedious data ingestion, and give full play to its own OLAP capabilities to perform data analysis on external tables: -::tip Tips +:::tip Tips This feature is supported since the Apache Doris 1.2 version ::: diff --git a/versioned_docs/version-1.2/lakehouse/file.md b/versioned_docs/version-1.2/lakehouse/file.md index a7d7be206d320..b50c15238df18 100644 --- a/versioned_docs/version-1.2/lakehouse/file.md +++ b/versioned_docs/version-1.2/lakehouse/file.md @@ -136,15 +136,15 @@ SELECT * FROM s3( "Format" = "parquet", "use_path_style"="true") LIMIT 5; -+-----------+------------------------------------------+----------------+----------+-------------------------+--------+-------------+---------------+---------------------+ ++-----------+------------------------------------------+----------------+----------+----------------+ | p_partkey | p_name | p_mfgr | p_brand | p_type | p_size | p_container | p_retailprice | p_comment | -+-----------+------------------------------------------+----------------+----------+-------------------------+--------+-------------+---------------+---------------------+ ++-----------+------------------------------------------+----------------+----------+----------------+ | 1 | goldenrod lavender spring chocolate lace | Manufacturer#1 | Brand#13 | PROMO BURNISHED COPPER | 7 | JUMBO PKG | 901 | ly. slyly ironi | | 2 | blush thistle blue yellow saddle | Manufacturer#1 | Brand#13 | LARGE BRUSHED BRASS | 1 | LG CASE | 902 | lar accounts amo | | 3 | spring green yellow purple cornsilk | Manufacturer#4 | Brand#42 | STANDARD POLISHED BRASS | 21 | WRAP CASE | 903 | egular deposits hag | | 4 | cornflower chocolate smoke green pink | Manufacturer#3 | Brand#34 | SMALL PLATED BRASS | 14 | MED DRUM | 904 | p furiously r | | 5 | forest brown coral puff cream | Manufacturer#3 | Brand#32 | STANDARD POLISHED TIN | 15 | SM PKG | 905 | wake carefully | -+-----------+------------------------------------------+----------------+----------+-------------------------+--------+-------------+---------------+---------------------+ ++-----------+------------------------------------------+----------------+----------+----------------+ ``` You can put the Table Value Function anywhere that you used to put Table in the SQL, such as in the WITH or FROM clause in CTE. In this way, you can treat the file as a normal table and conduct analysis conveniently. diff --git a/versioned_docs/version-1.2/lakehouse/filecache.md b/versioned_docs/version-1.2/lakehouse/filecache.md index 18312e1a244d4..bc2370f5735cd 100644 --- a/versioned_docs/version-1.2/lakehouse/filecache.md +++ b/versioned_docs/version-1.2/lakehouse/filecache.md @@ -57,13 +57,13 @@ SET GLOBAL enable_file_cache = true; ### Configurations for BE Add settings to the BE node's configuration file `conf/be.conf`, and restart the BE node for the configuration to take effect. -| Parameter | Description | -| --- | --- | -| `enable_file_cache` | Whether to enable File Cache, default false | +| Parameter | Description | +| --------------------------------- | -------------------------------------------------------------------- | +| `enable_file_cache` | Whether to enable File Cache, default false | | `file_cache_max_file_segment_size` | Max size of a single cached block, default 4MB, should greater than 4096 | -| `file_cache_path` | Parameters about cache path, json format, for exmaple: `[{"path": "/path/to/file_cache1", "total_size":53687091200,"query_limit": "10737418240"},{"path": "/path/to/file_cache2", "total_size":53687091200,"query_limit": "10737418240"},{"path": "/path/to/file_cache3", "total_size":53687091200,"query_limit": "10737418240"}]`. `path` is the path to save cached data; `total_size` is the max size of cached data; `query_limit` is the max size of cached data for a single query. | -| `enable_file_cache_query_limit` | Whether to limit the cache size used by a single query, default false | -| `clear_file_cache` | Whether to delete the previous cache data when the BE restarts, default false | +| `file_cache_path` | Parameters about cache path, json format, for exmaple: `[{"path": "/path/to/file_cache1", "total_size":53687091200,"query_limit": "10737418240"},{"path": "/path/to/file_cache2", "total_size":53687091200,"query_limit": "10737418240"},{"path": "/path/to/file_cache3", "total_size":53687091200,"query_limit": "10737418240"}]`. `path` is the path to save cached data; `total_size` is the max size of cached data; `query_limit` is the max size of cached data for a single query. | +| `enable_file_cache_query_limit` | Whether to limit the cache size used by a single query, default false | +| `clear_file_cache` | Whether to delete the previous cache data when the BE restarts, default false | ## Check whether a query hits cache diff --git a/versioned_docs/version-1.2/lakehouse/multi-catalog/es.md b/versioned_docs/version-1.2/lakehouse/multi-catalog/es.md index 88ecc372cd4dc..aa62d58406b4c 100644 --- a/versioned_docs/version-1.2/lakehouse/multi-catalog/es.md +++ b/versioned_docs/version-1.2/lakehouse/multi-catalog/es.md @@ -50,17 +50,17 @@ After switching to the ES Catalog, you will be in the `dafault_db` so you don't ### Parameter Description -| Parameter | Required or Not | Default Value | Description | -| ----------------- | --------------- | ------------- |---------------------------------------------------------------------------------------------------------------------------------------------------| -| `hosts` | Yes | | ES address, can be one or multiple addresses, or the load balancer address of ES | -| `user` | No | Empty | ES username | -| `password` | No | Empty | Password of the corresponding user | -| `doc_value_scan` | No | true | Whether to obtain value of the target field by ES/Lucene columnar storage | -| `keyword_sniff` | No | true | Whether to sniff the text.fields in ES based on keyword; If this is set to false, the system will perform matching after tokenization. | -| `nodes_discovery` | No | true | Whether to enable ES node discovery, set to true by default; set to false in network isolation environments and only connected to specified nodes | -| `ssl` | No | false | Whether to enable HTTPS access mode for ES, currently follows a "Trust All" method in FE/BE | -| `mapping_es_id` | No | false | Whether to map the `_id` field in the ES index | -| `like_push_down` | No | true | Whether to transform like to wildcard push down to es, this increases the cpu consumption of the es. | +| Parameter | Required or Not | Default Value | Description | +| -------------------------------- | ----------------------------- | -------------------- |---------------------------------------------------------------------------------| +| `hosts` | Yes | | ES address, can be one or multiple addresses, or the load balancer address of ES | +| `user` | No | Empty | ES username | +| `password` | No | Empty | Password of the corresponding user | +| `doc_value_scan` | No | true | Whether to obtain value of the target field by ES/Lucene columnar storage | +| `keyword_sniff` | No | true | Whether to sniff the text.fields in ES based on keyword; If this is set to false, the system will perform matching after tokenization. | +| `nodes_discovery` | No | true | Whether to enable ES node discovery, set to true by default; set to false in network isolation environments and only connected to specified nodes | +| `ssl` | No | false | Whether to enable HTTPS access mode for ES, currently follows a "Trust All" method in FE/BE | +| `mapping_es_id` | No | false | Whether to map the `_id` field in the ES index | +| `like_push_down` | No | true | Whether to transform like to wildcard push down to es, this increases the cpu consumption of the es. | > 1. In terms of authentication, only HTTP Basic authentication is supported and it requires the user to have read privilege for the index and paths including `/_cluster/state/` and `_nodes/http` ; if you have not enabled security authentication for the cluster, you don't need to set the `user` and `password`. > diff --git a/versioned_docs/version-1.2/lakehouse/multi-catalog/jdbc.md b/versioned_docs/version-1.2/lakehouse/multi-catalog/jdbc.md index 4c184a7ed96cb..fa0c8286c583a 100644 --- a/versioned_docs/version-1.2/lakehouse/multi-catalog/jdbc.md +++ b/versioned_docs/version-1.2/lakehouse/multi-catalog/jdbc.md @@ -120,12 +120,12 @@ Once connected, Doris will ingest metadata of databases and tables from the exte ```sql CREATE CATALOG sqlserver_catalog PROPERTIES ( - "type"="jdbc", - "user"="SA", - "password"="Doris123456", - "jdbc_url" = "jdbc:sqlserver://localhost:1433;DataBaseName=doris_test", - "driver_url" = "mssql-jdbc-11.2.3.jre8.jar", - "driver_class" = "com.microsoft.sqlserver.jdbc.SQLServerDriver" + "type"="jdbc", + "user"="SA", + "password"="Doris123456", + "jdbc_url" = "jdbc:sqlserver://localhost:1433;DataBaseName=doris_test", + "driver_url" = "mssql-jdbc-11.2.3.jre8.jar", + "driver_class" = "com.microsoft.sqlserver.jdbc.SQLServerDriver" ); ``` @@ -325,8 +325,8 @@ The transaction mechanism ensures the atomicity of data writing to JDBC External ### PostgreSQL - POSTGRESQL Type | Doris Type | Comment | -|---|---|---| + POSTGRESQL Type | Doris Type | Comment | +|-----------------------------------------|------------|---------------------------------------------------------| | boolean | BOOLEAN | | | smallint/int2 | SMALLINT | | | integer/int4 | INT | | @@ -351,8 +351,8 @@ The transaction mechanism ensures the atomicity of data writing to JDBC External ### Oracle -| ORACLE Type | Doris Type | Comment | -| ----------------------------- | ----------- | ------------------------------------------------------------ | +| ORACLE Type | Doris Type | Comment | +| ----------------------------- | ------------------------------------ | ----------------------------------------------------| | number(p) / number(p,0) | TINYINT/SMALLINT/INT/BIGINT/LARGEINT | Doris will determine the type to map to based on the value of p: `p < 3` -> `TINYINT`; `p < 5` -> `SMALLINT`; `p < 10` -> `INT`; `p < 19` -> `BIGINT`; `p > 19` -> `LARGEINT` | | number(p,s), [ if(s>0 && p>s) ] | DECIMAL(p,s) | | | number(p,s), [ if(s>0 && p < s) ] | DECIMAL(s,s) | | @@ -390,8 +390,8 @@ The transaction mechanism ensures the atomicity of data writing to JDBC External ### Clickhouse -| ClickHouse Type | Doris Type | Comment | -|------------------------------------------------------|--------------------------|--------------------------------------------------------------------------------------------------------------------------------------| +| ClickHouse Type | Doris Type | Comment | +|------------------------------------------------------|--------------------------|--------------------------------------------------| | Bool | BOOLEAN | | | String | STRING | | | Date/Date32 | DATEV2 | JDBC CATLOG uses Datev2 type default when connecting ClickHouse | @@ -411,8 +411,8 @@ The transaction mechanism ensures the atomicity of data writing to JDBC External ### Doris -| Doris Type | Jdbc Catlog Doris Type | Comment | -|---|---|---| +| Doris Type | Jdbc Catlog Doris Type | Comment | +|---------------------|---------------------------|---------------------------------------------| | BOOLEAN | BOOLEAN | | | TINYINT | TINYINT | | | SMALLINT | SMALLINT | | @@ -434,8 +434,8 @@ The transaction mechanism ensures the atomicity of data writing to JDBC External ### SAP HANA -| SAP HANA Type | Doris Type | Comment | -|---------------|--------------------------|--------------------------------------------------------------------------------------------------------------------| +| SAP HANA Type | Doris Type | Comment | +|---------------|--------------------------|-----------------------------------------------------------------------| | BOOLEAN | BOOLEAN | | | TINYINT | TINYINT | | | SMALLINT | SMALLINT | | @@ -459,8 +459,8 @@ The transaction mechanism ensures the atomicity of data writing to JDBC External ### Trino -| Trino Type | Doris Type | Comment | -|------------------------------------------------------|--------------------------|--------------------------------------------------------------------------------------------------------------------| +| Trino Type | Doris Type | Comment | +|-------------------------|--------------------------|-----------------------------------------------------------------------------| | boolean | BOOLEAN | | | tinyint | TINYINT | | | smallint | SMALLINT | | diff --git a/versioned_docs/version-1.2/query-acceleration/join-optimization/bucket-shuffle-join.md b/versioned_docs/version-1.2/query-acceleration/join-optimization/bucket-shuffle-join.md index a01e3f3d99443..0c99a53758520 100644 --- a/versioned_docs/version-1.2/query-acceleration/join-optimization/bucket-shuffle-join.md +++ b/versioned_docs/version-1.2/query-acceleration/join-optimization/bucket-shuffle-join.md @@ -84,11 +84,11 @@ The session variable is set to `true` by default in version 0.14, while it needs You can use the `explain` command to check whether the join is a Bucket Shuffle Join ```sql -| 2:HASH JOIN | -| | join op: INNER JOIN (BUCKET_SHUFFLE) | -| | hash predicates: | -| | colocate: false, reason: table not in the same group | -| | equal join conjunct: `test`.`k1` = `baseall`.`k1` +| 2:HASH JOIN | +| | join op: INNER JOIN (BUCKET_SHUFFLE) | +| | hash predicates: | +| | colocate: false, reason: table not in the same group | +| | equal join conjunct: `test`.`k1` = `baseall`.`k1` | ``` The join type indicates that the join method to be used is:`BUCKET_SHUFFLE`。 diff --git a/versioned_docs/version-1.2/query-acceleration/join-optimization/colocation-join.md b/versioned_docs/version-1.2/query-acceleration/join-optimization/colocation-join.md index 15357c291366f..30d3e7e70d5f3 100644 --- a/versioned_docs/version-1.2/query-acceleration/join-optimization/colocation-join.md +++ b/versioned_docs/version-1.2/query-acceleration/join-optimization/colocation-join.md @@ -419,7 +419,8 @@ The API is implemented on the FE side and accessed using `fe_host: fe_http_port` POST /api/colocate/bucketseq?db_id=10005&group_id=10008 Body: - [[10004,10002],[10003,10002],[10002,10004],[10003,10002],[10002,10004],[10003,10002],[10003,10004],[10003,10004],[10003,10004],[10002,10004]] + [[10004,10002],[10003,10002],[10002,10004],[10003,10002],[10002,10004],[10003,10002], + [10003,10004],[10003,10004],[10003,10004],[10002,10004]] Returns: 200 ``` diff --git a/versioned_docs/version-1.2/query-acceleration/materialized-view.md b/versioned_docs/version-1.2/query-acceleration/materialized-view.md index 2be07d7e97d15..3e357cbc28db4 100644 --- a/versioned_docs/version-1.2/query-acceleration/materialized-view.md +++ b/versioned_docs/version-1.2/query-acceleration/materialized-view.md @@ -188,15 +188,15 @@ The table structure of this `sales_records` is as follows: ``` MySQL [test]> desc sales_records; -+-----------+--------+------+-------+---------+--- ----+ -| Field | Type | Null | Key | Default | Extra | -+-----------+--------+------+-------+---------+--- ----+ -| record_id | INT | Yes | true | NULL | | -| seller_id | INT | Yes | true | NULL | | -| store_id | INT | Yes | true | NULL | | -| sale_date | DATE | Yes | false | NULL | NONE | -| sale_amt | BIGINT | Yes | false | NULL | NONE | -+-----------+--------+------+-------+---------+--- ----+ ++-----------+--------+------+-------+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++-----------+--------+------+-------+---------+-------+ +| record_id | INT | Yes | true | NULL | | +| seller_id | INT | Yes | true | NULL | | +| store_id | INT | Yes | true | NULL | | +| sale_date | DATE | Yes | false | NULL | NONE | +| sale_amt | BIGINT | Yes | false | NULL | NONE | ++-----------+--------+------+-------+---------+-------+ ``` At this time, if the user often performs an analysis query on the sales volume of different stores, you can create a materialized view for the `sales_records` table to group the sales stores and sum the sales of the same sales stores. The creation statement is as follows: @@ -223,11 +223,11 @@ SHOW ALTER TABLE MATERIALIZED VIEW FROM db_name; (Version 0.13) In this command, `db_name` is a parameter, you need to replace it with your real db name. The result of the command is to display all the tasks of creating a materialized view of this db. The results are as follows: ``` -+-------+---------------+---------------------+--- ------------------+---------------+--------------- --+----------+---------------+-----------+-------- -------------------------------------------------- -------------------------------------------------- -------------+----------+---------+ ++-------+-----------+------------+--------------+---------------+-----------------+----------+ | JobId | TableName | CreateTime | FinishedTime | BaseIndexName | RollupIndexName | RollupId | TransactionId | State | Msg | Progress | Timeout | -+-------+---------------+---------------------+--- ------------------+---------------+--------------- --+----------+---------------+-----------+-------- -------------------------------------------------- -------------------------------------------------- -------------+----------+---------+ ++-------+---------------+---------------------+---------------------+---------------+--------- | 22036 | sales_records | 2020-07-30 20:04:28 | 2020-07-30 20:04:57 | sales_records | store_amt | 22037 | 5008 | FINISHED | | NULL | 86400 | -+-------+---------------+---------------------+--- ------------------+---------------+--------------- --+----------+---------------+-----------+-------- ---------------------------------------- ++-------+---------------+---------------------+---------------------+---------------+--------- ``` @@ -353,9 +353,9 @@ MySQL [test]> desc advertiser_view_record; ``` MySQL [test]> desc advertiser_view_record all; - +------------------------+---------------+----------------------+-------------+------+-------+---------+--------------+ + +------------------------+---------------+----------------------+-------------+------+-----+ | IndexName | IndexKeysType | Field | Type | Null | Key | Default | Extra | - +------------------------+---------------+----------------------+-------------+------+-------+---------+--------------+ + +------------------------+---------------+----------------------+-------------+------+-----+ | advertiser_view_record | DUP_KEYS | time | DATE | Yes | true | NULL | | | | | advertiser | VARCHAR(10) | Yes | true | NULL | | | | | channel | VARCHAR(10) | Yes | false | NULL | NONE | @@ -364,7 +364,7 @@ MySQL [test]> desc advertiser_view_record; | advertiser_uv | AGG_KEYS | advertiser | VARCHAR(10) | Yes | true | NULL | | | | | channel | VARCHAR(10) | Yes | true | NULL | | | | | to_bitmap(`user_id`) | BITMAP | No | false | | BITMAP_UNION | - +------------------------+---------------+----------------------+-------------+------+-------+---------+--------------+ + +------------------------+---------------+----------------------+-------------+------+-----+ ``` 2. Automatic query matching @@ -383,59 +383,66 @@ MySQL [test]> desc advertiser_view_record; Through the EXPLAIN command, you can check whether Doris matches the materialized view: - ```sql - mysql [test]>explain SELECT advertiser, channel, count(distinct user_id) FROM advertiser_view_record GROUP BY advertiser, channel; - +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | Explain String | - +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | PLAN FRAGMENT 0 | - | OUTPUT EXPRS: | - | `default_cluster:test`.`advertiser_view_record`.`mv_advertiser` | - | `default_cluster:test`.`advertiser_view_record`.`mv_channel` | - | bitmap_union_count(`default_cluster:test`.`advertiser_view_record`.`mva_BITMAP_UNION__to_bitmap_with_check(`user_id`)`) | - | PARTITION: UNPARTITIONED | - | | - | VRESULT SINK | - | | - | 4:VEXCHANGE | - | offset: 0 | - | | - | PLAN FRAGMENT 1 | - | | - | PARTITION: HASH_PARTITIONED: `default_cluster:test`.`advertiser_view_record`.`mv_advertiser`, `default_cluster:test`.`advertiser_view_record`.`mv_channel` | - | | - | STREAM DATA SINK | - | EXCHANGE ID: 04 | - | UNPARTITIONED | - | | - | 3:VAGGREGATE (merge finalize) | - | | output: bitmap_union_count( bitmap_union_count(`default_cluster:test`.`advertiser_view_record`.`mva_BITMAP_UNION__to_bitmap_with_check(`user_id`)`)) | - | | group by: `default_cluster:test`.`advertiser_view_record`.`mv_advertiser`, `default_cluster:test`.`advertiser_view_record`.`mv_channel` | - | | cardinality=-1 | - | | | - | 2:VEXCHANGE | - | offset: 0 | - | | - | PLAN FRAGMENT 2 | - | | - | PARTITION: HASH_PARTITIONED: `default_cluster:test`.`advertiser_view_record`.`time` | - | | - | STREAM DATA SINK | - | EXCHANGE ID: 02 | - | HASH_PARTITIONED: `default_cluster:test`.`advertiser_view_record`.`mv_advertiser`, `default_cluster:test`.`advertiser_view_record`.`mv_channel` | - | | - | 1:VAGGREGATE (update serialize) | - | | STREAMING | - | | output: bitmap_union_count(`default_cluster:test`.`advertiser_view_record`.`mva_BITMAP_UNION__to_bitmap_with_check(`user_id`)`) | - | | group by: `default_cluster:test`.`advertiser_view_record`.`mv_advertiser`, `default_cluster:test`.`advertiser_view_record`.`mv_channel` | - | | cardinality=-1 | - | | | - | 0:VOlapScanNode | - | TABLE: default_cluster:test.advertiser_view_record(advertiser_uv), PREAGGREGATION: ON | - | partitions=1/1, tablets=10/10, tabletList=50075,50077,50079 ... | - | cardinality=0, avgRowSize=48.0, numNodes=1 | - +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - ``` +```sql +mysql [test]>explain SELECT advertiser, channel, count(distinct user_id) FROM advertiser_view_record GROUP BY advertiser, channel; + +--------------------------------------------------------------------------------------------+ + | Explain String | + +--------------------------------------------------------------------------------------------+ + | PLAN FRAGMENT 0 | + | OUTPUT EXPRS: | + | `default_cluster:test`.`advertiser_view_record`.`mv_advertiser` | + | `default_cluster:test`.`advertiser_view_record`.`mv_channel` | + | bitmap_union_count(`default_cluster:test`.`advertiser_view_record`. | + | `mva_BITMAP_UNION__to_bitmap_with_check(`user_id`)`) | + | PARTITION: UNPARTITIONED | + | | + | VRESULT SINK | + | | + | 4:VEXCHANGE | + | offset: 0 | + | | + | PLAN FRAGMENT 1 | + | | + | PARTITION: HASH_PARTITIONED: `default_cluster:test`.`advertiser_view_record` | + | .`mv_advertiser`, `default_cluster:test`.`advertiser_view_record`.`mv_channel` | + | | + | STREAM DATA SINK | + | EXCHANGE ID: 04 | + | UNPARTITIONED | + | | + | 3:VAGGREGATE (merge finalize) | + | | output: bitmap_union_count( bitmap_union_count(`default_cluster:test`. | + | `advertiser_view_record`.`mva_BITMAP_UNION__to_bitmap_with_check(`user_id`)`)) | + | | group by: `default_cluster:test`.`advertiser_view_record`.`mv_advertiser`, | + | `default_cluster:test`.`advertiser_view_record`.`mv_channel` | + | | cardinality=-1 | + | | | + | 2:VEXCHANGE | + | offset: 0 | + | | + | PLAN FRAGMENT 2 | + | | + | PARTITION: HASH_PARTITIONED: `default_cluster:test`.`advertiser_view_record`.`time` | + | | + | STREAM DATA SINK | + | EXCHANGE ID: 02 | + | HASH_PARTITIONED: `default_cluster:test`.`advertiser_view_record` | + | .`mv_advertiser`, `default_cluster:test`.`advertiser_view_record`.`mv_channel`| + | | + | 1:VAGGREGATE (update serialize) | + | | STREAMING | + | | output: bitmap_union_count(`default_cluster:test`.`advertiser_view_record`. | + | `mva_BITMAP_UNION__to_bitmap_with_check(`user_id`)`) | + | | group by: `default_cluster:test`.`advertiser_view_record`.`mv_advertiser`, | + | `default_cluster:test`.`advertiser_view_record`.`mv_channel` | + | | cardinality=-1 | + | | | + | 0:VOlapScanNode | + | TABLE: default_cluster:test.advertiser_view_record(advertiser_uv), PREAGGREGATION: ON | + | partitions=1/1, tablets=10/10, tabletList=50075,50077,50079 ... | + | cardinality=0, avgRowSize=48.0, numNodes=1 | + +--------------------------------------------------------------------------------------------+ +``` In the result of EXPLAIN, you can first see that `VOlapScanNode` hits `advertiser_uv`. That is, the query scans the materialized view's data directly. Indicates that the match is successful. diff --git a/versioned_docs/version-1.2/query-acceleration/slow-query-analysis/get-profile.md b/versioned_docs/version-1.2/query-acceleration/slow-query-analysis/get-profile.md index c5e99af4f5bfd..b6cf7476fbe66 100644 --- a/versioned_docs/version-1.2/query-acceleration/slow-query-analysis/get-profile.md +++ b/versioned_docs/version-1.2/query-acceleration/slow-query-analysis/get-profile.md @@ -74,11 +74,12 @@ We often encounter situations where the execution time of the corresponding SQL --Execute the corresponding Query mysql> select id,name from test.test where name like "%RuO%"; - +---------------------------+-----------------------------------------------------------------------------------------------------------------------------+ - | id | name | - +---------------------------+-----------------------------------------------------------------------------------------------------------------------------+ - | 1ZWXYGbb8nr5Pi29J4cEMyEMb | ZN1nqzBRSl1rTrr99rnX1aplxhRuOUTLw6so7rzjlRQ317gTPxh0dHljmrARDJjH7FjRkJW9c7YuUBmWikq7eNgmFKJPreWirDrGrFzUYH4eP6kDtSA3UTnNIIj | - +---------------------------+-----------------------------------------------------------------------------------------------------------------------------+ + +---------------------------+---------------------------------------------------------------+ + | id | name | + +---------------------------+---------------------------------------------------------------+ + | 1ZWXYGbb8nr5Pi29J4cEMyEMb | ZN1nqzBRSl1rTrr99rnX1aplxhRuOUTLw6so7rzjlRQ317gTPxh0dHljmrARDJ| + | | jH7FjRkJW9c7YuUBmWikq7eNgmFKJPreWirDrGrFzUYH4eP6kDtSA3UTnNIIj | + +---------------------------+---------------------------------------------------------------+ 1 row in set (0.01 sec) ``` @@ -100,12 +101,12 @@ When the cluster cannot access the external network normally, it needs to obtain ``` --Find the Profile ID according to the corresponding query mysql> show query profile "/"; - +-----------------------------------+-----------+---------------------+---------------------+-------+------------+------+------------+-------------------------------------------------------+ + +-----------------------------------+-----------+---------------------+---------------------+ | Profile ID | Task Type | Start Time | End Time | Total | Task State | User | Default Db | Sql Statement | - +-----------------------------------+-----------+---------------------+---------------------+-------+------------+------+------------+-------------------------------------------------------+ + +-----------------------------------+-----------+---------------------+---------------------+ | 1b0bb22689734d30-bbe56e17c2ff21dc | QUERY | 2024-02-28 11:00:17 | 2024-02-28 11:00:17 | 7ms | EOF | root | | select id,name from test.test where name like "%RuO%" | | 202fb174510c4772-965289e8f7f0cf10 | QUERY | 2024-02-25 19:39:20 | 2024-02-25 19:39:20 | 19ms | EOF | root | | select id,name from test.test where name like "%KJ%" | - +-----------------------------------+-----------+---------------------+---------------------+-------+------------+------+------------+-------------------------------------------------------+ + +-----------------------------------+-----------+---------------------+---------------------+ 2 rows in set (0.00 sec) ``` @@ -120,7 +121,7 @@ When the cluster cannot access the external network normally, it needs to obtain 100 1211 0 1211 0 0 168k 0 --:--:-- --:--:-- --:--:-- 168k ``` -- The returned Profile line break is \ \n, which is inconvenient to analyze. You can replace \ \n with \n in a text editing tool. +- The returned Profile line break is `\ \n`, which is inconvenient to analyze. You can replace `\ \n` with `\n` in a text editing tool. ``` [user@VM-10-6-centos profile]$ cat test.profile diff --git a/versioned_docs/version-1.2/releasenotes/v1.1/release-1.1.0.md b/versioned_docs/version-1.2/releasenotes/v1.1/release-1.1.0.md index dd94da6816294..e7bb10faf5abf 100644 --- a/versioned_docs/version-1.2/releasenotes/v1.1/release-1.1.0.md +++ b/versioned_docs/version-1.2/releasenotes/v1.1/release-1.1.0.md @@ -88,11 +88,11 @@ On all 13 SQLs in the SSB test data set, version 1.1 is better than version 0.15 On all 22 SQLs in the TPC-H test data set, version 1.1 is better than version 0.15, the overall performance is improved by about 4.5 times, and the performance of some scenarios is improved by more than ten times; -![](/images/release-note-1.1.0-SSB.png) +![release-note-1.1.0-SSB](/images/release-note-1.1.0-SSB.png)

SSB Benchmark

-![](/images/release-note-1.1.0-TPC-H.png) +![release-note-1.1.0-TPC-H](/images/release-note-1.1.0-TPC-H.png)

TPC-H Benchmark

diff --git a/versioned_docs/version-1.2/releasenotes/v2.0/release-2.0.2.md b/versioned_docs/version-1.2/releasenotes/v2.0/release-2.0.2.md index 3f8e89cddf946..d6c9e0e5a972a 100644 --- a/versioned_docs/version-1.2/releasenotes/v2.0/release-2.0.2.md +++ b/versioned_docs/version-1.2/releasenotes/v2.0/release-2.0.2.md @@ -36,7 +36,7 @@ Thanks to our community users and developers, 489 improvements and bug fixes hav - [Start the script to set metadata_failure_recovery #24308](https://github.com/apache/doris/pull/24308) Move metadata_failure_recovery from fe.conf to start_fe.sh argument to prevent being used unexpectedly. -- [Change ordinary type null value is \N,complex type null value is null #24207](https://github.com/apache/doris/pull/24207) +- [Change ordinary type null value is `\N`,complex type null value is null #24207](https://github.com/apache/doris/pull/24207) - [Optimize priority_ network matching logic for be #23795](https://github.com/apache/doris/pull/23795) - [Fix cancel load failed because Job could not be cancelled… #17730](https://github.com/apache/doris/pull/17730) @@ -121,7 +121,7 @@ Improve performance of MATCH - [Need to call 'set_version' in nested functions #24381](https://github.com/apache/doris/pull/24381) - [windown_funnel compatibility issue with multi backends #24385](https://github.com/apache/doris/pull/24385) - [correlated anti join shouldn't be translated to null aware anti join #24290](https://github.com/apache/doris/pull/24290) -- [Change ordinary type null value is \N,complex type null value is null #24207](https://github.com/apache/doris/pull/24207) +- [Change ordinary type null value is `\N`,complex type null value is null #24207](https://github.com/apache/doris/pull/24207) - [Fix analyze failed when there are thousands of partitions. #24521](https://github.com/apache/doris/pull/24521) - [Do not use enum as the data type for JavaUdfDataType. #24460](https://github.com/apache/doris/pull/24460) - [Fix multi window projection issue temporarily #24568](https://github.com/apache/doris/pull/24568) diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/any_value.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/any-value.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/any_value.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/any-value.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/approx_count_distinct.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/approx-count-distinct.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/approx_count_distinct.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/approx-count-distinct.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/avg_weighted.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/avg-weighted.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/avg_weighted.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/avg-weighted.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/bitmap_union.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/bitmap-union.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/bitmap_union.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/bitmap-union.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/collect_list.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/collect-list.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/collect_list.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/collect-list.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/collect_set.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/collect-set.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/collect_set.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/collect-set.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group_bit_and.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group-bit-and.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group_bit_and.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group-bit-and.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group_bit_or.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group-bit-or.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group_bit_or.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group-bit-or.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group_bit_xor.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group-bit-xor.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group_bit_xor.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group-bit-xor.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group_bitmap_xor.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group-bitmap-xor.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group_bitmap_xor.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group-bitmap-xor.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group_concat.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group-concat.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group_concat.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/group-concat.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/grouping_id.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/grouping-id.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/grouping_id.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/grouping-id.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/grouping.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/grouping.md index 350085cdaf680..981746554abcd 100755 --- a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/grouping.md +++ b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/grouping.md @@ -105,4 +105,4 @@ GROUPING ### Best Practice -See also [GROUPING_ID](./grouping_id.md) +See also [GROUPING_ID](./grouping-id.md) diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/hll_union_agg.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/hll_union_agg.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/max_by.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/max-by.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/max_by.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/max-by.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/min_by.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/min-by.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/min_by.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/min-by.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/percentile_approx.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/percentile-approx.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/percentile_approx.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/percentile-approx.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/percentile_array.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/percentile-array.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/percentile_array.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/percentile-array.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/sequence_count.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/sequence-count.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/sequence_count.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/sequence-count.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/sequence_match.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/sequence-match.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/sequence_match.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/sequence-match.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/stddev_samp.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/stddev-samp.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/stddev_samp.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/stddev-samp.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/topn_array.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/topn-array.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/topn_array.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/topn-array.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/topn_weighted.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/topn-weighted.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/topn_weighted.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/topn-weighted.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/var_samp.md b/versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/var-samp.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/var_samp.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/aggregate-functions/var-samp.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_apply.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-apply.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_apply.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-apply.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_avg.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-avg.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_avg.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-avg.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_compact.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-compact.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_compact.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-compact.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_concat.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-concat.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_concat.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-concat.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_contains.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-contains.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_contains.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-contains.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_cum_sum.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-cum-sum.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_cum_sum.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-cum-sum.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_difference.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-difference.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_difference.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-difference.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_distinct.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-distinct.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_distinct.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-distinct.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_enumerate_uniq.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-enumerate-uniq.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_enumerate_uniq.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-enumerate-uniq.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_enumerate.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-enumerate.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_enumerate.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-enumerate.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_except.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-except.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_except.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-except.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_exists.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-exists.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_exists.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-exists.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_filter.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-filter.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_filter.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-filter.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_first_index.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-first-index.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_first_index.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-first-index.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_intersect.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-intersect.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_intersect.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-intersect.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_join.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-join.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_join.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-join.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_map.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-map.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_map.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-map.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_max.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-max.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_max.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-max.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_min.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-min.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_min.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-min.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_popback.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-popback.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_popback.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-popback.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_popfront.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-popfront.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_popfront.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-popfront.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_position.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-position.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_position.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-position.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_product.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-product.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_product.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-product.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_pushfront.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-pushfront.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_pushfront.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-pushfront.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_range.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-range.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_range.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-range.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_remove.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-remove.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_remove.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-remove.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_reverse_sort.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-reverse-sort.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_reverse_sort.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-reverse-sort.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_shuffle.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-shuffle.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_shuffle.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-shuffle.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_size.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-size.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_size.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-size.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_slice.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-slice.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_slice.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-slice.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_sort.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-sort.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_sort.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-sort.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_sortby.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-sortby.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_sortby.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-sortby.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_sum.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-sum.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_sum.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-sum.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_union.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-union.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_union.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-union.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_with_constant.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-with-constant.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array_with_constant.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/array-with-constant.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/arrays_overlap.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/arrays-overlap.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/arrays_overlap.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/arrays-overlap.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/element_at.md b/versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/element-at.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/element_at.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/array-functions/element-at.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_and_count.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-and-count.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_and_count.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-and-count.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_and_not_count.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-and-not-count.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_and_not_count.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-and-not-count.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_and_not.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-and-not.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_and_not.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-and-not.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_and.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-and.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_and.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-and.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_contains.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-contains.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_contains.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-contains.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_count.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-count.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_count.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-count.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_empty.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-empty.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_empty.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-empty.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_from_array.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-from-array.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_from_array.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-from-array.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_from_string.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-from-string.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_from_string.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-from-string.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_has_all.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-has-all.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_has_all.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-has-all.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_has_any.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-has-any.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_has_any.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-has-any.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-hash.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-hash.md new file mode 100644 index 0000000000000..03f4d1eac8d7a --- /dev/null +++ b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-hash.md @@ -0,0 +1,112 @@ +--- +{ + "title": "bitmap_hash", + "language": "en" +} +--- + + + +## bitmap_hash + +### Name + +BITMAP_HASH + +### Description + +Calculating hash value for what your input and return a BITMAP which contain the hash value. MurMur3 is used for this function because it is high-performance with low collision rate. More important, the MurMur3 distribution is "simili-random"; the Chi-Square distribution test is used to prove it. By the way, Different hardware platforms and different SEED may change the result of MurMur3. For more information about its performance, see [Smhasher](http://rurban.github.io/smhasher/). + +#### Syntax + +`BITMAP BITMAP_HASH()` + +#### Arguments + +`` +any value or expression. + +#### Return Type + +BITMAP + +#### Remarks + +Generally, MurMurHash 32 is friendly to random, short STRING with low collision rate about one-billionth. But for longer STRING, such as your path of system, can cause more frequent collision. If you indexed your system path, you will find a lot of collisions. + +The following two values are the same. + +```sql +SELECT bitmap_to_string(bitmap_hash('/System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/KernelManagement.framework/KernelManagement.tbd')) AS a , + bitmap_to_string(bitmap_hash('/System/Library/PrivateFrameworks/Install.framework/Versions/Current/Resources/es_419.lproj/Architectures.strings')) AS b; +``` + +Here is the result. + +```text ++-----------+-----------+ +| a | b | ++-----------+-----------+ +| 282251871 | 282251871 | ++-----------+-----------+ +``` + +### Example + +If you want to calculate MurMur3 of a certain value, you can + +``` +select bitmap_to_array(bitmap_hash('hello'))[1]; +``` + +Here is the result. + +```text ++-------------------------------------------------------------+ +| %element_extract%(bitmap_to_array(bitmap_hash('hello')), 1) | ++-------------------------------------------------------------+ +| 1321743225 | ++-------------------------------------------------------------+ +``` + +If you want to `count distinct` some columns, using bitmap has higher performance in some scenes. + +```sql +select bitmap_count(bitmap_union(bitmap_hash(`word`))) from `words`; +``` + +Here is the result. + +```text ++-------------------------------------------------+ +| bitmap_count(bitmap_union(bitmap_hash(`word`))) | ++-------------------------------------------------+ +| 33263478 | ++-------------------------------------------------+ +``` + +### Keywords + + BITMAP_HASH,BITMAP + +### Best Practice + +For more information, see also: +- [BITMAP_HASH64](./bitmap-hash64.md) diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_hash64.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-hash64.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_hash64.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-hash64.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_intersect.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-intersect.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_intersect.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-intersect.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_max.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-max.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_max.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-max.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_min.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-min.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_min.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-min.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_not.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-not.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_not.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-not.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_or_count.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-or-count.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_or_count.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-or-count.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_or.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-or.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_or.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-or.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_subset_in_range.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-subset-in-range.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_subset_in_range.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-subset-in-range.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_subset_limit.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-subset-limit.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_subset_limit.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-subset-limit.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_to_array.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-to-array.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_to_array.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-to-array.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_to_string.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-to-string.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_to_string.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-to-string.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_union.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-union.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_union.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-union.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_xor_count.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-xor-count.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_xor_count.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-xor-count.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_xor.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-xor.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_xor.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap-xor.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_hash.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_hash.md deleted file mode 100644 index 7163aeb5a1bd4..0000000000000 --- a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/bitmap_hash.md +++ /dev/null @@ -1,112 +0,0 @@ ---- -{ - "title": "bitmap_hash", - "language": "en" -} ---- - - - -## bitmap_hash - -### Name - -BITMAP_HASH - -### Description - -Calculating hash value for what your input and return a BITMAP which contain the hash value. MurMur3 is used for this function because it is high-performance with low collision rate. More important, the MurMur3 distribution is "simili-random"; the Chi-Square distribution test is used to prove it. By the way, Different hardware platforms and different SEED may change the result of MurMur3. For more information about its performance, see [Smhasher](http://rurban.github.io/smhasher/). - -#### Syntax - -`BITMAP BITMAP_HASH()` - -#### Arguments - -`` -any value or expression. - -#### Return Type - -BITMAP - -#### Remarks - -Generally, MurMurHash 32 is friendly to random, short STRING with low collision rate about one-billionth. But for longer STRING, such as your path of system, can cause more frequent collision. If you indexed your system path, you will find a lot of collisions. - -The following two values are the same. - -```sql -SELECT bitmap_to_string(bitmap_hash('/System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/KernelManagement.framework/KernelManagement.tbd')) AS a , - bitmap_to_string(bitmap_hash('/System/Library/PrivateFrameworks/Install.framework/Versions/Current/Resources/es_419.lproj/Architectures.strings')) AS b; -``` - -Here is the result. - -```text -+-----------+-----------+ -| a | b | -+-----------+-----------+ -| 282251871 | 282251871 | -+-----------+-----------+ -``` - -### Example - -If you want to calculate MurMur3 of a certain value, you can - -``` -select bitmap_to_array(bitmap_hash('hello'))[1]; -``` - -Here is the result. - -```text -+-------------------------------------------------------------+ -| %element_extract%(bitmap_to_array(bitmap_hash('hello')), 1) | -+-------------------------------------------------------------+ -| 1321743225 | -+-------------------------------------------------------------+ -``` - -If you want to `count distinct` some columns, using bitmap has higher performance in some scenes. - -```sql -select bitmap_count(bitmap_union(bitmap_hash(`word`))) from `words`; -``` - -Here is the result. - -```text -+-------------------------------------------------+ -| bitmap_count(bitmap_union(bitmap_hash(`word`))) | -+-------------------------------------------------+ -| 33263478 | -+-------------------------------------------------+ -``` - -### Keywords - - BITMAP_HASH,BITMAP - -### Best Practice - -For more information, see also: -- [BITMAP_HASH64](./bitmap_hash64.md) diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/intersect_count.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/intersect-count.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/intersect_count.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/intersect-count.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal_bitmap_intersect_count.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal-bitmap-intersect-count.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal_bitmap_intersect_count.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal-bitmap-intersect-count.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal_bitmap_intersect.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal-bitmap-intersect.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal_bitmap_intersect.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal-bitmap-intersect.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal_bitmap_union_count.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal-bitmap-union-count.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal_bitmap_union_count.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/orthogonal-bitmap-union-count.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/sub_bitmap.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/sub-bitmap.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/sub_bitmap.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/sub-bitmap.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/to_bitmap.md b/versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/to-bitmap.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/to_bitmap.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/bitmap-functions/to-bitmap.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/convert_tz.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/convert-tz.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/convert_tz.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/convert-tz.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/current_timestamp.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/current-timestamp.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/current_timestamp.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/current-timestamp.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/date_add.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/date-add.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/date_add.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/date-add.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/date_format.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/date-format.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/date_format.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/date-format.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/date_sub.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/date-sub.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/date_sub.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/date-sub.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/date_trunc.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/date-trunc.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/date_trunc.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/date-trunc.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/day_ceil.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/day-ceil.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/day_ceil.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/day-ceil.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/day_floor.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/day-floor.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/day_floor.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/day-floor.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/days_add.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/days-add.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/days_add.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/days-add.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/days_diff.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/days-diff.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/days_diff.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/days-diff.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/days_sub.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/days-sub.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/days_sub.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/days-sub.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/from_days.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/from-days.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/from_days.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/from-days.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/from_unixtime.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/from-unixtime.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/from_unixtime.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/from-unixtime.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/hour_ceil.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/hour-ceil.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/hour_ceil.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/hour-ceil.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/hour_floor.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/hour-floor.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/hour_floor.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/hour-floor.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours_add.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours-add.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours_add.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours-add.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours_diff.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours-diff.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours_diff.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours-diff.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours_sub.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours-sub.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours_sub.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/hours-sub.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/last_day.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/last-day.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/last_day.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/last-day.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/microseconds_add.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/microseconds-add.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/microseconds_add.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/microseconds-add.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/microseconds_sub.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/microseconds-sub.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/microseconds_sub.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/microseconds-sub.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/minute_ceil.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/minute-ceil.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/minute_ceil.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/minute-ceil.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/minute_floor.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/minute-floor.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/minute_floor.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/minute-floor.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes_add.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes-add.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes_add.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes-add.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes_diff.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes-diff.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes_diff.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes-diff.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes_sub.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes-sub.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes_sub.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/minutes-sub.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/month_ceil.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/month-ceil.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/month_ceil.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/month-ceil.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/month_floor.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/month-floor.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/month_floor.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/month-floor.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/months_add.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/months-add.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/months_add.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/months-add.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/months_diff.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/months-diff.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/months_diff.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/months-diff.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/months_sub.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/months-sub.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/months_sub.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/months-sub.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/second_ceil.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/second-ceil.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/second_ceil.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/second-ceil.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/second_floor.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/second-floor.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/second_floor.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/second-floor.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds_add.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds-add.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds_add.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds-add.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds_diff.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds-diff.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds_diff.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds-diff.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds_sub.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds-sub.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds_sub.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/seconds-sub.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/str-to-date.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/str-to-date.md new file mode 100644 index 0000000000000..d21a4b50dc6ff --- /dev/null +++ b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/str-to-date.md @@ -0,0 +1,72 @@ +--- +{ + "title": "str_to_date", + "language": "en" +} +--- + + + +## Str_to_date +### Description +#### Syntax + +`DATETIME STR TWO DATES (VARCHAR STR, VARCHAR format)` + + +Convert STR to DATE type by format specified, if the conversion result does not return NULL. Note that the 'format' parameter specifies the format of the first parameter. + +The `format` supported is consistent with [date_format](date-format.md) + +### example + +``` +mysql> select str_to_date('2014-12-21 12:34:56', '%Y-%m-%d %H:%i:%s'); ++---------------------------------------------------------+ +| str_to_date('2014-12-21 12:34:56', '%Y-%m-%d %H:%i:%s') | ++---------------------------------------------------------+ +| 2014-12-21 12:34:56 | ++---------------------------------------------------------+ + +mysql> select str_to_date('2014-12-21 12:34%3A56', '%Y-%m-%d %H:%i%%3A%s'); ++--------------------------------------------------------------+ +| str_to_date('2014-12-21 12:34%3A56', '%Y-%m-%d %H:%i%%3A%s') | ++--------------------------------------------------------------+ +| 2014-12-21 12:34:56 | ++--------------------------------------------------------------+ + +mysql> select str_to_date('200442 Monday', '%X%V %W'); ++-----------------------------------------+ +| str_to_date('200442 Monday', '%X%V %W') | ++-----------------------------------------+ +| 2004-10-18 | ++-----------------------------------------+ + +mysql> select str_to_date("2020-09-01", "%Y-%m-%d %H:%i:%s"); ++------------------------------------------------+ +| str_to_date('2020-09-01', '%Y-%m-%d %H:%i:%s') | ++------------------------------------------------+ +| 2020-09-01 00:00:00 | ++------------------------------------------------+ +1 row in set (0.01 sec) +``` +### keywords + + STR_TO_DATE,STR,TO,DATE diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/str_to_date.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/str_to_date.md deleted file mode 100644 index 07cca843ecb57..0000000000000 --- a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/str_to_date.md +++ /dev/null @@ -1,72 +0,0 @@ ---- -{ - "title": "str_to_date", - "language": "en" -} ---- - - - -## Str_to_date -### Description -#### Syntax - -`DATETIME STR TWO DATES (VARCHAR STR, VARCHAR format)` - - -Convert STR to DATE type by format specified, if the conversion result does not return NULL. Note that the 'format' parameter specifies the format of the first parameter. - -The `format` supported is consistent with [date_format](date_format.md) - -### example - -``` -mysql> select str_to_date('2014-12-21 12:34:56', '%Y-%m-%d %H:%i:%s'); -+---------------------------------------------------------+ -| str_to_date('2014-12-21 12:34:56', '%Y-%m-%d %H:%i:%s') | -+---------------------------------------------------------+ -| 2014-12-21 12:34:56 | -+---------------------------------------------------------+ - -mysql> select str_to_date('2014-12-21 12:34%3A56', '%Y-%m-%d %H:%i%%3A%s'); -+--------------------------------------------------------------+ -| str_to_date('2014-12-21 12:34%3A56', '%Y-%m-%d %H:%i%%3A%s') | -+--------------------------------------------------------------+ -| 2014-12-21 12:34:56 | -+--------------------------------------------------------------+ - -mysql> select str_to_date('200442 Monday', '%X%V %W'); -+-----------------------------------------+ -| str_to_date('200442 Monday', '%X%V %W') | -+-----------------------------------------+ -| 2004-10-18 | -+-----------------------------------------+ - -mysql> select str_to_date("2020-09-01", "%Y-%m-%d %H:%i:%s"); -+------------------------------------------------+ -| str_to_date('2020-09-01', '%Y-%m-%d %H:%i:%s') | -+------------------------------------------------+ -| 2020-09-01 00:00:00 | -+------------------------------------------------+ -1 row in set (0.01 sec) -``` -### keywords - - STR_TO_DATE,STR,TO,DATE diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/time_round.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/time-round.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/time_round.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/time-round.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/time_to_sec.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/time-to-sec.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/time_to_sec.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/time-to-sec.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/to_date.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/to-date.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/to_date.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/to-date.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/to_days.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/to-days.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/to_days.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/to-days.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/to_monday.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/to-monday.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/to_monday.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/to-monday.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/unix_timestamp.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/unix-timestamp.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/unix_timestamp.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/unix-timestamp.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/utc_timestamp.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/utc-timestamp.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/utc_timestamp.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/utc-timestamp.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks_add.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks-add.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks_add.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks-add.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks_diff.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks-diff.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks_diff.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks-diff.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks_sub.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks-sub.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks_sub.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/weeks-sub.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/year_ceil.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/year-ceil.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/year_ceil.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/year-ceil.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/year_floor.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/year-floor.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/year_floor.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/year-floor.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/years_add.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/years-add.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/years_add.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/years-add.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/years_diff.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/years-diff.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/years_diff.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/years-diff.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/years_sub.md b/versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/years-sub.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/years_sub.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/date-time-functions/years-sub.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/hash-functions/murmur_hash3_32.md b/versioned_docs/version-1.2/sql-manual/sql-functions/hash-functions/murmur-hash3-32.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/hash-functions/murmur_hash3_32.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/hash-functions/murmur-hash3-32.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/hash-functions/murmur_hash3_64.md b/versioned_docs/version-1.2/sql-manual/sql-functions/hash-functions/murmur-hash3-64.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/hash-functions/murmur_hash3_64.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/hash-functions/murmur-hash3-64.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/hll-functions/hll_cardinality.md b/versioned_docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-cardinality.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/hll-functions/hll_cardinality.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-cardinality.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/hll-functions/hll_empty.md b/versioned_docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-empty.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/hll-functions/hll_empty.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-empty.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/hll-functions/hll_hash.md b/versioned_docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-hash.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/hll-functions/hll_hash.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/hll-functions/hll-hash.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/get_json_bigint.md b/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/get-json-bigint.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/get_json_bigint.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/get-json-bigint.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/get_json_double.md b/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/get-json-double.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/get_json_double.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/get-json-double.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/get_json_int.md b/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/get-json-int.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/get_json_int.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/get-json-int.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/get_json_string.md b/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/get-json-string.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/get_json_string.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/get-json-string.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json_array.md b/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json-array.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json_array.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json-array.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json_extract.md b/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json-extract.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json_extract.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json-extract.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json_object.md b/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json-object.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json_object.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json-object.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json_quote.md b/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json-quote.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json_quote.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json-quote.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json-unquote.md b/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json-unquote.md new file mode 100644 index 0000000000000..3be2352e0a426 --- /dev/null +++ b/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json-unquote.md @@ -0,0 +1,83 @@ +--- +{ + "title": "json_unquote", + "language": "en" +} +--- + + + +## json_unquote +### Description +#### Syntax + +`VARCHAR json_ununquote(VARCHAR)` + +This function unquotes a JSON value and returns the result as a utf8mb4 string. If the argument is NULL, it will return NULL. + +Escape sequences within a string as shown in the following table will be recognized. Backslashes will be ignored for all other escape sequences. + +| Escape Sequence | Character Represented by Sequence | +|-------------------|------------------------------------| +| `\"` | A double quote (") character | +| `\b` | A backspace character | +| `\f` | A formfeed character | +| `\n` | A newline (linefeed) character | +| `\r` | A carriage return character | +| `\t` | A tab character | +| `\\` | A backslash (\) character | +| `\uxxxx` | UTF-8 bytes for Unicode value XXXX | + + + +### example + +``` +mysql> SELECT json_unquote('"doris"'); ++-------------------------+ +| json_unquote('"doris"') | ++-------------------------+ +| doris | ++-------------------------+ + +mysql> SELECT json_unquote('[1, 2, 3]'); ++---------------------------+ +| json_unquote('[1, 2, 3]') | ++---------------------------+ +| [1, 2, 3] | ++---------------------------+ + + +mysql> SELECT json_unquote(null); ++--------------------+ +| json_unquote(NULL) | ++--------------------+ +| NULL | ++--------------------+ + +mysql> SELECT json_unquote('"\\ttest"'); ++--------------------------+ +| json_unquote('"\ttest"') | ++--------------------------+ +| test | ++--------------------------+ +``` +### keywords +json,unquote,json_unquote diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json_valid.md b/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json-valid.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json_valid.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json-valid.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json_unquote.md b/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json_unquote.md deleted file mode 100644 index 0b0c7f08ac45b..0000000000000 --- a/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/json_unquote.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -{ - "title": "json_unquote", - "language": "en" -} ---- - - - -## json_unquote -### Description -#### Syntax - -`VARCHAR json_ununquote(VARCHAR)` - -This function unquotes a JSON value and returns the result as a utf8mb4 string. If the argument is NULL, it will return NULL. - -Escape sequences within a string as shown in the following table will be recognized. Backslashes will be ignored for all other escape sequences. - -| Escape Sequence | Character Represented by Sequence | -|-----------------|------------------------------------| -| \" | A double quote (") character | -| \b | A backspace character | -| \f | A formfeed character | -| \n | A newline (linefeed) character | -| \r | A carriage return character | -| \t | A tab character | -| \\ | A backslash (\) character | -| \uxxxx | UTF-8 bytes for Unicode value XXXX | - - - -### example - -``` -mysql> SELECT json_unquote('"doris"'); -+-------------------------+ -| json_unquote('"doris"') | -+-------------------------+ -| doris | -+-------------------------+ - -mysql> SELECT json_unquote('[1, 2, 3]'); -+---------------------------+ -| json_unquote('[1, 2, 3]') | -+---------------------------+ -| [1, 2, 3] | -+---------------------------+ - - -mysql> SELECT json_unquote(null); -+--------------------+ -| json_unquote(NULL) | -+--------------------+ -| NULL | -+--------------------+ - -mysql> SELECT json_unquote('"\\ttest"'); -+--------------------------+ -| json_unquote('"\ttest"') | -+--------------------------+ -| test | -+--------------------------+ -``` -### keywords -json,unquote,json_unquote diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb_exists_path.md b/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb-exists-path.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb_exists_path.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb-exists-path.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb_extract.md b/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb-extract.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb_extract.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb-extract.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb_parse.md b/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb-parse.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb_parse.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb-parse.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb_type.md b/versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb-type.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb_type.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/json-functions/jsonb-type.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/math-functions/round_bankers.md b/versioned_docs/version-1.2/sql-manual/sql-functions/math-functions/round-bankers.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/math-functions/round_bankers.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/math-functions/round-bankers.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/math-functions/running_difference.md b/versioned_docs/version-1.2/sql-manual/sql-functions/math-functions/running-difference.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/math-functions/running_difference.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/math-functions/running-difference.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_angle_sphere.md b/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-angle-sphere.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_angle_sphere.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-angle-sphere.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_angle.md b/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-angle.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_angle.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-angle.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_area.md b/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-area.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_area.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-area.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_asbinary.md b/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-asbinary.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_asbinary.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-asbinary.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_astext.md b/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-astext.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_astext.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-astext.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_azimuth.md b/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-azimuth.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_azimuth.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-azimuth.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_circle.md b/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-circle.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_circle.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-circle.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_contains.md b/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-contains.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_contains.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-contains.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_distance_sphere.md b/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-distance-sphere.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_distance_sphere.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-distance-sphere.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_geometryfromtext.md b/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-geometryfromtext.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_geometryfromtext.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-geometryfromtext.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_geometryfromwkb.md b/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-geometryfromwkb.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_geometryfromwkb.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-geometryfromwkb.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_linefromtext.md b/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-linefromtext.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_linefromtext.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-linefromtext.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_point.md b/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-point.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_point.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-point.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_polygon.md b/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-polygon.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_polygon.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-polygon.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_x.md b/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-x.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_x.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-x.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_y.md b/versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-y.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st_y.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/spatial-functions/st-y.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/append_trailing_char_if_absent.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/append-trailing-char-if-absent.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/append_trailing_char_if_absent.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/append-trailing-char-if-absent.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/bit_length.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/bit-length.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/bit_length.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/bit-length.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/char_length.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/char-length.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/char_length.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/char-length.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/concat_ws.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/concat-ws.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/concat_ws.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/concat-ws.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/convert_to.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/convert-to.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/convert_to.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/convert-to.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/ends_with.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/ends-with.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/ends_with.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/ends-with.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/extract-url-parameter.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/extract-url-parameter.md new file mode 100644 index 0000000000000..ff5d11bf542f6 --- /dev/null +++ b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/extract-url-parameter.md @@ -0,0 +1,52 @@ +--- +{ +"title": "extract_url_parameter", +"language": "en" +} +--- + + + +## extract_url_parameter +### description +#### Syntax + +`VARCHAR extract_url_parameter(VARCHAR url, VARCHAR name)` + + +Returns the value of the "name" parameter in the URL, if present. Otherwise an empty string. +If there are many parameters with this name, the first occurrence is returned. +This function works assuming that the parameter name is encoded in the URL exactly as it was in the passed parameter. + +``` +mysql> SELECT extract_url_parameter ("http://doris.apache.org?k1=aa&k2=bb&test=cc#999", "k2"); ++--------------------------------------------------------------------------------+ +| extract_url_parameter('http://doris.apache.org?k1=aa&k2=bb&test=cc#999', 'k2') | ++--------------------------------------------------------------------------------+ +| bb | ++--------------------------------------------------------------------------------+ +``` + +If you want to get other part of URL, you can use [parse_url](./parse-url.md). + +### keywords + EXTRACT URL PARAMETER diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/extract_url_parameter.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/extract_url_parameter.md deleted file mode 100644 index 196f20e9d31a1..0000000000000 --- a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/extract_url_parameter.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -{ -"title": "extract_url_parameter", -"language": "en" -} ---- - - - -## extract_url_parameter -### description -#### Syntax - -`VARCHAR extract_url_parameter(VARCHAR url, VARCHAR name)` - - -Returns the value of the "name" parameter in the URL, if present. Otherwise an empty string. -If there are many parameters with this name, the first occurrence is returned. -This function works assuming that the parameter name is encoded in the URL exactly as it was in the passed parameter. - -``` -mysql> SELECT extract_url_parameter ("http://doris.apache.org?k1=aa&k2=bb&test=cc#999", "k2"); -+--------------------------------------------------------------------------------+ -| extract_url_parameter('http://doris.apache.org?k1=aa&k2=bb&test=cc#999', 'k2') | -+--------------------------------------------------------------------------------+ -| bb | -+--------------------------------------------------------------------------------+ -``` - -If you want to get other part of URL, you can use [parse_url](./parse_url.md). - -### keywords - EXTRACT URL PARAMETER diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/find_in_set.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/find-in-set.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/find_in_set.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/find-in-set.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/from_base64.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/from-base64.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/from_base64.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/from-base64.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/like/not_like.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/like/not-like.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/like/not_like.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/like/not-like.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/mask/mask_first_n.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/mask/mask-first-n.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/mask/mask_first_n.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/mask/mask-first-n.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/mask/mask_last_n.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/mask/mask-last-n.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/mask/mask_last_n.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/mask/mask-last-n.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/money_format.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/money-format.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/money_format.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/money-format.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/not_null_or_empty.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/not-null-or-empty.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/not_null_or_empty.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/not-null-or-empty.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/null_or_empty.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/null-or-empty.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/null_or_empty.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/null-or-empty.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/parse-url.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/parse-url.md new file mode 100644 index 0000000000000..57b0df80039ed --- /dev/null +++ b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/parse-url.md @@ -0,0 +1,50 @@ +--- +{ + "title": "parse_url", + "language": "en" +} +--- + + + +## parse_url +### description +#### Syntax + +`VARCHAR parse_url(VARCHAR url, VARCHAR name)` + + +From the URL, the field corresponding to name is resolved. The name options are as follows: 'PROTOCOL', 'HOST', 'PATH', 'REF', 'AUTHORITY', 'FILE', 'USERINFO', 'PORT', 'QUERY', and the result is returned. + +### example + +``` +mysql> SELECT parse_url ('https://doris.apache.org/', 'HOST'); ++------------------------------------------------+ +| parse_url('https://doris.apache.org/', 'HOST') | ++------------------------------------------------+ +| doris.apache.org | ++------------------------------------------------+ +``` + +If you want to get parameter in QUERY, you can use [extract_url_parameter](./extract-url-parameter.md). + +### keywords + PARSE URL diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/parse_url.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/parse_url.md deleted file mode 100644 index 1c349b68a8cc6..0000000000000 --- a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/parse_url.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -{ - "title": "parse_url", - "language": "en" -} ---- - - - -## parse_url -### description -#### Syntax - -`VARCHAR parse_url(VARCHAR url, VARCHAR name)` - - -From the URL, the field corresponding to name is resolved. The name options are as follows: 'PROTOCOL', 'HOST', 'PATH', 'REF', 'AUTHORITY', 'FILE', 'USERINFO', 'PORT', 'QUERY', and the result is returned. - -### example - -``` -mysql> SELECT parse_url ('https://doris.apache.org/', 'HOST'); -+------------------------------------------------+ -| parse_url('https://doris.apache.org/', 'HOST') | -+------------------------------------------------+ -| doris.apache.org | -+------------------------------------------------+ -``` - -If you want to get parameter in QUERY, you can use [extract_url_parameter](./extract_url_parameter.md). - -### keywords - PARSE URL diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp_extract_all.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp-extract-all.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp_extract_all.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp-extract-all.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp_extract.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp-extract.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp_extract.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp-extract.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp_replace_one.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp-replace-one.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp_replace_one.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp-replace-one.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp_replace.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp-replace.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp_replace.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/regexp/regexp-replace.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/search/multi_match_any.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/search/multi-match-any.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/search/multi_match_any.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/search/multi-match-any.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/search/multi_search_all_positions.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/search/multi-search-all-positions.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/search/multi_search_all_positions.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/search/multi-search-all-positions.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/split_by_string.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/split-by-string.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/split_by_string.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/split-by-string.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/split_part.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/split-part.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/split_part.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/split-part.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/starts_with.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/starts-with.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/starts_with.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/starts-with.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/sub_replace.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/sub-replace.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/sub_replace.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/sub-replace.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/substring_index.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/substring-index.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/substring_index.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/substring-index.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/to_base64.md b/versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/to-base64.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/to_base64.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/string-functions/to-base64.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-functions/table-functions/iceberg_meta.md b/versioned_docs/version-1.2/sql-manual/sql-functions/table-functions/iceberg-meta.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-functions/table-functions/iceberg_meta.md rename to versioned_docs/version-1.2/sql-manual/sql-functions/table-functions/iceberg-meta.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Load/CREATE-ROUTINE-LOAD.md b/versioned_docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Load/CREATE-ROUTINE-LOAD.md index a5ffb86f453b7..58dafaf8c73e1 100644 --- a/versioned_docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Load/CREATE-ROUTINE-LOAD.md +++ b/versioned_docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Load/CREATE-ROUTINE-LOAD.md @@ -176,7 +176,7 @@ FROM data_source [data_source_properties] | source data | source data example | string to int | strict_mode | result | | ----------- | ------------------- | ------------- | ------------- | ---------------------- | - | null | \N | N/A | true or false | NULL | + | null | `\N` | N/A | true or false | NULL | | not null | aaa or 2000 | NULL | true | invalid data(filtered) | | not null | aaa | NULL | false | NULL | | not null | 1 | 1 | true or false | correct data | @@ -187,7 +187,7 @@ FROM data_source [data_source_properties] | source data | source data example | string to int | strict_mode | result | | ----------- | ------------------- | ------------- | ------------- | ---------------------- | - | null | \N | N/A | true or false | NULL | + | null | `\N` | N/A | true or false | NULL | | not null | aaa | NULL | true | invalid data(filtered) | | not null | aaa | NULL | false | NULL | | not null | 1 or 10 | 1 | true or false | correct data | diff --git a/versioned_docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Load/STREAM-LOAD.md b/versioned_docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Load/STREAM-LOAD.md index 90d8ed47ebcc6..bca1e3d03baf9 100644 --- a/versioned_docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Load/STREAM-LOAD.md +++ b/versioned_docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Load/STREAM-LOAD.md @@ -57,13 +57,13 @@ Parameter introduction: Currently, Doris retains the most recent successful label within 30 minutes. -2. column_separator: used to specify the column separator in the import file, the default is \t. If it is an invisible character, you need to add \x as a prefix and use hexadecimal to represent the separator. +2. column_separator: used to specify the column separator in the import file, the default is `\t`. If it is an invisible character, you need to add `\x` as a prefix and use hexadecimal to represent the separator. - For example, the separator \x01 of the hive file needs to be specified as -H "column_separator:\x01". + For example, the separator `\x01` of the hive file needs to be specified as `-H "column_separator:\x01"`. You can use a combination of multiple characters as column separators. -3. line_delimiter: used to specify the newline character in the imported file, the default is \n. Combinations of multiple characters can be used as newlines. +3. line_delimiter: used to specify the newline character in the imported file, the default is `\n`. Combinations of multiple characters can be used as newlines. 4. columns: used to specify the correspondence between the columns in the import file and the columns in the table. If the column in the source file corresponds exactly to the content in the table, then there is no need to specify the content of this field. @@ -259,7 +259,7 @@ ERRORS: curl --location-trusted -u root -H "label:123" -H "format: json" -T testData http://host:port/api/testDb/testTbl/_stream_load ``` - In order to improve throughput, it supports importing multiple pieces of json data at one time, each line is a json object, and \n is used as a newline by default. You need to set read_json_by_line to true. The json data format is as follows: + In order to improve throughput, it supports importing multiple pieces of json data at one time, each line is a json object, and `\n` is used as a newline by default. You need to set read_json_by_line to true. The json data format is as follows: ``` {"category":"C++","author":"avc","title":"C++ primer","price":89.5} diff --git a/versioned_docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/EXPORT.md b/versioned_docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/EXPORT.md index f3f3014f9799c..1eaa46134453f 100644 --- a/versioned_docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/EXPORT.md +++ b/versioned_docs/version-1.2/sql-manual/sql-reference/Data-Manipulation-Statements/Manipulation/EXPORT.md @@ -69,8 +69,8 @@ illustrate: The following parameters can be specified: - - `column_separator`: Specifies the exported column separator, default is \t. Only single byte is supported. - - `line_delimiter`: Specifies the line delimiter for export, the default is \n. Only single byte is supported. + - `column_separator`: Specifies the exported column separator, default is `\t`. Only single byte is supported. + - `line_delimiter`: Specifies the line delimiter for export, the default is `\n`. Only single byte is supported. - `exec_mem_limit`: Export the upper limit of the memory usage of a single BE node, the default is 2GB, and the unit is bytes. - `timeout`: The timeout period of the export job, the default is 2 hours, the unit is seconds. - `tablet_num_per_task`: The maximum number of tablets each subtask can allocate to scan. @@ -154,7 +154,7 @@ WITH BROKER "broker_name" EXPORT TABLE testTbl TO "file:///home/data/a"; ``` -6. Export all data in the testTbl table to hdfs with invisible character "\x07" as column or row separator. +6. Export all data in the testTbl table to hdfs with invisible character `"\x07"` as column or row separator. ```sql EXPORT TABLE testTbl TO "hdfs://hdfs_host:port/a/b/c" @@ -175,7 +175,7 @@ WITH BROKER "broker_name" EXPORT TABLE testTbl TO "file:///home/data/a" PROPERTIES ("columns" = "k1,v1"); ``` -8. Export all data in the testTbl table to s3 with invisible characters "\x07" as column or row separators. +8. Export all data in the testTbl table to s3 with invisible characters `"\x07"` as column or row separators. ```sql EXPORT TABLE testTbl TO "hdfs://hdfs_host:port/a/b/c" diff --git a/versioned_docs/version-1.2/sql-manual/sql-reference/Data-Types/QUANTILE_STATE.md b/versioned_docs/version-1.2/sql-manual/sql-reference/Data-Types/QUANTILE-STATE.md similarity index 100% rename from versioned_docs/version-1.2/sql-manual/sql-reference/Data-Types/QUANTILE_STATE.md rename to versioned_docs/version-1.2/sql-manual/sql-reference/Data-Types/QUANTILE-STATE.md diff --git a/versioned_docs/version-1.2/sql-manual/sql-reference/Show-Statements/SHOW-LOAD-PROFILE.md b/versioned_docs/version-1.2/sql-manual/sql-reference/Show-Statements/SHOW-LOAD-PROFILE.md index 0ed157748bf48..6de47e8d76944 100644 --- a/versioned_docs/version-1.2/sql-manual/sql-reference/Show-Statements/SHOW-LOAD-PROFILE.md +++ b/versioned_docs/version-1.2/sql-manual/sql-reference/Show-Statements/SHOW-LOAD-PROFILE.md @@ -66,7 +66,7 @@ This command will list all currently saved import profiles. Each line correspond ```sql mysql> show load profile "/"\G -*************************** 1. row *************************** + *************************** 1. row *************************** JobId: 20010 QueryId: 980014623046410a-af5d36f23381017f User: root @@ -83,8 +83,8 @@ This command will list all currently saved import profiles. Each line correspond ScheduleTime: NULL FetchResultTime: NULL WriteResultTime: NULL -WaitAndFetchResultTime: NULL -*************************** 2. row *************************** + WaitAndFetchResultTime: NULL + *************************** 2. row *************************** JobId: N/A QueryId: 7cc2d0282a7a4391-8dd75030185134d8 User: root @@ -101,7 +101,7 @@ WaitAndFetchResultTime: NULL ScheduleTime: N/A FetchResultTime: 0ns WriteResultTime: 0ns -WaitAndFetchResultTime: N/A + WaitAndFetchResultTime: N/A ``` 2. View an overview of the subtasks with imported jobs: @@ -157,7 +157,7 @@ WaitAndFetchResultTime: N/A │Fragment: 1 │ │Fragment: 1 │ └─────────────────┘ └─────────────┘ - ```sql + ``` This will show the plan tree and fragment id on it @@ -227,5 +227,3 @@ WaitAndFetchResultTime: N/A SHOW, LOAD, PROFILE -### Best Practice - diff --git a/versioned_docs/version-2.0/ecosystem/doris-kafka-connector.md b/versioned_docs/version-2.0/ecosystem/doris-kafka-connector.md index 5712f344c6d02..414b598a3b43a 100644 --- a/versioned_docs/version-2.0/ecosystem/doris-kafka-connector.md +++ b/versioned_docs/version-2.0/ecosystem/doris-kafka-connector.md @@ -98,7 +98,7 @@ Create the plugins directory under $KAFKA_HOME and put the downloaded doris-kafk Configure config/connect-distributed.properties ```properties -# Modify broker address +# Modify kafka server address bootstrap.servers=127.0.0.1:9092 # Modify group.id, the same cluster needs to be consistent diff --git a/versioned_docs/version-2.0/releasenotes/v1.1/release-1.1.0.md b/versioned_docs/version-2.0/releasenotes/v1.1/release-1.1.0.md index dd94da6816294..e7bb10faf5abf 100644 --- a/versioned_docs/version-2.0/releasenotes/v1.1/release-1.1.0.md +++ b/versioned_docs/version-2.0/releasenotes/v1.1/release-1.1.0.md @@ -88,11 +88,11 @@ On all 13 SQLs in the SSB test data set, version 1.1 is better than version 0.15 On all 22 SQLs in the TPC-H test data set, version 1.1 is better than version 0.15, the overall performance is improved by about 4.5 times, and the performance of some scenarios is improved by more than ten times; -![](/images/release-note-1.1.0-SSB.png) +![release-note-1.1.0-SSB](/images/release-note-1.1.0-SSB.png)

SSB Benchmark

-![](/images/release-note-1.1.0-TPC-H.png) +![release-note-1.1.0-TPC-H](/images/release-note-1.1.0-TPC-H.png)

TPC-H Benchmark

diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-angle-sphere.md b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-angle-sphere.md index ca99aeb9125dd..401c2ac7c0a0f 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-angle-sphere.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-angle-sphere.md @@ -24,36 +24,52 @@ specific language governing permissions and limitations under the License. --> -## ST_Angle_Sphere -### description -#### Syntax +## Description -`DOUBLE ST_Angle_Sphere(DOUBLE x_lng, DOUBLE x_lat, DOUBLE y_lng, DOUBLE y_lat)` +Calculate the center Angle between two points on the Earth's surface in degrees. The parameters passed in are the longitude of point X, latitude of point X, longitude of point Y, and latitude of point Y. +## Syntax -Calculates the central angle between two points on the Earth's surface. The incoming parameters are the longitude of point X, the latitude of point X, the longitude of point Y and the latitude of point Y. +```sql +ST_Angle_Sphere( , , , ) +``` + +## Parameters + +| Parameters | Instructions | +| -- | -- | +| `` | Longitude data, reasonable value range is [-180, 180] | +| `` | Longitude data, reasonable value range is [-180, 180] | +| `` | Latitude data, reasonable value range is [-90, 90] | +| `` | Latitude data, reasonable value range is [-90, 90] | -x_lng and y_lng are Longitude values, must be in the range [-180, 180]. -x_lat and y_lat are Latitude values, must be in the range [-90, 90]. +## Return Value -### example +The Angle of the center between two points +## Examples + +```sql +select ST_Angle_Sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); ``` -mysql> select ST_Angle_Sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); + +```text +---------------------------------------------------------------------------+ | st_angle_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219) | +---------------------------------------------------------------------------+ | 0.0659823452409903 | +---------------------------------------------------------------------------+ -1 row in set (0.06 sec) +``` + +```sql +select ST_Angle_Sphere(0, 0, 45, 0); +``` -mysql> select ST_Angle_Sphere(0, 0, 45, 0); +```text +----------------------------------------+ | st_angle_sphere(0.0, 0.0, 45.0, 0.0) | +----------------------------------------+ | 45 | +----------------------------------------+ -1 row in set (0.06 sec) ``` -### keywords -ST_ANGLE_SPHERE,ST,ANGLE,SPHERE + diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-angle.md b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-angle.md index bccc92b06034c..bc5e44b4e443a 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-angle.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-angle.md @@ -24,66 +24,95 @@ specific language governing permissions and limitations under the License. --> -## ST_Angle +## Description -### Syntax +Enter three points that represent two intersecting lines. Return the Angle between these lines. -`DOUBLE ST_Angle(GEOPOINT point1, GEOPOINT point2, GEOPOINT point3)` +## Syntax -### description +```sql +ST_Angle( , , ) +``` + +## Parameters + +| Parameters | Instructions | +|----------|---------------------------------------------------------------------------| +| `` | The first point of the first line | +| `` | The second point of the first line and the first point of the second line | +| `` | The second point of the second line | -Enter three point, which represent two intersecting lines. Returns the angle between these lines. Point 2 and point 1 represent the first line and point 2 and point 3 represent the second line. The angle between these lines is in radians, in the range [0, 2pi). The angle is measured clockwise from the first line to the second line. +## Return Value + +The Angle between these lines is expressed in radians and ranges from [0, 2pi]. The Angle is measured clockwise from the first line to the second line. ST_ANGLE has the following edge cases: -* If points 2 and 3 are the same, returns NULL. -* If points 2 and 1 are the same, returns NULL. -* If points 2 and 3 are exactly antipodal, returns NULL. -* If points 2 and 1 are exactly antipodal, returns NULL. -* If any of the input geographies are not single points or are the empty geography, then throws an error. +- If point 2 and point 3 are the same, NULL is returned +- If point 2 and point 1 are the same, NULL is returned +- NULL is returned if points 2 and 3 are perfect Antipodes +- NULL is returned if points 2 and 1 are perfect AntipodesL +- If any input geography is not a single point or is an empty geography, an error is thrown -### example +## Examples +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1)); ``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1)); + +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------------------------+ | 4.71238898038469 | +----------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1)); +``` -mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1)); +```text +----------------------------------------------------------------------+ | st_angle(st_point(0.0, 0.0), st_point(1.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------------------------+ | 0.78547432161873854 | +----------------------------------------------------------------------+ -1 row in set (0.02 sec) +``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0)); +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0)); +``` + +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(1.0, 0.0)) | +----------------------------------------------------------------------+ | 0 | +----------------------------------------------------------------------+ -1 row in set (0.02 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 0)); +``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 0)); +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 0.0)) | +----------------------------------------------------------------------+ | NULL | +----------------------------------------------------------------------+ -1 row in set (0.03 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(0, 0),ST_Point(-30, 0),ST_Point(150, 0)); +``` -mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(-30, 0),ST_Point(150, 0)); +```text +--------------------------------------------------------------------------+ | st_angle(st_point(0.0, 0.0), st_point(-30.0, 0.0), st_point(150.0, 0.0)) | +--------------------------------------------------------------------------+ | NULL | +--------------------------------------------------------------------------+ -1 row in set (0.02 sec) ``` -### keywords -ST_ANGLE,ST,ANGLE + diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-area.md b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-area.md index b9f38dc13582b..5a6b635411391 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-area.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-area.md @@ -24,57 +24,75 @@ specific language governing permissions and limitations under the License. --> -## ST_Area_Square_Meters,ST_Area_Square_Km +## Description -### Syntax +Calculate the area of the region on the sphere of the Earth + +## Syntax ```sql -DOUBLE ST_Area_Square_Meters(GEOMETRY geo) -DOUBLE ST_Area_Square_Km(GEOMETRY geo) +ST_Area_Square_Meters( ) +ST_Area_Square_Km( ) ``` +## Parameters -### description +| Parameters | Instructions | +| -- |--------| +| `` | The spherical position of the earth | -Calculate the area of the area on the earth's sphere. Currently, the parameter geo supports St_Point, St_LineString, St_Circle and St_Polygon. +## Return Value -Returns zero if the input is St_Point, St_LineString. +ST_Area_Square_Meters( ): the units returned are square meters -Among them, the unit returned by ST_Area_Square_Meters (GEOMETRY geo) is square meters, and the unit returned by ST_Area_Square_Km (GEOMETRY geo) is square kilometers. +ST_Area_Square_Km( ): the units returned are square kilometers -### example +## Examples +```sql +SELECT ST_Area_Square_Meters(ST_Circle(0, 0, 1)); ``` -mysql> SELECT ST_Area_Square_Meters(ST_Circle(0, 0, 1)); + +```text +-------------------------------------------------+ | st_area_square_meters(st_circle(0.0, 0.0, 1.0)) | +-------------------------------------------------+ | 3.1415926535897869 | +-------------------------------------------------+ -1 row in set (0.04 sec) +``` -mysql> SELECT ST_Area_Square_Km(ST_Polygon("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))")); +```sql +SELECT ST_Area_Square_Km(ST_Polygon("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))")); +``` + +```text +----------------------------------------------------------------------+ | st_area_square_km(st_polygon('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))')) | +----------------------------------------------------------------------+ | 12364.036567076409 | +----------------------------------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> SELECT ST_Area_Square_Meters(ST_Point(0, 1)); +```sql +SELECT ST_Area_Square_Meters(ST_Point(0, 1)); +``` + +```text +-------------------------------------------+ | st_area_square_meters(st_point(0.0, 1.0)) | +-------------------------------------------+ | 0 | +-------------------------------------------+ -1 row in set (0.05 sec) +``` -mysql> SELECT ST_Area_Square_Meters(ST_LineFromText("LINESTRING (1 1, 2 2)")); +```sql +SELECT ST_Area_Square_Meters(ST_LineFromText("LINESTRING (1 1, 2 2)")); +``` + +```text +-----------------------------------------------------------------+ | st_area_square_meters(st_linefromtext('LINESTRING (1 1, 2 2)')) | +-----------------------------------------------------------------+ | 0 | +-----------------------------------------------------------------+ -1 row in set (0.03 sec) ``` -### keywords -ST_Area_Square_Meters,ST_Area_Square_Km,ST_Area,ST,Area + diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-asbinary.md b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-asbinary.md index d349861bbf19d..c3e2b26c5c078 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-asbinary.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-asbinary.md @@ -24,45 +24,63 @@ specific language governing permissions and limitations under the License. --> -## ST_AsBinary +## Description -### Syntax +Convert a geometric figure to a standard WKB (Well-known binary) representation. -`VARCHAR ST_AsBinary(GEOMETRY geo)` +At present, the supported geometry is: Point, LineString, Polygon. -### Description +## Syntax -Converting a geometric figure into a standard WKB (Well-known binary) representation +```sql +ST_AsBinary( ) +``` + +## Parameters + +| Parameters | Instructions | +| -- |----------| +| `` | The graph that needs to be converted | + +## Return Value -Currently supported geometric figures are: Point, LineString, Polygon. +The WKB representation of the geometry -### example +## Examples +```sql +select ST_AsBinary(st_point(24.7, 56.7)); ``` -mysql> select ST_AsBinary(st_point(24.7, 56.7)); + +```text +----------------------------------------------+ | st_asbinary(st_point(24.7, 56.7)) | +----------------------------------------------+ | \x01010000003333333333b338409a99999999594c40 | +----------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> select ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); +```sql +select ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); +``` + +```text +--------------------------------------------------------------------------------------+ | st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +--------------------------------------------------------------------------------------+ | \x010200000002000000000000000000f03f000000000000f03f00000000000000400000000000000040 | +--------------------------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` + +```sql +select ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")); +``` -mysql> select ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")); +```text +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')) | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | \x01030000000100000006000000f3380ce6af865c402d05a4fd0f8c364041ef8d2100865c403049658a398c3640b9fb1c1f2d865c409d9b36e334883640de921cb0ab865c40cf876709328a36402cefaa07cc865c407b319413ed8a3640f3380ce6af865c402d05a4fd0f8c3640 | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.02 sec) - ``` -### keywords -ST_ASBINARY,ST,ASBINARY + diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-astext.md b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-astext.md index b1990bb38353a..984ccdb156767 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-astext.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-astext.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_AsText,ST_AsWKT -### Description -#### Syntax +## Description -`VARCHAR ST_AsText (GEOMETRY geo)` +Convert a geometric figure to a representation of WKT (Well Known Text) +## Syntax -Converting a geometric figure into a WKT (Well Known Text) representation +```sql +ST_AsText( ) +``` + +## Parameters + +| Parameters | Instructions | +| -- |----------| +| `` | The graph that needs to be converted | -### example +## Return Value +The WKT representation of the geometry: + +## Examples + +```sql +SELECT ST_AsText(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_AsText(ST_Point(24.7, 56.7)); + +```text +---------------------------------+ | st_astext(st_point(24.7, 56.7)) | +---------------------------------+ | POINT (24.7 56.7) | +---------------------------------+ ``` -### keywords -ST_ASTEXT,ST_ASWKT,ST,ASTEXT,ASWKT diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-azimuth.md b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-azimuth.md index bb7b9ed19e41a..88744e119f173 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-azimuth.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-azimuth.md @@ -24,72 +24,84 @@ specific language governing permissions and limitations under the License. --> -## ST_Azimuth +## Description -### Syntax +Enter two points and return the azimuth of the line segment formed by points 1 and 2. Azimuth is the arc of the Angle between the true north line of point 1 and the line segment formed by points 1 and 2. -`DOUBLE ST_Azimuth(GEOPOINT point1, GEOPOINT point2)` +## Syntax -### description +```sql +ST_Azimuth( , ) +``` +## Parameters + +| Parameters | Instructions | +|----------|------------------------------------------------| +| `` | The first point used to calculate the azimuth | +| `` | The second point used to calculate the azimuth | -Enter two point, and returns the azimuth of the line segment formed by points 1 and 2. The azimuth is the angle in radians measured between the line from point 1 facing true North to the line segment from point 1 to point 2. +## Return Value -The positive angle is measured clockwise on the surface of a sphere. For example, the azimuth for a line segment: +Positive angles are measured clockwise on the sphere. For example, the azimuth of a line segment: -* Pointing North is 0 -* Pointing East is PI/2 -* Pointing South is PI -* Pointing West is 3PI/2 +- North is 0 +- East is PI/2 +- The guide is PI +- The west is 3PI/2 ST_Azimuth has the following edge cases: -* If the two input points are the same, returns NULL. -* If the two input points are exactly antipodal, returns NULL. -* If either of the input geographies are not single points or are the empty geography, throws an error. +- Return NULL if both input points are the same. +- NULL is returned if the two input points are perfect mapping points. +- An error is thrown if any of the input geographies are not a single point or are empty geographies -### example +## Examples +```sql +SELECT st_azimuth(ST_Point(1, 0),ST_Point(0, 0)); ``` -mysql> SELECT st_azimuth(ST_Point(1, 0),ST_Point(0, 0)); + +```text +----------------------------------------------------+ | st_azimuth(st_point(1.0, 0.0), st_point(0.0, 0.0)) | +----------------------------------------------------+ | 4.71238898038469 | +----------------------------------------------------+ -1 row in set (0.03 sec) +``` -mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(1, 0)); +```sql +SELECT st_azimuth(ST_Point(0, 0),ST_Point(1, 0)); +``` + +```text +----------------------------------------------------+ | st_azimuth(st_point(0.0, 0.0), st_point(1.0, 0.0)) | +----------------------------------------------------+ | 1.5707963267948966 | +----------------------------------------------------+ -1 row in set (0.01 sec) +``` + +```sql +SELECT st_azimuth(ST_Point(0, 0),ST_Point(0, 1)); +``` -mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(0, 1)); +```text +----------------------------------------------------+ | st_azimuth(st_point(0.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------+ | 0 | +----------------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> SELECT st_azimuth(ST_Point(0, 1),ST_Point(0, 1)); -+----------------------------------------------------+ -| st_azimuth(st_point(0.0, 1.0), st_point(0.0, 1.0)) | -+----------------------------------------------------+ -| NULL | -+----------------------------------------------------+ -1 row in set (0.02 sec) +```sql +SELECT st_azimuth(ST_Point(-30, 0),ST_Point(150, 0)); +``` -mysql> SELECT st_azimuth(ST_Point(-30, 0),ST_Point(150, 0)); +```text +--------------------------------------------------------+ | st_azimuth(st_point(-30.0, 0.0), st_point(150.0, 0.0)) | +--------------------------------------------------------+ | NULL | +--------------------------------------------------------+ -1 row in set (0.02 sec) - ``` -### keywords -ST_AZIMUTH,ST,AZIMUTH + diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-circle.md b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-circle.md index 5b9750a1cf021..8e16a6befe79d 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-circle.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-circle.md @@ -24,25 +24,41 @@ specific language governing permissions and limitations under the License. --> -## ST_Circle -### Description -#### Syntax +## Description -`GEOMETRY ST_Circle(DOUBLE center_lng, DOUBLE center_lat, DOUBLE radius)` +Convert a WKT (Well Known Text) to a circle on the sphere of the Earth. +## Syntax -Convert a WKT (Well Known Text) into a circle on the earth's sphere. Where `center_lng'denotes the longitude of the center of a circle, -` Center_lat` denotes the latitude of the center of a circle, radius` denotes the radius of a circle in meters. +```sql +ST_Circle( , , ) +``` + +## Parameters + +| Parameters | Instructions | +| -- | -- | +| `` | Longitude of the center of the circle | +| `` | The latitude of the center of the circle | +| `` | Radius of a circle | + +- The unit of radius is meters. A maximum of 9999999 RADIUS is supported -### example +## Return Value +A circle on a sphere based on basic information about the circle + +## Examples + +```sql +SELECT ST_AsText(ST_Circle(111, 64, 10000)); ``` -mysql> SELECT ST_AsText(ST_Circle(111, 64, 10000)); + +```text +--------------------------------------------+ | st_astext(st_circle(111.0, 64.0, 10000.0)) | +--------------------------------------------+ | CIRCLE ((111 64), 10000) | +--------------------------------------------+ ``` -### keywords -ST_CIRCLE,ST,CIRCLE + diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-contains.md b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-contains.md index a3ab1214b0ccf..6454cce61403a 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-contains.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-contains.md @@ -24,32 +24,52 @@ specific language governing permissions and limitations under the License. --> -## ST_Contains -### Description -#### Syntax +## Description -`BOOL ST_Contains(GEOMETRY shape1, GEOMETRY shape2)` +Determines whether the geometry shape1 is fully capable of containing the geometry shape2 +## Syntax -Judging whether geometric shape 1 can contain geometric shape 2 completely +```sql +ST_Contains( , ) +``` + +## Parameters + +| Parameters | Instructions | +|----------|------------------------| +| `` | The passed geometry used to determine whether shape2 is included | +| `` | The passed geometry is used to determine whether shape1 is included | + +## Return Value + +Return 1:shape1 The graph can contain the graph shape2 -### example +Return 0:shape1 Graph cannot contain graph shape2 +## Examples + +```sql +SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(5, 5)); ``` -mysql> SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(5, 5)); + +```text +----------------------------------------------------------------------------------------+ | st_contains(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'), st_point(5.0, 5.0)) | +----------------------------------------------------------------------------------------+ | 1 | +----------------------------------------------------------------------------------------+ +``` + +```sql +SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(50, 50)); +``` -mysql> SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(50, 50)); +```text +------------------------------------------------------------------------------------------+ | st_contains(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'), st_point(50.0, 50.0)) | +------------------------------------------------------------------------------------------+ | 0 | +------------------------------------------------------------------------------------------+ ``` -### keywords -ST_CONTAINS,ST,CONTAINS diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-distance-sphere.md b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-distance-sphere.md index a50fc65625b1f..e1b5c76a90d9d 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-distance-sphere.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-distance-sphere.md @@ -24,27 +24,40 @@ specific language governing permissions and limitations under the License. --> -## ST_Distance_Sphere -### description -#### Syntax +## Description -`DOUBLE ST_Distance_Sphere(DOUBLE x_lng, DOUBLE x_lat, DOUBLE y_lng, DOUBLE y_lat)` +Calculate the spherical distance in meters between two points on the Earth. The parameters passed in are the longitude of point X, latitude of point X, longitude of point Y, and latitude of point Y. +## Syntax -Calculate the spherical distance between two points of the earth in meters. The incoming parameters are the longitude of point X, the latitude of point X, the longitude of point Y and the latitude of point Y. +```sql +ST_Distance_Sphere( , , , ) +``` + +## Parameters + +| Parameters | Instructions | +| -- | -- | +| `` | Longitude data, reasonable value range is [-180, 180] | +| `` | Longitude data, reasonable value range is [-180, 180] | +| `` | Latitude data, reasonable value range is [-90, 90] | +| `` | Latitude data, reasonable value range is [-90, 90] | -x_lng and y_lng are Longitude values, must be in the range [-180, 180]. -x_lat and y_lat are Latitude values, must be in the range [-90, 90]. +## Return Value -### example +The spherical distance between two points +## Examples + +```sql +select st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); ``` -mysql> select st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); + +```text +----------------------------------------------------------------------------+ | st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219) | +----------------------------------------------------------------------------+ | 7336.9135549995917 | +----------------------------------------------------------------------------+ ``` -### keywords -ST_DISTANCE_SPHERE,ST,DISTANCE,SPHERE + diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-geometryfromtext.md b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-geometryfromtext.md index 28072a02016d0..860fc1790c3c7 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-geometryfromtext.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-geometryfromtext.md @@ -24,24 +24,35 @@ specific language governing permissions and limitations under the License. --> -## ST_GeometryFromText,ST_GeomFromText -### Description -#### Syntax +## Description -`GEOMETRY ST_GeometryFromText (VARCHAR wkt)` +Convert a linear WKT (Well Known Text) to the corresponding memory geometry +## Syntax -Converting a WKT (Well Known Text) into a corresponding memory geometry +```sql +ST_GeometryFromText( ) +``` +## Parameters + +| Parameters | Instructions | +| -- |---------| +| `` | The memory form of the graph | + +## Return Value -### example +The corresponding geometric storage form of WKB +## Examples + +```sql +SELECT ST_AsText(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); ``` -mysql> SELECT ST_AsText(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); + +```text +---------------------------------------------------------+ | st_astext(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +---------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +---------------------------------------------------------+ -``` -### keywords -ST_GEOMETRYFROMTEXT,ST_GEOMFROMTEXT,ST,GEOMETRYFROMTEXT,GEOMFROMTEXT +``` \ No newline at end of file diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-geometryfromwkb.md b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-geometryfromwkb.md index bf0a47f4b5903..09b66bbb15706 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-geometryfromwkb.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-geometryfromwkb.md @@ -24,59 +24,84 @@ specific language governing permissions and limitations under the License. --> -## ST_GeometryFromWKB,ST_GeomFromWKB -### Syntax +## Description -`GEOMETRY ST_GeometryFromWKB(VARCHAR WKB)` +Converts a standard figure WKB (Well-known binary) to the corresponding memory geometry -### Description +## Syntax -Converting a standard WKB (Well-known binary) into a corresponding memory geometry +```sql +ST_GeometryFromWKB( ) +``` +## Parameters + +| Parameters | Instructions | +|------------|---------| +| `` | The memory form of the graph | + +## Return Value -### example +The corresponding geometric storage form of WKB +## Examples + +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); ``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); + +```text +------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_point(24.7, 56.7)))) | +------------------------------------------------------------------+ | POINT (24.7 56.7) | +------------------------------------------------------------------+ -1 row in set (0.05 sec) +``` + +```sql +select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); +``` -mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); +```text +--------------------------------------------------------------+ | st_astext(st_geomfromwkb(st_asbinary(st_point(24.7, 56.7)))) | +--------------------------------------------------------------+ | POINT (24.7 56.7) | +--------------------------------------------------------------+ -1 row in set (0.03 sec) +``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")))); +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")))); +``` + +```text +------------------------------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')))) | +------------------------------------------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +------------------------------------------------------------------------------------------+ -1 row in set (0.06 sec) +``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +``` + +```text +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) +``` -mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +```sql +select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +``` + +```text +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_astext(st_geomfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) | +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) | +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) - -``` -### keywords -ST_GEOMETRYFROMWKB,ST_GEOMFROMWKB,ST,GEOMETRYFROMWKB,GEOMFROMWKB,WKB +``` \ No newline at end of file diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-linefromtext.md b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-linefromtext.md index 3a033103b1580..9fa5f0f4b8e37 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-linefromtext.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-linefromtext.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_LineFromText,ST_LineStringFromText -### Description -#### Syntax +## Description -`GEOMETRY ST LineFromText (VARCHAR wkt)` +Converts a WKT (Well Known Text) to a memory representation in the form of a Line +## Syntax -Converting a WKT (Well Known Text) into a Line-style memory representation +```sql +ST_LineFromText( ) +``` + +## Parameters + +| Parameters | Instructions | +|-----|------------| +| `` | A line segment consisting of two coordinates | + +## Return Value -### example +The memory form of a line segment. +## Examples + +```sql +SELECT ST_AsText(ST_LineFromText("LINESTRING (1 1, 2 2)")); ``` -mysql> SELECT ST_AsText(ST_LineFromText("LINESTRING (1 1, 2 2)")); + +```text +---------------------------------------------------------+ | st_astext(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +---------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +---------------------------------------------------------+ -``` -### keywords -ST_LINEFROMTEXT, ST_LINESTRINGFROMTEXT,ST,LINEFROMTEXT,LINESTRINGFROMTEXT +``` \ No newline at end of file diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-point.md b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-point.md index 050f41a31ad88..661fdac7ee6e1 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-point.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-point.md @@ -24,25 +24,38 @@ specific language governing permissions and limitations under the License. --> -## St_Point -### Description -#### Syntax +## Description -`POINT ST_Point(DOUBLE x, DOUBLE y)` +With the given X coordinate value, the Y coordinate value returns the corresponding Point. +The current value is only meaningful in the sphere set, X/Y corresponds to longitude/latitude; -Given the X coordinate value, the Y coordinate value returns the corresponding Point. -The current value is meaningful only for spherical sets, and X/Y corresponds to longitude/latitude. +## Syntax -### example +```sql +ST_Point( , ) +``` +## Parameters + +| Parameters | Instructions | +|-----|--------------| +| `` | x-coordinate | +| `` | y-coordinate | + +## Return Value + +Given horizontal coordinate and vertical coordinate corresponding position information +## Examples + +```sql +SELECT ST_AsText(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_AsText(ST_Point(24.7, 56.7)); + +```text +---------------------------------+ | st_astext(st_point(24.7, 56.7)) | +---------------------------------+ | POINT (24.7 56.7) | +---------------------------------+ -``` -### keywords -ST_POINT,ST,POINT +``` \ No newline at end of file diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-polygon.md b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-polygon.md index 226736bb2d64c..aa282b328bab1 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-polygon.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-polygon.md @@ -24,25 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_Polygon,ST_PolyFromText,ST_PolygonFromText -### Description -#### Syntax +## Description -`GEOMETRY ST_Polygon (VARCHAR wkt)` +Convert a WKT (Well Known Text) to the corresponding polygonal memory form +## Syntax -Converting a WKT (Well Known Text) into a corresponding polygon memory form +```sql +ST_Polygon( ) +``` + +## Parameters + +| Parameters | Instructions | +|------|--------------------| +| `` | A POLYGON generated by the polygon function | +## Return Value -#### example +Memory form of polygon +## Examples + +```sql +SELECT ST_AsText(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))")); ``` -mysql> SELECT ST_AsText(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))")); + +```text +------------------------------------------------------------------+ | st_astext(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))')) | +------------------------------------------------------------------+ | POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0)) | +------------------------------------------------------------------+ ``` -### keywords -ST_POLYGON,ST_POLYFROMTEXT,ST_POLYGONFROMTEXT,ST,POLYGON,POLYFROMTEXT,POLYGONFROMTEXT diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-x.md b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-x.md index a00eb050cfc13..80bcc385d18aa 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-x.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-x.md @@ -24,24 +24,37 @@ specific language governing permissions and limitations under the License. --> -## ST_X -### Description -#### Syntax -`DOUBLE ST_X(POINT point)` +## Description +When point is a valid POINT type, return the corresponding x-coordinate value -When point is a valid POINT type, the corresponding X coordinate value is returned. +## Syntax -### example +```sql +ST_X( ) +``` + +## Parameters + +| Parameters | Instructions | +|------|----------| +| `` | The geometric coordinates of a two-dimensional point | + +## Return Value +X value in geometric coordinates + +## Examples + +```sql +SELECT ST_X(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_X(ST_Point(24.7, 56.7)); + +```text +----------------------------+ | st_x(st_point(24.7, 56.7)) | +----------------------------+ | 24.7 | +----------------------------+ -``` -### keywords -ST_X,ST,X +``` \ No newline at end of file diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-y.md b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-y.md index eec67131b9ad3..6c55702dfada3 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-y.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/spatial-functions/st-y.md @@ -24,24 +24,34 @@ specific language governing permissions and limitations under the License. --> -## ST_Y -### Description -#### Syntax +## Description -`DOUBLE ST_Y(POINT point)` +When point is a valid POINT type, return the corresponding y-coordinate value +```sql +ST_Y( ) +``` + +## Parameters + +| Parameters | Instructions | +|------|----------| +| `` | The geometric coordinates of a two-dimensional point | -When point is a valid POINT type, the corresponding Y coordinate value is returned. +## Return Value -### example +Y value in geometric coordinates +## Examples + +```sql +SELECT ST_Y(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_Y(ST_Point(24.7, 56.7)); + +```text +----------------------------+ -| st_y(st_point(24.7, 56.7)) | +| st_x(st_point(24.7, 56.7)) | +----------------------------+ -| 56.7 | +| 24.7 | +----------------------------+ -``` -### keywords -ST_Y,ST,Y +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/data-operate/import/data-source/kafka.md b/versioned_docs/version-2.1/data-operate/import/data-source/kafka.md index 51254997a11c8..b2cb53cee81de 100644 --- a/versioned_docs/version-2.1/data-operate/import/data-source/kafka.md +++ b/versioned_docs/version-2.1/data-operate/import/data-source/kafka.md @@ -191,7 +191,7 @@ The Doris Kafka Connector is a tool for loading Kafka data streams into the Dori 2. Configure `config/connect-distributed.properties`: ```Bash -# Modify broker address +# Modify kafka server address bootstrap.servers=127.0.0.1:9092 # Modify group.id, which needs to be consistent across the same cluster diff --git a/versioned_docs/version-2.1/data-operate/update/update-of-aggregate-model.md b/versioned_docs/version-2.1/data-operate/update/update-of-aggregate-model.md index 3fde759a85cb6..8fa858b7a226c 100644 --- a/versioned_docs/version-2.1/data-operate/update/update-of-aggregate-model.md +++ b/versioned_docs/version-2.1/data-operate/update/update-of-aggregate-model.md @@ -1,4 +1,4 @@ -- +--- { "title": "Updating Data on Aggregate Key Model", "language": "en" diff --git a/versioned_docs/version-2.1/ecosystem/doris-kafka-connector.md b/versioned_docs/version-2.1/ecosystem/doris-kafka-connector.md index 5712f344c6d02..414b598a3b43a 100644 --- a/versioned_docs/version-2.1/ecosystem/doris-kafka-connector.md +++ b/versioned_docs/version-2.1/ecosystem/doris-kafka-connector.md @@ -98,7 +98,7 @@ Create the plugins directory under $KAFKA_HOME and put the downloaded doris-kafk Configure config/connect-distributed.properties ```properties -# Modify broker address +# Modify kafka server address bootstrap.servers=127.0.0.1:9092 # Modify group.id, the same cluster needs to be consistent diff --git a/versioned_docs/version-2.1/releasenotes/v1.1/release-1.1.0.md b/versioned_docs/version-2.1/releasenotes/v1.1/release-1.1.0.md index dd94da6816294..e7bb10faf5abf 100644 --- a/versioned_docs/version-2.1/releasenotes/v1.1/release-1.1.0.md +++ b/versioned_docs/version-2.1/releasenotes/v1.1/release-1.1.0.md @@ -88,11 +88,11 @@ On all 13 SQLs in the SSB test data set, version 1.1 is better than version 0.15 On all 22 SQLs in the TPC-H test data set, version 1.1 is better than version 0.15, the overall performance is improved by about 4.5 times, and the performance of some scenarios is improved by more than ten times; -![](/images/release-note-1.1.0-SSB.png) +![release-note-1.1.0-SSB](/images/release-note-1.1.0-SSB.png)

SSB Benchmark

-![](/images/release-note-1.1.0-TPC-H.png) +![release-note-1.1.0-TPC-H](/images/release-note-1.1.0-TPC-H.png)

TPC-H Benchmark

diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/group-concat.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/group-concat.md index cc870e11a43dc..c009e0d842159 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/group-concat.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/group-concat.md @@ -24,25 +24,36 @@ specific language governing permissions and limitations under the License. --> -## GROUP_CONCAT -### description -#### Syntax +## Description -`VARCHAR GROUP_CONCAT([DISTINCT] VARCHAR str[, VARCHAR sep] [ORDER BY { col_name | expr} [ASC | DESC]])` +The GROUP_CONCAT function concatenates multiple rows of results in the result set into a string. +## Syntax -This function is an aggregation function similar to sum (), and group_concat links multiple rows of results in the result set to a string. The second parameter, sep, is a connection symbol between strings, which can be omitted. This function usually needs to be used with group by statements. +```sql +GROUP_CONCAT([DISTINCT] [, ] [ORDER BY { | } [ASC | DESC]]) +``` + +## Parameters + +| Parameters | Description | +| ------------ | ---------------------- | +| `` | Required. The expression of the value to be concatenated. | +| `` | Optional. The separator between strings. | +| `` | Optional. The column used for sorting. | +| `` | Optional. The expression used for sorting. | -Support Order By for sorting multi-row results, sorting and aggregation columns can be different. +## Return Value -:::caution -`group_concat` don't support using `distinct` with `order by` together. -::: +Returns a value of type VARCHAR. -### example +## Example +```sql +select value from test; ``` -mysql> select value from test; + +```text +-------+ | value | +-------+ @@ -51,29 +62,49 @@ mysql> select value from test; | c | | c | +-------+ +``` + +```sql +select GROUP_CONCAT(value) from test; +``` -mysql> select GROUP_CONCAT(value) from test; +```text +-----------------------+ | GROUP_CONCAT(`value`) | +-----------------------+ -| a, b, c, c | +| a, b, c, c | +-----------------------+ +``` -mysql> select GROUP_CONCAT(value, " ") from test; -+----------------------------+ -| GROUP_CONCAT(`value`, ' ') | -+----------------------------+ -| a b c c | -+----------------------------+ +```sql +select GROUP_CONCAT(DISTINCT value) from test; +``` -mysql> select GROUP_CONCAT(DISTINCT value) from test; +```text +-----------------------+ | GROUP_CONCAT(`value`) | +-----------------------+ | a, b, c | +-----------------------+ +``` + +```sql +select GROUP_CONCAT(value, " ") from test; +``` + +```text ++----------------------------+ +| GROUP_CONCAT(`value`, ' ') | ++----------------------------+ +| a b c c | ++----------------------------+ +``` + +```sql +select GROUP_CONCAT(value, NULL) from test; +``` -mysql> select GROUP_CONCAT(value, NULL) from test; +```text +----------------------------+ | GROUP_CONCAT(`value`, NULL)| +----------------------------+ @@ -81,5 +112,3 @@ mysql> select GROUP_CONCAT(value, NULL) from test; +----------------------------+ ``` -### keywords -GROUP_CONCAT,GROUP,CONCAT diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/histogram.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/histogram.md index 20246ec319a30..d17ca8af30162 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/histogram.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/histogram.md @@ -24,32 +24,52 @@ specific language governing permissions and limitations under the License. --> -## HISTOGRAM -### description -#### Syntax +## Description -`histogram(expr[, INT num_buckets])` +The histogram function is used to describe the distribution of the data. It uses an "equal height" bucking strategy, and divides the data into buckets according to the value of the data. It describes each bucket with some simple data, such as the number of values that fall in the bucket. -The histogram function is used to describe the distribution of the data. It uses an "equal height" bucking strategy, and divides the data into buckets according to the value of the data. It describes each bucket with some simple data, such as the number of values that fall in the bucket. It is mainly used by the optimizer to estimate the range query. +## Alias -The result of the function returns an empty or Json string. +HIST -Parameter description: -- num_buckets:Optional. Limit the number of histogram buckets. The default value is 128. +## Syntax + +```sql +HISTOGRAM([, ]) +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `expr` | The expression that needs to be obtained. | +| `num_buckets` | Optional. Limit the number of histogram buckets. The default value is 128.| -Alias function: `hist(expr[, INT num_buckets])` -### example +## Return Value +Returns a value of JSON type after histogram estimation. Special cases: +- When the parameter is NULL, it returns NULL. + +## Example + +```sql +SELECT histogram(c_float) FROM histogram_test; ``` -MySQL [test]> SELECT histogram(c_float) FROM histogram_test; + +```text +-------------------------------------------------------------------------------------------------------------------------------------+ | histogram(`c_float`) | +-------------------------------------------------------------------------------------------------------------------------------------+ | {"num_buckets":3,"buckets":[{"lower":"0.1","upper":"0.1","count":1,"pre_sum":0,"ndv":1},...]} | +-------------------------------------------------------------------------------------------------------------------------------------+ +``` + +```sql +SELECT histogram(c_string, 2) FROM histogram_test; +``` -MySQL [test]> SELECT histogram(c_string, 2) FROM histogram_test; +```text +-------------------------------------------------------------------------------------------------------------------------------------+ | histogram(`c_string`) | +-------------------------------------------------------------------------------------------------------------------------------------+ @@ -59,7 +79,7 @@ MySQL [test]> SELECT histogram(c_string, 2) FROM histogram_test; Query result description: -``` +```json { "num_buckets": 3, "buckets": [ @@ -88,6 +108,7 @@ Query result description: } ``` +```text Field description: - num_buckets:The number of buckets - buckets:All buckets @@ -98,7 +119,4 @@ Field description: - ndv:The number of different values in the bucket > Total number of histogram elements = number of elements in the last bucket(count) + total number of elements in the previous bucket(pre_sum). - -### keywords - -HISTOGRAM, HIST +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md index 49d6da2d682b0..0a87ce538719f 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md @@ -24,29 +24,36 @@ specific language governing permissions and limitations under the License. --> -## HLL_UNION_AGG -### description -#### Syntax +## Description -`HLL_UNION_AGG(hll)` +The HLL_UNION_AGG function is an aggregate function, which is mainly used to merge multiple HyperLogLog data structures and estimate the approximate value of the combined cardinality. +## Syntax -HLL is an engineering implementation based on HyperLog algorithm, which is used to save the intermediate results of HyperLog calculation process. +```sql +hll_union_agg() +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The HyperLogLog type expression to be calculated | -It can only be used as the value column type of the table and reduce the amount of data through aggregation to achieve the purpose of speeding up the query. +## Return Value -Based on this, we get an estimate with an error of about 1%. The HLL column is generated by other columns or data imported into the data. +Returns the cardinality value of type BIGINT. -When importing, hll_hash function is used to specify which column in data is used to generate HLL column. It is often used to replace count distinct, and to calculate UV quickly in business by combining rollup. +## Example -### example +```sql +select HLL_UNION_AGG(uv_set) from test_uv; ``` -MySQL > select HLL_UNION_AGG(uv_set) from test_uv;; + +```text +-------------------------+ -THE COURT OF JUSTICE OF THE EUROPEAN COMMUNITIES, +| HLL_UNION_AGG(`uv_set`) | +-------------------------+ | 17721 | +-------------------------+ -``` -### keywords -HLL_UNION_AGG,HLL,UNION,AGG +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/intersect-count.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/intersect-count.md index eabb298d94ef7..37ad852316118 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/intersect-count.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/intersect-count.md @@ -22,36 +22,51 @@ specific language governing permissions and limitations under the License. --> -## intersect_count -### description -#### Syntax +## Description -`BITMAP INTERSECT_COUNT(bitmap_column, column_to_filter, filter_values)` -Calculate the intersection of two or more bitmaps -Usage: intersect_count(bitmap_column_to_count, filter_column, filter_values ...) -Example: intersect_count(user_id, event, 'A', 'B', 'C'), meaning find the intersect count of user_id in all A/B/C 3 bitmaps +The INTERSECT_COUNT function is used to calculate the number of intersecting elements of the Bitmap data structure. -### example +## Syntax +```sql +INTERSECT_COUNT(, , ) ``` -MySQL [test_query_qa]> select dt,bitmap_to_string(user_id) from pv_bitmap where dt in (3,4); + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The expression that needs to be obtained. | +| `` | Optional. The dimension column that needs to be filtered. | +| `` | Optional. Different values of the filtering dimension column. | + +## Return Value + +Returns a value of type BIGINT. + +## Example + +```sql +select dt,bitmap_to_string(user_id) from pv_bitmap where dt in (3,4); +``` + +```text +------+-----------------------------+ | dt | bitmap_to_string(`user_id`) | +------+-----------------------------+ -| 4 | 1,2,3 | -| 3 | 1,2,3,4,5 | +| 4 | 1,2,3 | +| 3 | 1,2,3,4,5 | +------+-----------------------------+ -2 rows in set (0.012 sec) +``` + +```sql +select intersect_count(user_id,dt,3,4) from pv_bitmap; +``` -MySQL [test_query_qa]> select intersect_count(user_id,dt,3,4) from pv_bitmap; +```text +----------------------------------------+ | intersect_count(`user_id`, `dt`, 3, 4) | +----------------------------------------+ | 3 | +----------------------------------------+ -1 row in set (0.014 sec) ``` - -### keywords - - INTERSECT_COUNT,BITMAP diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/map-agg.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/map-agg.md index b4c5ff616448a..15484436a98f2 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/map-agg.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/map-agg.md @@ -24,18 +24,32 @@ specific language governing permissions and limitations under the License. --> -## MAP_AGG -### description -#### Syntax +## Description -`MAP_AGG(expr1, expr2)` +The MAP_AGG function is used to form a mapping structure based on key-value pairs from multiple rows of data. +## Syntax -Returns a map consists of expr1 as the key and expr2 as the corresponding value. +`MAP_AGG(, )` -### example +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The expression used to specify the key. | +| `` | The expression used to specify the corresponding value. | + +## Return Value + +Returns a value of the MAP type. + +## Example + +```sql +select `n_nationkey`, `n_name`, `n_regionkey` from `nation`; ``` -MySQL > select `n_nationkey`, `n_name`, `n_regionkey` from `nation`; + +```text +-------------+----------------+-------------+ | n_nationkey | n_name | n_regionkey | +-------------+----------------+-------------+ @@ -65,8 +79,13 @@ MySQL > select `n_nationkey`, `n_name`, `n_regionkey` from `nation`; | 23 | UNITED KINGDOM | 3 | | 24 | UNITED STATES | 1 | +-------------+----------------+-------------+ +``` + +```sql +select `n_regionkey`, map_agg(`n_nationkey`, `n_name`) from `nation` group by `n_regionkey`; +``` -MySQL > select `n_regionkey`, map_agg(`n_nationkey`, `n_name`) from `nation` group by `n_regionkey`; +```text +-------------+---------------------------------------------------------------------------+ | n_regionkey | map_agg(`n_nationkey`, `n_name`) | +-------------+---------------------------------------------------------------------------+ @@ -76,8 +95,13 @@ MySQL > select `n_regionkey`, map_agg(`n_nationkey`, `n_name`) from `nation` gro | 4 | {4:"EGYPT", 10:"IRAN", 11:"IRAQ", 13:"JORDAN", 20:"SAUDI ARABIA"} | | 2 | {8:"INDIA", 9:"INDONESIA", 12:"JAPAN", 18:"CHINA", 21:"VIETNAM"} | +-------------+---------------------------------------------------------------------------+ +``` + +```sql +select n_regionkey, map_agg(`n_name`, `n_nationkey` % 5) from `nation` group by `n_regionkey`; +``` -MySQL > select n_regionkey, map_agg(`n_name`, `n_nationkey` % 5) from `nation` group by `n_regionkey`; +```text +-------------+------------------------------------------------------------------------+ | n_regionkey | map_agg(`n_name`, (`n_nationkey` % 5)) | +-------------+------------------------------------------------------------------------+ @@ -88,5 +112,3 @@ MySQL > select n_regionkey, map_agg(`n_name`, `n_nationkey` % 5) from `nation` g | 4 | {"EGYPT":4, "IRAN":0, "IRAQ":1, "JORDAN":3, "SAUDI ARABIA":0} | +-------------+------------------------------------------------------------------------+ ``` -### keywords -MAP_AGG diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/max-by.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/max-by.md index df3096287e92b..26ddb78b30546 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/max-by.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/max-by.md @@ -24,18 +24,34 @@ specific language governing permissions and limitations under the License. --> -## MAX_BY -### description -#### Syntax +## Description -`MAX_BY(expr1, expr2)` +The MAX_BY function is used to return the corresponding associated value based on the maximum value of the specified column. +## Syntax -Returns the value of an expr1 associated with the maximum value of expr2 in a group. +```sql +MAX_BY(, ) +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The expression used to specify the corresponding association. | +| `` | The expression used to specify the maximum value for statistics. | + +## Return Value + +Returns the same data type as the input expression . -### example +## Example + +```sql +select * from tbl; ``` -MySQL > select * from tbl; + +```text +------+------+------+------+ | k1 | k2 | k3 | k4 | +------+------+------+------+ @@ -44,13 +60,16 @@ MySQL > select * from tbl; | 4 | 3 | 2 | 1 | | 3 | 4 | 2 | 1 | +------+------+------+------+ +``` + +```sql +select max_by(k1, k4) from tbl; +``` -MySQL > select max_by(k1, k4) from tbl; +```text +--------------------+ | max_by(`k1`, `k4`) | +--------------------+ | 0 | +--------------------+ ``` -### keywords -MAX_BY diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/max.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/max.md index 68dd6183217c5..4b5d469814a11 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/max.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/max.md @@ -24,23 +24,36 @@ specific language governing permissions and limitations under the License. --> -## MAX -### description -#### Syntax +## Description -`MAX(expr)` +The MAX function returns the maximum value of the expression. +## Syntax -Returns the maximum value of an expr expression +```sql +MAX() +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `expr` | The expression needs to be obtained | + +## Return Value -### example +Returns the same data type as the input expression. + +## Example + +```sql +select max(scan_rows) from log_statis group by datetime; ``` -MySQL > select max(scan_rows) from log_statis group by datetime; + +```text +------------------+ | max(`scan_rows`) | +------------------+ | 4671587 | +------------------+ ``` -### keywords -MAX diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/min-by.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/min-by.md index 52373088a4382..3d08da082367b 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/min-by.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/min-by.md @@ -24,18 +24,34 @@ specific language governing permissions and limitations under the License. --> -## MIN_BY -### description -#### Syntax +## Description -`MIN_BY(expr1, expr2)` +The MIN_BY function is used to return the corresponding associated value based on the minimum value of the specified column. +## Syntax -Returns the value of an expr1 associated with the minimum value of expr2 in a group. +```sql +MIN_BY(, ) +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The expression used to specify the corresponding association. | +| `` | The expression used to specify the minimum value for statistics. | + +## Return Value + +Returns the same data type as the input expression . -### example +## Example + +```sql +select * from tbl; ``` -MySQL > select * from tbl; + +```text +------+------+------+------+ | k1 | k2 | k3 | k4 | +------+------+------+------+ @@ -44,13 +60,16 @@ MySQL > select * from tbl; | 4 | 3 | 2 | 1 | | 3 | 4 | 2 | 1 | +------+------+------+------+ +``` + +```sql +select min_by(k1, k4) from tbl; +``` -MySQL > select min_by(k1, k4) from tbl; +```text +--------------------+ | min_by(`k1`, `k4`) | +--------------------+ | 4 | +--------------------+ ``` -### keywords -MIN_BY diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/min.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/min.md index 76915e2f1f199..4c1fb5425056d 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/min.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/min.md @@ -24,23 +24,36 @@ specific language governing permissions and limitations under the License. --> -## MIN -### Description -#### Syntax +## Description -`MIN(expr)` +The MIN function returns the minimum value of the expression. +## Syntax -Returns the minimum value of an expr expression +```sql +MIN(expr) +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The expression needs to be obtained | + +## Return Value -### example +Returns the same data type as the input expression. + +## Example + +```sql +select MIN(scan_rows) from log_statis group by datetime; ``` -MySQL > select min(scan_rows) from log_statis group by datetime; + +```text +------------------+ -| min(`scan_rows`) | +| MIN(`scan_rows`) | +------------------+ | 0 | +------------------+ ``` -### keywords -MIN diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md index 3562e3fcd34df..6d40da959f170 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md @@ -1,7 +1,7 @@ --- { -"title": "ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT", -"language": "en" + "title": "ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT", + "language": "en" } --- @@ -13,7 +13,9 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -22,26 +24,52 @@ specific language governing permissions and limitations under the License. --> -## orthogonal_bitmap_expr_calculate_count -### description -#### Syntax +## Description -`BITMAP ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT(bitmap_column, column_to_filter, input_string)` -Calculate the bitmap intersection, union and difference set of expressions to calculate the count function. The first parameter is the Bitmap column, the second parameter is the dimension column used for filtering, that is, the calculated key column, and the third parameter is the calculation expression string, meaning that the bitmap intersection, union and difference set expression is calculated according to the key column -The calculators supported by the expression:&represents intersection calculation, | represents union calculation, - represents difference calculation, ^ represents XOR calculation, and \ represents escape characters +The ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT function returns the number of elements in the set after performing intersection, union, and difference calculations on the Bitmap expression. -### example +## Syntax +```sql +ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT(, , ) ``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The Bitmap type expression needs to be obtained | +| `` | The filtering dimension column, the Key column for calculation | +| `` | The calculation expression string, meaning that the Bitmap intersection, union, and difference set expressions are calculated based on the Key column. The supported operators in the expression: &represents intersection calculation, \| represents union calculation, - represents difference calculation, ^ represents XOR calculation, and \ represents escape characters | + +## Return Value + +Returns a value of type BIGINT. + +## Example + +```sql select orthogonal_bitmap_expr_calculate_count(user_id, tag, '(833736|999777)&(1308083|231207)&(1000|20000-30000)') from user_tag_bitmap where tag in (833736,999777,130808,231207,1000,20000,30000); Note: 1000, 20000, 30000 plastic tags represent different labels of users ``` +```text ++-----------------------------------------------------------------------------------------------------------------+ +| orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(833736|999777)&(1308083|231207)&(1000|20000-30000)') | ++-----------------------------------------------------------------------------------------------------------------+ +| 1000 | ++-----------------------------------------------------------------------------------------------------------------+ ``` + +```sql select orthogonal_bitmap_expr_calculate_count(user_id, tag, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23') from user_str_tag_bitmap where tag in ('A:a/b', 'B:2-4', 'C:1', 'D:12', 'E:23'); Note: 'A:a/b', 'B:2-4', etc. are string types tag, representing different labels of users, where 'B:2-4' needs to be escaped as'B:2\\-4' ``` -### keywords - - ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT,BITMAP +```text ++---------------------------------------------------------------------------------------------+ +| orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23') | ++---------------------------------------------------------------------------------------------+ +| 30 | ++---------------------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md index e25c3611cfa0d..9b0a6ce71429c 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md @@ -1,7 +1,7 @@ --- { -"title": "ORTHOGONAL_BITMAP_EXPR_CALCULATE", -"language": "en" + "title": "orthogonal_bitmap_expr_calculate", + "language": "en" } --- @@ -13,7 +13,9 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -22,26 +24,52 @@ specific language governing permissions and limitations under the License. --> -## orthogonal_bitmap_expr_calculate -### description -#### Syntax +## Description -`BITMAP ORTHOGONAL_BITMAP_EXPR_CALCULATE(bitmap_column, column_to_filter, input_string)` -The first parameter is the Bitmap column, the second parameter is the dimension column used for filtering, that is, the calculated key column, and the third parameter is the calculation expression string, meaning that the bitmap intersection, union, and difference set expression is calculated according to the key column -The calculators supported by the expression:&represents intersection calculation, | represents union calculation, - represents difference calculation, ^ represents XOR calculation, and \ represents escape characters +The ORTHOGONAL_BITMAP_EXPR_CALCULATE function returns the set obtained after performing intersection, union, and difference calculations on the Bitmap expression. -### example +## Syntax +```sql +ORTHOGONAL_BITMAP_EXPR_CALCULATE(, , ) ``` -select orthogonal_bitmap_expr_calculate(user_id, tag, '(833736|999777)&(1308083|231207)&(1000|20000-30000)') from user_tag_bitmap where tag in (833736,999777,130808,231207,1000,20000,30000); + +## Parameters + +| 参数 | 说明 | +| -- | -- | +| `` | The Bitmap type expression needs to be obtained | +| `` | The filtering dimension column, the Key column for calculation | +| `` | The calculation expression string, meaning that the Bitmap intersection, union, and difference set expressions are calculated based on the Key column. The supported operators in the expression: &represents intersection calculation, \| represents union calculation, - represents difference calculation, ^ represents XOR calculation, and \ represents escape characters | + +## Return Value + +Returns a set of BITMAP type. + +## Example + +```sql +select bitmap_count(orthogonal_bitmap_expr_calculate(user_id, tag, '(833736|999777)&(1308083|231207)&(1000|20000-30000)')) from user_tag_bitmap where tag in (833736,999777,130808,231207,1000,20000,30000); Note: 1000, 20000, 30000 plastic tags represent different labels of users ``` +```text ++-------------------------------------------------------------------------------------------------------------------------------+ +| bitmap_count(orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(833736|999777)&(1308083|231207)&(1000|20000-30000)')) | ++-------------------------------------------------------------------------------------------------------------------------------+ +| 1000 | ++-------------------------------------------------------------------------------------------------------------------------------+ ``` -select orthogonal_bitmap_expr_calculate(user_id, tag, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23') from user_str_tag_bitmap where tag in ('A:a/b', 'B:2-4', 'C:1', 'D:12', 'E:23'); + +```sql +select bitmap_count(orthogonal_bitmap_expr_calculate(user_id, tag, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23')) from user_str_tag_bitmap where tag in ('A:a/b', 'B:2-4', 'C:1', 'D:12', 'E:23'); Note: 'A:a/b', 'B:2-4', etc. are string types tag, representing different labels of users, where 'B:2-4' needs to be escaped as'B:2\\-4' ``` -### keywords - - ORTHOGONAL_BITMAP_EXPR_CALCULATE,BITMAP +```text ++-----------------------------------------------------------------------------------------------------------+ +| bitmap_count(orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23')) | ++-----------------------------------------------------------------------------------------------------------+ +| 30 | ++-----------------------------------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md index 3884e4f47151f..57f1f722b36cc 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md @@ -1,7 +1,7 @@ --- { -"title": "ORTHOGONAL_BITMAP_INTERSECT_COUNT", -"language": "en" + "title": "orthogonal_bitmap_intersect_count", + "language": "en" } --- @@ -13,7 +13,9 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -22,25 +24,39 @@ specific language governing permissions and limitations under the License. --> -## orthogonal_bitmap_intersect_count -### description -#### Syntax +## Description + +The ORTHOGONAL_BITMAP_INTERSECT_COUNT function returns the number of elements in the set after performing an intersection calculation on the Bitmap expression. + +## Syntax + +```sql +ORTHOGONAL_BITMAP_INTERSECT_COUNT(, , ) +``` + +## Parameters -`BITMAP ORTHOGONAL_BITMAP_INTERSECT_COUNT(bitmap_column, column_to_filter, filter_values)` -The bitmap intersection count function, the first parameter is the bitmap column, the second parameter is the dimension column for filtering, and the third parameter is the variable length parameter, which means different values of the filter dimension column +| Parameters | Description | +| -- | -- | +| `` | The Bitmap type expression needs to be obtained | +| `` | Optional. The dimension column that needs to be filtered | +| `` | Optional. A variable-length parameter, used to filter different values of the dimension column | -### example +## Return Value + +Returns a value of type BIGINT. + +## Example + +```sql +select orthogonal_bitmap_intersect_count(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); ``` -mysql> select orthogonal_bitmap_intersect_count(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); + +```text +-------------------------------------------------------------------------------------+ | orthogonal_bitmap_intersect_count(`members`, `tag_group`, 1150000, 1150001, 390006) | +-------------------------------------------------------------------------------------+ | 0 | +-------------------------------------------------------------------------------------+ -1 row in set (3.382 sec) -``` - -### keywords - - ORTHOGONAL_BITMAP_INTERSECT_COUNT,BITMAP +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md index c7be4fdcf6e80..bdcbe0b1e39ca 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md @@ -1,7 +1,7 @@ --- { -"title": "ORTHOGONAL_BITMAP_INTERSECT", -"language": "en" + "title": "orthogonal_bitmap_intersect", + "language": "en" } --- @@ -13,7 +13,9 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -22,26 +24,39 @@ specific language governing permissions and limitations under the License. --> -## orthogonal_bitmap_intersect -### description -#### Syntax +## Description -`BITMAP ORTHOGONAL_BITMAP_INTERSECT(bitmap_column, column_to_filter, filter_values)` -The bitmap intersection function, the first parameter is the bitmap column, the second parameter is the dimension column for filtering, and the third parameter is the variable length parameter, which means different values of the filter dimension column +The ORTHOGONAL_BITMAP_INTERSECT function returns the intersection set of the Bitmap expression. -### example +## Syntax +```sql +ORTHOGONAL_BITMAP_INTERSECT(, , ) ``` -mysql> select orthogonal_bitmap_intersect(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The Bitmap type expression needs to be obtained | +| `` | Optional. The dimension column that needs to be filtered | +| `` | Optional. A variable-length parameter, used to filter different values of the dimension column | + +## Return Value + +Returns a set of BITMAP type. + +## Example + +```sql +select orthogonal_bitmap_intersect(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); + +``` + +```text +-------------------------------------------------------------------------------+ | orthogonal_bitmap_intersect(`members`, `tag_group`, 1150000, 1150001, 390006) | +-------------------------------------------------------------------------------+ | NULL | +-------------------------------------------------------------------------------+ -1 row in set (3.505 sec) - -``` - -### keywords - - ORTHOGONAL_BITMAP_INTERSECT,BITMAP +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md index 18d5fc76f1a2e..f234df23dd180 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md @@ -1,7 +1,7 @@ --- { -"title": "ORTHOGONAL_BITMAP_UNION_COUNT", -"language": "en" + "title": "orthogonal_bitmap_union_count", + "language": "en" } --- @@ -13,7 +13,9 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -22,25 +24,38 @@ specific language governing permissions and limitations under the License. --> -## orthogonal_bitmap_union_count -### description -#### Syntax +## Description -`BITMAP ORTHOGONAL_BITMAP_UNION_COUNT(bitmap_column, column_to_filter, filter_values)` -Figure out the bitmap union count function, syntax with the original bitmap_union_count, but the implementation is different. +The ORTHOGONAL_BITMAP_UNION_COUNT function returns the number of elements in the set after performing a union calculation on the Bitmap expression. -### example +## Syntax +```sql +ORTHOGONAL_BITMAP_UNION_COUNT(, , ) ``` -mysql> select orthogonal_bitmap_union_count(members) from tag_map where tag_group in ( 1150000, 1150001, 390006); + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The Bitmap type expression needs to be obtained | +| `` | Optional. The dimension column that needs to be filtered | +| `` | Optional. A variable-length parameter, used to filter different values of the dimension column | + +## Return Value + +Returns a set of BITMAP type. + +## Example + +```sql +select ORTHOGONAL_BITMAP_UNION_COUNT(members) from tag_map where tag_group in ( 1150000, 1150001, 390006); +``` + +```text +------------------------------------------+ | orthogonal_bitmap_union_count(`members`) | +------------------------------------------+ | 286957811 | +------------------------------------------+ -1 row in set (2.645 sec) -``` - -### keywords - - ORTHOGONAL_BITMAP_UNION_COUNT,BITMAP \ No newline at end of file +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile-approx.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile-approx.md index 627ebc09797a1..e0810d31d902e 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile-approx.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile-approx.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,33 +22,73 @@ specific language governing permissions and limitations under the License. --> -## PERCENTILE_APPROX -### Description -#### Syntax +## Description + +The `PERCENTILE_APPROX` function is used to calculate approximate percentiles, primarily for large datasets. Compared to the `PERCENTILE` function, it has the following features: + +1. Memory Efficiency: Uses fixed-size memory, maintaining low memory consumption even when processing high-cardinality columns (large data volumes) +2. Performance Advantage: Suitable for processing large-scale datasets with faster computation +3. Adjustable Precision: Balance between precision and performance through the compression parameter + + +## Syntax + +```sql +PERCENTILE_APPROX(,

[, ]) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The column to calculate percentiles for | +| `

` | Percentile value, range `[0.0, 1.0]`, e.g., `0.99` represents the `99th` percentile | +| `` | Optional parameter, compression level, range `[2048, 10000]`, higher values increase precision but consume more memory. If not specified or out of range, uses `10000` | + +## Return Value -`PERCENTILE_APPROX(expr, DOUBLE p[, DOUBLE compression])` +Returns a `DOUBLE` value representing the calculated approximate percentile. -Return the approximation of the point p, where the value of P is between 0 and 1. +## Examples -Compression param is optional and can be setted to a value in the range of [2048, 10000]. The bigger compression you set, the more precise result and more time cost you will get. If it is not setted or not setted in the correct range, PERCENTILE_APPROX function will run with a default compression param of 10000. +```sql +-- Create sample table +CREATE TABLE response_times ( + request_id INT, + response_time DECIMAL(10, 2) +) DUPLICATE KEY(`request_id`) +DISTRIBUTED BY HASH(`request_id`) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); -This function uses fixed size memory, so less memory can be used for columns with high cardinality, and can be used to calculate statistics such as tp99. +-- Insert sample data +INSERT INTO response_times VALUES +(1, 10.5), +(2, 15.2), +(3, 20.1), +(4, 25.8), +(5, 30.3), +(6, 35.7), +(7, 40.2), +(8, 45.9), +(9, 50.4), +(10, 100.6); -### example +-- Calculate 99th percentile using different compression levels +SELECT + percentile_approx(response_time, 0.99) as p99_default, -- Default compression + percentile_approx(response_time, 0.99, 2048) as p99_fast, -- Lower compression, faster + percentile_approx(response_time, 0.99, 10000) as p99_accurate -- Higher compression, more accurate +FROM response_times; ``` -MySQL > select `table`, percentile_approx(cost_time,0.99) from log_statis group by `table`; -+---------------------+---------------------------+ -| table | percentile_approx(`cost_time`, 0.99) | -+----------+--------------------------------------+ -| test | 54.22 | -+----------+--------------------------------------+ - -MySQL > select `table`, percentile_approx(cost_time,0.99, 4096) from log_statis group by `table`; -+---------------------+---------------------------+ -| table | percentile_approx(`cost_time`, 0.99, 4096.0) | -+----------+--------------------------------------+ -| test | 54.21 | -+----------+--------------------------------------+ + +```text ++-------------------+-------------------+-------------------+ +| p99_default | p99_fast | p99_accurate | ++-------------------+-------------------+-------------------+ +| 100.5999984741211 | 100.5999984741211 | 100.5999984741211 | ++-------------------+-------------------+-------------------+ ``` -### keywords -PERCENTILE_APPROX,PERCENTILE,APPROX + + diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile-array.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile-array.md index 42c697a84e464..70039bda6b239 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile-array.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile-array.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,29 +22,68 @@ specific language governing permissions and limitations under the License. --> -## PERCENTILE_ARRAY -### Description -#### Syntax +## Description + +The `PERCENTILE_ARRAY` function calculates exact percentile arrays, allowing multiple percentile values to be computed at once. This function is primarily suitable for small datasets. -`ARRAY_DOUBLE PERCENTILE_ARRAY(expr, ARRAY_DOUBLE p)` +Key features: +1. Exact Calculation: Provides exact percentile results rather than approximations +2. Batch Processing: Can calculate multiple percentiles in a single operation +3. Scope: Best suited for handling small-scale datasets -Calculate exact percentiles, suitable for small data volumes. Sorts the specified column in descending order first, then takes the exact pth percentile. -The return value is the result of sequentially taking the specified percentages in the array p. -Parameter Description: -expr: Required. Columns whose values are of type integer (up to bigint). -p: The exact percentile is required, an array of constants, taking the value [0.0, 1.0]. -### example +## Syntax + +```sql +PERCENTILE_ARRAY(, ) ``` -mysql> select percentile_array(k1,[0.3,0.5,0.9]) from baseall; -+----------------------------------------------+ -| percentile_array(`k1`, ARRAY(0.3, 0.5, 0.9)) | -+----------------------------------------------+ -| [5.2, 8, 13.6] | -+----------------------------------------------+ -1 row in set (0.02 sec) +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The column to calculate the percentile for | +| `` | Percentile array, each element must be in the range `[0.0, 1.0]`, e.g., `[0.5, 0.95, 0.99]` | + +## Return Value + +Return a `DOUBLE` type array, containing the calculated percentile values. + +## Examples + +```sql +-- Create sample table +CREATE TABLE sales_data ( + id INT, + amount DECIMAL(10, 2) +) DUPLICATE KEY(`id`) +DISTRIBUTED BY HASH(`id`) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- Insert sample data +INSERT INTO sales_data VALUES +(1, 10.5), +(2, 15.2), +(3, 20.1), +(4, 25.8), +(5, 30.3), +(6, 35.7), +(7, 40.2), +(8, 45.9), +(9, 50.4), +(10, 100.6); + +-- Calculate multiple percentiles +SELECT percentile_array(amount, [0.25, 0.5, 0.75, 0.9]) as percentiles +FROM sales_data; ``` -### keywords -PERCENTILE_ARRAY +```text ++-----------------------------------------+ +| percentiles | ++-----------------------------------------+ +| [21.25, 32.5, 43.75, 54.99999999999998] | ++-----------------------------------------+ +``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md deleted file mode 100644 index ae807db60062e..0000000000000 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -{ - "title": "PERCENTILE_APPROX_WEIGHTED", - "language": "en" -} ---- - - - -## PERCENTILE_APPROX_WEIGHTED -### description -#### Syntax - -`PERCENTILE_APPROX_WEIGHTED(expr, w ,DOUBLE p [, DOUBLE compression])` - - -The function is similar to PERCENTILE_APPROX, with the only difference being an additional parameter w, which represents the number of times expr appears. -Note that the value of parameter W needs to be greater than 0. If the value of a row is less than or equal to 0 during the calculation process, the current row will be skipped. - -### example -``` -mysql >select * from quantile_weighted_table order by k; -+------+------+ -| k | w | -+------+------+ -| 1 | 2 | -| 3 | 1 | -| 5 | 2 | -+------+------+ - - -mysql >select percentile_approx_weighted(k,w,0.55) from quantile_weighted_table; -+----------------------------------------------------------------------------------------+ -| percentile_approx_weighted(cast(k as DOUBLE), cast(w as DOUBLE), cast(0.55 as DOUBLE)) | -+----------------------------------------------------------------------------------------+ -| 3.3333332538604736 | -+----------------------------------------------------------------------------------------+ - -``` - -### keywords -PERCENTILE_APPROX,PERCENTILE,APPROX,PERCENTILE_APPROX_WEIGHTED diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/quantile-union.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/quantile-union.md index 1eb0e3aee78b5..b70301d9518cf 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/quantile-union.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/quantile-union.md @@ -1,6 +1,6 @@ --- { - "title": "quantile_union", + "title": "QUANTILE_UNION", "language": "en" } --- @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -23,3 +21,73 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## Description + +The `QUANTILE_UNION` function is used to merge intermediate results from multiple quantile calculations. This function typically works in conjunction with `QUANTILE_STATE` and is particularly useful in scenarios requiring multi-stage quantile calculations. + +## Syntax + +```sql +QUANTILE_UNION() +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The intermediate state generated by the `TO_QUANTILE_STATE` function. | + +## Return Value + +Returns an aggregation state that can be used for further quantile calculations. The result of this function remains a `QUANTILE_STATE`. + +## Example + +```sql +-- Create sample table +CREATE TABLE response_times ( + request_id INT, + response_time DOUBLE, + region STRING +) DUPLICATE KEY(request_id) +DISTRIBUTED BY HASH(request_id) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- Insert sample data +INSERT INTO response_times VALUES +(1, 10.5, 'east'), +(2, 15.2, 'east'), +(3, 20.1, 'west'), +(4, 25.8, 'east'), +(5, 30.3, 'west'), +(6, 35.7, 'east'), +(7, 40.2, 'west'), +(8, 45.9, 'east'), +(9, 50.4, 'west'), +(10, 100.6, 'east'); + +-- Calculate 50th percentile of response times by region +SELECT + region, + QUANTILE_PERCENT( + QUANTILE_UNION( + TO_QUANTILE_STATE(response_time, 2048) + ), + 0.5 + ) AS median_response_time +FROM response_times +GROUP BY region; + +``` + +```text ++--------+----------------------+ +| region | median_response_time | ++--------+----------------------+ +| west | 35.25 | +| east | 30.75 | ++--------+----------------------+ +``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/retention.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/retention.md index 6f0ea487838aa..043a6ffc8c8b9 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/retention.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/retention.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,118 +22,72 @@ specific language governing permissions and limitations under the License. --> -## RETENTION - -RETENTION - -### Description -#### Syntax - -`retention(event1, event2, ... , eventN);` +## Description The `retention` function takes as arguments a set of conditions from 1 to 32 arguments of type `UInt8` that indicate whether a certain condition was met for the event. Any condition can be specified as an argument. The conditions, except the first, apply in pairs: the result of the second will be true if the first and second are true, of the third if the first and third are true, etc. -To put it simply, the first digit of the return value array indicates whether `event1` is true or false, the second digit represents the truth and falseness of `event1` and `event2`, and the third digit represents whether `event1` is true or false and `event3` is true False and, and so on. If `event1` is false, return an array full of zeros. +To put it simply, the first digit of the return value array indicates whether `event_1` is true or false, the second digit represents the truth and falseness of `event_1` and `event_2`, and the third digit represents whether `event_1` is true or false and `event_3` is true False and, and so on. If `event_1` is false, return an array full of zeros. -#### Arguments +## Syntax -`event` — An expression that returns a `UInt8` result (1 or 0). +```sql +RETENTION( [, , ... , ]); +``` -##### Returned value +## Parameters -An array of 1s and 0s with a maximum length of 32 bits, the final output array has the same length as the input parameter. +| Parameter | Description | +| -- | -- | +| `` | The `n`th event condition, of type `UInt8` and value 1 or 0. | -1 — Condition was met for the event. +## Returned value -0 — Condition wasn’t met for the event. +An array of 1 and 0 with a maximum length of 32, where the final output array length matches the input parameter length. -### example +- 1: Condition is met. +- 0: Condition is not met. -```sql -DROP TABLE IF EXISTS retention_test; +## Examples +```sql +-- Create sample table CREATE TABLE retention_test( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( - "replication_num" = "1" -); - -INSERT into retention_test (uid, date) values (0, '2022-10-12'), - (0, '2022-10-13'), - (0, '2022-10-14'), - (1, '2022-10-12'), - (1, '2022-10-13'), - (2, '2022-10-12'); - -SELECT * from retention_test; - -+------+---------------------+ -| uid | date | -+------+---------------------+ -| 0 | 2022-10-14 00:00:00 | -| 0 | 2022-10-13 00:00:00 | -| 0 | 2022-10-12 00:00:00 | -| 1 | 2022-10-13 00:00:00 | -| 1 | 2022-10-12 00:00:00 | -| 2 | 2022-10-12 00:00:00 | -+------+---------------------+ - + "replication_allocation" = "tag.location.default: 1" +); + +-- Insert sample data +INSERT into retention_test values +(0, '2022-10-12'), +(0, '2022-10-13'), +(0, '2022-10-14'), +(1, '2022-10-12'), +(1, '2022-10-13'), +(2, '2022-10-12'); + +-- Calculate user retention SELECT uid, - retention(date = '2022-10-12') - AS r - FROM retention_test - GROUP BY uid - ORDER BY uid ASC; - -+------+------+ -| uid | r | -+------+------+ -| 0 | [1] | -| 1 | [1] | -| 2 | [1] | -+------+------+ - -SELECT - uid, - retention(date = '2022-10-12', date = '2022-10-13') - AS r - FROM retention_test - GROUP BY uid - ORDER BY uid ASC; - -+------+--------+ -| uid | r | -+------+--------+ -| 0 | [1, 1] | -| 1 | [1, 1] | -| 2 | [1, 0] | -+------+--------+ - -SELECT - uid, - retention(date = '2022-10-12', date = '2022-10-13', date = '2022-10-14') - AS r - FROM retention_test - GROUP BY uid - ORDER BY uid ASC; - -+------+-----------+ -| uid | r | -+------+-----------+ -| 0 | [1, 1, 1] | -| 1 | [1, 1, 0] | -| 2 | [1, 0, 0] | -+------+-----------+ - + RETENTION(date = '2022-10-12') AS r, + RETENTION(date = '2022-10-12', date = '2022-10-13') AS r2, + RETENTION(date = '2022-10-12', date = '2022-10-13', date = '2022-10-14') AS r3 +FROM retention_test +GROUP BY uid +ORDER BY uid ASC; ``` -### keywords - -RETENTION +```text ++------+------+--------+-----------+ +| uid | r | r2 | r3 | ++------+------+--------+-----------+ +| 0 | [1] | [1, 1] | [1, 1, 1] | +| 1 | [1] | [1, 1] | [1, 1, 0] | +| 2 | [1] | [1, 0] | [1, 0, 0] | ++------+------+--------+-----------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sequence-count.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sequence-count.md index 68abb404dcaad..d0a55625aeb96 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sequence-count.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sequence-count.md @@ -1,6 +1,6 @@ --- { - "title": "SEQUENCE-COUNT", + "title": "SEQUENCE_COUNT", "language": "en" } --- @@ -22,11 +22,7 @@ specific language governing permissions and limitations under the License. --> -## SEQUENCE-COUNT -### Description -#### Syntax - -`sequence_count(pattern, timestamp, cond1, cond2, ...);` +## Description Counts the number of event chains that matched the pattern. The function searches event chains that do not overlap. It starts to search for the next chain after the current chain is matched. @@ -34,188 +30,140 @@ Counts the number of event chains that matched the pattern. The function searche Events that occur at the same second may lay in the sequence in an undefined order affecting the result. -#### Arguments +## Syntax + +```sql +SEQUENCE_COUNT(, , [, , ..., ]); +``` + +## Parameters -`pattern` — Pattern string. +| Parameter | Description | +| -- | -- | +| `` | Pattern string, see **Pattern syntax** below. | +| `` | Column considered to contain time data. Typical data types are `Date` and `DateTime`. You can also use any of the supported UInt data types. | +| `` | Conditions that describe the chain of events. Data type: `UInt8`. You can pass up to 32 condition arguments. The function takes only the events described in these conditions into account. If the sequence contains data that isn’t described in a condition, the function skips them. | **Pattern syntax** -`(?N)` — Matches the condition argument at position N. Conditions are numbered in the `[1, 32]` range. For example, `(?1)` matches the argument passed to the `cond1` parameter. - -`.*` — Matches any number of events. You do not need conditional arguments to count this element of the pattern. +- `(?N)` — Matches the condition argument at position N. Conditions are numbered in the `[1, 32]` range. For example, `(?1)` matches the argument passed to the `cond_1` parameter. -`(?t operator value)` — Sets the time in seconds that should separate two events. +- `.*` — Matches any number of events. You do not need conditional arguments to count this element of the pattern. -We define `t` as the difference in seconds between two times, For example, pattern `(?1)(?t>1800)(?2)` matches events that occur more than 1800 seconds from each other. pattern `(?1)(?t>10000)(?2)` matches events that occur more than 10000 seconds from each other. An arbitrary number of any events can lay between these events. You can use the `>=`, `>`, `<`, `<=`, `==` operators. +- `(?t operator value)` — Sets the time in seconds that should separate two events. -`timestamp` — Column considered to contain time data. Typical data types are `Date` and `DateTime`. You can also use any of the supported UInt data types. +- We define `t` as the difference in seconds between two times, For example, pattern `(?1)(?t>1800)(?2)` matches events that occur more than 1800 seconds from each other. pattern `(?1)(?t>10000)(?2)` matches events that occur more than 10000 seconds from each other. An arbitrary number of any events can lay between these events. You can use the `>=`, `>`, `<`, `<=`, `==` operators. -`cond1`, `cond2` — Conditions that describe the chain of events. Data type: `UInt8`. You can pass up to 32 condition arguments. The function takes only the events described in these conditions into account. If the sequence contains data that isn’t described in a condition, the function skips them. -#### Returned value +## Return Value Number of non-overlapping event chains that are matched. -### example +## Examples -**count examples** +**Matching examples** ```sql -DROP TABLE IF EXISTS sequence_count_test2; - -CREATE TABLE sequence_count_test2( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 +-- Create sample table +CREATE TABLE sequence_count_test1( + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_count_test2(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 13:28:02', 2), - (3, '2022-11-02 16:15:01', 1), - (4, '2022-11-02 19:05:04', 2), - (5, '2022-11-02 20:08:44', 3); - -SELECT * FROM sequence_count_test2 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 13:28:02 | 2 | -| 3 | 2022-11-02 16:15:01 | 1 | -| 4 | 2022-11-02 19:05:04 | 2 | -| 5 | 2022-11-02 20:08:44 | 3 | -+------+---------------------+--------+ - -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 3) FROM sequence_count_test2; - -+----------------------------------------------------------------+ -| sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 3) | -+----------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 2) FROM sequence_count_test2; - -+----------------------------------------------------------------+ -| sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 2 | -+----------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?t>=10000)(?2)', date, number = 1, number = 2) FROM sequence_count_test1; +-- Insert sample data +INSERT INTO sequence_count_test1(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 13:28:02', 2), +(3, '2022-11-02 16:15:01', 1), +(4, '2022-11-02 19:05:04', 2), +(5, '2022-11-02 20:08:44', 3); + +-- Query example +SELECT + SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 3) as c1, + SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 2) as c2, + SEQUENCE_COUNT('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) as c3 +FROM sequence_count_test1; +``` -+---------------------------------------------------------------------------+ -| sequence_count('(?1)(?t>=3600)(?2)', `date`, `number` = 1, `number` = 2) | -+---------------------------------------------------------------------------+ -| 2 | -+---------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 1 | 2 | 2 | ++------+------+------+ ``` -**not count examples** +**Non-matching examples** ```sql -DROP TABLE IF EXISTS sequence_count_test1; - -CREATE TABLE sequence_count_test1( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 +-- Create sample table +CREATE TABLE sequence_count_test2( + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_count_test1(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_count_test1 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ - -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 2) FROM sequence_count_test1; - -+----------------------------------------------------------------+ -| sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 0 | -+----------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?2).*', date, number = 1, number = 2) FROM sequence_count_test1; - -+------------------------------------------------------------------+ -| sequence_count('(?1)(?2).*', `date`, `number` = 1, `number` = 2) | -+------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?t>3600)(?2)', date, number = 1, number = 7) FROM sequence_count_test1; +-- Insert sample data +INSERT INTO sequence_count_test2(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); + +-- Query example +SELECT + SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 2) as c1, + SEQUENCE_COUNT('(?1)(?2).*', date, number = 1, number = 2) as c2, + SEQUENCE_COUNT('(?1)(?t>3600)(?2)', date, number = 1, number = 7) as c3 +FROM sequence_count_test2; +``` -+--------------------------------------------------------------------------+ -| sequence_count('(?1)(?t>3600)(?2)', `date`, `number` = 1, `number` = 7) | -+--------------------------------------------------------------------------+ -| 0 | -+--------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 0 | 0 | 0 | ++------+------+------+ ``` -**special examples** +**Special examples** ```sql -DROP TABLE IF EXISTS sequence_count_test3; - +-- Create sample table CREATE TABLE sequence_count_test3( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_count_test3(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_count_test3 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ -``` - -Perform the query: +-- Insert sample data +INSERT INTO sequence_count_test3(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); -```sql -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5) FROM sequence_count_test3; +-- Query example +SELECT SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 5) FROM sequence_count_test3; +``` +```text +----------------------------------------------------------------+ | sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 5) | +----------------------------------------------------------------+ @@ -228,8 +176,10 @@ This is a very simple example. The function found the event chain where number 5 Now, perform this query: ```sql -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM sequence_count_test3; +SELECT SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM sequence_count_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 4) | +------------------------------------------------------------------------------+ @@ -240,15 +190,13 @@ SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM The result is kind of confusing. In this case, the function couldn’t find the event chain matching the pattern, because the event for number 4 occurred between 1 and 5. If in the same case we checked the condition for number 6, the sequence would count the pattern. ```sql -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5, number = 6) FROM sequence_count_test3; +SELECT SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 5, number = 6) FROM sequence_count_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 6) | +------------------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------------------+ ``` - -### keywords - -SEQUENCE_COUNT \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sequence-match.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sequence-match.md index c088fc2e746f2..a36a00a42f737 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sequence-match.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sequence-match.md @@ -22,11 +22,7 @@ specific language governing permissions and limitations under the License. --> -## SEQUENCE-MATCH -### Description -#### Syntax - -`sequence_match(pattern, timestamp, cond1, cond2, ...);` +## Description Checks whether the sequence contains an event chain that matches the pattern. @@ -34,190 +30,135 @@ Checks whether the sequence contains an event chain that matches the pattern. Events that occur at the same second may lay in the sequence in an undefined order affecting the result. -#### Arguments -`pattern` — Pattern string. +## Syntax -**Pattern syntax** +```sql +SEQUENCE_MATCH(, , [, , ..., ]) +``` -`(?N)` — Matches the condition argument at position N. Conditions are numbered in the `[1, 32]` range. For example, `(?1)` matches the argument passed to the `cond1` parameter. +## Parameters -`.*` — Matches any number of events. You do not need conditional arguments to match this element of the pattern. +| Parameter | Description | +| -- | -- | +| `` | Pattern string. See **Pattern syntax** below. | +| `` | Column considered to contain time data. Typical data types are `Date` and `DateTime`. You can also use any of the supported UInt data types. | +| `` | Conditions that describe the chain of events. Data type: `UInt8`. You can pass up to 32 condition arguments. The function takes only the events described in these conditions into account. If the sequence contains data that isn’t described in a condition, the function skips them. | -`(?t operator value)` — Sets the time in seconds that should separate two events. +**Pattern syntax** -We define `t` as the difference in seconds between two times, For example, pattern `(?1)(?t>1800)(?2)` matches events that occur more than 1800 seconds from each other. pattern `(?1)(?t>10000)(?2)` matches events that occur more than 10000 seconds from each other. An arbitrary number of any events can lay between these events. You can use the `>=`, `>`, `<`, `<=`, `==` operators. +- `(?N)` — Matches the condition argument at position N. Conditions are numbered in the `[1, 32]` range. For example, `(?1)` matches the argument passed to the `cond1` parameter. -`timestamp` — Column considered to contain time data. Typical data types are `Date` and `DateTime`. You can also use any of the supported UInt data types. +- `.*` — Matches any number of events. You do not need conditional arguments to match this element of the pattern. -`cond1`, `cond2` — Conditions that describe the chain of events. Data type: `UInt8`. You can pass up to 32 condition arguments. The function takes only the events described in these conditions into account. If the sequence contains data that isn’t described in a condition, the function skips them. +- `(?t operator value)` — Sets the time in seconds that should separate two events. -#### Returned value +- We define `t` as the difference in seconds between two times, For example, pattern `(?1)(?t>1800)(?2)` matches events that occur more than 1800 seconds from each other. pattern `(?1)(?t>10000)(?2)` matches events that occur more than 10000 seconds from each other. An arbitrary number of any events can lay between these events. You can use the `>=`, `>`, `<`, `<=`, `==` operators. -1, if the pattern is matched. +## Return value -0, if the pattern isn’t matched. +1: if the pattern is matched. -### example +0: if the pattern isn’t matched. -**match examples** +## Examples -```sql -DROP TABLE IF EXISTS sequence_match_test1; +**Match examples** +```sql CREATE TABLE sequence_match_test1( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_match_test1(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 13:28:02', 2), - (3, '2022-11-02 16:15:01', 1), - (4, '2022-11-02 19:05:04', 2), - (5, '2022-11-02 20:08:44', 3); - -SELECT * FROM sequence_match_test1 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 13:28:02 | 2 | -| 3 | 2022-11-02 16:15:01 | 1 | -| 4 | 2022-11-02 19:05:04 | 2 | -| 5 | 2022-11-02 20:08:44 | 3 | -+------+---------------------+--------+ +INSERT INTO sequence_match_test1(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 13:28:02', 2), +(3, '2022-11-02 16:15:01', 1), +(4, '2022-11-02 19:05:04', 2), +(5, '2022-11-02 20:08:44', 3); -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 3) FROM sequence_match_test1; -+----------------------------------------------------------------+ -| sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 3) | -+----------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 2) FROM sequence_match_test1; - -+----------------------------------------------------------------+ -| sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) FROM sequence_match_test1; +SELECT +sequence_match('(?1)(?2)', date, number = 1, number = 3) as c1, +sequence_match('(?1)(?2)', date, number = 1, number = 2) as c2, +sequence_match('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) as c3 +FROM sequence_match_test1; +``` -+---------------------------------------------------------------------------+ -| sequence_match('(?1)(?t>=3600)(?2)', `date`, `number` = 1, `number` = 2) | -+---------------------------------------------------------------------------+ -| 1 | -+---------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 1 | 1 | 1 | ++------+------+------+ ``` -**not match examples** +**Not match examples** ```sql -DROP TABLE IF EXISTS sequence_match_test2; - CREATE TABLE sequence_match_test2( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_match_test2(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_match_test2 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ - -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 2) FROM sequence_match_test2; - -+----------------------------------------------------------------+ -| sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 0 | -+----------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?2).*', date, number = 1, number = 2) FROM sequence_match_test2; - -+------------------------------------------------------------------+ -| sequence_match('(?1)(?2).*', `date`, `number` = 1, `number` = 2) | -+------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?t>3600)(?2)', date, number = 1, number = 7) FROM sequence_match_test2; +INSERT INTO sequence_match_test2(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); + +SELECT +sequence_match('(?1)(?2)', date, number = 1, number = 2) as c1, +sequence_match('(?1)(?2).*', date, number = 1, number = 2) as c2, +sequence_match('(?1)(?t>3600)(?2)', date, number = 1, number = 7) as c3 +FROM sequence_match_test2; +``` -+--------------------------------------------------------------------------+ -| sequence_match('(?1)(?t>3600)(?2)', `date`, `number` = 1, `number` = 7) | -+--------------------------------------------------------------------------+ -| 0 | -+--------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 0 | 0 | 0 | ++------+------+------+ ``` -**special examples** +**Special examples** ```sql -DROP TABLE IF EXISTS sequence_match_test3; - CREATE TABLE sequence_match_test3( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_match_test3(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_match_test3 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ -``` +INSERT INTO sequence_match_test3(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); -Perform the query: - -```sql -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5) FROM sequence_match_test3; +SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5) +FROM sequence_match_test3; +``` +```text +----------------------------------------------------------------+ | sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 5) | +----------------------------------------------------------------+ @@ -230,8 +171,11 @@ This is a very simple example. The function found the event chain where number 5 Now, perform this query: ```sql -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM sequence_match_test3; +SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 4) +FROM sequence_match_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 4) | +------------------------------------------------------------------------------+ @@ -242,15 +186,14 @@ SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM The result is kind of confusing. In this case, the function couldn’t find the event chain matching the pattern, because the event for number 4 occurred between 1 and 5. If in the same case we checked the condition for number 6, the sequence would match the pattern. ```sql -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 6) FROM sequence_match_test3; +SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 6) +FROM sequence_match_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 6) | +------------------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------------------+ ``` - -### keywords - -SEQUENCE_MATCH \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/stddev-samp.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/stddev-samp.md index 086c7b4d84113..45be4c6c9c7d5 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/stddev-samp.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/stddev-samp.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,23 +22,54 @@ specific language governing permissions and limitations under the License. --> -## STDDEV_SAMP -### Description -#### Syntax +## Description + +Returns the sample standard deviation of the expr expression -`STDDEV SAMP (expr)` +## Syntax +```sql +STDDEV_SAMP() +``` -Returns the sample standard deviation of the expr expression +## Parameters -### example +| Parameter | Description | +| -- | -- | +| `` | The value to be calculated standard deviation | + +## Return Value + +Return the sample standard deviation of the expr expression + +### Examples +```sql +-- Create sample tables +CREATE TABLE score_table ( + student_id INT, + score DOUBLE +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO score_table VALUES +(1, 85), +(2, 90), +(3, 82), +(4, 88), +(5, 95); + +-- Calculate the sample standard deviation of all students' scores +SELECT STDDEV_SAMP(score) as score_stddev +FROM score_table; ``` -MySQL > select stddev_samp(scan_rows) from log_statis group by datetime; -+--------------------------+ -| stddev_samp(`scan_rows`) | -+--------------------------+ -| 2.372044195280762 | -+--------------------------+ + +```text ++-------------------+ +| score_stddev | ++-------------------+ +| 4.949747468305831 | ++-------------------+ ``` -### keywords -STDDEV SAMP,STDDEV,SAMP diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/stddev.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/stddev.md index d22a6d771792a..f31d41efacf49 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/stddev.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/stddev.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,30 +22,58 @@ specific language governing permissions and limitations under the License. --> -## STDDEV,STDDEV_POP -### Description -#### Syntax +## Description -`stddev (expl)` +Returns the standard deviation of the expr expression +## Alias -Returns the standard deviation of the expr expression +- STDDEV_POP + +## Syntax + +```sql +STDDEV() +``` -### example +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The value to be calculated standard deviation | + +## Return Value + +Return the standard deviation of the expr expression + +## Examples +```sql +-- Create sample tables +CREATE TABLE score_table ( + student_id INT, + score DOUBLE +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO score_table VALUES +(1, 85), +(2, 90), +(3, 82), +(4, 88), +(5, 95); + +-- Calculate the standard deviation of all students' scores +SELECT STDDEV(score) as score_stddev +FROM score_table; ``` -MySQL > select stddev(scan_rows) from log_statis group by datetime; -+---------------------+ -| stddev(`scan_rows`) | -+---------------------+ -| 2.3736656687790934 | -+---------------------+ - -MySQL > select stddev_pop(scan_rows) from log_statis group by datetime; -+-------------------------+ -| stddev_pop(`scan_rows`) | -+-------------------------+ -| 2.3722760595994914 | -+-------------------------+ + +```text ++-------------------+ +| score_stddev | ++-------------------+ +| 4.427188724235729 | ++-------------------+ ``` -### keywords -STDDEV,STDDEV_POP,POP diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sum.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sum.md index 10802b4707ae3..669c0dbdd724b 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sum.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sum.md @@ -24,23 +24,55 @@ specific language governing permissions and limitations under the License. --> -## SUM -### Description -#### Syntax +## Description -`Sum (Expr)` +Used to return the sum of all values of the selected field +## Syntax -Used to return the sum of all values of the selected field +```sql +SUM() +``` + +## Parameters + +| Parameter | Description | +| --- | --- | +| `` | The field to calculate the sum of | -### example +## Return Value + +Return the sum of all values of the selected field. + +## Examples +```sql +-- Create sample tables +CREATE TABLE sales_table ( + product_id INT, + price DECIMAL(10,2), + quantity INT +) DISTRIBUTED BY HASH(product_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO sales_table VALUES +(1, 99.99, 2), +(2, 159.99, 1), +(3, 49.99, 5), +(4, 299.99, 1), +(5, 79.99, 3); + +-- Calculate the total sales amount +SELECT SUM(price * quantity) as total_sales +FROM sales_table; ``` -MySQL > select sum(scan_rows) from log_statis group by datetime; -+------------------+ -| sum(`scan_rows`) | -+------------------+ -| 8217360135 | -+------------------+ + +```text ++-------------+ +| total_sales | ++-------------+ +| 1149.88 | ++-------------+ ``` -### keywords -SUM diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sum0.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sum0.md index 745b70b3043c6..adf052f8b98d6 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sum0.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/sum0.md @@ -1,7 +1,6 @@ --- { - "title": "sum0 - ", + "title": "SUM0", "language": "en" } --- @@ -24,3 +23,60 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## Description + +Used to return the sum of all values of the selected field. Unlike the SUM function, when all input values are NULL, SUM0 returns 0 instead of NULL. + +## Syntax + +```sql +SUM0() +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The field to calculate the sum of | + +## Return Value + +Returns the sum of all values of the selected field. If all values are NULL, returns 0. + +## Examples + +```sql +-- Create example table +CREATE TABLE sales_table ( + product_id INT, + price DECIMAL(10,2), + quantity INT, + discount DECIMAL(10,2) +) DISTRIBUTED BY HASH(product_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO sales_table VALUES +(1, 99.99, 2, NULL), +(2, 159.99, 1, NULL), +(3, 49.99, 5, NULL), +(4, 299.99, 1, NULL), +(5, 79.99, 3, NULL); + +-- Compare SUM and SUM0 +SELECT + SUM(discount) as sum_discount, -- Returns NULL + SUM0(discount) as sum0_discount -- Returns 0 +FROM sales_table; +``` + +```text ++--------------+---------------+ +| sum_discount | sum0_discount | ++--------------+---------------+ +| NULL | 0.00 | ++--------------+---------------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn-array.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn-array.md index 0cb0b177a8b31..f3710a434434e 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn-array.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn-array.md @@ -24,38 +24,60 @@ specific language governing permissions and limitations under the License. --> -## TOPN_ARRAY -### description -#### Syntax +## Description -`ARRAY topn_array(expr, INT top_num[, INT space_expand_rate])` +TOPN_ARRAY returns an array of the N most frequent values in the specified column. It is an approximate calculation function that returns results ordered by count in descending order. -The topn function uses the Space-Saving algorithm to calculate the top_num frequent items in expr, -and return an array about the top n nums, which is an approximation +## Syntax -The space_expand_rate parameter is optional and is used to set the number of counters used in the Space-Saving algorithm +```sql +TOPN_ARRAY(, [, ]) ``` -counter numbers = top_num * space_expand_rate -``` -The higher value of space_expand_rate, the more accurate result will be. The default value is 50 -### example +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The column or expression to be counted. | +| `` | The number of the most frequent values to return. It must be a positive integer. | +| `` | Optional parameter, which is used to set the number of counters used in the Space-Saving algorithm. `counter_numbers = top_num * space_expand_rate` , the larger the value of space_expand_rate, the more accurate the result, and the default value is 50. | + +## Return Value + +Return an array containing the N most frequent values. + +## Examples +```sql +-- Create sample table +CREATE TABLE page_visits ( + page_id INT, + user_id INT, + visit_date DATE +) DISTRIBUTED BY HASH(page_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO page_visits VALUES +(1, 101, '2024-01-01'), +(2, 102, '2024-01-01'), +(1, 103, '2024-01-01'), +(3, 101, '2024-01-01'), +(1, 104, '2024-01-01'), +(2, 105, '2024-01-01'), +(1, 106, '2024-01-01'), +(4, 107, '2024-01-01'); + +-- Find top 3 most visited pages +SELECT TOPN_ARRAY(page_id, 3) as top_pages +FROM page_visits; ``` -mysql> select topn_array(k3,3) from baseall; -+--------------------------+ -| topn_array(`k3`, 3) | -+--------------------------+ -| [3021, 2147483647, 5014] | -+--------------------------+ -1 row in set (0.02 sec) - -mysql> select topn_array(k3,3,100) from baseall; -+--------------------------+ -| topn_array(`k3`, 3, 100) | -+--------------------------+ -| [3021, 2147483647, 5014] | -+--------------------------+ -1 row in set (0.02 sec) + +```text ++-----------+ +| top_pages | ++-----------+ +| [1, 2, 4] | ++-----------+ ``` -### keywords -TOPN, TOPN_ARRAY \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn-weighted.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn-weighted.md index 805ba0ac134ca..627abf9ce9ad0 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn-weighted.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn-weighted.md @@ -24,37 +24,61 @@ specific language governing permissions and limitations under the License. --> -## TOPN_WEIGHTED -### description -#### Syntax +## Description -`ARRAY topn_weighted(expr, BigInt weight, INT top_num[, INT space_expand_rate])` +The TOPN_WEIGHTED function returns the N most frequent values in the specified column with weighted counting. Unlike the regular TOPN function, TOPN_WEIGHTED allows adjusting the importance of values through weights. -The topn_weighted function is calculated using the Space-Saving algorithm, and the sum of the weights in expr is the result of the top n numbers, which is an approximate value +## Syntax -The space_expand_rate parameter is optional and is used to set the number of counters used in the Space-Saving algorithm +```sql +TOPN_WEIGHTED(, , [, ]) ``` -counter numbers = top_num * space_expand_rate -``` -The higher value of space_expand_rate, the more accurate result will be. The default value is 50 -### example +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The column or expression to be counted | +| `` | The column or expression to adjust the weight | +| `` | The number of the most frequent values to return. It must be a positive integer. | +| `` | Optional, the value to set the counter_numbers used in the Space-Saving algorithm. `counter_numbers = top_num * space_expand_rate`. The value of space_expand_rate should be greater than 1, and the default value is 50. | + +## Return Value + +Return an array containing values and weighted counts. + +## Examples +```sql +-- create example table +CREATE TABLE product_sales ( + product_id INT, + sale_amount DECIMAL(10,2), + sale_date DATE +) DISTRIBUTED BY HASH(product_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- insert test data +INSERT INTO product_sales VALUES +(1, 100.00, '2024-01-01'), +(2, 50.00, '2024-01-01'), +(1, 150.00, '2024-01-01'), +(3, 75.00, '2024-01-01'), +(1, 200.00, '2024-01-01'), +(2, 80.00, '2024-01-01'), +(1, 120.00, '2024-01-01'), +(4, 90.00, '2024-01-01'); + +-- find the top 3 products with highest sales amount +SELECT TOPN_WEIGHTED(product_id, sale_amount, 3) as top_products +FROM product_sales; ``` -mysql> select topn_weighted(k5,k1,3) from baseall; -+------------------------------+ -| topn_weighted(`k5`, `k1`, 3) | -+------------------------------+ -| [0, 243.325, 100.001] | -+------------------------------+ -1 row in set (0.02 sec) - -mysql> select topn_weighted(k5,k1,3,100) from baseall; -+-----------------------------------+ -| topn_weighted(`k5`, `k1`, 3, 100) | -+-----------------------------------+ -| [0, 243.325, 100.001] | -+-----------------------------------+ -1 row in set (0.02 sec) + +```text ++--------------+ +| top_products | ++--------------+ +| [1, 2, 4] | ++--------------+ ``` -### keywords -TOPN, TOPN_WEIGHTED \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn.md index 8ca8840b44533..eb25148fe58d2 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/topn.md @@ -24,38 +24,59 @@ specific language governing permissions and limitations under the License. --> -## TOPN -### description -#### Syntax +## Description -`topn(expr, INT top_num[, INT space_expand_rate])` +The TOPN function returns the N most frequent values in the specified column. It is an approximate calculation function that returns results ordered by count in descending order. -The topn function uses the Space-Saving algorithm to calculate the top_num frequent items in expr, and the result is the -frequent items and their occurrence times, which is an approximation +## Syntax -The space_expand_rate parameter is optional and is used to set the number of counters used in the Space-Saving algorithm +```sql +TOPN(, [, ]) ``` -counter numbers = top_num * space_expand_rate -``` -The higher value of space_expand_rate, the more accurate result will be. The default value is 50 -### example -``` -MySQL [test]> select topn(keyword,10) from keyword_table where date>= '2020-06-01' and date <= '2020-06-19' ; -+------------------------------------------------------------------------------------------------------------+ -| topn(`keyword`, 10) | -+------------------------------------------------------------------------------------------------------------+ -| a:157, b:138, c:133, d:133, e:131, f:127, g:124, h:122, i:117, k:117 | -+------------------------------------------------------------------------------------------------------------+ - -MySQL [test]> select date,topn(keyword,10,100) from keyword_table where date>= '2020-06-17' and date <= '2020-06-19' group by date; -+------------+-----------------------------------------------------------------------------------------------+ -| date | topn(`keyword`, 10, 100) | -+------------+-----------------------------------------------------------------------------------------------+ -| 2020-06-19 | a:11, b:8, c:8, d:7, e:7, f:7, g:7, h:7, i:7, j:7 | -| 2020-06-18 | a:10, b:8, c:7, f:7, g:7, i:7, k:7, l:7, m:6, d:6 | -| 2020-06-17 | a:9, b:8, c:8, j:8, d:7, e:7, f:7, h:7, i:7, k:7 | -+------------+-----------------------------------------------------------------------------------------------+ +## Parameters +| Parameter | Description | +| -- | -- | +| `` | The column or expression to be counted. | +| `` | The number of the most frequent values to return. It must be a positive integer. | +| `` | Optional parameter, which is used to set the number of counters used in the Space-Saving algorithm. `counter_numbers = top_num * space_expand_rate` , the larger the value of space_expand_rate, the more accurate the result, and the default value is 50. | + +## Return Value + +Returns a JSON string containing values and their corresponding occurrence counts. + +## Examples +```sql +-- Create sample table +CREATE TABLE page_visits ( + page_id INT, + user_id INT, + visit_date DATE +) DISTRIBUTED BY HASH(page_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO page_visits VALUES +(1, 101, '2024-01-01'), +(2, 102, '2024-01-01'), +(1, 103, '2024-01-01'), +(3, 101, '2024-01-01'), +(1, 104, '2024-01-01'), +(2, 105, '2024-01-01'), +(1, 106, '2024-01-01'), +(4, 107, '2024-01-01'); + +-- Find top 3 most visited pages +SELECT TOPN(page_id, 3) as top_pages +FROM page_visits; ``` -### keywords -TOPN \ No newline at end of file + +```text ++---------------------+ +| top_pages | ++---------------------+ +| {"1":4,"2":2,"4":1} | ++---------------------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/var-samp.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/var-samp.md index 8fe7ad5a39f7e..40b7abfae8dd0 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/var-samp.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/var-samp.md @@ -1,6 +1,6 @@ --- { - "title": "VARIANCE_SAMP,VARIANCE_SAMP", + "title": "VAR_SAMP,VARIANCE_SAMP", "language": "en" } --- @@ -24,23 +24,62 @@ specific language governing permissions and limitations under the License. --> -## VARIANCE_SAMP,VARIANCE_SAMP -### Description -#### Syntax +## Description -`VAR SAMP (expr)` +The VAR_SAMP function calculates the sample variance of a specified expression. Unlike VARIANCE (population variance), VAR_SAMP uses n-1 as the divisor, which is considered an unbiased estimate of the population variance in statistics. +## Alias -Returns the sample variance of the expr expression +- VARIANCE_SAMP -### example +## Syntax + +```sql +VAR_SAMP() ``` -MySQL > select var_samp(scan_rows) from log_statis group by datetime; -+-----------------------+ -| var_samp(`scan_rows`) | -+-----------------------+ -| 5.6227132145741789 | -+-----------------------+ + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The column or expression to calculate sample variance for. Must be numeric type | + +## Return Value +Returns a DOUBLE value representing the calculated sample variance. + +## Examples +```sql +-- Create sample table +CREATE TABLE student_scores ( + student_id INT, + score DECIMAL(4,1) +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO student_scores VALUES +(1, 85.5), +(2, 92.0), +(3, 78.5), +(4, 88.0), +(5, 95.5), +(6, 82.0), +(7, 90.0), +(8, 87.5); + +-- Calculate sample variance of student scores +SELECT + VAR_SAMP(score) as sample_variance, + VARIANCE(score) as population_variance +FROM student_scores; +``` + +```text ++------------------+---------------------+ +| sample_variance | population_variance | ++------------------+---------------------+ +| 29.4107142857143 | 25.73437500000001 | ++------------------+---------------------+ ``` -### keywords -VAR SAMP, VARIANCE SAMP,VAR,SAMP,VARIANCE diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/variance.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/variance.md index f58da61bf708f..5e43d59eddfd8 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/variance.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/variance.md @@ -24,30 +24,59 @@ specific language governing permissions and limitations under the License. --> -## VARIANCE,VAR_POP,VARIANCE_POP -### Description -#### Syntax +## Description -`VARIANCE(expr)` +The VARIANCE function calculates the statistical variance of the specified expression. It measures how far a set of numbers are spread out from their arithmetic mean. +## Alias -Returns the variance of the expr expression +- VAR_POP +- VARIANCE_POP -### example +## Syntax + +```sql +VARIANCE() ``` -MySQL > select variance(scan_rows) from log_statis group by datetime; -+-----------------------+ -| variance(`scan_rows`) | -+-----------------------+ -| 5.6183332881176211 | -+-----------------------+ - -MySQL > select var_pop(scan_rows) from log_statis group by datetime; -+----------------------+ -| var_pop(`scan_rows`) | -+----------------------+ -| 5.6230744719006163 | -+----------------------+ + +## Parameters +| Parameter | Description | +| -- | -- | +| `` | The column or expression to calculate variance for. Must be numeric type | + +## Return Value +Returns a DOUBLE value representing the calculated variance. + +## Examples +```sql +-- Create sample table +CREATE TABLE student_scores ( + student_id INT, + score DECIMAL(4,1) +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO student_scores VALUES +(1, 85.5), +(2, 92.0), +(3, 78.5), +(4, 88.0), +(5, 95.5), +(6, 82.0), +(7, 90.0), +(8, 87.5); +-- Calculate variance of student scores +SELECT VARIANCE(score) as score_variance +FROM student_scores; +``` + +```text ++-------------------+ +| score_variance | ++-------------------+ +| 25.73437499999998 | ++-------------------+ ``` -### keywords -VARIANCE,VAR_POP,VARIANCE_POP,VAR,POP diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/window-funnel.md b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/window-funnel.md index 47d440b958049..4e4e361e72f37 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/window-funnel.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/aggregate-functions/window-funnel.md @@ -11,19 +11,9 @@ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> -## WINDOW FUNCTION WINDOW_FUNNEL -### description +## Description -Searches for event chains in a sliding time window and calculates the maximum number of events that occurred from the chain. - -- window is the length of time window in seconds. -- mode can be one of the followings: - - "default": Defualt mode. - - "deduplication": If the same event holds for the sequence of events, then such repeating event interrupts further processing. E.g. the array parameter is [event1='A', event2='B', event3='C', event4='D'], and the original event chain is "A-B-C-B-D". Since event B repeats, the filtered event chain can only be "A-B-C" and the max event level is 3. - - "fixed": Don't allow interventions of other events. E.g. the array parameter is [event1='A', event2='B', event3='C', event4='D'], and the original event chain is A->B->D->C, it stops finding A->B->C at the D and the max event level is 2. - - "increase": Apply conditions only to events with strictly increasing timestamps. -- timestamp_column specifies column of DATETIME type, sliding time window works on it. -- evnetN is boolean expression like eventID = 1004. +The WINDOW_FUNNEL function analyzes user behavior sequences by searching for event chains within a specified time window and calculating the maximum number of completed steps in the event chain. This function is particularly useful for conversion funnel analysis, such as analyzing user conversion from website visits to final purchases. The function works according to the algorithm: @@ -31,15 +21,35 @@ The function works according to the algorithm: - If events from the chain occur sequentially within the window, the counter is incremented. If the sequence of events is disrupted, the counter is not incremented. - If the data has multiple event chains at varying points of completion, the function will only output the size of the longest chain. +## Syntax + ```sql -window_funnel(window, mode, timestamp_column, event1, event2, ... , eventN) +WINDOW_FUNNEL(, , , [, event_2, ... , event_n]) ``` -### example +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | window is the length of time window in seconds | +| `` | There are four modes in total, `default`, `deduplication`, `fixed`, and `increase`. For details, please refer to the **Mode** below. | +| `` | timestamp specifies column of DATETIME type, sliding time window works on it | +| `` | evnet_n is boolean expression like eventID = 1004 | + +**Mode** + - `default`: Defualt mode. + - `deduplication`: If the same event holds for the sequence of events, then such repeating event interrupts further processing. E.g. the array parameter is [event1='A', event2='B', event3='C', event4='D'], and the original event chain is "A-B-C-B-D". Since event B repeats, the filtered event chain can only be "A-B-C" and the max event level is 3. + - `fixed`: Don't allow interventions of other events. E.g. the array parameter is [event1='A', event2='B', event3='C', event4='D'], and the original event chain is A->B->D->C, it stops finding A->B->C at the D and the max event level is 2. + - `increase`: Apply conditions only to events with strictly increasing timestamps. -#### example1: default mode +## Return Value +Returns an integer representing the maximum number of consecutive steps completed within the specified time window. -Using the ```default``` mode, find out the maximum number of consecutive events corresponding to different ```user_id```, with a time window of ```5``` minutes: +## Examples + +### example1: default mode + +Using the `default` mode, find out the maximum number of consecutive events corresponding to different `user_id`, with a time window of `5` minutes: ```sql CREATE TABLE events( @@ -82,7 +92,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -93,11 +105,11 @@ order BY +---------+-------+ ``` -For ```uesr_id=100123```, because the time when the ```payment``` event occurred exceeds the time window, the matched event chain is ```login-visit-order```. +For `uesr_id=100123`, because the time when the `payment` event occurred exceeds the time window, the matched event chain is `login-visit-order`. -#### example2: deduplication mode +### example2: deduplication mode -Use the ```deduplication``` mode to find out the maximum number of consecutive events corresponding to different user_ids, with a time window of 1 hour: +Use the `deduplication` mode to find out the maximum number of consecutive events corresponding to different user_ids, with a time window of 1 hour: ```sql CREATE TABLE events( @@ -141,7 +153,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -151,11 +165,11 @@ order BY | 100127 | 2 | +---------+-------+ ``` -For ```uesr_id=100123```, after matching the ```visit``` event, the ```login``` event appears repeatedly, so the matched event chain is ```login-visit```. +For `uesr_id=100123`, after matching the `visit` event, the `login` event appears repeatedly, so the matched event chain is `login-visit`. -#### example3: fixed mode +### example3: fixed mode -Use the ```fixed``` mode to find out the maximum number of consecutive events corresponding to different ```user_id```, with a time window of ```1``` hour: +Use the `fixed` mode to find out the maximum number of consecutive events corresponding to different `user_id`, with a time window of `1` hour: ```sql CREATE TABLE events( @@ -199,7 +213,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -209,11 +225,11 @@ order BY | 100127 | 2 | +---------+-------+ ``` -For ```uesr_id=100123```, after matching the ```order``` event, the event chain is interrupted by the ```login2``` event, so the matched event chain is ```login-visit-order```. +For `uesr_id=100123`, after matching the `order` event, the event chain is interrupted by the `login2` event, so the matched event chain is `login-visit-order`. -#### example4: increase mode +### example4: increase mode -Use the ```increase``` mode to find out the maximum number of consecutive events corresponding to different ```user_id```, with a time window of ```1``` hour: +Use the `increase` mode to find out the maximum number of consecutive events corresponding to different `user_id`, with a time window of `1` hour: ```sql CREATE TABLE events( @@ -256,7 +272,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -266,9 +284,4 @@ order BY | 100127 | 2 | +---------+-------+ ``` -For ```uesr_id=100123```, the timestamp of the ```payment``` event and the timestamp of the ```order``` event occur in the same second and are not incremented, so the matched event chain is ```login-visit-order```. - - -### keywords - - WINDOW,FUNCTION,WINDOW_FUNNEL +For `uesr_id=100123`, the timestamp of the `payment` event and the timestamp of the `order` event occur in the same second and are not incremented, so the matched event chain is `login-visit-order`. diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md index ddd3ee704c4b1..9863806bac137 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md @@ -24,27 +24,37 @@ specific language governing permissions and limitations under the License. --> -## hours_add -### description -#### Syntax +## Description -`DATETIME HOURS_ADD(DATETIME date, INT hours)` +Returns a new datetime value that is the result of adding a specified number of hours to the input datetime. -Add specified hours from date time or date +## Syntax -The parameter date can be DATETIME or DATE, and the return type is DATETIME. +```sql +HOURS_ADD(, ) +``` -### example +## Parameters -``` -mysql> select hours_add("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| hours_add('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-02-02 03:02:02 | -+-------------------------------------+ -``` +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATETIME or DATE | +| `` | The number of hours to add, of type INT | + +## Return Value -### keywords +Returns a value of type DATETIME, representing the time value after adding the specified number of hours to the input datetime. - HOURS_ADD +## Example + +```sql +SELECT HOURS_ADD('2020-02-02 02:02:02', 1); +``` + +```text ++------------------------------------------------------------+ +| hours_add(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), 1) | ++------------------------------------------------------------+ +| 2020-02-02 03:02:02 | ++------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md index f299f8d15c6d8..78e690f7bf8ea 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md @@ -24,25 +24,37 @@ specific language governing permissions and limitations under the License. --> -## hours_diff -### description -#### Syntax +## Description -`INT hours_diff(DATETIME enddate, DATETIME startdate)` +Calculates the difference in hours between the start time and the end time. -The difference between the start time and the end time is a few hours +## Syntax -### example - -``` -mysql> select hours_diff('2020-12-25 22:00:00','2020-12-25 21:00:00'); -+----------------------------------------------------------+ -| hours_diff('2020-12-25 22:00:00', '2020-12-25 21:00:00') | -+----------------------------------------------------------+ -| 1 | -+----------------------------------------------------------+ +```sql +HOURS_DIFF(, ) ``` -### keywords +## Parameters + +| Parameter | Description | +|------------|-------------------------------------------------| +| `` | The end time, which can be of type DATETIME or DATE | +| `` | The start time, which can be of type DATETIME or DATE | + +## Return Value + +Returns an INT type representing the number of hours between the start time and the end time. + +## Example + +```sql +SELECT HOURS_DIFF('2020-12-25 22:00:00', '2020-12-25 21:00:00'); +``` - hours_diff +```text ++--------------------------------------------------------------------------------------------------------+ +| hours_diff(cast('2020-12-25 22:00:00' as DATETIMEV2(0)), cast('2020-12-25 21:00:00' as DATETIMEV2(0))) | ++--------------------------------------------------------------------------------------------------------+ +| 1 | ++--------------------------------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md index 7bb2ba1f75d0b..234d0c5ef41cd 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md @@ -24,27 +24,37 @@ specific language governing permissions and limitations under the License. --> -## hours_sub -### description -#### Syntax +## Description -`DATETIME HOURS_SUB(DATETIME date, INT hours)` +Returns a new datetime value that is the result of subtracting a specified number of hours from the input datetime. -Subtracts a specified number of hours from a datetime or date +## Syntax -The parameter date can be DATETIME or DATE, and the return type is DATETIME. +```sql +HOURS_SUB(, ) +``` -### example +## Parameters -``` -mysql> select hours_sub("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| hours_sub('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-02-02 01:02:02 | -+-------------------------------------+ -``` +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATETIME or DATE | +| `` | The number of hours to subtract, of type INT | + +## Return Value -### keywords +Returns a value of type DATETIME, representing the time value after subtracting the specified number of hours from the input datetime. - HOURS_SUB +## Example + +```sql +SELECT HOURS_SUB('2020-02-02 02:02:02', 1); +``` + +```text ++------------------------------------------------------------+ +| hours_sub(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), 1) | ++------------------------------------------------------------+ +| 2020-02-02 01:02:02 | ++------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md index 0eb3956f4bb84..6e2dc10cf0e09 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md @@ -22,28 +22,40 @@ specific language governing permissions and limitations under the License. --> -## last_day -### Description -#### Syntax +## Description -`DATE last_day(DATETIME date)` +Returns the date of the last day of the month for the given input date. The returned day varies depending on the month: +- 28th - For February in non-leap years +- 29th - For February in leap years +- 30th - For April, June, September, and November +- 31st - For January, March, May, July, August, October, and December -Return the last day of the month, the return day may be : -'28'(February and not a leap year), -'29'(February and a leap year), -'30'(April, June, September, November), -'31'(January, March, May, July, August, October, December) - -### example +## Syntax +```sql +LAST_DAY() ``` -mysql > select last_day('2000-02-03'); -+-------------------+ -| last_day('2000-02-03 00:00:00') | -+-------------------+ -| 2000-02-29 | -+-------------------+ + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | Input datetime value, type can be DATETIME or DATE | + +## Return Value + +Returns a value of type DATE representing the last day of the month for the given input date. + +## Example + +```sql +SELECT LAST_DAY('2000-02-03'); ``` -### keywords - LAST_DAY,DAYS +```text ++-----------------------------------------------+ +| last_day(cast('2000-02-03' as DATETIMEV2(0))) | ++-----------------------------------------------+ +| 2000-02-29 | ++-----------------------------------------------+ +``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md index 83b091409d934..19461f14de550 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md @@ -24,22 +24,42 @@ specific language governing permissions and limitations under the License. --> -## makedate -### Description -#### Syntax -`DATE MAKEDATE(INT year, INT dayofyear)` +## Description -Returns a date, given year and day-of-year values. dayofyear must be greater than 0 or the result is NULL. +Returns a date based on the specified year and the day of the year (dayofyear). -### example +Special cases: +- Returns NULL when `dayofyear` is less than or equal to 0. +- Automatically rolls over to the next year if `dayofyear` exceeds the number of days in the year. + +## Syntax + +```sql +MAKEDATE(, ) +``` + +## Parameters + +| Parameter | Description | +|-------------|-------------------------------------------| +| `` | The specified year, of type INT | +| `` | The day of the year (1-366), of type INT | + +## Return Value + +Returns a value of type DATE, constructed from the specified year and the given day of the year. + +## Example + +```sql +SELECT MAKEDATE(2021, 1), MAKEDATE(2021, 100), MAKEDATE(2021, 400); ``` -mysql> select makedate(2021,1), makedate(2021,100), makedate(2021,400); + +```text +-------------------+---------------------+---------------------+ | makedate(2021, 1) | makedate(2021, 100) | makedate(2021, 400) | +-------------------+---------------------+---------------------+ | 2021-01-01 | 2021-04-10 | 2022-02-04 | +-------------------+---------------------+---------------------+ ``` -### keywords - MAKEDATE diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md index a99ad0b4c8e33..2a5191e01cb5e 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md @@ -24,25 +24,37 @@ specific language governing permissions and limitations under the License. --> -## microsecond -### description -#### Syntax -`INT MICROSECOND(DATETIMEV2 date)` +## Description -Returns microsecond information in the time type. +Extracts the microsecond part from a datetime value. The returned range is from 0 to 999999. -The parameter is Datetime type +## Syntax -### example +```sql +MICROSECOND() +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, of type DATETIMEV2, with a precision greater than 0 | + +## Return Value +Returns an INT type representing the microsecond part of the datetime value. The range is from 0 to 999999. For inputs with a precision less than 6, the missing digits are padded with zeros. + +## Example + +```sql +SELECT MICROSECOND(CAST('1999-01-02 10:11:12.000123' AS DATETIMEV2(6))) AS microsecond; ``` -mysql> select microsecond(cast('1999-01-02 10:11:12.000123' as datetimev2(6))) as microsecond; + +```text +-------------+ | microsecond | +-------------+ | 123 | +-------------+ ``` -### keywords - MICROSECOND diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md index 106e015dfa70d..f0fef6608c18e 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md @@ -24,27 +24,42 @@ specific language governing permissions and limitations under the License. --> -## microseconds_add -### description -#### Syntax -`DATETIMEV2 microseconds_add(DATETIMEV2 basetime, INT delta)` -- basetime: Base time whose type is DATETIMEV2 -- delta: Microseconds to add to basetime -- Return type of this function is DATETIMEV2 +## Description -### example +Adds a specified number of microseconds to a datetime value and returns a new datetime value. + +## Syntax + +```sql +MICROSECONDS_ADD(, ) ``` -mysql> select now(3), microseconds_add(now(3), 100000); -+-------------------------+----------------------------------+ -| now(3) | microseconds_add(now(3), 100000) | -+-------------------------+----------------------------------+ -| 2023-02-21 11:35:56.556 | 2023-02-21 11:35:56.656 | -+-------------------------+----------------------------------+ + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, of type DATETIMEV2 | +| `` | The number of microseconds to add, of type INT; 1 second = 1,000,000 microseconds | + +## Return Value + +Returns a value of type DATETIMEV2, representing the time value after adding the specified number of microseconds to the input datetime. The precision of the return value is the same as that of the input parameter basetime. + +## Example + +```sql +SELECT NOW(3) AS current_time, MICROSECONDS_ADD(NOW(3), 100000) AS after_add; ``` -`now(3)` returns current time as type DATETIMEV2 with precision 3d,`microseconds_add(now(3), 100000)` means 100000 microseconds after current time -### keywords - microseconds_add +```text ++-------------------------+----------------------------+ +| current_time | after_add | ++-------------------------+----------------------------+ +| 2025-01-16 11:48:10.505 | 2025-01-16 11:48:10.605000 | ++-------------------------+----------------------------+ +``` - \ No newline at end of file +**Note:** +- `NOW(3)` returns the current time with a precision of 3 decimal places. +- After adding 100000 microseconds (0.1 seconds), the time increases by 0.1 seconds. diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md index 7a48fc117b59c..04254f2cd54d0 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md @@ -24,26 +24,41 @@ specific language governing permissions and limitations under the License. --> -## microseconds_diff -### description -#### Syntax -`INT microseconds_diff(DATETIME enddate, DATETIME startdate)` +## Description -How many microseconds is the difference between the start time and the end time. +Calculates the microsecond difference between two datetime values. The result is the number of microseconds from `` subtracted from ``. -### example +## Syntax +```sql +MICROSECONDS_DIFF(, ) ``` -mysql> select microseconds_diff('2020-12-25 21:00:00.623000','2020-12-25 21:00:00.123000'); + +## Parameters + +| Parameter | Description | +|------------|-------------------------------------------------| +| `` | The end time, of type DATETIMEV2 | +| `` | The start time, of type DATETIMEV2 | + +## Return Value + +Returns an INT type representing the microsecond difference between the two times. +- Returns a positive number if `` is greater than ``. +- Returns a negative number if `` is less than ``. +- 1 second = 1,000,000 microseconds. + +## Example + +```sql +SELECT MICROSECONDS_DIFF('2020-12-25 21:00:00.623000', '2020-12-25 21:00:00.123000'); +``` + +```text +-----------------------------------------------------------------------------------------------------------------------------+ -| microseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(6)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(6))) | +| microseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(3)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(3))) | +-----------------------------------------------------------------------------------------------------------------------------+ | 500000 | +-----------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.12 sec) ``` - -### keywords - - microseconds_diff diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md index 439bc2a37429b..c7a61d509bce4 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md @@ -24,25 +24,43 @@ specific language governing permissions and limitations under the License. --> -## microseconds_sub -### description -#### Syntax -`DATETIMEV2 microseconds_sub(DATETIMEV2 basetime, INT delta)` -- basetime: Base time whose type is DATETIMEV2 -- delta: Microseconds to subtract from basetime -- Return type of this function is DATETIMEV2 +## Description -### example +Subtracts a specified number of microseconds from a datetime value and returns a new datetime value. + +## Syntax + +```sql +MICROSECONDS_SUB(, ) +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, of type DATETIMEV2 | +| `` | The number of microseconds to subtract, of type INT; 1 second = 1,000,000 microseconds | + +## Return Value + +Returns a value of type DATETIMEV2, representing the time value after subtracting the specified number of microseconds from the input datetime. The precision of the return value is the same as that of the input parameter basetime. + +## Example + +```sql +SELECT NOW(3) AS current_time, MICROSECONDS_SUB(NOW(3), 100000) AS after_sub; ``` -mysql> select now(3), microseconds_sub(now(3), 100000); -+-------------------------+----------------------------------+ -| now(3) | microseconds_sub(now(3), 100000) | -+-------------------------+----------------------------------+ -| 2023-02-25 02:03:05.174 | 2023-02-25 02:03:05.074 | -+-------------------------+----------------------------------+ + +```text ++-------------------------+----------------------------+ +| current_time | after_sub | ++-------------------------+----------------------------+ +| 2025-01-16 11:52:22.296 | 2025-01-16 11:52:22.196000 | ++-------------------------+----------------------------+ ``` -`now(3)` returns current time as type DATETIMEV2 with precision `3`,`microseconds_sub(now(3), 100000)` means 100000 microseconds before current time -### keywords - microseconds_sub +**Note:** +- `NOW(3)` returns the current time with a precision of 3 decimal places. +- After subtracting 100000 microseconds (0.1 seconds), the time decreases by 0.1 seconds. +- The function's result is dependent on the precision of the input time. diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md index 4d2c2f27d2221..bdd66319310ce 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md @@ -24,28 +24,43 @@ specific language governing permissions and limitations under the License. --> -## milliseconds_add -### description -#### Syntax -`DATETIMEV2 milliseconds_add(DATETIMEV2 basetime, INT delta)` -- basetime: Base time whose type is DATETIMEV2 -- delta:Milliseconds to add to basetime -- Return type of this function is DATETIMEV2 +## Description -### example +Adds a specified number of milliseconds to a datetime value and returns a new datetime value. + +## Syntax + +```sql +MILLISECONDS_ADD(, ) +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, of type DATETIMEV2 | +| `` | The number of milliseconds to add, of type INT; 1 second = 1,000 milliseconds = 1,000,000 microseconds | + +## Return Value + +Returns a value of type DATETIMEV2, representing the time value after adding the specified number of milliseconds to the input datetime. The precision of the return value is the same as that of the input parameter basetime. + +## Example + +```sql +SELECT MILLISECONDS_ADD('2023-09-08 16:02:08.435123', 1); ``` -mysql> select milliseconds_add('2023-09-08 16:02:08.435123', 1); + +```text +--------------------------------------------------------------------------+ | milliseconds_add(cast('2023-09-08 16:02:08.435123' as DATETIMEV2(6)), 1) | +--------------------------------------------------------------------------+ | 2023-09-08 16:02:08.436123 | +--------------------------------------------------------------------------+ -1 row in set (0.04 sec) ``` - -### keywords - milliseconds_add - - \ No newline at end of file +**Note:** +- In the example, after adding 1 millisecond, the time increases from .435123 to .436123. +- 1 millisecond equals 1000 microseconds. +- The function's result is dependent on the precision of the input time; the example uses a precision of 6 decimal places. diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md index 94f4b678e3a47..071bf8fac6e77 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md @@ -24,26 +24,47 @@ specific language governing permissions and limitations under the License. --> -## milliseconds_diff -### description -#### Syntax -`INT milliseconds_diff(DATETIME enddate, DATETIME startdate)` +## Description -How many milliseconds is the difference between the start time and the end time? +Calculates the millisecond difference between two datetime values. The result is the number of milliseconds from `` subtracted from ``. -### example +## Syntax +```sql +MILLISECONDS_DIFF(, ) ``` -mysql> select milliseconds_diff('2020-12-25 21:00:00.623000','2020-12-25 21:00:00.123000'); + +## Parameters + +| Parameter | Description | +|------------|-------------------------------------------------| +| `` | The end time, of type DATETIMEV2 | +| `` | The start time, of type DATETIMEV2 | + +## Return Value + +Returns an INT type representing the millisecond difference between the two times. +- Returns a positive number if `` is greater than ``. +- Returns a negative number if `` is less than ``. +- 1 second = 1,000 milliseconds. +- 1 millisecond = 1,000 microseconds. + +## Example + +```sql +SELECT MILLISECONDS_DIFF('2020-12-25 21:00:00.623000', '2020-12-25 21:00:00.123000'); +``` + +```text +-----------------------------------------------------------------------------------------------------------------------------+ -| milliseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(6)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(6))) | +| milliseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(3)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(3))) | +-----------------------------------------------------------------------------------------------------------------------------+ | 500 | +-----------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) ``` -### keywords - - milliseconds_diff +**Note:** +- The time difference in the example is 0.5 seconds, which equals 500 milliseconds. +- The function's result is dependent on the precision of the input time; the example uses a precision of 3 decimal places. +- The result only returns the millisecond difference and does not include the microsecond part. diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md index 500579d5a07cb..806b96d80ad5c 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md @@ -24,18 +24,35 @@ specific language governing permissions and limitations under the License. --> -## milliseconds_sub -### description -#### Syntax -`DATETIMEV2 milliseconds_sub(DATETIMEV2 basetime, INT delta)` -- basetime: Base time whose type is DATETIMEV2 -- delta: Milliseconds to subtract from basetime -- Return type of this function is DATETIMEV2 +## Description -### example +Subtracts a specified number of milliseconds from a datetime value and returns a new datetime value. + +## Syntax + +```sql +MILLISECONDS_SUB(, ) +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, of type DATETIMEV2 | +| `` | The number of milliseconds to subtract, of type INT; 1 second = 1,000 milliseconds = 1,000,000 microseconds | + +## Return Value + +Returns a value of type DATETIMEV2, representing the time value after subtracting the specified number of milliseconds from the input datetime. The precision of the return value is the same as that of the input parameter basetime. + +## Example + +```sql +SELECT MILLISECONDS_SUB('2023-09-08 16:02:08.435123', 1); ``` -mysql> select milliseconds_sub('2023-09-08 16:02:08.435123', 1); + +```text +--------------------------------------------------------------------------+ | milliseconds_sub(cast('2023-09-08 16:02:08.435123' as DATETIMEV2(6)), 1) | +--------------------------------------------------------------------------+ @@ -44,8 +61,8 @@ mysql> select milliseconds_sub('2023-09-08 16:02:08.435123', 1); 1 row in set (0.11 sec) ``` - -### keywords - milliseconds_sub - - \ No newline at end of file +**Note:** +- In the example, after subtracting 1 millisecond, the time decreases from .435123 to .434123. +- 1 millisecond equals 1000 microseconds. +- The function's result is dependent on the precision of the input time; the example uses a precision of 6 decimal places. +- The result retains microsecond-level precision. diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-ceil.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-ceil.md index 36e8b809e1ca6..e2eb8911a3ed5 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-ceil.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-ceil.md @@ -1,6 +1,6 @@ --- { - "title": "minute_ceil", + "title": "MINUTE_CEIL", "language": "en" } --- @@ -24,39 +24,51 @@ specific language governing permissions and limitations under the License. --> -## minute_ceil -### description -#### Syntax + +## Description + +Rounds up a datetime value to the nearest specified minute interval. If a starting time (origin) is provided, it uses that time as the reference for calculating the interval. + +## Syntax ```sql -DATETIME MINUTE_CEIL(DATETIME datetime) -DATETIME MINUTE_CEIL(DATETIME datetime, DATETIME origin) -DATETIME MINUTE_CEIL(DATETIME datetime, INT period) -DATETIME MINUTE_CEIL(DATETIME datetime, INT period, DATETIME origin) +MINUTE_CEIL() +MINUTE_CEIL(, ) +MINUTE_CEIL(, ) +MINUTE_CEIL(, , ) ``` -Convert the date to the nearest rounding up time of the specified time interval period. +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The datetime value to round up, of type DATETIME or DATETIMEV2 | +| `` | The minute interval value, of type INT, representing the number of minutes in each interval | +| `` | The starting point for the interval, of type DATETIME or DATETIMEV2; defaults to 0001-01-01 00:00:00 | -- datetime: a valid date expression. -- period: specifies how many minutes each cycle consists of. -- origin: starting from 0001-01-01T00:00:00. +## Return Value -### example +Returns a value of type DATETIMEV2, representing the rounded-up datetime value based on the specified minute interval. The precision of the return value is the same as that of the input parameter datetime. +## Example + +```sql +SELECT MINUTE_CEIL("2023-07-13 22:28:18", 5); ``` -mysql> select minute_ceil("2023-07-13 22:28:18", 5); + +```text +--------------------------------------------------------------+ | minute_ceil(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +--------------------------------------------------------------+ | 2023-07-13 22:30:00 | +--------------------------------------------------------------+ -1 row in set (0.21 sec) ``` -### keywords - - MINUTE_CEIL, MINUTE, CEIL +**Note:** +- If no period is specified, it defaults to a 1-minute interval. +- The period must be a positive integer. +- The result is always rounded up to a future time. -### Best Practice +## Best Practices See also [date_ceil](./date_ceil) diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md index afe9f8ac3e89c..bf644db01d0f3 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md @@ -1,6 +1,6 @@ --- { - "title": "minute_floor", + "title": "MINUTE_FLOOR", "language": "en" } --- @@ -24,39 +24,52 @@ specific language governing permissions and limitations under the License. --> -## minute_floor -### description -#### Syntax + +## Description + +Rounds down a datetime value to the nearest specified minute interval. If a starting time (origin) is provided, it uses that time as the reference for calculating the interval. + +## Syntax ```sql -DATETIME MINUTE_FLOOR(DATETIME datetime) -DATETIME MINUTE_FLOOR(DATETIME datetime, DATETIME origin) -DATETIME MINUTE_FLOOR(DATETIME datetime, INT period) -DATETIME MINUTE_FLOOR(DATETIME datetime, INT period, DATETIME origin) +MINUTE_FLOOR() +MINUTE_FLOOR(, ) +MINUTE_FLOOR(, ) +MINUTE_FLOOR(, , ) ``` -Convert the date to the nearest rounding down time of the specified time interval period. +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The datetime value to round down, of type DATETIME or DATETIMEV2 | +| `` | The minute interval value, of type INT, representing the number of minutes in each interval | +| `` | The starting point for the interval, of type DATETIME or DATETIMEV2; defaults to 0001-01-01 00:00:00 | -- datetime: a valid date expression. -- period: specifies how many minutes each cycle consists of. -- origin: starting from 0001-01-01T00:00:00. +## Return Value -### example +Returns a value of type DATETIMEV2, representing the rounded-down datetime value. +## Example + +```sql +SELECT MINUTE_FLOOR("2023-07-13 22:28:18", 5); ``` -mysql> select minute_floor("2023-07-13 22:28:18", 5); + +```text +---------------------------------------------------------------+ | minute_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +---------------------------------------------------------------+ | 2023-07-13 22:25:00 | +---------------------------------------------------------------+ -1 row in set (0.06 sec) ``` -### keywords - - MINUTE_FLOOR, MINUTE, FLOOR +**Note:** +- If no period is specified, it defaults to a 1-minute interval. +- The period must be a positive integer. +- The result is always rounded down to a past time. +- Unlike MINUTE_CEIL, MINUTE_FLOOR always discards the portion that exceeds the interval. -### Best Practice +## Best Practices See also [date_floor](./date_floor) diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md index cfa348e739933..09a224da048d2 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md @@ -27,21 +27,39 @@ under the License. ## Description -Returns minute information in the time type, ranging from 0,59 +Extracts the minute part from a datetime value. The returned value ranges from 0 to 59. -The parameter is Date or Datetime or Time type ## Syntax -`INT MINUTE(DATETIME date)` + +```sql +MINUTE() +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATE, DATETIME, DATETIMEV2, or TIME | + +## Return Value + +Returns an INT type representing the minute value, with a range of 0-59. ## Example ```sql -mysql> select minute('2018-12-31 23:59:59'); -+-----------------------------+ -| minute('2018-12-31 23:59:59') | -+-----------------------------+ -| 59 | -+-----------------------------+ +SELECT MINUTE('2018-12-31 23:59:59'); ``` -## Keywords - MINUTE + +```text ++------------------------------------------------------+ +| minute(cast('2018-12-31 23:59:59' as DATETIMEV2(0))) | ++------------------------------------------------------+ +| 59 | ++------------------------------------------------------+ +``` + +**Note:** +- The input parameter can be of various time-related types. +- The returned value is always an integer between 0 and 59. +- If the input parameter is NULL, the function returns NULL. diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md index 7c4636db8c855..04479f476828a 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md @@ -24,27 +24,43 @@ specific language governing permissions and limitations under the License. --> -## minutes_add -### description -#### Syntax -`DATETIME MINUTES_ADD(DATETIME date, INT minutes)` +## Description -Add specified minutes from date time or date +Adds a specified number of minutes to a datetime value and returns a new datetime value. -The parameter date can be DATETIME or DATE, and the return type is DATETIME. - -### example +## Syntax +```sql +MINUTES_ADD(, ) ``` -mysql> select minutes_add("2020-02-02", 1); -+---------------------------------------+ -| minutes_add('2020-02-02 00:00:00', 1) | -+---------------------------------------+ -| 2020-02-02 00:01:00 | -+---------------------------------------+ + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATE, DATETIME, or DATETIMEV2 | +| `` | The number of minutes to add, of type INT; can be positive or negative | + +## Return Value + +Returns a value of type DATETIME, representing the datetime value after adding the specified number of minutes. + +## Example + +```sql +SELECT MINUTES_ADD("2020-02-02", 1); ``` -### keywords +```text ++-----------------------------------------------------+ +| minutes_add(cast('2020-02-02' as DATETIMEV2(0)), 1) | ++-----------------------------------------------------+ +| 2020-02-02 00:01:00 | ++-----------------------------------------------------+ +``` - MINUTES_ADD +**Note:** +- When the number of minutes added is negative, it effectively subtracts the corresponding number of minutes. +- The function automatically handles cases that cross hours and days. +- If the input parameter is NULL, the function returns NULL. diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md index b8c7fd1c1b880..ff3ccd818844f 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md @@ -24,25 +24,45 @@ specific language governing permissions and limitations under the License. --> -## minutes_diff -### description -#### Syntax -`INT minutes_diff(DATETIME enddate, DATETIME startdate)` +## Description -The difference between the start time and the end time is a few minutes +Calculates the minute difference between two datetime values. The result is the number of minutes from `` subtracted from ``. -### example +## Syntax +```sql +MINUTES_DIFF(, ) ``` -mysql> select minutes_diff('2020-12-25 22:00:00','2020-12-25 21:00:00'); -+------------------------------------------------------------+ -| minutes_diff('2020-12-25 22:00:00', '2020-12-25 21:00:00') | -+------------------------------------------------------------+ -| 60 | -+------------------------------------------------------------+ + +## Parameters + +| Parameter | Description | +|------------|-------------------------------------------------| +| `` | The end time, which can be of type DATE, DATETIME, or DATETIMEV2 | +| `` | The start time, which can be of type DATE, DATETIME, or DATETIMEV2 | + +## Return Value + +Returns an INT type representing the minute difference between the two times. +- Returns a positive number if `` is greater than ``. +- Returns a negative number if `` is less than ``. + +## Example + +```sql +SELECT MINUTES_DIFF('2020-12-25 22:00:00', '2020-12-25 21:00:00'); ``` -### keywords +```text ++----------------------------------------------------------------------------------------------------------+ +| minutes_diff(cast('2020-12-25 22:00:00' as DATETIMEV2(0)), cast('2020-12-25 21:00:00' as DATETIMEV2(0))) | ++----------------------------------------------------------------------------------------------------------+ +| 60 | ++----------------------------------------------------------------------------------------------------------+ +``` - minutes_diff +**Note:** +- The calculation only considers complete minutes; seconds and milliseconds are ignored. +- If either input parameter is NULL, the function returns NULL. +- It can handle time differences that span days, months, or years. diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md index 42612d96f501f..0d502ca9a0697 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md @@ -24,27 +24,44 @@ specific language governing permissions and limitations under the License. --> -## minutes_sub -### description -#### Syntax -`DATETIME MINUTES_SUB(DATETIME date, INT minutes)` +## Description -Subtracts a specified number of minutes from a datetime or date +Subtracts a specified number of minutes from a datetime value and returns a new datetime value. -The parameter date can be DATETIME or DATE, and the return type is DATETIME. - -### example +## Syntax +```sql +MINUTES_SUB(, ) ``` -mysql> select minutes_sub("2020-02-02 02:02:02", 1); -+---------------------------------------+ -| minutes_sub('2020-02-02 02:02:02', 1) | -+---------------------------------------+ -| 2020-02-02 02:01:02 | -+---------------------------------------+ + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATE, DATETIME, or DATETIMEV2 | +| `` | The number of minutes to subtract, of type INT; can be positive or negative | + +## Return Value + +Returns a value of type DATETIME, representing the datetime value after subtracting the specified number of minutes. + +## Example + +```sql +SELECT MINUTES_SUB("2020-02-02 02:02:02", 1); ``` -### keywords +```text ++--------------------------------------------------------------+ +| minutes_sub(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), 1) | ++--------------------------------------------------------------+ +| 2020-02-02 02:01:02 | ++--------------------------------------------------------------+ +``` - MINUTES_SUB +**Note:** +- When the number of minutes subtracted is negative, it effectively adds the corresponding number of minutes. +- The function automatically handles cases that cross hours and days. +- If the input parameter is NULL, the function returns NULL. +- The result retains the seconds portion of the original time. diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md index dd50bc4342bb4..d27c4d4102065 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md @@ -1,6 +1,6 @@ --- { - "title": "month_ceil", + "title": "MONTH_CEIL", "language": "en" } --- @@ -24,39 +24,52 @@ specific language governing permissions and limitations under the License. --> -## month_ceil -### description -#### Syntax + +## Description + +Rounds up a datetime value to the nearest specified month interval. If a starting time (origin) is provided, it uses that time as the reference for calculating the interval. + +## Syntax ```sql -DATETIME MONTH_CEIL(DATETIME datetime) -DATETIME MONTH_CEIL(DATETIME datetime, DATETIME origin) -DATETIME MONTH_CEIL(DATETIME datetime, INT period) -DATETIME MONTH_CEIL(DATETIME datetime, INT period, DATETIME origin) +MONTH_CEIL() +MONTH_CEIL(, ) +MONTH_CEIL(, ) +MONTH_CEIL(, , ) ``` -Convert the date to the nearest rounding up time of the specified time interval period. +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The datetime value to round up, of type DATETIME or DATETIMEV2 | +| `` | The month interval value, of type INT, representing the number of months in each interval | +| `` | The starting point for the interval, of type DATETIME or DATETIMEV2; defaults to 0001-01-01 00:00:00 | -- datetime: a valid date expression. -- period: specifies how many months each cycle consists of. -- origin: starting from 0001-01-01T00:00:00. +## Return Value -### example +Returns a value of type DATETIME, representing the rounded-up datetime value. The time portion of the result will be set to 00:00:00. +## Example + +```sql +SELECT MONTH_CEIL("2023-07-13 22:28:18", 5); ``` -mysql> select month_ceil("2023-07-13 22:28:18", 5); + +```text +-------------------------------------------------------------+ | month_ceil(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +-------------------------------------------------------------+ | 2023-10-01 00:00:00 | +-------------------------------------------------------------+ -1 row in set (0.02 sec) ``` -### keywords - - MONTH_CEIL, MONTH, CEIL +**Note:** +- If no period is specified, it defaults to a 1-month interval. +- The period must be a positive integer. +- The result is always rounded up to a future time. +- The time portion of the returned value is always set to 00:00:00. -### Best Practice +## Best Practices See also [date_ceil](./date_ceil) diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md index 60684714fb1c3..e6e672c246e69 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md @@ -1,6 +1,6 @@ --- { - "title": "month_floor", + "title": "MONTH_FLOOR", "language": "en" } --- @@ -24,39 +24,53 @@ specific language governing permissions and limitations under the License. --> -## month_floor -### description -#### Syntax + +## Description + +Rounds down a datetime value to the nearest specified month interval. If a starting time (origin) is provided, it uses that time as the reference for calculating the interval. + +## Syntax ```sql -DATETIME MONTH_FLOOR(DATETIME datetime) -DATETIME MONTH_FLOOR(DATETIME datetime, DATETIME origin) -DATETIME MONTH_FLOOR(DATETIME datetime, INT period) -DATETIME MONTH_FLOOR(DATETIME datetime, INT period, DATETIME origin) +MONTH_FLOOR() +MONTH_FLOOR(, ) +MONTH_FLOOR(, ) +MONTH_FLOOR(, , ) ``` -Convert the date to the nearest rounding down time of the specified time interval period. +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The datetime value to round down, of type DATETIME or DATETIMEV2 | +| `` | The month interval value, of type INT, representing the number of months in each interval | +| `` | The starting point for the interval, of type DATETIME or DATETIMEV2; defaults to 0001-01-01 00:00:00 | -- datetime: a valid date expression. -- period: specifies how many months each cycle consists of. -- origin: starting from 0001-01-01T00:00:00. +## Return Value -### example +Returns a value of type DATETIME, representing the rounded-down datetime value. The time portion of the result will be set to 00:00:00. +## Example + +```sql +SELECT MONTH_FLOOR("2023-07-13 22:28:18", 5); ``` -mysql> select month_floor("2023-07-13 22:28:18", 5); + +```text +--------------------------------------------------------------+ | month_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +--------------------------------------------------------------+ | 2023-05-01 00:00:00 | +--------------------------------------------------------------+ -1 row in set (0.12 sec) ``` -### keywords - - MONTH_FLOOR, MONTH, FLOOR +**Note:** +- If no period is specified, it defaults to a 1-month interval. +- The period must be a positive integer. +- The result is always rounded down to a past time. +- The time portion of the returned value is always set to 00:00:00. +- Unlike MONTH_CEIL, MONTH_FLOOR always discards the portion that exceeds the interval. -### Best Practice +## Best Practices See also [date_floor](./date_floor) diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md index 9a3a71f15be76..3dfc9779fc380 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md @@ -24,26 +24,40 @@ specific language governing permissions and limitations under the License. --> -## month -### Description -#### Syntax -`INT MONTH (DATETIME date)` +## Description +Extracts the month value from a datetime value. The returned value ranges from 1 to 12, representing the 12 months of the year. -Returns month information in the time type, ranging from 1,12 +## Syntax -The parameter is Date or Datetime type +```sql +MONTH() +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATE, DATETIME, or DATETIMEV2 | -### example +## Return Value +Returns an INT type representing the month value: +- Range: 1 to 12 +- 1 represents January, and 12 represents December. +- If the input is NULL, the function returns NULL. + +## Example + +```sql +SELECT MONTH('1987-01-01'); ``` -mysql> select month('1987-01-01'); -+-----------------------------+ -| month('1987-01-01 00:00:00') | -+-----------------------------+ -| 1 | -+-----------------------------+ + +```text ++--------------------------------------------+ +| month(cast('1987-01-01' as DATETIMEV2(0))) | ++--------------------------------------------+ +| 1 | ++--------------------------------------------+ ``` -### keywords - MONTH diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md index ae1852d1aa8cc..bd597c431fe14 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md @@ -24,26 +24,40 @@ specific language governing permissions and limitations under the License. --> -## monthname -### Description -#### Syntax -`VARCHAR MONTHNAME (DATE)` +## Description +Returns the English name of the month corresponding to a given date. The returned value is the full English name of the month (from January to December). -Month name corresponding to return date +## Syntax -The parameter is Date or Datetime type +```sql +MONTHNAME() +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATE, DATETIME, or DATETIMEV2 | -### example +## Return Value +Returns a value of type VARCHAR representing the English name of the month: +- Possible return values: January, February, March, April, May, June, July, August, September, October, November, December +- If the input is NULL, the function returns NULL. +- The first letter of the return value is capitalized, and the remaining letters are in lowercase. + +## Example + +```sql +SELECT MONTHNAME('2008-02-03 00:00:00'); ``` -mysql> select monthname('2008-02-03 00:00:00'); -+----------------------------------+ -| monthname('2008-02-03 00:00:00') | -+----------------------------------+ -| February | -+----------------------------------+ + +```text ++---------------------------------------------------------+ +| monthname(cast('2008-02-03 00:00:00' as DATETIMEV2(0))) | ++---------------------------------------------------------+ +| February | ++---------------------------------------------------------+ ``` -### keywords - MONTHNAME diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md index e5957fdc9e416..70bba730c0902 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md @@ -24,50 +24,37 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Determines whether the given `map` contains a specific key `key` -`BOOLEAN map_contains_key(Map map, K key)` +## Syntax -Determines whether the given `map` contains a particular key `key`. +```sql +MAP_CONTAINS_KEY(, ) +``` -### Example +## Parameters -```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +| Parameter | Description | +| -- | -- | +| `` | Input map content | +| `` | The key to be retrieved | -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## Return Value -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +Determines whether the given `map` contains a specific key `key`, and returns 1 if it exists, otherwise returns 0. -mysql> select map_contains_key(map(null, 1, 2, null), null); -+-----------------------------------------------+ -| map_contains_key(map(NULL, 1, 2, NULL), NULL) | -+-----------------------------------------------+ -| 1 | -+-----------------------------------------------+ -1 row in set (0.14 sec) -``` +## Example -### Keywords +```sql +select map_contains_key(map(null, 1, 2, null), null),map_contains_key(map(1, "100", 0.1, 2), 0.11); +``` -MAP, CONTAINS, KEY, MAP_CONTAINS_KEY +```text ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_key(map(NULL, 1, 2, NULL), NULL) | map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast(0.11 as DECIMALV3(3, 2))) | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md index 68c280c05b0af..1eea84a410cc7 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md @@ -24,66 +24,37 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Determines whether the given `map` contains a specific value `value` -`BOOLEAN map_contains_value(Map map, V value)` - -Determines whether the given `map` contains a particular value `value`. - -### Example +## Syntax ```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +MAP_CONTAINS_VALUE(, ) +``` -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## Parameters -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +| Parameter | Description | +| -- | -- | +| `` | Input map content | +| `` | The value to be retrieved | -mysql> select map_contains_value(map(1, "100", 0.1, 2), 100.0); -+--------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(100.0 as VARCHAR(3))) | -+--------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+--------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## Return Value -mysql> select map_contains_value(map(1, "100", 0.1, 2), 101); -+------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | -+------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.14 sec) +Determines whether the given `map` contains a specific value `value`, and returns 1 if it exists, otherwise returns 0. -mysql> select map_contains_value(map(null, 1, 2, null), null); -+-------------------------------------------------+ -| map_contains_value(map(NULL, 1, 2, NULL), NULL) | -+-------------------------------------------------+ -| 1 | -+-------------------------------------------------+ -1 row in set (0.15 sec) -``` +## Example -### Keywords +```sql +select map_contains_value(map(null, 1, 2, null), null),map_contains_value(map(1, "100", 0.1, 2), 101); +``` -MAP, CONTAINS, VALUE, MAP_CONTAINS_VALUE +```text ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_value(map(NULL, 1, 2, NULL), NULL) | map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md index 04e20a1cfb261..5bde39f09b926 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md @@ -23,35 +23,36 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> +## Description -### Description +Extract the keys of the given `map` into an `ARRAY` of the corresponding type -#### Syntax +## Syntax -`ARRAY map_keys(Map map)` +```sql +MAP_KEYS() +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | Input map content | -Extracts the keys of a given `map` into an `ARRAY` of the corresponding type. +## Return Value -### Example +Extract the keys of the given `map` into an `ARRAY` of the corresponding type + +## Example ```sql -mysql> select map_keys(map(1, "100", 0.1, 2)); -+-------------------------------------------------------------------------------------------------+ -| map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+-------------------------------------------------------------------------------------------------+ -| [1.0, 0.1] | -+-------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) - -mysql> select map_keys(map()); -+-----------------+ -| map_keys(map()) | -+-----------------+ -| [] | -+-----------------+ -1 row in set (0.12 sec) +select map_keys(map()),map_keys(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, KEYS, MAP_KEYS +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_keys(map()) | map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| [] | [1.0, 0.1] | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md index 79f097a3ff53d..15c78086b80c3 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md @@ -1,7 +1,6 @@ --- { - "title": "MAP_SIZE - ", + "title": "MAP_SIZE", "language": "en" } --- @@ -24,3 +23,37 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## Description + +Count the number of elements in a Map + +## Syntax + +```sql +MAP_SIZE() +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | Input map content | + +## Return Value + +Returns the number of elements in the Map + +## Example + +```sql +select map_size(map()),map_size(map(1, "100", 0.1, 2)); +``` + +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_size(map()) | map_size(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| 0 | 2 | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md index 6fef8da25aab1..160fcb91ee7cf 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md @@ -24,34 +24,36 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Extract the values of the given `map` into an `ARRAY` of the corresponding type -`ARRAY map_values(Map map)` +## Syntax -Extracts the value of a given `map` into an `ARRAY` of the corresponding type. +```sql +MAP_VALUES() +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | Input map content | -### Example +## Return Value + +Extract the values of the given `map` into an `ARRAY` of the corresponding type + +## Example ```sql -mysql> select map_values(map(1, "100", 0.1, 2)); -+---------------------------------------------------------------------------------------------------+ -| map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+---------------------------------------------------------------------------------------------------+ -| ["100", "2"] | -+---------------------------------------------------------------------------------------------------+ -1 row in set (0.12 sec) - -mysql> select map_values(map()); -+-------------------+ -| map_values(map()) | -+-------------------+ -| [] | -+-------------------+ -1 row in set (0.11 sec) +select map_values(map()),map_values(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, VALUES, MAP_VALUES +```text ++-------------------+---------------------------------------------------------------------------------------------------+ +| map_values(map()) | map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-------------------+---------------------------------------------------------------------------------------------------+ +| [] | ["100", "2"] | ++-------------------+---------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map.md index 8ffda7f10305b..f19716c0dc13f 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/map-functions/map.md @@ -24,34 +24,37 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Constructs a `Map` of a specific type using some set of key-value pairs -`MAP map(K key0, V value0, K key1, V value1, ..., K keyn, V valuen)` +## Syntax -Construct a type-specific `Map` using a set of key-value pairs. +```sql +MAP( , [, , ... ]) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | Constructing the key of the map | +| `` | Constructing the value of the map | -### Example +## Return Value + +Returns a specific type `Map` constructed from a number of key-value pairs + +## Example ```sql -mysql> select map(1, "100", 0.1, 2); -+---------------------------------------------------------------------------------------+ -| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | -+---------------------------------------------------------------------------------------+ -| {1.0:"100", 0.1:"2"} | -+---------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) - -mysql> select map(1, "100", 0.1, 2)[1]; -+-------------------------------------------------------------------------------------------------------------------------------+ -| element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | -+-------------------------------------------------------------------------------------------------------------------------------+ -| 100 | -+-------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +select map(1, "100", 0.1, 2),map(1, "100", 0.1, 2)[1]; ``` -### Keywords - -MAP +```text ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| {1.0:"100", 0.1:"2"} | 100 | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md index ca99aeb9125dd..401c2ac7c0a0f 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md @@ -24,36 +24,52 @@ specific language governing permissions and limitations under the License. --> -## ST_Angle_Sphere -### description -#### Syntax +## Description -`DOUBLE ST_Angle_Sphere(DOUBLE x_lng, DOUBLE x_lat, DOUBLE y_lng, DOUBLE y_lat)` +Calculate the center Angle between two points on the Earth's surface in degrees. The parameters passed in are the longitude of point X, latitude of point X, longitude of point Y, and latitude of point Y. +## Syntax -Calculates the central angle between two points on the Earth's surface. The incoming parameters are the longitude of point X, the latitude of point X, the longitude of point Y and the latitude of point Y. +```sql +ST_Angle_Sphere( , , , ) +``` + +## Parameters + +| Parameters | Instructions | +| -- | -- | +| `` | Longitude data, reasonable value range is [-180, 180] | +| `` | Longitude data, reasonable value range is [-180, 180] | +| `` | Latitude data, reasonable value range is [-90, 90] | +| `` | Latitude data, reasonable value range is [-90, 90] | -x_lng and y_lng are Longitude values, must be in the range [-180, 180]. -x_lat and y_lat are Latitude values, must be in the range [-90, 90]. +## Return Value -### example +The Angle of the center between two points +## Examples + +```sql +select ST_Angle_Sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); ``` -mysql> select ST_Angle_Sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); + +```text +---------------------------------------------------------------------------+ | st_angle_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219) | +---------------------------------------------------------------------------+ | 0.0659823452409903 | +---------------------------------------------------------------------------+ -1 row in set (0.06 sec) +``` + +```sql +select ST_Angle_Sphere(0, 0, 45, 0); +``` -mysql> select ST_Angle_Sphere(0, 0, 45, 0); +```text +----------------------------------------+ | st_angle_sphere(0.0, 0.0, 45.0, 0.0) | +----------------------------------------+ | 45 | +----------------------------------------+ -1 row in set (0.06 sec) ``` -### keywords -ST_ANGLE_SPHERE,ST,ANGLE,SPHERE + diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md index bccc92b06034c..bc5e44b4e443a 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md @@ -24,66 +24,95 @@ specific language governing permissions and limitations under the License. --> -## ST_Angle +## Description -### Syntax +Enter three points that represent two intersecting lines. Return the Angle between these lines. -`DOUBLE ST_Angle(GEOPOINT point1, GEOPOINT point2, GEOPOINT point3)` +## Syntax -### description +```sql +ST_Angle( , , ) +``` + +## Parameters + +| Parameters | Instructions | +|----------|---------------------------------------------------------------------------| +| `` | The first point of the first line | +| `` | The second point of the first line and the first point of the second line | +| `` | The second point of the second line | -Enter three point, which represent two intersecting lines. Returns the angle between these lines. Point 2 and point 1 represent the first line and point 2 and point 3 represent the second line. The angle between these lines is in radians, in the range [0, 2pi). The angle is measured clockwise from the first line to the second line. +## Return Value + +The Angle between these lines is expressed in radians and ranges from [0, 2pi]. The Angle is measured clockwise from the first line to the second line. ST_ANGLE has the following edge cases: -* If points 2 and 3 are the same, returns NULL. -* If points 2 and 1 are the same, returns NULL. -* If points 2 and 3 are exactly antipodal, returns NULL. -* If points 2 and 1 are exactly antipodal, returns NULL. -* If any of the input geographies are not single points or are the empty geography, then throws an error. +- If point 2 and point 3 are the same, NULL is returned +- If point 2 and point 1 are the same, NULL is returned +- NULL is returned if points 2 and 3 are perfect Antipodes +- NULL is returned if points 2 and 1 are perfect AntipodesL +- If any input geography is not a single point or is an empty geography, an error is thrown -### example +## Examples +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1)); ``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1)); + +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------------------------+ | 4.71238898038469 | +----------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1)); +``` -mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1)); +```text +----------------------------------------------------------------------+ | st_angle(st_point(0.0, 0.0), st_point(1.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------------------------+ | 0.78547432161873854 | +----------------------------------------------------------------------+ -1 row in set (0.02 sec) +``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0)); +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0)); +``` + +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(1.0, 0.0)) | +----------------------------------------------------------------------+ | 0 | +----------------------------------------------------------------------+ -1 row in set (0.02 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 0)); +``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 0)); +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 0.0)) | +----------------------------------------------------------------------+ | NULL | +----------------------------------------------------------------------+ -1 row in set (0.03 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(0, 0),ST_Point(-30, 0),ST_Point(150, 0)); +``` -mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(-30, 0),ST_Point(150, 0)); +```text +--------------------------------------------------------------------------+ | st_angle(st_point(0.0, 0.0), st_point(-30.0, 0.0), st_point(150.0, 0.0)) | +--------------------------------------------------------------------------+ | NULL | +--------------------------------------------------------------------------+ -1 row in set (0.02 sec) ``` -### keywords -ST_ANGLE,ST,ANGLE + diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md index d349861bbf19d..c4282f10a1654 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md @@ -24,45 +24,63 @@ specific language governing permissions and limitations under the License. --> -## ST_AsBinary +## Description -### Syntax +Convert a geometric figure to a standard WKB (Well-known binary) representation. -`VARCHAR ST_AsBinary(GEOMETRY geo)` +At present, the supported geometry is: Point, LineString, Polygon. -### Description +## Syntax -Converting a geometric figure into a standard WKB (Well-known binary) representation +```sql +ST_AsBinary( ) +``` + +## Parameters + +| Parameters | Instructions | +| -- |----------| +| `` | The graph that needs to be converted | + +## Return Value -Currently supported geometric figures are: Point, LineString, Polygon. +The WKB representation of the geometry: -### example +## Examples +```sql +select ST_AsBinary(st_point(24.7, 56.7)); ``` -mysql> select ST_AsBinary(st_point(24.7, 56.7)); + +```text +----------------------------------------------+ | st_asbinary(st_point(24.7, 56.7)) | +----------------------------------------------+ | \x01010000003333333333b338409a99999999594c40 | +----------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> select ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); +```sql +select ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); +``` + +```text +--------------------------------------------------------------------------------------+ | st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +--------------------------------------------------------------------------------------+ | \x010200000002000000000000000000f03f000000000000f03f00000000000000400000000000000040 | +--------------------------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` + +```sql +select ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")); +``` -mysql> select ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")); +```text +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')) | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | \x01030000000100000006000000f3380ce6af865c402d05a4fd0f8c364041ef8d2100865c403049658a398c3640b9fb1c1f2d865c409d9b36e334883640de921cb0ab865c40cf876709328a36402cefaa07cc865c407b319413ed8a3640f3380ce6af865c402d05a4fd0f8c3640 | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.02 sec) - ``` -### keywords -ST_ASBINARY,ST,ASBINARY + diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md index b1990bb38353a..985ab2fb9d9bb 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_AsText,ST_AsWKT -### Description -#### Syntax +## Description -`VARCHAR ST_AsText (GEOMETRY geo)` +Convert a geometric figure to a representation of WKT (Well Known Text) +## Syntax -Converting a geometric figure into a WKT (Well Known Text) representation +```sql +ST_AsText(GEOMETRY ) +``` + +## Parameters + +| Parameters | Instructions | +| -- |----------| +| `` | The graph that needs to be converted | -### example +## Return Value +The WKT representation of the geometry: + +## Examples + +```sql +SELECT ST_AsText(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_AsText(ST_Point(24.7, 56.7)); + +```text +---------------------------------+ | st_astext(st_point(24.7, 56.7)) | +---------------------------------+ | POINT (24.7 56.7) | +---------------------------------+ ``` -### keywords -ST_ASTEXT,ST_ASWKT,ST,ASTEXT,ASWKT diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md index bb7b9ed19e41a..e202728c5d14a 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md @@ -24,72 +24,85 @@ specific language governing permissions and limitations under the License. --> -## ST_Azimuth +## Description -### Syntax +Enter two points and return the azimuth of the line segment formed by points 1 and 2. Azimuth is the arc of the Angle between the true north line of point 1 and the line segment formed by points 1 and 2. -`DOUBLE ST_Azimuth(GEOPOINT point1, GEOPOINT point2)` +## Syntax -### description +```sql +ST_Azimuth( , ) +``` + +## Parameters + +| Parameters | Instructions | +|----------|------------------------------------------------| +| `` | The first point used to calculate the azimuth | +| `` | The second point used to calculate the azimuth | -Enter two point, and returns the azimuth of the line segment formed by points 1 and 2. The azimuth is the angle in radians measured between the line from point 1 facing true North to the line segment from point 1 to point 2. +## Return Value -The positive angle is measured clockwise on the surface of a sphere. For example, the azimuth for a line segment: +Positive angles are measured clockwise on the sphere. For example, the azimuth of a line segment: -* Pointing North is 0 -* Pointing East is PI/2 -* Pointing South is PI -* Pointing West is 3PI/2 +- North is 0 +- East is PI/2 +- The guide is PI +- The west is 3PI/2 ST_Azimuth has the following edge cases: -* If the two input points are the same, returns NULL. -* If the two input points are exactly antipodal, returns NULL. -* If either of the input geographies are not single points or are the empty geography, throws an error. +- Return NULL if both input points are the same. +- NULL is returned if the two input points are perfect mapping points. +- An error is thrown if any of the input geographies are not a single point or are empty geographies -### example +## Examples +```sql +SELECT st_azimuth(ST_Point(1, 0),ST_Point(0, 0)); ``` -mysql> SELECT st_azimuth(ST_Point(1, 0),ST_Point(0, 0)); + +```text +----------------------------------------------------+ | st_azimuth(st_point(1.0, 0.0), st_point(0.0, 0.0)) | +----------------------------------------------------+ | 4.71238898038469 | +----------------------------------------------------+ -1 row in set (0.03 sec) +``` -mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(1, 0)); +```sql +SELECT st_azimuth(ST_Point(0, 0),ST_Point(1, 0)); +``` + +```text +----------------------------------------------------+ | st_azimuth(st_point(0.0, 0.0), st_point(1.0, 0.0)) | +----------------------------------------------------+ | 1.5707963267948966 | +----------------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(0, 1)); +```sql +SELECT st_azimuth(ST_Point(0, 0),ST_Point(0, 1)); +``` + +```text +----------------------------------------------------+ | st_azimuth(st_point(0.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------+ | 0 | +----------------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> SELECT st_azimuth(ST_Point(0, 1),ST_Point(0, 1)); -+----------------------------------------------------+ -| st_azimuth(st_point(0.0, 1.0), st_point(0.0, 1.0)) | -+----------------------------------------------------+ -| NULL | -+----------------------------------------------------+ -1 row in set (0.02 sec) +```sql +SELECT st_azimuth(ST_Point(-30, 0),ST_Point(150, 0)); +``` -mysql> SELECT st_azimuth(ST_Point(-30, 0),ST_Point(150, 0)); +```text +--------------------------------------------------------+ | st_azimuth(st_point(-30.0, 0.0), st_point(150.0, 0.0)) | +--------------------------------------------------------+ | NULL | +--------------------------------------------------------+ -1 row in set (0.02 sec) - ``` -### keywords -ST_AZIMUTH,ST,AZIMUTH + diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md index 5b9750a1cf021..8e16a6befe79d 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md @@ -24,25 +24,41 @@ specific language governing permissions and limitations under the License. --> -## ST_Circle -### Description -#### Syntax +## Description -`GEOMETRY ST_Circle(DOUBLE center_lng, DOUBLE center_lat, DOUBLE radius)` +Convert a WKT (Well Known Text) to a circle on the sphere of the Earth. +## Syntax -Convert a WKT (Well Known Text) into a circle on the earth's sphere. Where `center_lng'denotes the longitude of the center of a circle, -` Center_lat` denotes the latitude of the center of a circle, radius` denotes the radius of a circle in meters. +```sql +ST_Circle( , , ) +``` + +## Parameters + +| Parameters | Instructions | +| -- | -- | +| `` | Longitude of the center of the circle | +| `` | The latitude of the center of the circle | +| `` | Radius of a circle | + +- The unit of radius is meters. A maximum of 9999999 RADIUS is supported -### example +## Return Value +A circle on a sphere based on basic information about the circle + +## Examples + +```sql +SELECT ST_AsText(ST_Circle(111, 64, 10000)); ``` -mysql> SELECT ST_AsText(ST_Circle(111, 64, 10000)); + +```text +--------------------------------------------+ | st_astext(st_circle(111.0, 64.0, 10000.0)) | +--------------------------------------------+ | CIRCLE ((111 64), 10000) | +--------------------------------------------+ ``` -### keywords -ST_CIRCLE,ST,CIRCLE + diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md index a3ab1214b0ccf..6454cce61403a 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md @@ -24,32 +24,52 @@ specific language governing permissions and limitations under the License. --> -## ST_Contains -### Description -#### Syntax +## Description -`BOOL ST_Contains(GEOMETRY shape1, GEOMETRY shape2)` +Determines whether the geometry shape1 is fully capable of containing the geometry shape2 +## Syntax -Judging whether geometric shape 1 can contain geometric shape 2 completely +```sql +ST_Contains( , ) +``` + +## Parameters + +| Parameters | Instructions | +|----------|------------------------| +| `` | The passed geometry used to determine whether shape2 is included | +| `` | The passed geometry is used to determine whether shape1 is included | + +## Return Value + +Return 1:shape1 The graph can contain the graph shape2 -### example +Return 0:shape1 Graph cannot contain graph shape2 +## Examples + +```sql +SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(5, 5)); ``` -mysql> SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(5, 5)); + +```text +----------------------------------------------------------------------------------------+ | st_contains(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'), st_point(5.0, 5.0)) | +----------------------------------------------------------------------------------------+ | 1 | +----------------------------------------------------------------------------------------+ +``` + +```sql +SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(50, 50)); +``` -mysql> SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(50, 50)); +```text +------------------------------------------------------------------------------------------+ | st_contains(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'), st_point(50.0, 50.0)) | +------------------------------------------------------------------------------------------+ | 0 | +------------------------------------------------------------------------------------------+ ``` -### keywords -ST_CONTAINS,ST,CONTAINS diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md index a50fc65625b1f..e1b5c76a90d9d 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md @@ -24,27 +24,40 @@ specific language governing permissions and limitations under the License. --> -## ST_Distance_Sphere -### description -#### Syntax +## Description -`DOUBLE ST_Distance_Sphere(DOUBLE x_lng, DOUBLE x_lat, DOUBLE y_lng, DOUBLE y_lat)` +Calculate the spherical distance in meters between two points on the Earth. The parameters passed in are the longitude of point X, latitude of point X, longitude of point Y, and latitude of point Y. +## Syntax -Calculate the spherical distance between two points of the earth in meters. The incoming parameters are the longitude of point X, the latitude of point X, the longitude of point Y and the latitude of point Y. +```sql +ST_Distance_Sphere( , , , ) +``` + +## Parameters + +| Parameters | Instructions | +| -- | -- | +| `` | Longitude data, reasonable value range is [-180, 180] | +| `` | Longitude data, reasonable value range is [-180, 180] | +| `` | Latitude data, reasonable value range is [-90, 90] | +| `` | Latitude data, reasonable value range is [-90, 90] | -x_lng and y_lng are Longitude values, must be in the range [-180, 180]. -x_lat and y_lat are Latitude values, must be in the range [-90, 90]. +## Return Value -### example +The spherical distance between two points +## Examples + +```sql +select st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); ``` -mysql> select st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); + +```text +----------------------------------------------------------------------------+ | st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219) | +----------------------------------------------------------------------------+ | 7336.9135549995917 | +----------------------------------------------------------------------------+ ``` -### keywords -ST_DISTANCE_SPHERE,ST,DISTANCE,SPHERE + diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md index 28072a02016d0..b0068482233f0 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md @@ -24,24 +24,35 @@ specific language governing permissions and limitations under the License. --> -## ST_GeometryFromText,ST_GeomFromText -### Description -#### Syntax +## Description -`GEOMETRY ST_GeometryFromText (VARCHAR wkt)` +Convert a linear WKT (Well Known Text) to the corresponding memory geometry +## Syntax -Converting a WKT (Well Known Text) into a corresponding memory geometry +```sql +ST_GeometryFromText( ) +``` +## Parameters + +| Parameters | Instructions | +|------------|---------| +| `` | The memory form of the graph | + +## Return Value -### example +The corresponding geometric storage form of WKB +## Examples + +```sql +SELECT ST_AsText(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); ``` -mysql> SELECT ST_AsText(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); + +```text +---------------------------------------------------------+ | st_astext(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +---------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +---------------------------------------------------------+ -``` -### keywords -ST_GEOMETRYFROMTEXT,ST_GEOMFROMTEXT,ST,GEOMETRYFROMTEXT,GEOMFROMTEXT +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md index bf0a47f4b5903..ed7366c2e0939 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md @@ -24,59 +24,83 @@ specific language governing permissions and limitations under the License. --> -## ST_GeometryFromWKB,ST_GeomFromWKB +## Description -### Syntax +Converts a standard figure WKB (Well-known binary) to the corresponding memory geometry -`GEOMETRY ST_GeometryFromWKB(VARCHAR WKB)` +## Syntax -### Description +```sql +ST_GeometryFromWKB( ) +``` +## Parameters + +| Parameters | Instructions | +|------------|---------| +| `` | The memory form of the graph | + +## Return Value -Converting a standard WKB (Well-known binary) into a corresponding memory geometry +The corresponding geometric storage form of WKB -### example +## Examples +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); ``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); + +```text +------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_point(24.7, 56.7)))) | +------------------------------------------------------------------+ | POINT (24.7 56.7) | +------------------------------------------------------------------+ -1 row in set (0.05 sec) +``` -mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); +```sql +select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); +``` + +```text +--------------------------------------------------------------+ | st_astext(st_geomfromwkb(st_asbinary(st_point(24.7, 56.7)))) | +--------------------------------------------------------------+ | POINT (24.7 56.7) | +--------------------------------------------------------------+ -1 row in set (0.03 sec) +``` + +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")))); +``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")))); +```text +------------------------------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')))) | +------------------------------------------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +------------------------------------------------------------------------------------------+ -1 row in set (0.06 sec) +``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +``` + +```text +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) +``` -mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +```sql +select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +``` + +```text +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_astext(st_geomfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) | +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) | +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) - -``` -### keywords -ST_GEOMETRYFROMWKB,ST_GEOMFROMWKB,ST,GEOMETRYFROMWKB,GEOMFROMWKB,WKB +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md index 3a033103b1580..9fa5f0f4b8e37 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_LineFromText,ST_LineStringFromText -### Description -#### Syntax +## Description -`GEOMETRY ST LineFromText (VARCHAR wkt)` +Converts a WKT (Well Known Text) to a memory representation in the form of a Line +## Syntax -Converting a WKT (Well Known Text) into a Line-style memory representation +```sql +ST_LineFromText( ) +``` + +## Parameters + +| Parameters | Instructions | +|-----|------------| +| `` | A line segment consisting of two coordinates | + +## Return Value -### example +The memory form of a line segment. +## Examples + +```sql +SELECT ST_AsText(ST_LineFromText("LINESTRING (1 1, 2 2)")); ``` -mysql> SELECT ST_AsText(ST_LineFromText("LINESTRING (1 1, 2 2)")); + +```text +---------------------------------------------------------+ | st_astext(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +---------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +---------------------------------------------------------+ -``` -### keywords -ST_LINEFROMTEXT, ST_LINESTRINGFROMTEXT,ST,LINEFROMTEXT,LINESTRINGFROMTEXT +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md index 050f41a31ad88..661fdac7ee6e1 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md @@ -24,25 +24,38 @@ specific language governing permissions and limitations under the License. --> -## St_Point -### Description -#### Syntax +## Description -`POINT ST_Point(DOUBLE x, DOUBLE y)` +With the given X coordinate value, the Y coordinate value returns the corresponding Point. +The current value is only meaningful in the sphere set, X/Y corresponds to longitude/latitude; -Given the X coordinate value, the Y coordinate value returns the corresponding Point. -The current value is meaningful only for spherical sets, and X/Y corresponds to longitude/latitude. +## Syntax -### example +```sql +ST_Point( , ) +``` +## Parameters + +| Parameters | Instructions | +|-----|--------------| +| `` | x-coordinate | +| `` | y-coordinate | + +## Return Value + +Given horizontal coordinate and vertical coordinate corresponding position information +## Examples + +```sql +SELECT ST_AsText(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_AsText(ST_Point(24.7, 56.7)); + +```text +---------------------------------+ | st_astext(st_point(24.7, 56.7)) | +---------------------------------+ | POINT (24.7 56.7) | +---------------------------------+ -``` -### keywords -ST_POINT,ST,POINT +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md index 226736bb2d64c..aa282b328bab1 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md @@ -24,25 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_Polygon,ST_PolyFromText,ST_PolygonFromText -### Description -#### Syntax +## Description -`GEOMETRY ST_Polygon (VARCHAR wkt)` +Convert a WKT (Well Known Text) to the corresponding polygonal memory form +## Syntax -Converting a WKT (Well Known Text) into a corresponding polygon memory form +```sql +ST_Polygon( ) +``` + +## Parameters + +| Parameters | Instructions | +|------|--------------------| +| `` | A POLYGON generated by the polygon function | +## Return Value -#### example +Memory form of polygon +## Examples + +```sql +SELECT ST_AsText(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))")); ``` -mysql> SELECT ST_AsText(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))")); + +```text +------------------------------------------------------------------+ | st_astext(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))')) | +------------------------------------------------------------------+ | POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0)) | +------------------------------------------------------------------+ ``` -### keywords -ST_POLYGON,ST_POLYFROMTEXT,ST_POLYGONFROMTEXT,ST,POLYGON,POLYFROMTEXT,POLYGONFROMTEXT diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md index a00eb050cfc13..7324fe6226bb1 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_X -### Description -#### Syntax +## Description -`DOUBLE ST_X(POINT point)` +When point is a valid POINT type, return the corresponding x-coordinate value +## Syntax -When point is a valid POINT type, the corresponding X coordinate value is returned. +```sql +ST_X( ) +``` + +## Parameters + +| Parameters | Instructions | +|------|----------| +| `` | The geometric coordinates of a two-dimensional point | + +## Return Value -### example +X value in geometric coordinates +## Examples + +```sql +SELECT ST_X(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_X(ST_Point(24.7, 56.7)); + +```text +----------------------------+ | st_x(st_point(24.7, 56.7)) | +----------------------------+ | 24.7 | +----------------------------+ -``` -### keywords -ST_X,ST,X +``` \ No newline at end of file diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md index eec67131b9ad3..de27d59df8015 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_Y -### Description -#### Syntax +## Description -`DOUBLE ST_Y(POINT point)` +When point is a valid POINT type, return the corresponding y-coordinate value +## Syntax -When point is a valid POINT type, the corresponding Y coordinate value is returned. +```sql +ST_Y( ) +``` + +## Parameters + +| Parameters | Instructions | +|------|----------| +| `` | The geometric coordinates of a two-dimensional point | + +## Return Value -### example +Y value in geometric coordinates +## Examples + +```sql +SELECT ST_Y(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_Y(ST_Point(24.7, 56.7)); + +```text +----------------------------+ -| st_y(st_point(24.7, 56.7)) | +| st_x(st_point(24.7, 56.7)) | +----------------------------+ -| 56.7 | +| 24.7 | +----------------------------+ -``` -### keywords -ST_Y,ST,Y +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/compute-storage-decoupled/managing-storage-vault.md b/versioned_docs/version-3.0/compute-storage-decoupled/managing-storage-vault.md index 56170c579ceb2..24216e8077f5d 100644 --- a/versioned_docs/version-3.0/compute-storage-decoupled/managing-storage-vault.md +++ b/versioned_docs/version-3.0/compute-storage-decoupled/managing-storage-vault.md @@ -44,7 +44,7 @@ PROPERTIES To create an HDFS-based decoupled storage-compute Doris cluster, ensure that all nodes (including FE/BE nodes, Meta Service) have privilege to access the specified HDFS, including completing Kerberos authorization configuration and connectivity checks in advance (which can be tested using Hadoop Client on each corresponding node). ```sql -CREATE STORAGE VAULT IF NOT EXISTS ssb_hdfs_vault +CREATE STORAGE VAULT IF NOT EXISTS hdfs_vault_demo PROPERTIES ( "type"="hdfs", -- required "fs.defaultFS"="hdfs://127.0.0.1:8020", -- required @@ -59,17 +59,18 @@ CREATE STORAGE VAULT IF NOT EXISTS ssb_hdfs_vault ### Create an S3 Storage Vault ```sql -CREATE STORAGE VAULT IF NOT EXISTS ssb_s3_vault - PROPERTIES ( - "type"="S3", -- required - "s3.endpoint" = "oss-cn-beijing.aliyuncs.com", -- required - "s3.region" = "bj", -- required - "s3.bucket" = "bucket", -- required - "s3.root.path" = "big/data/prefix", -- required - "s3.access_key" = "ak", -- required - "s3.secret_key" = "sk", -- required - "provider" = "OSS" -- required - ); +CREATE STORAGE VAULT IF NOT EXISTS s3_vault_demo +PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "oss-cn-beijing.aliyuncs.com", -- required + "s3.region" = "cn-beijing", -- required + "s3.bucket" = "bucket", -- required + "s3.root.path" = "big/data/prefix", -- required + "s3.access_key" = "ak", -- required + "s3.secret_key" = "sk", -- required + "provider" = "OSS", -- required + "use_path_style" = "false" -- optional +); ``` More parameter explanations and examples can be found in [CREATE-STORAGE-VAULT](../sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT.md). @@ -112,7 +113,7 @@ UNIQUE KEY (s_suppkey) DISTRIBUTED BY HASH(s_suppkey) BUCKETS 1 PROPERTIES ( "replication_num" = "1", -"storage_vault_name" = "ssb_hdfs_vault" +"storage_vault_name" = "hdfs_demo_vault" ); ``` @@ -171,7 +172,7 @@ GRANT Only Admin users have the authority to execute the `GRANT` statement, which is used to grant specified Storage Vault privileges to User/Role. Users/Roles with `USAGE_PRIV` privilege for a certain Storage Vault can perform the following operations: -- View the information of that Storage Vault through `SHOW STORAGE VAULT`; +- View the information of that Storage Vault through `SHOW STORAGE VAULTS`; - Specify the use of that Storage Vault in `PROPERTIES` when creating tables. **Example** diff --git a/versioned_docs/version-3.0/data-operate/import/data-source/kafka.md b/versioned_docs/version-3.0/data-operate/import/data-source/kafka.md index 51254997a11c8..b2cb53cee81de 100644 --- a/versioned_docs/version-3.0/data-operate/import/data-source/kafka.md +++ b/versioned_docs/version-3.0/data-operate/import/data-source/kafka.md @@ -191,7 +191,7 @@ The Doris Kafka Connector is a tool for loading Kafka data streams into the Dori 2. Configure `config/connect-distributed.properties`: ```Bash -# Modify broker address +# Modify kafka server address bootstrap.servers=127.0.0.1:9092 # Modify group.id, which needs to be consistent across the same cluster diff --git a/versioned_docs/version-3.0/data-operate/update/update-of-aggregate-model.md b/versioned_docs/version-3.0/data-operate/update/update-of-aggregate-model.md index 3fde759a85cb6..8fa858b7a226c 100644 --- a/versioned_docs/version-3.0/data-operate/update/update-of-aggregate-model.md +++ b/versioned_docs/version-3.0/data-operate/update/update-of-aggregate-model.md @@ -1,4 +1,4 @@ -- +--- { "title": "Updating Data on Aggregate Key Model", "language": "en" diff --git a/versioned_docs/version-3.0/ecosystem/doris-kafka-connector.md b/versioned_docs/version-3.0/ecosystem/doris-kafka-connector.md index a2601eac131c9..98b9c791f723e 100644 --- a/versioned_docs/version-3.0/ecosystem/doris-kafka-connector.md +++ b/versioned_docs/version-3.0/ecosystem/doris-kafka-connector.md @@ -98,7 +98,7 @@ Create the plugins directory under $KAFKA_HOME and put the downloaded doris-kafk Configure config/connect-distributed.properties ```properties -# Modify broker address +# Modify kafka server address bootstrap.servers=127.0.0.1:9092 # Modify group.id, the same cluster needs to be consistent diff --git a/versioned_docs/version-3.0/gettingStarted/what-is-apache-doris.md b/versioned_docs/version-3.0/gettingStarted/what-is-apache-doris.md index 5353017b4f544..cfddb0c9ce061 100644 --- a/versioned_docs/version-3.0/gettingStarted/what-is-apache-doris.md +++ b/versioned_docs/version-3.0/gettingStarted/what-is-apache-doris.md @@ -83,7 +83,7 @@ Starting from version 3.0, a compute-storage decoupled deployment architecture c - Storage Layer: The storage layer can use shared storage solutions such as S3, HDFS, OSS, COS, OBS, Minio, and Ceph to store Doris's data files, including Segment files and inverted index files. -![Overall Architecture and Technical Features of Compute-Storage Decoupling](/images/getting-started/apache-doris-technical-compute-storage-decouple-overview.png) +![Overall Architecture and Technical Features of Compute-Storage Decoupling](/images/getting-started/apache-doris-technical-compute-storage-decouple-overview.jpg) ## Core Features of Apache Doris diff --git a/versioned_docs/version-3.0/install/deploy-manually/storage-compute-decoupled-deploy-manually.md b/versioned_docs/version-3.0/install/deploy-manually/storage-compute-decoupled-deploy-manually.md index 1a354de126ae1..6f64e971c9497 100644 --- a/versioned_docs/version-3.0/install/deploy-manually/storage-compute-decoupled-deploy-manually.md +++ b/versioned_docs/version-3.0/install/deploy-manually/storage-compute-decoupled-deploy-manually.md @@ -1,6 +1,6 @@ --- { - "title": "deploy storage compute decoupled manually", + "title": "Deploy Storage Compute Decoupled Manually", "language": "en" } --- diff --git a/versioned_docs/version-3.0/releasenotes/v1.1/release-1.1.0.md b/versioned_docs/version-3.0/releasenotes/v1.1/release-1.1.0.md index dd94da6816294..e7bb10faf5abf 100644 --- a/versioned_docs/version-3.0/releasenotes/v1.1/release-1.1.0.md +++ b/versioned_docs/version-3.0/releasenotes/v1.1/release-1.1.0.md @@ -88,11 +88,11 @@ On all 13 SQLs in the SSB test data set, version 1.1 is better than version 0.15 On all 22 SQLs in the TPC-H test data set, version 1.1 is better than version 0.15, the overall performance is improved by about 4.5 times, and the performance of some scenarios is improved by more than ten times; -![](/images/release-note-1.1.0-SSB.png) +![release-note-1.1.0-SSB](/images/release-note-1.1.0-SSB.png)

SSB Benchmark

-![](/images/release-note-1.1.0-TPC-H.png) +![release-note-1.1.0-TPC-H](/images/release-note-1.1.0-TPC-H.png)

TPC-H Benchmark

diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/group-concat.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/group-concat.md index cc870e11a43dc..f2abc73843bf7 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/group-concat.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/group-concat.md @@ -24,25 +24,36 @@ specific language governing permissions and limitations under the License. --> -## GROUP_CONCAT -### description -#### Syntax +## Description -`VARCHAR GROUP_CONCAT([DISTINCT] VARCHAR str[, VARCHAR sep] [ORDER BY { col_name | expr} [ASC | DESC]])` +The GROUP_CONCAT function concatenates multiple rows of results in the result set into a string. +## Syntax -This function is an aggregation function similar to sum (), and group_concat links multiple rows of results in the result set to a string. The second parameter, sep, is a connection symbol between strings, which can be omitted. This function usually needs to be used with group by statements. +```sql +GROUP_CONCAT([DISTINCT] [, ] [ORDER BY { | } [ASC | DESC]]) +``` + +## Parameters -Support Order By for sorting multi-row results, sorting and aggregation columns can be different. +| Parameters | Description | +| ------------ | ---------------------- | +| `` | Required. The expression of the value to be concatenated. | +| `` | Optional. The separator between strings. | +| `` | Optional. The column used for sorting. | +| `` | Optional. The expression used for sorting. | -:::caution -`group_concat` don't support using `distinct` with `order by` together. -::: +## Return Value -### example +Returns a value of type VARCHAR. +## Example + +```sql +select value from test; ``` -mysql> select value from test; + +```text +-------+ | value | +-------+ @@ -51,35 +62,52 @@ mysql> select value from test; | c | | c | +-------+ +``` + +```sql +select GROUP_CONCAT(value) from test; +``` -mysql> select GROUP_CONCAT(value) from test; +```text +-----------------------+ | GROUP_CONCAT(`value`) | +-----------------------+ -| a, b, c, c | +| a, b, c, c | +-----------------------+ +``` -mysql> select GROUP_CONCAT(value, " ") from test; -+----------------------------+ -| GROUP_CONCAT(`value`, ' ') | -+----------------------------+ -| a b c c | -+----------------------------+ +```sql +select GROUP_CONCAT(DISTINCT value) from test; +``` -mysql> select GROUP_CONCAT(DISTINCT value) from test; +```text +-----------------------+ | GROUP_CONCAT(`value`) | +-----------------------+ | a, b, c | +-----------------------+ +``` + +```sql +select GROUP_CONCAT(value, " ") from test; +``` -mysql> select GROUP_CONCAT(value, NULL) from test; +```text +----------------------------+ -| GROUP_CONCAT(`value`, NULL)| +| GROUP_CONCAT(`value`, ' ') | +----------------------------+ -| NULL | +| a b c c | +----------------------------+ ``` -### keywords -GROUP_CONCAT,GROUP,CONCAT +```sql +select GROUP_CONCAT(value, NULL) from test; +``` + +```text ++----------------------------+ +| GROUP_CONCAT(`value`, NULL)| ++----------------------------+ +| NULL | ++----------------------------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/histogram.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/histogram.md index 20246ec319a30..85d211b3380da 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/histogram.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/histogram.md @@ -24,32 +24,52 @@ specific language governing permissions and limitations under the License. --> -## HISTOGRAM -### description -#### Syntax +## Description -`histogram(expr[, INT num_buckets])` +The histogram function is used to describe the distribution of the data. It uses an "equal height" bucking strategy, and divides the data into buckets according to the value of the data. It describes each bucket with some simple data, such as the number of values that fall in the bucket. -The histogram function is used to describe the distribution of the data. It uses an "equal height" bucking strategy, and divides the data into buckets according to the value of the data. It describes each bucket with some simple data, such as the number of values that fall in the bucket. It is mainly used by the optimizer to estimate the range query. +## Alias -The result of the function returns an empty or Json string. +HIST -Parameter description: -- num_buckets:Optional. Limit the number of histogram buckets. The default value is 128. +## Syntax + +```sql +HISTOGRAM([, ]) +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `expr` | The expression that needs to be obtained. | +| `num_buckets` | Optional. Limit the number of histogram buckets. The default value is 128.| -Alias function: `hist(expr[, INT num_buckets])` -### example +## Return Value +Returns a value of JSON type after histogram estimation. Special cases: +- When the parameter is NULL, it returns NULL. + +## Example + +```sql +SELECT histogram(c_float) FROM histogram_test; ``` -MySQL [test]> SELECT histogram(c_float) FROM histogram_test; + +```text +-------------------------------------------------------------------------------------------------------------------------------------+ | histogram(`c_float`) | +-------------------------------------------------------------------------------------------------------------------------------------+ | {"num_buckets":3,"buckets":[{"lower":"0.1","upper":"0.1","count":1,"pre_sum":0,"ndv":1},...]} | +-------------------------------------------------------------------------------------------------------------------------------------+ +``` + +```sql +SELECT histogram(c_string, 2) FROM histogram_test; +``` -MySQL [test]> SELECT histogram(c_string, 2) FROM histogram_test; +```text +-------------------------------------------------------------------------------------------------------------------------------------+ | histogram(`c_string`) | +-------------------------------------------------------------------------------------------------------------------------------------+ @@ -59,7 +79,7 @@ MySQL [test]> SELECT histogram(c_string, 2) FROM histogram_test; Query result description: -``` +```json { "num_buckets": 3, "buckets": [ @@ -88,6 +108,7 @@ Query result description: } ``` +```text Field description: - num_buckets:The number of buckets - buckets:All buckets @@ -98,7 +119,4 @@ Field description: - ndv:The number of different values in the bucket > Total number of histogram elements = number of elements in the last bucket(count) + total number of elements in the previous bucket(pre_sum). - -### keywords - -HISTOGRAM, HIST +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md index 49d6da2d682b0..0a87ce538719f 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/hll-union-agg.md @@ -24,29 +24,36 @@ specific language governing permissions and limitations under the License. --> -## HLL_UNION_AGG -### description -#### Syntax +## Description -`HLL_UNION_AGG(hll)` +The HLL_UNION_AGG function is an aggregate function, which is mainly used to merge multiple HyperLogLog data structures and estimate the approximate value of the combined cardinality. +## Syntax -HLL is an engineering implementation based on HyperLog algorithm, which is used to save the intermediate results of HyperLog calculation process. +```sql +hll_union_agg() +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The HyperLogLog type expression to be calculated | -It can only be used as the value column type of the table and reduce the amount of data through aggregation to achieve the purpose of speeding up the query. +## Return Value -Based on this, we get an estimate with an error of about 1%. The HLL column is generated by other columns or data imported into the data. +Returns the cardinality value of type BIGINT. -When importing, hll_hash function is used to specify which column in data is used to generate HLL column. It is often used to replace count distinct, and to calculate UV quickly in business by combining rollup. +## Example -### example +```sql +select HLL_UNION_AGG(uv_set) from test_uv; ``` -MySQL > select HLL_UNION_AGG(uv_set) from test_uv;; + +```text +-------------------------+ -THE COURT OF JUSTICE OF THE EUROPEAN COMMUNITIES, +| HLL_UNION_AGG(`uv_set`) | +-------------------------+ | 17721 | +-------------------------+ -``` -### keywords -HLL_UNION_AGG,HLL,UNION,AGG +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/intersect-count.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/intersect-count.md index eabb298d94ef7..37ad852316118 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/intersect-count.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/intersect-count.md @@ -22,36 +22,51 @@ specific language governing permissions and limitations under the License. --> -## intersect_count -### description -#### Syntax +## Description -`BITMAP INTERSECT_COUNT(bitmap_column, column_to_filter, filter_values)` -Calculate the intersection of two or more bitmaps -Usage: intersect_count(bitmap_column_to_count, filter_column, filter_values ...) -Example: intersect_count(user_id, event, 'A', 'B', 'C'), meaning find the intersect count of user_id in all A/B/C 3 bitmaps +The INTERSECT_COUNT function is used to calculate the number of intersecting elements of the Bitmap data structure. -### example +## Syntax +```sql +INTERSECT_COUNT(, , ) ``` -MySQL [test_query_qa]> select dt,bitmap_to_string(user_id) from pv_bitmap where dt in (3,4); + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The expression that needs to be obtained. | +| `` | Optional. The dimension column that needs to be filtered. | +| `` | Optional. Different values of the filtering dimension column. | + +## Return Value + +Returns a value of type BIGINT. + +## Example + +```sql +select dt,bitmap_to_string(user_id) from pv_bitmap where dt in (3,4); +``` + +```text +------+-----------------------------+ | dt | bitmap_to_string(`user_id`) | +------+-----------------------------+ -| 4 | 1,2,3 | -| 3 | 1,2,3,4,5 | +| 4 | 1,2,3 | +| 3 | 1,2,3,4,5 | +------+-----------------------------+ -2 rows in set (0.012 sec) +``` + +```sql +select intersect_count(user_id,dt,3,4) from pv_bitmap; +``` -MySQL [test_query_qa]> select intersect_count(user_id,dt,3,4) from pv_bitmap; +```text +----------------------------------------+ | intersect_count(`user_id`, `dt`, 3, 4) | +----------------------------------------+ | 3 | +----------------------------------------+ -1 row in set (0.014 sec) ``` - -### keywords - - INTERSECT_COUNT,BITMAP diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/kurt.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/kurt.md index 430118be26061..8056dd0297a52 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/kurt.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/kurt.md @@ -26,42 +26,66 @@ under the License. ## Description -Returns the [kurtosis](https://en.wikipedia.org/wiki/Kurtosis) of the expr expression. -The forumula used for this function is `4-th centrol moment / ((variance)^2) - 3`, when variance is zero, `kurtosis` will return `NULL`. +The KURTOSIS function returns the [kurtosis](https://en.wikipedia.org/wiki/Kurtosis) of the expr expression. +The forumula used for this function is `4-th centrol moment / ((variance)^2) - 3`. + +## Alias + +KURT_POP,KURTOSIS ## Syntax -`kurtosis(expr)` +```sql +KURTOSIS() +``` -## Arguments +## Parameters -TinyInt/SmallInt/Integer/BigInt/Float/Double, Decimal will be casted to a float number. +| Parameters | Description | +| -- | -- | +| `` | The expression needs to be obtained | -## Return value +## Return Value -`Double` +Returns a value of type DOUBLE. Special cases: +- Returns NULL when the variance is zero. ## Example + ```sql -create table statistic_test(tag int, val1 double not null, val2 double null) distributed by hash(tag) properties("replication_num"="1") +select * from statistic_test; +``` -insert into statistic_test values (1, -10, -10),(2, -20, NULL),(3, 100, NULL),(4, 100, NULL),(5, 1000,1000); +```text ++-----+------+------+ +| tag | val1 | val2 | ++-----+------+------+ +| 1 | -10 | -10| +| 2 | -20 | NULL| +| 3 | 100 | NULL| +| 4 | 100 | NULL| +| 5 | 1000 | 1000| ++-----+------+------+ +``` -// NULL is ignored -select kurt(val1), kurt(val2) from statistic_test --------------- +```sql +select kurt(val1), kurt(val2) from statistic_test; +``` +```text +-------------------+--------------------+ | kurt(val1) | kurt(val2) | +-------------------+--------------------+ | 0.162124583734851 | -1.3330994719286338 | +-------------------+--------------------+ -1 row in set (0.02 sec) +``` +```sql // Each group just has one row, result is NULL -select kurt(val1), kurt(val2) from statistic_test group by tag --------------- +select kurt(val1), kurt(val2) from statistic_test group by tag; +``` +```text +------------+------------+ | kurt(val1) | kurt(val2) | +------------+------------+ @@ -71,9 +95,5 @@ select kurt(val1), kurt(val2) from statistic_test group by tag | NULL | NULL | | NULL | NULL | +------------+------------+ -5 rows in set (0.02 sec) ``` -## Related Commands - -[skew](./skew.md) \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/linear-histogram.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/linear-histogram.md index 939376c357042..db0e37df42104 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/linear-histogram.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/linear-histogram.md @@ -25,28 +25,45 @@ under the License. --> ## Description -### Syntax -`LINEAR_HISTOGRAM(expr, DOUBLE interval[, DOUBLE offset)` +The LINEAR_HISTOGRAM function is used to describe the data distribution. It uses an "equal width" bucking strategy, and divides the data into buckets according to the value of the data. -The linear_histogram function is used to describe the distribution of the data, It uses an "equal width" bucking strategy, and divides the data into buckets according to the value of the data. +## Syntax -Parameter description: +```sql +`LINEAR_HISTOGRAM(, DOUBLE [, DOUBLE )` +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `interval` | Required. The width of the bucket. | +| `offset` | Optional. The default value is 0, and the range is `[0, interval)`. | -- `interval`: Required. The bucket width. -- `offset`: Optional. Default is 0. It should be in `[0, interval)`. +## Return Value + +Returns a value of the computed JSON type. ## Example +```sql +select linear_histogram(a, 2) from histogram_test; ``` -mysql> select linear_histogram(a, 2) from histogram_test; + +```text +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | linear_histogram(a, cast(2 as DOUBLE)) | +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | {"num_buckets":6,"buckets":[{"lower":0.0,"upper":2.0,"count":2,"acc_count":2},{"lower":2.0,"upper":4.0,"count":4,"acc_count":6},{"lower":4.0,"upper":6.0,"count":4,"acc_count":10},{"lower":6.0,"upper":8.0,"count":4,"acc_count":14},{"lower":8.0,"upper":10.0,"count":4,"acc_count":18},{"lower":10.0,"upper":12.0,"count":2,"acc_count":20}]} | +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +``` -mysql> select linear_histogram(a, 2, 1) from histogram_test; +```sql +select linear_histogram(a, 2, 1) from histogram_test; +``` + +```text +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | linear_histogram(a, cast(2 as DOUBLE), cast(1 as DOUBLE)) | +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ @@ -54,6 +71,7 @@ mysql> select linear_histogram(a, 2, 1) from histogram_test; +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ``` +```text Field description: - `num_buckets`: The number of buckets. @@ -62,8 +80,4 @@ Field description: - `upper`: Upper bound of the bucket. (not included) - `count`: The number of elements contained in the bucket. - `acc_count`: Accumulated count. - - -## Keywords - -LINEAR_HISTOGRAM \ No newline at end of file +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/map-agg.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/map-agg.md index b4c5ff616448a..15484436a98f2 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/map-agg.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/map-agg.md @@ -24,18 +24,32 @@ specific language governing permissions and limitations under the License. --> -## MAP_AGG -### description -#### Syntax +## Description -`MAP_AGG(expr1, expr2)` +The MAP_AGG function is used to form a mapping structure based on key-value pairs from multiple rows of data. +## Syntax -Returns a map consists of expr1 as the key and expr2 as the corresponding value. +`MAP_AGG(, )` -### example +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The expression used to specify the key. | +| `` | The expression used to specify the corresponding value. | + +## Return Value + +Returns a value of the MAP type. + +## Example + +```sql +select `n_nationkey`, `n_name`, `n_regionkey` from `nation`; ``` -MySQL > select `n_nationkey`, `n_name`, `n_regionkey` from `nation`; + +```text +-------------+----------------+-------------+ | n_nationkey | n_name | n_regionkey | +-------------+----------------+-------------+ @@ -65,8 +79,13 @@ MySQL > select `n_nationkey`, `n_name`, `n_regionkey` from `nation`; | 23 | UNITED KINGDOM | 3 | | 24 | UNITED STATES | 1 | +-------------+----------------+-------------+ +``` + +```sql +select `n_regionkey`, map_agg(`n_nationkey`, `n_name`) from `nation` group by `n_regionkey`; +``` -MySQL > select `n_regionkey`, map_agg(`n_nationkey`, `n_name`) from `nation` group by `n_regionkey`; +```text +-------------+---------------------------------------------------------------------------+ | n_regionkey | map_agg(`n_nationkey`, `n_name`) | +-------------+---------------------------------------------------------------------------+ @@ -76,8 +95,13 @@ MySQL > select `n_regionkey`, map_agg(`n_nationkey`, `n_name`) from `nation` gro | 4 | {4:"EGYPT", 10:"IRAN", 11:"IRAQ", 13:"JORDAN", 20:"SAUDI ARABIA"} | | 2 | {8:"INDIA", 9:"INDONESIA", 12:"JAPAN", 18:"CHINA", 21:"VIETNAM"} | +-------------+---------------------------------------------------------------------------+ +``` + +```sql +select n_regionkey, map_agg(`n_name`, `n_nationkey` % 5) from `nation` group by `n_regionkey`; +``` -MySQL > select n_regionkey, map_agg(`n_name`, `n_nationkey` % 5) from `nation` group by `n_regionkey`; +```text +-------------+------------------------------------------------------------------------+ | n_regionkey | map_agg(`n_name`, (`n_nationkey` % 5)) | +-------------+------------------------------------------------------------------------+ @@ -88,5 +112,3 @@ MySQL > select n_regionkey, map_agg(`n_name`, `n_nationkey` % 5) from `nation` g | 4 | {"EGYPT":4, "IRAN":0, "IRAQ":1, "JORDAN":3, "SAUDI ARABIA":0} | +-------------+------------------------------------------------------------------------+ ``` -### keywords -MAP_AGG diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/max-by.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/max-by.md index df3096287e92b..26ddb78b30546 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/max-by.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/max-by.md @@ -24,18 +24,34 @@ specific language governing permissions and limitations under the License. --> -## MAX_BY -### description -#### Syntax +## Description -`MAX_BY(expr1, expr2)` +The MAX_BY function is used to return the corresponding associated value based on the maximum value of the specified column. +## Syntax -Returns the value of an expr1 associated with the maximum value of expr2 in a group. +```sql +MAX_BY(, ) +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The expression used to specify the corresponding association. | +| `` | The expression used to specify the maximum value for statistics. | + +## Return Value + +Returns the same data type as the input expression . -### example +## Example + +```sql +select * from tbl; ``` -MySQL > select * from tbl; + +```text +------+------+------+------+ | k1 | k2 | k3 | k4 | +------+------+------+------+ @@ -44,13 +60,16 @@ MySQL > select * from tbl; | 4 | 3 | 2 | 1 | | 3 | 4 | 2 | 1 | +------+------+------+------+ +``` + +```sql +select max_by(k1, k4) from tbl; +``` -MySQL > select max_by(k1, k4) from tbl; +```text +--------------------+ | max_by(`k1`, `k4`) | +--------------------+ | 0 | +--------------------+ ``` -### keywords -MAX_BY diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/max.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/max.md index 68dd6183217c5..4b5d469814a11 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/max.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/max.md @@ -24,23 +24,36 @@ specific language governing permissions and limitations under the License. --> -## MAX -### description -#### Syntax +## Description -`MAX(expr)` +The MAX function returns the maximum value of the expression. +## Syntax -Returns the maximum value of an expr expression +```sql +MAX() +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `expr` | The expression needs to be obtained | + +## Return Value -### example +Returns the same data type as the input expression. + +## Example + +```sql +select max(scan_rows) from log_statis group by datetime; ``` -MySQL > select max(scan_rows) from log_statis group by datetime; + +```text +------------------+ | max(`scan_rows`) | +------------------+ | 4671587 | +------------------+ ``` -### keywords -MAX diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/min-by.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/min-by.md index 52373088a4382..3d08da082367b 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/min-by.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/min-by.md @@ -24,18 +24,34 @@ specific language governing permissions and limitations under the License. --> -## MIN_BY -### description -#### Syntax +## Description -`MIN_BY(expr1, expr2)` +The MIN_BY function is used to return the corresponding associated value based on the minimum value of the specified column. +## Syntax -Returns the value of an expr1 associated with the minimum value of expr2 in a group. +```sql +MIN_BY(, ) +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The expression used to specify the corresponding association. | +| `` | The expression used to specify the minimum value for statistics. | + +## Return Value + +Returns the same data type as the input expression . -### example +## Example + +```sql +select * from tbl; ``` -MySQL > select * from tbl; + +```text +------+------+------+------+ | k1 | k2 | k3 | k4 | +------+------+------+------+ @@ -44,13 +60,16 @@ MySQL > select * from tbl; | 4 | 3 | 2 | 1 | | 3 | 4 | 2 | 1 | +------+------+------+------+ +``` + +```sql +select min_by(k1, k4) from tbl; +``` -MySQL > select min_by(k1, k4) from tbl; +```text +--------------------+ | min_by(`k1`, `k4`) | +--------------------+ | 4 | +--------------------+ ``` -### keywords -MIN_BY diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/min.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/min.md index 76915e2f1f199..4c1fb5425056d 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/min.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/min.md @@ -24,23 +24,36 @@ specific language governing permissions and limitations under the License. --> -## MIN -### Description -#### Syntax +## Description -`MIN(expr)` +The MIN function returns the minimum value of the expression. +## Syntax -Returns the minimum value of an expr expression +```sql +MIN(expr) +``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The expression needs to be obtained | + +## Return Value -### example +Returns the same data type as the input expression. + +## Example + +```sql +select MIN(scan_rows) from log_statis group by datetime; ``` -MySQL > select min(scan_rows) from log_statis group by datetime; + +```text +------------------+ -| min(`scan_rows`) | +| MIN(`scan_rows`) | +------------------+ | 0 | +------------------+ ``` -### keywords -MIN diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md index 3562e3fcd34df..6d40da959f170 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate-count.md @@ -1,7 +1,7 @@ --- { -"title": "ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT", -"language": "en" + "title": "ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT", + "language": "en" } --- @@ -13,7 +13,9 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -22,26 +24,52 @@ specific language governing permissions and limitations under the License. --> -## orthogonal_bitmap_expr_calculate_count -### description -#### Syntax +## Description -`BITMAP ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT(bitmap_column, column_to_filter, input_string)` -Calculate the bitmap intersection, union and difference set of expressions to calculate the count function. The first parameter is the Bitmap column, the second parameter is the dimension column used for filtering, that is, the calculated key column, and the third parameter is the calculation expression string, meaning that the bitmap intersection, union and difference set expression is calculated according to the key column -The calculators supported by the expression:&represents intersection calculation, | represents union calculation, - represents difference calculation, ^ represents XOR calculation, and \ represents escape characters +The ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT function returns the number of elements in the set after performing intersection, union, and difference calculations on the Bitmap expression. -### example +## Syntax +```sql +ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT(, , ) ``` + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The Bitmap type expression needs to be obtained | +| `` | The filtering dimension column, the Key column for calculation | +| `` | The calculation expression string, meaning that the Bitmap intersection, union, and difference set expressions are calculated based on the Key column. The supported operators in the expression: &represents intersection calculation, \| represents union calculation, - represents difference calculation, ^ represents XOR calculation, and \ represents escape characters | + +## Return Value + +Returns a value of type BIGINT. + +## Example + +```sql select orthogonal_bitmap_expr_calculate_count(user_id, tag, '(833736|999777)&(1308083|231207)&(1000|20000-30000)') from user_tag_bitmap where tag in (833736,999777,130808,231207,1000,20000,30000); Note: 1000, 20000, 30000 plastic tags represent different labels of users ``` +```text ++-----------------------------------------------------------------------------------------------------------------+ +| orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(833736|999777)&(1308083|231207)&(1000|20000-30000)') | ++-----------------------------------------------------------------------------------------------------------------+ +| 1000 | ++-----------------------------------------------------------------------------------------------------------------+ ``` + +```sql select orthogonal_bitmap_expr_calculate_count(user_id, tag, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23') from user_str_tag_bitmap where tag in ('A:a/b', 'B:2-4', 'C:1', 'D:12', 'E:23'); Note: 'A:a/b', 'B:2-4', etc. are string types tag, representing different labels of users, where 'B:2-4' needs to be escaped as'B:2\\-4' ``` -### keywords - - ORTHOGONAL_BITMAP_EXPR_CALCULATE_COUNT,BITMAP +```text ++---------------------------------------------------------------------------------------------+ +| orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23') | ++---------------------------------------------------------------------------------------------+ +| 30 | ++---------------------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md index e25c3611cfa0d..e49639b73d069 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-expr-calculate.md @@ -1,7 +1,7 @@ --- { -"title": "ORTHOGONAL_BITMAP_EXPR_CALCULATE", -"language": "en" + "title": "orthogonal_bitmap_expr_calculate", + "language": "en" } --- @@ -13,7 +13,9 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -22,26 +24,52 @@ specific language governing permissions and limitations under the License. --> -## orthogonal_bitmap_expr_calculate -### description -#### Syntax +## Description -`BITMAP ORTHOGONAL_BITMAP_EXPR_CALCULATE(bitmap_column, column_to_filter, input_string)` -The first parameter is the Bitmap column, the second parameter is the dimension column used for filtering, that is, the calculated key column, and the third parameter is the calculation expression string, meaning that the bitmap intersection, union, and difference set expression is calculated according to the key column -The calculators supported by the expression:&represents intersection calculation, | represents union calculation, - represents difference calculation, ^ represents XOR calculation, and \ represents escape characters +The ORTHOGONAL_BITMAP_EXPR_CALCULATE function returns the set obtained after performing intersection, union, and difference calculations on the Bitmap expression. -### example +## Syntax +```sql +ORTHOGONAL_BITMAP_EXPR_CALCULATE(, , ) ``` -select orthogonal_bitmap_expr_calculate(user_id, tag, '(833736|999777)&(1308083|231207)&(1000|20000-30000)') from user_tag_bitmap where tag in (833736,999777,130808,231207,1000,20000,30000); + +## Parameters + +| 参数 | 说明 | +| -- | -- | +| `` | The Bitmap type expression needs to be obtained | +| `` | The filtering dimension column, the Key column for calculation | +| `` | The calculation expression string, meaning that the Bitmap intersection, union, and difference set expressions are calculated based on the Key column. The supported operators in the expression: &represents intersection calculation, \| represents union calculation, - represents difference calculation, ^ represents XOR calculation, and \ represents escape characters | + +## Return Value + +Returns a set of BITMAP type. + +## Example + +```sql +select bitmap_count(orthogonal_bitmap_expr_calculate(user_id, tag, '(833736|999777)&(1308083|231207)&(1000|20000-30000)')) from user_tag_bitmap where tag in (833736,999777,130808,231207,1000,20000,30000); Note: 1000, 20000, 30000 plastic tags represent different labels of users ``` +```text ++-------------------------------------------------------------------------------------------------------------------------------+ +| bitmap_count(orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(833736|999777)&(1308083|231207)&(1000|20000-30000)')) | ++-------------------------------------------------------------------------------------------------------------------------------+ +| 1000 | ++-------------------------------------------------------------------------------------------------------------------------------+ ``` -select orthogonal_bitmap_expr_calculate(user_id, tag, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23') from user_str_tag_bitmap where tag in ('A:a/b', 'B:2-4', 'C:1', 'D:12', 'E:23'); + +```sql +select bitmap_count(orthogonal_bitmap_expr_calculate(user_id, tag, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23')) from user_str_tag_bitmap where tag in ('A:a/b', 'B:2-4', 'C:1', 'D:12', 'E:23'); Note: 'A:a/b', 'B:2-4', etc. are string types tag, representing different labels of users, where 'B:2-4' needs to be escaped as'B:2\\-4' ``` -### keywords - - ORTHOGONAL_BITMAP_EXPR_CALCULATE,BITMAP +```text ++-----------------------------------------------------------------------------------------------------------+ +| bitmap_count(orthogonal_bitmap_expr_calculate_count(`user_id`, `tag`, '(A:a/b|B:2\\-4)&(C:1-D:12)&E:23')) | ++-----------------------------------------------------------------------------------------------------------+ +| 30 | ++-----------------------------------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md index 3884e4f47151f..57f1f722b36cc 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect-count.md @@ -1,7 +1,7 @@ --- { -"title": "ORTHOGONAL_BITMAP_INTERSECT_COUNT", -"language": "en" + "title": "orthogonal_bitmap_intersect_count", + "language": "en" } --- @@ -13,7 +13,9 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -22,25 +24,39 @@ specific language governing permissions and limitations under the License. --> -## orthogonal_bitmap_intersect_count -### description -#### Syntax +## Description + +The ORTHOGONAL_BITMAP_INTERSECT_COUNT function returns the number of elements in the set after performing an intersection calculation on the Bitmap expression. + +## Syntax + +```sql +ORTHOGONAL_BITMAP_INTERSECT_COUNT(, , ) +``` + +## Parameters -`BITMAP ORTHOGONAL_BITMAP_INTERSECT_COUNT(bitmap_column, column_to_filter, filter_values)` -The bitmap intersection count function, the first parameter is the bitmap column, the second parameter is the dimension column for filtering, and the third parameter is the variable length parameter, which means different values of the filter dimension column +| Parameters | Description | +| -- | -- | +| `` | The Bitmap type expression needs to be obtained | +| `` | Optional. The dimension column that needs to be filtered | +| `` | Optional. A variable-length parameter, used to filter different values of the dimension column | -### example +## Return Value + +Returns a value of type BIGINT. + +## Example + +```sql +select orthogonal_bitmap_intersect_count(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); ``` -mysql> select orthogonal_bitmap_intersect_count(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); + +```text +-------------------------------------------------------------------------------------+ | orthogonal_bitmap_intersect_count(`members`, `tag_group`, 1150000, 1150001, 390006) | +-------------------------------------------------------------------------------------+ | 0 | +-------------------------------------------------------------------------------------+ -1 row in set (3.382 sec) -``` - -### keywords - - ORTHOGONAL_BITMAP_INTERSECT_COUNT,BITMAP +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md index c7be4fdcf6e80..bdcbe0b1e39ca 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-intersect.md @@ -1,7 +1,7 @@ --- { -"title": "ORTHOGONAL_BITMAP_INTERSECT", -"language": "en" + "title": "orthogonal_bitmap_intersect", + "language": "en" } --- @@ -13,7 +13,9 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -22,26 +24,39 @@ specific language governing permissions and limitations under the License. --> -## orthogonal_bitmap_intersect -### description -#### Syntax +## Description -`BITMAP ORTHOGONAL_BITMAP_INTERSECT(bitmap_column, column_to_filter, filter_values)` -The bitmap intersection function, the first parameter is the bitmap column, the second parameter is the dimension column for filtering, and the third parameter is the variable length parameter, which means different values of the filter dimension column +The ORTHOGONAL_BITMAP_INTERSECT function returns the intersection set of the Bitmap expression. -### example +## Syntax +```sql +ORTHOGONAL_BITMAP_INTERSECT(, , ) ``` -mysql> select orthogonal_bitmap_intersect(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The Bitmap type expression needs to be obtained | +| `` | Optional. The dimension column that needs to be filtered | +| `` | Optional. A variable-length parameter, used to filter different values of the dimension column | + +## Return Value + +Returns a set of BITMAP type. + +## Example + +```sql +select orthogonal_bitmap_intersect(members, tag_group, 1150000, 1150001, 390006) from tag_map where tag_group in ( 1150000, 1150001, 390006); + +``` + +```text +-------------------------------------------------------------------------------+ | orthogonal_bitmap_intersect(`members`, `tag_group`, 1150000, 1150001, 390006) | +-------------------------------------------------------------------------------+ | NULL | +-------------------------------------------------------------------------------+ -1 row in set (3.505 sec) - -``` - -### keywords - - ORTHOGONAL_BITMAP_INTERSECT,BITMAP +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md index 18d5fc76f1a2e..f234df23dd180 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/orthogonal-bitmap-union-count.md @@ -1,7 +1,7 @@ --- { -"title": "ORTHOGONAL_BITMAP_UNION_COUNT", -"language": "en" + "title": "orthogonal_bitmap_union_count", + "language": "en" } --- @@ -13,7 +13,9 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -22,25 +24,38 @@ specific language governing permissions and limitations under the License. --> -## orthogonal_bitmap_union_count -### description -#### Syntax +## Description -`BITMAP ORTHOGONAL_BITMAP_UNION_COUNT(bitmap_column, column_to_filter, filter_values)` -Figure out the bitmap union count function, syntax with the original bitmap_union_count, but the implementation is different. +The ORTHOGONAL_BITMAP_UNION_COUNT function returns the number of elements in the set after performing a union calculation on the Bitmap expression. -### example +## Syntax +```sql +ORTHOGONAL_BITMAP_UNION_COUNT(, , ) ``` -mysql> select orthogonal_bitmap_union_count(members) from tag_map where tag_group in ( 1150000, 1150001, 390006); + +## Parameters + +| Parameters | Description | +| -- | -- | +| `` | The Bitmap type expression needs to be obtained | +| `` | Optional. The dimension column that needs to be filtered | +| `` | Optional. A variable-length parameter, used to filter different values of the dimension column | + +## Return Value + +Returns a set of BITMAP type. + +## Example + +```sql +select ORTHOGONAL_BITMAP_UNION_COUNT(members) from tag_map where tag_group in ( 1150000, 1150001, 390006); +``` + +```text +------------------------------------------+ | orthogonal_bitmap_union_count(`members`) | +------------------------------------------+ | 286957811 | +------------------------------------------+ -1 row in set (2.645 sec) -``` - -### keywords - - ORTHOGONAL_BITMAP_UNION_COUNT,BITMAP \ No newline at end of file +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile-approx.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile-approx.md index 627ebc09797a1..e0810d31d902e 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile-approx.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile-approx.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,33 +22,73 @@ specific language governing permissions and limitations under the License. --> -## PERCENTILE_APPROX -### Description -#### Syntax +## Description + +The `PERCENTILE_APPROX` function is used to calculate approximate percentiles, primarily for large datasets. Compared to the `PERCENTILE` function, it has the following features: + +1. Memory Efficiency: Uses fixed-size memory, maintaining low memory consumption even when processing high-cardinality columns (large data volumes) +2. Performance Advantage: Suitable for processing large-scale datasets with faster computation +3. Adjustable Precision: Balance between precision and performance through the compression parameter + + +## Syntax + +```sql +PERCENTILE_APPROX(,

[, ]) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The column to calculate percentiles for | +| `

` | Percentile value, range `[0.0, 1.0]`, e.g., `0.99` represents the `99th` percentile | +| `` | Optional parameter, compression level, range `[2048, 10000]`, higher values increase precision but consume more memory. If not specified or out of range, uses `10000` | + +## Return Value -`PERCENTILE_APPROX(expr, DOUBLE p[, DOUBLE compression])` +Returns a `DOUBLE` value representing the calculated approximate percentile. -Return the approximation of the point p, where the value of P is between 0 and 1. +## Examples -Compression param is optional and can be setted to a value in the range of [2048, 10000]. The bigger compression you set, the more precise result and more time cost you will get. If it is not setted or not setted in the correct range, PERCENTILE_APPROX function will run with a default compression param of 10000. +```sql +-- Create sample table +CREATE TABLE response_times ( + request_id INT, + response_time DECIMAL(10, 2) +) DUPLICATE KEY(`request_id`) +DISTRIBUTED BY HASH(`request_id`) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); -This function uses fixed size memory, so less memory can be used for columns with high cardinality, and can be used to calculate statistics such as tp99. +-- Insert sample data +INSERT INTO response_times VALUES +(1, 10.5), +(2, 15.2), +(3, 20.1), +(4, 25.8), +(5, 30.3), +(6, 35.7), +(7, 40.2), +(8, 45.9), +(9, 50.4), +(10, 100.6); -### example +-- Calculate 99th percentile using different compression levels +SELECT + percentile_approx(response_time, 0.99) as p99_default, -- Default compression + percentile_approx(response_time, 0.99, 2048) as p99_fast, -- Lower compression, faster + percentile_approx(response_time, 0.99, 10000) as p99_accurate -- Higher compression, more accurate +FROM response_times; ``` -MySQL > select `table`, percentile_approx(cost_time,0.99) from log_statis group by `table`; -+---------------------+---------------------------+ -| table | percentile_approx(`cost_time`, 0.99) | -+----------+--------------------------------------+ -| test | 54.22 | -+----------+--------------------------------------+ - -MySQL > select `table`, percentile_approx(cost_time,0.99, 4096) from log_statis group by `table`; -+---------------------+---------------------------+ -| table | percentile_approx(`cost_time`, 0.99, 4096.0) | -+----------+--------------------------------------+ -| test | 54.21 | -+----------+--------------------------------------+ + +```text ++-------------------+-------------------+-------------------+ +| p99_default | p99_fast | p99_accurate | ++-------------------+-------------------+-------------------+ +| 100.5999984741211 | 100.5999984741211 | 100.5999984741211 | ++-------------------+-------------------+-------------------+ ``` -### keywords -PERCENTILE_APPROX,PERCENTILE,APPROX + + diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile-array.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile-array.md index 42c697a84e464..70039bda6b239 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile-array.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile-array.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,29 +22,68 @@ specific language governing permissions and limitations under the License. --> -## PERCENTILE_ARRAY -### Description -#### Syntax +## Description + +The `PERCENTILE_ARRAY` function calculates exact percentile arrays, allowing multiple percentile values to be computed at once. This function is primarily suitable for small datasets. -`ARRAY_DOUBLE PERCENTILE_ARRAY(expr, ARRAY_DOUBLE p)` +Key features: +1. Exact Calculation: Provides exact percentile results rather than approximations +2. Batch Processing: Can calculate multiple percentiles in a single operation +3. Scope: Best suited for handling small-scale datasets -Calculate exact percentiles, suitable for small data volumes. Sorts the specified column in descending order first, then takes the exact pth percentile. -The return value is the result of sequentially taking the specified percentages in the array p. -Parameter Description: -expr: Required. Columns whose values are of type integer (up to bigint). -p: The exact percentile is required, an array of constants, taking the value [0.0, 1.0]. -### example +## Syntax + +```sql +PERCENTILE_ARRAY(, ) ``` -mysql> select percentile_array(k1,[0.3,0.5,0.9]) from baseall; -+----------------------------------------------+ -| percentile_array(`k1`, ARRAY(0.3, 0.5, 0.9)) | -+----------------------------------------------+ -| [5.2, 8, 13.6] | -+----------------------------------------------+ -1 row in set (0.02 sec) +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The column to calculate the percentile for | +| `` | Percentile array, each element must be in the range `[0.0, 1.0]`, e.g., `[0.5, 0.95, 0.99]` | + +## Return Value + +Return a `DOUBLE` type array, containing the calculated percentile values. + +## Examples + +```sql +-- Create sample table +CREATE TABLE sales_data ( + id INT, + amount DECIMAL(10, 2) +) DUPLICATE KEY(`id`) +DISTRIBUTED BY HASH(`id`) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- Insert sample data +INSERT INTO sales_data VALUES +(1, 10.5), +(2, 15.2), +(3, 20.1), +(4, 25.8), +(5, 30.3), +(6, 35.7), +(7, 40.2), +(8, 45.9), +(9, 50.4), +(10, 100.6); + +-- Calculate multiple percentiles +SELECT percentile_array(amount, [0.25, 0.5, 0.75, 0.9]) as percentiles +FROM sales_data; ``` -### keywords -PERCENTILE_ARRAY +```text ++-----------------------------------------+ +| percentiles | ++-----------------------------------------+ +| [21.25, 32.5, 43.75, 54.99999999999998] | ++-----------------------------------------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md index ae807db60062e..56aa8965c703f 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/percentile_approx_weighted.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,36 +22,76 @@ specific language governing permissions and limitations under the License. --> -## PERCENTILE_APPROX_WEIGHTED -### description -#### Syntax +## Description + +The `PERCENTILE_APPROX_WEIGHTED` function calculates weighted approximate percentiles, primarily used in scenarios where value importance needs to be considered. It is a weighted version of `PERCENTILE_APPROX`, allowing a weight to be specified for each value. + +Key features: +1. Weight Support: Each value can be assigned a corresponding weight, affecting the final percentile calculation +2. Memory Efficiency: Uses fixed-size memory, suitable for processing large-scale data +3. Adjustable Precision: Balance between precision and performance through the compression parameter + +## Syntax + +```sql +PERCENTILE_APPROX_WEIGHTED(, ,

[, ]) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The column to calculate the percentile for | +| `` | Weight column, must be positive numbers | +| `

` | Percentile value, range `[0.0, 1.0]`, e.g., `0.99` represents the `99`th percentile | +| `` | Optional parameter, compression ratio, range `[2048, 10000]`. The higher the value, the higher the precision, but the greater the memory consumption. If not specified or outside the range, use `10000`. | -`PERCENTILE_APPROX_WEIGHTED(expr, w ,DOUBLE p [, DOUBLE compression])` +## Return Value +Return a `DOUBLE` type value, representing the calculated weighted approximate percentile. -The function is similar to PERCENTILE_APPROX, with the only difference being an additional parameter w, which represents the number of times expr appears. -Note that the value of parameter W needs to be greater than 0. If the value of a row is less than or equal to 0 during the calculation process, the current row will be skipped. +## Examples -### example +```sql +-- Create sample table +CREATE TABLE weighted_scores ( + student_id INT, + score DECIMAL(10, 2), + weight INT +) DUPLICATE KEY(student_id) +DISTRIBUTED BY HASH(student_id) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- Insert example data +INSERT INTO weighted_scores VALUES +(1, 85.5, 1), -- Normal homework score, weight 1 +(2, 90.0, 2), -- Important homework score, weight 2 +(3, 75.5, 1), +(4, 95.5, 3), -- Very important homework, weight 3 +(5, 88.0, 2), +(6, 92.5, 2), +(7, 78.0, 1), +(8, 89.5, 2), +(9, 94.0, 3), +(10, 83.5, 1); + +-- Calculate weighted scores distribution +SELECT + -- Calculate 90th percentile for different compression ratios + percentile_approx_weighted(score, weight, 0.9) as p90_default, -- Default compression ratio + percentile_approx_weighted(score, weight, 0.9, 2048) as p90_fast, -- Lower compression ratio, faster + percentile_approx_weighted(score, weight, 0.9, 10000) as p90_accurate -- Higher compression ratio, more accurate +FROM weighted_scores; ``` -mysql >select * from quantile_weighted_table order by k; -+------+------+ -| k | w | -+------+------+ -| 1 | 2 | -| 3 | 1 | -| 5 | 2 | -+------+------+ - - -mysql >select percentile_approx_weighted(k,w,0.55) from quantile_weighted_table; -+----------------------------------------------------------------------------------------+ -| percentile_approx_weighted(cast(k as DOUBLE), cast(w as DOUBLE), cast(0.55 as DOUBLE)) | -+----------------------------------------------------------------------------------------+ -| 3.3333332538604736 | -+----------------------------------------------------------------------------------------+ +```text ++------------------+------------------+------------------+ +| p90_default | p90_fast | p90_accurate | ++------------------+------------------+------------------+ +| 95.3499984741211 | 95.3499984741211 | 95.3499984741211 | ++------------------+------------------+------------------+ ``` -### keywords -PERCENTILE_APPROX,PERCENTILE,APPROX,PERCENTILE_APPROX_WEIGHTED + diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/quantile-union.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/quantile-union.md index 1eb0e3aee78b5..b70301d9518cf 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/quantile-union.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/quantile-union.md @@ -1,6 +1,6 @@ --- { - "title": "quantile_union", + "title": "QUANTILE_UNION", "language": "en" } --- @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -23,3 +21,73 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## Description + +The `QUANTILE_UNION` function is used to merge intermediate results from multiple quantile calculations. This function typically works in conjunction with `QUANTILE_STATE` and is particularly useful in scenarios requiring multi-stage quantile calculations. + +## Syntax + +```sql +QUANTILE_UNION() +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The intermediate state generated by the `TO_QUANTILE_STATE` function. | + +## Return Value + +Returns an aggregation state that can be used for further quantile calculations. The result of this function remains a `QUANTILE_STATE`. + +## Example + +```sql +-- Create sample table +CREATE TABLE response_times ( + request_id INT, + response_time DOUBLE, + region STRING +) DUPLICATE KEY(request_id) +DISTRIBUTED BY HASH(request_id) BUCKETS AUTO +PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" +); + +-- Insert sample data +INSERT INTO response_times VALUES +(1, 10.5, 'east'), +(2, 15.2, 'east'), +(3, 20.1, 'west'), +(4, 25.8, 'east'), +(5, 30.3, 'west'), +(6, 35.7, 'east'), +(7, 40.2, 'west'), +(8, 45.9, 'east'), +(9, 50.4, 'west'), +(10, 100.6, 'east'); + +-- Calculate 50th percentile of response times by region +SELECT + region, + QUANTILE_PERCENT( + QUANTILE_UNION( + TO_QUANTILE_STATE(response_time, 2048) + ), + 0.5 + ) AS median_response_time +FROM response_times +GROUP BY region; + +``` + +```text ++--------+----------------------+ +| region | median_response_time | ++--------+----------------------+ +| west | 35.25 | +| east | 30.75 | ++--------+----------------------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/retention.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/retention.md index 6f0ea487838aa..043a6ffc8c8b9 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/retention.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/retention.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,118 +22,72 @@ specific language governing permissions and limitations under the License. --> -## RETENTION - -RETENTION - -### Description -#### Syntax - -`retention(event1, event2, ... , eventN);` +## Description The `retention` function takes as arguments a set of conditions from 1 to 32 arguments of type `UInt8` that indicate whether a certain condition was met for the event. Any condition can be specified as an argument. The conditions, except the first, apply in pairs: the result of the second will be true if the first and second are true, of the third if the first and third are true, etc. -To put it simply, the first digit of the return value array indicates whether `event1` is true or false, the second digit represents the truth and falseness of `event1` and `event2`, and the third digit represents whether `event1` is true or false and `event3` is true False and, and so on. If `event1` is false, return an array full of zeros. +To put it simply, the first digit of the return value array indicates whether `event_1` is true or false, the second digit represents the truth and falseness of `event_1` and `event_2`, and the third digit represents whether `event_1` is true or false and `event_3` is true False and, and so on. If `event_1` is false, return an array full of zeros. -#### Arguments +## Syntax -`event` — An expression that returns a `UInt8` result (1 or 0). +```sql +RETENTION( [, , ... , ]); +``` -##### Returned value +## Parameters -An array of 1s and 0s with a maximum length of 32 bits, the final output array has the same length as the input parameter. +| Parameter | Description | +| -- | -- | +| `` | The `n`th event condition, of type `UInt8` and value 1 or 0. | -1 — Condition was met for the event. +## Returned value -0 — Condition wasn’t met for the event. +An array of 1 and 0 with a maximum length of 32, where the final output array length matches the input parameter length. -### example +- 1: Condition is met. +- 0: Condition is not met. -```sql -DROP TABLE IF EXISTS retention_test; +## Examples +```sql +-- Create sample table CREATE TABLE retention_test( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( - "replication_num" = "1" -); - -INSERT into retention_test (uid, date) values (0, '2022-10-12'), - (0, '2022-10-13'), - (0, '2022-10-14'), - (1, '2022-10-12'), - (1, '2022-10-13'), - (2, '2022-10-12'); - -SELECT * from retention_test; - -+------+---------------------+ -| uid | date | -+------+---------------------+ -| 0 | 2022-10-14 00:00:00 | -| 0 | 2022-10-13 00:00:00 | -| 0 | 2022-10-12 00:00:00 | -| 1 | 2022-10-13 00:00:00 | -| 1 | 2022-10-12 00:00:00 | -| 2 | 2022-10-12 00:00:00 | -+------+---------------------+ - + "replication_allocation" = "tag.location.default: 1" +); + +-- Insert sample data +INSERT into retention_test values +(0, '2022-10-12'), +(0, '2022-10-13'), +(0, '2022-10-14'), +(1, '2022-10-12'), +(1, '2022-10-13'), +(2, '2022-10-12'); + +-- Calculate user retention SELECT uid, - retention(date = '2022-10-12') - AS r - FROM retention_test - GROUP BY uid - ORDER BY uid ASC; - -+------+------+ -| uid | r | -+------+------+ -| 0 | [1] | -| 1 | [1] | -| 2 | [1] | -+------+------+ - -SELECT - uid, - retention(date = '2022-10-12', date = '2022-10-13') - AS r - FROM retention_test - GROUP BY uid - ORDER BY uid ASC; - -+------+--------+ -| uid | r | -+------+--------+ -| 0 | [1, 1] | -| 1 | [1, 1] | -| 2 | [1, 0] | -+------+--------+ - -SELECT - uid, - retention(date = '2022-10-12', date = '2022-10-13', date = '2022-10-14') - AS r - FROM retention_test - GROUP BY uid - ORDER BY uid ASC; - -+------+-----------+ -| uid | r | -+------+-----------+ -| 0 | [1, 1, 1] | -| 1 | [1, 1, 0] | -| 2 | [1, 0, 0] | -+------+-----------+ - + RETENTION(date = '2022-10-12') AS r, + RETENTION(date = '2022-10-12', date = '2022-10-13') AS r2, + RETENTION(date = '2022-10-12', date = '2022-10-13', date = '2022-10-14') AS r3 +FROM retention_test +GROUP BY uid +ORDER BY uid ASC; ``` -### keywords - -RETENTION +```text ++------+------+--------+-----------+ +| uid | r | r2 | r3 | ++------+------+--------+-----------+ +| 0 | [1] | [1, 1] | [1, 1, 1] | +| 1 | [1] | [1, 1] | [1, 1, 0] | +| 2 | [1] | [1, 0] | [1, 0, 0] | ++------+------+--------+-----------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sequence-count.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sequence-count.md index 68abb404dcaad..d0a55625aeb96 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sequence-count.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sequence-count.md @@ -1,6 +1,6 @@ --- { - "title": "SEQUENCE-COUNT", + "title": "SEQUENCE_COUNT", "language": "en" } --- @@ -22,11 +22,7 @@ specific language governing permissions and limitations under the License. --> -## SEQUENCE-COUNT -### Description -#### Syntax - -`sequence_count(pattern, timestamp, cond1, cond2, ...);` +## Description Counts the number of event chains that matched the pattern. The function searches event chains that do not overlap. It starts to search for the next chain after the current chain is matched. @@ -34,188 +30,140 @@ Counts the number of event chains that matched the pattern. The function searche Events that occur at the same second may lay in the sequence in an undefined order affecting the result. -#### Arguments +## Syntax + +```sql +SEQUENCE_COUNT(, , [, , ..., ]); +``` + +## Parameters -`pattern` — Pattern string. +| Parameter | Description | +| -- | -- | +| `` | Pattern string, see **Pattern syntax** below. | +| `` | Column considered to contain time data. Typical data types are `Date` and `DateTime`. You can also use any of the supported UInt data types. | +| `` | Conditions that describe the chain of events. Data type: `UInt8`. You can pass up to 32 condition arguments. The function takes only the events described in these conditions into account. If the sequence contains data that isn’t described in a condition, the function skips them. | **Pattern syntax** -`(?N)` — Matches the condition argument at position N. Conditions are numbered in the `[1, 32]` range. For example, `(?1)` matches the argument passed to the `cond1` parameter. - -`.*` — Matches any number of events. You do not need conditional arguments to count this element of the pattern. +- `(?N)` — Matches the condition argument at position N. Conditions are numbered in the `[1, 32]` range. For example, `(?1)` matches the argument passed to the `cond_1` parameter. -`(?t operator value)` — Sets the time in seconds that should separate two events. +- `.*` — Matches any number of events. You do not need conditional arguments to count this element of the pattern. -We define `t` as the difference in seconds between two times, For example, pattern `(?1)(?t>1800)(?2)` matches events that occur more than 1800 seconds from each other. pattern `(?1)(?t>10000)(?2)` matches events that occur more than 10000 seconds from each other. An arbitrary number of any events can lay between these events. You can use the `>=`, `>`, `<`, `<=`, `==` operators. +- `(?t operator value)` — Sets the time in seconds that should separate two events. -`timestamp` — Column considered to contain time data. Typical data types are `Date` and `DateTime`. You can also use any of the supported UInt data types. +- We define `t` as the difference in seconds between two times, For example, pattern `(?1)(?t>1800)(?2)` matches events that occur more than 1800 seconds from each other. pattern `(?1)(?t>10000)(?2)` matches events that occur more than 10000 seconds from each other. An arbitrary number of any events can lay between these events. You can use the `>=`, `>`, `<`, `<=`, `==` operators. -`cond1`, `cond2` — Conditions that describe the chain of events. Data type: `UInt8`. You can pass up to 32 condition arguments. The function takes only the events described in these conditions into account. If the sequence contains data that isn’t described in a condition, the function skips them. -#### Returned value +## Return Value Number of non-overlapping event chains that are matched. -### example +## Examples -**count examples** +**Matching examples** ```sql -DROP TABLE IF EXISTS sequence_count_test2; - -CREATE TABLE sequence_count_test2( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 +-- Create sample table +CREATE TABLE sequence_count_test1( + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_count_test2(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 13:28:02', 2), - (3, '2022-11-02 16:15:01', 1), - (4, '2022-11-02 19:05:04', 2), - (5, '2022-11-02 20:08:44', 3); - -SELECT * FROM sequence_count_test2 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 13:28:02 | 2 | -| 3 | 2022-11-02 16:15:01 | 1 | -| 4 | 2022-11-02 19:05:04 | 2 | -| 5 | 2022-11-02 20:08:44 | 3 | -+------+---------------------+--------+ - -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 3) FROM sequence_count_test2; - -+----------------------------------------------------------------+ -| sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 3) | -+----------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 2) FROM sequence_count_test2; - -+----------------------------------------------------------------+ -| sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 2 | -+----------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?t>=10000)(?2)', date, number = 1, number = 2) FROM sequence_count_test1; +-- Insert sample data +INSERT INTO sequence_count_test1(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 13:28:02', 2), +(3, '2022-11-02 16:15:01', 1), +(4, '2022-11-02 19:05:04', 2), +(5, '2022-11-02 20:08:44', 3); + +-- Query example +SELECT + SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 3) as c1, + SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 2) as c2, + SEQUENCE_COUNT('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) as c3 +FROM sequence_count_test1; +``` -+---------------------------------------------------------------------------+ -| sequence_count('(?1)(?t>=3600)(?2)', `date`, `number` = 1, `number` = 2) | -+---------------------------------------------------------------------------+ -| 2 | -+---------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 1 | 2 | 2 | ++------+------+------+ ``` -**not count examples** +**Non-matching examples** ```sql -DROP TABLE IF EXISTS sequence_count_test1; - -CREATE TABLE sequence_count_test1( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 +-- Create sample table +CREATE TABLE sequence_count_test2( + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_count_test1(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_count_test1 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ - -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 2) FROM sequence_count_test1; - -+----------------------------------------------------------------+ -| sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 0 | -+----------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?2).*', date, number = 1, number = 2) FROM sequence_count_test1; - -+------------------------------------------------------------------+ -| sequence_count('(?1)(?2).*', `date`, `number` = 1, `number` = 2) | -+------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------+ - -SELECT sequence_count('(?1)(?t>3600)(?2)', date, number = 1, number = 7) FROM sequence_count_test1; +-- Insert sample data +INSERT INTO sequence_count_test2(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); + +-- Query example +SELECT + SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 2) as c1, + SEQUENCE_COUNT('(?1)(?2).*', date, number = 1, number = 2) as c2, + SEQUENCE_COUNT('(?1)(?t>3600)(?2)', date, number = 1, number = 7) as c3 +FROM sequence_count_test2; +``` -+--------------------------------------------------------------------------+ -| sequence_count('(?1)(?t>3600)(?2)', `date`, `number` = 1, `number` = 7) | -+--------------------------------------------------------------------------+ -| 0 | -+--------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 0 | 0 | 0 | ++------+------+------+ ``` -**special examples** +**Special examples** ```sql -DROP TABLE IF EXISTS sequence_count_test3; - +-- Create sample table CREATE TABLE sequence_count_test3( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_count_test3(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_count_test3 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ -``` - -Perform the query: +-- Insert sample data +INSERT INTO sequence_count_test3(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); -```sql -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5) FROM sequence_count_test3; +-- Query example +SELECT SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 5) FROM sequence_count_test3; +``` +```text +----------------------------------------------------------------+ | sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 5) | +----------------------------------------------------------------+ @@ -228,8 +176,10 @@ This is a very simple example. The function found the event chain where number 5 Now, perform this query: ```sql -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM sequence_count_test3; +SELECT SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM sequence_count_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 4) | +------------------------------------------------------------------------------+ @@ -240,15 +190,13 @@ SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM The result is kind of confusing. In this case, the function couldn’t find the event chain matching the pattern, because the event for number 4 occurred between 1 and 5. If in the same case we checked the condition for number 6, the sequence would count the pattern. ```sql -SELECT sequence_count('(?1)(?2)', date, number = 1, number = 5, number = 6) FROM sequence_count_test3; +SELECT SEQUENCE_COUNT('(?1)(?2)', date, number = 1, number = 5, number = 6) FROM sequence_count_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_count('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 6) | +------------------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------------------+ ``` - -### keywords - -SEQUENCE_COUNT \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sequence-match.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sequence-match.md index c088fc2e746f2..a36a00a42f737 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sequence-match.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sequence-match.md @@ -22,11 +22,7 @@ specific language governing permissions and limitations under the License. --> -## SEQUENCE-MATCH -### Description -#### Syntax - -`sequence_match(pattern, timestamp, cond1, cond2, ...);` +## Description Checks whether the sequence contains an event chain that matches the pattern. @@ -34,190 +30,135 @@ Checks whether the sequence contains an event chain that matches the pattern. Events that occur at the same second may lay in the sequence in an undefined order affecting the result. -#### Arguments -`pattern` — Pattern string. +## Syntax -**Pattern syntax** +```sql +SEQUENCE_MATCH(, , [, , ..., ]) +``` -`(?N)` — Matches the condition argument at position N. Conditions are numbered in the `[1, 32]` range. For example, `(?1)` matches the argument passed to the `cond1` parameter. +## Parameters -`.*` — Matches any number of events. You do not need conditional arguments to match this element of the pattern. +| Parameter | Description | +| -- | -- | +| `` | Pattern string. See **Pattern syntax** below. | +| `` | Column considered to contain time data. Typical data types are `Date` and `DateTime`. You can also use any of the supported UInt data types. | +| `` | Conditions that describe the chain of events. Data type: `UInt8`. You can pass up to 32 condition arguments. The function takes only the events described in these conditions into account. If the sequence contains data that isn’t described in a condition, the function skips them. | -`(?t operator value)` — Sets the time in seconds that should separate two events. +**Pattern syntax** -We define `t` as the difference in seconds between two times, For example, pattern `(?1)(?t>1800)(?2)` matches events that occur more than 1800 seconds from each other. pattern `(?1)(?t>10000)(?2)` matches events that occur more than 10000 seconds from each other. An arbitrary number of any events can lay between these events. You can use the `>=`, `>`, `<`, `<=`, `==` operators. +- `(?N)` — Matches the condition argument at position N. Conditions are numbered in the `[1, 32]` range. For example, `(?1)` matches the argument passed to the `cond1` parameter. -`timestamp` — Column considered to contain time data. Typical data types are `Date` and `DateTime`. You can also use any of the supported UInt data types. +- `.*` — Matches any number of events. You do not need conditional arguments to match this element of the pattern. -`cond1`, `cond2` — Conditions that describe the chain of events. Data type: `UInt8`. You can pass up to 32 condition arguments. The function takes only the events described in these conditions into account. If the sequence contains data that isn’t described in a condition, the function skips them. +- `(?t operator value)` — Sets the time in seconds that should separate two events. -#### Returned value +- We define `t` as the difference in seconds between two times, For example, pattern `(?1)(?t>1800)(?2)` matches events that occur more than 1800 seconds from each other. pattern `(?1)(?t>10000)(?2)` matches events that occur more than 10000 seconds from each other. An arbitrary number of any events can lay between these events. You can use the `>=`, `>`, `<`, `<=`, `==` operators. -1, if the pattern is matched. +## Return value -0, if the pattern isn’t matched. +1: if the pattern is matched. -### example +0: if the pattern isn’t matched. -**match examples** +## Examples -```sql -DROP TABLE IF EXISTS sequence_match_test1; +**Match examples** +```sql CREATE TABLE sequence_match_test1( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_match_test1(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 13:28:02', 2), - (3, '2022-11-02 16:15:01', 1), - (4, '2022-11-02 19:05:04', 2), - (5, '2022-11-02 20:08:44', 3); - -SELECT * FROM sequence_match_test1 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 13:28:02 | 2 | -| 3 | 2022-11-02 16:15:01 | 1 | -| 4 | 2022-11-02 19:05:04 | 2 | -| 5 | 2022-11-02 20:08:44 | 3 | -+------+---------------------+--------+ +INSERT INTO sequence_match_test1(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 13:28:02', 2), +(3, '2022-11-02 16:15:01', 1), +(4, '2022-11-02 19:05:04', 2), +(5, '2022-11-02 20:08:44', 3); -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 3) FROM sequence_match_test1; -+----------------------------------------------------------------+ -| sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 3) | -+----------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 2) FROM sequence_match_test1; - -+----------------------------------------------------------------+ -| sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) FROM sequence_match_test1; +SELECT +sequence_match('(?1)(?2)', date, number = 1, number = 3) as c1, +sequence_match('(?1)(?2)', date, number = 1, number = 2) as c2, +sequence_match('(?1)(?t>=3600)(?2)', date, number = 1, number = 2) as c3 +FROM sequence_match_test1; +``` -+---------------------------------------------------------------------------+ -| sequence_match('(?1)(?t>=3600)(?2)', `date`, `number` = 1, `number` = 2) | -+---------------------------------------------------------------------------+ -| 1 | -+---------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 1 | 1 | 1 | ++------+------+------+ ``` -**not match examples** +**Not match examples** ```sql -DROP TABLE IF EXISTS sequence_match_test2; - CREATE TABLE sequence_match_test2( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_match_test2(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_match_test2 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ - -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 2) FROM sequence_match_test2; - -+----------------------------------------------------------------+ -| sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 2) | -+----------------------------------------------------------------+ -| 0 | -+----------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?2).*', date, number = 1, number = 2) FROM sequence_match_test2; - -+------------------------------------------------------------------+ -| sequence_match('(?1)(?2).*', `date`, `number` = 1, `number` = 2) | -+------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------+ - -SELECT sequence_match('(?1)(?t>3600)(?2)', date, number = 1, number = 7) FROM sequence_match_test2; +INSERT INTO sequence_match_test2(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); + +SELECT +sequence_match('(?1)(?2)', date, number = 1, number = 2) as c1, +sequence_match('(?1)(?2).*', date, number = 1, number = 2) as c2, +sequence_match('(?1)(?t>3600)(?2)', date, number = 1, number = 7) as c3 +FROM sequence_match_test2; +``` -+--------------------------------------------------------------------------+ -| sequence_match('(?1)(?t>3600)(?2)', `date`, `number` = 1, `number` = 7) | -+--------------------------------------------------------------------------+ -| 0 | -+--------------------------------------------------------------------------+ +```text ++------+------+------+ +| c1 | c2 | c3 | ++------+------+------+ +| 0 | 0 | 0 | ++------+------+------+ ``` -**special examples** +**Special examples** ```sql -DROP TABLE IF EXISTS sequence_match_test3; - CREATE TABLE sequence_match_test3( - `uid` int COMMENT 'user id', - `date` datetime COMMENT 'date time', - `number` int NULL COMMENT 'number' - ) -DUPLICATE KEY(uid) -DISTRIBUTED BY HASH(uid) BUCKETS 3 + `uid` int COMMENT 'user id', + `date` datetime COMMENT 'date time', + `number` int NULL COMMENT 'number' +) DUPLICATE KEY(uid) +DISTRIBUTED BY HASH(uid) BUCKETS AUTO PROPERTIES ( "replication_num" = "1" ); -INSERT INTO sequence_match_test3(uid, date, number) values (1, '2022-11-02 10:41:00', 1), - (2, '2022-11-02 11:41:00', 7), - (3, '2022-11-02 16:15:01', 3), - (4, '2022-11-02 19:05:04', 4), - (5, '2022-11-02 21:24:12', 5); - -SELECT * FROM sequence_match_test3 ORDER BY date; - -+------+---------------------+--------+ -| uid | date | number | -+------+---------------------+--------+ -| 1 | 2022-11-02 10:41:00 | 1 | -| 2 | 2022-11-02 11:41:00 | 7 | -| 3 | 2022-11-02 16:15:01 | 3 | -| 4 | 2022-11-02 19:05:04 | 4 | -| 5 | 2022-11-02 21:24:12 | 5 | -+------+---------------------+--------+ -``` +INSERT INTO sequence_match_test3(uid, date, number) values +(1, '2022-11-02 10:41:00', 1), +(2, '2022-11-02 11:41:00', 7), +(3, '2022-11-02 16:15:01', 3), +(4, '2022-11-02 19:05:04', 4), +(5, '2022-11-02 21:24:12', 5); -Perform the query: - -```sql -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5) FROM sequence_match_test3; +SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5) +FROM sequence_match_test3; +``` +```text +----------------------------------------------------------------+ | sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 5) | +----------------------------------------------------------------+ @@ -230,8 +171,11 @@ This is a very simple example. The function found the event chain where number 5 Now, perform this query: ```sql -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM sequence_match_test3; +SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 4) +FROM sequence_match_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 4) | +------------------------------------------------------------------------------+ @@ -242,15 +186,14 @@ SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 4) FROM The result is kind of confusing. In this case, the function couldn’t find the event chain matching the pattern, because the event for number 4 occurred between 1 and 5. If in the same case we checked the condition for number 6, the sequence would match the pattern. ```sql -SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 6) FROM sequence_match_test3; +SELECT sequence_match('(?1)(?2)', date, number = 1, number = 5, number = 6) +FROM sequence_match_test3; +``` +```text +------------------------------------------------------------------------------+ | sequence_match('(?1)(?2)', `date`, `number` = 1, `number` = 5, `number` = 6) | +------------------------------------------------------------------------------+ | 1 | +------------------------------------------------------------------------------+ ``` - -### keywords - -SEQUENCE_MATCH \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/skew.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/skew.md index 7185ca7f00287..6b05a54dbbeb1 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/skew.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/skew.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,50 +22,79 @@ specific language governing permissions and limitations under the License. --> -## skewness,skew,skew_pop -### Description +## Description Returns the [skewness](https://en.wikipedia.org/wiki/Skewness) of the expr expression. -The forumula used for this function is `3-th centrol moment / ((variance)^{1.5})`, when variance is zero, `skewness` will return `NULL`. +The forumula used for this function is `3-th centrol moment / ((variance)^{1.5})`, when variance is zero, `SKEWNESS` will return `NULL`. -### Syntax +**Related Commands** -`skewness(expr)` +[kurt](./kurt.md) -### Arguments +## Alias -TinyInt/SmallInt/Integer/BigInt/Float/Double, Decimal will be casted to a float number. +- SKEW +- SKEW_POP -### Return value +## Syntax -`Double` - -### Example ```sql -create table statistic_test (tag int, val1 double not null, val2 double null) - distributed by hash(tag) properties("replication_num"="1") +SKEWNESS() +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The column to be calculated skewness | + +## Return Value -insert into statistic_test values (1, -10, -10), - (2, -20, NULL), - (3, 100, NULL), - (4, 100, NULL), - (5, 1000,1000); +Returns the skewness of the expr expression, which is a `Double` type. -// NULL is ignored -select skew(val1), skew(val2) from statistic_test --------------- +## Examples +```sql +CREATE TABLE statistic_test( + tag int, + val1 double not null, + val2 double null +) DISTRIBUTED BY HASH(tag) +PROPERTIES ( + "replication_num"="1" +); + +INSERT INTO statistic_test VALUES +(1, -10, -10), +(2, -20, NULL), +(3, 100, NULL), +(4, 100, NULL), +(5, 1000,1000); + +-- NULL is ignored +SELECT + skew(val1), + skew(val2) +FROM statistic_test; +``` +```text +--------------------+--------------------+ | skew(val1) | skew(val2) | +--------------------+--------------------+ | 1.4337199628825619 | 1.1543940205711711 | +--------------------+--------------------+ -1 row in set (0.01 sec) +``` -// Each group just has one row, result is NULL -select skew(val1), skew(val2) from statistic_test group by tag --------------- +```sql +-- Each group just has one row, result is NULL +SELECT + skew(val1), + skew(val2) +FROM statistic_test +GROUP BY tag; +``` +```text +------------+------------+ | skew(val1) | skew(val2) | +------------+------------+ @@ -77,8 +104,4 @@ select skew(val1), skew(val2) from statistic_test group by tag | NULL | NULL | | NULL | NULL | +------------+------------+ -5 rows in set (0.04 sec) -``` -### Related Commands - -[kurt](./kurt.md) \ No newline at end of file +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/stddev-samp.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/stddev-samp.md index 086c7b4d84113..45be4c6c9c7d5 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/stddev-samp.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/stddev-samp.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,23 +22,54 @@ specific language governing permissions and limitations under the License. --> -## STDDEV_SAMP -### Description -#### Syntax +## Description + +Returns the sample standard deviation of the expr expression -`STDDEV SAMP (expr)` +## Syntax +```sql +STDDEV_SAMP() +``` -Returns the sample standard deviation of the expr expression +## Parameters -### example +| Parameter | Description | +| -- | -- | +| `` | The value to be calculated standard deviation | + +## Return Value + +Return the sample standard deviation of the expr expression + +### Examples +```sql +-- Create sample tables +CREATE TABLE score_table ( + student_id INT, + score DOUBLE +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO score_table VALUES +(1, 85), +(2, 90), +(3, 82), +(4, 88), +(5, 95); + +-- Calculate the sample standard deviation of all students' scores +SELECT STDDEV_SAMP(score) as score_stddev +FROM score_table; ``` -MySQL > select stddev_samp(scan_rows) from log_statis group by datetime; -+--------------------------+ -| stddev_samp(`scan_rows`) | -+--------------------------+ -| 2.372044195280762 | -+--------------------------+ + +```text ++-------------------+ +| score_stddev | ++-------------------+ +| 4.949747468305831 | ++-------------------+ ``` -### keywords -STDDEV SAMP,STDDEV,SAMP diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/stddev.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/stddev.md index d22a6d771792a..f31d41efacf49 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/stddev.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/stddev.md @@ -13,9 +13,7 @@ regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -24,30 +22,58 @@ specific language governing permissions and limitations under the License. --> -## STDDEV,STDDEV_POP -### Description -#### Syntax +## Description -`stddev (expl)` +Returns the standard deviation of the expr expression +## Alias -Returns the standard deviation of the expr expression +- STDDEV_POP + +## Syntax + +```sql +STDDEV() +``` -### example +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The value to be calculated standard deviation | + +## Return Value + +Return the standard deviation of the expr expression + +## Examples +```sql +-- Create sample tables +CREATE TABLE score_table ( + student_id INT, + score DOUBLE +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO score_table VALUES +(1, 85), +(2, 90), +(3, 82), +(4, 88), +(5, 95); + +-- Calculate the standard deviation of all students' scores +SELECT STDDEV(score) as score_stddev +FROM score_table; ``` -MySQL > select stddev(scan_rows) from log_statis group by datetime; -+---------------------+ -| stddev(`scan_rows`) | -+---------------------+ -| 2.3736656687790934 | -+---------------------+ - -MySQL > select stddev_pop(scan_rows) from log_statis group by datetime; -+-------------------------+ -| stddev_pop(`scan_rows`) | -+-------------------------+ -| 2.3722760595994914 | -+-------------------------+ + +```text ++-------------------+ +| score_stddev | ++-------------------+ +| 4.427188724235729 | ++-------------------+ ``` -### keywords -STDDEV,STDDEV_POP,POP diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sum.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sum.md index 10802b4707ae3..669c0dbdd724b 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sum.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sum.md @@ -24,23 +24,55 @@ specific language governing permissions and limitations under the License. --> -## SUM -### Description -#### Syntax +## Description -`Sum (Expr)` +Used to return the sum of all values of the selected field +## Syntax -Used to return the sum of all values of the selected field +```sql +SUM() +``` + +## Parameters + +| Parameter | Description | +| --- | --- | +| `` | The field to calculate the sum of | -### example +## Return Value + +Return the sum of all values of the selected field. + +## Examples +```sql +-- Create sample tables +CREATE TABLE sales_table ( + product_id INT, + price DECIMAL(10,2), + quantity INT +) DISTRIBUTED BY HASH(product_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO sales_table VALUES +(1, 99.99, 2), +(2, 159.99, 1), +(3, 49.99, 5), +(4, 299.99, 1), +(5, 79.99, 3); + +-- Calculate the total sales amount +SELECT SUM(price * quantity) as total_sales +FROM sales_table; ``` -MySQL > select sum(scan_rows) from log_statis group by datetime; -+------------------+ -| sum(`scan_rows`) | -+------------------+ -| 8217360135 | -+------------------+ + +```text ++-------------+ +| total_sales | ++-------------+ +| 1149.88 | ++-------------+ ``` -### keywords -SUM diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sum0.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sum0.md index 745b70b3043c6..adf052f8b98d6 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sum0.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/sum0.md @@ -1,7 +1,6 @@ --- { - "title": "sum0 - ", + "title": "SUM0", "language": "en" } --- @@ -24,3 +23,60 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## Description + +Used to return the sum of all values of the selected field. Unlike the SUM function, when all input values are NULL, SUM0 returns 0 instead of NULL. + +## Syntax + +```sql +SUM0() +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The field to calculate the sum of | + +## Return Value + +Returns the sum of all values of the selected field. If all values are NULL, returns 0. + +## Examples + +```sql +-- Create example table +CREATE TABLE sales_table ( + product_id INT, + price DECIMAL(10,2), + quantity INT, + discount DECIMAL(10,2) +) DISTRIBUTED BY HASH(product_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO sales_table VALUES +(1, 99.99, 2, NULL), +(2, 159.99, 1, NULL), +(3, 49.99, 5, NULL), +(4, 299.99, 1, NULL), +(5, 79.99, 3, NULL); + +-- Compare SUM and SUM0 +SELECT + SUM(discount) as sum_discount, -- Returns NULL + SUM0(discount) as sum0_discount -- Returns 0 +FROM sales_table; +``` + +```text ++--------------+---------------+ +| sum_discount | sum0_discount | ++--------------+---------------+ +| NULL | 0.00 | ++--------------+---------------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn-array.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn-array.md index 0cb0b177a8b31..f3710a434434e 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn-array.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn-array.md @@ -24,38 +24,60 @@ specific language governing permissions and limitations under the License. --> -## TOPN_ARRAY -### description -#### Syntax +## Description -`ARRAY topn_array(expr, INT top_num[, INT space_expand_rate])` +TOPN_ARRAY returns an array of the N most frequent values in the specified column. It is an approximate calculation function that returns results ordered by count in descending order. -The topn function uses the Space-Saving algorithm to calculate the top_num frequent items in expr, -and return an array about the top n nums, which is an approximation +## Syntax -The space_expand_rate parameter is optional and is used to set the number of counters used in the Space-Saving algorithm +```sql +TOPN_ARRAY(, [, ]) ``` -counter numbers = top_num * space_expand_rate -``` -The higher value of space_expand_rate, the more accurate result will be. The default value is 50 -### example +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The column or expression to be counted. | +| `` | The number of the most frequent values to return. It must be a positive integer. | +| `` | Optional parameter, which is used to set the number of counters used in the Space-Saving algorithm. `counter_numbers = top_num * space_expand_rate` , the larger the value of space_expand_rate, the more accurate the result, and the default value is 50. | + +## Return Value + +Return an array containing the N most frequent values. + +## Examples +```sql +-- Create sample table +CREATE TABLE page_visits ( + page_id INT, + user_id INT, + visit_date DATE +) DISTRIBUTED BY HASH(page_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO page_visits VALUES +(1, 101, '2024-01-01'), +(2, 102, '2024-01-01'), +(1, 103, '2024-01-01'), +(3, 101, '2024-01-01'), +(1, 104, '2024-01-01'), +(2, 105, '2024-01-01'), +(1, 106, '2024-01-01'), +(4, 107, '2024-01-01'); + +-- Find top 3 most visited pages +SELECT TOPN_ARRAY(page_id, 3) as top_pages +FROM page_visits; ``` -mysql> select topn_array(k3,3) from baseall; -+--------------------------+ -| topn_array(`k3`, 3) | -+--------------------------+ -| [3021, 2147483647, 5014] | -+--------------------------+ -1 row in set (0.02 sec) - -mysql> select topn_array(k3,3,100) from baseall; -+--------------------------+ -| topn_array(`k3`, 3, 100) | -+--------------------------+ -| [3021, 2147483647, 5014] | -+--------------------------+ -1 row in set (0.02 sec) + +```text ++-----------+ +| top_pages | ++-----------+ +| [1, 2, 4] | ++-----------+ ``` -### keywords -TOPN, TOPN_ARRAY \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn-weighted.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn-weighted.md index 805ba0ac134ca..627abf9ce9ad0 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn-weighted.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn-weighted.md @@ -24,37 +24,61 @@ specific language governing permissions and limitations under the License. --> -## TOPN_WEIGHTED -### description -#### Syntax +## Description -`ARRAY topn_weighted(expr, BigInt weight, INT top_num[, INT space_expand_rate])` +The TOPN_WEIGHTED function returns the N most frequent values in the specified column with weighted counting. Unlike the regular TOPN function, TOPN_WEIGHTED allows adjusting the importance of values through weights. -The topn_weighted function is calculated using the Space-Saving algorithm, and the sum of the weights in expr is the result of the top n numbers, which is an approximate value +## Syntax -The space_expand_rate parameter is optional and is used to set the number of counters used in the Space-Saving algorithm +```sql +TOPN_WEIGHTED(, , [, ]) ``` -counter numbers = top_num * space_expand_rate -``` -The higher value of space_expand_rate, the more accurate result will be. The default value is 50 -### example +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The column or expression to be counted | +| `` | The column or expression to adjust the weight | +| `` | The number of the most frequent values to return. It must be a positive integer. | +| `` | Optional, the value to set the counter_numbers used in the Space-Saving algorithm. `counter_numbers = top_num * space_expand_rate`. The value of space_expand_rate should be greater than 1, and the default value is 50. | + +## Return Value + +Return an array containing values and weighted counts. + +## Examples +```sql +-- create example table +CREATE TABLE product_sales ( + product_id INT, + sale_amount DECIMAL(10,2), + sale_date DATE +) DISTRIBUTED BY HASH(product_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- insert test data +INSERT INTO product_sales VALUES +(1, 100.00, '2024-01-01'), +(2, 50.00, '2024-01-01'), +(1, 150.00, '2024-01-01'), +(3, 75.00, '2024-01-01'), +(1, 200.00, '2024-01-01'), +(2, 80.00, '2024-01-01'), +(1, 120.00, '2024-01-01'), +(4, 90.00, '2024-01-01'); + +-- find the top 3 products with highest sales amount +SELECT TOPN_WEIGHTED(product_id, sale_amount, 3) as top_products +FROM product_sales; ``` -mysql> select topn_weighted(k5,k1,3) from baseall; -+------------------------------+ -| topn_weighted(`k5`, `k1`, 3) | -+------------------------------+ -| [0, 243.325, 100.001] | -+------------------------------+ -1 row in set (0.02 sec) - -mysql> select topn_weighted(k5,k1,3,100) from baseall; -+-----------------------------------+ -| topn_weighted(`k5`, `k1`, 3, 100) | -+-----------------------------------+ -| [0, 243.325, 100.001] | -+-----------------------------------+ -1 row in set (0.02 sec) + +```text ++--------------+ +| top_products | ++--------------+ +| [1, 2, 4] | ++--------------+ ``` -### keywords -TOPN, TOPN_WEIGHTED \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn.md index 8ca8840b44533..eb25148fe58d2 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/topn.md @@ -24,38 +24,59 @@ specific language governing permissions and limitations under the License. --> -## TOPN -### description -#### Syntax +## Description -`topn(expr, INT top_num[, INT space_expand_rate])` +The TOPN function returns the N most frequent values in the specified column. It is an approximate calculation function that returns results ordered by count in descending order. -The topn function uses the Space-Saving algorithm to calculate the top_num frequent items in expr, and the result is the -frequent items and their occurrence times, which is an approximation +## Syntax -The space_expand_rate parameter is optional and is used to set the number of counters used in the Space-Saving algorithm +```sql +TOPN(, [, ]) ``` -counter numbers = top_num * space_expand_rate -``` -The higher value of space_expand_rate, the more accurate result will be. The default value is 50 -### example -``` -MySQL [test]> select topn(keyword,10) from keyword_table where date>= '2020-06-01' and date <= '2020-06-19' ; -+------------------------------------------------------------------------------------------------------------+ -| topn(`keyword`, 10) | -+------------------------------------------------------------------------------------------------------------+ -| a:157, b:138, c:133, d:133, e:131, f:127, g:124, h:122, i:117, k:117 | -+------------------------------------------------------------------------------------------------------------+ - -MySQL [test]> select date,topn(keyword,10,100) from keyword_table where date>= '2020-06-17' and date <= '2020-06-19' group by date; -+------------+-----------------------------------------------------------------------------------------------+ -| date | topn(`keyword`, 10, 100) | -+------------+-----------------------------------------------------------------------------------------------+ -| 2020-06-19 | a:11, b:8, c:8, d:7, e:7, f:7, g:7, h:7, i:7, j:7 | -| 2020-06-18 | a:10, b:8, c:7, f:7, g:7, i:7, k:7, l:7, m:6, d:6 | -| 2020-06-17 | a:9, b:8, c:8, j:8, d:7, e:7, f:7, h:7, i:7, k:7 | -+------------+-----------------------------------------------------------------------------------------------+ +## Parameters +| Parameter | Description | +| -- | -- | +| `` | The column or expression to be counted. | +| `` | The number of the most frequent values to return. It must be a positive integer. | +| `` | Optional parameter, which is used to set the number of counters used in the Space-Saving algorithm. `counter_numbers = top_num * space_expand_rate` , the larger the value of space_expand_rate, the more accurate the result, and the default value is 50. | + +## Return Value + +Returns a JSON string containing values and their corresponding occurrence counts. + +## Examples +```sql +-- Create sample table +CREATE TABLE page_visits ( + page_id INT, + user_id INT, + visit_date DATE +) DISTRIBUTED BY HASH(page_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO page_visits VALUES +(1, 101, '2024-01-01'), +(2, 102, '2024-01-01'), +(1, 103, '2024-01-01'), +(3, 101, '2024-01-01'), +(1, 104, '2024-01-01'), +(2, 105, '2024-01-01'), +(1, 106, '2024-01-01'), +(4, 107, '2024-01-01'); + +-- Find top 3 most visited pages +SELECT TOPN(page_id, 3) as top_pages +FROM page_visits; ``` -### keywords -TOPN \ No newline at end of file + +```text ++---------------------+ +| top_pages | ++---------------------+ +| {"1":4,"2":2,"4":1} | ++---------------------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/var-samp.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/var-samp.md index 8fe7ad5a39f7e..40b7abfae8dd0 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/var-samp.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/var-samp.md @@ -1,6 +1,6 @@ --- { - "title": "VARIANCE_SAMP,VARIANCE_SAMP", + "title": "VAR_SAMP,VARIANCE_SAMP", "language": "en" } --- @@ -24,23 +24,62 @@ specific language governing permissions and limitations under the License. --> -## VARIANCE_SAMP,VARIANCE_SAMP -### Description -#### Syntax +## Description -`VAR SAMP (expr)` +The VAR_SAMP function calculates the sample variance of a specified expression. Unlike VARIANCE (population variance), VAR_SAMP uses n-1 as the divisor, which is considered an unbiased estimate of the population variance in statistics. +## Alias -Returns the sample variance of the expr expression +- VARIANCE_SAMP -### example +## Syntax + +```sql +VAR_SAMP() ``` -MySQL > select var_samp(scan_rows) from log_statis group by datetime; -+-----------------------+ -| var_samp(`scan_rows`) | -+-----------------------+ -| 5.6227132145741789 | -+-----------------------+ + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | The column or expression to calculate sample variance for. Must be numeric type | + +## Return Value +Returns a DOUBLE value representing the calculated sample variance. + +## Examples +```sql +-- Create sample table +CREATE TABLE student_scores ( + student_id INT, + score DECIMAL(4,1) +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO student_scores VALUES +(1, 85.5), +(2, 92.0), +(3, 78.5), +(4, 88.0), +(5, 95.5), +(6, 82.0), +(7, 90.0), +(8, 87.5); + +-- Calculate sample variance of student scores +SELECT + VAR_SAMP(score) as sample_variance, + VARIANCE(score) as population_variance +FROM student_scores; +``` + +```text ++------------------+---------------------+ +| sample_variance | population_variance | ++------------------+---------------------+ +| 29.4107142857143 | 25.73437500000001 | ++------------------+---------------------+ ``` -### keywords -VAR SAMP, VARIANCE SAMP,VAR,SAMP,VARIANCE diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/variance.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/variance.md index f58da61bf708f..5e43d59eddfd8 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/variance.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/variance.md @@ -24,30 +24,59 @@ specific language governing permissions and limitations under the License. --> -## VARIANCE,VAR_POP,VARIANCE_POP -### Description -#### Syntax +## Description -`VARIANCE(expr)` +The VARIANCE function calculates the statistical variance of the specified expression. It measures how far a set of numbers are spread out from their arithmetic mean. +## Alias -Returns the variance of the expr expression +- VAR_POP +- VARIANCE_POP -### example +## Syntax + +```sql +VARIANCE() ``` -MySQL > select variance(scan_rows) from log_statis group by datetime; -+-----------------------+ -| variance(`scan_rows`) | -+-----------------------+ -| 5.6183332881176211 | -+-----------------------+ - -MySQL > select var_pop(scan_rows) from log_statis group by datetime; -+----------------------+ -| var_pop(`scan_rows`) | -+----------------------+ -| 5.6230744719006163 | -+----------------------+ + +## Parameters +| Parameter | Description | +| -- | -- | +| `` | The column or expression to calculate variance for. Must be numeric type | + +## Return Value +Returns a DOUBLE value representing the calculated variance. + +## Examples +```sql +-- Create sample table +CREATE TABLE student_scores ( + student_id INT, + score DECIMAL(4,1) +) DISTRIBUTED BY HASH(student_id) +PROPERTIES ( + "replication_num" = "1" +); + +-- Insert test data +INSERT INTO student_scores VALUES +(1, 85.5), +(2, 92.0), +(3, 78.5), +(4, 88.0), +(5, 95.5), +(6, 82.0), +(7, 90.0), +(8, 87.5); +-- Calculate variance of student scores +SELECT VARIANCE(score) as score_variance +FROM student_scores; +``` + +```text ++-------------------+ +| score_variance | ++-------------------+ +| 25.73437499999998 | ++-------------------+ ``` -### keywords -VARIANCE,VAR_POP,VARIANCE_POP,VAR,POP diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/window-funnel.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/window-funnel.md index 47d440b958049..4e4e361e72f37 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/window-funnel.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/window-funnel.md @@ -11,19 +11,9 @@ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> -## WINDOW FUNCTION WINDOW_FUNNEL -### description +## Description -Searches for event chains in a sliding time window and calculates the maximum number of events that occurred from the chain. - -- window is the length of time window in seconds. -- mode can be one of the followings: - - "default": Defualt mode. - - "deduplication": If the same event holds for the sequence of events, then such repeating event interrupts further processing. E.g. the array parameter is [event1='A', event2='B', event3='C', event4='D'], and the original event chain is "A-B-C-B-D". Since event B repeats, the filtered event chain can only be "A-B-C" and the max event level is 3. - - "fixed": Don't allow interventions of other events. E.g. the array parameter is [event1='A', event2='B', event3='C', event4='D'], and the original event chain is A->B->D->C, it stops finding A->B->C at the D and the max event level is 2. - - "increase": Apply conditions only to events with strictly increasing timestamps. -- timestamp_column specifies column of DATETIME type, sliding time window works on it. -- evnetN is boolean expression like eventID = 1004. +The WINDOW_FUNNEL function analyzes user behavior sequences by searching for event chains within a specified time window and calculating the maximum number of completed steps in the event chain. This function is particularly useful for conversion funnel analysis, such as analyzing user conversion from website visits to final purchases. The function works according to the algorithm: @@ -31,15 +21,35 @@ The function works according to the algorithm: - If events from the chain occur sequentially within the window, the counter is incremented. If the sequence of events is disrupted, the counter is not incremented. - If the data has multiple event chains at varying points of completion, the function will only output the size of the longest chain. +## Syntax + ```sql -window_funnel(window, mode, timestamp_column, event1, event2, ... , eventN) +WINDOW_FUNNEL(, , , [, event_2, ... , event_n]) ``` -### example +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | window is the length of time window in seconds | +| `` | There are four modes in total, `default`, `deduplication`, `fixed`, and `increase`. For details, please refer to the **Mode** below. | +| `` | timestamp specifies column of DATETIME type, sliding time window works on it | +| `` | evnet_n is boolean expression like eventID = 1004 | + +**Mode** + - `default`: Defualt mode. + - `deduplication`: If the same event holds for the sequence of events, then such repeating event interrupts further processing. E.g. the array parameter is [event1='A', event2='B', event3='C', event4='D'], and the original event chain is "A-B-C-B-D". Since event B repeats, the filtered event chain can only be "A-B-C" and the max event level is 3. + - `fixed`: Don't allow interventions of other events. E.g. the array parameter is [event1='A', event2='B', event3='C', event4='D'], and the original event chain is A->B->D->C, it stops finding A->B->C at the D and the max event level is 2. + - `increase`: Apply conditions only to events with strictly increasing timestamps. -#### example1: default mode +## Return Value +Returns an integer representing the maximum number of consecutive steps completed within the specified time window. -Using the ```default``` mode, find out the maximum number of consecutive events corresponding to different ```user_id```, with a time window of ```5``` minutes: +## Examples + +### example1: default mode + +Using the `default` mode, find out the maximum number of consecutive events corresponding to different `user_id`, with a time window of `5` minutes: ```sql CREATE TABLE events( @@ -82,7 +92,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -93,11 +105,11 @@ order BY +---------+-------+ ``` -For ```uesr_id=100123```, because the time when the ```payment``` event occurred exceeds the time window, the matched event chain is ```login-visit-order```. +For `uesr_id=100123`, because the time when the `payment` event occurred exceeds the time window, the matched event chain is `login-visit-order`. -#### example2: deduplication mode +### example2: deduplication mode -Use the ```deduplication``` mode to find out the maximum number of consecutive events corresponding to different user_ids, with a time window of 1 hour: +Use the `deduplication` mode to find out the maximum number of consecutive events corresponding to different user_ids, with a time window of 1 hour: ```sql CREATE TABLE events( @@ -141,7 +153,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -151,11 +165,11 @@ order BY | 100127 | 2 | +---------+-------+ ``` -For ```uesr_id=100123```, after matching the ```visit``` event, the ```login``` event appears repeatedly, so the matched event chain is ```login-visit```. +For `uesr_id=100123`, after matching the `visit` event, the `login` event appears repeatedly, so the matched event chain is `login-visit`. -#### example3: fixed mode +### example3: fixed mode -Use the ```fixed``` mode to find out the maximum number of consecutive events corresponding to different ```user_id```, with a time window of ```1``` hour: +Use the `fixed` mode to find out the maximum number of consecutive events corresponding to different `user_id`, with a time window of `1` hour: ```sql CREATE TABLE events( @@ -199,7 +213,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -209,11 +225,11 @@ order BY | 100127 | 2 | +---------+-------+ ``` -For ```uesr_id=100123```, after matching the ```order``` event, the event chain is interrupted by the ```login2``` event, so the matched event chain is ```login-visit-order```. +For `uesr_id=100123`, after matching the `order` event, the event chain is interrupted by the `login2` event, so the matched event chain is `login-visit-order`. -#### example4: increase mode +### example4: increase mode -Use the ```increase``` mode to find out the maximum number of consecutive events corresponding to different ```user_id```, with a time window of ```1``` hour: +Use the `increase` mode to find out the maximum number of consecutive events corresponding to different `user_id`, with a time window of `1` hour: ```sql CREATE TABLE events( @@ -256,7 +272,9 @@ GROUP BY user_id order BY user_id; +``` +```text +---------+-------+ | user_id | level | +---------+-------+ @@ -266,9 +284,4 @@ order BY | 100127 | 2 | +---------+-------+ ``` -For ```uesr_id=100123```, the timestamp of the ```payment``` event and the timestamp of the ```order``` event occur in the same second and are not incremented, so the matched event chain is ```login-visit-order```. - - -### keywords - - WINDOW,FUNCTION,WINDOW_FUNNEL +For `uesr_id=100123`, the timestamp of the `payment` event and the timestamp of the `order` event occur in the same second and are not incremented, so the matched event chain is `login-visit-order`. diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md index ddd3ee704c4b1..9863806bac137 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-add.md @@ -24,27 +24,37 @@ specific language governing permissions and limitations under the License. --> -## hours_add -### description -#### Syntax +## Description -`DATETIME HOURS_ADD(DATETIME date, INT hours)` +Returns a new datetime value that is the result of adding a specified number of hours to the input datetime. -Add specified hours from date time or date +## Syntax -The parameter date can be DATETIME or DATE, and the return type is DATETIME. +```sql +HOURS_ADD(, ) +``` -### example +## Parameters -``` -mysql> select hours_add("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| hours_add('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-02-02 03:02:02 | -+-------------------------------------+ -``` +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATETIME or DATE | +| `` | The number of hours to add, of type INT | + +## Return Value -### keywords +Returns a value of type DATETIME, representing the time value after adding the specified number of hours to the input datetime. - HOURS_ADD +## Example + +```sql +SELECT HOURS_ADD('2020-02-02 02:02:02', 1); +``` + +```text ++------------------------------------------------------------+ +| hours_add(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), 1) | ++------------------------------------------------------------+ +| 2020-02-02 03:02:02 | ++------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md index f299f8d15c6d8..78e690f7bf8ea 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-diff.md @@ -24,25 +24,37 @@ specific language governing permissions and limitations under the License. --> -## hours_diff -### description -#### Syntax +## Description -`INT hours_diff(DATETIME enddate, DATETIME startdate)` +Calculates the difference in hours between the start time and the end time. -The difference between the start time and the end time is a few hours +## Syntax -### example - -``` -mysql> select hours_diff('2020-12-25 22:00:00','2020-12-25 21:00:00'); -+----------------------------------------------------------+ -| hours_diff('2020-12-25 22:00:00', '2020-12-25 21:00:00') | -+----------------------------------------------------------+ -| 1 | -+----------------------------------------------------------+ +```sql +HOURS_DIFF(, ) ``` -### keywords +## Parameters + +| Parameter | Description | +|------------|-------------------------------------------------| +| `` | The end time, which can be of type DATETIME or DATE | +| `` | The start time, which can be of type DATETIME or DATE | + +## Return Value + +Returns an INT type representing the number of hours between the start time and the end time. + +## Example + +```sql +SELECT HOURS_DIFF('2020-12-25 22:00:00', '2020-12-25 21:00:00'); +``` - hours_diff +```text ++--------------------------------------------------------------------------------------------------------+ +| hours_diff(cast('2020-12-25 22:00:00' as DATETIMEV2(0)), cast('2020-12-25 21:00:00' as DATETIMEV2(0))) | ++--------------------------------------------------------------------------------------------------------+ +| 1 | ++--------------------------------------------------------------------------------------------------------+ +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md index 7bb2ba1f75d0b..234d0c5ef41cd 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/hours-sub.md @@ -24,27 +24,37 @@ specific language governing permissions and limitations under the License. --> -## hours_sub -### description -#### Syntax +## Description -`DATETIME HOURS_SUB(DATETIME date, INT hours)` +Returns a new datetime value that is the result of subtracting a specified number of hours from the input datetime. -Subtracts a specified number of hours from a datetime or date +## Syntax -The parameter date can be DATETIME or DATE, and the return type is DATETIME. +```sql +HOURS_SUB(, ) +``` -### example +## Parameters -``` -mysql> select hours_sub("2020-02-02 02:02:02", 1); -+-------------------------------------+ -| hours_sub('2020-02-02 02:02:02', 1) | -+-------------------------------------+ -| 2020-02-02 01:02:02 | -+-------------------------------------+ -``` +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATETIME or DATE | +| `` | The number of hours to subtract, of type INT | + +## Return Value -### keywords +Returns a value of type DATETIME, representing the time value after subtracting the specified number of hours from the input datetime. - HOURS_SUB +## Example + +```sql +SELECT HOURS_SUB('2020-02-02 02:02:02', 1); +``` + +```text ++------------------------------------------------------------+ +| hours_sub(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), 1) | ++------------------------------------------------------------+ +| 2020-02-02 01:02:02 | ++------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md index 0eb3956f4bb84..6e2dc10cf0e09 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/last-day.md @@ -22,28 +22,40 @@ specific language governing permissions and limitations under the License. --> -## last_day -### Description -#### Syntax +## Description -`DATE last_day(DATETIME date)` +Returns the date of the last day of the month for the given input date. The returned day varies depending on the month: +- 28th - For February in non-leap years +- 29th - For February in leap years +- 30th - For April, June, September, and November +- 31st - For January, March, May, July, August, October, and December -Return the last day of the month, the return day may be : -'28'(February and not a leap year), -'29'(February and a leap year), -'30'(April, June, September, November), -'31'(January, March, May, July, August, October, December) - -### example +## Syntax +```sql +LAST_DAY() ``` -mysql > select last_day('2000-02-03'); -+-------------------+ -| last_day('2000-02-03 00:00:00') | -+-------------------+ -| 2000-02-29 | -+-------------------+ + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | Input datetime value, type can be DATETIME or DATE | + +## Return Value + +Returns a value of type DATE representing the last day of the month for the given input date. + +## Example + +```sql +SELECT LAST_DAY('2000-02-03'); ``` -### keywords - LAST_DAY,DAYS +```text ++-----------------------------------------------+ +| last_day(cast('2000-02-03' as DATETIMEV2(0))) | ++-----------------------------------------------+ +| 2000-02-29 | ++-----------------------------------------------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md index 83b091409d934..19461f14de550 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/makedate.md @@ -24,22 +24,42 @@ specific language governing permissions and limitations under the License. --> -## makedate -### Description -#### Syntax -`DATE MAKEDATE(INT year, INT dayofyear)` +## Description -Returns a date, given year and day-of-year values. dayofyear must be greater than 0 or the result is NULL. +Returns a date based on the specified year and the day of the year (dayofyear). -### example +Special cases: +- Returns NULL when `dayofyear` is less than or equal to 0. +- Automatically rolls over to the next year if `dayofyear` exceeds the number of days in the year. + +## Syntax + +```sql +MAKEDATE(, ) +``` + +## Parameters + +| Parameter | Description | +|-------------|-------------------------------------------| +| `` | The specified year, of type INT | +| `` | The day of the year (1-366), of type INT | + +## Return Value + +Returns a value of type DATE, constructed from the specified year and the given day of the year. + +## Example + +```sql +SELECT MAKEDATE(2021, 1), MAKEDATE(2021, 100), MAKEDATE(2021, 400); ``` -mysql> select makedate(2021,1), makedate(2021,100), makedate(2021,400); + +```text +-------------------+---------------------+---------------------+ | makedate(2021, 1) | makedate(2021, 100) | makedate(2021, 400) | +-------------------+---------------------+---------------------+ | 2021-01-01 | 2021-04-10 | 2022-02-04 | +-------------------+---------------------+---------------------+ ``` -### keywords - MAKEDATE diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md index a99ad0b4c8e33..2a5191e01cb5e 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microsecond.md @@ -24,25 +24,37 @@ specific language governing permissions and limitations under the License. --> -## microsecond -### description -#### Syntax -`INT MICROSECOND(DATETIMEV2 date)` +## Description -Returns microsecond information in the time type. +Extracts the microsecond part from a datetime value. The returned range is from 0 to 999999. -The parameter is Datetime type +## Syntax -### example +```sql +MICROSECOND() +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, of type DATETIMEV2, with a precision greater than 0 | + +## Return Value +Returns an INT type representing the microsecond part of the datetime value. The range is from 0 to 999999. For inputs with a precision less than 6, the missing digits are padded with zeros. + +## Example + +```sql +SELECT MICROSECOND(CAST('1999-01-02 10:11:12.000123' AS DATETIMEV2(6))) AS microsecond; ``` -mysql> select microsecond(cast('1999-01-02 10:11:12.000123' as datetimev2(6))) as microsecond; + +```text +-------------+ | microsecond | +-------------+ | 123 | +-------------+ ``` -### keywords - MICROSECOND diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md index 106e015dfa70d..f0fef6608c18e 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-add.md @@ -24,27 +24,42 @@ specific language governing permissions and limitations under the License. --> -## microseconds_add -### description -#### Syntax -`DATETIMEV2 microseconds_add(DATETIMEV2 basetime, INT delta)` -- basetime: Base time whose type is DATETIMEV2 -- delta: Microseconds to add to basetime -- Return type of this function is DATETIMEV2 +## Description -### example +Adds a specified number of microseconds to a datetime value and returns a new datetime value. + +## Syntax + +```sql +MICROSECONDS_ADD(, ) ``` -mysql> select now(3), microseconds_add(now(3), 100000); -+-------------------------+----------------------------------+ -| now(3) | microseconds_add(now(3), 100000) | -+-------------------------+----------------------------------+ -| 2023-02-21 11:35:56.556 | 2023-02-21 11:35:56.656 | -+-------------------------+----------------------------------+ + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, of type DATETIMEV2 | +| `` | The number of microseconds to add, of type INT; 1 second = 1,000,000 microseconds | + +## Return Value + +Returns a value of type DATETIMEV2, representing the time value after adding the specified number of microseconds to the input datetime. The precision of the return value is the same as that of the input parameter basetime. + +## Example + +```sql +SELECT NOW(3) AS current_time, MICROSECONDS_ADD(NOW(3), 100000) AS after_add; ``` -`now(3)` returns current time as type DATETIMEV2 with precision 3d,`microseconds_add(now(3), 100000)` means 100000 microseconds after current time -### keywords - microseconds_add +```text ++-------------------------+----------------------------+ +| current_time | after_add | ++-------------------------+----------------------------+ +| 2025-01-16 11:48:10.505 | 2025-01-16 11:48:10.605000 | ++-------------------------+----------------------------+ +``` - \ No newline at end of file +**Note:** +- `NOW(3)` returns the current time with a precision of 3 decimal places. +- After adding 100000 microseconds (0.1 seconds), the time increases by 0.1 seconds. diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md index 7a48fc117b59c..04254f2cd54d0 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-diff.md @@ -24,26 +24,41 @@ specific language governing permissions and limitations under the License. --> -## microseconds_diff -### description -#### Syntax -`INT microseconds_diff(DATETIME enddate, DATETIME startdate)` +## Description -How many microseconds is the difference between the start time and the end time. +Calculates the microsecond difference between two datetime values. The result is the number of microseconds from `` subtracted from ``. -### example +## Syntax +```sql +MICROSECONDS_DIFF(, ) ``` -mysql> select microseconds_diff('2020-12-25 21:00:00.623000','2020-12-25 21:00:00.123000'); + +## Parameters + +| Parameter | Description | +|------------|-------------------------------------------------| +| `` | The end time, of type DATETIMEV2 | +| `` | The start time, of type DATETIMEV2 | + +## Return Value + +Returns an INT type representing the microsecond difference between the two times. +- Returns a positive number if `` is greater than ``. +- Returns a negative number if `` is less than ``. +- 1 second = 1,000,000 microseconds. + +## Example + +```sql +SELECT MICROSECONDS_DIFF('2020-12-25 21:00:00.623000', '2020-12-25 21:00:00.123000'); +``` + +```text +-----------------------------------------------------------------------------------------------------------------------------+ -| microseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(6)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(6))) | +| microseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(3)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(3))) | +-----------------------------------------------------------------------------------------------------------------------------+ | 500000 | +-----------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.12 sec) ``` - -### keywords - - microseconds_diff diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md index 439bc2a37429b..c7a61d509bce4 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/microseconds-sub.md @@ -24,25 +24,43 @@ specific language governing permissions and limitations under the License. --> -## microseconds_sub -### description -#### Syntax -`DATETIMEV2 microseconds_sub(DATETIMEV2 basetime, INT delta)` -- basetime: Base time whose type is DATETIMEV2 -- delta: Microseconds to subtract from basetime -- Return type of this function is DATETIMEV2 +## Description -### example +Subtracts a specified number of microseconds from a datetime value and returns a new datetime value. + +## Syntax + +```sql +MICROSECONDS_SUB(, ) +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, of type DATETIMEV2 | +| `` | The number of microseconds to subtract, of type INT; 1 second = 1,000,000 microseconds | + +## Return Value + +Returns a value of type DATETIMEV2, representing the time value after subtracting the specified number of microseconds from the input datetime. The precision of the return value is the same as that of the input parameter basetime. + +## Example + +```sql +SELECT NOW(3) AS current_time, MICROSECONDS_SUB(NOW(3), 100000) AS after_sub; ``` -mysql> select now(3), microseconds_sub(now(3), 100000); -+-------------------------+----------------------------------+ -| now(3) | microseconds_sub(now(3), 100000) | -+-------------------------+----------------------------------+ -| 2023-02-25 02:03:05.174 | 2023-02-25 02:03:05.074 | -+-------------------------+----------------------------------+ + +```text ++-------------------------+----------------------------+ +| current_time | after_sub | ++-------------------------+----------------------------+ +| 2025-01-16 11:52:22.296 | 2025-01-16 11:52:22.196000 | ++-------------------------+----------------------------+ ``` -`now(3)` returns current time as type DATETIMEV2 with precision `3`,`microseconds_sub(now(3), 100000)` means 100000 microseconds before current time -### keywords - microseconds_sub +**Note:** +- `NOW(3)` returns the current time with a precision of 3 decimal places. +- After subtracting 100000 microseconds (0.1 seconds), the time decreases by 0.1 seconds. +- The function's result is dependent on the precision of the input time. diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md index 4d2c2f27d2221..bdd66319310ce 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-add.md @@ -24,28 +24,43 @@ specific language governing permissions and limitations under the License. --> -## milliseconds_add -### description -#### Syntax -`DATETIMEV2 milliseconds_add(DATETIMEV2 basetime, INT delta)` -- basetime: Base time whose type is DATETIMEV2 -- delta:Milliseconds to add to basetime -- Return type of this function is DATETIMEV2 +## Description -### example +Adds a specified number of milliseconds to a datetime value and returns a new datetime value. + +## Syntax + +```sql +MILLISECONDS_ADD(, ) +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, of type DATETIMEV2 | +| `` | The number of milliseconds to add, of type INT; 1 second = 1,000 milliseconds = 1,000,000 microseconds | + +## Return Value + +Returns a value of type DATETIMEV2, representing the time value after adding the specified number of milliseconds to the input datetime. The precision of the return value is the same as that of the input parameter basetime. + +## Example + +```sql +SELECT MILLISECONDS_ADD('2023-09-08 16:02:08.435123', 1); ``` -mysql> select milliseconds_add('2023-09-08 16:02:08.435123', 1); + +```text +--------------------------------------------------------------------------+ | milliseconds_add(cast('2023-09-08 16:02:08.435123' as DATETIMEV2(6)), 1) | +--------------------------------------------------------------------------+ | 2023-09-08 16:02:08.436123 | +--------------------------------------------------------------------------+ -1 row in set (0.04 sec) ``` - -### keywords - milliseconds_add - - \ No newline at end of file +**Note:** +- In the example, after adding 1 millisecond, the time increases from .435123 to .436123. +- 1 millisecond equals 1000 microseconds. +- The function's result is dependent on the precision of the input time; the example uses a precision of 6 decimal places. diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md index 94f4b678e3a47..071bf8fac6e77 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-diff.md @@ -24,26 +24,47 @@ specific language governing permissions and limitations under the License. --> -## milliseconds_diff -### description -#### Syntax -`INT milliseconds_diff(DATETIME enddate, DATETIME startdate)` +## Description -How many milliseconds is the difference between the start time and the end time? +Calculates the millisecond difference between two datetime values. The result is the number of milliseconds from `` subtracted from ``. -### example +## Syntax +```sql +MILLISECONDS_DIFF(, ) ``` -mysql> select milliseconds_diff('2020-12-25 21:00:00.623000','2020-12-25 21:00:00.123000'); + +## Parameters + +| Parameter | Description | +|------------|-------------------------------------------------| +| `` | The end time, of type DATETIMEV2 | +| `` | The start time, of type DATETIMEV2 | + +## Return Value + +Returns an INT type representing the millisecond difference between the two times. +- Returns a positive number if `` is greater than ``. +- Returns a negative number if `` is less than ``. +- 1 second = 1,000 milliseconds. +- 1 millisecond = 1,000 microseconds. + +## Example + +```sql +SELECT MILLISECONDS_DIFF('2020-12-25 21:00:00.623000', '2020-12-25 21:00:00.123000'); +``` + +```text +-----------------------------------------------------------------------------------------------------------------------------+ -| milliseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(6)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(6))) | +| milliseconds_diff(cast('2020-12-25 21:00:00.623000' as DATETIMEV2(3)), cast('2020-12-25 21:00:00.123000' as DATETIMEV2(3))) | +-----------------------------------------------------------------------------------------------------------------------------+ | 500 | +-----------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) ``` -### keywords - - milliseconds_diff +**Note:** +- The time difference in the example is 0.5 seconds, which equals 500 milliseconds. +- The function's result is dependent on the precision of the input time; the example uses a precision of 3 decimal places. +- The result only returns the millisecond difference and does not include the microsecond part. diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md index 500579d5a07cb..806b96d80ad5c 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/milliseconds-sub.md @@ -24,18 +24,35 @@ specific language governing permissions and limitations under the License. --> -## milliseconds_sub -### description -#### Syntax -`DATETIMEV2 milliseconds_sub(DATETIMEV2 basetime, INT delta)` -- basetime: Base time whose type is DATETIMEV2 -- delta: Milliseconds to subtract from basetime -- Return type of this function is DATETIMEV2 +## Description -### example +Subtracts a specified number of milliseconds from a datetime value and returns a new datetime value. + +## Syntax + +```sql +MILLISECONDS_SUB(, ) +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, of type DATETIMEV2 | +| `` | The number of milliseconds to subtract, of type INT; 1 second = 1,000 milliseconds = 1,000,000 microseconds | + +## Return Value + +Returns a value of type DATETIMEV2, representing the time value after subtracting the specified number of milliseconds from the input datetime. The precision of the return value is the same as that of the input parameter basetime. + +## Example + +```sql +SELECT MILLISECONDS_SUB('2023-09-08 16:02:08.435123', 1); ``` -mysql> select milliseconds_sub('2023-09-08 16:02:08.435123', 1); + +```text +--------------------------------------------------------------------------+ | milliseconds_sub(cast('2023-09-08 16:02:08.435123' as DATETIMEV2(6)), 1) | +--------------------------------------------------------------------------+ @@ -44,8 +61,8 @@ mysql> select milliseconds_sub('2023-09-08 16:02:08.435123', 1); 1 row in set (0.11 sec) ``` - -### keywords - milliseconds_sub - - \ No newline at end of file +**Note:** +- In the example, after subtracting 1 millisecond, the time decreases from .435123 to .434123. +- 1 millisecond equals 1000 microseconds. +- The function's result is dependent on the precision of the input time; the example uses a precision of 6 decimal places. +- The result retains microsecond-level precision. diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-ceil.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-ceil.md index 36e8b809e1ca6..e2eb8911a3ed5 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-ceil.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-ceil.md @@ -1,6 +1,6 @@ --- { - "title": "minute_ceil", + "title": "MINUTE_CEIL", "language": "en" } --- @@ -24,39 +24,51 @@ specific language governing permissions and limitations under the License. --> -## minute_ceil -### description -#### Syntax + +## Description + +Rounds up a datetime value to the nearest specified minute interval. If a starting time (origin) is provided, it uses that time as the reference for calculating the interval. + +## Syntax ```sql -DATETIME MINUTE_CEIL(DATETIME datetime) -DATETIME MINUTE_CEIL(DATETIME datetime, DATETIME origin) -DATETIME MINUTE_CEIL(DATETIME datetime, INT period) -DATETIME MINUTE_CEIL(DATETIME datetime, INT period, DATETIME origin) +MINUTE_CEIL() +MINUTE_CEIL(, ) +MINUTE_CEIL(, ) +MINUTE_CEIL(, , ) ``` -Convert the date to the nearest rounding up time of the specified time interval period. +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The datetime value to round up, of type DATETIME or DATETIMEV2 | +| `` | The minute interval value, of type INT, representing the number of minutes in each interval | +| `` | The starting point for the interval, of type DATETIME or DATETIMEV2; defaults to 0001-01-01 00:00:00 | -- datetime: a valid date expression. -- period: specifies how many minutes each cycle consists of. -- origin: starting from 0001-01-01T00:00:00. +## Return Value -### example +Returns a value of type DATETIMEV2, representing the rounded-up datetime value based on the specified minute interval. The precision of the return value is the same as that of the input parameter datetime. +## Example + +```sql +SELECT MINUTE_CEIL("2023-07-13 22:28:18", 5); ``` -mysql> select minute_ceil("2023-07-13 22:28:18", 5); + +```text +--------------------------------------------------------------+ | minute_ceil(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +--------------------------------------------------------------+ | 2023-07-13 22:30:00 | +--------------------------------------------------------------+ -1 row in set (0.21 sec) ``` -### keywords - - MINUTE_CEIL, MINUTE, CEIL +**Note:** +- If no period is specified, it defaults to a 1-minute interval. +- The period must be a positive integer. +- The result is always rounded up to a future time. -### Best Practice +## Best Practices See also [date_ceil](./date_ceil) diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md index afe9f8ac3e89c..bf644db01d0f3 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute-floor.md @@ -1,6 +1,6 @@ --- { - "title": "minute_floor", + "title": "MINUTE_FLOOR", "language": "en" } --- @@ -24,39 +24,52 @@ specific language governing permissions and limitations under the License. --> -## minute_floor -### description -#### Syntax + +## Description + +Rounds down a datetime value to the nearest specified minute interval. If a starting time (origin) is provided, it uses that time as the reference for calculating the interval. + +## Syntax ```sql -DATETIME MINUTE_FLOOR(DATETIME datetime) -DATETIME MINUTE_FLOOR(DATETIME datetime, DATETIME origin) -DATETIME MINUTE_FLOOR(DATETIME datetime, INT period) -DATETIME MINUTE_FLOOR(DATETIME datetime, INT period, DATETIME origin) +MINUTE_FLOOR() +MINUTE_FLOOR(, ) +MINUTE_FLOOR(, ) +MINUTE_FLOOR(, , ) ``` -Convert the date to the nearest rounding down time of the specified time interval period. +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The datetime value to round down, of type DATETIME or DATETIMEV2 | +| `` | The minute interval value, of type INT, representing the number of minutes in each interval | +| `` | The starting point for the interval, of type DATETIME or DATETIMEV2; defaults to 0001-01-01 00:00:00 | -- datetime: a valid date expression. -- period: specifies how many minutes each cycle consists of. -- origin: starting from 0001-01-01T00:00:00. +## Return Value -### example +Returns a value of type DATETIMEV2, representing the rounded-down datetime value. +## Example + +```sql +SELECT MINUTE_FLOOR("2023-07-13 22:28:18", 5); ``` -mysql> select minute_floor("2023-07-13 22:28:18", 5); + +```text +---------------------------------------------------------------+ | minute_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +---------------------------------------------------------------+ | 2023-07-13 22:25:00 | +---------------------------------------------------------------+ -1 row in set (0.06 sec) ``` -### keywords - - MINUTE_FLOOR, MINUTE, FLOOR +**Note:** +- If no period is specified, it defaults to a 1-minute interval. +- The period must be a positive integer. +- The result is always rounded down to a past time. +- Unlike MINUTE_CEIL, MINUTE_FLOOR always discards the portion that exceeds the interval. -### Best Practice +## Best Practices See also [date_floor](./date_floor) diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md index cfa348e739933..09a224da048d2 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minute.md @@ -27,21 +27,39 @@ under the License. ## Description -Returns minute information in the time type, ranging from 0,59 +Extracts the minute part from a datetime value. The returned value ranges from 0 to 59. -The parameter is Date or Datetime or Time type ## Syntax -`INT MINUTE(DATETIME date)` + +```sql +MINUTE() +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATE, DATETIME, DATETIMEV2, or TIME | + +## Return Value + +Returns an INT type representing the minute value, with a range of 0-59. ## Example ```sql -mysql> select minute('2018-12-31 23:59:59'); -+-----------------------------+ -| minute('2018-12-31 23:59:59') | -+-----------------------------+ -| 59 | -+-----------------------------+ +SELECT MINUTE('2018-12-31 23:59:59'); ``` -## Keywords - MINUTE + +```text ++------------------------------------------------------+ +| minute(cast('2018-12-31 23:59:59' as DATETIMEV2(0))) | ++------------------------------------------------------+ +| 59 | ++------------------------------------------------------+ +``` + +**Note:** +- The input parameter can be of various time-related types. +- The returned value is always an integer between 0 and 59. +- If the input parameter is NULL, the function returns NULL. diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md index 7c4636db8c855..04479f476828a 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-add.md @@ -24,27 +24,43 @@ specific language governing permissions and limitations under the License. --> -## minutes_add -### description -#### Syntax -`DATETIME MINUTES_ADD(DATETIME date, INT minutes)` +## Description -Add specified minutes from date time or date +Adds a specified number of minutes to a datetime value and returns a new datetime value. -The parameter date can be DATETIME or DATE, and the return type is DATETIME. - -### example +## Syntax +```sql +MINUTES_ADD(, ) ``` -mysql> select minutes_add("2020-02-02", 1); -+---------------------------------------+ -| minutes_add('2020-02-02 00:00:00', 1) | -+---------------------------------------+ -| 2020-02-02 00:01:00 | -+---------------------------------------+ + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATE, DATETIME, or DATETIMEV2 | +| `` | The number of minutes to add, of type INT; can be positive or negative | + +## Return Value + +Returns a value of type DATETIME, representing the datetime value after adding the specified number of minutes. + +## Example + +```sql +SELECT MINUTES_ADD("2020-02-02", 1); ``` -### keywords +```text ++-----------------------------------------------------+ +| minutes_add(cast('2020-02-02' as DATETIMEV2(0)), 1) | ++-----------------------------------------------------+ +| 2020-02-02 00:01:00 | ++-----------------------------------------------------+ +``` - MINUTES_ADD +**Note:** +- When the number of minutes added is negative, it effectively subtracts the corresponding number of minutes. +- The function automatically handles cases that cross hours and days. +- If the input parameter is NULL, the function returns NULL. diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md index b8c7fd1c1b880..ff3ccd818844f 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-diff.md @@ -24,25 +24,45 @@ specific language governing permissions and limitations under the License. --> -## minutes_diff -### description -#### Syntax -`INT minutes_diff(DATETIME enddate, DATETIME startdate)` +## Description -The difference between the start time and the end time is a few minutes +Calculates the minute difference between two datetime values. The result is the number of minutes from `` subtracted from ``. -### example +## Syntax +```sql +MINUTES_DIFF(, ) ``` -mysql> select minutes_diff('2020-12-25 22:00:00','2020-12-25 21:00:00'); -+------------------------------------------------------------+ -| minutes_diff('2020-12-25 22:00:00', '2020-12-25 21:00:00') | -+------------------------------------------------------------+ -| 60 | -+------------------------------------------------------------+ + +## Parameters + +| Parameter | Description | +|------------|-------------------------------------------------| +| `` | The end time, which can be of type DATE, DATETIME, or DATETIMEV2 | +| `` | The start time, which can be of type DATE, DATETIME, or DATETIMEV2 | + +## Return Value + +Returns an INT type representing the minute difference between the two times. +- Returns a positive number if `` is greater than ``. +- Returns a negative number if `` is less than ``. + +## Example + +```sql +SELECT MINUTES_DIFF('2020-12-25 22:00:00', '2020-12-25 21:00:00'); ``` -### keywords +```text ++----------------------------------------------------------------------------------------------------------+ +| minutes_diff(cast('2020-12-25 22:00:00' as DATETIMEV2(0)), cast('2020-12-25 21:00:00' as DATETIMEV2(0))) | ++----------------------------------------------------------------------------------------------------------+ +| 60 | ++----------------------------------------------------------------------------------------------------------+ +``` - minutes_diff +**Note:** +- The calculation only considers complete minutes; seconds and milliseconds are ignored. +- If either input parameter is NULL, the function returns NULL. +- It can handle time differences that span days, months, or years. diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md index 42612d96f501f..0d502ca9a0697 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/minutes-sub.md @@ -24,27 +24,44 @@ specific language governing permissions and limitations under the License. --> -## minutes_sub -### description -#### Syntax -`DATETIME MINUTES_SUB(DATETIME date, INT minutes)` +## Description -Subtracts a specified number of minutes from a datetime or date +Subtracts a specified number of minutes from a datetime value and returns a new datetime value. -The parameter date can be DATETIME or DATE, and the return type is DATETIME. - -### example +## Syntax +```sql +MINUTES_SUB(, ) ``` -mysql> select minutes_sub("2020-02-02 02:02:02", 1); -+---------------------------------------+ -| minutes_sub('2020-02-02 02:02:02', 1) | -+---------------------------------------+ -| 2020-02-02 02:01:02 | -+---------------------------------------+ + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATE, DATETIME, or DATETIMEV2 | +| `` | The number of minutes to subtract, of type INT; can be positive or negative | + +## Return Value + +Returns a value of type DATETIME, representing the datetime value after subtracting the specified number of minutes. + +## Example + +```sql +SELECT MINUTES_SUB("2020-02-02 02:02:02", 1); ``` -### keywords +```text ++--------------------------------------------------------------+ +| minutes_sub(cast('2020-02-02 02:02:02' as DATETIMEV2(0)), 1) | ++--------------------------------------------------------------+ +| 2020-02-02 02:01:02 | ++--------------------------------------------------------------+ +``` - MINUTES_SUB +**Note:** +- When the number of minutes subtracted is negative, it effectively adds the corresponding number of minutes. +- The function automatically handles cases that cross hours and days. +- If the input parameter is NULL, the function returns NULL. +- The result retains the seconds portion of the original time. diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md index dd50bc4342bb4..d27c4d4102065 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month-ceil.md @@ -1,6 +1,6 @@ --- { - "title": "month_ceil", + "title": "MONTH_CEIL", "language": "en" } --- @@ -24,39 +24,52 @@ specific language governing permissions and limitations under the License. --> -## month_ceil -### description -#### Syntax + +## Description + +Rounds up a datetime value to the nearest specified month interval. If a starting time (origin) is provided, it uses that time as the reference for calculating the interval. + +## Syntax ```sql -DATETIME MONTH_CEIL(DATETIME datetime) -DATETIME MONTH_CEIL(DATETIME datetime, DATETIME origin) -DATETIME MONTH_CEIL(DATETIME datetime, INT period) -DATETIME MONTH_CEIL(DATETIME datetime, INT period, DATETIME origin) +MONTH_CEIL() +MONTH_CEIL(, ) +MONTH_CEIL(, ) +MONTH_CEIL(, , ) ``` -Convert the date to the nearest rounding up time of the specified time interval period. +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The datetime value to round up, of type DATETIME or DATETIMEV2 | +| `` | The month interval value, of type INT, representing the number of months in each interval | +| `` | The starting point for the interval, of type DATETIME or DATETIMEV2; defaults to 0001-01-01 00:00:00 | -- datetime: a valid date expression. -- period: specifies how many months each cycle consists of. -- origin: starting from 0001-01-01T00:00:00. +## Return Value -### example +Returns a value of type DATETIME, representing the rounded-up datetime value. The time portion of the result will be set to 00:00:00. +## Example + +```sql +SELECT MONTH_CEIL("2023-07-13 22:28:18", 5); ``` -mysql> select month_ceil("2023-07-13 22:28:18", 5); + +```text +-------------------------------------------------------------+ | month_ceil(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +-------------------------------------------------------------+ | 2023-10-01 00:00:00 | +-------------------------------------------------------------+ -1 row in set (0.02 sec) ``` -### keywords - - MONTH_CEIL, MONTH, CEIL +**Note:** +- If no period is specified, it defaults to a 1-month interval. +- The period must be a positive integer. +- The result is always rounded up to a future time. +- The time portion of the returned value is always set to 00:00:00. -### Best Practice +## Best Practices See also [date_ceil](./date_ceil) diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md index 60684714fb1c3..e6e672c246e69 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month-floor.md @@ -1,6 +1,6 @@ --- { - "title": "month_floor", + "title": "MONTH_FLOOR", "language": "en" } --- @@ -24,39 +24,53 @@ specific language governing permissions and limitations under the License. --> -## month_floor -### description -#### Syntax + +## Description + +Rounds down a datetime value to the nearest specified month interval. If a starting time (origin) is provided, it uses that time as the reference for calculating the interval. + +## Syntax ```sql -DATETIME MONTH_FLOOR(DATETIME datetime) -DATETIME MONTH_FLOOR(DATETIME datetime, DATETIME origin) -DATETIME MONTH_FLOOR(DATETIME datetime, INT period) -DATETIME MONTH_FLOOR(DATETIME datetime, INT period, DATETIME origin) +MONTH_FLOOR() +MONTH_FLOOR(, ) +MONTH_FLOOR(, ) +MONTH_FLOOR(, , ) ``` -Convert the date to the nearest rounding down time of the specified time interval period. +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The datetime value to round down, of type DATETIME or DATETIMEV2 | +| `` | The month interval value, of type INT, representing the number of months in each interval | +| `` | The starting point for the interval, of type DATETIME or DATETIMEV2; defaults to 0001-01-01 00:00:00 | -- datetime: a valid date expression. -- period: specifies how many months each cycle consists of. -- origin: starting from 0001-01-01T00:00:00. +## Return Value -### example +Returns a value of type DATETIME, representing the rounded-down datetime value. The time portion of the result will be set to 00:00:00. +## Example + +```sql +SELECT MONTH_FLOOR("2023-07-13 22:28:18", 5); ``` -mysql> select month_floor("2023-07-13 22:28:18", 5); + +```text +--------------------------------------------------------------+ | month_floor(cast('2023-07-13 22:28:18' as DATETIMEV2(0)), 5) | +--------------------------------------------------------------+ | 2023-05-01 00:00:00 | +--------------------------------------------------------------+ -1 row in set (0.12 sec) ``` -### keywords - - MONTH_FLOOR, MONTH, FLOOR +**Note:** +- If no period is specified, it defaults to a 1-month interval. +- The period must be a positive integer. +- The result is always rounded down to a past time. +- The time portion of the returned value is always set to 00:00:00. +- Unlike MONTH_CEIL, MONTH_FLOOR always discards the portion that exceeds the interval. -### Best Practice +## Best Practices See also [date_floor](./date_floor) diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md index 9a3a71f15be76..3dfc9779fc380 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/month.md @@ -24,26 +24,40 @@ specific language governing permissions and limitations under the License. --> -## month -### Description -#### Syntax -`INT MONTH (DATETIME date)` +## Description +Extracts the month value from a datetime value. The returned value ranges from 1 to 12, representing the 12 months of the year. -Returns month information in the time type, ranging from 1,12 +## Syntax -The parameter is Date or Datetime type +```sql +MONTH() +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATE, DATETIME, or DATETIMEV2 | -### example +## Return Value +Returns an INT type representing the month value: +- Range: 1 to 12 +- 1 represents January, and 12 represents December. +- If the input is NULL, the function returns NULL. + +## Example + +```sql +SELECT MONTH('1987-01-01'); ``` -mysql> select month('1987-01-01'); -+-----------------------------+ -| month('1987-01-01 00:00:00') | -+-----------------------------+ -| 1 | -+-----------------------------+ + +```text ++--------------------------------------------+ +| month(cast('1987-01-01' as DATETIMEV2(0))) | ++--------------------------------------------+ +| 1 | ++--------------------------------------------+ ``` -### keywords - MONTH diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md index ae1852d1aa8cc..bd597c431fe14 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/date-time-functions/monthname.md @@ -24,26 +24,40 @@ specific language governing permissions and limitations under the License. --> -## monthname -### Description -#### Syntax -`VARCHAR MONTHNAME (DATE)` +## Description +Returns the English name of the month corresponding to a given date. The returned value is the full English name of the month (from January to December). -Month name corresponding to return date +## Syntax -The parameter is Date or Datetime type +```sql +MONTHNAME() +``` + +## Parameters + +| Parameter | Description | +|-----------|--------------------------------------------------| +| `` | The input datetime value, which can be of type DATE, DATETIME, or DATETIMEV2 | -### example +## Return Value +Returns a value of type VARCHAR representing the English name of the month: +- Possible return values: January, February, March, April, May, June, July, August, September, October, November, December +- If the input is NULL, the function returns NULL. +- The first letter of the return value is capitalized, and the remaining letters are in lowercase. + +## Example + +```sql +SELECT MONTHNAME('2008-02-03 00:00:00'); ``` -mysql> select monthname('2008-02-03 00:00:00'); -+----------------------------------+ -| monthname('2008-02-03 00:00:00') | -+----------------------------------+ -| February | -+----------------------------------+ + +```text ++---------------------------------------------------------+ +| monthname(cast('2008-02-03 00:00:00' as DATETIMEV2(0))) | ++---------------------------------------------------------+ +| February | ++---------------------------------------------------------+ ``` -### keywords - MONTHNAME diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md index e5957fdc9e416..70bba730c0902 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-key.md @@ -24,50 +24,37 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Determines whether the given `map` contains a specific key `key` -`BOOLEAN map_contains_key(Map map, K key)` +## Syntax -Determines whether the given `map` contains a particular key `key`. +```sql +MAP_CONTAINS_KEY(, ) +``` -### Example +## Parameters -```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +| Parameter | Description | +| -- | -- | +| `` | Input map content | +| `` | The key to be retrieved | -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## Return Value -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +Determines whether the given `map` contains a specific key `key`, and returns 1 if it exists, otherwise returns 0. -mysql> select map_contains_key(map(null, 1, 2, null), null); -+-----------------------------------------------+ -| map_contains_key(map(NULL, 1, 2, NULL), NULL) | -+-----------------------------------------------+ -| 1 | -+-----------------------------------------------+ -1 row in set (0.14 sec) -``` +## Example -### Keywords +```sql +select map_contains_key(map(null, 1, 2, null), null),map_contains_key(map(1, "100", 0.1, 2), 0.11); +``` -MAP, CONTAINS, KEY, MAP_CONTAINS_KEY +```text ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_key(map(NULL, 1, 2, NULL), NULL) | map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast(0.11 as DECIMALV3(3, 2))) | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md index 68c280c05b0af..1eea84a410cc7 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-contains-value.md @@ -24,66 +24,37 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Determines whether the given `map` contains a specific value `value` -`BOOLEAN map_contains_value(Map map, V value)` - -Determines whether the given `map` contains a particular value `value`. - -### Example +## Syntax ```sql -mysql> select map_contains_key(map(1, "100", 0.1, 2), "1"); -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('1' as DECIMALV3(38, 9))) | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.17 sec) +MAP_CONTAINS_VALUE(, ) +``` -mysql> select map_contains_key(map(1, "100", 0.1, 2), "abc"); -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast('abc' as DECIMALV3(38, 9))) | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## Parameters -mysql> select map_contains_key(map(1, "100", 0.1, 2), 0.11); -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_key(cast(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) as MAP), cast(0.11 as DECIMALV3(3, 2))) | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) +| Parameter | Description | +| -- | -- | +| `` | Input map content | +| `` | The value to be retrieved | -mysql> select map_contains_value(map(1, "100", 0.1, 2), 100.0); -+--------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(100.0 as VARCHAR(3))) | -+--------------------------------------------------------------------------------------------------------------------------------------+ -| 1 | -+--------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +## Return Value -mysql> select map_contains_value(map(1, "100", 0.1, 2), 101); -+------------------------------------------------------------------------------------------------------------------------------------+ -| map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | -+------------------------------------------------------------------------------------------------------------------------------------+ -| 0 | -+------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.14 sec) +Determines whether the given `map` contains a specific value `value`, and returns 1 if it exists, otherwise returns 0. -mysql> select map_contains_value(map(null, 1, 2, null), null); -+-------------------------------------------------+ -| map_contains_value(map(NULL, 1, 2, NULL), NULL) | -+-------------------------------------------------+ -| 1 | -+-------------------------------------------------+ -1 row in set (0.15 sec) -``` +## Example -### Keywords +```sql +select map_contains_value(map(null, 1, 2, null), null),map_contains_value(map(1, "100", 0.1, 2), 101); +``` -MAP, CONTAINS, VALUE, MAP_CONTAINS_VALUE +```text ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| map_contains_value(map(NULL, 1, 2, NULL), NULL) | map_contains_value(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(101 as VARCHAR(3))) | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +| 1 | 0 | ++-------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md index 04e20a1cfb261..5bde39f09b926 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-keys.md @@ -23,35 +23,36 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> +## Description -### Description +Extract the keys of the given `map` into an `ARRAY` of the corresponding type -#### Syntax +## Syntax -`ARRAY map_keys(Map map)` +```sql +MAP_KEYS() +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | Input map content | -Extracts the keys of a given `map` into an `ARRAY` of the corresponding type. +## Return Value -### Example +Extract the keys of the given `map` into an `ARRAY` of the corresponding type + +## Example ```sql -mysql> select map_keys(map(1, "100", 0.1, 2)); -+-------------------------------------------------------------------------------------------------+ -| map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+-------------------------------------------------------------------------------------------------+ -| [1.0, 0.1] | -+-------------------------------------------------------------------------------------------------+ -1 row in set (0.15 sec) - -mysql> select map_keys(map()); -+-----------------+ -| map_keys(map()) | -+-----------------+ -| [] | -+-----------------+ -1 row in set (0.12 sec) +select map_keys(map()),map_keys(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, KEYS, MAP_KEYS +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_keys(map()) | map_keys(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| [] | [1.0, 0.1] | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md index 79f097a3ff53d..15c78086b80c3 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-size.md @@ -1,7 +1,6 @@ --- { - "title": "MAP_SIZE - ", + "title": "MAP_SIZE", "language": "en" } --- @@ -24,3 +23,37 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> + +## Description + +Count the number of elements in a Map + +## Syntax + +```sql +MAP_SIZE() +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | Input map content | + +## Return Value + +Returns the number of elements in the Map + +## Example + +```sql +select map_size(map()),map_size(map(1, "100", 0.1, 2)); +``` + +```text ++-----------------+-------------------------------------------------------------------------------------------------+ +| map_size(map()) | map_size(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-----------------+-------------------------------------------------------------------------------------------------+ +| 0 | 2 | ++-----------------+-------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md index 6fef8da25aab1..160fcb91ee7cf 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map-values.md @@ -24,34 +24,36 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Extract the values of the given `map` into an `ARRAY` of the corresponding type -`ARRAY map_values(Map map)` +## Syntax -Extracts the value of a given `map` into an `ARRAY` of the corresponding type. +```sql +MAP_VALUES() +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | Input map content | -### Example +## Return Value + +Extract the values of the given `map` into an `ARRAY` of the corresponding type + +## Example ```sql -mysql> select map_values(map(1, "100", 0.1, 2)); -+---------------------------------------------------------------------------------------------------+ -| map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | -+---------------------------------------------------------------------------------------------------+ -| ["100", "2"] | -+---------------------------------------------------------------------------------------------------+ -1 row in set (0.12 sec) - -mysql> select map_values(map()); -+-------------------+ -| map_values(map()) | -+-------------------+ -| [] | -+-------------------+ -1 row in set (0.11 sec) +select map_values(map()),map_values(map(1, "100", 0.1, 2)); ``` -### Keywords - -MAP, VALUES, MAP_VALUES +```text ++-------------------+---------------------------------------------------------------------------------------------------+ +| map_values(map()) | map_values(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT))) | ++-------------------+---------------------------------------------------------------------------------------------------+ +| [] | ["100", "2"] | ++-------------------+---------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map.md index 8ffda7f10305b..f19716c0dc13f 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/map-functions/map.md @@ -24,34 +24,37 @@ specific language governing permissions and limitations under the License. --> -### Description +## Description -#### Syntax +Constructs a `Map` of a specific type using some set of key-value pairs -`MAP map(K key0, V value0, K key1, V value1, ..., K keyn, V valuen)` +## Syntax -Construct a type-specific `Map` using a set of key-value pairs. +```sql +MAP( , [, , ... ]) +``` + +## Parameters + +| Parameter | Description | +| -- | -- | +| `` | Constructing the key of the map | +| `` | Constructing the value of the map | -### Example +## Return Value + +Returns a specific type `Map` constructed from a number of key-value pairs + +## Example ```sql -mysql> select map(1, "100", 0.1, 2); -+---------------------------------------------------------------------------------------+ -| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | -+---------------------------------------------------------------------------------------+ -| {1.0:"100", 0.1:"2"} | -+---------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) - -mysql> select map(1, "100", 0.1, 2)[1]; -+-------------------------------------------------------------------------------------------------------------------------------+ -| element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | -+-------------------------------------------------------------------------------------------------------------------------------+ -| 100 | -+-------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.16 sec) +select map(1, "100", 0.1, 2),map(1, "100", 0.1, 2)[1]; ``` -### Keywords - -MAP +```text ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)) | element_at(map(cast(1 as DECIMALV3(2, 1)), '100', cast(0.1 as DECIMALV3(2, 1)), cast(2 as TEXT)), cast(1 as DECIMALV3(2, 1))) | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +| {1.0:"100", 0.1:"2"} | 100 | ++---------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md index ca99aeb9125dd..401c2ac7c0a0f 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle-sphere.md @@ -24,36 +24,52 @@ specific language governing permissions and limitations under the License. --> -## ST_Angle_Sphere -### description -#### Syntax +## Description -`DOUBLE ST_Angle_Sphere(DOUBLE x_lng, DOUBLE x_lat, DOUBLE y_lng, DOUBLE y_lat)` +Calculate the center Angle between two points on the Earth's surface in degrees. The parameters passed in are the longitude of point X, latitude of point X, longitude of point Y, and latitude of point Y. +## Syntax -Calculates the central angle between two points on the Earth's surface. The incoming parameters are the longitude of point X, the latitude of point X, the longitude of point Y and the latitude of point Y. +```sql +ST_Angle_Sphere( , , , ) +``` + +## Parameters + +| Parameters | Instructions | +| -- | -- | +| `` | Longitude data, reasonable value range is [-180, 180] | +| `` | Longitude data, reasonable value range is [-180, 180] | +| `` | Latitude data, reasonable value range is [-90, 90] | +| `` | Latitude data, reasonable value range is [-90, 90] | -x_lng and y_lng are Longitude values, must be in the range [-180, 180]. -x_lat and y_lat are Latitude values, must be in the range [-90, 90]. +## Return Value -### example +The Angle of the center between two points +## Examples + +```sql +select ST_Angle_Sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); ``` -mysql> select ST_Angle_Sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); + +```text +---------------------------------------------------------------------------+ | st_angle_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219) | +---------------------------------------------------------------------------+ | 0.0659823452409903 | +---------------------------------------------------------------------------+ -1 row in set (0.06 sec) +``` + +```sql +select ST_Angle_Sphere(0, 0, 45, 0); +``` -mysql> select ST_Angle_Sphere(0, 0, 45, 0); +```text +----------------------------------------+ | st_angle_sphere(0.0, 0.0, 45.0, 0.0) | +----------------------------------------+ | 45 | +----------------------------------------+ -1 row in set (0.06 sec) ``` -### keywords -ST_ANGLE_SPHERE,ST,ANGLE,SPHERE + diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md index bccc92b06034c..bc5e44b4e443a 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-angle.md @@ -24,66 +24,95 @@ specific language governing permissions and limitations under the License. --> -## ST_Angle +## Description -### Syntax +Enter three points that represent two intersecting lines. Return the Angle between these lines. -`DOUBLE ST_Angle(GEOPOINT point1, GEOPOINT point2, GEOPOINT point3)` +## Syntax -### description +```sql +ST_Angle( , , ) +``` + +## Parameters + +| Parameters | Instructions | +|----------|---------------------------------------------------------------------------| +| `` | The first point of the first line | +| `` | The second point of the first line and the first point of the second line | +| `` | The second point of the second line | -Enter three point, which represent two intersecting lines. Returns the angle between these lines. Point 2 and point 1 represent the first line and point 2 and point 3 represent the second line. The angle between these lines is in radians, in the range [0, 2pi). The angle is measured clockwise from the first line to the second line. +## Return Value + +The Angle between these lines is expressed in radians and ranges from [0, 2pi]. The Angle is measured clockwise from the first line to the second line. ST_ANGLE has the following edge cases: -* If points 2 and 3 are the same, returns NULL. -* If points 2 and 1 are the same, returns NULL. -* If points 2 and 3 are exactly antipodal, returns NULL. -* If points 2 and 1 are exactly antipodal, returns NULL. -* If any of the input geographies are not single points or are the empty geography, then throws an error. +- If point 2 and point 3 are the same, NULL is returned +- If point 2 and point 1 are the same, NULL is returned +- NULL is returned if points 2 and 3 are perfect Antipodes +- NULL is returned if points 2 and 1 are perfect AntipodesL +- If any input geography is not a single point or is an empty geography, an error is thrown -### example +## Examples +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1)); ``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 1)); + +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------------------------+ | 4.71238898038469 | +----------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1)); +``` -mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(1, 0),ST_Point(0, 1)); +```text +----------------------------------------------------------------------+ | st_angle(st_point(0.0, 0.0), st_point(1.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------------------------+ | 0.78547432161873854 | +----------------------------------------------------------------------+ -1 row in set (0.02 sec) +``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0)); +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(1, 0)); +``` + +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(1.0, 0.0)) | +----------------------------------------------------------------------+ | 0 | +----------------------------------------------------------------------+ -1 row in set (0.02 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 0)); +``` -mysql> SELECT ST_Angle(ST_Point(1, 0),ST_Point(0, 0),ST_Point(0, 0)); +```text +----------------------------------------------------------------------+ | st_angle(st_point(1.0, 0.0), st_point(0.0, 0.0), st_point(0.0, 0.0)) | +----------------------------------------------------------------------+ | NULL | +----------------------------------------------------------------------+ -1 row in set (0.03 sec) +``` + +```sql +SELECT ST_Angle(ST_Point(0, 0),ST_Point(-30, 0),ST_Point(150, 0)); +``` -mysql> SELECT ST_Angle(ST_Point(0, 0),ST_Point(-30, 0),ST_Point(150, 0)); +```text +--------------------------------------------------------------------------+ | st_angle(st_point(0.0, 0.0), st_point(-30.0, 0.0), st_point(150.0, 0.0)) | +--------------------------------------------------------------------------+ | NULL | +--------------------------------------------------------------------------+ -1 row in set (0.02 sec) ``` -### keywords -ST_ANGLE,ST,ANGLE + diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md index d349861bbf19d..c4282f10a1654 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-asbinary.md @@ -24,45 +24,63 @@ specific language governing permissions and limitations under the License. --> -## ST_AsBinary +## Description -### Syntax +Convert a geometric figure to a standard WKB (Well-known binary) representation. -`VARCHAR ST_AsBinary(GEOMETRY geo)` +At present, the supported geometry is: Point, LineString, Polygon. -### Description +## Syntax -Converting a geometric figure into a standard WKB (Well-known binary) representation +```sql +ST_AsBinary( ) +``` + +## Parameters + +| Parameters | Instructions | +| -- |----------| +| `` | The graph that needs to be converted | + +## Return Value -Currently supported geometric figures are: Point, LineString, Polygon. +The WKB representation of the geometry: -### example +## Examples +```sql +select ST_AsBinary(st_point(24.7, 56.7)); ``` -mysql> select ST_AsBinary(st_point(24.7, 56.7)); + +```text +----------------------------------------------+ | st_asbinary(st_point(24.7, 56.7)) | +----------------------------------------------+ | \x01010000003333333333b338409a99999999594c40 | +----------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> select ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); +```sql +select ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); +``` + +```text +--------------------------------------------------------------------------------------+ | st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +--------------------------------------------------------------------------------------+ | \x010200000002000000000000000000f03f000000000000f03f00000000000000400000000000000040 | +--------------------------------------------------------------------------------------+ -1 row in set (0.04 sec) +``` + +```sql +select ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")); +``` -mysql> select ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")); +```text +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')) | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | \x01030000000100000006000000f3380ce6af865c402d05a4fd0f8c364041ef8d2100865c403049658a398c3640b9fb1c1f2d865c409d9b36e334883640de921cb0ab865c40cf876709328a36402cefaa07cc865c407b319413ed8a3640f3380ce6af865c402d05a4fd0f8c3640 | +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.02 sec) - ``` -### keywords -ST_ASBINARY,ST,ASBINARY + diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md index b1990bb38353a..984ccdb156767 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-astext.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_AsText,ST_AsWKT -### Description -#### Syntax +## Description -`VARCHAR ST_AsText (GEOMETRY geo)` +Convert a geometric figure to a representation of WKT (Well Known Text) +## Syntax -Converting a geometric figure into a WKT (Well Known Text) representation +```sql +ST_AsText( ) +``` + +## Parameters + +| Parameters | Instructions | +| -- |----------| +| `` | The graph that needs to be converted | -### example +## Return Value +The WKT representation of the geometry: + +## Examples + +```sql +SELECT ST_AsText(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_AsText(ST_Point(24.7, 56.7)); + +```text +---------------------------------+ | st_astext(st_point(24.7, 56.7)) | +---------------------------------+ | POINT (24.7 56.7) | +---------------------------------+ ``` -### keywords -ST_ASTEXT,ST_ASWKT,ST,ASTEXT,ASWKT diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md index bb7b9ed19e41a..88744e119f173 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-azimuth.md @@ -24,72 +24,84 @@ specific language governing permissions and limitations under the License. --> -## ST_Azimuth +## Description -### Syntax +Enter two points and return the azimuth of the line segment formed by points 1 and 2. Azimuth is the arc of the Angle between the true north line of point 1 and the line segment formed by points 1 and 2. -`DOUBLE ST_Azimuth(GEOPOINT point1, GEOPOINT point2)` +## Syntax -### description +```sql +ST_Azimuth( , ) +``` +## Parameters + +| Parameters | Instructions | +|----------|------------------------------------------------| +| `` | The first point used to calculate the azimuth | +| `` | The second point used to calculate the azimuth | -Enter two point, and returns the azimuth of the line segment formed by points 1 and 2. The azimuth is the angle in radians measured between the line from point 1 facing true North to the line segment from point 1 to point 2. +## Return Value -The positive angle is measured clockwise on the surface of a sphere. For example, the azimuth for a line segment: +Positive angles are measured clockwise on the sphere. For example, the azimuth of a line segment: -* Pointing North is 0 -* Pointing East is PI/2 -* Pointing South is PI -* Pointing West is 3PI/2 +- North is 0 +- East is PI/2 +- The guide is PI +- The west is 3PI/2 ST_Azimuth has the following edge cases: -* If the two input points are the same, returns NULL. -* If the two input points are exactly antipodal, returns NULL. -* If either of the input geographies are not single points or are the empty geography, throws an error. +- Return NULL if both input points are the same. +- NULL is returned if the two input points are perfect mapping points. +- An error is thrown if any of the input geographies are not a single point or are empty geographies -### example +## Examples +```sql +SELECT st_azimuth(ST_Point(1, 0),ST_Point(0, 0)); ``` -mysql> SELECT st_azimuth(ST_Point(1, 0),ST_Point(0, 0)); + +```text +----------------------------------------------------+ | st_azimuth(st_point(1.0, 0.0), st_point(0.0, 0.0)) | +----------------------------------------------------+ | 4.71238898038469 | +----------------------------------------------------+ -1 row in set (0.03 sec) +``` -mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(1, 0)); +```sql +SELECT st_azimuth(ST_Point(0, 0),ST_Point(1, 0)); +``` + +```text +----------------------------------------------------+ | st_azimuth(st_point(0.0, 0.0), st_point(1.0, 0.0)) | +----------------------------------------------------+ | 1.5707963267948966 | +----------------------------------------------------+ -1 row in set (0.01 sec) +``` + +```sql +SELECT st_azimuth(ST_Point(0, 0),ST_Point(0, 1)); +``` -mysql> SELECT st_azimuth(ST_Point(0, 0),ST_Point(0, 1)); +```text +----------------------------------------------------+ | st_azimuth(st_point(0.0, 0.0), st_point(0.0, 1.0)) | +----------------------------------------------------+ | 0 | +----------------------------------------------------+ -1 row in set (0.01 sec) +``` -mysql> SELECT st_azimuth(ST_Point(0, 1),ST_Point(0, 1)); -+----------------------------------------------------+ -| st_azimuth(st_point(0.0, 1.0), st_point(0.0, 1.0)) | -+----------------------------------------------------+ -| NULL | -+----------------------------------------------------+ -1 row in set (0.02 sec) +```sql +SELECT st_azimuth(ST_Point(-30, 0),ST_Point(150, 0)); +``` -mysql> SELECT st_azimuth(ST_Point(-30, 0),ST_Point(150, 0)); +```text +--------------------------------------------------------+ | st_azimuth(st_point(-30.0, 0.0), st_point(150.0, 0.0)) | +--------------------------------------------------------+ | NULL | +--------------------------------------------------------+ -1 row in set (0.02 sec) - ``` -### keywords -ST_AZIMUTH,ST,AZIMUTH + diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md index 5b9750a1cf021..8e16a6befe79d 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-circle.md @@ -24,25 +24,41 @@ specific language governing permissions and limitations under the License. --> -## ST_Circle -### Description -#### Syntax +## Description -`GEOMETRY ST_Circle(DOUBLE center_lng, DOUBLE center_lat, DOUBLE radius)` +Convert a WKT (Well Known Text) to a circle on the sphere of the Earth. +## Syntax -Convert a WKT (Well Known Text) into a circle on the earth's sphere. Where `center_lng'denotes the longitude of the center of a circle, -` Center_lat` denotes the latitude of the center of a circle, radius` denotes the radius of a circle in meters. +```sql +ST_Circle( , , ) +``` + +## Parameters + +| Parameters | Instructions | +| -- | -- | +| `` | Longitude of the center of the circle | +| `` | The latitude of the center of the circle | +| `` | Radius of a circle | + +- The unit of radius is meters. A maximum of 9999999 RADIUS is supported -### example +## Return Value +A circle on a sphere based on basic information about the circle + +## Examples + +```sql +SELECT ST_AsText(ST_Circle(111, 64, 10000)); ``` -mysql> SELECT ST_AsText(ST_Circle(111, 64, 10000)); + +```text +--------------------------------------------+ | st_astext(st_circle(111.0, 64.0, 10000.0)) | +--------------------------------------------+ | CIRCLE ((111 64), 10000) | +--------------------------------------------+ ``` -### keywords -ST_CIRCLE,ST,CIRCLE + diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md index a3ab1214b0ccf..6454cce61403a 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-contains.md @@ -24,32 +24,52 @@ specific language governing permissions and limitations under the License. --> -## ST_Contains -### Description -#### Syntax +## Description -`BOOL ST_Contains(GEOMETRY shape1, GEOMETRY shape2)` +Determines whether the geometry shape1 is fully capable of containing the geometry shape2 +## Syntax -Judging whether geometric shape 1 can contain geometric shape 2 completely +```sql +ST_Contains( , ) +``` + +## Parameters + +| Parameters | Instructions | +|----------|------------------------| +| `` | The passed geometry used to determine whether shape2 is included | +| `` | The passed geometry is used to determine whether shape1 is included | + +## Return Value + +Return 1:shape1 The graph can contain the graph shape2 -### example +Return 0:shape1 Graph cannot contain graph shape2 +## Examples + +```sql +SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(5, 5)); ``` -mysql> SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(5, 5)); + +```text +----------------------------------------------------------------------------------------+ | st_contains(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'), st_point(5.0, 5.0)) | +----------------------------------------------------------------------------------------+ | 1 | +----------------------------------------------------------------------------------------+ +``` + +```sql +SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(50, 50)); +``` -mysql> SELECT ST_Contains(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))"), ST_Point(50, 50)); +```text +------------------------------------------------------------------------------------------+ | st_contains(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'), st_point(50.0, 50.0)) | +------------------------------------------------------------------------------------------+ | 0 | +------------------------------------------------------------------------------------------+ ``` -### keywords -ST_CONTAINS,ST,CONTAINS diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md index a50fc65625b1f..e1b5c76a90d9d 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-distance-sphere.md @@ -24,27 +24,40 @@ specific language governing permissions and limitations under the License. --> -## ST_Distance_Sphere -### description -#### Syntax +## Description -`DOUBLE ST_Distance_Sphere(DOUBLE x_lng, DOUBLE x_lat, DOUBLE y_lng, DOUBLE y_lat)` +Calculate the spherical distance in meters between two points on the Earth. The parameters passed in are the longitude of point X, latitude of point X, longitude of point Y, and latitude of point Y. +## Syntax -Calculate the spherical distance between two points of the earth in meters. The incoming parameters are the longitude of point X, the latitude of point X, the longitude of point Y and the latitude of point Y. +```sql +ST_Distance_Sphere( , , , ) +``` + +## Parameters + +| Parameters | Instructions | +| -- | -- | +| `` | Longitude data, reasonable value range is [-180, 180] | +| `` | Longitude data, reasonable value range is [-180, 180] | +| `` | Latitude data, reasonable value range is [-90, 90] | +| `` | Latitude data, reasonable value range is [-90, 90] | -x_lng and y_lng are Longitude values, must be in the range [-180, 180]. -x_lat and y_lat are Latitude values, must be in the range [-90, 90]. +## Return Value -### example +The spherical distance between two points +## Examples + +```sql +select st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); ``` -mysql> select st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219); + +```text +----------------------------------------------------------------------------+ | st_distance_sphere(116.35620117, 39.939093, 116.4274406433, 39.9020987219) | +----------------------------------------------------------------------------+ | 7336.9135549995917 | +----------------------------------------------------------------------------+ ``` -### keywords -ST_DISTANCE_SPHERE,ST,DISTANCE,SPHERE + diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md index 28072a02016d0..860fc1790c3c7 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromtext.md @@ -24,24 +24,35 @@ specific language governing permissions and limitations under the License. --> -## ST_GeometryFromText,ST_GeomFromText -### Description -#### Syntax +## Description -`GEOMETRY ST_GeometryFromText (VARCHAR wkt)` +Convert a linear WKT (Well Known Text) to the corresponding memory geometry +## Syntax -Converting a WKT (Well Known Text) into a corresponding memory geometry +```sql +ST_GeometryFromText( ) +``` +## Parameters + +| Parameters | Instructions | +| -- |---------| +| `` | The memory form of the graph | + +## Return Value -### example +The corresponding geometric storage form of WKB +## Examples + +```sql +SELECT ST_AsText(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); ``` -mysql> SELECT ST_AsText(ST_GeometryFromText("LINESTRING (1 1, 2 2)")); + +```text +---------------------------------------------------------+ | st_astext(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +---------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +---------------------------------------------------------+ -``` -### keywords -ST_GEOMETRYFROMTEXT,ST_GEOMFROMTEXT,ST,GEOMETRYFROMTEXT,GEOMFROMTEXT +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md index bf0a47f4b5903..e7c692ad15a2f 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-geometryfromwkb.md @@ -24,59 +24,84 @@ specific language governing permissions and limitations under the License. --> -## ST_GeometryFromWKB,ST_GeomFromWKB -### Syntax +## Description -`GEOMETRY ST_GeometryFromWKB(VARCHAR WKB)` +Converts a standard figure WKB (Well-known binary) to the corresponding memory geometry -### Description +## Syntax -Converting a standard WKB (Well-known binary) into a corresponding memory geometry +```sql +ST_GeometryFromWKB( ) +``` +## Parameters + +| Parameters | Instructions | +| -- |---------| +| `` | The memory form of the graph | + +## Return Value -### example +The corresponding geometric storage form of WKB +## Examples + +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); ``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); + +```text +------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_point(24.7, 56.7)))) | +------------------------------------------------------------------+ | POINT (24.7 56.7) | +------------------------------------------------------------------+ -1 row in set (0.05 sec) +``` + +```sql +select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); +``` -mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7)))); +```text +--------------------------------------------------------------+ | st_astext(st_geomfromwkb(st_asbinary(st_point(24.7, 56.7)))) | +--------------------------------------------------------------+ | POINT (24.7 56.7) | +--------------------------------------------------------------+ -1 row in set (0.03 sec) +``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")))); +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)")))); +``` + +```text +------------------------------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')))) | +------------------------------------------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +------------------------------------------------------------------------------------------+ -1 row in set (0.06 sec) +``` -mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +```sql +select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +``` + +```text +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_astext(st_geometryfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) +``` -mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +```sql +select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))")))); +``` + +```text +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | st_astext(st_geomfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) | +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) | +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -1 row in set (0.03 sec) - -``` -### keywords -ST_GEOMETRYFROMWKB,ST_GEOMFROMWKB,ST,GEOMETRYFROMWKB,GEOMFROMWKB,WKB +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md index 3a033103b1580..9fa5f0f4b8e37 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-linefromtext.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_LineFromText,ST_LineStringFromText -### Description -#### Syntax +## Description -`GEOMETRY ST LineFromText (VARCHAR wkt)` +Converts a WKT (Well Known Text) to a memory representation in the form of a Line +## Syntax -Converting a WKT (Well Known Text) into a Line-style memory representation +```sql +ST_LineFromText( ) +``` + +## Parameters + +| Parameters | Instructions | +|-----|------------| +| `` | A line segment consisting of two coordinates | + +## Return Value -### example +The memory form of a line segment. +## Examples + +```sql +SELECT ST_AsText(ST_LineFromText("LINESTRING (1 1, 2 2)")); ``` -mysql> SELECT ST_AsText(ST_LineFromText("LINESTRING (1 1, 2 2)")); + +```text +---------------------------------------------------------+ | st_astext(st_geometryfromtext('LINESTRING (1 1, 2 2)')) | +---------------------------------------------------------+ | LINESTRING (1 1, 2 2) | +---------------------------------------------------------+ -``` -### keywords -ST_LINEFROMTEXT, ST_LINESTRINGFROMTEXT,ST,LINEFROMTEXT,LINESTRINGFROMTEXT +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md index 050f41a31ad88..661fdac7ee6e1 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-point.md @@ -24,25 +24,38 @@ specific language governing permissions and limitations under the License. --> -## St_Point -### Description -#### Syntax +## Description -`POINT ST_Point(DOUBLE x, DOUBLE y)` +With the given X coordinate value, the Y coordinate value returns the corresponding Point. +The current value is only meaningful in the sphere set, X/Y corresponds to longitude/latitude; -Given the X coordinate value, the Y coordinate value returns the corresponding Point. -The current value is meaningful only for spherical sets, and X/Y corresponds to longitude/latitude. +## Syntax -### example +```sql +ST_Point( , ) +``` +## Parameters + +| Parameters | Instructions | +|-----|--------------| +| `` | x-coordinate | +| `` | y-coordinate | + +## Return Value + +Given horizontal coordinate and vertical coordinate corresponding position information +## Examples + +```sql +SELECT ST_AsText(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_AsText(ST_Point(24.7, 56.7)); + +```text +---------------------------------+ | st_astext(st_point(24.7, 56.7)) | +---------------------------------+ | POINT (24.7 56.7) | +---------------------------------+ -``` -### keywords -ST_POINT,ST,POINT +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md index 226736bb2d64c..aa282b328bab1 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-polygon.md @@ -24,25 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_Polygon,ST_PolyFromText,ST_PolygonFromText -### Description -#### Syntax +## Description -`GEOMETRY ST_Polygon (VARCHAR wkt)` +Convert a WKT (Well Known Text) to the corresponding polygonal memory form +## Syntax -Converting a WKT (Well Known Text) into a corresponding polygon memory form +```sql +ST_Polygon( ) +``` + +## Parameters + +| Parameters | Instructions | +|------|--------------------| +| `` | A POLYGON generated by the polygon function | +## Return Value -#### example +Memory form of polygon +## Examples + +```sql +SELECT ST_AsText(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))")); ``` -mysql> SELECT ST_AsText(ST_Polygon("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))")); + +```text +------------------------------------------------------------------+ | st_astext(st_polygon('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))')) | +------------------------------------------------------------------+ | POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0)) | +------------------------------------------------------------------+ ``` -### keywords -ST_POLYGON,ST_POLYFROMTEXT,ST_POLYGONFROMTEXT,ST,POLYGON,POLYFROMTEXT,POLYGONFROMTEXT diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md index a00eb050cfc13..7324fe6226bb1 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-x.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_X -### Description -#### Syntax +## Description -`DOUBLE ST_X(POINT point)` +When point is a valid POINT type, return the corresponding x-coordinate value +## Syntax -When point is a valid POINT type, the corresponding X coordinate value is returned. +```sql +ST_X( ) +``` + +## Parameters + +| Parameters | Instructions | +|------|----------| +| `` | The geometric coordinates of a two-dimensional point | + +## Return Value -### example +X value in geometric coordinates +## Examples + +```sql +SELECT ST_X(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_X(ST_Point(24.7, 56.7)); + +```text +----------------------------+ | st_x(st_point(24.7, 56.7)) | +----------------------------+ | 24.7 | +----------------------------+ -``` -### keywords -ST_X,ST,X +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md index eec67131b9ad3..de27d59df8015 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/scalar-functions/spatial-functions/st-y.md @@ -24,24 +24,36 @@ specific language governing permissions and limitations under the License. --> -## ST_Y -### Description -#### Syntax +## Description -`DOUBLE ST_Y(POINT point)` +When point is a valid POINT type, return the corresponding y-coordinate value +## Syntax -When point is a valid POINT type, the corresponding Y coordinate value is returned. +```sql +ST_Y( ) +``` + +## Parameters + +| Parameters | Instructions | +|------|----------| +| `` | The geometric coordinates of a two-dimensional point | + +## Return Value -### example +Y value in geometric coordinates +## Examples + +```sql +SELECT ST_Y(ST_Point(24.7, 56.7)); ``` -mysql> SELECT ST_Y(ST_Point(24.7, 56.7)); + +```text +----------------------------+ -| st_y(st_point(24.7, 56.7)) | +| st_x(st_point(24.7, 56.7)) | +----------------------------+ -| 56.7 | +| 24.7 | +----------------------------+ -``` -### keywords -ST_Y,ST,Y +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT.md b/versioned_docs/version-3.0/sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT.md index 6fc0e219a3a8c..e0da5f83fbd4d 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT.md +++ b/versioned_docs/version-3.0/sql-manual/sql-statements/cluster-management/storage-management/CREATE-STORAGE-VAULT.md @@ -1,6 +1,6 @@ --- { - "title": "CREATE STORAGE VAULT", + "title": "CREATE-STORAGE-VAULT", "language": "en", "toc_min_heading_level": 2, "toc_max_heading_level": 4 @@ -26,9 +26,9 @@ specific language governing permissions and limitations under the License. --> +## CREATE-STORAGE-VAULT - -## Description +### Description This command is used to create a storage vault. The subject of this document describes the syntax for creating Doris self-maintained storage vault. @@ -48,13 +48,13 @@ CREATE STORAGE VAULT [IF NOT EXISTS] vault | param | is required | desc | |:----------------|:------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `s3.endpoint` | required | The endpoint used for object storage.
**Notice**, please don't provide the endpoint with any `http://` or `https://`. And for Azure Blob Storage, the endpoint should be like `${ak}.blob.core.windows.net/`. | -| `s3.region` | required | The region of your bucket.(Not required when you'r using GCP or AZURE). | -| `s3.root.path` | required | The path where the data would be stored. | -| `s3.bucket` | required | The bucket of your object storage account. (StorageAccount if you're using Azure). | -| `s3.access_key` | required | The access key of your object storage account. (AccountName if you're using Azure). | -| `s3.secret_key` | required | The secret key of your object storage account. (AccountKey if you're using Azure). | -| `provider` | required | The cloud vendor which provides the object storage service. The supported values include `COS`, `OSS`, `S3`, `OBS`, `BOS`, `AZURE`, `GCP` | +| `s3.endpoint` | required | The endpoint used for object storage.
**Notice**, please don't provide the endpoint with any `http://` or `https://`. And for Azure Blob Storage, the endpoint should be `blob.core.windows.net`. | +| `s3.region` | required | The region of your bucket.(Not required when you'r using GCP or AZURE). | +| `s3.root.path` | required | The path where the data would be stored. | +| `s3.bucket` | required | The bucket of your object storage account. (StorageAccount if you're using Azure). | +| `s3.access_key` | required | The access key of your object storage account. (AccountName if you're using Azure). | +| `s3.secret_key` | required | The secret key of your object storage account. (AccountKey if you're using Azure). | +| `provider` | required | The cloud vendor which provides the object storage service. The supported values include `COS`, `OSS`, `S3`, `OBS`, `BOS`, `AZURE`, `GCP` | | `use_path_style` | optional | Indicate using `path-style URL`(private environment recommended) or `virtual-hosted-style URL`(public cloud recommended), default `true` (`path-style`) | ##### HDFS Vault @@ -68,111 +68,147 @@ CREATE STORAGE VAULT [IF NOT EXISTS] vault | `hadoop.kerberos.principal` | optional | The path to your kerberos principal. | | `hadoop.kerberos.keytab` | optional | The path to your kerberos keytab. | - -## Example +### Example 1. create a HDFS storage vault. ```sql - CREATE STORAGE VAULT IF NOT EXISTS hdfs_vault - PROPERTIES ( - "type"="hdfs", - "fs.defaultFS"="hdfs://127.0.0.1:8020" - ); + CREATE STORAGE VAULT IF NOT EXISTS hdfs_vault_demo + PROPERTIES ( + "type" = "hdfs", -- required + "fs.defaultFS" = "hdfs://127.0.0.1:8020", -- required + "path_prefix" = "big/data", -- optional + "hadoop.username" = "user" -- optional + "hadoop.security.authentication" = "kerberos" -- optional + "hadoop.kerberos.principal" = "hadoop/127.0.0.1@XXX" -- optional + "hadoop.kerberos.keytab" = "/etc/emr.keytab" -- optional + ); ``` -2. create a S3 storage vault using azure. +2. create a S3 storage vault using OSS. ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="ak.blob.core.windows.net/", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "AZURE" - ); + CREATE STORAGE VAULT IF NOT EXISTS oss_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "oss-cn-beijing.aliyuncs.com", -- required + "s3.access_key" = "xxxxxx", -- required, Your OSS access key + "s3.secret_key" = "xxxxxx", -- required, Your OSS secret key + "s3.region" = "cn-beijing", -- required + "s3.root.path" = "oss_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your OSS bucket name + "provider" = "OSS", -- required + "use_path_style" = "false" -- optional, OSS suggest setting `false` + ); ``` -3. create a S3 storage vault using OSS. +3. create a S3 storage vault using COS. ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="oss.aliyuncs.com", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.region" = "cn-hangzhou", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "OSS", - "use_path_style" = "false" - ); + CREATE STORAGE VAULT IF NOT EXISTS cos_demo_vault + PROPERTIES ( + "type" = "S3", + "s3.endpoint" = "cos.ap-guangzhou.myqcloud.com", -- required + "s3.access_key" = "xxxxxx", -- required, Your COS access key + "s3.secret_key" = "xxxxxx", -- required, Your COS secret key + "s3.region" = "ap-guangzhou", -- required + "s3.root.path" = "cos_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your COS bucket name + "provider" = "COS", -- required + "use_path_style" = "false" -- optional, COS suggest setting `false` + ); ``` -4. create a S3 storage vault using COS. +4. create a S3 storage vault using OBS. ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="cos.ap-guangzhou.myqcloud.com", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.region" = "ap-guangzhou", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "COS", - "use_path_style" = "false" - ); + CREATE STORAGE VAULT IF NOT EXISTS obs_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "obs.cn-north-4.myhuaweicloud.com", -- required + "s3.access_key" = "xxxxxx", -- required, Your OBS access key + "s3.secret_key" = "xxxxxx", -- required, Your OBS secret key + "s3.region" = "cn-north-4", -- required + "s3.root.path" = "obs_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your COS bucket name + "provider" = "OBS", -- required + "use_path_style" = "false" -- optional, OBS suggest setting `false` + ); ``` -5. create a S3 storage vault using OBS. +5. create a S3 storage vault using BOS. ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="obs.cn-north-4.myhuaweicloud.com", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.region" = "cn-north-4", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "OBS", - "use_path_style" = "false" - ); + CREATE STORAGE VAULT IF NOT EXISTS obs_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "s3.bj.bcebos.com", -- required + "s3.access_key" = "xxxxxx", -- required, Your BOS access key + "s3.secret_key" = "xxxxxx", -- required, Your BOS secret key + "s3.region" = "bj", -- required + "s3.root.path" = "bos_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your BOS bucket name + "provider" = "BOS", -- required + "use_path_style" = "false" -- optional, BOS suggest setting `false` + ); ``` 6. create a S3 storage vault using AWS. ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="s3.us-east-1.amazonaws.com", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.region" = "us-east-1", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "S3", - "use_path_style" = "false" - ); + CREATE STORAGE VAULT IF NOT EXISTS s3_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "s3.us-east-1.amazonaws.com", -- required + "s3.access_key" = "xxxxxx", -- required, Your S3 access key + "s3.secret_key" = "xxxxxx", -- required, Your OBS secret key + "s3.region" = "us-east-1", -- required + "s3.root.path" = "s3_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your s3 bucket name + "provider" = "S3", -- required + "use_path_style" = "false" -- optional, S3 suggest setting `false` + ); ``` 7. create a S3 storage vault using MinIO. ```sql - CREATE STORAGE VAULT IF NOT EXISTS s3_vault - PROPERTIES ( - "type"="S3", - "s3.endpoint"="127.0.0.1:9000", - "s3.access_key" = "ak", - "s3.secret_key" = "sk", - "s3.region" = "us-east-1", - "s3.root.path" = "ssb_sf1_p2_s3", - "s3.bucket" = "doris-build-1308700295", - "provider" = "S3", - "use_path_style" = "true" - ); + CREATE STORAGE VAULT IF NOT EXISTS minio_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "127.0.0.1:9000", -- required + "s3.access_key" = "xxxxxx", -- required, Your minio access key + "s3.secret_key" = "xxxxxx", -- required, Your minio secret key + "s3.region" = "us-east-1", -- required + "s3.root.path" = "minio_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your minio bucket name + "provider" = "S3", -- required + "use_path_style" = "true" -- required, minio suggest setting `true` + ); ``` -## Keywords +8. create a S3 storage vault using AZURE. + ```sql + CREATE STORAGE VAULT IF NOT EXISTS azure_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "blob.core.windows.net", -- required + "s3.access_key" = "xxxxxx", -- required, Your Azure AccountName + "s3.secret_key" = "xxxxxx", -- required, Your Azure AccountKey + "s3.region" = "us-east-1", -- required + "s3.root.path" = "azure_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required, Your Azure StorageAccount + "provider" = "AZURE" -- required + ); + ``` + +9. create a S3 storage vault using GCP. + ```sql + CREATE STORAGE VAULT IF NOT EXISTS gcp_demo_vault + PROPERTIES ( + "type" = "S3", -- required + "s3.endpoint" = "storage.googleapis.com", -- required + "s3.access_key" = "xxxxxx", -- required + "s3.secret_key" = "xxxxxx", -- required + "s3.region" = "us-east-1", -- required + "s3.root.path" = "gcp_demo_vault_prefix", -- required + "s3.bucket" = "xxxxxx", -- required + "provider" = "GCP" -- required + ); + ``` + +### Keywords CREATE, STORAGE VAULT diff --git a/versioned_sidebars/version-1.2-sidebars.json b/versioned_sidebars/version-1.2-sidebars.json index 703f63a5534f7..9f0f5507210a8 100644 --- a/versioned_sidebars/version-1.2-sidebars.json +++ b/versioned_sidebars/version-1.2-sidebars.json @@ -102,7 +102,7 @@ "items": [ "data-operate/export/export-manual", "data-operate/export/outfile", - "data-operate/export/export_with_mysql_dump" + "data-operate/export/export-with-mysql-dump" ] }, { @@ -162,8 +162,8 @@ "advanced/variables", "advanced/time-zone", "advanced/small-file-mgr", - "advanced/cold_hot_separation", - "advanced/compute_node", + "advanced/cold-hot-separation", + "advanced/compute-node", "advanced/lateral-view" ] }, @@ -236,54 +236,54 @@ "label": "Array Functions", "items": [ "sql-manual/sql-functions/array-functions/array", - "sql-manual/sql-functions/array-functions/array_max", - "sql-manual/sql-functions/array-functions/array_min", - "sql-manual/sql-functions/array-functions/array_map", - "sql-manual/sql-functions/array-functions/array_filter", - "sql-manual/sql-functions/array-functions/array_avg", - "sql-manual/sql-functions/array-functions/array_sum", - "sql-manual/sql-functions/array-functions/array_size", - "sql-manual/sql-functions/array-functions/array_remove", - "sql-manual/sql-functions/array-functions/array_slice", - "sql-manual/sql-functions/array-functions/array_sort", - "sql-manual/sql-functions/array-functions/array_reverse_sort", - "sql-manual/sql-functions/array-functions/array_sortby", - "sql-manual/sql-functions/array-functions/array_position", - "sql-manual/sql-functions/array-functions/array_contains", - "sql-manual/sql-functions/array-functions/array_except", - "sql-manual/sql-functions/array-functions/array_product", - "sql-manual/sql-functions/array-functions/array_intersect", - "sql-manual/sql-functions/array-functions/array_range", - "sql-manual/sql-functions/array-functions/array_distinct", - "sql-manual/sql-functions/array-functions/array_difference", - "sql-manual/sql-functions/array-functions/array_union", - "sql-manual/sql-functions/array-functions/array_join", - "sql-manual/sql-functions/array-functions/array_with_constant", - "sql-manual/sql-functions/array-functions/array_enumerate", - "sql-manual/sql-functions/array-functions/array_enumerate_uniq", - "sql-manual/sql-functions/array-functions/array_popback", - "sql-manual/sql-functions/array-functions/array_popfront", - "sql-manual/sql-functions/array-functions/array_pushfront", - "sql-manual/sql-functions/array-functions/array_compact", - "sql-manual/sql-functions/array-functions/array_concat", - "sql-manual/sql-functions/array-functions/array_shuffle", - "sql-manual/sql-functions/array-functions/array_cum_sum", - "sql-manual/sql-functions/array-functions/array_exists", - "sql-manual/sql-functions/array-functions/array_first_index", - "sql-manual/sql-functions/array-functions/arrays_overlap", - "sql-manual/sql-functions/array-functions/array_apply", + "sql-manual/sql-functions/array-functions/array-max", + "sql-manual/sql-functions/array-functions/array-min", + "sql-manual/sql-functions/array-functions/array-map", + "sql-manual/sql-functions/array-functions/array-filter", + "sql-manual/sql-functions/array-functions/array-avg", + "sql-manual/sql-functions/array-functions/array-sum", + "sql-manual/sql-functions/array-functions/array-size", + "sql-manual/sql-functions/array-functions/array-remove", + "sql-manual/sql-functions/array-functions/array-slice", + "sql-manual/sql-functions/array-functions/array-sort", + "sql-manual/sql-functions/array-functions/array-reverse-sort", + "sql-manual/sql-functions/array-functions/array-sortby", + "sql-manual/sql-functions/array-functions/array-position", + "sql-manual/sql-functions/array-functions/array-contains", + "sql-manual/sql-functions/array-functions/array-except", + "sql-manual/sql-functions/array-functions/array-product", + "sql-manual/sql-functions/array-functions/array-intersect", + "sql-manual/sql-functions/array-functions/array-range", + "sql-manual/sql-functions/array-functions/array-distinct", + "sql-manual/sql-functions/array-functions/array-difference", + "sql-manual/sql-functions/array-functions/array-union", + "sql-manual/sql-functions/array-functions/array-join", + "sql-manual/sql-functions/array-functions/array-with-constant", + "sql-manual/sql-functions/array-functions/array-enumerate", + "sql-manual/sql-functions/array-functions/array-enumerate-uniq", + "sql-manual/sql-functions/array-functions/array-popback", + "sql-manual/sql-functions/array-functions/array-popfront", + "sql-manual/sql-functions/array-functions/array-pushfront", + "sql-manual/sql-functions/array-functions/array-compact", + "sql-manual/sql-functions/array-functions/array-concat", + "sql-manual/sql-functions/array-functions/array-shuffle", + "sql-manual/sql-functions/array-functions/array-cum-sum", + "sql-manual/sql-functions/array-functions/array-exists", + "sql-manual/sql-functions/array-functions/array-first-index", + "sql-manual/sql-functions/array-functions/arrays-overlap", + "sql-manual/sql-functions/array-functions/array-apply", "sql-manual/sql-functions/array-functions/countequal", - "sql-manual/sql-functions/array-functions/element_at" + "sql-manual/sql-functions/array-functions/element-at" ] }, { "type": "category", "label": "Date Functions", "items": [ - "sql-manual/sql-functions/date-time-functions/convert_tz", + "sql-manual/sql-functions/date-time-functions/convert-tz", "sql-manual/sql-functions/date-time-functions/curdate", "sql-manual/sql-functions/date-time-functions/curtime", - "sql-manual/sql-functions/date-time-functions/current_timestamp", + "sql-manual/sql-functions/date-time-functions/current-timestamp", "sql-manual/sql-functions/date-time-functions/localtime", "sql-manual/sql-functions/date-time-functions/now", "sql-manual/sql-functions/date-time-functions/year", @@ -302,96 +302,96 @@ "sql-manual/sql-functions/date-time-functions/hour", "sql-manual/sql-functions/date-time-functions/minute", "sql-manual/sql-functions/date-time-functions/second", - "sql-manual/sql-functions/date-time-functions/from_days", - "sql-manual/sql-functions/date-time-functions/last_day", - "sql-manual/sql-functions/date-time-functions/to_monday", - "sql-manual/sql-functions/date-time-functions/from_unixtime", - "sql-manual/sql-functions/date-time-functions/unix_timestamp", - "sql-manual/sql-functions/date-time-functions/utc_timestamp", - "sql-manual/sql-functions/date-time-functions/to_date", - "sql-manual/sql-functions/date-time-functions/to_days", - "sql-manual/sql-functions/date-time-functions/time_to_sec", + "sql-manual/sql-functions/date-time-functions/from-days", + "sql-manual/sql-functions/date-time-functions/last-day", + "sql-manual/sql-functions/date-time-functions/to-monday", + "sql-manual/sql-functions/date-time-functions/from-unixtime", + "sql-manual/sql-functions/date-time-functions/unix-timestamp", + "sql-manual/sql-functions/date-time-functions/utc-timestamp", + "sql-manual/sql-functions/date-time-functions/to-date", + "sql-manual/sql-functions/date-time-functions/to-days", + "sql-manual/sql-functions/date-time-functions/time-to-sec", "sql-manual/sql-functions/date-time-functions/extract", "sql-manual/sql-functions/date-time-functions/makedate", - "sql-manual/sql-functions/date-time-functions/str_to_date", - "sql-manual/sql-functions/date-time-functions/time_round", + "sql-manual/sql-functions/date-time-functions/str-to-date", + "sql-manual/sql-functions/date-time-functions/time-round", "sql-manual/sql-functions/date-time-functions/timediff", "sql-manual/sql-functions/date-time-functions/timestampadd", "sql-manual/sql-functions/date-time-functions/timestampdiff", - "sql-manual/sql-functions/date-time-functions/date_add", - "sql-manual/sql-functions/date-time-functions/date_sub", - "sql-manual/sql-functions/date-time-functions/date_trunc", - "sql-manual/sql-functions/date-time-functions/date_format", + "sql-manual/sql-functions/date-time-functions/date-add", + "sql-manual/sql-functions/date-time-functions/date-sub", + "sql-manual/sql-functions/date-time-functions/date-trunc", + "sql-manual/sql-functions/date-time-functions/date-format", "sql-manual/sql-functions/date-time-functions/datediff", - "sql-manual/sql-functions/date-time-functions/second_floor", - "sql-manual/sql-functions/date-time-functions/minute_floor", - "sql-manual/sql-functions/date-time-functions/hour_floor", - "sql-manual/sql-functions/date-time-functions/day_floor", - "sql-manual/sql-functions/date-time-functions/month_floor", - "sql-manual/sql-functions/date-time-functions/year_floor", - "sql-manual/sql-functions/date-time-functions/second_ceil", - "sql-manual/sql-functions/date-time-functions/minute_ceil", - "sql-manual/sql-functions/date-time-functions/hour_ceil", - "sql-manual/sql-functions/date-time-functions/day_ceil", - "sql-manual/sql-functions/date-time-functions/month_ceil", - "sql-manual/sql-functions/date-time-functions/year_ceil", - "sql-manual/sql-functions/date-time-functions/microseconds_add", - "sql-manual/sql-functions/date-time-functions/microseconds_sub", - "sql-manual/sql-functions/date-time-functions/minutes_add", - "sql-manual/sql-functions/date-time-functions/minutes_diff", - "sql-manual/sql-functions/date-time-functions/minutes_sub", - "sql-manual/sql-functions/date-time-functions/seconds_add", - "sql-manual/sql-functions/date-time-functions/seconds_diff", - "sql-manual/sql-functions/date-time-functions/seconds_sub", - "sql-manual/sql-functions/date-time-functions/hours_add", - "sql-manual/sql-functions/date-time-functions/hours_diff", - "sql-manual/sql-functions/date-time-functions/hours_sub", - "sql-manual/sql-functions/date-time-functions/days_add", - "sql-manual/sql-functions/date-time-functions/days_diff", - "sql-manual/sql-functions/date-time-functions/days_sub", - "sql-manual/sql-functions/date-time-functions/weeks_add", - "sql-manual/sql-functions/date-time-functions/weeks_diff", - "sql-manual/sql-functions/date-time-functions/weeks_sub", - "sql-manual/sql-functions/date-time-functions/months_add", - "sql-manual/sql-functions/date-time-functions/months_diff", - "sql-manual/sql-functions/date-time-functions/months_sub", - "sql-manual/sql-functions/date-time-functions/years_add", - "sql-manual/sql-functions/date-time-functions/years_diff", - "sql-manual/sql-functions/date-time-functions/years_sub" + "sql-manual/sql-functions/date-time-functions/second-floor", + "sql-manual/sql-functions/date-time-functions/minute-floor", + "sql-manual/sql-functions/date-time-functions/hour-floor", + "sql-manual/sql-functions/date-time-functions/day-floor", + "sql-manual/sql-functions/date-time-functions/month-floor", + "sql-manual/sql-functions/date-time-functions/year-floor", + "sql-manual/sql-functions/date-time-functions/second-ceil", + "sql-manual/sql-functions/date-time-functions/minute-ceil", + "sql-manual/sql-functions/date-time-functions/hour-ceil", + "sql-manual/sql-functions/date-time-functions/day-ceil", + "sql-manual/sql-functions/date-time-functions/month-ceil", + "sql-manual/sql-functions/date-time-functions/year-ceil", + "sql-manual/sql-functions/date-time-functions/microseconds-add", + "sql-manual/sql-functions/date-time-functions/microseconds-sub", + "sql-manual/sql-functions/date-time-functions/minutes-add", + "sql-manual/sql-functions/date-time-functions/minutes-diff", + "sql-manual/sql-functions/date-time-functions/minutes-sub", + "sql-manual/sql-functions/date-time-functions/seconds-add", + "sql-manual/sql-functions/date-time-functions/seconds-diff", + "sql-manual/sql-functions/date-time-functions/seconds-sub", + "sql-manual/sql-functions/date-time-functions/hours-add", + "sql-manual/sql-functions/date-time-functions/hours-diff", + "sql-manual/sql-functions/date-time-functions/hours-sub", + "sql-manual/sql-functions/date-time-functions/days-add", + "sql-manual/sql-functions/date-time-functions/days-diff", + "sql-manual/sql-functions/date-time-functions/days-sub", + "sql-manual/sql-functions/date-time-functions/weeks-add", + "sql-manual/sql-functions/date-time-functions/weeks-diff", + "sql-manual/sql-functions/date-time-functions/weeks-sub", + "sql-manual/sql-functions/date-time-functions/months-add", + "sql-manual/sql-functions/date-time-functions/months-diff", + "sql-manual/sql-functions/date-time-functions/months-sub", + "sql-manual/sql-functions/date-time-functions/years-add", + "sql-manual/sql-functions/date-time-functions/years-diff", + "sql-manual/sql-functions/date-time-functions/years-sub" ] }, { "type": "category", "label": "GIS Functions", "items": [ - "sql-manual/sql-functions/spatial-functions/st_x", - "sql-manual/sql-functions/spatial-functions/st_y", - "sql-manual/sql-functions/spatial-functions/st_circle", - "sql-manual/sql-functions/spatial-functions/st_distance_sphere", - "sql-manual/sql-functions/spatial-functions/st_angle", - "sql-manual/sql-functions/spatial-functions/st_azimuth", - "sql-manual/sql-functions/spatial-functions/st_angle_sphere", - "sql-manual/sql-functions/spatial-functions/st_area", - "sql-manual/sql-functions/spatial-functions/st_point", - "sql-manual/sql-functions/spatial-functions/st_polygon", - "sql-manual/sql-functions/spatial-functions/st_astext", - "sql-manual/sql-functions/spatial-functions/st_contains", - "sql-manual/sql-functions/spatial-functions/st_geometryfromtext", - "sql-manual/sql-functions/spatial-functions/st_linefromtext", - "sql-manual/sql-functions/spatial-functions/st_asbinary", - "sql-manual/sql-functions/spatial-functions/st_geometryfromwkb" + "sql-manual/sql-functions/spatial-functions/st-x", + "sql-manual/sql-functions/spatial-functions/st-y", + "sql-manual/sql-functions/spatial-functions/st-circle", + "sql-manual/sql-functions/spatial-functions/st-distance-sphere", + "sql-manual/sql-functions/spatial-functions/st-angle", + "sql-manual/sql-functions/spatial-functions/st-azimuth", + "sql-manual/sql-functions/spatial-functions/st-angle-sphere", + "sql-manual/sql-functions/spatial-functions/st-area", + "sql-manual/sql-functions/spatial-functions/st-point", + "sql-manual/sql-functions/spatial-functions/st-polygon", + "sql-manual/sql-functions/spatial-functions/st-astext", + "sql-manual/sql-functions/spatial-functions/st-contains", + "sql-manual/sql-functions/spatial-functions/st-geometryfromtext", + "sql-manual/sql-functions/spatial-functions/st-linefromtext", + "sql-manual/sql-functions/spatial-functions/st-asbinary", + "sql-manual/sql-functions/spatial-functions/st-geometryfromwkb" ] }, { "type": "category", "label": "String Functions", "items": [ - "sql-manual/sql-functions/string-functions/to_base64", - "sql-manual/sql-functions/string-functions/from_base64", + "sql-manual/sql-functions/string-functions/to-base64", + "sql-manual/sql-functions/string-functions/from-base64", "sql-manual/sql-functions/string-functions/ascii", "sql-manual/sql-functions/string-functions/length", - "sql-manual/sql-functions/string-functions/bit_length", - "sql-manual/sql-functions/string-functions/char_length", + "sql-manual/sql-functions/string-functions/bit-length", + "sql-manual/sql-functions/string-functions/char-length", "sql-manual/sql-functions/string-functions/lpad", "sql-manual/sql-functions/string-functions/rpad", "sql-manual/sql-functions/string-functions/lower", @@ -402,51 +402,51 @@ "sql-manual/sql-functions/string-functions/repeat", "sql-manual/sql-functions/string-functions/reverse", "sql-manual/sql-functions/string-functions/concat", - "sql-manual/sql-functions/string-functions/concat_ws", + "sql-manual/sql-functions/string-functions/concat-ws", "sql-manual/sql-functions/string-functions/substr", "sql-manual/sql-functions/string-functions/substring", - "sql-manual/sql-functions/string-functions/sub_replace", - "sql-manual/sql-functions/string-functions/append_trailing_char_if_absent", - "sql-manual/sql-functions/string-functions/ends_with", - "sql-manual/sql-functions/string-functions/starts_with", + "sql-manual/sql-functions/string-functions/sub-replace", + "sql-manual/sql-functions/string-functions/append-trailing-char-if-absent", + "sql-manual/sql-functions/string-functions/ends-with", + "sql-manual/sql-functions/string-functions/starts-with", "sql-manual/sql-functions/string-functions/trim", "sql-manual/sql-functions/string-functions/ltrim", "sql-manual/sql-functions/string-functions/rtrim", - "sql-manual/sql-functions/string-functions/null_or_empty", - "sql-manual/sql-functions/string-functions/not_null_or_empty", + "sql-manual/sql-functions/string-functions/null-or-empty", + "sql-manual/sql-functions/string-functions/not-null-or-empty", "sql-manual/sql-functions/string-functions/hex", "sql-manual/sql-functions/string-functions/unhex", "sql-manual/sql-functions/string-functions/elt", "sql-manual/sql-functions/string-functions/instr", "sql-manual/sql-functions/string-functions/locate", "sql-manual/sql-functions/string-functions/field", - "sql-manual/sql-functions/string-functions/find_in_set", + "sql-manual/sql-functions/string-functions/find-in-set", "sql-manual/sql-functions/string-functions/replace", "sql-manual/sql-functions/string-functions/left", "sql-manual/sql-functions/string-functions/right", "sql-manual/sql-functions/string-functions/strleft", "sql-manual/sql-functions/string-functions/strright", - "sql-manual/sql-functions/string-functions/split_part", - "sql-manual/sql-functions/string-functions/split_by_string", - "sql-manual/sql-functions/string-functions/substring_index", - "sql-manual/sql-functions/string-functions/money_format", - "sql-manual/sql-functions/string-functions/parse_url", - "sql-manual/sql-functions/string-functions/convert_to", - "sql-manual/sql-functions/string-functions/extract_url_parameter", + "sql-manual/sql-functions/string-functions/split-part", + "sql-manual/sql-functions/string-functions/split-by-string", + "sql-manual/sql-functions/string-functions/substring-index", + "sql-manual/sql-functions/string-functions/money-format", + "sql-manual/sql-functions/string-functions/parse-url", + "sql-manual/sql-functions/string-functions/convert-to", + "sql-manual/sql-functions/string-functions/extract-url-parameter", "sql-manual/sql-functions/string-functions/uuid", "sql-manual/sql-functions/string-functions/space", "sql-manual/sql-functions/string-functions/esquery", "sql-manual/sql-functions/string-functions/mask/mask", - "sql-manual/sql-functions/string-functions/mask/mask_first_n", - "sql-manual/sql-functions/string-functions/mask/mask_last_n", - "sql-manual/sql-functions/string-functions/search/multi_search_all_positions", - "sql-manual/sql-functions/string-functions/search/multi_match_any", + "sql-manual/sql-functions/string-functions/mask/mask-first-n", + "sql-manual/sql-functions/string-functions/mask/mask-last-n", + "sql-manual/sql-functions/string-functions/search/multi-search-all-positions", + "sql-manual/sql-functions/string-functions/search/multi-match-any", { "type": "category", "label": "Fuzzy Match", "items": [ "sql-manual/sql-functions/string-functions/like/like", - "sql-manual/sql-functions/string-functions/like/not_like" + "sql-manual/sql-functions/string-functions/like/not-like" ] }, { @@ -454,10 +454,10 @@ "label": "Regular Match", "items": [ "sql-manual/sql-functions/string-functions/regexp/regexp", - "sql-manual/sql-functions/string-functions/regexp/regexp_extract", - "sql-manual/sql-functions/string-functions/regexp/regexp_extract_all", - "sql-manual/sql-functions/string-functions/regexp/regexp_replace", - "sql-manual/sql-functions/string-functions/regexp/regexp_replace_one" + "sql-manual/sql-functions/string-functions/regexp/regexp-extract", + "sql-manual/sql-functions/string-functions/regexp/regexp-extract-all", + "sql-manual/sql-functions/string-functions/regexp/regexp-replace", + "sql-manual/sql-functions/string-functions/regexp/regexp-replace-one" ] } ] @@ -466,40 +466,40 @@ "type": "category", "label": "Aggregate Functions", "items": [ - "sql-manual/sql-functions/aggregate-functions/collect_set", + "sql-manual/sql-functions/aggregate-functions/collect-set", "sql-manual/sql-functions/aggregate-functions/min", - "sql-manual/sql-functions/aggregate-functions/stddev_samp", + "sql-manual/sql-functions/aggregate-functions/stddev-samp", "sql-manual/sql-functions/aggregate-functions/avg", - "sql-manual/sql-functions/aggregate-functions/avg_weighted", + "sql-manual/sql-functions/aggregate-functions/avg-weighted", "sql-manual/sql-functions/aggregate-functions/percentile", - "sql-manual/sql-functions/aggregate-functions/percentile_array", - "sql-manual/sql-functions/aggregate-functions/hll_union_agg", + "sql-manual/sql-functions/aggregate-functions/percentile-array", + "sql-manual/sql-functions/aggregate-functions/hll-union-agg", "sql-manual/sql-functions/aggregate-functions/topn", - "sql-manual/sql-functions/aggregate-functions/topn_array", - "sql-manual/sql-functions/aggregate-functions/topn_weighted", + "sql-manual/sql-functions/aggregate-functions/topn-array", + "sql-manual/sql-functions/aggregate-functions/topn-weighted", "sql-manual/sql-functions/aggregate-functions/count", "sql-manual/sql-functions/aggregate-functions/sum", - "sql-manual/sql-functions/aggregate-functions/max_by", - "sql-manual/sql-functions/aggregate-functions/bitmap_union", - "sql-manual/sql-functions/aggregate-functions/group_bitmap_xor", - "sql-manual/sql-functions/aggregate-functions/group_bit_and", - "sql-manual/sql-functions/aggregate-functions/group_bit_or", - "sql-manual/sql-functions/aggregate-functions/group_bit_xor", - "sql-manual/sql-functions/aggregate-functions/percentile_approx", + "sql-manual/sql-functions/aggregate-functions/max-by", + "sql-manual/sql-functions/aggregate-functions/bitmap-union", + "sql-manual/sql-functions/aggregate-functions/group-bitmap-xor", + "sql-manual/sql-functions/aggregate-functions/group-bit-and", + "sql-manual/sql-functions/aggregate-functions/group-bit-or", + "sql-manual/sql-functions/aggregate-functions/group-bit-xor", + "sql-manual/sql-functions/aggregate-functions/percentile-approx", "sql-manual/sql-functions/aggregate-functions/stddev", - "sql-manual/sql-functions/aggregate-functions/group_concat", - "sql-manual/sql-functions/aggregate-functions/collect_list", - "sql-manual/sql-functions/aggregate-functions/min_by", + "sql-manual/sql-functions/aggregate-functions/group-concat", + "sql-manual/sql-functions/aggregate-functions/collect-list", + "sql-manual/sql-functions/aggregate-functions/min-by", "sql-manual/sql-functions/aggregate-functions/max", - "sql-manual/sql-functions/aggregate-functions/any_value", - "sql-manual/sql-functions/aggregate-functions/var_samp", - "sql-manual/sql-functions/aggregate-functions/approx_count_distinct", + "sql-manual/sql-functions/aggregate-functions/any-value", + "sql-manual/sql-functions/aggregate-functions/var-samp", + "sql-manual/sql-functions/aggregate-functions/approx-count-distinct", "sql-manual/sql-functions/aggregate-functions/variance", "sql-manual/sql-functions/aggregate-functions/retention", - "sql-manual/sql-functions/aggregate-functions/sequence_match", - "sql-manual/sql-functions/aggregate-functions/sequence_count", + "sql-manual/sql-functions/aggregate-functions/sequence-match", + "sql-manual/sql-functions/aggregate-functions/sequence-count", "sql-manual/sql-functions/aggregate-functions/grouping", - "sql-manual/sql-functions/aggregate-functions/grouping_id", + "sql-manual/sql-functions/aggregate-functions/grouping-id", "sql-manual/sql-functions/aggregate-functions/histogram" ] }, @@ -507,38 +507,38 @@ "type": "category", "label": "Bitmap Functions", "items": [ - "sql-manual/sql-functions/bitmap-functions/to_bitmap", - "sql-manual/sql-functions/bitmap-functions/bitmap_hash", - "sql-manual/sql-functions/bitmap-functions/bitmap_from_string", - "sql-manual/sql-functions/bitmap-functions/bitmap_to_string", - "sql-manual/sql-functions/bitmap-functions/bitmap_to_array", - "sql-manual/sql-functions/bitmap-functions/bitmap_from_array", - "sql-manual/sql-functions/bitmap-functions/bitmap_empty", - "sql-manual/sql-functions/bitmap-functions/bitmap_or", - "sql-manual/sql-functions/bitmap-functions/bitmap_and", - "sql-manual/sql-functions/bitmap-functions/bitmap_union", - "sql-manual/sql-functions/bitmap-functions/bitmap_xor", - "sql-manual/sql-functions/bitmap-functions/bitmap_not", - "sql-manual/sql-functions/bitmap-functions/bitmap_and_not", - "sql-manual/sql-functions/bitmap-functions/bitmap_subset_limit", - "sql-manual/sql-functions/bitmap-functions/bitmap_subset_in_range", - "sql-manual/sql-functions/bitmap-functions/sub_bitmap", - "sql-manual/sql-functions/bitmap-functions/bitmap_count", - "sql-manual/sql-functions/bitmap-functions/bitmap_and_count", - "sql-manual/sql-functions/bitmap-functions/bitmap_and_not_count", - "sql-manual/sql-functions/bitmap-functions/orthogonal_bitmap_union_count", - "sql-manual/sql-functions/bitmap-functions/bitmap_xor_count", - "sql-manual/sql-functions/bitmap-functions/bitmap_or_count", - "sql-manual/sql-functions/bitmap-functions/bitmap_contains", - "sql-manual/sql-functions/bitmap-functions/bitmap_has_all", - "sql-manual/sql-functions/bitmap-functions/bitmap_has_any", - "sql-manual/sql-functions/bitmap-functions/bitmap_max", - "sql-manual/sql-functions/bitmap-functions/bitmap_min", - "sql-manual/sql-functions/bitmap-functions/intersect_count", - "sql-manual/sql-functions/bitmap-functions/bitmap_intersect", - "sql-manual/sql-functions/bitmap-functions/orthogonal_bitmap_intersect", - "sql-manual/sql-functions/bitmap-functions/orthogonal_bitmap_intersect_count", - "sql-manual/sql-functions/bitmap-functions/bitmap_hash64" + "sql-manual/sql-functions/bitmap-functions/to-bitmap", + "sql-manual/sql-functions/bitmap-functions/bitmap-hash", + "sql-manual/sql-functions/bitmap-functions/bitmap-from-string", + "sql-manual/sql-functions/bitmap-functions/bitmap-to-string", + "sql-manual/sql-functions/bitmap-functions/bitmap-to-array", + "sql-manual/sql-functions/bitmap-functions/bitmap-from-array", + "sql-manual/sql-functions/bitmap-functions/bitmap-empty", + "sql-manual/sql-functions/bitmap-functions/bitmap-or", + "sql-manual/sql-functions/bitmap-functions/bitmap-and", + "sql-manual/sql-functions/bitmap-functions/bitmap-union", + "sql-manual/sql-functions/bitmap-functions/bitmap-xor", + "sql-manual/sql-functions/bitmap-functions/bitmap-not", + "sql-manual/sql-functions/bitmap-functions/bitmap-and-not", + "sql-manual/sql-functions/bitmap-functions/bitmap-subset-limit", + "sql-manual/sql-functions/bitmap-functions/bitmap-subset-in-range", + "sql-manual/sql-functions/bitmap-functions/sub-bitmap", + "sql-manual/sql-functions/bitmap-functions/bitmap-count", + "sql-manual/sql-functions/bitmap-functions/bitmap-and-count", + "sql-manual/sql-functions/bitmap-functions/bitmap-and-not-count", + "sql-manual/sql-functions/bitmap-functions/orthogonal-bitmap-union-count", + "sql-manual/sql-functions/bitmap-functions/bitmap-xor-count", + "sql-manual/sql-functions/bitmap-functions/bitmap-or-count", + "sql-manual/sql-functions/bitmap-functions/bitmap-contains", + "sql-manual/sql-functions/bitmap-functions/bitmap-has-all", + "sql-manual/sql-functions/bitmap-functions/bitmap-has-any", + "sql-manual/sql-functions/bitmap-functions/bitmap-max", + "sql-manual/sql-functions/bitmap-functions/bitmap-min", + "sql-manual/sql-functions/bitmap-functions/intersect-count", + "sql-manual/sql-functions/bitmap-functions/bitmap-intersect", + "sql-manual/sql-functions/bitmap-functions/orthogonal-bitmap-intersect", + "sql-manual/sql-functions/bitmap-functions/orthogonal-bitmap-intersect-count", + "sql-manual/sql-functions/bitmap-functions/bitmap-hash64" ] }, { @@ -567,37 +567,37 @@ "type": "category", "label": "JSON Functions", "items": [ - "sql-manual/sql-functions/json-functions/jsonb_parse", - "sql-manual/sql-functions/json-functions/jsonb_extract", - "sql-manual/sql-functions/json-functions/jsonb_exists_path", - "sql-manual/sql-functions/json-functions/jsonb_type", - "sql-manual/sql-functions/json-functions/get_json_double", - "sql-manual/sql-functions/json-functions/get_json_int", - "sql-manual/sql-functions/json-functions/get_json_bigint", - "sql-manual/sql-functions/json-functions/get_json_string", - "sql-manual/sql-functions/json-functions/json_array", - "sql-manual/sql-functions/json-functions/json_object", - "sql-manual/sql-functions/json-functions/json_quote", - "sql-manual/sql-functions/json-functions/json_unquote", - "sql-manual/sql-functions/json-functions/json_valid", - "sql-manual/sql-functions/json-functions/json_extract" + "sql-manual/sql-functions/json-functions/jsonb-parse", + "sql-manual/sql-functions/json-functions/jsonb-extract", + "sql-manual/sql-functions/json-functions/jsonb-exists-path", + "sql-manual/sql-functions/json-functions/jsonb-type", + "sql-manual/sql-functions/json-functions/get-json-double", + "sql-manual/sql-functions/json-functions/get-json-int", + "sql-manual/sql-functions/json-functions/get-json-bigint", + "sql-manual/sql-functions/json-functions/get-json-string", + "sql-manual/sql-functions/json-functions/json-array", + "sql-manual/sql-functions/json-functions/json-object", + "sql-manual/sql-functions/json-functions/json-quote", + "sql-manual/sql-functions/json-functions/json-unquote", + "sql-manual/sql-functions/json-functions/json-valid", + "sql-manual/sql-functions/json-functions/json-extract" ] }, { "type": "category", "label": "Hash Functions", "items": [ - "sql-manual/sql-functions/hash-functions/murmur_hash3_32", - "sql-manual/sql-functions/hash-functions/murmur_hash3_64" + "sql-manual/sql-functions/hash-functions/murmur-hash3-32", + "sql-manual/sql-functions/hash-functions/murmur-hash3-64" ] }, { "type": "category", "label": "HLL Functions", "items": [ - "sql-manual/sql-functions/hll-functions/hll_cardinality", - "sql-manual/sql-functions/hll-functions/hll_empty", - "sql-manual/sql-functions/hll-functions/hll_hash" + "sql-manual/sql-functions/hll-functions/hll-cardinality", + "sql-manual/sql-functions/hll-functions/hll-empty", + "sql-manual/sql-functions/hll-functions/hll-hash" ] }, { @@ -623,7 +623,7 @@ "sql-manual/sql-functions/math-functions/floor", "sql-manual/sql-functions/math-functions/pmod", "sql-manual/sql-functions/math-functions/round", - "sql-manual/sql-functions/math-functions/round_bankers", + "sql-manual/sql-functions/math-functions/round-bankers", "sql-manual/sql-functions/math-functions/truncate", "sql-manual/sql-functions/math-functions/abs", "sql-manual/sql-functions/math-functions/sqrt", @@ -638,7 +638,7 @@ "sql-manual/sql-functions/math-functions/least", "sql-manual/sql-functions/math-functions/random", "sql-manual/sql-functions/math-functions/mod", - "sql-manual/sql-functions/math-functions/running_difference" + "sql-manual/sql-functions/math-functions/running-difference" ] }, { @@ -668,7 +668,7 @@ "sql-manual/sql-functions/table-functions/explode-numbers", "sql-manual/sql-functions/table-functions/s3", "sql-manual/sql-functions/table-functions/hdfs", - "sql-manual/sql-functions/table-functions/iceberg_meta", + "sql-manual/sql-functions/table-functions/iceberg-meta", "sql-manual/sql-functions/table-functions/backends", "sql-manual/sql-functions/table-functions/resource-group" ] @@ -983,7 +983,7 @@ "sql-manual/sql-reference/Data-Types/STRING", "sql-manual/sql-reference/Data-Types/HLL", "sql-manual/sql-reference/Data-Types/BITMAP", - "sql-manual/sql-reference/Data-Types/QUANTILE_STATE", + "sql-manual/sql-reference/Data-Types/QUANTILE-STATE", "sql-manual/sql-reference/Data-Types/ARRAY", "sql-manual/sql-reference/Data-Types/JSONB" ] @@ -1163,7 +1163,7 @@ "admin-manual/http-actions/be/restore-tablet", "admin-manual/http-actions/be/pad-rowset", "admin-manual/http-actions/be/tablet-migration-action", - "admin-manual/http-actions/be/tablets_distribution", + "admin-manual/http-actions/be/tablets-distribution", "admin-manual/http-actions/be/compaction-action", "admin-manual/http-actions/be/get-tablets", "admin-manual/http-actions/be/check-reset-rpc-cache", @@ -1239,53 +1239,6 @@ "label": "Releases", "collapsed": false, "items": [ - "releasenotes/all-release", - { - "type": "category", - "label": "v3.0", - "items": [ - "releasenotes/v3.0/release-3.0.3", - "releasenotes/v3.0/release-3.0.2", - "releasenotes/v3.0/release-3.0.1", - "releasenotes/v3.0/release-3.0.0" - ] - }, - { - "type": "category", - "label": "v2.1", - "items": [ - "releasenotes/v2.1/release-2.1.7", - "releasenotes/v2.1/release-2.1.6", - "releasenotes/v2.1/release-2.1.5", - "releasenotes/v2.1/release-2.1.4", - "releasenotes/v2.1/release-2.1.3", - "releasenotes/v2.1/release-2.1.2", - "releasenotes/v2.1/release-2.1.1", - "releasenotes/v2.1/release-2.1.0" - ] - }, - { - "type": "category", - "label": "v2.0", - "items": [ - "releasenotes/v2.0/release-2.0.15", - "releasenotes/v2.0/release-2.0.14", - "releasenotes/v2.0/release-2.0.13", - "releasenotes/v2.0/release-2.0.12", - "releasenotes/v2.0/release-2.0.11", - "releasenotes/v2.0/release-2.0.10", - "releasenotes/v2.0/release-2.0.9", - "releasenotes/v2.0/release-2.0.8", - "releasenotes/v2.0/release-2.0.7", - "releasenotes/v2.0/release-2.0.6", - "releasenotes/v2.0/release-2.0.5", - "releasenotes/v2.0/release-2.0.4", - "releasenotes/v2.0/release-2.0.3", - "releasenotes/v2.0/release-2.0.2", - "releasenotes/v2.0/release-2.0.1", - "releasenotes/v2.0/release-2.0.0" - ] - }, { "type": "category", "label": "v1.2", @@ -1300,18 +1253,6 @@ "releasenotes/v1.2/release-1.2.1", "releasenotes/v1.2/release-1.2.0" ] - }, - { - "type": "category", - "label": "v1.1", - "items": [ - "releasenotes/v1.1/release-1.1.5", - "releasenotes/v1.1/release-1.1.4", - "releasenotes/v1.1/release-1.1.3", - "releasenotes/v1.1/release-1.1.2", - "releasenotes/v1.1/release-1.1.1", - "releasenotes/v1.1/release-1.1.0" - ] } ] } diff --git a/versions.json b/versions.json index 6734a84031325..07f5992f18248 100644 --- a/versions.json +++ b/versions.json @@ -1 +1 @@ -["3.0", "2.1", "2.0", "1.2", "current"] \ No newline at end of file +["3.0", "2.1", "2.0", "current"] \ No newline at end of file