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

chore: handle error returned from resolve_data_source() #14097

Merged
merged 4 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions src/common/exception/src/exception_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ build_exceptions! {
UnknownShareEndpointId(2716),
UnknownShareTable(2717),
CannotShareDatabaseCreatedFromShare(2718),
ShareStorageError(2719),

// Index error codes.
CreateIndexWithDropTime(2720),
Expand Down
20 changes: 17 additions & 3 deletions src/query/sharing/src/share_endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,24 @@ impl ShareEndpointManager {
let resp = self.client.send(req).await;
match resp {
Ok(resp) => {
if !resp.status().is_success() {
return Err(ErrorCode::ShareStorageError(format!(
"share {:?} storage error: HTTP status {:?}",
share_name,
match resp.status().canonical_reason() {
Some(reason) => reason.to_string(),
None => resp.status().to_string(),
}
)));
}
let bs = resp.into_body().bytes().await?;
let table_info_map: TableInfoMap = serde_json::from_slice(&bs)?;

Ok(table_info_map)
match serde_json::from_slice(&bs) {
Ok(table_info_map) => Ok(table_info_map),
Err(e) => Err(ErrorCode::ShareStorageError(format!(
"share {:?} storage error: deser json file error: {:?}",
share_name, e
))),
}
}
Err(err) => Err(err.into()),
}
Expand Down
13 changes: 8 additions & 5 deletions src/query/sql/src/planner/binder/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl Binder {
.await
{
Ok(table) => table,
Err(_) => {
Err(e) => {
let mut parent = bind_context.parent.as_mut();
loop {
if parent.is_none() {
Expand All @@ -260,10 +260,13 @@ impl Binder {
}
parent = bind_context.parent.as_mut();
}
return Err(ErrorCode::UnknownTable(format!(
"Unknown table `{database}`.`{table_name}` in catalog '{catalog}'"
))
.set_span(*span));
if e.code() == 1025 {
lichuang marked this conversation as resolved.
Show resolved Hide resolved
return Err(ErrorCode::UnknownTable(format!(
"Unknown table `{database}`.`{table_name}` in catalog '{catalog}'"
))
.set_span(*span));
}
return Err(e);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,7 @@ drop shared database and query data from share
4
5
6
ERROR 1105 (HY000) at line 1: UnknownTable. Code: 1025, Text = error:
--> SQL:1:15
|
1 | SELECT * FROM shared_db.t2
| ^^^^^^^^^^^^ Unknown table `shared_db`.`t2` in catalog 'default'
ERROR 1105 (HY000): ShareStorageError. Code: 2719, Text = share "test_share" storage error: HTTP status "Bad Request".
ERROR 1105 (HY000): ShareStorageError. Code: 2719, Text = share "test_share" storage error: HTTP status "Bad Request".

.
ERROR 1105 (HY000) at line 1: UnknownTable. Code: 1025, Text = error:
--> SQL:1:15
|
1 | SELECT * FROM shared_db.t2
| ^^^^^^^^^^^^ Unknown table `shared_db`.`t2` in catalog 'default'

.
all is good
Loading