Skip to content

Commit

Permalink
Bug/428 (#459)
Browse files Browse the repository at this point in the history
* Fix #428 by considering subtraction of zero column tries to be empty

---------

Co-authored-by: Alex Ivliev <[email protected]>
  • Loading branch information
Alex Ivliev and aannleax authored Apr 2, 2024
1 parent c0515cb commit 6837c95
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nemo-physical/src/tabular/operations/subtract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ impl OperationGenerator for GeneratorSubtract {
return None;
}

if tries_subtract.iter().any(|scan| scan.arity() == 0) {
// If we subtract a non empty zero column trie the result is defined as empty
return None;
}

let mut active_scans = Vec::with_capacity(trie_main.arity() + 1);
active_scans.push(Rc::new(RefCell::new(vec![true; tries_subtract.len()])));

Expand Down
15 changes: 15 additions & 0 deletions resources/testcases/regression/unbound_negation/run.rls
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
%%% Test related to
%%% https://github.com/knowsys/nemo/issues/428
%%%
%%% Previously, subtracting a zero arity table resulted in a crash

Input(-1).

Assert(positive) :- Input(?i), ?i > 0.
Assert(negative) :- Input(?i), ?i < 0.

NonPositive(?r) :- Input(?r), ~Assert(positive).
NonNegative(?r) :- Input(?r), ~Assert(negative).

@export NonPositive :- csv {} .
@export NonNegative :- csv {} .
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-1

0 comments on commit 6837c95

Please sign in to comment.