Hi
I'm trying to create a simple custom operator to process the result of an outer join in GQI.
I basically want to use the value of the first column if not empty or the second column when the first column is empty.
I have this code, but it's difficult to debug where things go wrong in GQI:
using System;
using Skyline.DataMiner.Analytics.GenericInterface;
using Skyline.DataMiner.Net.Messages;
{
// Arguments
private readonly GQIColumnDropdownArgument _columnArg1;
private readonly GQIColumnDropdownArgument _columnArg2;
private readonly GQIStringArgument _newNameArg;
// Argument values
private GQIColumn _column1;
private GQIColumn _column2;
private string _newName;
// variables
private GQIColumn _mergedColumn;
public MergeOuterJoinKeys()
{
_columnArg1 = new GQIColumnDropdownArgument("Column 1") { IsRequired = true };
_columnArg2 = new GQIColumnDropdownArgument("Column 2") { IsRequired = true };
_newNameArg = new GQIStringArgument("Name of merged column") { IsRequired = true };
}
public GQIArgument[] GetInputArguments()
{
return new GQIArgument[]
{
_columnArg1,
_columnArg2,
_newNameArg,
};
}
public OnArgumentsProcessedOutputArgs OnArgumentsProcessed(OnArgumentsProcessedInputArgs args)
{
_column1 = args.GetArgumentValue(_columnArg1);
_column2 = args.GetArgumentValue(_columnArg2);
_newName = args.GetArgumentValue(_newNameArg);
return default;
}
public void HandleColumns(GQIEditableHeader header)
{
_mergedColumn = new GQIStringColumn(_newName);
header.AddColumns(_mergedColumn);
}
public void HandleRow(GQIEditableRow row)
{
if (!row.TryGetValue(_column1, out string column1String))
{
throw new Exception("Column 1 not found");
}
if (!row.TryGetValue(_column2, out string column2String))
{
throw new Exception("Column 2 not found");
}
GenerateInformationEvent($"Column 1: {column1String}");
GenerateInformationEvent($"Column 2 {column2String}");
string mergedString;
if (column1String.Length > 0)
{
mergedString = column1String;
}
else
{
mergedString = column2String;
}
row.SetValue(_mergedColumn, mergedString);
}
}
Hi Jonas,
Can you try again by adding interface IGQIRowOperator to your class?
That was it, overlooked it. Now it’s working fine, thanks!