Yakir Gibraltar
05/28/2026, 11:09 AMDDL like CREATE TABLE AS SELECT ?
https://github.com/StarRocks/starrocks/blob/main/fe/fe-core/src/main/java/com/starrocks/qe/ConnectProcessor.java#L351
// Build Digest and queryFeMemory for SELECT/INSERT/UPDATE/DELETE
if (ctx.getState().isQuery() || parsedStmt instanceof DmlStmt) {
String digest = digestFromLeader;
if (digest == null && (Config.enable_sql_digest || ctx.getSessionVariable().isEnableSQLDigest())) {
digest = computeStatementDigest(parsedStmt);
}
if (digest != null) {
ctx.getAuditEventBuilder().setDigest(digest);
}
long threadAllocatedMemory =
getThreadAllocatedBytes(Thread.currentThread().getId()) - ctx.getCurrentThreadAllocatedMemory();
ctx.getAuditEventBuilder().setQueryFeMemory(threadAllocatedMemory);
}
@Rocky
@Michael Taranov @Rotem Adhoh ccRocky
05/28/2026, 11:10 AMSELECT) and DML statements (like INSERT, UPDATE, DELETE).
Why CREATE TABLE AS SELECT (CTAS) is not included:
In the StarRocks FE codebase, CreateTableAsSelectStmt is categorized as a DDL (Data Definition Language) statement rather than a DmlStmt. The logic in ConnectProcessor.java specifically filters for:
1. `ctx.getState().isQuery()`: Typically true for SELECT and certain SHOW statements.
2. `parsedStmt instanceof DmlStmt`: Covers INSERT, UPDATE, and DELETE.
Since CTAS is technically a "Create Table" operation that happens to contain a "Select" query, it is treated as a DDL schema change. Most DDLs (ALTER, DROP, CREATE) are excluded from digest generation because:
* Frequency: DDLs are generally low-frequency operations compared to queries and DML.
* Purpose: The SQL Digest feature was primarily designed to identify patterns in high-concurrency workloads to analyze query performance and resource consumption.
Impact on CTAS
Even though the "Select" portion of a CTAS can be resource-intensive and follow a repeated pattern (common in ETL jobs), the outer statement remains a DDL. Consequently:
* CTAS operations will appear in the audit log, but the digest field will be empty.
* You cannot cluster CTAS operations by their query structure using the digest column in the starrocks_audit_tbl__.
Recommendation
If you need to track the performance patterns of heavy CTAS operations via digests, this would currently require an enhancement to the FE logic to include CreateTableAsSelectStmt (or DDLs in general) in the digest computation block.
For now, if you are performing heavy ETL, you might consider using INSERT INTO ... SELECT into an existing table if possible, as INSERT statements will generate a digest.
References:
* SQL Digest Documentation
* Audit Log Field Reference
References
• administration/sql_digest.md
• administration/management/FE_configuration.md
• faq/operation_maintenance_faq.md
• administration/management/logs.md
• administration/management/audit_loader.md
• integrations/smt/starrocks_sqlalchemy.md