Passing 3rd argument in IntermediateAggs
Hi,
Based on the
I wrote below code.
virtual void initAggregate(ServerInterface &si, IntermediateAggs &aggs)
{ try{
VString &arg1 = aggs.getStringRef(0);
arg1.setNull();
VString &arg2 = aggs.getStringRef(1);
arg2.setNull();
VString &arg3 = aggs.getStringRef(2);
arg3.setNull();
}catch(std::exception &e) {
vt_report_error(0, "Exception while initializing intermediate aggregates: [% s]", e.what());
}
}
The problem is I’ll have 3 arguments to pass around between aggregate to combine function instead of 2. I’m getting an exception because of “VString &arg3 = aggs.getStringRef(2);”
error code: 0, message: Exception while initializing intermediate aggregates: [vector::_M_range_check]
LOCATION: initAgg, /scratch_a/release/svrtar4536/vbuild/vertica/EE/Functions/UserDefinedAggregate.cpp:143
My requirement is to pass 3 arguments, how can I do this?
0
Comments
You need to specify the third intermediate in the AggregateFunctionFactory class -
virtual void getIntermediateTypes(ServerInterface &srvInterface,
const SizedColumnTypes &inputTypes,
SizedColumnTypes &intermediateTypeMetaData)
{
const VerticaType &inType = inputTypes.getColumnType(0);
intermediateTypeMetaData.addNumeric(interPrec, inType.getNumericScale());
intermediateTypeMetaData.addInt();
// Add your 3rd type here...
}
got the answer we need define it in . the getIntermediateTypes methods