dotnet/machinelearning · error · ArgumentException

Strings.MultipleMismatchedValueType (formatted with typeof(l

Error message

Strings.MultipleMismatchedValueType (formatted with typeof(long), typeof(int), typeof(bool))

What it means

ArrowStringDataFrameColumn.Clone validates that the mapIndices column's data type is one of long, int, or bool, since only PrimitiveDataFrameColumn<long>, <int>, or <bool> index maps are supported. Passing any other element type (e.g. string, short, double) makes it impossible to select/reorder rows, so an ArgumentException naming the three accepted types is thrown.

Source

Thrown at src/Microsoft.Data.Analysis/DataFrameColumns/ArrowStringDataFrameColumn.cs:400

            for (long i = 0; i < Length; i++)
                ret.Append(IsValid(i) ? GetBytes(i) : default(ReadOnlySpan<byte>));

            for (long i = 0; i < numberOfNullsToAppend; i++)
                ret.Append(default);

            return ret;
        }

        /// <inheritdoc/>
        protected override DataFrameColumn CloneImplementation(DataFrameColumn mapIndices, bool invertMapIndices = false, long numberOfNullsToAppend = 0)
        {
            ArrowStringDataFrameColumn clone;
            if (!(mapIndices is null))
            {
                Type dataType = mapIndices.DataType;
                if (dataType != typeof(long) && dataType != typeof(int) && dataType != typeof(bool))
                    throw new ArgumentException(String.Format(Strings.MultipleMismatchedValueType, typeof(long), typeof(int), typeof(bool)), nameof(mapIndices));
                if (mapIndices.DataType == typeof(long))
                    clone = CloneImplementation(mapIndices as PrimitiveDataFrameColumn<long>, invertMapIndices);
                else if (dataType == typeof(int))
                    clone = CloneImplementation(mapIndices as PrimitiveDataFrameColumn<int>, invertMapIndices);
                else
                    clone = CloneImplementation(mapIndices as PrimitiveDataFrameColumn<bool>);

                for (long i = 0; i < numberOfNullsToAppend; i++)
                    clone.Append(default);
            }
            else
            {
                clone = Clone(numberOfNullsToAppend);
            }

            return clone;
        }

View on GitHub (pinned to 7b76e69cf9)

Solutions

  1. Pass a PrimitiveDataFrameColumn<long> (or int/bool) as the index map instead of the offending type.
  2. Convert the index column first, e.g. new PrimitiveDataFrameColumn<long>("indices", indices.Select(i => (long)i)).
  3. Use the parameterless Clone() and then Filter(boolColumn) if you meant boolean row selection.
  4. Inspect mapIndices.DataType and branch before calling Clone.

Example fix

// before
col.Clone(doubleIndexColumn);
// after
col.Clone(new PrimitiveDataFrameColumn<long>("idx", doubleIndexColumn.Select(d => (long)d)));
Defensive patterns

Strategy: validation

Validate before calling

if (mapIndices != null && mapIndices.DataType != typeof(long) && mapIndices.DataType != typeof(int) && mapIndices.DataType != typeof(bool))
    throw new ArgumentException($"mapIndices must be PrimitiveDataFrameColumn<long>, <int>, or <bool>; got {mapIndices.DataType.Name}", nameof(mapIndices));

Type guard

bool IsValidIndexMap<T>(DataFrameColumn c) => c is PrimitiveDataFrameColumn<long> || c is PrimitiveDataFrameColumn<int> || c is PrimitiveDataFrameColumn<bool>;

Prevention

When it happens

Trigger: Calling column.Clone(mapIndices) where mapIndices is a PrimitiveDataFrameColumn<T> with T other than long/int/bool, e.g. Clone(otherStringColumn) or a column of shorts/doubles/uints.

Common situations: Passing a filtered column of values instead of indices; using a column whose DataType changed after arithmetic (e.g. double-valued index math); copying code that used another column type as an index map.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of dotnet/machinelearning@7b76e69cf9 (2026-09-11). Data as JSON: /api/errors/692ab6d4f592d6f1. Report an issue: GitHub.