cube-js/cube · error

Unexpected dimension type: {}

Error message

Unexpected dimension type: {}

What it means

member_type maps a Cube dimension's declared type to the internal MemberType enum. Only number, boolean, string and time are recognized; any other `type` value in the dimension metadata causes a panic.

Source

Thrown at rust/cubesql/cubesql/src/transport/ext.rs:404

        if let Some(_) = self
            .measures
            .iter()
            .find(|m| m.name.eq_ignore_ascii_case(member_name))
        {
            return Some(MemberType::Number);
        }

        if let Some(dimension) = self
            .dimensions
            .iter()
            .find(|m| m.name.eq_ignore_ascii_case(member_name))
        {
            return Some(match dimension.r#type.as_str() {
                "number" => MemberType::Number,
                "boolean" => MemberType::Boolean,
                "string" => MemberType::String,
                "time" => MemberType::Time,
                x => panic!("Unexpected dimension type: {}", x),
            });
        }

        if let Some(_) = self
            .segments
            .iter()
            .find(|m| m.name.eq_ignore_ascii_case(member_name))
        {
            return Some(MemberType::Boolean);
        }
        None
    }
}

pub fn df_data_type_by_column_type(column_type: ColumnType) -> DataType {
    match column_type {
        ColumnType::Int32 | ColumnType::Int64 | ColumnType::Int8 => DataType::Int64,
        ColumnType::String => DataType::Utf8,

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Fix the dimension's type in the data model to one of: number, boolean, string, time
  2. Move the value to a measure or remove the dimension if it isn't one of the supported types
  3. Upgrade CubeSQL/Cube so both sides agree on the supported type vocabulary

Example fix

// before (data model)
dimensions:
  - name: location
    sql: ${TABLE}.location
    type: geo
// after
dimensions:
  - name: location
    sql: ${TABLE}.location
    type: string
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED_DIM_TYPES: [&str; 4] = ["number", "boolean", "string", "time"];
fn validate_schema(schema: &serde_json::Value) -> Result<(), String> {
    for dim in schema["dimensions"].as_array().unwrap_or(&vec![]) {
        let t = dim["type"].as_str().unwrap_or("");
        if !SUPPORTED_DIM_TYPES.contains(&t) {
            return Err(format!("dimension '{}' has unsupported type '{}'", dim["name"], t));
        }
    }
    Ok(())
}

Type guard

fn is_supported_dim_type(t: &str) -> bool {
    matches!(t, "number" | "boolean" | "string" | "time")
}

Prevention

When it happens

Trigger: A data model schema declares a dimension with a type string outside {number, boolean, string, time} (e.g. 'geo', 'bigint', a typo like 'strng') and a meta/transport request calls member_type for that dimension.

Common situations: Hand-written or AI-generated data model files with invalid dimension types; schema from a newer/older Cube version exposing a type this CubeSQL build doesn't know.

Related errors


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