You can configure rules for ClickHouse SQL inspection on FusionInsight Manager and configure rule parameters as you need.
For details about the rules supported by the ClickHouse SQL engine, see MRS SQL Inspection Rules.
For example, add a rule whose ID is static_0008 and checks whether a SQL statement executes the cluster-level table update operation. If so, the system displays a hint.
cd /opt/hadoopclient
Run the following command to set environment variables:
source bigdata_env
kinit Component service user
Example: kinit clickhouseuser
Security mode
clickhouse client --host IP address of the ClickHouseServer instance --port 9440 --secure
Normal clusters:
clickhouse client --host IP address of the ClickHouseServer instance--user Username --password --port 9000
Enter the password.
CREATE DATABASE cktest ON CLUSTER default_cluster;
CREATE TABLE cktest.test2 ON CLUSTER default_cluster ( `EventDate` DateTime, `CounterID` UInt32, `UserID` UInt32, `ver` UInt16 ) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/cktest/test2', '{replica}') PARTITION BY toYYYYMM(EventDate) ORDER BY (EventDate, intHash32(UserID));
CREATE TABLE cktest.test2_dir ON CLUSTER default_cluster as cktest.test2 ENGINE = Distributed(default_cluster, cktest, test2, rand());
insert into cktest.test2 values('2023-08-01',111,111,111);
insert into cktest.test2 values('2023-08-02',222,111,111);
alter table cktest.test2 on cluster default_cluster update CounterID = toUInt32(222) where EventDate='2023-08-01' ;
... <Warning> SQLDefender: Distributed DDL ALTER UPDATE queries are undesirable. ...
If the operation set in the rule is Intercept, the statement fails to be executed and the following information is displayed:
... DB::Exception: Distributed DDL ALTER TABLE UPDATE queries are undesirable..(QUERY_IS_PROHIBITED) ...