fix(plugin-native-sidecar): Pass session start time as a header in na…#27545
Draft
pdabre12 wants to merge 1 commit intoprestodb:masterfrom
Draft
fix(plugin-native-sidecar): Pass session start time as a header in na…#27545pdabre12 wants to merge 1 commit intoprestodb:masterfrom
pdabre12 wants to merge 1 commit intoprestodb:masterfrom
Conversation
…tive expression optimizer
Contributor
Reviewer's GuidePasses the session start time from the Java sidecar plugin to the native expression optimizer via a new HTTP header, wires it into Velox QueryConfig so session-time-dependent functions like now() and current_timestamp are evaluated consistently, and adds/adjusts tests to validate session function optimization behavior. Sequence diagram for passing session start time header to native expression optimizersequenceDiagram
actor Client
participant PrestoCoordinator
participant NativeSidecarExpressionInterpreter
participant SidecarHttpClient
participant PrestoNativeServer
participant VeloxQueryConfig
participant ExpressionOptimizer
Client->>PrestoCoordinator: Submit query
PrestoCoordinator->>NativeSidecarExpressionInterpreter: Optimize expressions(ConnectorSession, Level, rows)
NativeSidecarExpressionInterpreter->>NativeSidecarExpressionInterpreter: Read sessionStartTime from SqlFunctionProperties
NativeSidecarExpressionInterpreter->>SidecarHttpClient: Build Request
activate NativeSidecarExpressionInterpreter
NativeSidecarExpressionInterpreter->>SidecarHttpClient: setHeader X-Presto-Session-Start-Time = sessionStartTime
deactivate NativeSidecarExpressionInterpreter
SidecarHttpClient->>PrestoNativeServer: POST /v1/expressions
activate PrestoNativeServer
PrestoNativeServer->>PrestoNativeServer: Read X-Presto-Session-Start-Time header
PrestoNativeServer->>VeloxQueryConfig: configs.insert(kSessionStartTime, sessionStartTime)
VeloxQueryConfig-->>PrestoNativeServer: QueryConfig instance
PrestoNativeServer->>ExpressionOptimizer: Optimize expressions(QueryConfig, expressions)
ExpressionOptimizer-->>PrestoNativeServer: Optimized expressions
deactivate PrestoNativeServer
PrestoNativeServer-->>SidecarHttpClient: HTTP 200 optimized expressions
SidecarHttpClient-->>NativeSidecarExpressionInterpreter: Response
NativeSidecarExpressionInterpreter-->>PrestoCoordinator: Optimized expressions
PrestoCoordinator-->>Client: Query result
Updated class diagram for sidecar interpreter and native server configurationclassDiagram
class NativeSidecarExpressionInterpreter {
+String PRESTO_TIME_ZONE_HEADER
+String PRESTO_USER_HEADER
+String PRESTO_EXPRESSION_OPTIMIZER_LEVEL_HEADER
+String PRESTO_SESSION_START_TIME_HEADER
-NodeManager nodeManager
-HttpClient httpClient
-Uri sidecarBaseUri
-Request getSidecarRequest(ConnectorSession session, Level level, List rows)
+List optimize(ConnectorSession session, Level level, List rows)
}
class ConnectorSession {
+String getUser()
+SqlFunctionProperties getSqlFunctionProperties()
}
class SqlFunctionProperties {
+TimeZoneKey getTimeZoneKey()
+long getSessionStartTime()
}
class TimeZoneKey {
+String getId()
}
class Request {
+RequestBuilder newBuilder()
}
class RequestBuilder {
+RequestBuilder setHeader(String name, String value)
+Request build()
}
class PrestoServer {
+json_array_t getOptimizedExpressions(HttpHeaders httpHeaders, String body)
-string kTimezoneHeader
-string kSessionStartTimeHeader
}
class HttpHeaders {
+String getSingleOrEmpty(String name)
}
class QueryConfig {
+static string kSessionTimezone
+static string kAdjustTimestampToTimezone
+static string kSessionStartTime
+QueryConfig(map configs)
}
class ExpressionOptimizerService {
+json_array_t optimize(QueryConfig queryConfig, json_array_t expressions)
}
NativeSidecarExpressionInterpreter --> ConnectorSession : uses
ConnectorSession --> SqlFunctionProperties : uses
SqlFunctionProperties --> TimeZoneKey : uses
NativeSidecarExpressionInterpreter --> RequestBuilder : builds
RequestBuilder --> Request : builds
PrestoServer --> HttpHeaders : reads
PrestoServer --> QueryConfig : constructs
PrestoServer --> ExpressionOptimizerService : calls
QueryConfig --> "configs" map : contains
SqlFunctionProperties : +long sessionStartTime
QueryConfig : +string sessionStartTime
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…tive expression optimizer
Description
Motivation and Context
Impact
Test Plan
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.
If release note is NOT required, use:
Summary by Sourcery
Propagate the SQL session start time from the Java sidecar plugin to the native expression optimizer so time-based session functions can be evaluated consistently in the native sidecar.
New Features:
Enhancements: