dotnet/machinelearning · error · NotImplementedException
nameof(T)
Error message
nameof(T)
What it means
PrimitiveDataFrameColumn<T>.GetArrowType() throws NotImplementedException(nameof(T)) when the column's generic type parameter T has no mapping to an Apache Arrow type. The method maps supported primitives (including ulong, ushort, DateTime) to Arrow types; any other T reaches the else branch. The message is just the type parameter name, so it identifies T only indirectly.
Source
Thrown at src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs:111
return Int8Type.Default;
else if (typeof(T) == typeof(int))
return Int32Type.Default;
else if (typeof(T) == typeof(long))
return Int64Type.Default;
else if (typeof(T) == typeof(short))
return Int16Type.Default;
else if (typeof(T) == typeof(byte))
return UInt8Type.Default;
else if (typeof(T) == typeof(uint))
return UInt32Type.Default;
else if (typeof(T) == typeof(ulong))
return UInt64Type.Default;
else if (typeof(T) == typeof(ushort))
return UInt16Type.Default;
else if (typeof(T) == typeof(DateTime))
return Date64Type.Default;
else
throw new NotImplementedException(nameof(T));
}
protected internal override Field GetArrowField() => new Field(Name, GetArrowType(), NullCount != 0);
protected internal override int GetMaxRecordBatchLength(long startIndex) => _columnContainer.MaxRecordBatchLength(startIndex);
private int GetNullCount(long startIndex, int numberOfRows)
{
int nullCount = 0;
for (long i = startIndex; i < numberOfRows; i++)
{
if (!IsValid(i))
nullCount++;
}
return nullCount;
}
protected internal override Apache.Arrow.Array ToArrowArray(long startIndex, int numberOfRows)View on GitHub (pinned to 7b76e69cf9)
Solutions
- Only create columns whose element type is an Arrow-supported primitive (bool, byte, char, decimal, double, float, int, long, sbyte, short, uint, ulong, ushort, DateTime)
- Convert unsupported columns to a supported primitive type before Arrow export
- Remove or skip non-primitive columns from the DataFrame before calling the Arrow conversion APIs
- Upgrade the Microsoft.Data.Analysis package in case a newer version added the missing Arrow mapping
Example fix
// before
var col = new PrimitiveDataFrameColumn<MyStruct>("data");
var field = col.GetArrowField(); // NotImplementedException
// after
var col = new PrimitiveDataFrameColumn<int>("data"); // supported Arrow type
var field = col.GetArrowField(); Defensive patterns
Strategy: type-guard
Validate before calling
static readonly HashSet<Type> ArrowSupported = new() { typeof(bool), typeof(byte), typeof(char), typeof(decimal), typeof(double), typeof(float), typeof(int), typeof(long), typeof(sbyte), typeof(short), typeof(uint), typeof(ulong), typeof(ushort), typeof(DateTime) };
if (!ArrowSupported.Contains(column.DataType)) throw new NotSupportedException($"{column.DataType} has no Arrow mapping"); Type guard
static bool IsArrowExportable<T>(PrimitiveDataFrameColumn<T> col) where T : unmanaged =>
col.DataType == typeof(bool) || col.DataType == typeof(byte) || col.DataType == typeof(char)
|| col.DataType == typeof(decimal) || col.DataType == typeof(double) || col.DataType == typeof(float)
|| col.DataType == typeof(int) || col.DataType == typeof(long) || col.DataType == typeof(sbyte)
|| col.DataType == typeof(short) || col.DataType == typeof(uint) || col.DataType == typeof(ulong)
|| col.DataType == typeof(ushort) || col.DataType == typeof(DateTime); Try / catch
try { var field = column.GetArrowField(); }
catch (NotImplementedException) { /* skip column or convert before export */ } Prevention
- Restrict column element types to Arrow-supported primitives
- Filter out non-exportable columns before Arrow/IPC conversion
- Check DataType against the supported set in generic export helpers
When it happens
Trigger: Calling GetArrowField()/GetArrowType() on a PrimitiveDataFrameColumn<T> where T is not one of the explicitly mapped Arrow-supported primitives, e.g. a PrimitiveDataFrameColumn<MyStruct> or T=TimeSpan/bool-dependent conversions.
Common situations: Serializing a DataFrame to Arrow/IPC after building columns with unusual element types; passing custom struct columns into the Arrow export pipeline; library version where a primitive's Arrow mapping was not yet added.
Related errors
- type.ToString()
- {fieldType.Name}
- The method or operation is not implemented.
- NotImplementedException
- offsetBuffer
AI-assisted analysis of dotnet/machinelearning@7b76e69cf9 (2026-09-11).
Data as JSON: /api/errors/bc2ef20c6216c96e.
Report an issue: GitHub.