Changeset: ac56f9c146f1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ac56f9c146f1
Modified Files:
sql/server/rel_select.c
sql/test/BugTracker-2015/Tests/quantile_function_resolution.Bug-3773.stable.out
sql/test/BugTracker-2017/Tests/null-quantile.Bug-6218.stable.out
Branch: Jul2017
Log Message:
fixed bug 6287, ie incase of numeric multi argument aggregators up
cast all arguments to the largest type, when resolving the aggregator.
diffs (112 lines):
diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c
--- a/sql/server/rel_select.c
+++ b/sql/server/rel_select.c
@@ -3441,22 +3441,53 @@ static sql_exp *
a = sql_bind_aggr_(sql->sa, s, aname, exp_types(sql->sa, exps));
if (!a && list_length(exps) > 1) {
- a = sql_bind_member_aggr(sql->sa, s, aname,
exp_subtype(exps->h->data), list_length(exps));
- if (a) {
- node *n, *op = a->aggr->ops->h;
- list *nexps = sa_list(sql->sa);
-
- for (n = exps->h ; a && op && n; op = op->next, n =
n->next ) {
- sql_arg *arg = op->data;
- sql_exp *e = n->data;
-
- e = rel_check_type(sql, &arg->type, e,
type_equal);
- if (!e)
- a = NULL;
- list_append(nexps, e);
+ sql_subtype *t1 = exp_subtype(exps->h->data);
+
+ if (!EC_NUMBER(t1->type->eclass) || list_length(exps) != 2) {
+ a = sql_bind_member_aggr(sql->sa, s, aname,
exp_subtype(exps->h->data), list_length(exps));
+ if (a) {
+ node *n, *op = a->aggr->ops->h;
+ list *nexps = sa_list(sql->sa);
+
+ for (n = exps->h ; a && op && n; op = op->next,
n = n->next ) {
+ sql_arg *arg = op->data;
+ sql_exp *e = n->data;
+
+ e = rel_check_type(sql, &arg->type, e,
type_equal);
+ if (!e)
+ a = NULL;
+ list_append(nexps, e);
+ }
+ if (a && list_length(nexps)) /* count(col) has
|exps| != |nexps| */
+ exps = nexps;
+ }
+ } else {
+ sql_exp *l = exps->h->data, *ol = l;
+ sql_exp *r = exps->h->next->data, *or = r;
+ sql_subtype *t2 = exp_subtype(r);
+
+ if (rel_convert_types(sql, &l, &r, 1/*fix scale*/,
type_equal) >= 0){
+ list *tps = sa_list(sql->sa);
+
+ t1 = exp_subtype(l);
+ list_append(tps, t1);
+ t2 = exp_subtype(r);
+ list_append(tps, t2);
+ a = sql_bind_aggr_(sql->sa, s, aname, tps);
}
- if (a && list_length(nexps)) /* count(col) has |exps|
!= |nexps| */
+ if (!a) {
+ sql->session->status = 0;
+ sql->errstr[0] = '\0';
+
+ l = ol;
+ r = or;
+ } else {
+ list *nexps = sa_list(sql->sa);
+
+ append(nexps,l);
+ append(nexps,r);
exps = nexps;
+ }
}
}
if (!a) { /* find aggr + convert */
diff --git
a/sql/test/BugTracker-2015/Tests/quantile_function_resolution.Bug-3773.stable.out
b/sql/test/BugTracker-2015/Tests/quantile_function_resolution.Bug-3773.stable.out
---
a/sql/test/BugTracker-2015/Tests/quantile_function_resolution.Bug-3773.stable.out
+++
b/sql/test/BugTracker-2015/Tests/quantile_function_resolution.Bug-3773.stable.out
@@ -35,21 +35,21 @@ Ready.
% .plan # table_name
% rel # name
% clob # type
-% 100 # length
+% 93 # length
project (
| group by (
| | table(sys.x) [ "x"."y" ] COUNT
-| ) [ ] [ sys.quantile no nil (decimal(18,3)["x"."y"] as "x"."y", double
"0.000000") as "L3"."L3" ]
+| ) [ ] [ sys.quantile no nil (double["x"."y"] as "x"."y", double "0.000000")
as "L3"."L3" ]
) [ "L3" as "L4"."L3" ]
#plan select quantile(y, 0) from x;
% .plan # table_name
% rel # name
% clob # type
-% 100 # length
+% 94 # length
project (
| group by (
| | table(sys.x) [ "x"."y" ] COUNT
-| ) [ ] [ sys.quantile no nil (decimal(18,3)["x"."y"] as "x"."y", double
"0.000000") as "L3"."L3" ]
+| ) [ ] [ sys.quantile no nil (tinyint["x"."y"] as "x"."y", double
"0.000000") as "L3"."L3" ]
) [ "L3" as "L4"."L3" ]
#rollback;
diff --git a/sql/test/BugTracker-2017/Tests/null-quantile.Bug-6218.stable.out
b/sql/test/BugTracker-2017/Tests/null-quantile.Bug-6218.stable.out
--- a/sql/test/BugTracker-2017/Tests/null-quantile.Bug-6218.stable.out
+++ b/sql/test/BugTracker-2017/Tests/null-quantile.Bug-6218.stable.out
@@ -81,7 +81,7 @@ Ready.
#select quantile(i,0.5),j from bug6218 group by j order by j;
% sys.L3, sys.bug6218 # table_name
% L2, j # name
-% int, int # type
+% hugeint, int # type
% 1, 1 # length
[ 1, 0 ]
[ NULL, 1 ]
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list