{"record":{"id":"9dc11134b80325d5","repo":"dotnet/machinelearning","slug":"type-tostring","errorCode":null,"errorMessage":"type.ToString()","messagePattern":"type\\.ToString\\(\\)","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs","lineNumber":192,"sourceCode":"                return new FloatArray(arrowValueBuffer, arrowNullBuffer, numberOfRows, nullCount, offset);\n            else if (type == typeof(int))\n                return new Int32Array(arrowValueBuffer, arrowNullBuffer, numberOfRows, nullCount, offset);\n            else if (type == typeof(long))\n                return new Int64Array(arrowValueBuffer, arrowNullBuffer, numberOfRows, nullCount, offset);\n            else if (type == typeof(sbyte))\n                return new Int8Array(arrowValueBuffer, arrowNullBuffer, numberOfRows, nullCount, offset);\n            else if (type == typeof(short))\n                return new Int16Array(arrowValueBuffer, arrowNullBuffer, numberOfRows, nullCount, offset);\n            else if (type == typeof(uint))\n                return new UInt32Array(arrowValueBuffer, arrowNullBuffer, numberOfRows, nullCount, offset);\n            else if (type == typeof(ulong))\n                return new UInt64Array(arrowValueBuffer, arrowNullBuffer, numberOfRows, nullCount, offset);\n            else if (type == typeof(ushort))\n                return new UInt16Array(arrowValueBuffer, arrowNullBuffer, numberOfRows, nullCount, offset);\n            else if (type == typeof(byte))\n                return new UInt8Array(arrowValueBuffer, arrowNullBuffer, numberOfRows, nullCount, offset);\n            else\n                throw new NotImplementedException(type.ToString());\n        }\n\n        public new IReadOnlyList<T?> this[long startIndex, int length]\n        {\n            get\n            {\n                if (startIndex >= Length)\n                {\n                    throw new ArgumentOutOfRangeException(nameof(startIndex));\n                }\n                return _columnContainer[startIndex, length];\n            }\n        }\n\n        protected override IReadOnlyList<object> GetValues(long startIndex, int length)\n        {\n            if (startIndex >= Length)\n            {","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.Data.Analysis/PrimitiveDataFrameColumn.cs#L174-L210","documentation":"PrimitiveDataFrameColumn<T>.ToArrowArray throws NotImplementedException(type.ToString()) when the column's DataType has no corresponding Arrow array constructor in the if/else chain (Boolean, SByte/Int16/Int32/Int64, Single/Double, Decimal, DateTime-converted, UInt64, UInt16, UInt8). The message is the type's ToString(), which at least names the offending type, unlike some other throws in this file.","triggerScenarios":"Calling ToArrowArray on a PrimitiveDataFrameColumn<T> whose DataType is not one of the explicitly handled Arrow array types, e.g. char columns or custom struct element types.","commonSituations":"Exporting DataFrames containing char or user-defined-struct columns to Arrow IPC; library version gaps where a primitive's Arrow conversion was not implemented; generic pipeline code that accepts any PrimitiveDataFrameColumn<T>.","solutions":["Restrict Arrow export to columns with DataType in the supported set (bool, byte, sbyte, short, int, long, float, double, decimal, ushort, uint, ulong, DateTime)","Convert unsupported columns (e.g. char) to a supported type before exporting","Skip unsupported columns when building the Arrow record batch / schema","Upgrade Microsoft.Data.Analysis to a version that may cover additional Arrow types"],"exampleFix":"// before\nvar array = charColumn.ToArrowArray(0, (int)charColumn.Length); // NotImplementedException\n// after\nvar intColumn = /* convert char data to PrimitiveDataFrameColumn<int> */;\nvar array = intColumn.ToArrowArray(0, (int)intColumn.Length);","handlingStrategy":"type-guard","validationCode":"static readonly HashSet<Type> ArrowArrayTypes = new() { typeof(bool), typeof(byte), typeof(sbyte), typeof(short), typeof(int), typeof(long), typeof(float), typeof(double), typeof(decimal), typeof(ushort), typeof(uint), typeof(ulong), typeof(DateTime) };\nif (!ArrowArrayTypes.Contains(column.DataType)) throw new NotSupportedException($\"Cannot convert {column.DataType} to an Arrow array\");","typeGuard":"static bool HasArrowArrayMapping(DataFrameColumn col) =>\n    ArrowArrayTypes.Contains(col.DataType);","tryCatchPattern":"try { var arr = column.ToArrowArray(startIndex, numberOfRows); }\ncatch (NotImplementedException ex) { logger.LogWarning(ex, \"No Arrow array mapping for {Type}\", column.DataType); /* skip or convert */ }","preventionTips":["Export only columns whose DataType appears in the supported Arrow type list","Convert char/struct columns to supported primitives before Arrow export","Keep Microsoft.Data.Analysis updated for new Arrow type support"],"tags":["not-implemented","arrow","dataframe","type-mapping"],"backgroundTag":"method-not-implemented","analyzedSha":"7b76e69cf964daeca3f1377af6bc5543284d56c6","analyzedAt":"2026-09-11T12:35:38.930Z","contentChangedAt":"2026-09-11T12:35:38.930Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}