Part 6: track why an empty or-join failed.

This commit is contained in:
Richard Newman 2017-04-05 17:49:12 -07:00
parent b693385495
commit 2b61944f09

View file

@ -387,20 +387,24 @@ impl ConjoiningClauses {
// ``` // ```
let mut receptacles = let mut receptacles =
patterns.into_iter() patterns.into_iter()
.filter_map(|pattern| { .map(|pattern| {
let mut receptacle = template.make_receptacle(); let mut receptacle = template.make_receptacle();
println!("Applying pattern with attribute {:?}", pattern.attribute); println!("Applying pattern with attribute {:?}", pattern.attribute);
receptacle.apply_pattern_clause_for_alias(schema, &pattern, &source_alias); receptacle.apply_pattern_clause_for_alias(schema, &pattern, &source_alias);
if receptacle.is_known_empty() { receptacle
println!("Receptacle is empty.");
let reason = receptacle.empty_because;
None
} else {
Some(receptacle)
}
}) })
.peekable(); .peekable();
// Let's see if we can grab a reason if every pattern failed.
// If every pattern failed, we can just take the first!
let reason = receptacles.peek()
.map(|r| r.empty_because.clone())
.unwrap_or(None);
// Filter out empties.
let mut receptacles = receptacles.filter(|receptacle| !receptacle.is_known_empty())
.peekable();
// We need to copy the column bindings from one of the receptacles. Because this is a simple // We need to copy the column bindings from one of the receptacles. Because this is a simple
// or, we know that they're all the same. // or, we know that they're all the same.
// Because we just made an empty template, and created a new alias from the destination CC, // Because we just made an empty template, and created a new alias from the destination CC,
@ -419,8 +423,7 @@ impl ConjoiningClauses {
} }
} else { } else {
// No non-empty receptacles? The destination CC is known-empty, because or([]) is false. // No non-empty receptacles? The destination CC is known-empty, because or([]) is false.
// TODO: get the reason out. self.mark_known_empty(reason.unwrap_or(EmptyBecause::AttributeLookupFailed));
self.mark_known_empty(EmptyBecause::AttributeLookupFailed);
return Ok(()); return Ok(());
} }