Changeset: 0d78b2cf7a46 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/0d78b2cf7a46
Modified Files:
sql/server/rel_statistics.c
sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.test
sql/test/BugTracker-2017/Tests/sqlitelogictest-aggregation-having-avg.Bug-6428.test
sql/test/BugTracker-2021/Tests/plan-not-optimal-view.Bug-7140.test
sql/test/miscellaneous/Tests/simple_plans.test
Branch: properties
Log Message:
Propagate statistics on grouping columns
diffs (110 lines):
diff --git a/sql/server/rel_statistics.c b/sql/server/rel_statistics.c
--- a/sql/server/rel_statistics.c
+++ b/sql/server/rel_statistics.c
@@ -599,6 +599,8 @@ rel_get_statistics_(visitor *v, sql_rel
case op_project:
case op_groupby:
case op_ddl:
+ if (is_groupby(rel->op) && !list_empty(rel->r))
+ rel->r = exps_exp_visitor_bottomup(v, rel, rel->r, 0,
&rel_propagate_statistics, false);
rel->exps = exps_exp_visitor_bottomup(v, rel, rel->exps, 0,
&rel_propagate_statistics, false);
if (is_simple_project(rel->op) && !list_empty(rel->r))
rel->r = exps_exp_visitor_bottomup(v, rel, rel->r, 0,
&rel_propagate_statistics, false);
diff --git a/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.test
b/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.test
--- a/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.test
+++ b/sql/test/BugTracker-2011/Tests/crash_on_alias.Bug-2798.test
@@ -14,7 +14,7 @@ SELECT a as d, MIN(b), (2 * (MIN(b) / (S
project (
| group by (
| | table("sys"."dbg") [ "dbg"."a" UNIQUE, "dbg"."b" UNIQUE ]
-| ) [ "dbg"."a" as "d" ] [ "d", "sys"."min" no nil ("dbg"."b" UNIQUE) as
"%1"."%1" ]
+| ) [ "dbg"."a" UNIQUE as "d" ] [ "d", "sys"."min" no nil ("dbg"."b" UNIQUE)
as "%1"."%1" ]
) [ "d" UNIQUE, "%1"."%1", "sys"."sql_mul"("sys"."sql_div"("%1"."%1",
tinyint(2) "2"), tinyint(2) "2") as "f" ]
statement ok
@@ -49,7 +49,7 @@ SELECT a as d, MIN(b) as e, (2 * (MIN(b)
project (
| group by (
| | table("sys"."dbg") [ "dbg"."a" UNIQUE, "dbg"."b" UNIQUE ]
-| ) [ "dbg"."a" as "d" ] [ "d", "sys"."min" no nil ("dbg"."b" UNIQUE) as
"%1"."%1" ]
+| ) [ "dbg"."a" UNIQUE as "d" ] [ "d", "sys"."min" no nil ("dbg"."b" UNIQUE)
as "%1"."%1" ]
) [ "d" UNIQUE, "%1"."%1" as "e", "sys"."sql_mul"("sys"."sql_div"("%1"."%1",
tinyint(2) "2"), tinyint(2) "2") as "f" ]
statement ok
diff --git
a/sql/test/BugTracker-2017/Tests/sqlitelogictest-aggregation-having-avg.Bug-6428.test
b/sql/test/BugTracker-2017/Tests/sqlitelogictest-aggregation-having-avg.Bug-6428.test
---
a/sql/test/BugTracker-2017/Tests/sqlitelogictest-aggregation-having-avg.Bug-6428.test
+++
b/sql/test/BugTracker-2017/Tests/sqlitelogictest-aggregation-having-avg.Bug-6428.test
@@ -21,7 +21,7 @@ project (
| | | | select (
| | | | | table("sys"."tab0") [ "tab0"."col0" UNIQUE as "cor0"."col0",
"tab0"."col1" UNIQUE as "cor0"."col1" ]
| | | | ) [ ("cor0"."col0" UNIQUE) * = (int(32) NULL) ]
-| | | ) [ "cor0"."col1", "cor0"."col0" ] [ "cor0"."col1" UNIQUE, "cor0"."col0"
UNIQUE ]
+| | | ) [ "cor0"."col1" UNIQUE, "cor0"."col0" UNIQUE ] [ "cor0"."col1" UNIQUE,
"cor0"."col0" UNIQUE ]
| | ) [ "cor0"."col1" UNIQUE, "cor0"."col0" UNIQUE ] [ "cor0"."col1" UNIQUE,
"cor0"."col0" UNIQUE, "sys"."avg" no nil ("cor0"."col0" UNIQUE) as "%1"."%1" ]
| ) [ ("sys"."sql_add"(double(53)["sys"."sql_neg"("cor0"."col1" UNIQUE)],
"%1"."%1")) ! * = (double(53) NULL) ]
) [ "sys"."sql_neg"("cor0"."col0" UNIQUE) as "col1" ]
diff --git a/sql/test/BugTracker-2021/Tests/plan-not-optimal-view.Bug-7140.test
b/sql/test/BugTracker-2021/Tests/plan-not-optimal-view.Bug-7140.test
--- a/sql/test/BugTracker-2021/Tests/plan-not-optimal-view.Bug-7140.test
+++ b/sql/test/BugTracker-2021/Tests/plan-not-optimal-view.Bug-7140.test
@@ -65,16 +65,16 @@ project (
| | | | | | | table("sys"."plantest0") [ "plantest0"."id" ]
| | | | | | ) [ ("plantest0"."id") >= (bigint(64) "150000000") ]
| | | | | ) [ "sys"."sql_div"("plantest0"."id" NOT NULL, int(24) "10000000")
NOT NULL as "t"."id_r" ]
-| | | | ) [ "t"."id_r" ] [ "t"."id_r" NOT NULL, "sys"."count" no nil
("t"."id_r" NOT NULL) NOT NULL as "%6"."%6" ],
+| | | | ) [ "t"."id_r" NOT NULL ] [ "t"."id_r" NOT NULL, "sys"."count" no nil
("t"."id_r" NOT NULL) NOT NULL as "%6"."%6" ],
| | | | group by (
| | | | | project (
| | | | | | select (
| | | | | | | table("sys"."plantest1") [ "plantest1"."id" ]
| | | | | | ) [ ("plantest1"."id") >= (bigint(64) "150000000") ]
| | | | | ) [ "sys"."sql_div"("plantest1"."id" NOT NULL, int(24) "10000000")
NOT NULL as "t"."id_r" ]
-| | | | ) [ "t"."id_r" ] [ "t"."id_r" NOT NULL, "sys"."count" no nil
("t"."id_r" NOT NULL) NOT NULL as "%6"."%6" ]
+| | | | ) [ "t"."id_r" NOT NULL ] [ "t"."id_r" NOT NULL, "sys"."count" no nil
("t"."id_r" NOT NULL) NOT NULL as "%6"."%6" ]
| | | ) [ "t"."id_r" NOT NULL, "%6"."%6" NOT NULL ]
-| | ) [ "t"."id_r" ] [ "t"."id_r" NOT NULL, "sys"."sum" no nil ("%6"."%6" NOT
NULL) NOT NULL as "%6"."%6" ]
+| | ) [ "t"."id_r" NOT NULL ] [ "t"."id_r" NOT NULL, "sys"."sum" no nil
("%6"."%6" NOT NULL) NOT NULL as "%6"."%6" ]
| ) [ "sys"."sql_mul"("t"."id_r" NOT NULL UNIQUE, int(24) "10000000") NOT NULL
as "id_range_base", "%6"."%6" NOT NULL as "nrows", "t"."id_r" NOT NULL UNIQUE ]
) [ "id_range_base" NOT NULL, "nrows" NOT NULL ] [ "t"."id_r" ASC NOT NULL
UNIQUE ]
@@ -127,7 +127,7 @@ project (
| | | | | | | ) [ ("plantest0"."id") >= (bigint(64) "150000000") ]
| | | | | | ) [ "sys"."sql_div"("plantest0"."id" NOT NULL, int(24) "10000000")
NOT NULL as "v"."id_div" ]
| | | | | ) [ "v"."id_div" NOT NULL as "t"."id_r" ]
-| | | | ) [ "t"."id_r" ] [ "t"."id_r" NOT NULL, "sys"."count" no nil
("t"."id_r" NOT NULL) NOT NULL as "%6"."%6" ],
+| | | | ) [ "t"."id_r" NOT NULL ] [ "t"."id_r" NOT NULL, "sys"."count" no nil
("t"."id_r" NOT NULL) NOT NULL as "%6"."%6" ],
| | | | group by (
| | | | | project (
| | | | | | project (
@@ -136,9 +136,9 @@ project (
| | | | | | | ) [ ("plantest1"."id") >= (bigint(64) "150000000") ]
| | | | | | ) [ "sys"."sql_div"("plantest1"."id" NOT NULL, int(24) "10000000")
NOT NULL as "v"."id_div" ]
| | | | | ) [ "v"."id_div" NOT NULL as "t"."id_r" ]
-| | | | ) [ "t"."id_r" ] [ "t"."id_r" NOT NULL, "sys"."count" no nil
("t"."id_r" NOT NULL) NOT NULL as "%6"."%6" ]
+| | | | ) [ "t"."id_r" NOT NULL ] [ "t"."id_r" NOT NULL, "sys"."count" no nil
("t"."id_r" NOT NULL) NOT NULL as "%6"."%6" ]
| | | ) [ "t"."id_r" NOT NULL, "%6"."%6" NOT NULL ]
-| | ) [ "t"."id_r" ] [ "t"."id_r" NOT NULL, "sys"."sum" no nil ("%6"."%6" NOT
NULL) NOT NULL as "%6"."%6" ]
+| | ) [ "t"."id_r" NOT NULL ] [ "t"."id_r" NOT NULL, "sys"."sum" no nil
("%6"."%6" NOT NULL) NOT NULL as "%6"."%6" ]
| ) [ "sys"."sql_mul"("t"."id_r" NOT NULL UNIQUE, int(24) "10000000") NOT NULL
as "id_range_base", "%6"."%6" NOT NULL as "nrows", "t"."id_r" NOT NULL UNIQUE ]
) [ "id_range_base" NOT NULL, "nrows" NOT NULL ] [ "t"."id_r" ASC NOT NULL
UNIQUE ]
diff --git a/sql/test/miscellaneous/Tests/simple_plans.test
b/sql/test/miscellaneous/Tests/simple_plans.test
--- a/sql/test/miscellaneous/Tests/simple_plans.test
+++ b/sql/test/miscellaneous/Tests/simple_plans.test
@@ -599,7 +599,7 @@ project (
| | select (
| | | [ [ tinyint(2) "1", tinyint(2) "2", tinyint(2) "3" ] as "x"."x" ]
| | ) [ ("x"."x") > (tinyint(2) "2") ]
-| ) [ "x"."x" ] [ "x"."x" NOT NULL ]
+| ) [ "x"."x" NOT NULL ] [ "x"."x" NOT NULL ]
) [ tinyint(1) "1" ]
query T nosort
@@ -610,7 +610,7 @@ project (
| | select (
| | | [ [ tinyint(2) "1", tinyint(2) "2", tinyint(2) "3" ] as "x"."x" ]
| | ) [ ("x"."x") > (tinyint(2) "2") ]
-| ) [ "x"."x" ] [ "sys"."max" no nil ("x"."x" NOT NULL) NOT NULL as "%5"."%5" ]
+| ) [ "x"."x" NOT NULL ] [ "sys"."max" no nil ("x"."x" NOT NULL) NOT NULL as
"%5"."%5" ]
) [ "%5"."%5" NOT NULL as "x"."y" ]
# here the select cannot be pushed down
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]