Skip to content

Conversation

@adheer-araokar
Copy link

@adheer-araokar adheer-araokar commented Oct 30, 2025

feat: Add queryType to ConnectorSession to add query meta information to the session

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== NO RELEASE NOTE ==

@adheer-araokar adheer-araokar requested a review from a team as a code owner October 30, 2025 00:46
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 30, 2025

Reviewer's Guide

Introduce QueryType support in ConnectorSession and implement it in session classes to allow SELECT queries to trigger ensureConsistentRead in Metastore API calls.

Sequence diagram for SELECT query triggering ensureConsistentRead in Metastore API

sequenceDiagram
    actor User
    participant PrestoCoordinator
    participant ConnectorSession
    participant MetastoreAPI
    User->>PrestoCoordinator: Submit SELECT query
    PrestoCoordinator->>ConnectorSession: getQueryType()
    ConnectorSession-->>PrestoCoordinator: QueryType.SELECT
    PrestoCoordinator->>MetastoreAPI: Read with ensureConsistentRead=true
    MetastoreAPI-->>PrestoCoordinator: Return results
    PrestoCoordinator-->>User: Return query results
Loading

Class diagram for updated ConnectorSession and session implementations

classDiagram
    class ConnectorSession {
        +getRuntimeStats()
        +getQueryType() Optional<QueryType>
        +forConnectorId(ConnectorId)
    }
    class FullConnectorSession {
        +getRuntimeStats()
        +getQueryType() Optional<QueryType>
        +forConnectorId(ConnectorId)
    }
    class TestingConnectorSession {
        +getRuntimeStats()
        +getQueryType() Optional<QueryType>
        +forConnectorId(ConnectorId)
    }
    ConnectorSession <|.. FullConnectorSession
    ConnectorSession <|.. TestingConnectorSession
    class QueryType {
        <<enum>>
        SELECT
        // ... other query types
    }
Loading

File-Level Changes

Change Details Files
Extend ConnectorSession API to include query type metadata
  • Add getQueryType() method signature to ConnectorSession interface
presto-spi/src/main/java/com/facebook/presto/spi/ConnectorSession.java
Propagate QueryType through ConnectorSession implementations
  • Override getQueryType() in FullConnectorSession to delegate to underlying session
  • Override getQueryType() in AbstractTestHiveClient to delegate to session
presto-main-base/src/main/java/com/facebook/presto/FullConnectorSession.java
presto-hive/src/test/java/com/facebook/presto/hive/AbstractTestHiveClient.java
Provide default QueryType for testing sessions
  • Return Optional.of(QueryType.SELECT) in TestingConnectorSession
  • Return Optional.of(QueryType.SELECT) in TestingSession
presto-main-base/src/main/java/com/facebook/presto/testing/TestingConnectorSession.java
presto-spi/src/test/java/com/facebook/presto/spi/TestingSession.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 30, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: adheer-araokar / name: Adheer Araokar (937161e)

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `presto-spi/src/main/java/com/facebook/presto/spi/ConnectorSession.java:71` </location>
<code_context>

     RuntimeStats getRuntimeStats();

+    Optional<QueryType> getQueryType();
+
     /**
</code_context>

<issue_to_address>
**suggestion:** Documenting the semantics of getQueryType() could help future maintainers.

Clarifying the expected values and conditions for returning Optional.empty would make the method's behavior more transparent.

```suggestion
    /**
     * Returns the {@link QueryType} for the current session, if available.
     * <p>
     * The returned {@link Optional} will contain a value if the query type is known
     * (e.g., for queries submitted via the main Presto engine). If the query type cannot
     * be determined (such as for internal or system queries), {@link Optional#empty()} is returned.
     *
     * @return an {@link Optional} containing the {@link QueryType} if available, otherwise {@link Optional#empty()}
     */
    Optional<QueryType> getQueryType();
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

RuntimeStats getRuntimeStats();

Optional<QueryType> getQueryType();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Documenting the semantics of getQueryType() could help future maintainers.

Clarifying the expected values and conditions for returning Optional.empty would make the method's behavior more transparent.

Suggested change
Optional<QueryType> getQueryType();
/**
* Returns the {@link QueryType} for the current session, if available.
* <p>
* The returned {@link Optional} will contain a value if the query type is known
* (e.g., for queries submitted via the main Presto engine). If the query type cannot
* be determined (such as for internal or system queries), {@link Optional#empty()} is returned.
*
* @return an {@link Optional} containing the {@link QueryType} if available, otherwise {@link Optional#empty()}
*/
Optional<QueryType> getQueryType();
adheer-araokar added a commit to adheer-araokar/presto that referenced this pull request Oct 30, 2025
…ELECT queries. (prestodb#26474)

Summary:

X-link: facebookexternal/presto-facebook#3436

feat: Send "ensureConsistentRead" to Metastore API for all SELECT queries.

BREAKING CHANGE: Default metastore replica to be read from for Select queries will be the read replica, and re-after-write users will have to set "prism.force_metastore_primary_enabled" session property to "true"

Reviewed By: konjac-h

Differential Revision: D84520611
@adheer-araokar adheer-araokar changed the title [Presto] Send "ensureConsistentRead" to Metastore API for all SELECT queries. Oct 30, 2025
adheer-araokar added a commit to adheer-araokar/presto that referenced this pull request Oct 30, 2025
…ELECT queries (prestodb#26474)

Summary:

X-link: facebookexternal/presto-facebook#3436

Feat: Send "ensureConsistentRead" to Metastore API for all SELECT queries

BREAKING CHANGE: Default metastore replica to be read from for Select queries will be the read replica, and re-after-write users will have to set "prism.force_metastore_primary_enabled" session property to "true"

Reviewed By: konjac-h

Differential Revision: D84520611
@adheer-araokar adheer-araokar changed the title feat: [Presto] Send "ensureConsistentRead" to Metastore API for all SELECT queries. Oct 30, 2025
@adheer-araokar adheer-araokar changed the title Feat: [Presto] Send "ensureConsistentRead" to Metastore API for all SELECT queries Oct 30, 2025
adheer-araokar added a commit to adheer-araokar/presto that referenced this pull request Oct 30, 2025
…eries (prestodb#26474)

Summary:
X-link: facebookexternal/presto-facebook#3436

feat: Send "ensureConsistentRead" to Metastore API for all SELECT queries

BREAKING CHANGE: Default metastore replica to be read from for Select queries will be the read replica, and re-after-write users will have to set "prism.force_metastore_primary_enabled" session property to "true"

Differential Revision: D84520611

Pulled By: adheer-araokar
adheer-araokar added a commit to adheer-araokar/presto that referenced this pull request Oct 30, 2025
…eries (prestodb#26474)

Summary:
X-link: facebookexternal/presto-facebook#3436


X-link: facebookexternal/presto-facebook#3436

feat: Send "ensureConsistentRead" to Metastore API for all SELECT queries

BREAKING CHANGE: Default metastore replica to be read from for Select queries will be the read replica, and re-after-write users will have to set "prism.force_metastore_primary_enabled" session property to "true"

Differential Revision: D84520611

Pulled By: adheer-araokar
@steveburnett
Copy link
Contributor

  1. If this PR contains a Breaking Change, it should probably have a release note entry so the entry can be included in the Breaking Changes topic of the release notes.

  2. prism.force_metastore_primary_enabled appears to be undocumented. Please include documentation.

@adheer-araokar adheer-araokar changed the title feat: Send "ensureConsistentRead" to Metastore API for all SELECT queries Oct 30, 2025
@adheer-araokar adheer-araokar changed the title feat: Add queryType to ConnectorSession to send query meta information. Oct 30, 2025
@adheer-araokar
Copy link
Author

@steveburnett

  1. If this PR contains a Breaking Change, it should probably have a release note entry so the entry can be included in the Breaking Changes topic of the release notes.

The change actually is not a breaking change and simply adds the queryType to the connector session object to add meta information about the query. I have now fixed the title and the summary.

  1. prism.force_metastore_primary_enabled appears to be undocumented. Please include documentation.

This session property is not relevant here either. Changed the summary.

adheer-araokar added a commit to adheer-araokar/presto that referenced this pull request Oct 30, 2025
…eries (prestodb#26474)

Summary:
X-link: facebookexternal/presto-facebook#3436


X-link: facebookexternal/presto-facebook#3436

feat: Send "ensureConsistentRead" to Metastore API for all SELECT queries

BREAKING CHANGE: Default metastore replica to be read from for Select queries will be the read replica, and re-after-write users will have to set "prism.force_metastore_primary_enabled" session property to "true"

Differential Revision: D84520611

Pulled By: adheer-araokar
…eries (prestodb#26474)

Summary:
X-link: facebookexternal/presto-facebook#3436


X-link: facebookexternal/presto-facebook#3436

feat: Send "ensureConsistentRead" to Metastore API for all SELECT queries

BREAKING CHANGE: Default metastore replica to be read from for Select queries will be the read replica, and re-after-write users will have to set "prism.force_metastore_primary_enabled" session property to "true"

Differential Revision: D84520611

Pulled By: adheer-araokar
Copy link
Contributor

@PingLiuPing PingLiuPing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where this new API getQueryType() been used?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment