Skip to content

Make aggregation? and column-selection? predicates more robust #55

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions src/inferenceql/query/plan.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
[node]
(tree/match [node]
[[:selection child & _]] (input-attr child)
[[:scalar-expr-group child]] (input-attr child)
[[:aggregation _aggregator "(" [:star & _] ")"]] nil
[[:aggregation _aggregator "(" _distinct [:star & _] ")"]] nil
[[:aggregation _aggregator "(" child ")"]] (literal/read child)
Expand Down Expand Up @@ -301,7 +302,9 @@
[node]
(tree/match [node]
[[:selection child & _]] (column-selection? child)
[[:scalar-expr-group "(" child ")"]] (column-selection? child)
[[:scalar-expr [:simple-symbol _]]] true
[[:scalar-expr child]] (column-selection? child)
:else false))

(defn ^:private aggregation-plan
Expand Down
4 changes: 4 additions & 0 deletions test/inferenceql/query/plan_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"SELECT * FROM data"
"SELECT x FROM data"
"SELECT (x) FROM data"
"SELECT MAX(x), y FROM data"
"SELECT MAX(x), (y) FROM data"
"SELECT PROBABILITY OF VAR x = x UNDER model FROM data"
"SELECT (PROBABILITY OF VAR x = x UNDER model) FROM data"))

Expand All @@ -29,6 +31,8 @@
"SELECT * FROM data"
"SELECT x FROM data"
"SELECT (x) FROM data"
"SELECT MAX(x), y FROM data"
"SELECT MAX(x), (y) FROM data"
"SELECT PROBABILITY OF x UNDER model FROM data"
"SELECT (PROBABILITY OF x UNDER model) FROM data"))

Expand Down