cube-js/cube · error

unexpected array type when converting to TableValue: {:?}

Error message

unexpected array type when converting to TableValue: {:?}

What it means

TableValue::from_array converts an Arrow array row into a TableValue, downcasting to the concrete array type matching the DataType. If the DataType isn't one of the supported variants (or the array doesn't match), it panics. It marks an unsupported data type reaching the conversion path.

Source

Thrown at rust/cubestore/cubestore/src/table/mod.rs:115

                    .value(row)
                    .into(),
            ),
            DataType::Timestamp(TimeUnit::Microsecond, None) => {
                TableValue::Timestamp(TimestampValue::new(
                    1000 * a
                        .as_any()
                        .downcast_ref::<TimestampMicrosecondArray>()
                        .unwrap()
                        .value(row),
                ))
            }
            DataType::Boolean => TableValue::Boolean(
                a.as_any()
                    .downcast_ref::<BooleanArray>()
                    .unwrap()
                    .value(row),
            ),
            other => panic!(
                "unexpected array type when converting to TableValue: {:?}",
                other
            ),
        }
    }

    /// Render the value as a string, using `column_type` for context-dependent
    /// variants (currently `Decimal` / `Decimal96`, where scale lives on the
    /// column rather than on the value). Falls back to `Display` otherwise.
    pub fn format_with(&self, column_type: &ColumnType) -> String {
        match (self, column_type) {
            (TableValue::Decimal(v), ColumnType::Decimal { scale, .. }) => {
                v.to_string(*scale as u8)
            }
            (TableValue::Decimal96(v), ColumnType::Decimal96 { scale, .. }) => {
                v.to_string(*scale as u8)
            }
            (v, _) => v.to_string(),

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Avoid selecting/returning unsupported types (lists, structs, dictionaries) from CubeStore queries; cast to a supported type (Utf8, Int, Float, Timestamp, Boolean)
  2. Cast unsupported expression results in SQL, e.g. CAST(col AS VARCHAR)
  3. Check CubeStore version — type support is added over time; upgrade if a supported type still fails
  4. Report as a bug with the query if a basic type (e.g. Utf8) is missing from the match

Example fix

// before
SELECT array_agg(id) FROM t; // List type
// after
SELECT CAST(array_agg(id) AS VARCHAR) FROM t;
Defensive patterns

Strategy: type-guard

Validate before calling

fn is_supported(dt: &DataType) -> bool {
    matches!(dt, DataType::Int8 | DataType::Int32 | DataType::Int64 | DataType::Float64 | DataType::Utf8 | DataType::Boolean | DataType::Timestamp(_, _))
}

Type guard

fn supported_array(a: &dyn Array) -> Option<&DataType> {
    let dt = a.data_type();
    if matches!(dt, DataType::List(_) | DataType::Struct(_) | DataType::Dictionary(_, _)) { None } else { Some(dt) }
}

Prevention

When it happens

Trigger: A query or scan produces an Arrow column whose DataType (e.g. Utf8, List, Dictionary, Decimal in older code) is not one of the handled variants in from_array, typically via a DataFusion expression result being converted to TableValue.

Common situations: Using SQL expressions/functions returning types CubeStore doesn't materialize (e.g. LIST/STRUCT); version mismatches between DataFusion and CubeStore changing type mapping; custom scans producing unhandled array types.

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/5556cfded0a3bef4. Report an issue: GitHub.