{"record":{"id":"c40653fb73c23074","repo":"t8y2/dbx","slug":"cassandra-table-has-no-partition-key-s-s","errorCode":null,"errorMessage":"Cassandra table has no partition key: %s.%s","messagePattern":"Cassandra table has no partition key: (.+?)\\.(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/cassandra-go/metadata.go","lineNumber":449,"sourceCode":"\tmetadata, err := s.tableMetadata(schema, table)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn tableDDLFromMetadata(schema, table, metadata)\n}\n\nfunc tableDDLFromMetadata(schema, table string, metadata *gocql.TableMetadata) (string, error) {\n\tdefinitions := make([]string, 0, len(metadata.Columns)+1)\n\tfor _, name := range orderedColumnNames(metadata) {\n\t\tcolumn := metadata.Columns[name]\n\t\tif column != nil {\n\t\t\tdefinitions = append(definitions, \"  \"+quoteCQLIdentifier(column.Name)+\" \"+cqlTypeName(column.Type))\n\t\t}\n\t}\n\tpartitionKeys := metadataColumnNames(metadata.PartitionKey)\n\tclusteringKeys := metadataColumnNames(metadata.ClusteringColumns)\n\tif len(partitionKeys) == 0 {\n\t\treturn \"\", fmt.Errorf(\"Cassandra table has no partition key: %s.%s\", schema, table)\n\t}\n\tprimaryParts := make([]string, 0, len(clusteringKeys)+1)\n\tif len(partitionKeys) == 1 {\n\t\tprimaryParts = append(primaryParts, quoteCQLIdentifier(partitionKeys[0]))\n\t} else {\n\t\tquoted := make([]string, len(partitionKeys))\n\t\tfor index, name := range partitionKeys {\n\t\t\tquoted[index] = quoteCQLIdentifier(name)\n\t\t}\n\t\tprimaryParts = append(primaryParts, \"(\"+strings.Join(quoted, \", \")+\")\")\n\t}\n\tfor _, name := range clusteringKeys {\n\t\tprimaryParts = append(primaryParts, quoteCQLIdentifier(name))\n\t}\n\tdefinitions = append(definitions, \"  PRIMARY KEY (\"+strings.Join(primaryParts, \", \")+\")\")\n\tddl := \"CREATE TABLE \" + quoteCQLIdentifier(schema) + \".\" + quoteCQLIdentifier(table) + \" (\\n\" + strings.Join(definitions, \",\\n\") + \"\\n)\"\n\torders := make([]string, 0, len(metadata.ClusteringColumns))\n\tfor _, column := range metadata.ClusteringColumns {","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/cassandra-go/metadata.go#L431-L467","documentation":"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.","triggerScenarios":"Thrown at agents/drivers/cassandra-go/metadata.go:449 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}