Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/452 #457

Merged
merged 3 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions nemo/src/execution/planning/operations/negation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub(crate) fn node_negation(
.iter()
.map(|atom| {
let subtract_markers = variable_translation.operation_table(atom.terms().iter());

let node = subplan_union(
plan,
table_manager,
Expand All @@ -36,9 +37,22 @@ pub(crate) fn node_negation(
subtract_markers.clone(),
);

// We simply apply all constraints to this node
// Constraints which do not reference this atom will be filtered in the physical layer
let node_filtered = node_filter(plan, variable_translation, node, subtracted_filters);
// We only keep those constraints that can be evaluated within the current atom
let filters = subtracted_filters
.iter()
.filter(|filter| {
filter.variables().all(|variable| {
subtract_markers.contains(
variable_translation
.get(variable)
.expect("variable translation must know every variable"),
)
})
})
.cloned()
.collect::<Vec<Constraint>>();

let node_filtered = node_filter(plan, variable_translation, node, &filters);

// The tables may contain columns that are not part of `node_main`.
// These need to be projected away.
Expand Down
2 changes: 0 additions & 2 deletions nemo/src/execution/planning/plan_head_restricted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ impl RestrictedChaseStrategy {
let head_join_atoms = analysis.existential_aux_rule.positive_body().clone();
let head_join_constraints = analysis.existential_aux_rule.positive_constraints().clone();

println!("{:?}, {:?}", head_join_atoms, head_join_constraints);

let aux_head = &analysis.existential_aux_rule.head()[0];
let mut aux_head_order = VariableOrder::new();
let mut used_join_head_variables = HashSet::<Variable>::new();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
%%% Test related to
%%% https://github.com/knowsys/nemo/issues/452
%%%
%%% Previously, an incorrect plan was produced, which lead to a crash.

S(a, b, c).
S(r, r, r).
T(a, b).
T(a, c).

R(?x, ?y, ?z) :-
S(?x, ?y, ?z),
~ T(?x, ?y),
~ T(a, ?z).

R(?x, ?y, ?z) :-
S(?x, ?y, ?z),
~ T(a, ?y),
~ T(a, ?z).

@export R :- csv {} .
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
r,r,r
Loading