{"record":{"id":"a7284aaaa7379be5","repo":"bytebase/bytebase","slug":"failed-to-extract-table-source-from-from-clause","errorCode":null,"errorMessage":"failed to extract table source from FROM clause","messagePattern":"failed to extract table source from FROM clause","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/plugin/parser/tidb/query_span_extractor.go","lineNumber":445,"sourceCode":"\tif node.With != nil {\n\t\tpreviousCteOuterLength := len(q.ctes)\n\t\tdefer func() {\n\t\t\tq.ctes = q.ctes[:previousCteOuterLength]\n\t\t}()\n\t\tfor _, cte := range node.With.CTEs {\n\t\t\tcteTableSource, err := q.extractCTE(cte)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tq.ctes = append(q.ctes, cteTableSource)\n\t\t}\n\t}\n\n\tvar fromFieldList []base.TableSource\n\tif node.From != nil {\n\t\ttableSource, err := q.extractTableSourceFromNode(node.From.TableRefs)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"failed to extract table source from FROM clause\")\n\t\t}\n\t\tpreviousTableSourcesFromLength := len(q.tableSourcesFrom)\n\t\tdefer func() {\n\t\t\tq.tableSourcesFrom = q.tableSourcesFrom[:previousTableSourcesFromLength]\n\t\t}()\n\t\tq.tableSourcesFrom = append(q.tableSourcesFrom, tableSource)\n\t\tfromFieldList = append(fromFieldList, tableSource)\n\t}\n\n\tresult := new(base.PseudoTable)\n\tif node.Fields != nil {\n\t\tfor _, field := range node.Fields.Fields {\n\t\t\tif field.WildCard != nil {\n\t\t\t\tif field.WildCard.Table.O == \"\" {\n\t\t\t\t\tvar columns []base.QuerySpanResult\n\t\t\t\t\tfor _, tableSource := range fromFieldList {\n\t\t\t\t\t\tcolumns = append(columns, tableSource.GetQuerySpanResult()...)\n\t\t\t\t\t}","sourceCodeStart":427,"sourceCodeEnd":463,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/backend/plugin/parser/tidb/query_span_extractor.go#L427-L463","documentation":"Wrapper error raised in extractSelect: the extractor failed to compute a table source for a SELECT statement's FROM clause. The underlying failure is inside extractTableSourceFromNode on the FROM TableRefs, so the select's lineage cannot be derived.","triggerScenarios":"Any analyzed SELECT (top-level or nested, e.g. inside a CTE, subquery, or FROM-clause extraction like errors 3290/3292) whose FROM refs fail extraction — unknown tables, unsupported joins, derived tables that themselves error.","commonSituations":"Lineage analysis over SQL referencing tables absent from schema metadata; deeply nested derived tables; dialect constructs unsupported by the TiDB AST span extractor.","solutions":["Inspect the wrapped cause error to find the exact FROM-clause construct that failed.","Ensure every table in FROM exists in the supplied schema metadata / catalog.","Simplify the FROM clause (inline derived tables, remove unsupported join types) and retry.","If nested, fix the inner extraction failure reported by the cause chain first."],"exampleFix":"// before: FROM references unknown table\nSELECT * FROM does_not_exist;\n// after: use a resolvable table or register it in metadata\nSELECT * FROM employees;","handlingStrategy":"try-catch","validationCode":"// check each table in the FROM clause is present in the schema metadata before extraction","typeGuard":null,"tryCatchPattern":"src, err := q.extractSelect(node)\nif err != nil {\n    if strings.Contains(err.Error(), \"FROM clause\") {\n        log.Warnf(\"FROM extraction failed: %v\", err)\n        return emptySpan\n    }\n    return err\n}","preventionTips":["Register all analyzed tables in schema metadata before lineage runs","Avoid unsupported FROM constructs or normalize them first","Inspect the wrapped cause chain to fix inner failures first"],"tags":["sql","lineage","query-span","from-clause"],"backgroundTag":"sql-analysis-failed","analyzedSha":"1870550677fe08f0d2a78c07acd27541464eb945","analyzedAt":"2026-09-06T21:16:13.665Z","contentChangedAt":"2026-09-06T21:16:13.665Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}