You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/11/22 12:11:19 UTC
[GitHub] [shardingsphere] Pace2Car commented on pull request #22320: Refactor auditor definition in DistSQL SHARDING RULE
Pace2Car commented on PR #22320:
URL: https://github.com/apache/shardingsphere/pull/22320#issuecomment-1323568498
This pr will modify DistSQL syntax.
Before this pr, we can create sharding table rule with audit strategy or audit definition.
```sql
CREATE SHARDING TABLE RULE t_order (
DATANODES("ds_${0..1}.t_order_${0..2}"),
TABLE_STRATEGY(TYPE=STANDARD,SHARDING_COLUMN=order_id,SHARDING_ALGORITHM=t_order_inline),
KEY_GENERATE_STRATEGY(COLUMN=order_id,KEY_GENERATOR=snowflake_key_generator),
AUDIT_STRATEGY(AUDITORS=[auditor1,auditor2],ALLOW_HINT_DISABLE=true)
);
```
or
```sql
CREATE SHARDING TABLE RULE t_order_detail (
DATANODES("ds_${0..1}.t_order_detail_${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=STANDARD,SHARDING_COLUMN=order_id,SHARDING_ALGORITHM(TYPE(NAME=INLINE,PROPERTIES("algorithm-expression"="t_order_detail_${order_id % 3}")))),
KEY_GENERATE_STRATEGY(COLUMN=detail_id,TYPE(NAME=snowflake)),
AUDIT_STRATEGY([(NAME=auditor1,TYPE(NAME=DML_SHARDING_CONDITIONS)),(NAME=auditor2,TYPE(NAME=DML_SHARDING_CONDITIONS))],ALLOW_HINT_DISABLE=true)
);
```
After refactoring, only the cohesive mode is retained, the use of brackets is removed, and the algorithm name is automatically created.
```sql
CREATE SHARDING TABLE RULE t_order (
DATANODES("ds_${0..1}.t_order_${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='STANDARD',SHARDING_COLUMN=order_id,SHARDING_ALGORITHM(TYPE(NAME='INLINE',PROPERTIES("algorithm-expression"="t_order_${order_id % 2}")))),
KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME='snowflake')),
AUDIT_STRATEGY((TYPE(NAME='DML_SHARDING_CONDITIONS')),(TYPE(NAME='DML_SHARDING_CONDITIONS')),ALLOW_HINT_DISABLE=true)
);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org