Skip to content

Conversation

@YaroslavLitvinov
Copy link
Contributor

@YaroslavLitvinov YaroslavLitvinov commented Jan 9, 2026

Save Query Attrs

  • query_submission_time
  • user_database_name (user context)
  • user_schema_name (user context)
  • database_name / schema_name (effective context) returned by current_database / current_schema
  • client_app_id / client_app_version
  • query_type - added explain/analyze

Features

In this PR - by default embucket/lambda won't persist SessionRecord when session created. Though Session updates will be persisted.
state-store-persist-session-oncreate when enabled - it allows saving empty session (having just session_id)

User Context behaviour changed

Previously, the context received in the login request was persisted in the state store.
Now, context such as UserName, Warehouse, Database, Schema, AccountName, ClientAppId, and ClientAppVersion is encoded directly in the authentication token.
This approach improves query latency because the query request can be sent immediately after the login request (~20 ms vs. >200 ms).
It also makes the Lambda cheaper when invoked from SnowSQL, which by default issues a login request for every query. As a result, we have fewer state-store reads and writes.

Changed behaviour: current_database / current_schema

    pub fn current_schema(&self) -> String {
        - self.query_context
        -    .schema
        -    .clone()
        -    .or_else(|| self.session.get_session_variable("schema"))
        self.session
       +     .get_session_variable("schema")
       +     .or_else(|| self.query_context.schema.clone())
       +     .unwrap_or_else(|| "public".to_string())

Unittests updated & refactored

@YaroslavLitvinov YaroslavLitvinov changed the title Yaro/query completion attrs3 query completion attrs3 Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants