This function applies only to clusters of MRS 3.5.0 and later versions.
You can configure inspection rules for Doris SQL statements on MRS Manager and set rule parameters based on your needs.

For details about the rules supported by the Doris SQL engine, see MRS SQL Inspection Rules.
For example, add the static_0001 rule while setting the threshold to 1 for the Hint action and 6 for the Intercept action. This rule detects a SQL statement that contains more than one count distinct.

If Kerberos authentication (security mode) has been enabled for the cluster, run the following commands to connect to the Doris database:
export LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN=1
mysql -uDatabase login username -p -PConnection port for FE queries -hIP address of the Doris FE instance
Enter the password for logging in to the database.
mysql -uDatabase login user -p -PTCP access port of DBalancer -hIP address of the Doris DBalancer instance
Enter the password for logging in to the database.
Enter the password of the dorisuser user after running the command.
use __internal_schema;
select * from sqldefend_rule;
+-------------+----------+--------------------+--------+-----------------+------+------+------+ | rule_name | is_group | group_or_user_name | action | threshold_value | p_1 | p_2 | p_3 | +-------------+----------+--------------------+--------+-----------------+------+------+------+ | static_0001 | 1 | A | 1 | 3 | NULL | NULL | NULL | | static_0001 | 1 | A | 2 | 2 | NULL | NULL | NULL | +-------------+----------+--------------------+--------+-----------------+------+------+------+
create database test;
use test;
create table if not exists t1(id int) engine=olap distributed by hash(id);
create table if not exists t2(id int) engine=olap distributed by hash(id);
create table if not exists t3(id int) engine=olap distributed by hash(id);
select count(distinct id) from t1 except select count(distinct id) from t2 intersect select count(distinct id) from t3 union all select count(distinct id) from t1 except select count(distinct id) from t2 intersect select count(distinct id) from t3;
The number of count distinct in this statement exceeds the threshold configured in 3.
show warnings;
+----------------------------------------------+-------------+------------------------------------------------------------------------------------+ | QueryId | RuleType | Message | +----------------------------------------------+-------------+------------------------------------------------------------------------------------+ | stmt[306, 887f43753bb749c9-b6ed36350f9454a8] | STATIC_RULE | static_0001 number of count(distinct) in the query 6 more than the allowed limit 1 | +----------------------------------------------+-------------+------------------------------------------------------------------------------------+
887f43753bb749c9-b6ed36350f9454a8 indicates the query ID. To view the SQL statement corresponding to the message, run the following command:
select * from query_history where query_id='887f43753bb749c9-b6ed36350f9454a8';
ERROR ... detailMessage = static_0001 number of count(distinct) in the query 7 more than the allowed limit 6
show warnings;
The statement output is empty.
Empty set (0.00 sec)
ERROR ... detailMessage = running_0001 Num of result rows num reaches the fuse threshold(1000), so cancel the output