Hi,
Last year, I was looking for the MAL definition of group_concat and
Nik Schuiling gave me the MAL definition which is below.
We compile MonetDB from source and this definition was working on
MonetDB-11.19.9 (Oct2014-SP2). Since this version, there has been a
number of newer versions of MonetDB. So, I was trying to upgrade our
system to the latest version of MonetDB (11.21.13). After the
installation of the newer version, I ran:
select "DataSetId", group_concat("FieldName") from datasetmarkermeta
group by "DataSetId";
from mclient interface and got the following error message:
TypeException:kddart.subgroup_concat[5]:'algebra.uselect' undefined
in: TIDs:any := algebra.uselect(g:bat[:oid,:oid],grpid:oid);
MALException:kddart.subgroup_concat[0]:Error in cloned function
TypeException:user.s2_1[15]:'kddart.subgroup_concat' undefined in:
X_27:bat[:oid,:str] :=
kddart.subgroup_concat(X_26:bat[:oid,:str],X_16:bat[:oid,:oid],r1_16:bat[:oid,:oid],true:bit);
program contains errors
It says algebra.uselect function is not defined. How do I fix this problem?
group_concat MAL definition start
-------------------------------------------
module kddart;
command group_concat(b:bat[:oid,:str]):str
address KDDARTgroup_concat
comment "Mal kddart";
function group_concat(b:bat[:oid, :str]):str;
value := "";
barrier (h, t) := iterator.new(b);
value := value + t;
value := value + "";
redo (h, t) := iterator.next(b);
exit (h, t);
return value;
end group_concat;
function subgroup_concat(b:bat[:oid,:any_1],g:bat[:oid,:oid],e:bat[:oid,:any_2],skip_nils:bit)
:bat[:oid,:str];
nw := aggr.count(e);
nl := calc.lng(nw);
bn := bat.new(:oid, :str, nl);
# check 'e' has some values - this is the list of group IDs in the head
# 'g' is the group to the data BAT head ID mapping
# 'b' is the data column BAT that we are aggregating over
barrier (grpid, t) := iterator.new(e);
# select GID from TID->GID map to get matching TIDs
TIDs := algebra.uselect(g,grpid);
# get DATA for matching TIDs
b_data := algebra.kintersect(b,TIDs);
# aggregate
grpval := group_concat(b_data);
# Store the result for this group
bat.insert(bn, grpid, grpval);
redo (grpid, t) := iterator.next(e);
exit (grpid, t);
return bn;
end subgroup_concat;