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

fix: handle empty table response in unity api #1963

Merged
merged 1 commit into from
Dec 13, 2023
Merged
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
26 changes: 26 additions & 0 deletions crates/deltalake-core/src/data_catalog/unity/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ pub enum ListTableSummariesResponse {
/// Successful response
Success {
/// Basic table infos
#[serde(default)]
tables: Vec<TableSummary>,
/// Continuation token
next_page_token: Option<String>,
Expand Down Expand Up @@ -441,6 +442,16 @@ pub(crate) mod tests {
}
"#;

pub(crate) const LIST_TABLES: &str = r#"
{
"tables": [{
"full_name": "catalog.schema.table_name",
"table_type": "MANAGED"
}]
}
"#;
pub(crate) const LIST_TABLES_EMPTY: &str = "{}";

#[test]
fn test_responses() {
let list_schemas: Result<ListSchemasResponse, _> =
Expand All @@ -458,6 +469,21 @@ pub(crate) mod tests {
GetTableResponse::Success { .. }
));

let list_tables: Result<ListTableSummariesResponse, _> = serde_json::from_str(LIST_TABLES);
assert!(list_tables.is_ok());
assert!(matches!(
list_tables.unwrap(),
ListTableSummariesResponse::Success { .. }
));

let list_tables: Result<ListTableSummariesResponse, _> =
serde_json::from_str(LIST_TABLES_EMPTY);
assert!(list_tables.is_ok());
assert!(matches!(
list_tables.unwrap(),
ListTableSummariesResponse::Success { .. }
));

let get_schema: Result<GetSchemaResponse, _> = serde_json::from_str(GET_SCHEMA_RESPONSE);
assert!(get_schema.is_ok());
assert!(matches!(get_schema.unwrap(), GetSchemaResponse::Success(_)))
Expand Down
Loading