{"record":{"id":"643467003bda7b6a","repo":"apache/cassandra","slug":"the-receiver-table-s-s-specified-by-call-to-func","errorCode":null,"errorMessage":"The receiver table %s.%s specified by call to function %s hasn't been found","messagePattern":"The receiver table (.+?)\\.(.+?) specified by call to function (.+?) hasn't been found","errorType":"exception","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/functions/TokenFct.java","lineNumber":91,"sourceCode":"    public static void addFunctionsTo(NativeFunctions functions)\n    {\n        functions.add(new FunctionFactory(\"token\")\n        {\n            @Override\n            public NativeFunction getOrCreateFunction(List<? extends AssignmentTestable> args,\n                                                      AbstractType<?> receiverType,\n                                                      String receiverKeyspace,\n                                                      String receiverTable)\n            {\n                if (receiverKeyspace == null)\n                    throw new InvalidRequestException(\"No receiver keyspace has been specified for function \" + name);\n\n                if (receiverTable == null)\n                    throw new InvalidRequestException(\"No receiver table has been specified for function \" + name);\n\n                TableMetadata metadata = Schema.instance.getTableMetadata(receiverKeyspace, receiverTable);\n                if (metadata == null)\n                    throw new InvalidRequestException(String.format(\"The receiver table %s.%s specified by call to \" +\n                                                                    \"function %s hasn't been found\",\n                                                                    receiverKeyspace, receiverTable, name));\n\n                return new TokenFct(metadata);\n            }\n\n            @Override\n            protected NativeFunction doGetOrCreateFunction(List<AbstractType<?>> argTypes, AbstractType<?> receiverType)\n            {\n                throw new AssertionError(\"Should be unreachable\");\n            }\n        });\n    }\n}\n","sourceCodeStart":73,"sourceCodeEnd":106,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/functions/TokenFct.java#L73-L106","documentation":"InvalidRequestException from the token() function factory (getOrCreateFunction): the table context the token() call refers to (receiver table in the receiver keyspace) does not exist in schema. token() must be resolved against a real table's partition-key types, so a missing receiver table cannot be prepared. The companion guard rejects a null receiverKeyspace.","triggerScenarios":"SELECT/condition invoking token() against keyspace.table that does not exist on this node — dropped table, typo in name, keyspace not replicated to this datacenter, or query racing a DROP TABLE.","commonSituations":"Stale prepared statements after a table was dropped and recreated with different options; typos or case-sensitivity mistakes in keyspace/table names; multi-DC setups where schema has not propagated yet.","solutions":["Verify the table exists: DESC keyspace; or query system_schema.tables","Correct the keyspace/table spelling (identifiers are case-sensitive unless quoted)","If the table was dropped/recreated, re-prepare statements and retry the query","Wait for schema agreement across the cluster before retrying after DDL"],"exampleFix":"// before\nSELECT * FROM my_ks.mytable WHERE token(pk) > 0;  // NoSuchTable\n// after\nSELECT * FROM my_ks.\"MyTable\" WHERE token(pk) > 0;  // correct quoting/case","handlingStrategy":"validation","validationCode":"ResultSet rs = session.execute(\n  \"SELECT keyspace_name FROM system_schema.tables WHERE keyspace_name=? AND table_name=?\", ks, table);\nif (rs.wasApplied() && rs.all().isEmpty()) throw new IllegalStateException(\"Table \" + ks + \".\" + table + \" does not exist\");","typeGuard":null,"tryCatchPattern":"try { session.execute(query); }\ncatch (InvalidRequestException e) {\n  if (e.getMessage().contains(\"hasn't been found\")) { /* refresh schema, verify table, retry */ }\n  else throw e;\n}","preventionTips":["Verify table existence (or use a schema cache) before queries referencing it","After DROP/CREATE TABLE, re-prepare statements and wait for schema agreement","Watch identifier case-sensitivity; quote names when necessary"],"tags":["cql","function","token","table-not-found","schema"],"backgroundTag":"resource-not-found","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}