Updated on 2026-06-17 GMT+08:00

Querying a SQL Inspection Rule

Function

This API is used to query a single SQL inspection rule.

Authorization

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see the required permissions in Introduction.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependency

    dli:sqldefendrule:get

    Read

    -

    -

    -

    -

URI

GET /v1/{project_id}/sql-defend-rules/{rule_id}

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID, which is used for resource isolation. For details about how to obtain its value, see Obtaining a Project ID.

Constraints

None

Range

The value can contain up to 64 characters. Only letters and digits are allowed.

Default Value

None

rule_id

Yes

String

Definition

Rule ID. For details, see the rule ID in Table 3.

Constraints

None

Range

For details about the enumerated values, see Table 3.

  • static_0001
  • static_0002
  • static_0003
  • static_0004
  • static_0005
  • static_0006
  • static_0007
  • dynamic_0001
  • dynamic_0002
  • running_0002
  • running_0003
  • running_0004

Default Value

None

Request Parameters

None

Response Parameters

Table 2 Response body parameters

Parameter

Type

Description

rule_uuid

String

Unique ID of a rule.

Maximum length: 64 characters.

project_id

String

Project ID.

Maximum length: 64 characters.

rule_name

String

Definition

Name of a custom SQL inspection rule.

Constraints

Minimum length: 1 character.

Maximum length: 32 characters.

Range

None

Default Value

None

rule_id

String

Definition

Rule ID. For details, see the rule ID in Table 3.

Constraints

None

Range

For details about the enumerated values, see Table 3.

  • static_0001
  • static_0002
  • static_0003
  • static_0004
  • static_0005
  • static_0006
  • static_0007
  • dynamic_0001
  • dynamic_0002
  • running_0002
  • running_0003
  • running_0004

Default Value

None

category

String

Definition

Rule status type. For details, see the status type column in Table 3.

Constraints

None

Range

Options:

  • static: static rule.
  • dynamic: dynamic rule.
  • running: blocking rule.

Default Value

None

engine_rules

Object

Definition

Action supported by the inspection rule. For details, see the supported actions in Table 3.

Constraints

None

Range

Options:

  • hint: hint.
  • intercept: interception.
  • fuse: block.

Default Value

None

queue_names

Array of strings

Queue name.

desc

String

Rule description.

Maximum length: 2,000 characters.

sys_desc

String

System rule description.

create_time

Long

Time when a rule was created.

update_time

Long

Time when a rule was updated.

Table 3 System inspection rules supported by DLI

Rule ID

Rule Name

Description

Category

Applicable Engine

Action

Value

Default System Rule

Example SQL Statement

Supported Engine Version

dynamic_0001

Scan files number

Maximum number of files to be scanned.

dynamic

spark

Hint

Intercept

Value range: 1–2000000

Default value: 200000

Yes

NA

Spark 3.3.1

dynamic_0002

Scan partitions number

Maximum number of partitions involved in the operations (select, delete, update, and alter) that can be performed on a table.

dynamic

spark

Hint

Intercept

Value range: 1–500000

Default value: 5000

Yes

select * from Partitioned table

Spark 3.3.1

running_0002

Memory used(MB)

Peak memory usage of the SQL statement.

running

spark

Block

Value range: 1–8388608

No

NA

Spark 3.3.1

running_0003

Run time(S)

Maximum running duration of the SQL statement.

running

spark

Block

Unit: second

Value range: 1–43200

No

NA

Spark 3.3.1

running_0004

Scan data(GB)

Maximum amount of data to be scanned.

running

spark

Block

Unit: GB

Value range: 1–10240

No

NA

Spark 3.3.1

running_0005

Shuffle data(GB)

Maximum amount of data to be shuffled.

running

spark

Block

Unit: GB

Value range: 1–10240

Default value: 2048

Yes

NA

Spark 3.3.1

Spark 2.4.5

static_0001

Count(distinct) occurrences

Maximum number of occurrences of count(distinct) in the SQL statement.

static

spark

Hint

Intercept

Value range: 1–100

Default value: 10

Yes

SELECT COUNT(DISTINCT deviceId), COUNT(DISTINCT collDeviceId)

FROM table

GROUP BY deviceName, collDeviceName, collCurrentVersion;

Spark 3.3.1

static_0002

Not in<Subquery>

Check whether not in <subquery> is used in the SQL statement.

static

spark

Hint

Intercept

Value range: Yes or No

Default value: Yes

Yes

SELECT *

FROM Orders o

WHERE Orders.Order_ID not in (Select Order_ID

FROM HeldOrders h

where h.order_id = o.order_id);

Spark 3.3.1

static_0003

Join occurrences

Maximum number of joins in the SQL statement.

static

spark

Hint

Intercept

Value range: 1–50

No

SELECT name, text FROM table_1 JOIN table_2 ON table_1.Id = table_2.Id

Spark 3.3.1

static_0004

Union occurrences

Maximum number of union all times in the SQL statement.

static

spark

Hint

Intercept

Value range: 1–100

No

select * from tables t1

union all select * from tables t2

union all select * from tables t3

Spark 3.3.1

static_0005

Subquery nesting layers

Maximum number of subquery nesting layers.

static

spark

Hint

Intercept

Value range: 1–20

No

select * from (

with temp1 as (select * from tables)

select * from temp1);

Spark 3.3.1

static_0006

Sql size(KB)

Maximum size of a SQL file.

static

spark

Hint

Intercept

Unit: KB

Value range: 1–1024

No

NA

Spark 3.3.1

static_0007

Cartesian product

Limitation of Cartesian products when multiple tables are being associated.

static

spark

Hint

Intercept

Value range: 0–1

No

select * from A,B;

Spark 3.3.1

Example Request

None

Example Response

{
    "rule_uuid": "168d21df-904c-402a-887c-0cee41dd55cc",
    "project_id": "330e068af1334c9782f4226acc00a2e2",
    "rule_name": "sql_running_0005_system",
    "rule_id": "running_0005",
    "category": "running",
    "engine_rules": {
        "fuse": 2048
    },
    "queue_names": [
        "ci_sql"
    ],
    "desc": "system default rule",
    "create_time": 1767924865715,
    "update_time": 1767924865715,
    "sys_desc": "Shuffle data(GB)"
}

Status Codes

Status Code

Description

201

A rule is successfully queried.

400

Request error.

500

Internal server error.

Error Codes

If an error occurs when this API is called, the system does not return the result similar to the preceding example, but returns an error code and error message. For details, see Error Codes.