From 61e29b90a3cafcb958deb0741b4ebdf4e06a18fc Mon Sep 17 00:00:00 2001 From: Jeremy Leibs Date: Tue, 15 Oct 2024 17:00:36 -0400 Subject: [PATCH] Warn when selection only includes static data --- rerun_py/src/dataframe.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/rerun_py/src/dataframe.rs b/rerun_py/src/dataframe.rs index d6352aff90f62..34b3baa735bcb 100644 --- a/rerun_py/src/dataframe.rs +++ b/rerun_py/src/dataframe.rs @@ -42,6 +42,16 @@ pub(crate) fn register(m: &Bound<'_, PyModule>) -> PyResult<()> { Ok(()) } +fn py_rerun_warn(msg: &str) -> PyResult<()> { + Python::with_gil(|py| { + let warning_type = PyModule::import_bound(py, "rerun")? + .getattr("error_utils")? + .getattr("RerunWarning")?; + PyErr::warn_bound(py, &warning_type, msg, 0)?; + Ok(()) + }) +} + /// Python binding for `IndexColumnDescriptor` #[pyclass(frozen, name = "IndexColumnDescriptor")] #[derive(Clone)] @@ -513,6 +523,18 @@ impl PyRecordingView { let query_handle = engine.query(query_expression); + let available_data_columns = query_handle + .view_contents() + .iter() + .filter(|c| matches!(c, ColumnDescriptor::Component(_))) + .collect::>(); + + if !available_data_columns.is_empty() + && available_data_columns.iter().all(|c| c.is_static()) + { + py_rerun_warn("RecordingView::select: contents only include static columns. No results will be returned. Either include non-static data or consider using `select_static()` instead.")?; + } + let schema = query_handle.schema(); let fields: Vec = schema.fields.iter().map(|f| f.clone().into()).collect();