risingwavelabs/risingwave · error

expect map(...,...)

Error message

expect map(...,...)

What it means

MapType::from_str parses a textual type name like `map(int,int32)` into a MapType. The parser first verifies the string starts with `map(` and ends with `)`. If not, it throws this error because the input is not syntactically a map type string.

Solutions

  1. Ensure the string starts with `map(` and ends with `)`, e.g. `map(varchar,int)`
  2. Trim whitespace and strip any generic-style angle brackets (`MAP<K,V>`) before parsing
  3. If the string came from a config or catalog, correct the stored type name

Example fix

// before
let ty: MapType = "map<int,int>".parse()?;
// after
let ty: MapType = "map(int,int)".parse()?;
Defensive patterns

Strategy: validation

Validate before calling

fn is_map_type_string(s: &str) -> bool {
    let s = s.trim();
    s.starts_with("map(") && s.ends_with(')')
}

Type guard

fn looks_like_map_type(s: &str) -> bool {
    let s = s.trim();
    s.to_ascii_lowercase().starts_with("map(") && s.ends_with(')')
}

Try / catch

match s.parse::<MapType>() {
    Ok(t) => t,
    Err(e) => { log::warn!("bad map type {s}: {e}"); MapType::try_from_kv(key, value)? }
}

Prevention

When it happens

Trigger: Calling `"map_int".parse::<MapType>()`, `MapType::from_str`, or deserializing a type name from config/catalog DDL where the string is missing the `map(` prefix or closing `)`.

Common situations: Hand-written SQL type strings in migrations or config (e.g. `MAP<INT,INT>` instead of `map(int,int)`), truncated type names read from external catalogs, or typos like `Map(` with wrong casing.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11). Data as JSON: /api/errors/9e507ef4d879e5ab. Report an issue: GitHub.

Appendix: source

Thrown at src/common/src/types/map_type.rs:148

            | DataType::Serial
            | DataType::Int256
            | DataType::Vector(_)
            | DataType::Map(_) => false,
        };
        if !ok {
            Err(format!("invalid map key type: {data_type}"))
        } else {
            Ok(())
        }
    }
}

impl FromStr for MapType {
    type Err = anyhow::Error;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        if !(s.starts_with("map(") && s.ends_with(')')) {
            return Err(anyhow::anyhow!("expect map(...,...)"));
        };
        if let Some((key, value)) = s[4..s.len() - 1].split(',').collect_tuple() {
            let key = key.parse().context("failed to parse map key type")?;
            let value = value.parse().context("failed to parse map value type")?;
            MapType::try_from_kv(key, value).map_err(|e| anyhow::anyhow!(e))
        } else {
            Err(anyhow::anyhow!("expect map(...,...)"))
        }
    }
}

impl std::fmt::Display for MapType {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        write!(f, "map({},{})", self.key(), self.value())
    }
}

View on GitHub (pinned to 6469eb736d)