You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by yx...@apache.org on 2022/10/28 00:03:14 UTC
[shardingsphere] branch master updated: Optimize `EXPORT` and `IMPORT` of DistSQL (#21793)
This is an automated email from the ASF dual-hosted git repository.
yx9o pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 0b0912e2665 Optimize `EXPORT` and `IMPORT` of DistSQL (#21793)
0b0912e2665 is described below
commit 0b0912e266590278445ea0c1c42d29b1a7eed7f6
Author: Raigor <ra...@gmail.com>
AuthorDate: Fri Oct 28 08:02:58 2022 +0800
Optimize `EXPORT` and `IMPORT` of DistSQL (#21793)
* Optimize some words of DistSQL RAL.
* Update test cases.
---
distsql/parser/src/main/antlr4/imports/Keyword.g4 | 8 ++--
.../parser/src/main/antlr4/imports/RALStatement.g4 | 6 +--
.../ConvertYamlConfigurationStatement.java | 2 +-
.../distsql/syntax/ral/_index.cn.md | 46 +++++++++++-----------
.../distsql/syntax/ral/_index.en.md | 46 +++++++++++-----------
.../src/main/antlr4/imports/migration/Keyword.g4 | 8 ----
.../main/resources/sql/supported/ral/queryable.xml | 4 +-
.../main/resources/sql/supported/ral/updatable.xml | 2 +-
8 files changed, 57 insertions(+), 65 deletions(-)
diff --git a/distsql/parser/src/main/antlr4/imports/Keyword.g4 b/distsql/parser/src/main/antlr4/imports/Keyword.g4
index 96759b944a4..41bc0d83c3a 100644
--- a/distsql/parser/src/main/antlr4/imports/Keyword.g4
+++ b/distsql/parser/src/main/antlr4/imports/Keyword.g4
@@ -63,6 +63,10 @@ FROM
: F R O M
;
+TO
+ : T O
+ ;
+
URL
: U R L
;
@@ -223,10 +227,6 @@ CONFIGURATION
: C O N F I G U R A T I O N
;
-CONFIG
- : C O N F I G
- ;
-
FILE
: F I L E
;
diff --git a/distsql/parser/src/main/antlr4/imports/RALStatement.g4 b/distsql/parser/src/main/antlr4/imports/RALStatement.g4
index 7190c1a8ff0..cbd27d20b10 100644
--- a/distsql/parser/src/main/antlr4/imports/RALStatement.g4
+++ b/distsql/parser/src/main/antlr4/imports/RALStatement.g4
@@ -76,15 +76,15 @@ unlabelComputeNode
;
exportDatabaseConfiguration
- : EXPORT DATABASE (CONFIGURATION | CONFIG) (FROM databaseName)? (COMMA? FILE EQ filePath)?
+ : EXPORT DATABASE CONFIGURATION (FROM databaseName)? (TO FILE filePath)?
;
importDatabaseConfiguration
- : IMPORT DATABASE (CONFIGURATION | CONFIG) FILE EQ filePath
+ : IMPORT DATABASE CONFIGURATION FROM FILE filePath
;
convertYamlConfiguration
- : CONVERT YAML (CONFIGURATION | CONFIG) FILE EQ filePath
+ : CONVERT YAML CONFIGURATION FROM FILE filePath
;
showMigrationRule
diff --git a/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/queryable/ConvertYamlConfigurationStatement.java b/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/queryable/ConvertYamlConfigurationStatement.java
index 247e262e3b6..7863298bcda 100644
--- a/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/queryable/ConvertYamlConfigurationStatement.java
+++ b/distsql/statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/queryable/ConvertYamlConfigurationStatement.java
@@ -22,7 +22,7 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.distsql.parser.statement.ral.QueryableRALStatement;
/**
- * Convert yaml configuration statement.
+ * Convert YAML configuration statement.
*/
@RequiredArgsConstructor
@Getter
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.cn.md
index 0bae60bbb58..53bc2f35274 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.cn.md
@@ -38,12 +38,12 @@ RAL (Resource & Rule Administration Language) 为 Apache ShardingSphere 的管
## 熔断
-| 语句 | 说明 | 示例 |
-|:-----------------------------------------------------------------------------------------------------|:-----------------------------|:-------------------------------------------------------------|
-| ALTER READWRITE_SPLITTING RULE [ groupName ] (ENABLE / DISABLE) storageUnitName [FROM databaseName] | 启用 / 禁用读库 | ALTER READWRITE_SPLITTING RULE group_1 ENABLE read_ds_1 |
-| [ENABLE / DISABLE] COMPUTE NODE instanceId | 启用 / 禁用 proxy 实例 | DISABLE COMPUTE NODE instance_1 |
-| SHOW COMPUTE NODES | 查询 proxy 实例信息 | SHOW COMPUTE NODES |
-| SHOW STATUS FROM READWRITE_SPLITTING (RULES / RULE groupName) [FROM databaseName] | 查询所有读库的状态 | SHOW STATUS FROM READWRITE_SPLITTING RULES |
+| 语句 | 说明 | 示例 |
+|:-----------------------------------------------------------------------------------------------------|:---------------------|:-------------------------------------------------------------|
+| ALTER READWRITE_SPLITTING RULE [ groupName ] (ENABLE / DISABLE) storageUnitName [FROM databaseName] | 启用 / 禁用读库 | ALTER READWRITE_SPLITTING RULE group_1 ENABLE read_ds_1 |
+| [ENABLE / DISABLE] COMPUTE NODE instanceId | 启用 / 禁用 proxy 实例 | DISABLE COMPUTE NODE instance_1 |
+| SHOW COMPUTE NODES | 查询 proxy 实例信息 | SHOW COMPUTE NODES |
+| SHOW STATUS FROM READWRITE_SPLITTING (RULES / RULE groupName) [FROM databaseName] | 查询读写分离数据源状态 | SHOW STATUS FROM READWRITE_SPLITTING RULES |
## 全局规则
@@ -57,23 +57,23 @@ RAL (Resource & Rule Administration Language) 为 Apache ShardingSphere 的管
## 其他
-| 语句 | 说明 | 示例 |
-|:--------------------------------------------------------------------| :-------------------------------------------------------------------------------------------------------------- |:-----------------------------------------------------------|
-| SHOW COMPUTE NODE INFO | 查询当前 proxy 的实例信息 | SHOW COMPUTE NODE INFO |
-| SHOW COMPUTE NODE MODE | 查询当前 proxy 的 mode 配置 | SHOW COMPUTE NODE MODE |
-| SET DIST VARIABLE proxy_property_name = xx | proxy_property_name 为 proxy 的[属性配置](/cn/user-manual/shardingsphere-proxy/yaml-config/props/),需使用下划线命名 | SET DIST VARIABLE sql_show = true |
-| SET DIST VARIABLE transaction_type = xx | 修改当前连接的事务类型, 支持 LOCAL,XA,BASE | SET DIST VARIABLE transaction_type = "XA" |
-| SET DIST VARIABLE agent_plugins_enabled = [TRUE / FALSE] | 设置 agent 插件的启用状态,默认值 false | SET DIST VARIABLE agent_plugins_enabled = TRUE |
-| SHOW DIST VARIABLES | 查询 proxy 所有的属性配置 | SHOW DIST VARIABLES |
-| SHOW DIST VARIABLE WHERE name = variable_name | 查询 proxy 属性,需使用下划线命名 | SHOW DIST VARIABLE WHERE name = sql_show |
-| REFRESH TABLE METADATA | 刷新所有表的元数据 | REFRESH TABLE METADATA |
-| REFRESH TABLE METADATA tableName | 刷新指定表的元数据 | REFRESH TABLE METADATA t_order |
-| REFRESH TABLE METADATA tableName FROM RESOURCE resourceName | 刷新指定数据源中表的元数据 | REFRESH TABLE METADATA t_order FROM RESOURCE ds_1 |
-| REFRESH TABLE METADATA FROM RESOURCE resourceName SCHEMA schemaName | 刷新指定 schema 中表的元数据,如果 schema 中不存在表,则会删除该 schema | REFRESH TABLE METADATA FROM RESOURCE ds_1 SCHEMA db_schema |
-| SHOW TABLE METADATA tableName [, tableName] ... | 查询表的元数据 | SHOW TABLE METADATA t_order |
-| EXPORT DATABASE CONFIG [FROM database_name] [, file="file_path"] | 将 database 中的资源和规则配置导出为 YAML 格式 | EXPORT DATABASE CONFIG FROM readwrite_splitting_db |
-| IMPORT DATABASE CONFIG FILE="file_path" | 将 YAML 中的配置导入到 database 中,仅支持对空库进行导入操作 | IMPORT DATABASE CONFIG FILE = "/xxx/config-sharding.yaml" |
-| SHOW RULES USED RESOURCE resourceName [from database] | 查询 database 中使用指定资源的规则 | SHOW RULES USED RESOURCE ds_0 FROM databaseName |
+| 语句 | 说明 | 示例 |
+|:---------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------|
+| SHOW COMPUTE NODE INFO | 查询当前 proxy 的实例信息 | SHOW COMPUTE NODE INFO |
+| SHOW COMPUTE NODE MODE | 查询当前 proxy 的 mode 配置 | SHOW COMPUTE NODE MODE |
+| SET DIST VARIABLE proxy_property_name = xx | proxy_property_name 为 proxy 的[属性配置](/cn/user-manual/shardingsphere-proxy/yaml-config/props/),需使用下划线命名 | SET DIST VARIABLE sql_show = true |
+| SET DIST VARIABLE transaction_type = xx | 修改当前连接的事务类型, 支持 LOCAL,XA,BASE | SET DIST VARIABLE transaction_type = "XA" |
+| SET DIST VARIABLE agent_plugins_enabled = [TRUE / FALSE] | 设置 agent 插件的启用状态,默认值 false | SET DIST VARIABLE agent_plugins_enabled = TRUE |
+| SHOW DIST VARIABLES | 查询 proxy 所有的属性配置 | SHOW DIST VARIABLES |
+| SHOW DIST VARIABLE WHERE name = variable_name | 查询 proxy 属性,需使用下划线命名 | SHOW DIST VARIABLE WHERE name = sql_show |
+| REFRESH TABLE METADATA | 刷新所有表的元数据 | REFRESH TABLE METADATA |
+| REFRESH TABLE METADATA tableName | 刷新指定表的元数据 | REFRESH TABLE METADATA t_order |
+| REFRESH TABLE METADATA tableName FROM STORAGE UNIT storageUnitName | 刷新指定数据源中表的元数据 | REFRESH TABLE METADATA t_order FROM STORAGE UNIT ds_1 |
+| REFRESH TABLE METADATA FROM STORAGE UNIT storageUnitName SCHEMA schemaName | 刷新指定 schema 中表的元数据,如果 schema 中不存在表,则会删除该 schema | REFRESH TABLE METADATA FROM STORAGE UNIT ds_1 SCHEMA db_schema |
+| SHOW TABLE METADATA tableName [, tableName] ... | 查询表的元数据 | SHOW TABLE METADATA t_order |
+| EXPORT DATABASE CONFIGURATION [FROM databaseName] [TO FILE "filePath"] | 将 database 中的数据源和规则配置导出为 YAML 格式 | EXPORT DATABASE CONFIGURATION TO FILE "/xxx/config-sharding.yaml" |
+| IMPORT DATABASE CONFIGURATION FROM FILE "filePath" | 将 YAML 中的配置导入到 database 中,仅支持对空库进行导入操作 | IMPORT DATABASE CONFIGURATION FROM FILE "/xxx/config-sharding.yaml" |
+| SHOW RULES USED STORAGE UNIT storageUnitName [FROM databaseName] | 查询 database 中使用指定数据源的规则 | SHOW RULES USED STORAGE UNIT ds_0 FROM databaseName |
## 注意事项
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.en.md b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.en.md
index 23f5627eaef..969e3695d1a 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.en.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/distsql/syntax/ral/_index.en.md
@@ -38,12 +38,12 @@ RAL (Resource & Rule Administration Language) responsible for hint, circuit brea
## Circuit Breaker
-| Statement | Function | Example |
-|:----------------------------------------------------------------------------------------------------|:-----------------------------------|:---------------------------------------------------------|
-| ALTER READWRITE_SPLITTING RULE [ groupName ] (ENABLE / DISABLE) storageUnitName [FROM databaseName] | Enable or disable read data source | ALTER READWRITE_SPLITTING RULE group_1 ENABLE read_ds_1 |
-| [ENABLE / DISABLE] COMPUTE NODE instanceId | Enable or disable proxy instance | DISABLE COMPUTE NODE instance_1 |
-| SHOW COMPUTE NODES | Query proxy instance information | SHOW COMPUTE NODES |
-| SHOW STATUS FROM READWRITE_SPLITTING (RULES / RULE groupName) [FROM databaseName] | Query all read resources status | SHOW STATUS FROM READWRITE_SPLITTING RULES |
+| Statement | Function | Example |
+|:----------------------------------------------------------------------------------------------------|:--------------------------------------------------------|:---------------------------------------------------------|
+| ALTER READWRITE_SPLITTING RULE [ groupName ] (ENABLE / DISABLE) storageUnitName [FROM databaseName] | Enable or disable read data source | ALTER READWRITE_SPLITTING RULE group_1 ENABLE read_ds_1 |
+| [ENABLE / DISABLE] COMPUTE NODE instanceId | Enable or disable proxy instance | DISABLE COMPUTE NODE instance_1 |
+| SHOW COMPUTE NODES | Query proxy instance information | SHOW COMPUTE NODES |
+| SHOW STATUS FROM READWRITE_SPLITTING (RULES / RULE groupName) [FROM databaseName] | Query data sources status of readwrite splitting groups | SHOW STATUS FROM READWRITE_SPLITTING RULES |
## Global Rule
@@ -57,23 +57,23 @@ RAL (Resource & Rule Administration Language) responsible for hint, circuit brea
## Other
-| Statement | Function | Example |
-|:---------------------------------------------------------------------------| :------------------------------------------------------------------------------------------------------------------------------------------------------ |:------------------------------------------------------------------|
-| SHOW COMPUTE NODE INFO | Query the instance information of the proxy | SHOW COMPUTE NODE INFO |
-| SHOW COMPUTE NODE MODE | Query the mode configuration of the proxy | SHOW COMPUTE NODE MODE |
-| SET DIST VARIABLE proxy_property_name = xx | proxy_property_name is one of [properties configuration](/en/user-manual/shardingsphere-proxy/yaml-config/props/) of proxy, name is split by underscore | SET DIST VARIABLE sql_show = true |
-| SET DIST VARIABLE transaction_type = xx | Modify transaction_type of the current connection, supports LOCAL, XA, BASE | SET DIST VARIABLE transaction_type = "XA" |
-| SET DIST VARIABLE agent_plugins_enabled = [TRUE / FALSE] | Set whether the agent plugins are enabled, the default value is false | SET DIST VARIABLE agent_plugins_enabled = TRUE |
-| SHOW DIST VARIABLES | Query proxy all properties configuration | SHOW DIST VARIABLES |
-| SHOW DIST VARIABLE WHERE name = variable_name | Query proxy variable, name is split by underscore | SHOW DIST VARIABLE WHERE name = sql_show |
-| REFRESH TABLE METADATA | Refresh the metadata of all tables | REFRESH TABLE METADATA |
-| REFRESH TABLE METADATA tableName | Refresh the metadata of the specified table | REFRESH TABLE METADATA t_order |
-| REFRESH TABLE METADATA tableName FROM RESOURCE resourceName | Refresh the tables' metadata in the specified data source | REFRESH TABLE METADATA t_order FROM RESOURCE ds_1 |
-| REFRESH TABLE METADATA FROM RESOURCE resourceName SCHEMA schemaName | Refresh the tables' metadata in a schema of a specified data source. If there are no tables in the schema, the schema will be deleted. | REFRESH TABLE METADATA FROM RESOURCE ds_1 SCHEMA db_schema |
-| SHOW TABLE METADATA tableName [, tableName] ... | Query table metadata | SHOW TABLE METADATA t_order |
-| EXPORT DATABASE CONFIG [FROM database_name] [, file="file_path"] | Export resources and rule configurations to YAML format | EXPORT DATABASE CONFIG FROM readwrite_splitting_db |
-| IMPORT DATABASE CONFIG FILE="file_path" | Import resources and rule configuration from YAML, only supports import into an empty database | IMPORT DATABASE CONFIG FILE = "/xxx/config-sharding.yaml" |
-| SHOW RULES USED RESOURCE resourceName [from database] | Query the rules for using the specified resource in database | SHOW RULES USED RESOURCE ds_0 FROM databaseName |
+| Statement | Function | Example |
+|:----------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------|
+| SHOW COMPUTE NODE INFO | Query the instance information of the proxy | SHOW COMPUTE NODE INFO |
+| SHOW COMPUTE NODE MODE | Query the mode configuration of the proxy | SHOW COMPUTE NODE MODE |
+| SET DIST VARIABLE proxy_property_name = xx | proxy_property_name is one of [properties configuration](/en/user-manual/shardingsphere-proxy/yaml-config/props/) of proxy, name is split by underscore | SET DIST VARIABLE sql_show = true |
+| SET DIST VARIABLE transaction_type = xx | Modify transaction_type of the current connection, supports LOCAL, XA, BASE | SET DIST VARIABLE transaction_type = "XA" |
+| SET DIST VARIABLE agent_plugins_enabled = [TRUE / FALSE] | Set whether the agent plugins are enabled, the default value is false | SET DIST VARIABLE agent_plugins_enabled = TRUE |
+| SHOW DIST VARIABLES | Query proxy all properties configuration | SHOW DIST VARIABLES |
+| SHOW DIST VARIABLE WHERE name = variable_name | Query proxy variable, name is split by underscore | SHOW DIST VARIABLE WHERE name = sql_show |
+| REFRESH TABLE METADATA | Refresh the metadata of all tables | REFRESH TABLE METADATA |
+| REFRESH TABLE METADATA tableName | Refresh the metadata of the specified table | REFRESH TABLE METADATA t_order |
+| REFRESH TABLE METADATA tableName FROM STORAGE UNIT storageUnitName | Refresh the tables' metadata in the specified data source | REFRESH TABLE METADATA t_order FROM STORAGE UNIT ds_1 |
+| REFRESH TABLE METADATA FROM STORAGE UNIT storageUnitName SCHEMA schemaName | Refresh the tables' metadata in a schema of a specified data source. If there are no tables in the schema, the schema will be deleted. | REFRESH TABLE METADATA FROM STORAGE UNIT ds_1 SCHEMA db_schema |
+| SHOW TABLE METADATA tableName [, tableName] ... | Query table metadata | SHOW TABLE METADATA t_order |
+| EXPORT DATABASE CONFIGURATION [FROM databaseName] [TO FILE "filePath"] | Export data sources and rule configurations to YAML format | EXPORT DATABASE CONFIGURATION FROM readwrite_splitting_db |
+| IMPORT DATABASE CONFIGURATION FILE="file_path" | Import data sources and rule configurations from YAML, only supports import into an empty database | IMPORT DATABASE CONFIGURATION FILE = "/xxx/config-sharding.yaml" |
+| SHOW RULES USED STORAGE UNIT storageUnitName [FROM databaseName] | Query the rules for using the specified data source in database | SHOW RULES USED STORAGE UNIT ds_0 FROM databaseName |
## Notice
diff --git a/features/sharding/distsql/parser/src/main/antlr4/imports/migration/Keyword.g4 b/features/sharding/distsql/parser/src/main/antlr4/imports/migration/Keyword.g4
index aaa3cd1066b..f058f01f2d0 100644
--- a/features/sharding/distsql/parser/src/main/antlr4/imports/migration/Keyword.g4
+++ b/features/sharding/distsql/parser/src/main/antlr4/imports/migration/Keyword.g4
@@ -167,14 +167,6 @@ ADD
: A D D
;
-RESOURCE
- : R E S O U R C E
- ;
-
-RESOURCES
- : R E S O U R C E S
- ;
-
REGISTER
: R E G I S T E R
;
diff --git a/test/parser/src/main/resources/sql/supported/ral/queryable.xml b/test/parser/src/main/resources/sql/supported/ral/queryable.xml
index dc0cc8a4738..f1d3ffbf772 100644
--- a/test/parser/src/main/resources/sql/supported/ral/queryable.xml
+++ b/test/parser/src/main/resources/sql/supported/ral/queryable.xml
@@ -34,6 +34,6 @@
<distsql-case id="show-compute-node-info" value="SHOW COMPUTE NODE INFO" />
<distsql-case id="show-compute-node-mode" value="SHOW COMPUTE NODE MODE" />
- <distsql-case id="export-database-config" value="EXPORT DATABASE CONFIG FROM database_name" />
- <distsql-case id="convert-yaml-config" value="CONVERT YAML CONFIG FILE='/yaml/config-resource.yaml'" />
+ <distsql-case id="export-database-config" value="EXPORT DATABASE CONFIGURATION FROM database_name" />
+ <distsql-case id="convert-yaml-config" value="CONVERT YAML CONFIGURATION FROM FILE '/yaml/config-resource.yaml'" />
</sql-cases>
diff --git a/test/parser/src/main/resources/sql/supported/ral/updatable.xml b/test/parser/src/main/resources/sql/supported/ral/updatable.xml
index 9feabf3ce78..02a57ddbb4a 100644
--- a/test/parser/src/main/resources/sql/supported/ral/updatable.xml
+++ b/test/parser/src/main/resources/sql/supported/ral/updatable.xml
@@ -45,5 +45,5 @@
<distsql-case id="apply-distsql" value="APPLY DISTSQL" />
<distsql-case id="discard-distsql" value="DISCARD DISTSQL" />
- <distsql-case id="import-database-config" value="IMPORT DATABASE CONFIG FILE='/yaml/config-sharding.yaml'" />
+ <distsql-case id="import-database-config" value="IMPORT DATABASE CONFIGURATION FROM FILE '/yaml/config-sharding.yaml'" />
</sql-cases>