presto
presto copied to clipboard
Implements #26762 : adds support for connecting to Astra DB
Description
adds a new parameter to facilitate connecting to Astra DB
Motivation and Context
Ability to query data in Astra DB
Impact
none
Test Plan
Unit test: used mocked Cluster.Builder to verify parameter is handled properly. Functional test (manual): verified ability to query data in Astra DB via presto-cli
Contributor checklist
- [x] Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
- [x] PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
- [ ] Documented new properties (with its default value), SQL syntax, functions, or other functionality.
- [ ] If release notes are required, they follow the release notes guidelines.
- [x] Adequate tests were added if applicable.
- [ ] CI passed.
- [ ] If adding new dependencies, verified they have an OpenSSF Scorecard score of 5.0 or higher (or obtained explicit TSC approval for lower scores).
Release Notes
Please follow release notes guidelines and fill in the release notes below.
== RELEASE NOTES ==
Cassandra Connector Changes
* adds support for Astra DB (via new configuration property ``cassandra.astra-secure-connect-bundle-path``)
Reviewer's Guide
Adds Astra DB support to the Cassandra connector by introducing a new configuration property for secure connect bundles, updating session creation to handle either contact points or Astra bundles, and adding focused tests and dependencies to validate the new behavior.
Sequence diagram for Cassandra session creation with Astra DB support
sequenceDiagram
participant Connector as CassandraConnector
participant Module as CassandraClientModule
participant Config as CassandraClientConfig
participant Builder as Cluster_Builder
participant Cluster as Cluster
participant Session as NativeCassandraSession
participant RCluster as ReopeningCluster
Connector->>Module: createCassandraSession(connectorId, config, extraColumnMetadataCodec)
Module->>Cluster: builder()
Cluster-->>Module: Builder
Module->>Builder: withProtocolVersion(config.getProtocolVersion())
Module->>Config: getAstraSecureConnectBundlePath()
Config-->>Module: astraSecureConnectBundlePath
alt astraSecureConnectBundlePath is null
Module->>Config: getContactPoints()
Config-->>Module: contactPoints
Module->>Module: check contactPoints not empty
loop for each contactPoint
Module->>Builder: addContactPoint(contactPoint)
end
else astraSecureConnectBundlePath is set
Module->>Module: assert contactPoints is null or empty
Module->>Builder: withCloudSecureConnectBundle(File(astraSecureConnectBundlePath))
end
Module->>Builder: withPort(config.getNativeProtocolPort())
Module->>Builder: withReconnectionPolicy(ExponentialReconnectionPolicy)
Module->>Builder: withRetryPolicy(config.getRetryPolicy().getPolicy())
Module->>Builder: withLoadBalancingPolicy(RoundRobinPolicy or DCAwareRoundRobinPolicy)
Module->>Builder: withQueryOptions(QueryOptions)
Module->>Builder: build()
Builder-->>Module: Cluster
Module->>RCluster: new ReopeningCluster(() -> Cluster)
Module->>Session: new NativeCassandraSession(connectorId, extraColumnMetadataCodec, RCluster, noHostAvailableRetryTimeout, caseSensitiveNameMatchingEnabled)
Module-->>Connector: CassandraSession
Class diagram for updated Cassandra client configuration and session creation
classDiagram
class CassandraClientConfig {
- ConsistencyLevel consistencyLevel
- int fetchSize
- List~String~ contactPoints
- String astraSecureConnectBundlePath
- int nativeProtocolPort
- int partitionSizeForBatchSelect
- int splitSize
- boolean caseSensitiveNameMatchingEnabled
+ List~String~ getContactPoints()
+ CassandraClientConfig setContactPoints(String contactPoints)
+ String getAstraSecureConnectBundlePath()
+ setAstraSecureConnectBundlePath(String astraSecureConnectBundlePath)
+ int getNativeProtocolPort()
}
class CassandraClientModule {
+ configure(Binder binder)
+ createCassandraSession(CassandraConnectorId connectorId, CassandraClientConfig config, JsonCodec extraColumnMetadataCodec) CassandraSession
+ createCassandraSession(ClusterBuilder clusterBuilder, CassandraConnectorId connectorId, CassandraClientConfig config, JsonCodec extraColumnMetadataCodec) CassandraSession
}
class CassandraSession {
}
class NativeCassandraSession {
+ NativeCassandraSession(String connectorId, JsonCodec extraColumnMetadataCodec, ReopeningCluster reopeningCluster, Duration noHostAvailableRetryTimeout, boolean caseSensitiveNameMatchingEnabled)
}
class ReopeningCluster {
+ ReopeningCluster(ClusterFactory clusterFactory)
}
class Cluster {
+ static ClusterBuilder builder()
}
class ClusterBuilder {
+ ClusterBuilder withProtocolVersion(ProtocolVersion protocolVersion)
+ ClusterBuilder addContactPoint(String contactPoint)
+ ClusterBuilder withCloudSecureConnectBundle(File secureConnectBundle)
+ ClusterBuilder withPort(int port)
+ ClusterBuilder withReconnectionPolicy(ReconnectionPolicy policy)
+ ClusterBuilder withRetryPolicy(RetryPolicy policy)
+ ClusterBuilder withLoadBalancingPolicy(LoadBalancingPolicy policy)
+ ClusterBuilder withQueryOptions(QueryOptions options)
+ Cluster build()
}
CassandraClientModule --> CassandraClientConfig : uses
CassandraClientModule --> CassandraSession : creates
CassandraClientModule --> NativeCassandraSession : instantiates
CassandraClientModule --> ReopeningCluster : wraps Cluster
CassandraClientModule --> ClusterBuilder : configures
CassandraClientConfig --> ClusterBuilder : provides connection configuration
NativeCassandraSession --> ReopeningCluster : depends on
ReopeningCluster --> Cluster : builds
File-Level Changes
| Change | Details | Files |
|---|---|---|
| Extend Cassandra session creation to support Astra secure connect bundle configuration in addition to traditional contact points, with mutual exclusivity validation. |
|
presto-cassandra/src/main/java/com/facebook/presto/cassandra/CassandraClientModule.java |
| Introduce Astra secure connect bundle configuration to Cassandra client configuration. |
|
presto-cassandra/src/main/java/com/facebook/presto/cassandra/CassandraClientConfig.java |
| Add unit tests for Astra bundle vs contact point behavior and supporting test dependencies. |
|
presto-cassandra/pom.xmlpresto-cassandra/src/test/java/com/facebook/presto/cassandra/CassandraClientModuleTest.java |
| Update embedded Cassandra test container version. |
|
presto-cassandra/src/test/java/com/facebook/presto/cassandra/CassandraServer.java |
Possibly linked issues
- #26762: PR adds the Astra secure connect bundle config and logic exactly as requested in the Astra DB issue.
Tips and commands
Interacting with Sourcery
- Trigger a new review: Comment
@sourcery-ai reviewon 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 issueto create an issue from it. - Generate a pull request title: Write
@sourcery-aianywhere in the pull request title to generate a title at any time. You can also comment@sourcery-ai titleon the pull request to (re-)generate the title at any time. - Generate a pull request summary: Write
@sourcery-ai summaryanywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment@sourcery-ai summaryon the pull request to (re-)generate the summary at any time. - Generate reviewer's guide: Comment
@sourcery-ai guideon the pull request to (re-)generate the reviewer's guide at any time. - Resolve all Sourcery comments: Comment
@sourcery-ai resolveon 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 dismisson 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 reviewto 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
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.
- :x: The email address for the commit (e8cd1b1374870e988ae84b0ad76ebf128f36691a) is not linked to the GitHub account, preventing the EasyCLA check. Consult this Help Article and GitHub Help to resolve. (To view the commit's email address, add .patch at the end of this PR page's URL.) For further assistance with EasyCLA, please submit a support request ticket.