{"record":{"id":"43c0b92bc2c2d3f6","repo":"run-llama/llama_index","slug":"not-supported","errorCode":null,"errorMessage":"Not supported","messagePattern":"Not supported","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/indices/struct_store/sql.py","lineNumber":146,"sourceCode":"            for node_set in source_to_node.values():\n                data_extractor.insert_datapoint_from_nodes(node_set)\n        return index_struct\n\n    def _insert(self, nodes: Sequence[BaseNode], **insert_kwargs: Any) -> None:\n        \"\"\"Insert a document.\"\"\"\n        data_extractor = SQLStructDatapointExtractor(\n            Settings.llm,\n            self.schema_extract_prompt,\n            self.output_parser,\n            self.sql_database,\n            table_name=self._table_name,\n            table=self._table,\n            ref_doc_id_column=self._ref_doc_id_column,\n        )\n        data_extractor.insert_datapoint_from_nodes(nodes)\n\n    def as_retriever(self, **kwargs: Any) -> BaseRetriever:\n        raise NotImplementedError(\"Not supported\")\n\n    def as_query_engine(\n        self,\n        llm: Optional[LLMType] = None,\n        query_mode: Union[str, SQLQueryMode] = SQLQueryMode.NL,\n        **kwargs: Any,\n    ) -> BaseQueryEngine:\n        # NOTE: lazy import\n        from llama_index.core.indices.struct_store.sql_query import (\n            NLStructStoreQueryEngine,\n            SQLStructStoreQueryEngine,\n        )\n\n        if query_mode == SQLQueryMode.NL:\n            return NLStructStoreQueryEngine(self, **kwargs)\n        elif query_mode == SQLQueryMode.SQL:\n            return SQLStructStoreQueryEngine(self, **kwargs)\n        else:","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/indices/struct_store/sql.py#L128-L164","documentation":"SQLStructStoreIndex.as_retriever() unconditionally raises NotImplementedError('Not supported'). A SQL index answers natural-language questions by generating and executing SQL, which is a query-engine flow, not a node-retrieval flow, so the BaseIndex retriever hook is deliberately disabled. There is no SQL retriever behind this index class; the code path exists only to satisfy the abstract interface.","triggerScenarios":"Calling index.as_retriever() on a SQLStructStoreIndex or GPTVectorStoreIndex alias user confusion; generic framework code that calls as_retriever() on any BaseIndex (e.g. routing code that treats all indexes uniformly); following retriever-based tutorials against a SQL index.","commonSituations":"Porting a VectorStoreIndex pipeline to SQL and keeping the retriever API; libraries that wrap any index with RetrieverQueryEngine(index.as_retriever()).","solutions":["Use index.as_query_engine() instead — SQL indexes are consumed as query engines (NLStructStoreQueryEngine / SQLStructStoreQueryEngine).","If you need retrieval-style access to the underlying rows, query the SQLAlchemy engine directly or use the query engine's response metadata['sql_query'].","If generic code must branch, check isinstance(index, SQLStructStoreIndex) and route it to as_query_engine()."],"exampleFix":"# before\nretriever = index.as_retriever()\nquery_engine = RetrieverQueryEngine(retriever)\n\n# after\nquery_engine = index.as_query_engine()  # NLStructStoreQueryEngine\nresponse = query_engine.query(\"How many cities are there?\")","handlingStrategy":"validation","validationCode":"from llama_index.core.indices.struct_store.sql import SQLStructStoreIndex\n\ndef get_query_engine(index):\n    if isinstance(index, SQLStructStoreIndex):\n        return index.as_query_engine()  # never .as_retriever() on SQL indexes\n    return index.as_query_engine()","typeGuard":"from llama_index.core.indices.struct_store.sql import SQLStructStoreIndex\n\ndef supports_retriever(index) -> bool:\n    return not isinstance(index, SQLStructStoreIndex)","tryCatchPattern":"try:\n    retriever = index.as_retriever()\nexcept NotImplementedError:\n    retriever = None  # fall back to query engine for SQL-backed indexes\n    engine = index.as_query_engine()","preventionTips":["Remember the SQL index contract: query engines only, no retrievers.","In generic routing code, branch on index type before choosing as_retriever vs as_query_engine."],"tags":["sql","api-misuse","retriever","llama-index"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}