diff --git a/crates/amalthea/src/comm/data_explorer_comm.rs b/crates/amalthea/src/comm/data_explorer_comm.rs index 6cb5c3313..0ea88a1ae 100644 --- a/crates/amalthea/src/comm/data_explorer_comm.rs +++ b/crates/amalthea/src/comm/data_explorer_comm.rs @@ -11,6 +11,13 @@ use serde::Deserialize; use serde::Serialize; +/// Result in Methods +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +pub struct OpenDatasetResult { + /// An error message if opening the dataset failed + pub error_message: Option +} + /// Result in Methods #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct SearchSchemaResult { @@ -67,7 +74,15 @@ pub struct BackendState { pub sort_keys: Vec, /// The features currently supported by the backend instance - pub supported_features: SupportedFeatures + pub supported_features: SupportedFeatures, + + /// Optional flag allowing backend to report that it is unable to serve + /// requests. This parameter may change. + pub connected: Option, + + /// Optional experimental parameter to provide an explanation when + /// connected=false. This parameter may change. + pub error_message: Option } /// Schema for a column in a table @@ -985,6 +1000,13 @@ pub enum ArraySelection { SelectIndices(DataSelectionIndices) } +/// Parameters for the OpenDataset method. +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +pub struct OpenDatasetParams { + /// The resource locator or file path + pub uri: String, +} + /// Parameters for the GetSchema method. #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct GetSchemaParams { @@ -1079,6 +1101,9 @@ pub struct ReturnColumnProfilesParams { /// Array of individual column profile results pub profiles: Vec, + + /// Optional error message if something failed to compute + pub error_message: Option, } /** @@ -1087,6 +1112,12 @@ pub struct ReturnColumnProfilesParams { #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(tag = "method", content = "params")] pub enum DataExplorerBackendRequest { + /// Request to open a dataset given a URI + /// + /// Request to open a dataset given a URI + #[serde(rename = "open_dataset")] + OpenDataset(OpenDatasetParams), + /// Request schema /// /// Request subset of column schemas for a table-like object @@ -1160,6 +1191,8 @@ pub enum DataExplorerBackendRequest { #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(tag = "method", content = "result")] pub enum DataExplorerBackendReply { + OpenDatasetReply(OpenDatasetResult), + GetSchemaReply(TableSchema), SearchSchemaReply(SearchSchemaResult), diff --git a/crates/ark/src/data_explorer/column_profile.rs b/crates/ark/src/data_explorer/column_profile.rs index b992f443d..0535fc553 100644 --- a/crates/ark/src/data_explorer/column_profile.rs +++ b/crates/ark/src/data_explorer/column_profile.rs @@ -68,6 +68,7 @@ pub async fn handle_columns_profiles_requests( let event = DataExplorerFrontendEvent::ReturnColumnProfiles(ReturnColumnProfilesParams { callback_id, profiles, + error_message: None, }); let json_event = serde_json::to_value(event)?; diff --git a/crates/ark/src/data_explorer/r_data_explorer.rs b/crates/ark/src/data_explorer/r_data_explorer.rs index e73cd15a0..7836780ff 100644 --- a/crates/ark/src/data_explorer/r_data_explorer.rs +++ b/crates/ark/src/data_explorer/r_data_explorer.rs @@ -522,6 +522,10 @@ impl RDataExplorer { DataExplorerBackendRequest::GetState => r_task(|| self.r_get_state()), + DataExplorerBackendRequest::OpenDataset(_) => { + return Err(anyhow!("Data Explorer: Not yet supported")); + }, + DataExplorerBackendRequest::SearchSchema(_) => { return Err(anyhow!("Data Explorer: Not yet supported")); }, @@ -873,6 +877,8 @@ impl RDataExplorer { fn r_get_state(&self) -> anyhow::Result { let state = BackendState { display_name: self.title.clone(), + connected: Some(true), + error_message: None, table_shape: TableShape { num_rows: match self.filtered_indices { Some(ref indices) => indices.len() as i64,