UDT
[SqlUserDefinedType(typeof(StudentHistoryFormatter))]
public struct StudentHistory
{
public StudentHistory(int i, double? score, string status):this()
{
InstitutionId = i;
Score = score;
Status = status;
}
int InstitutionId { get; set; }
double? Score {get; set; }
string Status { get; set; }
public string Value()
{
return string.Format("{0},{1},{2}", InstitutionId, Score, Status);
}
}
For simplicity I did not even put the class in a namespace. I registered the assembly with the USQL database
USQL
@history =
EXTRACT InstitutionId int,
Score double,
Status string
FROM @"CoreData\Institution\history.csv"
USING Extractors.Csv();
@historyMap =
SELECT InstitutionId,
ARRAY_AGG<StudentHistory>(new StudentHistory(InstitutionId, Score, Status)) AS History
FROM @history
GROUP BY InstitutionId;
Error
Severity Code Description Project File Line Suppression State Error E_CSC_USER_INVALIDCOLUMNTYPE: 'Microsoft.Analytics.Types.Sql.SqlArray' cannot be used as column type. Description: The column type must be a supported scalar, complex or user defined type. Resolution: Ensure the column type is a supported type. For a user defined type, make sure the type is registered, the type name is fully qualified, and the required assembly is referenced by the script.