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

refactor: rename query to start_query #250

Merged
merged 3 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl APIClient {
}
}

pub async fn query(&self, sql: &str) -> Result<QueryResponse> {
pub async fn start_query(&self, sql: &str) -> Result<QueryResponse> {
let session_settings = self.make_session().await;
let req = QueryRequest::new(sql)
.with_pagination(self.make_pagination())
Expand Down Expand Up @@ -293,8 +293,8 @@ impl APIClient {
}
}

pub async fn query_wait(&self, sql: &str) -> Result<QueryResponse> {
let resp = self.query(sql).await?;
pub async fn query(&self, sql: &str) -> Result<QueryResponse> {
let resp = self.start_query(sql).await?;
self.wait_for_query(resp).await
}

Expand Down Expand Up @@ -411,7 +411,7 @@ impl APIClient {

async fn get_presigned_upload_url(&self, stage: &str) -> Result<PresignedResponse> {
let sql = format!("PRESIGN UPLOAD {}", stage);
let resp = self.query_wait(&sql).await?;
let resp = self.query(&sql).await?;
if resp.data.len() != 1 {
return Err(Error::Request(
"Empty response from server for presigned request".to_string(),
Expand Down
2 changes: 1 addition & 1 deletion core/tests/core/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ use crate::common::DEFAULT_DSN;
async fn select_simple() {
let dsn = option_env!("TEST_DATABEND_DSN").unwrap_or(DEFAULT_DSN);
let client = APIClient::from_dsn(dsn).await.unwrap();
let resp = client.query("select 15532").await.unwrap();
let resp = client.start_query("select 15532").await.unwrap();
assert_eq!(resp.data, [["15532"]]);
}
6 changes: 3 additions & 3 deletions core/tests/core/stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async fn insert_with_stage(presigned: bool) {
"CREATE TABLE `{}` (id UInt64, city String, number UInt64)",
table
);
client.query_wait(&sql).await.unwrap();
client.query(&sql).await.unwrap();

let sql = format!("INSERT INTO `{}` VALUES", table);
let file_format_options = vec![
Expand All @@ -67,7 +67,7 @@ async fn insert_with_stage(presigned: bool) {
.unwrap();

let sql = format!("SELECT * FROM `{}`", table);
let resp = client.query_wait(&sql).await.unwrap();
let resp = client.query(&sql).await.unwrap();
assert_eq!(resp.data.len(), 6);
let expect = [
["1", "Beijing", "100"],
Expand All @@ -80,7 +80,7 @@ async fn insert_with_stage(presigned: bool) {
assert_eq!(resp.data, expect);

let sql = format!("DROP TABLE `{}`;", table);
client.query_wait(&sql).await.unwrap();
client.query(&sql).await.unwrap();
}

#[tokio::test]
Expand Down
6 changes: 3 additions & 3 deletions driver/src/rest_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl Connection for RestAPIConnection {
}

async fn exec(&self, sql: &str) -> Result<i64> {
let mut resp = self.client.query(sql).await?;
let mut resp = self.client.start_query(sql).await?;
while let Some(next_uri) = resp.next_uri {
resp = self.client.query_page(&next_uri).await?;
}
Expand All @@ -67,13 +67,13 @@ impl Connection for RestAPIConnection {
}

async fn query_iter_ext(&self, sql: &str) -> Result<(Schema, RowProgressIterator)> {
let resp = self.client.query(sql).await?;
let resp = self.client.start_query(sql).await?;
let (schema, rows) = RestAPIRows::from_response(self.client.clone(), resp)?;
Ok((schema, RowProgressIterator::new(Box::pin(rows))))
}

async fn query_row(&self, sql: &str) -> Result<Option<Row>> {
let resp = self.client.query(sql).await?;
let resp = self.client.start_query(sql).await?;
let resp = self.wait_for_data(resp).await?;
match resp.kill_uri {
Some(uri) => self.client.kill_query(&uri).await.map_err(|e| e.into()),
Expand Down