From a09e26b9173ecdebaa0810df2f48a2f8e1a0de81 Mon Sep 17 00:00:00 2001 From: Zane Shelby Date: Tue, 15 Nov 2022 01:29:54 -0500 Subject: [PATCH 1/2] test: Add more query plan generation tests --- test/inferenceql/query/plan_test.cljc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/inferenceql/query/plan_test.cljc b/test/inferenceql/query/plan_test.cljc index fbc897c..3100cda 100644 --- a/test/inferenceql/query/plan_test.cljc +++ b/test/inferenceql/query/plan_test.cljc @@ -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")) @@ -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")) From a6eca0554240c58d96d60dc56b73f042938bfd27 Mon Sep 17 00:00:00 2001 From: Zane Shelby Date: Tue, 15 Nov 2022 01:30:11 -0500 Subject: [PATCH 2/2] fix: Make aggregation? and column-selection? predicates more robust --- src/inferenceql/query/plan.cljc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/inferenceql/query/plan.cljc b/src/inferenceql/query/plan.cljc index f87a24b..6b1c2f7 100644 --- a/src/inferenceql/query/plan.cljc +++ b/src/inferenceql/query/plan.cljc @@ -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) @@ -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