Support SQL query profiling with the analytics engine#5475
Conversation
Add a `profile` boolean field to SQLQueryRequest and thread it through the SQL REST handler to the analytics router. Mirrors PPL's existing profile pattern: parsed from the JSON body's `profile` key, gated by the same rules (only honored for non-explain JDBC requests on the analytics engine path). Replaces the hardcoded `false` in SQLPlugin#createSqlAnalyticsRouter so analytics-engine queries now honor the request's profile flag. The V2 SQL engine path is unchanged; profile is silently ignored when the request does not route to the analytics engine. Refs: opensearch-project#5317 Signed-off-by: Chen Dai <daichen@amazon.com>
PR Reviewer Guide 🔍(Review updated until commit b968d7f)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|
Persistent review updated to latest commit 9cb31bb |
QueryPlanExecutor (analytics-framework 3.7+) fires its listener on a worker thread separate from the one that activated QueryProfiling. Without explicit handoff, the listener-side formatter reads an empty profile context, and the synchronous UnifiedQueryContext.close() via try-with-resources fires before async work finishes — closing the Calcite connection while it is still in use and clearing profile state before the listener can read it. - AnalyticsExecutionEngine.execute: capture the active ProfileContext and restore it via QueryProfiling.withCurrentContext inside the response callback so metric reads/writes see the same context. - RestUnifiedQueryAction.execute: defer UnifiedQueryContext.close to listener completion via ActionListener.runAfter, wrapped in a named wrapWithContextClose helper. - Add regression test simulating async listener delivery. Refs: opensearch-project#5317 Signed-off-by: Chen Dai <daichen@amazon.com>
9cb31bb to
b968d7f
Compare
|
Persistent review updated to latest commit b968d7f |
| ``_explain``) and only with the default ``format=jdbc``. | ||
|
|
||
| Example | ||
| ------- |
There was a problem hiding this comment.
Is this example an integration test? I am wondering if we can have an integration test for profiling(assert each metric to be greater than 0)?
There was a problem hiding this comment.
I did this manually against OS cluster with SQL + AE. I'm also thinking can we add some dedicated IT for AE. Let me check after this.
Description
Adds a
profileboolean field to the/_plugins/_sqlrequest body to capture per-stage query timings, mirroring PPL's existing profile pattern. Also propagates the profile context across the Analytics Engine's async listener thread so profile output is visible in the response."profile": trueis set on a SQL query that routes to the analytics engine.Related Issues
Part of #5246.
Check List
--signoffor-s.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.