cocoindex-io/cocoindex · error

Invalid table name format: {table}

Error message

Invalid table name format: {table}

What it means

build_vector_search_query accepts a table name of 'db.table' (2 parts) or a bare table (1 part). Any other number of dot-separated parts (e.g. '' or 'a.b.c') is rejected with ValueError since it cannot be safely quoted as `db`.`table`.

Source

Thrown at python/cocoindex/connectors/doris/_target.py:1404

    table: str,
    vector_field: str,
    query_vector: list[float],
    metric: str = "l2_distance",
    limit: int = 10,
    select_columns: list[str] | None = None,
    where_clause: str | None = None,
) -> str:
    """Build a vector search query for Doris."""
    table_parts = table.split(".")
    if len(table_parts) == 2:
        _validate_identifier(table_parts[0])
        _validate_identifier(table_parts[1])
        quoted_table = f"`{table_parts[0]}`.`{table_parts[1]}`"
    elif len(table_parts) == 1:
        _validate_identifier(table)
        quoted_table = f"`{table}`"
    else:
        raise ValueError(f"Invalid table name format: {table}")

    _validate_identifier(vector_field)

    if metric == "l2_distance":
        distance_fn = "l2_distance_approximate"
        order = "ASC"
    elif metric == "inner_product":
        distance_fn = "inner_product_approximate"
        order = "DESC"
    else:
        if not metric.isidentifier():
            raise ValueError(f"Invalid metric name: {metric}")
        distance_fn = metric
        order = "ASC" if "distance" in metric else "DESC"

    vector_literal = "[" + ", ".join(str(float(v)) for v in query_vector) + "]"

    if select_columns:

View on GitHub (pinned to e84aa99b32)

Solutions

  1. Pass either 'db.table' or plain 'table' — drop the catalog prefix and set the catalog context separately
  2. Strip extra qualification before calling: use only database and table parts
  3. Validate/split the table name before calling the builder

Example fix

// before
build_vector_search_query(table="internal.db.docs", ...)
// after
build_vector_search_query(table="db.docs", ...)
Defensive patterns

Strategy: validation

Validate before calling

parts = table.split(".")
assert len(parts) in (1, 2), f"table must be 'table' or 'db.table': {table}"

Try / catch

try:
    sql = build_vector_search_query(table=table, ...)
except ValueError as e:
    logger.error("Bad table name: %s", e); raise

Prevention

When it happens

Trigger: Passing a fully-qualified name with catalog prefix like 'internal.db.table' (3 parts), an empty string, or a name with stray dots to build_vector_search_query(table=...).

Common situations: Doris 2.x+ multi-catalog setups where users copy the catalog-qualified name; trailing/leading dots from string formatting; accidentally passing a connection string fragment.

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 cocoindex-io/cocoindex@e84aa99b32 (2026-09-08). Data as JSON: /api/errors/313535e12fb63e3c. Report an issue: GitHub.