wenzhenghu commented on PR #66006: URL: https://github.com/apache/doris/pull/66006#issuecomment-5070812160
### Note on commit `9a956e8` — `[fix](fe) Avoid ClassCastException when masking non-insert job DML in audit SQL` This commit fixes a **pre-existing bug on the master baseline**, not a regression introduced by this PR. **Background.** The P0 regression case `job_p0.test_base_insert_job` failed with `ClassCastException: UpdateContext cannot be cast to InsertTableContext`. The root cause is in `LogicalPlanBuilderForEncryption.visitCreateScheduledJob` / `visitAlterJob`, which unconditionally cast `supportedDmlStatement()` to `InsertTableContext`. For `CREATE/ALTER JOB ... DO update/delete`, the DML is parsed as `UpdateContext`, so the cast throws. Both this cast and `CreateJobCommand implements NeedAuditEncryption` already exist on master — this PR does not touch those two methods. **Impact assessment.** - This PR's feature (masking `ai.api_key` in FE logs and the audit log for `CREATE/ALTER RESOURCE`) is **not affected** — resource statements go through `visitCreateResource`/`visitAlterResource`, never through the job cast path. - The only affected logic: for `CREATE JOB ... DO update/delete`, the audit-encryption path (`geneEncryptionSQL` → `parseForEncryption`) threw `ClassCastException`. Because `AuditLogHelper.logAuditLog` wraps the call in `try/catch(Throwable)`, the query itself still executes successfully; the only consequence is that **the audit log entry for such a CREATE JOB statement is lost** (with a `Failed to write audit log` warning). **Fix.** Guard the cast with `instanceof InsertTableContext` in both `visitCreateScheduledJob` and `visitAlterJob`, so only real INSERT statements go through `visitInsertTable` masking; non-INSERT DML is skipped. A unit test (`testCreateJobWithUpdateDoesNotThrowClassCastException`) is added. Checkstyle passes and `RepositoryAuditEncryptionTest` is green (5/5). -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
