Skip to content

Commit

Permalink
Warn when selection only includes static data
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed Oct 15, 2024
1 parent 50ab88b commit 61e29b9
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions rerun_py/src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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::<Vec<_>>();

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<arrow::datatypes::Field> =
schema.fields.iter().map(|f| f.clone().into()).collect();
Expand Down

0 comments on commit 61e29b9

Please sign in to comment.