Skip to content

Commit

Permalink
refactor: rename query to start_query (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
flaneur2020 authored Oct 9, 2023
1 parent cea60a8 commit 0d68afd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
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

0 comments on commit 0d68afd

Please sign in to comment.