risingwavelabs/risingwave · error · anyhow::Error

ARRAY type missing element type

Error message

ARRAY type missing element type

What it means

When mapping a discovered SeaQL column type to a RisingWave DataType, `SeaType::Array` elements must carry their own `col_type`. If the element type descriptor is `None`, the connector cannot infer the array's element type and throws this error.

Source

Thrown at src/connector/src/connector_common/postgres.rs:696

        SeaType::DoublePrecision => DataType::Float64,
        SeaType::Varchar(_) | SeaType::Char(_) | SeaType::Text => DataType::Varchar,
        SeaType::Bytea => DataType::Bytea,
        SeaType::Timestamp(_) => DataType::Timestamp,
        SeaType::TimestampWithTimeZone(_) => DataType::Timestamptz,
        SeaType::Date => DataType::Date,
        SeaType::Time(_) | SeaType::TimeWithTimeZone(_) => DataType::Time,
        SeaType::Interval(_) => DataType::Interval,
        SeaType::Boolean => DataType::Boolean,
        SeaType::Point => postgres_point_type(),
        SeaType::Uuid => DataType::Varchar,
        SeaType::Xml => DataType::Varchar,
        SeaType::Json => DataType::Jsonb,
        SeaType::JsonBinary => DataType::Jsonb,
        SeaType::Array(def) => {
            let item_type = match def.col_type.as_ref() {
                Some(ty) => sea_type_to_rw_type(ty.as_ref())?,
                None => {
                    return Err(anyhow!("ARRAY type missing element type").into());
                }
            };

            DataType::list(item_type)
        }
        SeaType::PgLsn => DataType::Int64,
        SeaType::Cidr
        | SeaType::Inet
        | SeaType::MacAddr
        | SeaType::MacAddr8
        | SeaType::Int4Range
        | SeaType::Int8Range
        | SeaType::NumRange
        | SeaType::TsRange
        | SeaType::TsTzRange
        | SeaType::DateRange
        | SeaType::Enum(_) => DataType::Varchar,
        SeaType::Line

View on GitHub (pinned to 6469eb736d)

Solutions

  1. Restructure the upstream column to a single-level array with a simple element type (RW supports one nesting level)
  2. Cast the column to `text` upstream and parse it in RisingWave
  3. Avoid unsupported array element types (e.g. arrays of arrays, arrays of records)

Example fix

-- before
CREATE TABLE t (matrix INTEGER[][]);
-- after
CREATE TABLE t (values INTEGER[]);
Defensive patterns

Strategy: type-guard

Validate before calling

fn is_supported_pg_column(sea_type: &SeaQlType) -> bool {
    !matches!(sea_type, SeaType::Array(def) if def.col_type.is_none())
}

Type guard

fn has_array_element_type(t: &SeaType) -> bool {
    matches!(t, SeaType::Array(def) if def.col_type.is_some())
}

Try / catch

let rw_type = sea_type_to_rw_type(&col.col_type).map_err(|e| {
    if e.to_string().contains("ARRAY type missing element type") {
        TypeError::UnsupportedArray(col.name.clone())
    } else { TypeError::Other(e) }
})?;

Prevention

When it happens

Trigger: `sea_type_to_rw_type` encountering an `Array` definition whose inner `col_type` is `None` — typically from schema discovery output that lacks nested element typing (e.g. unusual or nested array columns).

Common situations: Multi-dimensional arrays (e.g. `int[][]`) whose inner type is unresolvable; schema discovery returning partial type info for exotic array columns; older discovery output formats missing element types.

Related errors


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