Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Simple query interface #2201

Merged
merged 7 commits into from
Dec 4, 2023
Merged

feat: Simple query interface #2201

merged 7 commits into from
Dec 4, 2023

Conversation

scsmithr
Copy link
Member

@scsmithr scsmithr commented Dec 2, 2023

Adds a simple query interface for use with Cloud.

@scsmithr scsmithr marked this pull request as ready for review December 3, 2023 22:26
Comment on lines +70 to +93
/// Get an existing session for a database, or creates a new one using the
/// provided configuration.
async fn get_or_initialize_session(
&self,
db_id: Uuid,
storage_conf: SessionStorageConfig,
) -> Result<RemoteSession> {
let sess = match self.sessions.get(&db_id) {
Some(sess) => sess.clone(),
None => {
info!(session_id=%db_id, "initializing remote session");
let context = self
.engine
.new_remote_session_context(db_id, storage_conf)
.await?;

let sess = RemoteSession::new(context);
self.sessions.insert(db_id, sess.clone());
sess
}
};

Ok(sess)
}
Copy link
Member Author

Choose a reason for hiding this comment

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

I factored this out since I was originally going to use the remote sessions for this, but the remote session doesn't having all the capabilities we need to actually execute sql queries.

Copy link
Member Author

Choose a reason for hiding this comment

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

The definitions Cloud cares about.

Note that this does import from common.proto, so it's not enough to just copy this file, we'll want to make sure protoc has access to the entire directory.

@tychoish tychoish mentioned this pull request Dec 4, 2023
@greyscaled greyscaled added the cloud ☁️ Issues that affect cloud label Dec 4, 2023
crates/glaredb/src/args/server.rs Outdated Show resolved Hide resolved
crates/glaredb/src/server.rs Show resolved Hide resolved
crates/protogen/proto/rpcsrv/simple.proto Show resolved Hide resolved
Comment on lines +47 to +48
// TODO: We may want to extend this to actually stream/return the record
// batches.
Copy link
Contributor

Choose a reason for hiding this comment

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

Question(if-minor): Is this something we should hold off until we change to Flight?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't need to. Depends on the requirements of cloud. It would be straightforward to add the batches to this if cloud needs the results (we already have all the types needed). It would just be a cloud to know how to deserialize those batches (which it'd also need for flightsql anyways).

Copy link
Contributor

@vrongmeal vrongmeal left a comment

Choose a reason for hiding this comment

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

Looks like a good framework to start with 🚀

@scsmithr scsmithr enabled auto-merge (squash) December 4, 2023 17:37
@scsmithr scsmithr merged commit 4256815 into main Dec 4, 2023
10 checks passed
@scsmithr scsmithr deleted the sean/simple-query branch December 4, 2023 17:41
@@ -7,6 +7,9 @@ syntax = "proto3";

package rpcsrv.common;

// Storage config for the session.
message SessionStorageConfig { optional string gcs_bucket = 1; }
Copy link
Collaborator

Choose a reason for hiding this comment

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

I might have let this be any kind of bucket?

(are we talking about session state or default location for storage for anything?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is for database table data.

Currently this is the equivalent to this: https://github.com/glaredb/glaredb/blob/425681572f04b796739c5f1b761caddc96eae59a/crates/sqlexec/src/engine.rs#L37-L44

We should (at some point) make it more generic to allow things other than gcs buckets, but I think this is fine for now as its very specific to where we currently deploy cloud (gcp).

Comment on lines +138 to +142
if rpc_bind.is_none() && enable_simple_query_rpc {
return Err(anyhow!(
"An rpc bind address needs to be provided to enable the simple query interface"
));
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

given the impending use of this RPC interface for flightsql (e.g. attaching different grpc services to this RPC endpoint, we might just know that we'll need to

Copy link
Member Author

Choose a reason for hiding this comment

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

Need to what?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cloud ☁️ Issues that affect cloud
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants