Skip to content

Commit

Permalink
Fix RDL parser test for hint sharding strategy (#30478)
Browse files Browse the repository at this point in the history
  • Loading branch information
RaigorJiang authored Mar 13, 2024
1 parent 494b54d commit 19527a4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions test/it/parser/src/main/resources/case/rdl/alter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@
<alter-sharding-table-rule sql-case-id="alter-sharding-table-rule-with-none-table-strategy-and-hint-database-strategy">
<rule name="t_order_item">
<data-node>ds_${0..1}.t_order_item_${0..1}</data-node>
<database-strategy type="hint" sharding-column="user_id">
<database-strategy type="hint">
<algorithm-segment algorithm-name="hint_inline">
<property key="algorithm-expression" value="t_order_${user_id % 2}" />
<property key="algorithm-expression" value="t_order_${value % 2}" />
</algorithm-segment>
</database-strategy>
<table-strategy type="none" />
Expand Down Expand Up @@ -320,9 +320,9 @@
</alter-default-sharding-strategy>

<alter-default-sharding-strategy sql-case-id="alter-default-sharding-table-strategy-with-hint-strategy-type">
<strategy default-type="TABLE" strategy-type="hint" sharding-column="user_id">
<strategy default-type="TABLE" strategy-type="hint">
<algorithm-segment algorithm-name="HINT_INLINE">
<property key="algorithm-expression" value="t_order_${user_id % 2}" />
<property key="algorithm-expression" value="t_order_${value % 2}" />
</algorithm-segment>
</strategy>
</alter-default-sharding-strategy>
Expand All @@ -340,9 +340,9 @@
</alter-default-sharding-strategy>

<alter-default-sharding-strategy sql-case-id="alter-default-sharding-database-strategy-with-hint-strategy-type">
<strategy default-type="DATABASE" strategy-type="hint" sharding-column="user_id">
<strategy default-type="DATABASE" strategy-type="hint">
<algorithm-segment algorithm-name="HINT_INLINE">
<property key="algorithm-expression" value="t_order_${user_id % 2}" />
<property key="algorithm-expression" value="t_order_${value % 2}" />
</algorithm-segment>
</strategy>
</alter-default-sharding-strategy>
Expand Down
12 changes: 6 additions & 6 deletions test/it/parser/src/main/resources/case/rdl/create.xml
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,9 @@
</create-default-sharding-strategy>

<create-default-sharding-strategy sql-case-id="create-default-sharding-table-strategy-with-hint-strategy-type">
<strategy default-type="TABLE" strategy-type="hint" sharding-column="user_id">
<strategy default-type="TABLE" strategy-type="hint">
<algorithm-segment algorithm-name="HINT_INLINE">
<property key="algorithm-expression" value="t_order_${user_id % 2}" />
<property key="algorithm-expression" value="t_order_${value % 2}" />
</algorithm-segment>
</strategy>
</create-default-sharding-strategy>
Expand All @@ -595,9 +595,9 @@
</create-default-sharding-strategy>

<create-default-sharding-strategy sql-case-id="create-default-sharding-database-strategy-with-hint-strategy-type">
<strategy default-type="DATABASE" strategy-type="hint" sharding-column="user_id">
<strategy default-type="DATABASE" strategy-type="hint">
<algorithm-segment algorithm-name="HINT_INLINE">
<property key="algorithm-expression" value="t_order_${user_id % 2}" />
<property key="algorithm-expression" value="t_order_${value % 2}" />
</algorithm-segment>
</strategy>
</create-default-sharding-strategy>
Expand Down Expand Up @@ -663,9 +663,9 @@
<create-sharding-table-rule sql-case-id="create-sharding-table-rule-with-none-table-strategy-and-hint-database-strategy">
<rule name="t_order_item">
<data-node>ds_${0..1}.t_order_item_${0..1}</data-node>
<database-strategy type="hint" sharding-column="user_id">
<database-strategy type="hint">
<algorithm-segment algorithm-name="hint_inline">
<property key="algorithm-expression" value="t_order_${user_id % 2}" />
<property key="algorithm-expression" value="t_order_${value % 2}" />
</algorithm-segment>
</database-strategy>
<table-strategy type="none" />
Expand Down
6 changes: 3 additions & 3 deletions test/it/parser/src/main/resources/sql/supported/rdl/alter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
<sql-case id="alter-sharding-table-rule-complex" value="ALTER SHARDING TABLE RULE t_order (DATANODES('ms_group_${0..1}_${0..1}.t_order_${0..1}'),DATABASE_STRATEGY(TYPE='complex',sharding_columns=order_id,user_id, sharding_algorithm(type(name='INLINE',PROPERTIES('algorithm-expression'='ms_group_${order_id % 2}_${user_id % 2}')))),TABLE_STRATEGY(TYPE='standard',sharding_column=user_id,sharding_algorithm(type(name='INLINE',PROPERTIES('algorithm-expression'='t_order_${user_id % 2}')))),KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME='snowflake')))" db-types="ShardingSphere" />
<sql-case id="alter-sharding-table-rule-with-auditor" value="ALTER SHARDING TABLE RULE t_order (DATANODES('ms_group_${0..1}.t_order_${0..1}'),DATABASE_STRATEGY(TYPE='standard',sharding_column=order_id,sharding_algorithm(type(name='INLINE',PROPERTIES('algorithm-expression'='ms_group_${order_id % 2}')))),TABLE_STRATEGY(TYPE='standard',sharding_column=user_id,sharding_algorithm(type(name='INLINE',PROPERTIES('algorithm-expression'='t_order_${user_id % 2}')))),KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME='snowflake')), AUDIT_STRATEGY(TYPE(NAME='DML_SHARDING_CONDITIONS'),ALLOW_HINT_DISABLE=true))" db-types="ShardingSphere" />
<sql-case id="alter-sharding-table-rule-with-complex-table-strategy-and-standard-database-strategy" value="ALTER SHARDING TABLE RULE t_order_item (DATANODES('ds_${0..1}.t_order_item_${0..1}'), DATABASE_STRATEGY(TYPE='standard',SHARDING_COLUMN=user_id,SHARDING_ALGORITHM(TYPE(NAME='inline',PROPERTIES('algorithm-expression'='ds_${user_id % 2}')))), TABLE_STRATEGY(TYPE='complex',SHARDING_COLUMNS=user_id,order_id,SHARDING_ALGORITHM(TYPE(NAME='complex_inline',PROPERTIES('algorithm-expression'='t_order_item_${user_id % 2}_${order_id % 2}')))));" db-types="ShardingSphere" />
<sql-case id="alter-sharding-table-rule-with-none-table-strategy-and-hint-database-strategy" value="ALTER SHARDING TABLE RULE t_order_item (DATANODES('ds_${0..1}.t_order_item_${0..1}'), DATABASE_STRATEGY(TYPE='hint',SHARDING_COLUMN=user_id,SHARDING_ALGORITHM(TYPE(NAME='hint_inline',PROPERTIES('algorithm-expression'='ds_${user_id % 2}')))), TABLE_STRATEGY(TYPE='none'));" db-types="ShardingSphere" />
<sql-case id="alter-sharding-table-rule-with-none-table-strategy-and-hint-database-strategy" value="ALTER SHARDING TABLE RULE t_order_item (DATANODES('ds_${0..1}.t_order_item_${0..1}'), DATABASE_STRATEGY(TYPE='hint',SHARDING_ALGORITHM(TYPE(NAME='hint_inline',PROPERTIES('algorithm-expression'='ds_${value % 2}')))), TABLE_STRATEGY(TYPE='none'));" db-types="ShardingSphere" />
<sql-case id="alter-default-sharding-strategy" value="ALTER DEFAULT SHARDING TABLE STRATEGY(TYPE='standard', SHARDING_COLUMN=order_id, SHARDING_ALGORITHM(TYPE(NAME='INLINE',PROPERTIES('algorithm-expression'='t_order_${order_id % 2}'))))" db-types="ShardingSphere" />
<sql-case id="alter-default-sharding-table-strategy-with-complex-strategy-type" value="ALTER DEFAULT SHARDING TABLE STRATEGY (TYPE='complex', SHARDING_COLUMNS=user_id,order_id, SHARDING_ALGORITHM(TYPE(NAME=COMPLEX_INLINE, PROPERTIES('algorithm-expression'='t_order_${user_id % 2}_${order_id % 2}'))));" db-types="ShardingSphere" />
<sql-case id="alter-default-sharding-table-strategy-with-hint-strategy-type" value="ALTER DEFAULT SHARDING TABLE STRATEGY (TYPE='hint', SHARDING_COLUMN=user_id, SHARDING_ALGORITHM(TYPE(NAME=HINT_INLINE, PROPERTIES('algorithm-expression'='t_order_${user_id % 2}'))));" db-types="ShardingSphere" />
<sql-case id="alter-default-sharding-table-strategy-with-hint-strategy-type" value="ALTER DEFAULT SHARDING TABLE STRATEGY (TYPE='hint', SHARDING_ALGORITHM(TYPE(NAME=HINT_INLINE, PROPERTIES('algorithm-expression'='t_order_${value % 2}'))));" db-types="ShardingSphere" />
<sql-case id="alter-default-sharding-table-strategy-with-none-strategy-type" value="ALTER DEFAULT SHARDING TABLE STRATEGY (TYPE='none');" db-types="ShardingSphere" />
<sql-case id="alter-default-sharding-database-strategy-with-complex-strategy-type" value="ALTER DEFAULT SHARDING DATABASE STRATEGY (TYPE='complex', SHARDING_COLUMNS=user_id,order_id, SHARDING_ALGORITHM(TYPE(NAME=COMPLEX_INLINE, PROPERTIES('algorithm-expression'='t_order_${user_id % 2}_${order_id % 2}'))));" db-types="ShardingSphere" />
<sql-case id="alter-default-sharding-database-strategy-with-hint-strategy-type" value="ALTER DEFAULT SHARDING DATABASE STRATEGY (TYPE='hint', SHARDING_COLUMN=user_id, SHARDING_ALGORITHM(TYPE(NAME=HINT_INLINE, PROPERTIES('algorithm-expression'='t_order_${user_id % 2}'))));" db-types="ShardingSphere" />
<sql-case id="alter-default-sharding-database-strategy-with-hint-strategy-type" value="ALTER DEFAULT SHARDING DATABASE STRATEGY (TYPE='hint', SHARDING_ALGORITHM(TYPE(NAME=HINT_INLINE, PROPERTIES('algorithm-expression'='t_order_${value % 2}'))));" db-types="ShardingSphere" />
<sql-case id="alter-default-sharding-database-strategy-with-none-strategy-type" value="ALTER DEFAULT SHARDING DATABASE STRATEGY (TYPE='none');" db-types="ShardingSphere" />
<sql-case id="alter-mask-rule" value="ALTER MASK RULE t_mask (COLUMNS((NAME=phone_number,TYPE(NAME='MASK_FROM_X_TO_Y', PROPERTIES('from-x'=1, 'to-y'=2, 'replace-char'='*'))), (NAME=address,TYPE(NAME=MD5))));" db-types="ShardingSphere" />
</sql-cases>
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@
<sql-case id="create-default-sharding-table-strategy-with-lower-case" value="create default sharding table strategy(type='standard', sharding_column=order_id, SHARDING_ALGORITHM(TYPE(NAME='INLINE',PROPERTIES('algorithm-expression'='t_order_${order_id % 2}'))))" db-types="ShardingSphere" />
<sql-case id="create-default-sharding-table-strategy-if-not-exists-with-lower-case" value="create default sharding table strategy if not exists(type='standard', sharding_column=order_id, SHARDING_ALGORITHM(TYPE(NAME='INLINE',PROPERTIES('algorithm-expression'='t_order_${order_id % 2}'))))" db-types="ShardingSphere" />
<sql-case id="create-default-sharding-table-strategy-with-complex-strategy-type" value="CREATE DEFAULT SHARDING TABLE STRATEGY (TYPE='complex', SHARDING_COLUMNS=user_id,order_id, SHARDING_ALGORITHM(TYPE(NAME=COMPLEX_INLINE, PROPERTIES('algorithm-expression'='${user_id % 2}_${order_id % 2}'))));" db-types="ShardingSphere" />
<sql-case id="create-default-sharding-table-strategy-with-hint-strategy-type" value="CREATE DEFAULT SHARDING TABLE STRATEGY (TYPE='hint', SHARDING_COLUMN=user_id, SHARDING_ALGORITHM(TYPE(NAME=HINT_INLINE, PROPERTIES('algorithm-expression'='t_order_${user_id % 2}'))));" db-types="ShardingSphere" />
<sql-case id="create-default-sharding-table-strategy-with-hint-strategy-type" value="CREATE DEFAULT SHARDING TABLE STRATEGY (TYPE='hint', SHARDING_ALGORITHM(TYPE(NAME=HINT_INLINE, PROPERTIES('algorithm-expression'='t_order_${value % 2}'))));" db-types="ShardingSphere" />
<sql-case id="create-default-sharding-table-strategy-with-none-strategy-type" value="CREATE DEFAULT SHARDING TABLE STRATEGY (TYPE='none');" db-types="ShardingSphere" />
<sql-case id="create-default-sharding-database-strategy-with-complex-strategy-type" value="CREATE DEFAULT SHARDING DATABASE STRATEGY (TYPE='complex', SHARDING_COLUMNS=user_id,order_id, SHARDING_ALGORITHM(TYPE(NAME=COMPLEX_INLINE, PROPERTIES('algorithm-expression'='t_order_${user_id % 2}_${order_id % 2}'))));" db-types="ShardingSphere" />
<sql-case id="create-default-sharding-database-strategy-with-hint-strategy-type" value="CREATE DEFAULT SHARDING DATABASE STRATEGY (TYPE='hint', SHARDING_COLUMN=user_id, SHARDING_ALGORITHM(TYPE(NAME=HINT_INLINE, PROPERTIES('algorithm-expression'='t_order_${user_id % 2}'))));" db-types="ShardingSphere" />
<sql-case id="create-default-sharding-database-strategy-with-hint-strategy-type" value="CREATE DEFAULT SHARDING DATABASE STRATEGY (TYPE='hint', SHARDING_ALGORITHM(TYPE(NAME=HINT_INLINE, PROPERTIES('algorithm-expression'='t_order_${value % 2}'))));" db-types="ShardingSphere" />
<sql-case id="create-default-sharding-database-strategy-with-none-strategy-type" value="CREATE DEFAULT SHARDING DATABASE STRATEGY (TYPE='none');" db-types="ShardingSphere" />
<sql-case id="create-default-sharding-database-strategy" value="CREATE DEFAULT SHARDING DATABASE STRATEGY(TYPE='STANDARD', SHARDING_COLUMN=ORDER_ID, SHARDING_ALGORITHM(TYPE(NAME='INLINE',PROPERTIES('algorithm-expression'='ms_group_${order_id % 2}'))))" db-types="ShardingSphere" />
<sql-case id="create-default-sharding-database-strategy-if-not-exists" value="CREATE DEFAULT SHARDING DATABASE STRATEGY IF NOT EXISTS (TYPE='STANDARD', SHARDING_COLUMN=ORDER_ID, SHARDING_ALGORITHM(TYPE(NAME='INLINE',PROPERTIES('algorithm-expression'='ms_group_${order_id % 2}'))))" db-types="ShardingSphere" />
<sql-case id="create-sharding-table-rule" value="CREATE SHARDING TABLE RULE t_order (DATANODES('ms_group_${0..1}.t_order_${0..1}'),DATABASE_STRATEGY(TYPE='standard',sharding_column=order_id,sharding_algorithm(type(name='INLINE',PROPERTIES('algorithm-expression'='ms_group_${order_id % 2}')))),TABLE_STRATEGY(TYPE='standard',sharding_column=user_id,sharding_algorithm(type(name='INLINE',PROPERTIES('algorithm-expression'='t_order_${user_id % 2}')))),KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME='snowflake'))),t_order_item (DATANODES('ms_group_${0..1}.t_order_item_${0..1}'),DATABASE_STRATEGY(TYPE='standard',sharding_column=order_id,sharding_algorithm(type(name='INLINE',PROPERTIES('algorithm-expression'='ms_group_${order_id % 2}')))),TABLE_STRATEGY(TYPE='standard',sharding_column=user_id,sharding_algorithm(type(name='INLINE',PROPERTIES('algorithm-expression'='t_order_item_${user_id % 2}')))))" db-types="ShardingSphere" />
<sql-case id="create-sharding-table-rule-with-enum-inline-expression" value="CREATE SHARDING TABLE RULE t_order (DATANODES(&quot;ms_group_${['abc','ac']}.t_order_${0..1}&quot;),DATABASE_STRATEGY(TYPE='standard',sharding_column=order_name,sharding_algorithm(type(name='INLINE',PROPERTIES('algorithm-expression'='ms_group_{order_name}')))),TABLE_STRATEGY(TYPE='standard',sharding_column=user_id,sharding_algorithm(type(name='INLINE',PROPERTIES('algorithm-expression'='t_order_${user_id % 2}')))),KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME='snowflake'))),t_order_item (DATANODES('ms_group_${0..1}.t_order_item_${0..1}'),DATABASE_STRATEGY(TYPE='standard',sharding_column=order_id,sharding_algorithm(type(name='INLINE',PROPERTIES('algorithm-expression'='ms_group_$${order_id % 2}')))),TABLE_STRATEGY(TYPE='standard',sharding_column=user_id,sharding_algorithm(type(name='INLINE',PROPERTIES('algorithm-expression'='t_order_item_${user_id % 2}')))))" db-types="ShardingSphere" />
<sql-case id="create-sharding-table-rule-complex" value="CREATE SHARDING TABLE RULE t_order (DATANODES('ms_group_${0..1}_${0..1}.t_order_${0..1}'),DATABASE_STRATEGY(TYPE='complex',sharding_columns=order_id,user_id,sharding_algorithm(type(name='INLINE',PROPERTIES('algorithm-expression'='ms_group_${order_id % 2}_${user_id % 2}')))),TABLE_STRATEGY(TYPE='standard',sharding_column=user_id,sharding_algorithm(type(name='INLINE',PROPERTIES('algorithm-expression'='t_order_${user_id % 2}')))),KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME='snowflake'))),t_order_item (DATANODES('ms_group_${0..1}.t_order_item_${0..1}'),DATABASE_STRATEGY(TYPE='standard',sharding_column=order_id,sharding_algorithm(type(name='INLINE',PROPERTIES('algorithm-expression'='ms_group_$${order_id % 2}')))),TABLE_STRATEGY(TYPE='standard',sharding_column=user_id,sharding_algorithm(type(name='INLINE',PROPERTIES('algorithm-expression'='t_order_item_${user_id % 2}')))))" db-types="ShardingSphere" />
<sql-case id="create-sharding-table-rule-with-complex-table-strategy-and-standard-database-strategy" value="CREATE SHARDING TABLE RULE t_order_item (DATANODES('ds_${0..1}.t_order_item_${0..1}'), DATABASE_STRATEGY(TYPE='standard',SHARDING_COLUMN=user_id,SHARDING_ALGORITHM(TYPE(NAME='inline',PROPERTIES('algorithm-expression'='ds_${user_id % 2}')))), TABLE_STRATEGY(TYPE='complex',SHARDING_COLUMNS=user_id,order_id,SHARDING_ALGORITHM(TYPE(NAME='complex_inline',PROPERTIES('algorithm-expression'='t_order_item_${user_id % 2}_${order_id % 2}')))));" db-types="ShardingSphere" />
<sql-case id="create-sharding-table-rule-with-none-table-strategy-and-hint-database-strategy" value="CREATE SHARDING TABLE RULE t_order_item (DATANODES('ds_${0..1}.t_order_item_${0..1}'), DATABASE_STRATEGY(TYPE='hint',SHARDING_COLUMN=user_id,SHARDING_ALGORITHM(TYPE(NAME='hint_inline',PROPERTIES('algorithm-expression'='ds_${user_id % 2}')))), TABLE_STRATEGY(TYPE='none'));" db-types="ShardingSphere" />
<sql-case id="create-sharding-table-rule-with-none-table-strategy-and-hint-database-strategy" value="CREATE SHARDING TABLE RULE t_order_item (DATANODES('ds_${0..1}.t_order_item_${0..1}'), DATABASE_STRATEGY(TYPE='hint',SHARDING_ALGORITHM(TYPE(NAME='hint_inline',PROPERTIES('algorithm-expression'='ds_${value % 2}')))), TABLE_STRATEGY(TYPE='none'));" db-types="ShardingSphere" />
<sql-case id="create-sharding-table-rule-with-auto-create-algorithm" value="CREATE SHARDING TABLE RULE t_order (DATANODES('ms_group_${0..1}.t_order_${0..1}'),DATABASE_STRATEGY(TYPE='standard',sharding_column=order_id,sharding_algorithm(TYPE(NAME='INLINE',PROPERTIES('algorithm-expression'='ms_group_${order_id % 2}')))),TABLE_STRATEGY(TYPE='standard',sharding_column=user_id,sharding_algorithm(type(name='INLINE',PROPERTIES('algorithm-expression'='t_order_${user_id % 2}')))),KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME='snowflake')))" db-types="ShardingSphere" />
<sql-case id="create-sharding-table-rule-with-auditor" value="CREATE SHARDING TABLE RULE t_order (DATANODES('ms_group_${0..1}.t_order_${0..1}'),DATABASE_STRATEGY(TYPE='standard',sharding_column=order_id,sharding_algorithm(TYPE(NAME='INLINE',PROPERTIES('algorithm-expression'='ms_group_${order_id % 2}')))),TABLE_STRATEGY(TYPE='standard',sharding_column=user_id,sharding_algorithm(type(name='INLINE',PROPERTIES('algorithm-expression'='t_order_${user_id % 2}')))),KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME='snowflake')), AUDIT_STRATEGY(TYPE(NAME='DML_SHARDING_CONDITIONS'),TYPE(NAME='DML_SHARDING_CONDITIONS'),ALLOW_HINT_DISABLE=true))" db-types="ShardingSphere" />
<sql-case id="create-sharding-table-rule-with-auditor-if-not-exists" value="CREATE SHARDING TABLE RULE IF NOT EXISTS t_order (DATANODES('ms_group_${0..1}.t_order_${0..1}'),DATABASE_STRATEGY(TYPE='standard',sharding_column=order_id,sharding_algorithm(TYPE(NAME='INLINE',PROPERTIES('algorithm-expression'='ms_group_${order_id % 2}')))),TABLE_STRATEGY(TYPE='standard',sharding_column=user_id,sharding_algorithm(type(name='INLINE',PROPERTIES('algorithm-expression'='t_order_${user_id % 2}')))),KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME='snowflake')), AUDIT_STRATEGY(TYPE(NAME='DML_SHARDING_CONDITIONS'),TYPE(NAME='DML_SHARDING_CONDITIONS'),ALLOW_HINT_DISABLE=true))" db-types="ShardingSphere" />
Expand Down

0 comments on commit 19527a4

Please sign in to comment.