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

chore: add rule and test #851

Merged
merged 3 commits into from
Jun 7, 2024
Merged
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
42 changes: 42 additions & 0 deletions src/planner/rules/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ fn cancel_rules() -> Vec<Rewrite> { vec![
rw!("limit-null"; "(limit null 0 ?child)" => "?child"),
rw!("order-null"; "(order (list) ?child)" => "?child"),
rw!("filter-true"; "(filter true ?child)" => "?child"),
rw!("filter-false"; "(filter false ?child)" => "(empty ?child)"),
rw!("window-null"; "(window (list) ?child)" => "?child"),
]}

Expand Down Expand Up @@ -582,6 +583,47 @@ mod tests {
rules
}

egg::test_fn! {
cancel_limit,
rules(),
// SELECT name
// FROM student
// WHERE true
// LIMIT 0
"
(proj (list $1.2)
(limit null 0
(filter true
(scan $1 (list $1.1 $1.2) null)
)
))" => "
(proj
(list $1.2)
(scan $1 (list $1.1 $1.2) null))
"
}

egg::test_fn! {
merge_filter,
rules(),
// SELECT name
// FROM student
// LIMIT 10
// Order by name
"
proj (list $1.2)
(limit 10 0
(order (list $1.2)
(scan $1 (list $1.1 $1.2) null)
)
)" => "
proj (list $1.2)
(topn 10 0 (list $1.2)
(scan $1 (list $1.1 $1.2) null)
)
"
}

egg::test_fn! {
predicate_pushdown,
rules(),
Expand Down
Loading