MonetDB: const_aggr_elim - Merges default

2025-01-27 Thread stefanos mavros via checkin-list
Changeset: ddd40ae2fa64 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/ddd40ae2fa64
Modified Files:
sql/test/rel-optimizers/Tests/All
Branch: const_aggr_elim
Log Message:

Merges default


diffs (truncated from 111036 to 300 lines):

diff --git a/MonetDB.spec b/MonetDB.spec
--- a/MonetDB.spec
+++ b/MonetDB.spec
@@ -923,6 +923,7 @@ sed -i 's/1\.2/1.1/' misc/selinux/monetd
 -DWITH_PCRE=ON \
 -DWITH_PROJ=OFF \
 -DWITH_READLINE=ON \
+-DWITH_RTREE=OFF \
 -DWITH_SQLPARSE=OFF \
 -DWITH_VALGRIND=OFF \
 -DWITH_XML2=ON \
diff --git a/clients/Tests/MAL-signatures-hge.test 
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -6,50881 +6,50876 @@ select * from sys.malfunctions() order b
 aggr
 Collect
 command aggr.Collect(X_0:bat[:wkb]):wkb
-wkbCollectAggr;
+wkbCollectAggr
 TODO
 aggr
 MakeLine
 command aggr.MakeLine(X_0:bat[:wkb]):wkb
-wkbMakeLineAggr;
+wkbMakeLineAggr
 Gets a BAT with point or linestring geometries and returns a single linestring 
geometry
 aggr
 all
 command aggr.all(X_0:bat[:any_1]):any_1
-SQLall;
+SQLall
 if all values in b are equal return this, else nil
 aggr
 allnotequal
 pattern aggr.allnotequal(X_0:bat[:any_1], X_1:bat[:any_1]):bit
-SQLallnotequal;
+SQLallnotequal
 if all values in r are not equal to l, return true, else if r has nil, return 
nil, else return false
 aggr
 anyequal
 pattern aggr.anyequal(X_0:any_1, X_1:any_1):bit
-CMDvarEQ;
+CMDvarEQ
 (empty)
 aggr
 anyequal
 pattern aggr.anyequal(X_0:bat[:any_1], X_1:bat[:any_1]):bit
-SQLanyequal;
+SQLanyequal
 if any value in r is equal to l, return true, else if r has nil, return nil, 
else return false
 aggr
 avg
 command aggr.avg(X_0:bat[:bte], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
-AGGRavg13_dbl;
+AGGRavg13_dbl
 Grouped tail average on bte
 aggr
 avg
 command aggr.avg(X_0:bat[:dbl], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
-AGGRavg13_dbl;
+AGGRavg13_dbl
 Grouped tail average on dbl
 aggr
 avg
 command aggr.avg(X_0:bat[:flt], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
-AGGRavg13_dbl;
+AGGRavg13_dbl
 Grouped tail average on flt
 aggr
 avg
 command aggr.avg(X_0:bat[:hge], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
-AGGRavg13_dbl;
+AGGRavg13_dbl
 Grouped tail average on hge
 aggr
 avg
 command aggr.avg(X_0:bat[:int], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
-AGGRavg13_dbl;
+AGGRavg13_dbl
 Grouped tail average on int
 aggr
 avg
 command aggr.avg(X_0:bat[:lng], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
-AGGRavg13_dbl;
+AGGRavg13_dbl
 Grouped tail average on lng
 aggr
 avg
 command aggr.avg(X_0:bat[:sht], X_1:bat[:oid], X_2:bat[:any_1]):bat[:dbl]
-AGGRavg13_dbl;
+AGGRavg13_dbl
 Grouped tail average on sht
 aggr
 avg
 command aggr.avg(X_0:bat[:bte], X_1:bat[:oid], X_2:bat[:any_1], 
X_3:int):bat[:dbl]
-AGGRavg14_dbl;
+AGGRavg14_dbl
 Grouped tail average on bte
 aggr
 avg
 command aggr.avg(X_0:bat[:dbl], X_1:bat[:oid], X_2:bat[:any_1], 
X_3:int):bat[:dbl]
-AGGRavg14_dbl;
+AGGRavg14_dbl
 Grouped tail average on dbl
 aggr
 avg
 command aggr.avg(X_0:bat[:flt], X_1:bat[:oid], X_2:bat[:any_1], 
X_3:int):bat[:dbl]
-AGGRavg14_dbl;
+AGGRavg14_dbl
 Grouped tail average on flt
 aggr
 avg
 command aggr.avg(X_0:bat[:int], X_1:bat[:oid], X_2:bat[:any_1], 
X_3:int):bat[:dbl]
-AGGRavg14_dbl;
+AGGRavg14_dbl
 Grouped tail average on int
 aggr
 avg
 command aggr.avg(X_0:bat[:lng], X_1:bat[:oid], X_2:bat[:any_1], 
X_3:int):bat[:dbl]
-AGGRavg14_dbl;
+AGGRavg14_dbl
 Grouped tail average on lng
 aggr
 avg
 command aggr.avg(X_0:bat[:sht], X_1:bat[:oid], X_2:bat[:any_1], 
X_3:int):bat[:dbl]
-AGGRavg14_dbl;
+AGGRavg14_dbl
 Grouped tail average on sht
 aggr
 avg
 command aggr.avg(X_0:bat[:bte], X_1:bat[:oid], X_2:bat[:any_1]) 
(X_3:bat[:dbl], X_4:bat[:lng])
-AGGRavg23_dbl;
+AGGRavg23_dbl
 Grouped tail average on bte, also returns count
 aggr
 avg
 command aggr.avg(X_0:bat[:dbl], X_1:bat[:oid], X_2:bat[:any_1]) 
(X_3:bat[:dbl], X_4:bat[:lng])
-AGGRavg23_dbl;
+AGGRavg23_dbl
 Grouped tail average on dbl, also returns count
 aggr
 avg
 command aggr.avg(X_0:bat[:flt], X_1:bat[:oid], X_2:bat[:any_1]) 
(X_3:bat[:dbl], X_4:bat[:lng])
-AGGRavg23_dbl;
+AGGRavg23_dbl
 Grouped tail average on flt, also returns count
 aggr
 avg
 command aggr.avg(X_0:bat[:hge], X_1:bat[:oid], X_2:bat[:any_1]) 
(X_3:bat[:dbl], X_4:bat[:lng])
-AGGRavg23_dbl;
+AGGRavg23_dbl
 Grouped tail average on hge, also returns count
 aggr
 avg
 command aggr.avg(X_0:bat[:int], X_1:bat[:oid], X_2:bat[:any_1]) 
(X_3:bat[:dbl], X_4:bat[:lng])
-AGGRavg23_dbl;
+AGGRavg23_dbl
 Grouped tail average on int, also returns count
 aggr
 avg
 command aggr.avg(X_0:bat[:lng], X_1:bat[:oid], X_2:bat[:any_1]) 
(X_3:bat[:dbl], X_4:bat[:lng])
-AGGRavg23_dbl;
+AGGRavg23_dbl
 Grouped tail average on lng, also returns count
 aggr
 avg
 command aggr.avg(X_0:bat[:sht], X_1:bat[:oid], X_2:bat[:any_1]) 
(X_3:bat[:dbl], X_4:bat[:lng])
-AGGRavg23_dbl;
+AGGRavg23_dbl
 Grouped tail average on 

MonetDB: const_aggr_elim - Fixes tests

2025-01-27 Thread stefanos mavros via checkin-list
Changeset: 69030e10166b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/69030e10166b
Modified Files:
sql/test/rel-optimizers/Tests/const-aggr-elim.test
Branch: const_aggr_elim
Log Message:

Fixes tests


diffs (21 lines):

diff --git a/sql/test/rel-optimizers/Tests/const-aggr-elim.test 
b/sql/test/rel-optimizers/Tests/const-aggr-elim.test
--- a/sql/test/rel-optimizers/Tests/const-aggr-elim.test
+++ b/sql/test/rel-optimizers/Tests/const-aggr-elim.test
@@ -59,7 +59,7 @@ project (
 | group by (
 | | table("sys"."baz") [ "baz"."b" NOT NULL ]
 | ) [ "baz"."b" NOT NULL ] [ "baz"."b" NOT NULL ]
-) [ "sys"."sql_add"(tinyint(2) "3", double(53) "1") NOT NULL ]
+) [ "sys"."sql_add"(double(53) "1", tinyint(2) "3") NOT NULL ]
 
 query I rowsort 
 SELECT avg(NULL) FROM baz GROUP BY b
@@ -90,7 +90,7 @@ project (
 | | | table("sys"."baz") [ "baz"."b" NOT NULL ]
 | | ) [ "baz"."b" NOT NULL ] [ "baz"."b" NOT NULL ]
 | ) [ tinyint(2) "3" as "%1"."%1" ]
-) [ "sys"."sql_add"("%1"."%1" NOT NULL, double(53) "1") NOT NULL, 
"sys"."sql_mul"("%1"."%1" NOT NULL, double(53) "10") NOT NULL ]
+) [ "sys"."sql_add"(double(53) "1", "%1"."%1" NOT NULL) NOT NULL, 
"sys"."sql_mul"("%1"."%1" NOT NULL, double(53) "10") NOT NULL ]
 
 query II rowsort
 SELECT avg(3), avg(b) FROM baz GROUP BY b
___
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org


MonetDB: nested - improvements for multisets of simple types

2025-01-27 Thread Niels Nes via checkin-list
Changeset: 4628cfb4100e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4628cfb4100e
Modified Files:
sql/backends/monet5/rel_bin.c
sql/server/rel_exp.c
sql/server/rel_multiset.c
sql/storage/store.c
Branch: nested
Log Message:

improvements for multisets of simple types


diffs (212 lines):

diff --git a/sql/backends/monet5/rel_bin.c b/sql/backends/monet5/rel_bin.c
--- a/sql/backends/monet5/rel_bin.c
+++ b/sql/backends/monet5/rel_bin.c
@@ -2478,7 +2478,7 @@ rel2bin_basetable(backend *be, sql_rel *
} else {
sql_column *c = find_sql_column(t, oname);
 
-   if (c->type.multiset || c->type.type->composite)
+   if (!c || c->type.multiset || c->type.type->composite)
continue;
fcol = c;
col = stmt_col(be, c, multiset?dels:NULL, 
dels->partition);
diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c
--- a/sql/server/rel_exp.c
+++ b/sql/server/rel_exp.c
@@ -3712,7 +3712,7 @@ exp_check_composite_type(mvc *sql, sql_s
 static sql_exp *
 exp_check_multiset_type(mvc *sql, sql_subtype *t, sql_rel *rel, sql_exp *exp, 
check_type tpe)
 {
-   assert(t->type->composite);
+   assert(t->type->composite || t->multiset);
if (!exp_is_rel(exp) && !is_values(exp)) {
sql_subtype *et = exp_subtype(exp);
/* hard code conversion from json allowed */
@@ -3720,7 +3720,9 @@ exp_check_multiset_type(mvc *sql, sql_su
return exp_convert(sql, exp, et, t);
if (et && et->multiset == t->multiset && subtype_cmp(et, t) == 
0)
return exp;
-   return sql_error( sql, 03, SQLSTATE(42000) "cannot convert 
value into composite type '%s'", t->type->base.name);
+   if (t->type->composite)
+   return sql_error( sql, 03, SQLSTATE(42000) "cannot 
convert value into composite type '%s'", t->type->base.name);
+   return sql_error( sql, 03, SQLSTATE(42000) "cannot convert 
value into multiset type '%s[]'", t->type->base.name);
}
 
list *msvals = NULL;
@@ -3757,7 +3759,7 @@ exp_check_type(mvc *sql, sql_subtype *t,
sql_exp* nexp = NULL;
sql_subtype *fromtype = exp_subtype(exp);
 
-   if (t->type->composite) {
+   if (t->type->composite || t->multiset) {
if (t->multiset || !is_row(exp))
return exp_check_multiset_type(sql, t, rel, exp, tpe);
return exp_check_composite_type(sql, t, rel, exp, tpe);
diff --git a/sql/server/rel_multiset.c b/sql/server/rel_multiset.c
--- a/sql/server/rel_multiset.c
+++ b/sql/server/rel_multiset.c
@@ -244,30 +244,39 @@ fm_project_ms(visitor *v, sql_exp *e, sq
e = exp_ref(v->sql, e);
sql_exp *mse = exp_column(v->sql->sa, cn, "rowid", inttype, 1,1, 1, 1);
mse->alias.label = (++label);
-   mse->nid = e->alias.label;
+   mse->nid = mse->alias.label;
append(nexps, mse);
-   for(node *f = t->type->d.fields->h; f; f = f->next) {
-   sql_arg *field = f->data;
+   if (t->type->composite) {
+   for(node *f = t->type->d.fields->h; f; f = f->next) {
+   sql_arg *field = f->data;
 
-   if (field->type.multiset) {
-   sql_alias *nn = a_create(v->sql->sa, field->name);
-   nn->parent = cn;
-   fm_project_ms(v, e, &field->type, nn, nexps);
-   } else {
-   mse = exp_column(v->sql->sa, cn, field->name, 
&field->type, 1,1, 1, 1);
-   mse->alias.label = (++label);
-   mse->nid = e->alias.label;
-   append(nexps, mse);
+   if (field->type.multiset) {
+   sql_alias *nn = a_create(v->sql->sa, 
field->name);
+   nn->parent = cn;
+   fm_project_ms(v, e, &field->type, nn, nexps);
+   } else {
+   mse = exp_column(v->sql->sa, cn, field->name, 
&field->type, 1,1, 1, 1);
+   mse->alias.label = (++label);
+   mse->nid = mse->alias.label;
+   append(nexps, mse);
+   }
}
+   } else {
+   sql_subtype lt = *t;
+   lt.multiset = MS_VALUE;
+   mse = exp_column(v->sql->sa, cn, "elements", <, 1,1, 1, 1);
+   mse->alias.label = (++label);
+   mse->nid = mse->alias.label;
+   append(nexps, mse);
}
mse = exp_column(v->sql->sa, cn, "multisetid", inttype, 1,1, 1, 1);
mse->alias.label = (++label);
-   mse->nid = e->alias.label;
+   mse->nid = mse->alias.label;
append(nexps, mse);
if