t8y2/dbx · error
Cassandra table has no partition key: %s.%s
Error message
Cassandra table has no partition key: %s.%s
What it means
Returned by tableDDLFromMetadata when generating CQL DDL from gocql table metadata whose PartitionKey list is empty. A Cassandra table always has at least one partition key column; empty metadata means the schema-agreement/metadata fetch was incomplete or the system table views lack key information, so a syntactically valid CREATE TABLE cannot be produced.
Source
Thrown at agents/drivers/cassandra-go/metadata.go:449
metadata, err := s.tableMetadata(schema, table)
if err != nil {
return "", err
}
return tableDDLFromMetadata(schema, table, metadata)
}
func tableDDLFromMetadata(schema, table string, metadata *gocql.TableMetadata) (string, error) {
definitions := make([]string, 0, len(metadata.Columns)+1)
for _, name := range orderedColumnNames(metadata) {
column := metadata.Columns[name]
if column != nil {
definitions = append(definitions, " "+quoteCQLIdentifier(column.Name)+" "+cqlTypeName(column.Type))
}
}
partitionKeys := metadataColumnNames(metadata.PartitionKey)
clusteringKeys := metadataColumnNames(metadata.ClusteringColumns)
if len(partitionKeys) == 0 {
return "", fmt.Errorf("Cassandra table has no partition key: %s.%s", schema, table)
}
primaryParts := make([]string, 0, len(clusteringKeys)+1)
if len(partitionKeys) == 1 {
primaryParts = append(primaryParts, quoteCQLIdentifier(partitionKeys[0]))
} else {
quoted := make([]string, len(partitionKeys))
for index, name := range partitionKeys {
quoted[index] = quoteCQLIdentifier(name)
}
primaryParts = append(primaryParts, "("+strings.Join(quoted, ", ")+")")
}
for _, name := range clusteringKeys {
primaryParts = append(primaryParts, quoteCQLIdentifier(name))
}
definitions = append(definitions, " PRIMARY KEY ("+strings.Join(primaryParts, ", ")+")")
ddl := "CREATE TABLE " + quoteCQLIdentifier(schema) + "." + quoteCQLIdentifier(table) + " (\n" + strings.Join(definitions, ",\n") + "\n)"
orders := make([]string, 0, len(metadata.ClusteringColumns))
for _, column := range metadata.ClusteringColumns {View on GitHub (pinned to c0390bff16)
Solutions
- Retry the DDL fetch after schema settles (run a consistent schema query on all nodes)
- Check cluster schema agreement (nodetool describecluster) and repair schema disagreements
- Verify the table still exists and the driver's metadata fetch permissions are intact
- Fetch DDL directly from the cluster's schema tables if metadata remains incomplete
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at agents/drivers/cassandra-go/metadata.go:449 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/c40653fb73c23074.
Report an issue: GitHub.