Skip to content

Commit c272f85

Browse files
committed
core/incremental: Improve error handling in compiler.rs
1 parent ad06e9f commit c272f85

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

core/incremental/compiler.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -886,13 +886,21 @@ impl DbspCompiler {
886886
// Determine the correct pairing: one column must be from left, one from right
887887
if first_in_left.is_some() && second_in_right.is_some() {
888888
// first is from left, second is from right
889-
let (left_idx, _) = first_in_left.unwrap();
890-
let (right_idx, _) = second_in_right.unwrap();
889+
let (left_idx, _) = first_in_left.ok_or_else(|| {
890+
LimboError::InternalError("first_in_left should exist".to_string())
891+
})?;
892+
let (right_idx, _) = second_in_right.ok_or_else(|| {
893+
LimboError::InternalError("second_in_right should exist".to_string())
894+
})?;
891895
Ok((first_col.clone(), left_idx, second_col.clone(), right_idx))
892896
} else if first_in_right.is_some() && second_in_left.is_some() {
893897
// first is from right, second is from left
894-
let (left_idx, _) = second_in_left.unwrap();
895-
let (right_idx, _) = first_in_right.unwrap();
898+
let (left_idx, _) = second_in_left.ok_or_else(|| {
899+
LimboError::InternalError("second_in_left should exist".to_string())
900+
})?;
901+
let (right_idx, _) = first_in_right.ok_or_else(|| {
902+
LimboError::InternalError("first_in_right should exist".to_string())
903+
})?;
896904
Ok((second_col.clone(), left_idx, first_col.clone(), right_idx))
897905
} else {
898906
// Provide specific error messages for different failure cases
@@ -1276,7 +1284,7 @@ impl DbspCompiler {
12761284
group_by_indices.clone(),
12771285
aggregate_functions.clone(),
12781286
input_column_names.clone(),
1279-
));
1287+
)?);
12801288

12811289
let result_node_id = self.circuit.add_node(
12821290
DbspOperator::Aggregate {
@@ -1421,7 +1429,7 @@ impl DbspCompiler {
14211429
group_by,
14221430
vec![], // Empty aggregates indicates plain DISTINCT
14231431
input_column_names,
1424-
),
1432+
)?,
14251433
);
14261434

14271435
// Add the node to the circuit

0 commit comments

Comments
 (0)