rust-lang / datafrog

A lightweight Datalog engine in Rust
Apache License 2.0
796 stars 43 forks source link

`Relation::from_antijoin` is broken #39

Closed ecstatic-morse closed 2 years ago

ecstatic-morse commented 3 years ago

Relation::from_antijoin always returns an empty Relation, regardless of its inputs. That's because the antijoin helper, which takes a JoinInput as its first parameter, operates only on recent tuples.

https://github.com/rust-lang/datafrog/blob/5bda2f0d0da74e6d86431cc8e4d439d75bf27f51/src/join.rs#L65-L73

This is correct for variables, but Relations, which don't change during iteration, only have stable tuples. See https://github.com/rust-lang/datafrog/pull/36#issuecomment-898952881 for the reason this must be the case.

To fix this, we should refactor the antijoin helper to work directly on Relations, and pass the proper input from Variable::from_antijoin and Relation::from_antijoin. A regression test is needed as well.

ecstatic-morse commented 2 years ago

Fixed in #42.