Skip to content

Commit

Permalink
Improve error logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs authored and teh-cmc committed Oct 16, 2024
1 parent ada2f35 commit 19b2f95
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions rerun_py/src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,17 +523,35 @@ impl PyRecordingView {

let query_handle = engine.query(query_expression);

// If the only contents found are static, we might need to warn the user since
// this means we won't naturally have any rows in the result.
let available_data_columns = query_handle
.view_contents()
.iter()
.filter(|c| matches!(c, ColumnDescriptor::Component(_)))
.collect::<Vec<_>>();

// We only consider all contents static if there at least some columns
let all_contents_are_static = !available_data_columns.is_empty()
&& available_data_columns.iter().all(|c| c.is_static());

// Additionally, we only want to warn if the user actually tried to select some
// of the static columns. Otherwise the fact that there are no results shouldn't
// be surprising.
let selected_data_columns = query_handle
.selected_contents()
.iter()
.map(|(_, col)| col)
.filter(|c| matches!(c, ColumnDescriptor::Component(_)))
.collect::<Vec<_>>();

let any_selected_data_is_static = selected_data_columns.iter().any(|c| c.is_static());

if self.query_expression.using_index_values.is_none()
&& !available_data_columns.is_empty()
&& available_data_columns.iter().all(|c| c.is_static())
&& all_contents_are_static
&& any_selected_data_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.")?;
py_rerun_warn("RecordingView::select: tried to select static data, but no non-static contents generated an index value on this timeline. No results will be returned. Either include non-static data or consider using `select_static()` instead.")?;
}

let schema = query_handle.schema();
Expand Down

0 comments on commit 19b2f95

Please sign in to comment.