diff --git a/nemo-physical/src/tabular/operations/filter.rs b/nemo-physical/src/tabular/operations/filter.rs index 2b18bdcd7..eb50ac6a1 100644 --- a/nemo-physical/src/tabular/operations/filter.rs +++ b/nemo-physical/src/tabular/operations/filter.rs @@ -117,15 +117,20 @@ impl GeneratorFilter { /// Helper function that finds the [OperationColumnMarker] used in the given [Filter] /// that appears closest to the end of the given [OperationTable]. - fn find_last_reference(table: &OperationTable, filter: &Filter) -> OperationColumnMarker { + /// + /// Returns `None` if the given filter does not use any values as input. + fn find_last_reference( + table: &OperationTable, + filter: &Filter, + ) -> Option { let references = filter.references(); for marker in table.iter().rev() { if references.contains(marker) { - return *marker; + return Some(*marker); } } - unreachable!("Filter must only use markers from the table.") + None } /// Helper function that takes a list of boolean [Filter]s @@ -139,7 +144,7 @@ impl GeneratorFilter { let mut grouped_filters = HashMap::>::new(); for filter in filters { - let marker = Self::find_last_reference(input, filter); + let marker = Self::find_last_reference(input, filter).unwrap_or(input[0]); grouped_filters.entry(marker).or_default().push(filter); } diff --git a/nemo/src/lib.rs b/nemo/src/lib.rs index 593c1ad89..246ab7f6c 100644 --- a/nemo/src/lib.rs +++ b/nemo/src/lib.rs @@ -1,5 +1,6 @@ //! A fast in-memory rule engine +#![type_length_limit = "5000000000"] #![deny( missing_debug_implementations, missing_copy_implementations, diff --git a/resources/testcases/regression/planning_engine/constants_filter/run.rls b/resources/testcases/regression/planning_engine/constants_filter/run.rls new file mode 100644 index 000000000..f8bc84022 --- /dev/null +++ b/resources/testcases/regression/planning_engine/constants_filter/run.rls @@ -0,0 +1,11 @@ +%%% Test related to +%%% https://github.com/knowsys/nemo/issues/500 +%%% +%%% A panic was caused by having a filter consisting of constants + +pair(1, 2) . +pair(3, 3) . + +equal(?x) :- pair(?x, ?y), c = d . + +@export equal :- csv {} . \ No newline at end of file diff --git a/resources/testcases/regression/planning_engine/constants_filter/run/equal.csv b/resources/testcases/regression/planning_engine/constants_filter/run/equal.csv new file mode 100644 index 000000000..e69de29bb