cocoindex-io/cocoindex · error · DorisSchemaError
Invalid identifier: {name}
Error message
Invalid identifier: {name} What it means
Identifiers used in generated SQL (table, column, vector field, database names) must match ^[a-zA-Z_][a-zA-Z0-9_]*$. Anything containing dashes, dots, spaces, unicode, or starting with a digit would allow SQL injection or produce invalid Doris DDL, so _validate_identifier raises DorisSchemaError.
Source
Thrown at python/cocoindex/connectors/doris/_target.py:490
async def close(self) -> None:
if self._session is not None and not self._session.closed:
await self._session.close()
self._session = None
def connect(config: DorisConnectionConfig) -> ManagedConnection:
"""Create a ManagedConnection from a DorisConnectionConfig."""
return ManagedConnection(config=config)
# ============================================================
# SQL helpers
# ============================================================
def _validate_identifier(name: str) -> None:
if not re.match(r"^[a-zA-Z_][a-zA-Z0-9_]*$", name):
raise DorisSchemaError(f"Invalid identifier: {name}")
def _convert_to_key_column_type(doris_type: str) -> str:
if doris_type in ("TEXT", "STRING"):
return "VARCHAR(512)"
return doris_type
def _convert_value_for_doris(value: Any) -> Any:
if value is None:
return None
if isinstance(value, uuid.UUID):
return str(value)
if isinstance(value, float) and math.isnan(value):
return None
if isinstance(value, (list, tuple)):
return [_convert_value_for_doris(v) for v in value]
if isinstance(value, dict):View on GitHub (pinned to e84aa99b32)
Solutions
- Rename the field/column to a valid SQL identifier (letters, digits, underscore; not starting with a digit)
- Use an explicit column name override that is a valid identifier for fields with awkward names
- Sanitize/normalize names (e.g. re.sub to underscores) before building the schema
Example fix
// before class Row: "user-id": str // after class Row: user_id: str = res_schema.field(column_name="user_id")
Defensive patterns
Strategy: validation
Validate before calling
import re
def safe_ident(name):
assert re.fullmatch(r"[a-zA-Z_][a-zA-Z0-9_]*", name), f"bad identifier: {name}"
return name Try / catch
try:
q = build_vector_search_query(table=t, ...)
except (DorisSchemaError, ValueError):
t = re.sub(r"\W", "_", t) Prevention
- Name record fields as valid SQL identifiers
- Provide explicit column_name overrides for awkward field names
- Never pass dotted/quoted names where a bare identifier is expected
When it happens
Trigger: Creating a table whose column names derive from record fields with non-identifier names (e.g. 'user-id', '2nd_col'); calling build_vector_search_query with a table/field name containing hyphens or dots; _execute_delete with a PK column name containing invalid characters.
Common situations: Deriving column names from file names or JSON keys that contain dashes/spaces; using quoted or schema-qualified names like 'db.table' where a bare identifier is expected.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- {identifier_type} cannot be empty
- Invalid {identifier_type}: '{name}'. Must start with a lette
- Invalid BigQuery {kind}: {name!r}
- Invalid vector dimension: {vector_schema.size}
- PK column '{pk}' not in columns: {list(self.columns.keys())}
AI-assisted analysis of cocoindex-io/cocoindex@e84aa99b32 (2026-09-08).
Data as JSON: /api/errors/27979ebc198d9a71.
Report an issue: GitHub.